3.2 Use of alarms of the owfs program


PIC


Figure 3.3: Example of configuration dialog for an alarm

Work with alarms belongs among the advanced techniques and requires good knowledge of owfs and the owserver. It is recommended to use alarms only when the 1-Wire driver response is too slow.

Configuration of one alarm in the case of DS2408 circuit based 1-Wire device is shown in Fig. 3.3. The path to the signal (Sensor/Actuator path) is entered without starting directory /alarm. After selecting the Alarm, additional strings should be entered. The configured string values are preprocessed and stored to working string variables for each alarm (before start of the driver):

sPath – path to the device, here: /29.066418000000. For reading or writing values, the /alarm directory can be inserted before this path, and the character / and the value of some of the preprocessed strings (see next items) can be appended after this path
sSensed – file with the value to be read, here: sensed.BYTE
sLatch – file with the sensed value change flag(s), here: latch.BYTE
sAlarmPor – file indicating the power-on reset of the device, here: por
sSet – file, to which should be written the configuration of next alarm generation (first part of the Set Alarm item to the character =), here: set_alarm
sSetVal – value, which should be written to the sSet file (second part of the Set Alarm item from the character =), here: 133333333
sLatchRes – file, to which should be written the value indicating that the alarm has been served (first part of the Reset Latch item to the character =), here: latch.BYTE
sLatchResVal – value, which should be written to the sLatchRes file (second part of the Reset Latch item from the character =), here: 0

The OwsDrv uses a state machine with the following states for the alarm processing:

NOT_USED – The driver configuration does not contain any alarm.
INIT – The initial state of the state machine.
ALARM_DIR – Browsing the /alarm directory contents.
ALARM_PROCESS – Start of each alarm processing.
ALARM_POR_READ – Detecting whether the device did not perform the power-on reset initialization by reading a file whose name is stored in the sAlarmPor string.
ALARM_POR_READ_WAIT – Waiting for the completion of the reading started in the ALARM_POR_READ state.
ALARM_SET – Setting the alarm generated on the device after power-on reset. The string value in sSetVal is written into the file whose name is specified by the sSet string.
ALARM_SET_WAIT – Waiting for the completion of the writing started in the ALARM_SET state. After that, all outputs are checked. When an output whose path starts with the sPath string is found, the initial value specified in the Init. Value item is written to the corresponding file (see fig. 3.3).
ALARM_INIT_WRITE_WAIT – Waiting for the completion of each individual initial value writing started in the previous state.
ALARM_POR_RESET – Clearing of the power-on reset initialization flag. The value 0 is written into the file whose name is specified by the sAlarmPor string.
ALARM_POR_RESET_WAIT – Waiting for the completion of the power-on reset flag clearing.
ALARM_LATCH – Determining whether the device indicates the occurrence of an alarm. In this state, the file whose name is specified by the sLatch string is read. If the content is non-zero, or the list of items contains at least one non-zero, the occurrence of alarm since the last reading is detected.
ALARM_LATCH_WAIT – Waiting for the completion of the reading started in the ALARM_LATCH state.
ALARM_SENSED – Reading the signal after the alarm occurred. If the alarm occurrence has been detected in the ALARM_LATCH state, reading of the file whose name is specified by the sSensed string in the /alarm directory is started.
ALARM_SENSED_WAIT – Waiting for the completion of the reading started in the ALARM_SENSED state.
ALARM_LATCH_RESET – Clearing of the alarm occurence flag. The string value in sLatchResVal is written into the file whose name is specified by string sLatchRes in the /alarm directory.
ALARM_LATCH_RESET_WAIT – Waiting for the completion of the alarm occurence flag clearing started in the ALARM_LATCH_RESET state.
SENSED – Reading the signal, which could change before clearing the alarm occurence flag in the ALARM_LATCH_RESET state. In this state, reading the contents of the file whose name is specified by the sSensed string is started.
SENSED_WAIT – Waiting for the completion of the reading started in the SENSED state.
ALARM_BYPASS – State enabling to perform one write or read of another signal between processing of two alarms.

Transitions between states follows the rules in table 3.1. The first column shows the current state, the second column can contain one or more conditions for each current state, and the third column contains the state into which the state-machine goes, if the relevant condition of the second column is fulfilled. Conditions in column two are evaluated from top to bottom for each current state.






# State

Transition Conditions

New State




-1 NOT_USED

At least one configured alarm found

INIT




0 INIT

Start of reading the /alarm directory

ALARM_DIR




1 ALARM_DIR

Reading of the /alarm directory completed

ALARM_PROCESS




2
ALARM_PROCESS

If nMaxConsAlarms is consecutively read then

ALARM_BYPASS


else

ALARM_POR_READ


At the end of alarm cycle assign: iAlarmPos = -1. Then

ALARM_BYPASS




3
ALARM_POR_READ

If sAlarmPor is not defined then next alarm

ALARM_PROCESS


If sAlarmPor is empty then

ALARM_LATCH


After succesful read of sAlarmPor

ALARM_POR_READ_WAIT




4
ALARM_POR_READ_WAIT

If the variable por is not equal to zero

ALARM_SET


If por is equal to zero

ALARM_LATCH




5
ALARM_SET

If sSet or sSetVal is not defined then next alarm

ALARM_PROCESS


If sSet or sSetVal is empty then

ALARM_POR_RESET


Assign iAlarmInitPos = -1; After successful write

ALARM_SET_WAIT




6
ALARM_SET_WAIT

Iterate iAlarmInitPos. For found write commands

ALARM_INIT_WRITE_WAIT


At the end of the cycle: iAlarmInitPos = -1; then

ALARM_POR_RESET




7
ALARM_INIT_WRITE_WAIT

If iAlarmInitPos < 0 then

ALARM_POR_RESET


else

ALARM_SET_WAIT




8
ALARM_POR_RESET

If sAlarmPor is not defined then next alarm

ALARM_PROCESS


If sAlarmPor is empty then

ALARM_LATCH


After successful write

ALARM_POR_RESET_WAIT




9 ALARM_POR_RESET_WAIT

After competion the request

ALARM_LATCH




10
ALARM_LATCH

If sLatch is not defined or is empty then next alarm

ALARM_PROCESS


After successful reading

ALARM_LATCH_WAIT




11
ALARM_LATCH_WAIT

If the variable latch is not equal to zero then

ALARM_SENSED


else next alarm

ALARM_PROCESS




12
ALARM_SENSED

If sSensed is not defined then next alarm

ALARM_PROCESS


If sSensed is empty then

ALARM_LATCH_RESET


After successful reading

ALARM_SENSED_WAIT




13 ALARM_SENSED_WAIT

After competion the request

ALARM_LATCH_RESET




14
ALARM_LATCH_RESET

If sLatchRes or sLatchResVal is not defined then

ALARM_PROCESS


If sLatchRes or sLatchResVal is empty then

SENSED


After successful write

ALARM_LATCH_RESET_WAIT




15 ALARM_LATCH_RESET_WAIT

After competion the request

SENSED




16
SENSED

If sSensed is not defined or is empty then next alarm

ALARM_PROCESS


After successful reading

SENSED_WAIT




17 SENSED_WAIT

After competion the request

ALARM_PROCESS




18
ALARM_BYPASS

If iAlarmPos >= 0 then next alarm

ALARM_PROCESS


Else continue from the beginning

INIT




Table 3.1: Alarm processing state-machine