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
|
/************************************************************************************************************************
* PrintSTM.c
* High managment logical unit of slow motors in the system ( 6 dispensers and the screw)
* profile run up begins from screw homing to begin position and only then from fast motors activation.
* SlowMotor module is responsible for :
* operating diffrent winding algorithms with predefined parameters from the UI
* operating the dispensers according to predefined dispensing rate from the UI
**************************************************************************************************************************/
#ifndef STATEMACHINES_PRINTSTM_H_
#define STATEMACHINES_PRINTSTM_H_
//#include "include.h"
#include "PMR/common/MessageContainer.pb-c.h"
#include "PMR/Hardware/HardwareDispenser.pb-c.h"
#include "PMR/Printing/JobSegment.pb-c.h"
#include "PMR/Printing/JobRequest.pb-c.h"
#include "PMR/Printing/JobTicket.pb-c.h"
#include "PMR/Printing/JobResponse.pb-c.h"
#define MAX_MSG_LEN 100
typedef enum
{
Entry= 0,
Prepare,
PreSegment,
PrintSegment,
End,
ExitPrint
} PrintingState_t;
#define EXIT_STATE ExitPrint
typedef enum
{
JobRequestMsg,
ValidationResultsOk,
ValidationResultsFail,
PreparationResultsOk,
PreparationResultsFail,
PrintMessage,
PrintingResultsOk,
PrintingResultsFail,
CleaningResultsOk,
CleaningResultsFail,
SystemFailure
}JobSTMEventsEnum;
typedef enum
{
Module_Thread,
Module_Winder,
Module_IDS,
Module_Heaters,
Module_Waste,
MAX_SYSTEM_MODULES
}SYSTEM_MODULE_ID_ENUM;
typedef enum
{
JobSuccess = 0,
JobFail,
JobStop
} ReturnCode;
typedef enum
{
ModuleIdle = 0,
ModuleWaiting,
ModuleDone,
ModuleFail
} ModuleStateEnum;
#define MAX_JOB_NAME_LEN 40
#define MAX_SEGMENT_NUM 30
#define MAX_GRADIENT_STAGES_PER_SEGMENT_NUM 50
#define MAX_DISPENSER_NUM 8
typedef struct
{
int32_t prevstepmiliseconds;
double nlflow;
}GradientFlowStruc;
typedef struct
{
size_t n_gradients;
GradientFlowStruc gradient[MAX_GRADIENT_STAGES_PER_SEGMENT_NUM];
}SegmentGradientStruc;
typedef struct
{
int32_t id;
double startflow;
}DispenserStruc;
typedef struct
{
char Segmentname[MAX_JOB_NAME_LEN];
int32_t length;
//RGB *color;
size_t n_dispensers;
DispenserStruc dispenser[MAX_DISPENSER_NUM];
}SegmentStruc;
typedef struct JobMessage{
uint16_t messageId;
uint16_t msglen;
uint8_t messageData[MAX_MSG_LEN];
}JobMessageStruc;
typedef struct PrintMessage{
uint16_t messageId;
uint16_t msglen;
uint8_t messageData[MAX_MSG_LEN];
}PrintMessageStruc;
extern JobTicket *CurrentJob;
extern JobTicket *PreviousJob;
extern Mailbox_Handle JobmsgQ;
void PrintSTMMsgHandler(void * msg);
void JobInit(void);
void PrintingsInit(void);
void JobRequestFunc(MessageContainer* requestContainer);
uint32_t PrepareReady(int ModuleId, ModuleStateEnum result);
uint32_t PreSegmentReady(int ModuleId, ModuleStateEnum result);
uint32_t SegmentReady(int ModuleId, ModuleStateEnum result);
#endif /* STATEMACHINES_PRINTSTM_H_ */
|