/************************************************************************************************************************ * 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_ */