Overview

This group defines all required functions for reading and writing device state specific parameters.

+ Collaboration diagram for Device State:

Functions

long NemClearFault (TNemesys *Nemesys)
 Clear fault state of device. More...
 
uint32_t NemIsEnabled (TNemesys *Nemesys)
 Check if device is in enabled state. More...
 
uint32_t NemIsInFaultState (TNemesys *Nemesys)
 Query fault state of device Check if device is in fault state. More...
 
long NemSetEnabled (TNemesys *Nemesys)
 Set single dosing unit into enable state. More...
 

Function Documentation

long NemClearFault ( TNemesys Nemesys)

Clear fault state of device.

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

Parameters
[in]NemesysDevice to reset from fault state
Returns
Error code - ERR_NOERR indicates success
See also
NemIsInFaultState(), NemGetLastDevErr()
557 {
558  long Result;
559 
560  //
561  // First we clear the error history and tehn we clear the fault state
562  //
563  Result = Nem_ClearErrHist(Nemesys);
564  if (ERR_NOERR != Result)
565  {
566  return Result;
567  }
568 
569  return Nem_SetControlWord(Nemesys, CW_FAULT_RST);
570 }
static long Nem_ClearErrHist(TNemesys *Nemesys)
Clears the device error history and error register.
Definition: nem_rs232_api.c:1248
#define ERR_NOERR
No error.
Definition: err_codes.h:102
reset device from fault state
Definition: nem_rs232_api.c:162
static long Nem_SetControlWord(TNemesys *Nemesys, uint16_t wControlWord)
Transmits the controlword to the device.
Definition: nem_rs232_api.c:711

+ Here is the call graph for this function:

uint32_t NemIsEnabled ( TNemesys Nemesys)

Check if device is in enabled state.

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

Parameters
[in]NemesysDevice to query
Return values
1enabled state
0disabled state
<0Error code
See also
NemSetEnabled()
829 {
830  long Result;
831  uint8_t IsOperational;
832 
833  Result = Nem_IsState(Nemesys, 0x006F, SW_OP_EN, &IsOperational);
834 
835  //
836  // If function call was successful then return the state of dosing move
837  // if function returns error code then return the error to user
838  //
839  if (Result != ERR_NOERR)
840  {
841  return Result;
842  }
843  else
844  {
845  return IsOperational;
846  }
847 }
operation enabled
Definition: nem_rs232_api.c:176
#define ERR_NOERR
No error.
Definition: err_codes.h:102
static long Nem_IsState(TNemesys *Nemesys, uint16_t wMask, uint16_t wState, uint8_t *pResult)
Test the status word for a certain bit pattern.
Definition: nem_rs232_api.c:780

+ Here is the call graph for this function:

uint32_t NemIsInFaultState ( TNemesys Nemesys)

Query fault state of device Check if device is in fault state.

Parameters
[in]NemesysDevice to query
Return values
1fault state
0not in fault state
<0Error code
See also
NemClearFault(), NemGetLastDevErr()
804 {
805  long Result;
806  uint8_t IsInFaultState;
807 
808  Result = Nem_IsState(Nemesys, 0x004F, SW_FAULT, &IsInFaultState);
809 
810  //
811  // If function call was successful then return the state of dosing move
812  // if function returns error code then return the error to user
813  //
814  if (Result != ERR_NOERR)
815  {
816  return Result;
817  }
818  else
819  {
820  return IsInFaultState;
821  }
822 }
#define ERR_NOERR
No error.
Definition: err_codes.h:102
fault
Definition: nem_rs232_api.c:179
static long Nem_IsState(TNemesys *Nemesys, uint16_t wMask, uint16_t wState, uint8_t *pResult)
Test the status word for a certain bit pattern.
Definition: nem_rs232_api.c:780

+ Here is the call graph for this function:

long NemSetEnabled ( TNemesys Nemesys)

Set single dosing unit into enable state.

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

