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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
/*
* AlarmHandling.c
*
* Created on: 24 may 2018
* Author: shlomo
*/
#include "include.h"
#include "Modules/General/GeneralHardware.h"
#include "AlarmHandling.h"
#include <driverlib/timer.h>
#include <inc/hw_ints.h>
#include "drivers/adc_sampling/adc.h"
#include "Control/control.h"
#include "drivers/Motors/Motor.h"
#include "drivers/Danser_SSI/SSI_Comm.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/Hardware/HardwareDancerType.pb-c.h"
#include "modules/thread/thread_ex.h"
#include <PMR/Diagnostics/Event.pb-c.h>
#include <PMR/Diagnostics/EventType.pb-c.h>
#include "PMR/debugging/DebugLogCategory.pb-c.h"
#include "StateMachines/Printing/PrintingSTM.h"
Task_Handle AlarmHandling_Task_Handle;
Mailbox_Handle AlarmHandlingMsgQ = NULL;
/******************** Functions ********************************************/
//uint32_t Control_Delta_Position_Pass(uint32_t Current_Read,uint32_t Previous_Read);
//**********************************************************************
typedef enum
{
AlarmHandlingTrigger,
}AlarmHandlingMessages;
typedef struct AlarmHandlingMessage{
uint16_t messageId;
uint16_t msglen;
uint32_t tick;
uint8_t messageData[20];
}AlarmHandlingMessageStruc;
void AlarmHandlingInit(void)
{
Error_Block eb;
Error_init(&eb);
AlarmHandlingMsgQ = Mailbox_create(sizeof(AlarmHandlingMessageStruc), 20, NULL,&eb);
return;
}
void AlarmHandlingIterate(UArg arg0)
{
AlarmHandlingMessageStruc Message;
//send message to the Millisec task
Message.messageId = AlarmHandlingTrigger;
Message.tick = UsersysTickGet();
Message.msglen = sizeof(AlarmHandlingMessageStruc);
if (AlarmHandlingMsgQ != NULL)
Mailbox_post(AlarmHandlingMsgQ , &Message, BIOS_NO_WAIT);
return ;
}
/*typedef enum _EventType {
EVENT_TYPE__ThreadBreak = 0,
EVENT_TYPE__ThreadTensionControlFailure = 1,
EVENT_TYPE__FeederConeInsufficiant = 2,
EVENT_TYPE__WinderGeneralError = 3,
EVENT_TYPE__WinderConeNotExists = 4,
EVENT_TYPE__ThreadFeedingGeneralError = 5,
EVENT_TYPE__DyeingHeadOverTemperature = 6,
EVENT_TYPE__DHThermalCutoff = 7,
EVENT_TYPE__DryerOverTemperature = 8,
EVENT_TYPE__DryerThermalCutoff = 9,
EVENT_TYPE__DyeingHeadHeatersCurrentOutOfRange = 10,
EVENT_TYPE__DryerHeatersCurrentOutOfRange = 11,
EVENT_TYPE__DryerDHeadCoverOpen = 12,
EVENT_TYPE__AirFilterClogged = 13,
EVENT_TYPE__AirFilterNotInstalled = 14,
EVENT_TYPE__WHSFailure = 15,
EVENT_TYPE__WasteContainerIsAlmostFull = 16,
EVENT_TYPE__WasteContainerIsFull = 17,
EVENT_TYPE__DispenserEmpty = 18,
EVENT_TYPE__DispenserLowLevel = 19,
EVENT_TYPE__DispenserRefillFailure = 20,
EVENT_TYPE__MidTankEmpty = 21,
EVENT_TYPE__MidTankLowLevel = 22,
EVENT_TYPE__MidTankNotInPlace = 23,
EVENT_TYPE__SystemBITFail = 24,
EVENT_TYPE__GeneralInternalOverTemperature = 25,
EVENT_TYPE__MachineCoverOpen = 26,
EVENT_TYPE__EmergencyPushButtonPressed = 27,
EVENT_TYPE__SystemGeneralError = 28,
EVENT_TYPE__RequestSent = 29,
EVENT_TYPE__ResponseReceived = 30,
EVENT_TYPE__RequestFailed = 31,
EVENT_TYPE__ApplicationException = 32,
EVENT_TYPE__ApplicationInformation = 33,
EVENT_TYPE__ApplicationStarted = 34,
EVENT_TYPE__ApplicationTerminated = 35,
EVENT_TYPE__RecordingStarted = 36,
EVENT_TYPE__RecordingStopped = 37
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(EVENT_TYPE)
} EventType;
* */
uint32_t AlarmHandlingConsequentActions(EventType EventId, DebugLogCategory Severity)
{
switch (Severity)
{
case DEBUG_LOG_CATEGORY__Warning:
//raise flag fr next job
break;
case DEBUG_LOG_CATEGORY__Error:
JobEndReason = JOB_OTHER_ALARM;
EndState(NULL,event_type__descriptor.name[EventId]);
//Stop Job
break;
case DEBUG_LOG_CATEGORY__Critical:
JobEndReason = JOB_OTHER_ALARM;
EndState(NULL,event_type__descriptor.name[EventId]);
//stop job
//turn machine off
break;
case DEBUG_LOG_CATEGORY__Debug:
case DEBUG_LOG_CATEGORY__Info:
default:
//do nothing
break;
}
return OK;
}
uint32_t AlarmHandlingLoop(uint32_t tick)
{
//read dispensers limit switches. 25 - send warning. up - stop job and send alarm
//Cone missing
//Dyeing head over temperature
//mixer over temperature
//dryer over temperature
//heaters failure
//dispenser pressure
//valve OCD
//Motor Status
//machine cover open
return OK;
}
/******************************************************************************
* ======== messageTsk ========
* Task for this function is created statically. See the project's .cfg file.
* this message task is created statically in system initialization,
******************************************************************************/
void AlarmHandlingTask(UArg arg0, UArg arg1)
{
AlarmHandlingMessageStruc Message;
//char str[60];
//uint16_t length;
//Clock_setTimeout(HostKAClock, 1000);
//Clock_start(HostKAClock);
AlarmHandlingInit();
AlarmHandling_Task_Handle = Task_self();
while(1)
{
Mailbox_pend(AlarmHandlingMsgQ , &Message, BIOS_WAIT_FOREVER);
switch (Message.messageId)
{
case AlarmHandlingTrigger:
AlarmHandlingLoop(Message.tick);
break;
default:
break;
}
}
}
|