35 control_mode = CMODE_REMOTE;
41 control_mode = CMODE_REMOTE;
48 SimpleMotorCtrl::SetupVars();
53 var_cmode_cur = RTDBvar( MyFullName(),
"ConMode", CUR_VAR, INT_VARIABLE, 1,1);
55 var_cmode_req = RTDBvar( MyFullName(),
"ConMode", REQ_VAR, INT_VARIABLE, 1,1);
57 catch (AOVarException &e)
59 Logger::get()->log(Logger::LOG_LEV_FATAL,
"%s:%s: %s", __FILE__, __LINE__, e.what().c_str());
60 throw AOException(
"Error creating RTDB variables");
71 SimpleMotor *motor = NULL;
73 if ((
string)ConfigDictionary()[
"MotorType"] ==
string(
"VisAOfilterwheel"))
76 _logger->log( Logger::LOG_LEV_DEBUG,
"This is a VisAO filterwheel");
77 motor =
new VisAOFilterWheel(
this, ConfigDictionary());
85 else motor = SimpleMotorCtrl::CreateMotor();
93 double pos = motor->GetPosition( force);
97 motor->SetPosName(customPos);
105 pos = fmod(pos, _customPos.size());
106 if(pos < 0) pos += _customPos.size();
109 while(
cpos_it != _customPos.end())
111 name = (*cpos_it).first;
112 np = (*cpos_it).second;
113 ll = fmod(np-.25, _customPos.size());
114 if(ll < 0) ll += _customPos.size();
115 ul = fmod(np+.25, _customPos.size());
116 if(ul < 0) ul += _customPos.size();
117 if((pos > ll && pos < ul) || (ul-ll < 0 && (pos < ul || pos > ll)))
125 return "intermediate";
140 type = (*ctype_it).first;
141 np = (*ctype_it).second;
146 if((pos > ll && pos < ul) || (ul-ll < 0 && (pos < ul || pos > ll)))
169 if(cmode >=
control_mode ||
override || cmode == CMODE_NONE)
191 newstate = msgb->Value.Lv[0];
198 cmode = CMODE_REMOTE;
201 cmode = CMODE_REMOTE;
212 cmode = CMODE_SCRIPT;
215 cmode = CMODE_SCRIPT;
235 _logger->log(Logger::LOG_LEV_TRACE,
"In Remote version of PosReqChanged");
239 pos = var->Value.Dv[0];
246 stat = SimpleMotorCtrl::PosReqChanged(pt, var);
248 catch(AOVarException &e)
250 _logger->log(Logger::LOG_LEV_ERROR,
"Exception in %s %i: %s", __FILE__, __LINE__, e.what().c_str());
270 _logger->log(Logger::LOG_LEV_TRACE,
"In Local version of PosReqChanged");
274 pos = var->Value.Dv[0];
281 stat = SimpleMotorCtrl::PosReqChanged(pt, var);
283 catch(AOVarException &e)
285 _logger->log(Logger::LOG_LEV_ERROR,
"Exception in %s %i: %s", __FILE__, __LINE__, e.what().c_str());
305 _logger->log(Logger::LOG_LEV_TRACE,
"In Script version of PosReqChanged");
309 pos = var->Value.Dv[0];
316 stat = SimpleMotorCtrl::PosReqChanged(pt, var);
318 catch(AOVarException &e)
320 _logger->log(Logger::LOG_LEV_ERROR,
"Exception in %s %i: %s", __FILE__, __LINE__, e.what().c_str());
map< std::string, float >::iterator cpos_it
An iterator for accessing the custom pos list.
multimap< int, float > _customTypes
Custom filter types list.
static int control_mode
The current control mode.
virtual SimpleMotor * CreateMotor()
Overridden to test if this is a VisAOFilterWheel.
double getAbortPos()
Exposes the abort Position (_abortPos) for use in PosReqChanged (which is static) ...
static int CModeReqChanged(void *pt, Variable *msgb)
RTDB handler for a control mode change request from the AO Supervisor.
pthread_mutex_t threadMutex
Mutex to lock out other threads during complex operations.
virtual void updatePos(bool force=false)
Update position variables in RTDB.
static int VisAO_PosLocalReqChanged(void *pt, Variable *msgb)
RTDB handler for a position change by the AO Supervisor.
static int VisAO_PosReqChanged(void *pt, Variable *msgb)
RTDB handler for a position change by the AO Supervisor.
int GetType(double pos)
Get the position type from the wheel position.
static int VisAO_PosScriptReqChanged(void *pt, Variable *msgb)
RTDB handler for a position change by the AO Supervisor.
RTDBvar var_cmode_req
The requested control mode in the RTDB.
std::string GetPosName(double pos)
Get the position name from wheel position.
A class to provide VisAO functionality to the adopt motor controller.
pthread_mutex_t threadMutex
Mutex to lock out other threads during complex operations.
void SetupVars()
Virtual function to setup variables in RTDB.
VisAOSimpleMotorCtrl(std::string name, const std::string &conffile)
Standard adopt style config file constructor.
multimap< int, float >::iterator ctype_it
An iterator for accessing the custom pos list.
virtual int request_control(int cmode)
Calls request_control(cmode, 0).
Declarations for the VisAOSimpleMotorCtrl class.
The namespace of VisAO software.
RTDBvar var_cmode_cur
The current control mode in the RTDB.
static int default_control_mode
The default control mode.