Parameters
[in]NemesysDevice to set enabled
Returns
Error code - ERR_NOERR indicates success
See also
NemIsOperational(), NemClearFault()
598 {
599  uint16_t state;
600  long Result;
601  uint8_t loopcnt = 0;
602 
603  //
604  // first read status word
605  //
606  Result = NemReadStatusWord(Nemesys, &state);
607  if (Result != ERR_NOERR)
608  {
609  return Result;
610  }
611 
612  //
613  // if drive is in fault state or in fault reaction state then we cannot enable
614  // drive because the user has to clear the fault state first
615  //
616  if (STATE_IS_FAULT(state) || STATE_IS_FAULT_REAC(state))
617  {
619  }
620 
621  //
622  // loop until we rach the operation enable state or until
623  // we reach the loop limit
624  //
625  do // while (state != DS402_STATE_OP_EN)
626  {
627  if (STATE_IS_QUICK_STOP(state))
628  {
629  Result = Nem_ExecDrvStateCmd(Nemesys, CW_OP_EN, &state, DRV_PROC_TIME);
630  }
631  else if (STATE_IS_SWON_DIS(state))
632  {
633  Result = Nem_ExecDrvStateCmd(Nemesys, CW_SHUTDOWN, &state, DRV_PROC_TIME);
634  }
635  else if (STATE_IS_SWON_RDY(state))
636  {
637  Result = Nem_ExecDrvStateCmd(Nemesys, CW_SWON, &state, DRV_PROC_TIME);
638  }
639  else if (STATE_IS_SWON(state))
640  {
641  //
642  // if operation is enabled we set the hal bit in order to avoid
643  // a running drive
644  //
645  Result = Nem_ExecDrvStateCmd(Nemesys, CW_OP_EN | CWBIT_HALT, &state, DRV_PROC_TIME);
646  }
647  } while (!STATE_IS_OP_EN(state) && (loopcnt++ < 10) && (ERR_NOERR == Result));
648 
649 
650  if (loopcnt <= 10)
651  {
652  return Result;
653  }
654  else
655  {
657  }
658 }
#define CWBIT_HALT
controlword bit halt
Definition: nem_rs232_api.c:39
#define STATE_IS_OP_EN(_wState_)
Checks if state is operation enabled.
Definition: nem_rs232_api.c:84
#define STATE_IS_SWON_RDY(_wState_)
Checks if state is ready to switch on.
Definition: nem_rs232_api.c:82
static long Nem_ExecDrvStateCmd(TNemesys *Nemesys, uint16_t wCmd, uint16_t *pwState, uint16_t wProcessTime)
Execute one single drive state command.
Definition: nem_rs232_api.c:575
#define ERR_DS402_TIMEOUT_STATUSWORD
Timeout waiting for status word.
Definition: err_codes.h:378
long NemReadStatusWord(TNemesys *Nemesys, uint16_t *pwStatusWord)
Read status word from device The bits of the statusword indicate the current state of the drive...
Definition: nem_rs232_api.c:721
#define DRV_PROC_TIME
processing time
Definition: nem_rs232_api.c:21
shutdown drive
Definition: nem_rs232_api.c:156
#define STATE_IS_SWON(_wState_)
Checks if state is switch on.
Definition: nem_rs232_api.c:83
#define STATE_IS_SWON_DIS(_wState_)
Checks if state is disabled.
Definition: nem_rs232_api.c:81
set device operational
Definition: nem_rs232_api.c:161
#define ERR_NOERR
No error.
Definition: err_codes.h:102
#define STATE_IS_FAULT(_wState_)
Checks if state is fault.
Definition: nem_rs232_api.c:77
#define STATE_IS_QUICK_STOP(_wState_)
Checks if state is quick stop.
Definition: nem_rs232_api.c:79
#define STATE_IS_FAULT_REAC(_wState_)
Checks if state is fault reaction active.
Definition: nem_rs232_api.c:78
#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
switch on
Definition: nem_rs232_api.c:157

+ Here is the call graph for this function: