use rs_teststand_sys::Dispatch;
use crate::Error;
use crate::dispids::sequence_context;
#[derive(Debug)]
pub struct SequenceContext {
dispatch: Box<dyn Dispatch>,
}
impl SequenceContext {
pub(crate) fn new(dispatch: Box<dyn Dispatch>) -> Self {
Self { dispatch }
}
pub fn as_property_object(&self) -> Result<crate::PropertyObject, Error> {
Ok(crate::PropertyObject::new(
self.dispatch
.call(sequence_context::AS_PROPERTY_OBJECT, &[])?
.into_object()?,
))
}
pub fn locals(&self) -> Result<crate::PropertyObject, Error> {
Ok(crate::PropertyObject::new(
self.dispatch.get(sequence_context::LOCALS)?.into_object()?,
))
}
pub fn parameters(&self) -> Result<crate::PropertyObject, Error> {
Ok(crate::PropertyObject::new(
self.dispatch
.get(sequence_context::PARAMETERS)?
.into_object()?,
))
}
pub fn file_globals(&self) -> Result<crate::PropertyObject, Error> {
Ok(crate::PropertyObject::new(
self.dispatch
.get(sequence_context::FILE_GLOBALS)?
.into_object()?,
))
}
pub fn station_globals(&self) -> Result<crate::PropertyObject, Error> {
Ok(crate::PropertyObject::new(
self.dispatch
.get(sequence_context::STATION_GLOBALS)?
.into_object()?,
))
}
pub fn execution(&self) -> Result<crate::Execution, Error> {
Ok(crate::Execution::new(
self.dispatch
.get(sequence_context::EXECUTION)?
.into_object()?,
))
}
pub fn thread(&self) -> Result<crate::Thread, Error> {
Ok(crate::Thread::new(
self.dispatch.get(sequence_context::THREAD)?.into_object()?,
))
}
pub fn sequence_file(&self) -> Result<crate::SequenceFile, Error> {
Ok(crate::SequenceFile::new(
self.dispatch
.get(sequence_context::SEQUENCE_FILE)?
.into_object()?,
))
}
pub fn sequence(&self) -> Result<crate::Sequence, Error> {
Ok(crate::Sequence::new(
self.dispatch
.get(sequence_context::SEQUENCE)?
.into_object()?,
))
}
pub fn call_stack_depth(&self) -> Result<i32, Error> {
Ok(self
.dispatch
.get(sequence_context::CALL_STACK_DEPTH)?
.as_i32()?)
}
pub fn step_index(&self) -> Result<i32, Error> {
Ok(self.dispatch.get(sequence_context::STEP_INDEX)?.as_i32()?)
}
pub fn num_steps_executed(&self) -> Result<i32, Error> {
Ok(self
.dispatch
.get(sequence_context::NUM_STEPS_EXECUTED)?
.as_i32()?)
}
pub fn sequence_failed(&self) -> Result<bool, Error> {
Ok(self
.dispatch
.get(sequence_context::SEQUENCE_FAILED)?
.as_bool()?)
}
pub fn error_reported(&self) -> Result<bool, Error> {
Ok(self
.dispatch
.get(sequence_context::ERROR_REPORTED)?
.as_bool()?)
}
pub fn run_time_error_message(&self) -> Result<String, Error> {
Ok(self
.dispatch
.get(sequence_context::RUN_TIME_ERROR_MESSAGE)?
.into_string()?)
}
pub fn step(&self) -> Result<crate::Step, Error> {
Ok(crate::Step::new(
self.dispatch.get(sequence_context::STEP)?.into_object()?,
))
}
}