Device State and Error Handling

Overview

This group defines all required functions for reading and changing the device state and for reading the error state and error information.

+ Collaboration diagram for Device State and Error Handling:

Functions

long NemV4ClearFault (TNemesysV4 *Nemesys)
 Clear fault state of Nemesys. More...
 
long NemV4GetLastDevErr (TNemesysV4 *Nemesys, int32_t *pLastDevErr)
 Read last Nemesys error from error register. More...
 
uint32_t NemV4IsEnabled (TNemesysV4 *Nemesys)
 Check if Nemesys is in enabled state. More...
 
uint32_t NemV4IsInFaultState (TNemesysV4 *Nemesys)
 Query fault state of Nemesys pump drive. More...
 
long NemV4ReadStatusWord (TNemesysV4 *Nemesys, uint16_t *pwStatusWord)
 Read status word from Nemesys. More...
 
long NemV4SetEnabled (TNemesysV4 *Nemesys)
 Set single dosing unit into enable state. More...
 

Function Documentation

long NemV4ClearFault ( TNemesysV4 Nemesys)

Clear fault state of Nemesys.

If Nemesys is in fault state then it is not possible to enable the Nemesys until the fault state is cleared. In fault state the Nemesys cannot execute any move. If you need further information about the error occurred you can call the function NemV4GetLastDevErr().

Parameters
NemesysDevice pointer of device to reset from fault state.
Returns
Error code - ERR_NOERR indicates success
See also
NemV4IsInFaultState(), NemV4GetLastDevErr()
544 {
545  long Result;
546 
547  Result = NemV4IsInFaultState(Nemesys);
548  CSI_RETURN_ON_ERROR(Result);
549 
550  // If we are not in fault state, then we can return now
551  if (!Result)
552  {
553  return ERR_NOERR;
554  }
555 
556  //
557  // First we clear the error history and then we clear the fault state
558  //
559  Result = NemV4_ClearErrHist(Nemesys);
560  CSI_RETURN_ON_ERROR(Result);
561 
562  return NemV4_SetControlWord(Nemesys, CW_FAULT_RST);
563 }
reset device from fault state
Definition: nem4_rs232_api.c:137
static long NemV4_ClearErrHist(TNemesysV4 *Nemesys)
Clears the device error history and error register.
Definition: nem4_rs232_api.c:1087
#define ERR_NOERR
No error.
Definition: err_codes.h:102
uint32_t NemV4IsInFaultState(TNemesysV4 *Nemesys)
Query fault state of Nemesys pump drive.
Definition: nem4_rs232_api.c:731
static long NemV4_SetControlWord(TNemesysV4 *Nemesys, uint16_t wControlWord)
Transmits the controlword to the device.
Definition: nem4_rs232_api.c:669

+ Here is the call graph for this function:

long NemV4GetLastDevErr ( TNemesysV4 Nemesys,
int32_t *  pLastDevErr 
)

Read last Nemesys error from error register.

If Nemesys is in fault state, then a Nemesys error occurred. The last Nemesys error is always stored in the Nemesys error register. This function reads the last Nemesys error from the Nemesys error register. The function NemV4ClearFault() will clear the error register so the application should read the last Nemesys error before it clears the fault state.

Parameters
[in]NemesysNemesys to query
[out]pLastDevErrStores last Nemesys error code
Returns
Error code - ERR_NOERR indicates success
See also
NemV4IsInFaultState(), NemV4ClearFault()
1078 {
1079  return CsiDevReadObject(&Nemesys->Device, NemV4_OD_H1003_ERROR_HISTORY,
1080  H1003_SUB_01_ERR_IDX_1, (uint32_t*)pLastDevErr);
1081 }
struct CsiDev Device
CSI device object.
Definition: nem4_rs232_api.h:107
long CsiDevReadObject(struct CsiDev *pDev, uint16_t ObjDicIdx, uint8_t ObjDicSub, uint32_t *pRxDWord)
This function reads up to 4 bytes of data from device object dictionary.
Definition: csi_dev.c:157

