27namespace zaberCtrlTest
36 zaberCtrl_test(
const std::string &device )
38 m_configName = device;
39 m_stageName =
"stage";
59 void setStagePosition(
double pos,
double countsPerMillimeter )
62 m_countsPerMillimeter = countsPerMillimeter;
66 void setPresets(
const std::vector<float> &positions,
const std::vector<std::string> &names )
68 m_presetPositions = positions;
69 m_presetNames = names;
73 void setParked(
bool parked )
79 void setStageTelemetry( int8_t moving,
float preset,
float presetTarget )
83 m_preset_target = presetTarget;
87 void setMovingState( int8_t movingState )
89 m_movingState = movingState;
93 void setHomePresetIndex(
int homePresetIndex )
95 m_homePreset = homePresetIndex;
99 int setPresetAliasIndex(
int presetNameIndex )
101 return setPresetNameTracking( presetNameIndex );
105 void clearPresetAliasIndex()
107 clearPresetNameTracking();
111 int activeAliasIndex()
113 return activePresetNameIndex( presetNumber() );
117 std::string activeAliasName()
119 return activePresetName( presetNumber() );
123 std::string telemetryAliasName()
125 return telemetryPresetName();
129 int stageOnPowerOff()
135 int syncPoweredOffTelemetry()
137 return syncPowerOffStageTelemetry();
141 int applyStageState(
const std::string &stageState )
143 pcf::IndiProperty ip;
144 ip.setDevice(
"stest" );
145 ip.setName(
"curr_state" );
146 ip.add( pcf::IndiElement( m_stageName ) );
147 ip[m_stageName].set( stageState );
149 return setCallBack_m_indiP_stageState( ip );
159 int homingState()
const
161 return m_homingState;
165 int8_t movingState()
const
171 float presetValue()
const
177 float presetTargetValue()
const
179 return m_preset_target;
191 #ifdef ZABERCTRL_TEST_DOXYGEN_REF
192 zaberCtrl::newCallBack_m_indiP_pos( pcf::IndiProperty() );
193 zaberCtrl::newCallBack_m_indiP_rawPos( pcf::IndiProperty() );
194 zaberCtrl::setCallBack_m_indiP_stageState( pcf::IndiProperty() );
195 zaberCtrl::activePresetName( 0 );
214SCENARIO(
"Power-off stage telemetry",
"[zaberCtrl]" )
216 zaberCtrl_test zct(
"stest" );
218 zct.setPresets( { -1, 1, 2, 3 }, {
"none",
"one",
"two",
"three" } );
219 zct.setStagePosition( 2.0, 1000.0 );
221 WHEN(
"the stage powers off while parked" )
223 zct.setParked(
true );
224 zct.setStageTelemetry( 0, 2, 2 );
226 REQUIRE( zct.syncPoweredOffTelemetry() == 0 );
227 REQUIRE( zct.presetValue() == 2 );
228 REQUIRE( zct.presetTargetValue() == 2 );
231 WHEN(
"the stage powers off while not parked" )
233 zct.setParked(
false );
234 zct.setStageTelemetry( 0, 2, 2 );
236 REQUIRE( zct.syncPoweredOffTelemetry() == 0 );
237 REQUIRE( zct.presetValue() == 0 );
238 REQUIRE( zct.presetTargetValue() == 0 );
242SCENARIO(
"Homing READY transitions update the controller FSM promptly",
"[zaberCtrl]" )
244 zaberCtrl_test zct(
"stest" );
246 WHEN(
"homing completes without a configured post-home preset move" )
248 zct.setHomePresetIndex( -1 );
250 REQUIRE( zct.applyStageState(
"HOMING" ) == 0 );
252 REQUIRE( zct.homingState() == 1 );
254 REQUIRE( zct.applyStageState(
"READY" ) == 0 );
256 REQUIRE( zct.homingState() == 0 );
259 WHEN(
"homing completes and a post-home preset move is still pending" )
261 zct.setHomePresetIndex( 1 );
263 REQUIRE( zct.applyStageState(
"HOMING" ) == 0 );
265 REQUIRE( zct.homingState() == 1 );
267 REQUIRE( zct.applyStageState(
"READY" ) == 0 );
269 REQUIRE( zct.homingState() == 2 );
273SCENARIO(
"Preset-name aliases follow the selected shared-position preset",
"[zaberCtrl]" )
275 zaberCtrl_test zct(
"stest" );
277 zct.setPresets( { -1, 10, 20, 20 }, {
"none",
"open",
"science",
"focus" } );
278 zct.setStagePosition( 20.0, 1000.0 );
279 zct.setStageTelemetry( 0, 3, 3 );
281 WHEN(
"a specific alias was selected for a shared preset position" )
283 REQUIRE( zct.setPresetAliasIndex( 3 ) == 0 );
285 REQUIRE( zct.activeAliasIndex() == 3 );
286 REQUIRE( zct.activeAliasName() ==
"focus" );
289 WHEN(
"the stage is moving toward a selected alias" )
291 REQUIRE( zct.setPresetAliasIndex( 3 ) == 0 );
292 zct.setMovingState( 1 );
293 zct.setStageTelemetry( 1, 2, 3 );
295 REQUIRE( zct.activeAliasIndex() == 3 );
296 REQUIRE( zct.activeAliasName() ==
"focus" );
299 WHEN(
"no alias is being tracked" )
301 zct.clearPresetAliasIndex();
303 REQUIRE( zct.activeAliasIndex() == 2 );
304 REQUIRE( zct.activeAliasName() ==
"science" );
307 WHEN(
"the alias tracking is cleared on power off" )
309 REQUIRE( zct.setPresetAliasIndex( 3 ) == 0 );
311 REQUIRE( zct.stageOnPowerOff() == 0 );
312 REQUIRE( zct.movingState() == -2 );
313 REQUIRE( zct.presetValue() == 3 );
314 REQUIRE( zct.presetTargetValue() == 3 );
315 REQUIRE( zct.activeAliasIndex() == 3 );
316 REQUIRE( zct.activeAliasName() ==
"focus" );
317 REQUIRE( zct.telemetryAliasName() ==
"focus" );
#define XWCTEST_INDI_SET_CALLBACK(testclass, varname, device, propname)
Catch-2 tests for whether a SET callback properly validates the input property properly.