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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
/*
* 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);
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;
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);
}
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);
}
else
{
if (WHS_GPI_SW_FILTER_PRES())
{
//report and handle filter missing
AlarmHandlingSetAlarm(EVENT_TYPE__AIR_FILTER_NOT_INSTALLED, true);
}
else
{
//if (WHS_GPI_WASTE_OVERFULL()) - cannot read this switch
{
//report and handle waste overflow
AlarmHandlingSetAlarm(EVENT_TYPE__WASTE_CONTAINER_OVERFLOW, 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;
}
}
}
}
return OK;
}
|