+ Here is the call graph for this function:

uint32_t NemV4IsEnabled ( TNemesysV4 Nemesys)

Check if Nemesys is in enabled state.

If Nemesys is not in enabled state, then dosing is not possible. You need to call NemV4SetEnabled() to set Nemesys in enabled state.

Parameters
[in]NemesysDevice pointer of device to query
Return values
1enabled state
0disabled state
<0Error code
See also
NemV4SetEnabled()
757 {
758  long Result;
759  uint8_t IsOperational;
760 
761  Result = NemV4_IsState(Nemesys, 0x006F, SW_OP_EN, &IsOperational);
762 
763  //
764  // If function call was successful then return the state of dosing move
765  // if function returns error code then return the error to user
766  //
767  if (Result != ERR_NOERR)
768  {
769  return Result;
770  }
771  else
772  {
773  return IsOperational;
774  }
775 }
static long NemV4_IsState(TNemesysV4 *Nemesys, uint16_t wMask, uint16_t wState, uint8_t *pResult)
Test the status word for a certain bit pattern.
Definition: nem4_rs232_api.c:708
#define ERR_NOERR
No error.
Definition: err_codes.h:102
operation enabled
Definition: nem4_rs232_api.c:151

+ Here is the call graph for this function:

uint32_t NemV4IsInFaultState ( TNemesysV4 Nemesys)

Query fault state of Nemesys pump drive.

Check if Nemesys is in fault state. The fault state needs to get cleared via NemV4ClearFault() before the pump drive can be enabled.

See also
NemV4ClearFault()
Parameters
NemesysDevice pointer
Return values
1fault state
0not in fault state
<0Error code

Referenced by NemV4ClearFault().

732 {
733  long Result;
734  uint8_t IsInFaultState;
735 
736  Result = NemV4_IsState(Nemesys, 0x004F, SW_FAULT, &IsInFaultState);
737 
738  //
739  // If function call was successful then return the state of dosing move
740  // if function returns error code then return the error to user
741  //
742  if (Result != ERR_NOERR)
743  {
744  return Result;
745  }
746  else
747  {
748  return IsInFaultState;
749  }
750 }
static long NemV4_IsState(TNemesysV4 *Nemesys, uint16_t wMask, uint16_t wState, uint8_t *pResult)
Test the status word for a certain bit pattern.
Definition: nem4_rs232_api.c:708
#define ERR_NOERR
No error.
Definition: err_codes.h:102
fault
Definition: nem4_rs232_api.c:154

+ Here is the call graph for this function:

long NemV4ReadStatusWord ( TNemesysV4 Nemesys,
uint16_t *  pwStatusWord 
)

Read status word from Nemesys.

The bits of the statusword indicate the current state of the drive.

Parameters
[in]NemesysNemesys to query
[out]pwStatusWordBuffer stores received status word
Returns
Error code - ERR_NOERR indicates success

Referenced by NemV4_ExecDrvStateCmd(), NemV4_IsState(), and NemV4SetEnabled().

680 {
681  long Result;
682  uint32_t StatusWord;
683 
684  Result = CsiDevReadObject(&Nemesys->Device, NemV4_OD_H6041_STATUS_WORD, 0, &StatusWord);
685  *pwStatusWord = StatusWord;
686 
687  return Result;
688 }
struct CsiDev Device
CSI device object.
Definition: nem4_rs232_api.h:107
long CsiDevReadObject(struct CsiDev *pDev, uint16_t ObjDicIdx, uint8_t ObjDicSub, uint32_t *pRxDWord)
This function reads up to 4 bytes of data from device object dictionary.
Definition: csi_dev.c:157

+ Here is the call graph for this function:

long NemV4SetEnabled ( TNemesysV4 Nemesys)

Set single dosing unit into enable state.

Dosing is possible if Nemesys is in enable state. If Nemesys is in fault state, then you need to clear the fault state first by calling NemV4ClearFault() and then you can set the Nemesys into enable state by calling this function.

