1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /*/*
* Safety.c
*
* Created on: Feb 26, 2019
* Author: shlomo
* This file includes the safety indication handling functions:
* Dispensers safety,Dryer door, Air suction, Air filter presence, Waste overflow
*/
#include "drivers/Motors/Motor.h"
#include "drivers/Heater/TemperatureSensor.h"
#include "drivers/FPGA/FPGA_SPI_Comm.h"
#include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h"
#include "drivers/FPGA/FPGA.h"
#include <PMR/Diagnostics/EventType.pb-c.h>
#include "Modules/General/GeneralHardware.h"
#include "modules/control/control.h"
#include "modules/AlarmHandling/AlarmHandling.h"
#include "modules/thread/thread_ex.h"
#include "modules/heaters/heaters_ex.h"
#include "modules/ids/ids_ex.h"
uint32_t SafetyControlId;
bool DispenserOverPressure[MAX_SYSTEM_DISPENSERS] = {false,false,false,false,false,false,false,false};
uint32_t Safety_Main_State(uint32_t IfIndex, uint32_t BusyFlag);
bool DrierDoorAlarmState = false;
bool AirFlowAlarmState = false;
bool AirFilterAlarmState = false;
bool WasteOverflowAlarmState = false;
void Safety_Init(void)
{
SafetyControlId = AddControlCallback( Safety_Main_State, eOneSecond, TemplateDataReadCBFunction,0,0, 0 );
//return;
}
uint32_t Safety_Main_State(uint32_t IfIndex, uint32_t BusyFlag)
{
int Disp_i;
bool AllDispensersInSafety = true;
bool AnyDispensersInSafety = false;
/*bool mDrierDoorAlarmState = false;
bool mAirFlowAlarmState = false;
bool mAirFilterAlarmState = false;
bool mWasteOverflowAlarmState = false;*/
for (Disp_i = 0;Disp_i < MAX_SYSTEM_DISPENSERS;Disp_i++)
{
if (isMotorConfigured(Disp_i + HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1)==true)
{
AllDispensersInSafety &= Check_Disp_Safety_Stop_Indication(Disp_i);
AnyDispensersInSafety |= Check_Disp_Safety_Stop_Indication(Disp_i);
}
}
if (AllDispensersInSafety)
{
if (Get_COVER_1_State(DryerDoor))
{
//report and handle dryer door open
AlarmHandlingSetAlarm(EVENT_TYPE__DRYER_DOOR_OPEN, true);
// mDrierDoorAlarmState = true;
// DrierDoorAlarmState = true;
}
else
{
if (WHS_GPI_WASTE_FLOW_SWITCH())
{
//report and handle air flow failure
//if blower if off handling is different
AlarmHandlingSetAlarm(EVENT_TYPE__NO_AIR_PRESSURE, true);
// mAirFlowAlarmState = true;
// AirFlowAlarmState = true;
}
else
{
if (WHS_GPI_SW_FILTER_PRES())
{
//report and handle filter missing
AlarmHandlingSetAlarm(EVENT_TYPE__AIR_FILTER_NOT_INSTALLED, true);
// mAirFilterAlarmState = true;
// AirFilterAlarmState = true;
}
else
{
//if (WHS_GPI_WASTE_OVERFULL()) - cannot read this switch
{
//report and handle waste overflow
AlarmHandlingSetAlarm(EVENT_TYPE__WASTE_CONTAINER_OVERFLOW, true);
// mWasteOverflowAlarmState = true;
// WasteOverflowAlarmState = true;
}
}
}
}
}
else if (AnyDispensersInSafety)
{
for (Disp_i = 0;Disp_i < MAX_SYSTEM_DISPENSERS;Disp_i++)
{
if (isMotorConfigured(Disp_i + HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1)==true)
{
if (Check_Disp_Safety_Stop_Indication(Disp_i) == true)
{
//report dispenser over pressure
AlarmHandlingSetAlarm(EVENT_TYPE__DISPENSER_1_OVERPRESSURE+Disp_i, true);
DispenserOverPressure[Disp_i] = true;
}
}
}
}
for (Disp_i = 0;Disp_i < MAX_SYSTEM_DISPENSERS;Disp_i++)
{
if (DispenserOverPressure[Disp_i] == true)
{
if (isMotorConfigured(Disp_i + HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1)==true)
{
if (Check_Disp_Safety_Stop_Indication(Disp_i) == false)
{
//report dispenser over pressure
AlarmHandlingSetAlarm(EVENT_TYPE__DISPENSER_1_OVERPRESSURE+Disp_i, false);
DispenserOverPressure[Disp_i] = false;
}
}
}
}
/* if ((mDrierDoorAlarmState != DrierDoorAlarmState)|| (mDrierDoorAlarmState == false))
{
//alarm went off
AlarmHandlingSetAlarm(EVENT_TYPE__DRYER_DOOR_OPEN, false);
DrierDoorAlarmState = mDrierDoorAlarmState;
}
if ((mAirFlowAlarmState != AirFlowAlarmState)|| (mAirFlowAlarmState == false))
{
//alarm went off
AlarmHandlingSetAlarm(EVENT_TYPE__NO_AIR_PRESSURE, false);
AirFlowAlarmState = mAirFlowAlarmState;
}
if ((mAirFilterAlarmState != AirFilterAlarmState)|| (mAirFilterAlarmState == false))
{
//alarm went off
AlarmHandlingSetAlarm(EVENT_TYPE__AIR_FILTER_NOT_INSTALLED, false);
AirFilterAlarmState = mAirFilterAlarmState;
}
if ((mWasteOverflowAlarmState != WasteOverflowAlarmState)|| (mWasteOverflowAlarmState == false))
{
//alarm went off
AlarmHandlingSetAlarm(EVENT_TYPE__WASTE_CONTAINER_OVERFLOW, false);
WasteOverflowAlarmState = mWasteOverflowAlarmState;
}
*/
return OK;
}
|