INOS
cinoscontrol.h
Go to the documentation of this file.
1 //******************************************************************************
27 //******************************************************************************
28 
29 #ifndef INC_CINOSCONTROL_H
30 #define INC_CINOSCONTROL_H
31 //
32 //------------------------------------------------------------------------------
33 // defines
34 //------------------------------------------------------------------------------
35 //
36 // --- controller states -------------------------------------------------------
37 //
38 #define DF_INOS_CTRL_STATE_UNDEFINED 0 // static state 'undefined'
39 #define DF_INOS_CTRL_STATE_ACTIVE 1 // static state 'active'
40 #define DF_INOS_CTRL_STATE_READY 2 // static state 'ready'
41 #define DF_INOS_CTRL_STATE_PULL 3 // static state 'pull'
42 #define DF_INOS_CTRL_STATE_ACTIVATING 8 // dynamic state 'activating'
43 #define DF_INOS_CTRL_STATE_INACTIVATING 9 // dynamic state 'inactivating'
44 #define DF_INOS_CTRL_STATE_MOVING 11 // dynamic state 'moving'
45 #define DF_INOS_CTRL_STATE_TOGGLE 13 // dynamic state 'toggle'
46 #define DF_INOS_CTRL_STATE_STOPPING 14 // dynamic state 'stopping'
47 #define DF_INOS_CTRL_STATE_TUNING 32 // dynamic state 'tuning'
48 #define DF_INOS_CTRL_STATES 33 // number of states
49 //
50 // --- controller commands -----------------------------------------------------
51 //
52 #define DF_INOS_CTRL_CMD_ACTIVATE 0x00000001 // command 'Activate'
53 #define DF_INOS_CTRL_CMD_INACTIVATE 0x00000002 // command 'InActivate'
54 #define DF_INOS_CTRL_CMD_MOVE 0x00000008 // command 'Move'
55 #define DF_INOS_CTRL_CMD_STOP 0x00000020 // command 'Stop'
56 #define DF_INOS_CTRL_CMD_UPDATE 0x00000200 // command 'Update'
57 #define DF_INOS_CTRL_CMD_TOGGLE 0x00000400 // command 'Toggle'
58 #define DF_INOS_CTRL_CMD_CURSOR 0x00008000 // command 'Cursor'
59 #define DF_INOS_CTRL_CMD_TUNE 0x00010000 // command 'Tune'
60 //
61 // --- controller errors -------------------------------------------------------
62 //
63 #define ER_INOS_CTRL_REJECTED 0x00000001 // command rejected
64 #define ER_INOS_CTRL_FAILED 0x00000002 // command failed
65 #define ER_INOS_CTRL_REMOTE_NOT_FOUND 0x00000004 // remote target not found
66 #define ER_INOS_CTRL_REMOTE_OFFLINE 0x00000008 // remote target offline
67 #define ER_INOS_CTRL_REMOTE_COMM_ERR 0x00000010 // remote target communication error
68 #define ER_INOS_CTRL_REMOTE_REJECTED 0x00000020 // attached to remote, command rejected
69 #define ER_INOS_CTRL_GROUP 0x00000800 // group member on error
70 #define ER_INOS_CTRL_BUS 0x00001000 // fieldbus on error
71 #define ER_INOS_CTRL_TARGET 0x00002000 // target on error
72 #define ER_INOS_CTRL_CONTROL 0x00004000 // control error pending
73 #define ER_INOS_CTRL_RAMP 0x00008000 // ramp error pending
74 #define ER_INOS_CTRL_SAFETY 0x00010000 // safety error pending
75 #define ER_INOS_CTRL_APPLICAT 0x00020000 // application specific error pending
76 
77 #define ER_INOS_CTRL_REMOTE (ER_INOS_CTRL_REMOTE_NOT_FOUND | ER_INOS_CTRL_REMOTE_OFFLINE | ER_INOS_CTRL_REMOTE_COMM_ERR | ER_INOS_CTRL_REMOTE_REJECTED)
78 //
79 // --- controller warnings -----------------------------------------------------
80 //
81 #define WR_INOS_CTRL_RAMP 0x00008000 // ramp warning pending
82 #define WR_INOS_CTRL_CONTROL 0x00004000 // control warning pending
83 #define WR_INOS_CTRL_IGNORED 0x00000001 // command ignored
84 //
85 //------------------------------------------------------------------------------
86 // includes
87 //------------------------------------------------------------------------------
88 //
89 // system
90 #include <cinosbus.h>
91 #include <cinosbaseramp.h>
92 #include <cinosbasecontroller.h>
93 //
94 // C++
95 //
96 // project
97 //
98 //------------------------------------------------------------------------------
99 // class definition
100 //------------------------------------------------------------------------------
101 //
102 class CINOSControl;
104 {
105  //--- user interface ---------------------------------------------------
106 
107  // public member functions
108  public :
109  virtual uint32 SetParam(const char* apName, real64 arValue);
110  //; universal set parameter with aName to aValue and return error code
111  virtual uint32 GetParam(const char* apName, real64& arResult);
112  //; universal get parameter with aName to aResult and return error code
113  virtual CINCOObject* GetRegister(CINOSControl* apControl);
114  //; return pointer to my inco object
115 
116  virtual CINOSBaseRampParamSet* GetRamp() {return m_pRamp;};
117 
118  //--- internals --------------------------------------------------------
119 
120  // my axis is my friend
121  friend class CINOSControl;
122 
123  // public but just for internal use
124  public:
125  int operator < (CINOSControlParamSet& aSet) const
126  { return (strcmp(m_cName, aSet.m_cName)<0);}
127  int operator == (CINOSControlParamSet& aSet) const
128  { return (strcmp(m_cName, aSet.m_cName)==0);}
129  int operator < (const char* apName) const
130  { return (strcmp(m_cName, apName)<0);}
131  int operator == (const char* apName) const
132  { return (strcmp(m_cName, apName)==0);}
133  friend int operator == (CINOSControlParamSet& aSet1, CINOSControlParamSet& aSet2)
134  { return (strcmp(aSet1.m_cName, aSet2.m_cName)==0);}
135 
136  // public but just for internal use
137  public:
138  explicit CINOSControlParamSet(const char* apName);
139  //; constructor
140  virtual ~CINOSControlParamSet();
141  //; destructor
142 
143  // protected members
144  protected:
145  inosName32 m_cName;
146  //; set name
147  CINCOObject* m_pRegister;
148  //; pointer to inco registration of set
149  CINOSBaseRampParamSet* m_pRamp;
150  //; pointer to ramp param set
151 
152  // allow dynamic object handling (new/delete)
153  DECLARE_DYNAMIC(CINOSControlParamSet);
154 };
155 
156 //------------------------------------------------------------------------------
157 // class definition
158 //------------------------------------------------------------------------------
159 //
160 struct SINOSControlErrorHook;
161 struct SINOSCollectedControlData;
162 
164 {
165  //--- user interface ---------------------------------------------------
166 
167  // public member functions
168  public :
169 
170  // constructor/destructor
171 
172  CINOSControl(const char* apName, const char* apRamp,
173  const char* apController, const char* apInpName, const char* apOutName);
174  //; constructor
175  virtual ~CINOSControl();
176  //; destructor
177  static CINOSControl* GetControl(uint32 auIndex);
178  //; return pointer to controller auNumber or NULL if not found
179  static CINOSControl* GetControl(const char* apName);
180  //; return pointer to controller apName or NULL if not found
181  static CINOSControl* Find(const char* apName);
183  static uint32 Add(CINOSControl* apControl);
185  static uint32 Remove(CINOSControl* apControl);
187 
188  virtual uint32 Activate(bool abCheckVal = true, bool abSimulateVal = false,
189  bool abSimulateOut = false, bool abSimulateAct = false,
190  CINOSSync* apSync = DF_INOS_SYNCHRONOUS);
191  //; activate axis
192  virtual uint32 InActivate(CINOSSync* apSync = DF_INOS_SYNCHRONOUS);
193  //; inactivate axis
194  virtual uint32 ReActivate(CINOSSync* apSync = DF_INOS_SYNCHRONOUS);
195  //; reactivate axis
196 
197  virtual void CreateRemoteTargetControl(const char* apTarget,
198  real64 arRemoteUpdateTime,
199  CINOSSync* apSync = DF_INOS_SYNCHRONOUS);
200 
201  virtual void AttachRemoteTargetControl(const char* apTarget,
202  real64 arRemoteUpdateTime,
203  CINOSSync* apSync = DF_INOS_SYNCHRONOUS);
204 
205  virtual uintptr DoCollectData();
206  //; start collecting data in every control cycle
207 
208  // moving functions
209 
210  virtual uint32 Move(real64 arValue,
211  CINOSSync* apSync = DF_INOS_SYNCHRONOUS);
212  //; move to value with commanded jerk, acc/deceleration and velocity
213  virtual uint32 Move(real64 arValue, SINOSRampParam* apParam,
214  CINOSSync* apSync = DF_INOS_SYNCHRONOUS);
215  //; move to value with apParam
216  virtual uint32 Move(real64 arPosition, const char* apParam,
217  CINOSSync* apSync = DF_INOS_SYNCHRONOUS);
218  //; move to value with apParam
219  virtual uint32 Toggle(real64 arvalue, real64 arValue2);
220  //; starts an endless toggle between pos1 and pos2
221  virtual uint32 Update(CINOSSync* apSync = DF_INOS_ASYNCHRONOUS);
222  //; update a running Move to actual commanded values (acc,dec,vel,jerk)
223  //; signal apSync if constant velocity reached (acc = 0)
224  virtual uint32 Update(SINOSRampParam* apParam, CINOSSync* apSync = DF_INOS_ASYNCHRONOUS);
225  //; update a running Move to apParam values (acc,dec,vel,jerk)
226  //; signal apSync if constant velocity reached (acc = 0)
227  virtual uint32 Update(const char* apParam, CINOSSync* apSync = DF_INOS_ASYNCHRONOUS);
228  //; update a running Move to apParam values (acc,dec,vel,jerk)
229  //; signal apSync if constant velocity reached (acc = 0)
230  virtual real64 GetMoveTime(real64 arValue);
231  //; return time [sec] a Move(arValue) needs until arValue
232  virtual real64 GetMoveTime(real64 arValue, SINOSRampParam* apParam);
233  //; return time [sec] a Move(arValue) needs until arValue
234  virtual real64 GetMoveTime(real64 arValue, const char* apParam);
235  //; return time [sec] a Move(arValue) needs until arValue
236  virtual real64 GetMoveTime(real64 arValue, real64 arDelta);
237  //; return time [sec] a Move(arValue) needs until arValue-arDelta
238  virtual real64 GetMoveTime(real64 arValue, real64 arDelta, SINOSRampParam* apParam);
239  //; return time [sec] a Move(arValue) needs until arValue-arDelta
240  virtual real64 GetMoveTime(real64 arValue, real64 arDelta, const char* apParam);
241  //; return time [sec] a Move(arValue) needs until arValue-arDelta
242  virtual real64 GetMoveTime(real64 arStartValue, real64 arEndValue,
243  real64 arDelta);
244  //; return time [sec] a Move needs from arStartValue
245  //; until arEndValue-arDelta
246  virtual real64 GetMoveTime(real64 arStartValue, real64 arEndValue,
247  real64 arDelta, SINOSRampParam* apParam);
248  //; return time [sec] a Move needs from arStartValue
249  //; until arEndValue-arDelta
250  virtual real64 GetMoveTime(real64 arStartValue, real64 arEndValue,
251  real64 arDelta, const char* apParam);
252  //; return time [sec] a Move needs from arStartValue
253  //; until arEndValue-arDelta
254  virtual uint32 GetMoveTicks(real64 arValue);
255  //; return bus ticks a Move(arValue) needs until arValue
256  virtual uint32 GetMoveTicks(real64 arPosition, SINOSRampParam* apParam);
257  //; return bus ticks a Move(adPosition) needs until arValue
258  virtual uint32 GetMoveTicks(real64 arValue, const char* apParam);
259  //; return bus ticks a Move(adPosition) needs until arValue
260  virtual uint32 GetMoveTicks(real64 arValue, real64 arDelta);
261  //; return bus ticks a Move(adPosition) needs until arValue-arDelta
262  virtual uint32 GetMoveTicks(real64 arValue, real64 arDelta, SINOSRampParam* apParam);
263  //; return bus ticks a Move(adPosition) needs until arValue-arDelta
264  virtual uint32 GetMoveTicks(real64 arValue, real64 arDelta, const char* apParam);
265  //; return bus ticks a Move(adPosition) needs until arValue-arDelta
266  virtual uint32 GetMoveTicks(real64 arStartValue, real64 arEndValue,
267  real64 arDelta);
268  //; return bus ticks [sec] a Move needs from arStartValue
269  //; until arEndValue-arDelta
270  virtual uint32 GetMoveTicks(real64 arStartValue, real64 arEndValue,
271  real64 arDelta, SINOSRampParam* apParam);
272  //; return bus ticks [sec] a Move needs from arStartValue
273  //; until arEndValue-arDelta
274  virtual uint32 GetMoveTicks(real64 arStartValue, real64 arEndValue,
275  real64 arDelta, const char* apParam);
276  //; return bus ticks [sec] a Move needs from arStartValue
277  //; until arEndValue-arDelta
278  virtual real64 GetMoveDist(real64 arValue, real64 arTime);
279  //; return distance [unit] a Move(arValue) progresses in arTime [sec]
280  virtual real64 GetMoveDist(real64 arValue, real64 arTime,
281  SINOSRampParam* apParam);
282  //; return distance [unit] a Move(arValue) progresses in arTime [sec]
283  virtual real64 GetMoveDist(real64 arValue, real64 arTime,
284  const char* apParam);
285  //; return distance [unit] a Move(arValue) progresses in arTime [sec]
286  virtual real64 GetMoveDist(real64 arValue, uint32 auTicks);
287  //; return distance [unit] a Move(arValue) progresses in auTicks [bus ticks]
288  virtual real64 GetMoveDist(real64 arValue, uint32 auTicks,
289  SINOSRampParam* apParam);
290  //; return distance [unit] a Move(arValue) progresses in auTicks [bus ticks]
291  virtual real64 GetMoveDist(real64 arValue, uint32 auTicks,
292  const char* apParam);
293  //; return distance [unit] a Move(arValue) progresses in auTicks [bus ticks]
294  virtual real64 GetMoveDist(real64 arStartValue, real64 arEndValue,
295  real64 arTime);
296  //; return distance [unit] a Move from arStartValue to arEndValue
297  //; progresses in arTime [sec]
298  virtual real64 GetMoveDist(real64 arStartValue, real64 arEndValue,
299  real64 arTime, SINOSRampParam* apParam);
300  //; return distance [unit] a Move from arStartValue to arEndValue
301  //; progresses in arTime [sec]
302  virtual real64 GetMoveDist(real64 arStartValue, real64 arEndValue,
303  real64 arTime, const char* apParam);
304  //; return distance [unit] a Move from arStartValue to arEndValue
305  //; progresses in arTime [sec]
306  virtual real64 GetMoveDist(real64 arStartValue, real64 arEndValue,
307  uint32 auTicks);
308  //; return distance [unit] a Move from arStartValue to arEndValue
309  //; progresses in auTicks [bus ticks]
310  virtual real64 GetMoveDist(real64 arStartValue, real64 arEndValue,
311  uint32 auTicks, SINOSRampParam* apParam);
312  //; return distance [unit] a Move from arStartValue to arEndValue
313  //; progresses in auTicks [bus ticks]
314  virtual real64 GetMoveDist(real64 arStartValue, real64 arEndValue,
315  uint32 auTicks, const char* apParam);
316  //; return distance [unit] a Move from arStartValue to arEndValue
317  //; progresses in auTicks [bus ticks]
318  virtual uint64 GetTargetTicks();
319  //; return absolut bus ticks the actual move reaches the target
320 
321  // pulling
322 
323  virtual uint32 Pull(real64 arS, real64 arV, real64 arA, real64 arJ);
324  //; add s, v, a, j to the actual pull list (starts pull if not yet done)
325  virtual void Pull(SINOSRampData& aData);
326  //; add aData to the actual pull list (starts pull if not yet done)
327  virtual void Pull(SINOSRampDataEx* apData);
328  //; add apData to the actual pull list (starts pull if not yet done)
329  //; apData IS deleted after processed
330  void EnableRamp()
331  //; enable ramp geni
332  { m_pRamp->Enable();};
333  void DisableRamp()
334  //; disable ramp geni (needed to be able to fill up pull list without
335  //; starting immediately)
336  { m_pRamp->Disable();};
337 
338  // stop/break/continue functions
339 
340  virtual uint32 Stop(CINOSSync* apSync = DF_INOS_SYNCHRONOUS);
341  //; stop move with acc/deceleration
342  virtual uint32 Stop(SINOSRampParam* apParam, CINOSSync* apSync = DF_INOS_SYNCHRONOUS);
343  //; stop move with acc/deceleration
344  virtual uint32 Stop(const char* apParam, CINOSSync* apSync = DF_INOS_SYNCHRONOUS);
345  //; stop move with acc/deceleration
346  virtual uint32 Stop(real64 arValue,
347  CINOSSync* apSync = DF_INOS_SYNCHRONOUS);
348  //; stop move with acc/deceleration at arValue
349  virtual uint32 Stop(real64 arPosition, SINOSRampParam* apParam,
350  CINOSSync* apSync = DF_INOS_SYNCHRONOUS);
351  //; stop move with acc/deceleration at arPosition
352  virtual uint32 Stop(real64 arValue, const char* apParam,
353  CINOSSync* apSync = DF_INOS_SYNCHRONOUS);
354  //; stop move with acc/deceleration at arValue
355 
356  // tuning
357 
358  virtual uint32 Tune(const char* apParam, CINOSSync* apSync = DF_INOS_SYNCHRONOUS);
359 
360  // get/set property functions
361 
362  virtual const char* GetName();
363  //; return control name
364  virtual const char* GetUnit();
365  //; return control unit
366  virtual uint32 GetCharacteristics();
367  //; return control characteristics
368  virtual void SetCmdValue(real64 arValue);
369  //; set commanded controller value
370  virtual void GetCmdValue(real64& arValue);
371  //; get commanded controller value
372  virtual void SetCmdVelocity(real64 arVelocity);
373  //; set commanded velocity
374  virtual void GetCmdVelocity(real64& arVelocity);
375  //; get commanded velocity
376  virtual void SetCmdAcceleration(real64 arAcceleration);
377  //; set commanded acceleration
378  virtual void GetCmdAcceleration(real64& arAcceleration);
379  //; get commanded acceleration
380  virtual void SetCmdDeceleration(real64 arDeceleration);
381  //; set commanded deceleration
382  virtual void GetCmdDeceleration(real64& arDeceleration);
383  //; get commanded deceleration
384  virtual void SetCmdJerk(real64 arJerk, uint32 auNumber = DF_INOS_RAMP_JERK_ALL);
385  //; set commanded jerk
386  virtual void GetCmdJerk(real64& arJerk, uint32 auNumber = 0);
387  //; get commanded jerk
388  virtual void GetCmdRealJerk(real64& arJerk, uint32 auNumber = 0);
389  //; get commanded real jerk
390  virtual void SetCmdSlowMotion(real64 arSlowMotion);
391  //; set commanded slowmotion factor
392  virtual void GetCmdSlowMotion(real64& arSlowMotion);
393  //; get commanded slowmotion factor
394  virtual uint32 SetActValue(real64 arValue);
395  //; set actual commanded position
396  virtual void GetActValue(real64& arValue);
397  //; get actual commanded position
398  virtual void GetActVelocity(real64& arVelocity);
399  //; get actual commaned velocity
400  virtual void GetActAcceleration(real64& arAcceleration);
401  //; get actual commanded acceleration
402  virtual void GetActJerk(real64& arJerk);
403  //; get actual commanded jerk
404  virtual uint32 SetRealValue(real64 arValue);
405  //; set actual real value
406  virtual void GetRealValue(real64& arValue);
407  //; get actual real value
408  virtual void SetMinValue(real64 arValue);
409  //; set min. allowed value
410  virtual void GetMinValue(real64& arValue);
411  //; get min. allowed value
412  virtual void SetMaxValue(real64 arValue);
413  //; set max. allowed value
414  virtual void GetMaxValue(real64& arValue);
415  //; get max. allowed value
416  virtual void SetMaxVelocity(real64 arVelocity);
417  //; set max. allowed velocity
418  virtual void GetMaxVelocity(real64& arVelocity);
419  //; get max. allowed velocity
420  virtual void SetMaxAcceleration(real64 arAcceleration);
421  //; set max. allowed acceleration
422  virtual void GetMaxAcceleration(real64& arAcceleration);
423  //; get max. allowed acceleration
424  virtual void SetMaxDeceleration(real64 arDeceleration);
425  //; set max. allowed deceleration
426  virtual void GetMaxDeceleration(real64& arDeceleration);
427  //; get max. allowed deceleration
428  virtual void SetMaxJerk(real64 arJerk);
429  //; set max. allowed jerk
430  virtual void GetMaxJerk(real64& arJerk);
431  //; get max. allowed jerk
432  virtual void SetCycleTime(real64 arCycleTime);
433  //; set controller cycle time [sec]
434  virtual void GetCycleTime(real64& arCycleTime);
435  //; get controller cycle time [sec]
436  virtual uint16 GetCycleNumber();
437  //; get controller cycle number
438  virtual uint16 GetCycleId();
439  //; get controller cycle id
440  virtual uint8 GetBusId();
441  //; get axis bus id
442  virtual uint32 SetParam(const char* apName, real64 arValue);
443  //; universal set parameter with aName to aValue and return error code
444  virtual uint32 GetParam(const char* apName, real64& arResult);
445  //; universal get parameter with aName to aResult and return error code
446  virtual volatile real64* GetParamAdr(const char* apName);
447  //; universal get address of parameter with aName or NULL if not found
448  void SetFlag(uint32 auFlag)
449  { INOS_OR(m_uFlag, auFlag);};
450  //; set controller flags
451  void ClrFlag(uint32 auFlag)
452  { INOS_AND(m_uFlag, ~auFlag);};
453  //; clear controller flags
454  uint32 GetFlag()
455  { return m_uFlag;};
456  //; get controller flags
457  virtual uint32 GetState();
458  //; get controller state
459  virtual uint32 GetState(uint32& auRmpState, uint32& auCtrState);
460  //; get controller, ramp and controller state
461  virtual uint32 GetError();
462  //; get controller error
463  virtual uint32 GetError(uint32& auRmpError, uint32& auCtrState);
464  //; get controller, ramp and controller error
465  virtual uint32 GetWarning();
466  //; get controller warning
467  virtual uint32 GetWarning(uint32& auRmpWarning, uint32& auCtrWarning);
468  //; get controller, ramp and controller warning
469  virtual void AcceptError();
470  //; accept all errors
471  virtual void AcceptError(uint32 auError);
472  //; accept error
473  virtual void AcceptError(uint32 auError, uint32 auRmpError, uint32 auCtrError);
474  //; accept error
475  virtual void AcceptWarning();
476  //; accept all warnings
477  virtual void AcceptWarning(uint32 auWarning);
478  //; accept warning
479  virtual void AcceptWarning(uint32 auWarning, uint32 auRmpWarning, uint32 auCtrError);
480  //; accept warning
481 
482  // param set functions
483  virtual void eCreateParamSet(const char* apSetName);
484  //; Same as CreateParamSet but for INCO registration (as it doesn't return
485  //; a pointer)
486  virtual CINOSControlParamSet* CreateParamSet(const char* apSetName);
487  //; create new param set with name apSetName and return pointer to it
488  virtual void DestroyParamSet(const char* apSetName);
489  //; destroy param set with name apSetName
490  virtual bool SelectParamSet(const char* apSetName);
491  //; select param set with name apSetName
492  virtual CINOSControlParamSet* GetParamSet(const char* apSetName);
493  //; get pointer to param set with name apSetName
494 
495  static void eCreateGlobalParamSet(const char* apSetName);
496  //; Same as CreateGlobalParamSet but for INCO registration (as it doesn't return
497  //; a pointer)
498  static CINOSControlParamSet* CreateGlobalParamSet(const char* apSetName);
499  //; create new param set with name apSetName and return pointer to it
500  static void DestroyGlobalParamSet(const char* apSetName);
501  //; destroy param set with name apSetName
502  static CINOSControlParamSet* GetGlobalParamSet(const char* apSetName);
503  //; get pointer to param set with name apSetName
504 
505  // miscellaneous functions
506 
507  virtual CINCOObject* GetRegister();
508  //; do inco registration and return pointer to it
509  virtual void SetRamp(CINOSBaseRamp* apRamp);
510  //; set new ramp geni
511  CINOSBaseRamp* GetRamp()
512  { return m_pRamp;};
513  //; return pointer to ramp geni
514  virtual uintid RegisterErrorHook(void* apHandler, void* apObject = 0);
515  //; register error hook and return hook id
516  virtual void UnRegisterErrorHook(uintid auHookId);
517  //; unregister error hook
518  virtual const char* GetInputName();
519  //; return control input name
520  virtual const char* GetOutputName();
521  //; return control output name
522  virtual const char* GetEnbOutputName();
523  //; return enable output name
524  virtual const char* GetActivateOutputName();
525  //; return output name for m_pActiveOutput
526 
527  static void SetBusError();
528  //; bus error occured
529  static void AcceptBusError();
530  //; accept bus error
531  static void SetSafetyError();
532  //; safety error occured
533  static void AcceptSafetyError();
534  //; accept safety error
535  static void SetApplicationError();
536  //; target error occured
537  static void AcceptApplicationError();
538  //; accept application error
539 
540  virtual void UpdateIncoItems(bool i_bForceUpdate);
541 
542  CINOSBaseController* GetController() { return m_pController; }
543  //; return controller
544 
545  //--- internals --------------------------------------------------------
546 
547  friend void _INI_0400_CINOSControl();
548  friend class CINOSRemoteControlWorker;
549 
550  // operators (for binary tree of shapes)
551  public:
552  int operator < (CINOSControl& aControl)
553  { return (strcmp(GetName(), aControl.GetName())<0);}
554  int operator == (CINOSControl& aControl)
555  { return (strcmp(GetName(), aControl.GetName())==0);}
556  int operator < (const char* aName)
557  { return (strcmp(GetName(), aName)<0);}
558  int operator == (const char* aName)
559  { return (strcmp(GetName(), aName)==0);}
560 
561  // protected member functions
562  protected:
563  void Signal(CINOSSync*& apSync);
564  //; signal sync object if requested
565  virtual void SetError(uint32 auErrors);
566  //; set axis error (and call error hook if nessecary)
567  bool Enter(uint32 auCommand, CINOSSync* apSync = 0);
568  //; check if command allowed in current state and return false if not
569  void Exit ();
570  //; leave critical section
571  void Exit (CINOSSync*& apCmdSync, CINOSSync* apSync);
572  //; leave critical section and wait if nessecary
573  bool IsCritical()
574  { return m_CmdLock.GetOwner() != 0;};
575  //; return true if somebody stays in critical section
576  virtual void iInActivate();
577  //; inactivate controller
578  virtual void iStop(SINOSRampParam* apParam);
579  //; internal stop
580  virtual SINOSRampParam* iGetRampParam(const char* apSetName);
581  //; get pointer to ramp param of set apSetName
582  virtual void iControl();
583  //; main control handler
584  virtual void iPostWrite();
585  //; post bus write handler
586  static void SetTargetError();
587  //; target error occured
588  void OnTargetError();
589  //; target error occured
590  void OnBusError();
591  //; bus error occured
592  void OnSafetyError();
593  //; safety error occured
594  void OnApplicationError();
595  //; safety error occured
596  CINOSBit* SearchOutput(const char* apName) const;
597  //; searches an output in the 'g_pOutputs', 'g_pFlags' and creates
598  //; creates it as a new flag if it doesn't exist.
599  virtual void CallErrorHooks();
600  //; call error hooks
601 
602  // private member functions (external versions, because until now we are not
603  // able to register functions with default parameters)
604  private:
605  CINOSBus& GetBus();
606  //; Gets this controller's INOS bus. Assertion fails if no bus is available
607  void eActivate();
608  //; activate controller
609  void eActivate(bool abCheckVal, bool abSimulateVal, bool abSimulateOut,
610  bool abSimulateAct);
611  //; activate controller
612  void eReActivate();
613  //; reactivate controller
614  void eInActivate();
615  //; inactivate controller
616  void eAttachRemoteTargetControl(const char* apTarget, real64 arRemoteUpdateTime, bool abCreate);
617  //; create remote target controller
618  void eMove(real64 arPosition, const char* apParam);
619  //; move to position with acc/deceleration and velocity
620  void eStop();
621  //; stop move with acc/deceleration
622  void eVal1();
623  //; move to val 1
624  void eVal2();
625  //; move to val 2
626  void eToggle();
627  //; toggle between pos 1 and pos 2
628  void eAcceptError();
629  //; accept all pending errors
630  void eAcceptWarning();
631  //; accept all pending warnings
632  void eTune(const char* apParam);
633  //; tune controller
634  void iToggling();
635  //; toggle handler (called cyclic)
636 
637  // protected members
638  protected:
639  uint32 m_uState;
640  //; actual state
641  uint32 m_uSubState;
642  //; actual sub state
643  uint32 m_uNxtState;
644  //; next state
645  uint32 m_uPrvState;
646  //; previous state
647  uint32 m_uRmpState;
648  //; state of ramp geni before GetSVAJ
649  uint32 m_uError;
650  //; actual errors
651  uint32 m_uErrorDis;
652  //; actual disabling errors
653  uint32 m_uErrorMask;
654  //; actual error mask
655  uint32 m_uMaskFatal;
656  //; mask of fatal errors
657  uint32 m_uWarning;
658  //; actual warnings
659  uint32 m_uWarningMask;
660  //; actual warning mask
661  uint32 m_uFlag;
662  //; controller flags
663 
664  inosName64 m_cName;
665  //; control name
666  CINCOObject* m_pRegister;
667  //; pointer to inco registration
668  CINCOObject* m_pCommand;
669  //; pointer to inco registration of commands
670  CINCOObject* m_pTest;
671  //; pointer to inco registration of controller test
672  CINCOObject* m_pError;
673  //; pointer to inco registration of errors
674  CINCOObject* m_pErrorDis;
675  //; pointer to inco registration of disabling errors
676  CINCOObject* m_pErrorMask;
677  //; pointer to inco registration of error mask
678  CINCOObject* m_pWarning;
679  //; pointer to inco registration of warnings
680  CINCOObject* m_pWarningMask;
681  //; pointer to inco registration of warning mask
682  CINCOObject* m_pFlag;
683  //; pointer to inco registration of controller flags
684  CINCOObject* m_pState;
685  //; pointer to inco registration of controller state
686  CINOSBaseRamp* m_pRamp;
687  //; pointer to ramp generator
688  CINOSBaseController* m_pController;
689  //; pointer to controller
690  CINOSMutex m_CmdLock;
691  //; mutex to guarantee mutual exclusion in command handling
692  CINOSSync* m_pActivate;
693  //; pointer to synch object to be signaled on end of activate
694  CINOSSync* m_pInActivate;
695  //; pointer to synch object to be signaled on end of inactivate
696  CINOSSync* m_pMove;
697  //; pointer to synch object to be signaled on end of move
698  CINOSSync* m_pStop;
699  //; pointer to synch object to be signaled on end of stop
700  CINOSSync* m_pVelocity;
701  //; pointer to synch object to be signaled on velocity reached
702  CINOSSync* m_pTune;
703  //; pointer to synch object to be signaled on tune ended
704  uintid m_uHookId;
705  //; id of main hook
706  uintid m_uPostHookId;
707  //; id of post hook
708  uintid m_uCmdHookId;
709  //; id of command hooks (e.g. toggle)
710  uintid m_uBusErrorHookId;
711  //; id of bus error hook
712  SINOSControlErrorHook* m_pErrorHooks;
713  //; pointer to list of error hooks
714  TINOSNameBalancedBinaryTree<CINOSControlParamSet>* m_pParamSets;
715  //; pool of all param sets
716  static TINOSNameBalancedBinaryTree<CINOSControlParamSet>* m_pGlobalParamSets;
717  //; pool of all param sets
718  real64 m_rCycleTimeMs;
719  //; requested cycle time [ms]
720  uint32 m_uCycleTime;
721  //; cycletime [us]
722  uint32 m_uHookTime;
723  //; cycletime [us]
724  uint32 m_uTimer;
725  //; cycletime [us]
726  inosName32 m_cInputName;
727  //; input name
728  inosName32 m_cOutputName;
729  //; output name
730  inosName32 m_cEnbOutputName;
731  //; enable output name
732  inosName32 m_cActivateOutputName;
733  //; output name for m_pActiveOutput
734  inosName32 m_cSelectedParamName;
735  //; last selected param name
736  inosName32 m_cRemoteTargetName;
737  //; remote target name (using local control if empty).
738  CINOSBusModule* m_pRemoteControlModule;
739  //; remote target module (using local control if nullptr).
740  uint32 m_uRemoteUpdateTime;
741  //; requested remote update time [ms].
742 
743  CINOSBit* m_pEnbOutput;
744  //; pointer to enable output
745  CINOSBit* m_pActiveOutput;
746  //; output will reflect the activation state. If controller
747  //; is active, the output will be set, otherwise cleared.
748  bool m_bEmgSet;
749  //; true if I 've set the emg output
750 
751  // test values
752 
753  real64 m_rVal1;
754  //; toggle value 1
755  real64 m_rVal2;
756  //; toggle value 2
757  uint32 m_uDelay;
758  //; delay in ms between toggles
759  int32 m_iTicks;
760  //; system ticks to handle delay
761 
762  bool m_bUpdatePending = false;
763  //; remote INCO items need to be updated
764  SINOSCollectedControlData* m_pCollectedData = nullptr;
765  //; collected data pointer
766  uint32 m_uRemoteCollectedDataAddr = 0;
767  //; collected data address from remote target
768  uint32 m_uRemoteCollectedDataVersion = 0;
769  //; version of collected data frame used by remote target (sender)
770  // command parameters
771  private:
772  uint32 m_uActivateCheckVal;
773  //; param : CheckVal
774  uint32 m_uActivateSimulateVal;
775  //; param : SimulateVal
776  uint32 m_uActivateSimulateOut;
777  //; param : SimulateOut
778  uint32 m_uActivateSimulateAct;
779  //; param : SimulateAct
780  real64 m_rMoveValue;
781  //; param : Value
782  inosName32 m_cMoveParam;
783  //; param
784  inosName32 m_cCreateRemoteControlTarget;
785  //; param
786  real64 m_cCreateRemoteControlUpdateTime;
787  bool m_bCreate{false};
788  //; remote target
789  char m_cTuneParam[64];
790  //; tune param
791 
792  // inco explorer methods
793  private :
795  static uint32 eCreate(char* apName, char* apRamp, char* apController,
796  char* apInpName, char* apOutName);
798  static uint32 eDestroy(char* apName);
799 
800  // static private members
801  private:
803  static TINOSNameBalancedBinaryTree<CINOSControl>* m_pControls;
805  static CINCOObject* m_psRegister;
807  static CINCOObject* m_psCmd;
809  static CINCOObject* m_psEntity;
811  static char m_ceName[64];
813  static char m_ceRamp[32];
815  static char m_ceController[32];
817  static char m_ceInput[32];
819  static char m_ceOutput[32];
820 
821  // allow dynamic object handling (new/delete)
823 };
824 
825 //------------------------------------------------------------------------------
826 // end of file
827 //------------------------------------------------------------------------------
828 
829 #endif // INC_CINOSCONTROL_H
CINOSMutex
Definition: cinosmutex.h:35
CINOSBus
Definition: cinosbus.h:562
CINOSMutex::GetOwner
ICACHE class CINOSTask * GetOwner()
Return id of mutex owner.
Definition: cinosmutex.h:118
INOS_OR
#define INOS_OR(variable, mask)
Definition: inosmacro.h:201
CINOSBit
Definition: cinosbit.h:53
SINOSRampData
ramp data
Definition: cinosbaseramp.h:601
cinosbaseramp.h
Short comment.
CINOSBaseRamp
Definition: cinosbaseramp.h:751
DF_INOS_ASYNCHRONOUS
#define DF_INOS_ASYNCHRONOUS
Definition: inosmacro.h:337
SINOSRampDataEx
extended ramp data
Definition: cinosbaseramp.h:616
CINOSControl::Remove
static uint32 Remove(CINOSControl *apControl)
add control
CINOSControl
Definition: cinoscontrol.h:163
INOS_AND
#define INOS_AND(variable, mask)
Definition: inosmacro.h:210
cinosbus.h
Short comment.
CINOSBaseRampParamSet
Definition: cinosbaseramp.h:696
CINOSControlParamSet
Definition: cinoscontrol.h:103
CINOSControl::Activate
virtual uint32 Activate(bool abCheckVal=true, bool abSimulateVal=false, bool abSimulateOut=false, bool abSimulateAct=false, CINOSSync *apSync=DF_INOS_SYNCHRONOUS)
remove control
DF_INOS_SYNCHRONOUS
#define DF_INOS_SYNCHRONOUS
Definition: inosmacro.h:332
CINOSSync
Definition: inos_syn.h:66
CINOSControl::Add
static uint32 Add(CINOSControl *apControl)
return pointer to control 'apName'
DECLARE_DYNAMIC
#define DECLARE_DYNAMIC(aClass)
Definition: cinospartitionmemory.h:328
SINOSRampParam
ramp parameters
Definition: cinosbaseramp.h:502
cinosbasecontroller.h
Short comment.
CINOSBaseController
Definition: cinosbasecontroller.h:109