Parameters
[in]NemesysNemesys device to set enabled
Returns
Error code - ERR_NOERR indicates success
See also
NemV4IsOperational(), NemV4ClearFault()
591 {
592  uint16_t state;
593  long Result;
594  uint8_t loopcnt = 0;
595 
596  //
597  // first read status word
598  //
599  Result = NemV4ReadStatusWord(Nemesys, &state);
600  CSI_RETURN_ON_ERROR(Result);
601 
602  //
603  // if drive is in fault state or in fault reaction state then we cannot enable
604  // drive because the user has to clear the fault state first
605  //
606  if (STATE_IS_FAULT(state) || STATE_IS_FAULT_REAC(state))
607  {
609  }
610 
611  //
612  // loop until we rach the operation enable state or until
613  // we reach the loop limit
614  //
615  do
616  {
617  if (STATE_IS_QUICK_STOP(state))
618  {
619  Result = NemV4_ExecDrvStateCmd(Nemesys, CW_OP_EN, &state, DRV_PROC_TIME);
620  }
621  else if (STATE_IS_SWON_DIS(state))
622  {
623  Result = NemV4_ExecDrvStateCmd(Nemesys, CW_SHUTDOWN, &state, DRV_PROC_TIME);
624  }
625  else if (STATE_IS_SWON_RDY(state) || STATE_IS_SWON(state))
626  {
627  //
628  // if we enable operation we set the halt bit in order to avoid
629  // a running drive
630  //
631  Result = NemV4_ExecDrvStateCmd(Nemesys, CW_OP_EN | CWBIT_HALT, &state, DRV_PROC_TIME);
632  }
633  } while (!STATE_IS_OP_EN(state) && (loopcnt++ < 10) && (ERR_NOERR == Result));
634 
635 
636  if (loopcnt <= 10)
637  {
638  return Result;
639  }
640  else
641  {
643  }
644 }
#define STATE_IS_OP_EN(_wState_)
Checks if state is operation enabled.
Definition: nem4_rs232_api.c:73
set device operational
Definition: nem4_rs232_api.c:136
shutdown drive
Definition: nem4_rs232_api.c:131
#define DRV_PROC_TIME
processing time
Definition: nem4_rs232_api.c:23
#define ERR_DS402_TIMEOUT_STATUSWORD
Timeout waiting for status word.
Definition: err_codes.h:378
#define STATE_IS_SWON(_wState_)
Checks if state is switch on.
Definition: nem4_rs232_api.c:72
#define CWBIT_HALT
controlword bit halt
Definition: nem4_rs232_api.c:34
#define STATE_IS_QUICK_STOP(_wState_)
Checks if state is quick stop.
Definition: nem4_rs232_api.c:68
long NemV4ReadStatusWord(TNemesysV4 *Nemesys, uint16_t *pwStatusWord)
Read status word from Nemesys.
Definition: nem4_rs232_api.c:679
#define ERR_NOERR
No error.
Definition: err_codes.h:102
#define STATE_IS_FAULT_REAC(_wState_)
Checks if state is fault reaction active.
Definition: nem4_rs232_api.c:67
#define STATE_IS_FAULT(_wState_)
Checks if state is fault.
Definition: nem4_rs232_api.c:66
#define STATE_IS_SWON_RDY(_wState_)
Checks if state is ready to switch on.
Definition: nem4_rs232_api.c:71
static long NemV4_ExecDrvStateCmd(TNemesysV4 *Nemesys, uint16_t wCmd, uint16_t *pwState, uint16_t wProcessTime)
Execute one single drive state command.
Definition: nem4_rs232_api.c:568
#define ERR_DS402_DRV_ENABLE_FAULT_STATE
Setting drive into operation enabled state is not possible because drive is in fault state...
Definition: err_codes.h:380
#define STATE_IS_SWON_DIS(_wState_)
Checks if state is disabled.
Definition: nem4_rs232_api.c:70

+ Here is the call graph for this function: