From 42ce5a31ab95f5de94c46b106268e042cc81e6d6 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Tue, 19 Mar 2019 12:51:47 +0200 Subject: prepare firmware upgrade continuous reporting + fix drivers overwrite --- .../Embedded/Common/SWUpdate/FirmwareUpgrade.c | 74 ++++++++++++++++++++-- 1 file changed, 68 insertions(+), 6 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c index c66300b7e..456c30290 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c @@ -22,7 +22,50 @@ #include #include "drivers/FPGA/Full_Vme/FPGA_Programming_Up.h" +#include "drivers/FPGA/Full_Vme/ispvme/vmopcode.h" +#include "Common/Utilities/Utils.h" + #include "Common/SWUpdate/FileSystem.h" +#include "Modules/Control/Control.h" + +int NumberOfFiles = 0,CurrentRunningFile; +int CurrentFileSize = 0; +uint32_t ActivateVersionControlId = 0xFF; +char activateString[100]; +char ActivateToken[36+1]={0}; +bool Reboot = false; + +uint32_t ActivateVersionCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) +{ + ActivateVersionResponse response = ACTIVATE_VERSION_RESPONSE__INIT; + MessageContainer responseContainer; + + usnprintf(activateString, 1000, "file %d of %d bytes %d of %d",CurrentRunningFile,NumberOfFiles,vme_index,CurrentFileSize); + + Report(activateString,__FILE__,__LINE__,(int)CurrentRunningFile,RpWarning,CurrentFileSize,0); + + if (CurrentRunningFiledata.len, requestContainer->data.data); @@ -42,6 +89,7 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) FPGA_ID FileDestinationToFPGAId[VERSION_FILE_DESTINATION__FPGA3+1] = {MAX_FPGA,FPGA1,FPGA2,FPGA3}; + ustrncpy (ActivateToken, requestContainer->token,36); strcpy (SWUpgradePath,request->path); strcat(SWUpgradePath,"/package.cfg"); @@ -50,8 +98,18 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) if (Fresult == FR_OK) { VersionPackage = version_package_descriptor__unpack(NULL,Bytes,buffer); + NumberOfFiles = VersionPackage->n_filedescriptors; + if (NumberOfFiles) + { + CurrentRunningFile = 0; + //add control 1 second + ActivateVersionControlId = AddControlCallback( ActivateVersionCallBackFunction, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + } for (File_i = 0;File_in_filedescriptors;File_i++) { + CurrentRunningFile = 0; + CurrentFileSize = -1; + vme_index = 0; switch(VersionPackage->filedescriptors[File_i]->destination) { case VERSION_FILE_DESTINATION__MCU: @@ -62,11 +120,11 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) //validate //update usnprintf(FullPath, 50, "%s%s%s", request->path,"/", VersionPackage->filedescriptors[File_i]->filename); - if (VersionPackage->filedescriptors[File_i]->destination == VERSION_FILE_DESTINATION__FPGA3) - Reboot = true; - else - Reboot = false; - Fresult = FPGA_Programming_Request( FileDestinationToFPGAId[VersionPackage->filedescriptors[File_i]->destination], FullPath, Reboot); + Reboot = true; + memset (fno,0,sizeof(FILINFO)); + Fresult = f_stat(FullPath,fno); + CurrentFileSize = fno->fsize; + Fresult = FPGA_Programming_Request( FileDestinationToFPGAId[VersionPackage->filedescriptors[File_i]->destination], FullPath, false); break; case VERSION_FILE_DESTINATION__ConfigParams: usnprintf(FullPath, 50, "%s%s%s", request->path,"/", VersionPackage->filedescriptors[File_i]->filename); @@ -108,6 +166,10 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) activate_version_request__free_unpacked(request,NULL); SendChars(container_buffer, container_size); + if (Reboot == true) + { + Power_Reset(); + } return OK; } -- cgit v1.3.1 From 67903ba41edc58090b41c782036acc1fd05548ea Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Mon, 1 Apr 2019 00:06:35 +0300 Subject: small improbvements in job handling and job end. preparations for log distributors setup --- .../Embedded/Common/SWUpdate/FileSystem.c | 2 +- .../Embedded/Common/report/distributor.c | 2 +- .../Embedded/Common/report/reportInit.c | 37 +++++++++-- .../Embedded_SW/Embedded/Communication/Container.c | 2 +- Software/Embedded_SW/Embedded/DataDef.h | 17 +++++ Software/Embedded_SW/Embedded/Embedded.cfg | 2 +- .../Embedded/Modules/Diagnostics/Diagnostics.c | 74 +++++++++++----------- .../Embedded/Modules/General/GeneralHardware.c | 2 +- .../Embedded/Modules/Heaters/Heaters_print.c | 8 +-- .../Embedded/Modules/Thread/Thread_Winder.c | 2 +- .../Embedded/Modules/Thread/Thread_print.c | 2 +- .../Embedded/StateMachines/Printing/PrintingSTM.c | 6 +- 12 files changed, 100 insertions(+), 56 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index c311e9787..d57d3b14b 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -86,7 +86,7 @@ uint32_t FileUploadRequestFunc(MessageContainer* requestContainer) Fresult = FR_DENIED; else { - Fresult = f_open(UploadFileHandle,request->path,FA_READ | FA_WRITE | FA_OPEN_ALWAYS ); + Fresult = f_open(UploadFileHandle,request->path,FA_READ | FA_WRITE |FA_OPEN_ALWAYS| FA_CREATE_ALWAYS); if (Fresult == FR_OK) { FileLength = request->length; diff --git a/Software/Embedded_SW/Embedded/Common/report/distributor.c b/Software/Embedded_SW/Embedded/Common/report/distributor.c index 0515b0472..c026ad4d2 100644 --- a/Software/Embedded_SW/Embedded/Common/report/distributor.c +++ b/Software/Embedded_SW/Embedded/Common/report/distributor.c @@ -242,7 +242,7 @@ Void reportService(UArg arg0, UArg arg1) ReportInitParams InitParams; InitParams.DistributorQueueMaxMsgs = 30; InitParams.DistributorTaskPriority = 6; - InitParams.MaxNumOfFilterNames = 1; + InitParams.MaxNumOfFilterNames = 1;//30 InitParams.MaxNumberOfPrivateDistributors = 2; ReportInit (InitParams); diff --git a/Software/Embedded_SW/Embedded/Common/report/reportInit.c b/Software/Embedded_SW/Embedded/Common/report/reportInit.c index feb13504a..bc3cbe20b 100644 --- a/Software/Embedded_SW/Embedded/Common/report/reportInit.c +++ b/Software/Embedded_SW/Embedded/Common/report/reportInit.c @@ -38,6 +38,21 @@ #include "PMR/debugging/StartDebugLogResponse.pb-c.h" #include "PMR/debugging/StopDebugLogResponse.pb-c.h" +/*PackageHandle ControlFilter; +PackageHandle HeatersFilter; +PackageHandle JobFilter ; +PackageHandle WasteFilter ; +PackageHandle AlarmFilter ; +PackageHandle DiagnosticsFilter; +PackageHandle IDSFilter; +PackageHandle ThreadFilter; +PackageHandle GeneralFilter; +PackageHandle CommFilter; +PackageHandle FPGAFilter; +PackageHandle LoadFilter; +PackageHandle InitFilter; +PackageHandle MaintFilter;*/ + char protobufToken[36+1] = {0}; int ReportResponseFunc(char *message, /* The formatted message */ @@ -115,11 +130,6 @@ uint32_t ReportInitMessage(MessageContainer* requestContainer) StartDebugLogRequest* request = start_debug_log_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); ustrncpy (protobufToken, requestContainer->token,36); - /* InitParams.DistributorQueueMaxMsgs = 20; - InitParams.DistributorTaskPriority = 6; - InitParams.MaxNumOfFilterNames = 1; - InitParams.MaxNumberOfPrivateDistributors = 2; - status |= ReportInit (InitParams);*/ DistributorHandle ReportHandle = ReportAddDistributor("ProtoBuf"); if (ReportHandle == NULL) status |= 0x8; status |= ReportFunc(ReportResponseFunc , REPORT_ADD, ReportHandle); @@ -166,7 +176,6 @@ void ReportStopReporting(void) protobufToken[0] = 0; } -#define REPORT_RESERVED_NUM_OF_FILTER_PACKAGES 30 /* This reserved for swinfra packages */ /*************************************************************************** * @@ -204,10 +213,24 @@ STATUS ReportInit(ReportInitParams InitParams) //ReportMonitorFunc(REPORT_ADD, 0); MaxNumOfFilterNames = InitParams.MaxNumOfFilterNames; - MaxNumOfFilterNames += REPORT_RESERVED_NUM_OF_FILTER_PACKAGES; status = filterTableInit(MaxNumOfFilterNames); if (status == OK) initialized = true; +/* ControlFilter = ReportAddFilterPackage("Control"); + HeatersFilter = ReportAddFilterPackage("Heaters"); + JobFilter = ReportAddFilterPackage("Job"); + WasteFilter = ReportAddFilterPackage("Waste"); + AlarmFilter = ReportAddFilterPackage("Alarm"); + DiagnosticsFilter = ReportAddFilterPackage("Diagnostics"); + IDSFilter = ReportAddFilterPackage("IDS"); + ThreadFilter = ReportAddFilterPackage("Thread"); + GeneralFilter = ReportAddFilterPackage("General"); + CommFilter = ReportAddFilterPackage("Comm"); + FPGAFilter = ReportAddFilterPackage("FPGA"); + LoadFilter = ReportAddFilterPackage("Load"); + InitFilter = ReportAddFilterPackage("Init"); + MaintFilter = ReportAddFilterPackage("Maint");*/ +// Filter = ReportAddFilterPackage(""); return status; } diff --git a/Software/Embedded_SW/Embedded/Communication/Container.c b/Software/Embedded_SW/Embedded/Communication/Container.c index bb6b82743..ad57c36ab 100644 --- a/Software/Embedded_SW/Embedded/Communication/Container.c +++ b/Software/Embedded_SW/Embedded/Communication/Container.c @@ -136,7 +136,7 @@ void receive_callback(char* buffer, size_t length) DataLength[index] = requestContainer->data.len; if (index++>=MAX_CONT_LOG) index = 0; - REPORT_MSG(requestContainer->type,"Message received"); + //REPORT_MSG(requestContainer->type,"Message received"); switch(requestContainer->type) { case MESSAGE_TYPE__CalculateRequest: diff --git a/Software/Embedded_SW/Embedded/DataDef.h b/Software/Embedded_SW/Embedded/DataDef.h index 66a5aa74f..424eff1d8 100644 --- a/Software/Embedded_SW/Embedded/DataDef.h +++ b/Software/Embedded_SW/Embedded/DataDef.h @@ -5,6 +5,7 @@ #include #include #include +#include "common/report/report.h" //#define EVALUATION_BOARD // to use the LCD only when using the evaluation board //#define USE_USB @@ -399,5 +400,21 @@ Supports diagnostic (--diag_suppress, - pds) #define HEAD6_PT100 TEMP_SENSE_AN_ENCLOSURETEMP3 #define MIXER_PT100 TEMP_SENSE_ANALOG_MIXCHIP_TEMP +/* +extern PackageHandle ControlFilter; +extern PackageHandle HeatersFilter; +extern PackageHandle JobFilter ; +extern PackageHandle WasteFilter ; +extern PackageHandle AlarmFilter ; +extern PackageHandle DiagnosticsFilter; +extern PackageHandle IDSFilter; +extern PackageHandle ThreadFilter; +extern PackageHandle GeneralFilter; +extern PackageHandle CommFilter; +extern PackageHandle FPGAFilter; +extern PackageHandle LoadFilter; +extern PackageHandle InitFilter; +extern PackageHandle MaintFilter; +*/ #endif /* DATADEF_H */ diff --git a/Software/Embedded_SW/Embedded/Embedded.cfg b/Software/Embedded_SW/Embedded/Embedded.cfg index cf1e9920c..7efea86f4 100644 --- a/Software/Embedded_SW/Embedded/Embedded.cfg +++ b/Software/Embedded_SW/Embedded/Embedded.cfg @@ -147,7 +147,7 @@ Program.global.communicationTx = Task.create("&communicationTxTask", CommTxTaskP var ProcessTaskParams = new Task.Params(); ProcessTaskParams.instance.name = "process"; -ProcessTaskParams.stackSize = 2048; +ProcessTaskParams.stackSize = 4096; ProcessTaskParams.priority = 8; Program.global.process = Task.create("&jobTask", ProcessTaskParams); diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index 3826168ec..c936d842c 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -67,30 +67,30 @@ int DiagnosticCollectionLimit = 2; //number of data samples to collect before s int DiagnosticLimit =eHundredMillisecond; //frequency of data collection int DiagnosticFastLimit = eTenMillisecond; //frequency of data collection -//DigitalPin DigitalPinArray[1][DIAGNOSTICS_LIMIT]; -double dancer1angle[DIAGNOSTICS_LIMIT]; -double dancer2angle[DIAGNOSTICS_LIMIT]; -double dancer3angle[DIAGNOSTICS_LIMIT]; - -double feedermotorfrequency[DIAGNOSTICS_LIMIT]; -double dryermotor[DIAGNOSTICS_LIMIT]; -double pollermotor[DIAGNOSTICS_LIMIT]; -double windermotor[DIAGNOSTICS_LIMIT]; -double screwmotor[DIAGNOSTICS_LIMIT]; -double mixertemperature[DIAGNOSTICS_LIMIT]; -double headzone1temperature[DIAGNOSTICS_LIMIT]; -double headzone2temperature[DIAGNOSTICS_LIMIT]; -double headzone3temperature[DIAGNOSTICS_LIMIT]; -double headzone4temperature[DIAGNOSTICS_LIMIT]; -double headzone5temperature[DIAGNOSTICS_LIMIT]; -double headzone6temperature[DIAGNOSTICS_LIMIT]; -double dryerzone1temperature[DIAGNOSTICS_LIMIT]; -double dryerzone2temperature[DIAGNOSTICS_LIMIT]; -double dryerzone3temperature[DIAGNOSTICS_LIMIT]; - - -double dispensermotorfrequency[MAX_SYSTEM_DISPENSERS][DIAGNOSTICS_LIMIT]; -double dispenserspressure[MAX_SYSTEM_DISPENSERS][DIAGNOSTICS_LIMIT]; +//DigitalPin DigitalPinArray[1][DIAGNOSTICS_LIMIT+1]; +double dancer1angle[DIAGNOSTICS_LIMIT+1]; +double dancer2angle[DIAGNOSTICS_LIMIT+1]; +double dancer3angle[DIAGNOSTICS_LIMIT+1]; + +double feedermotorfrequency[DIAGNOSTICS_LIMIT+1]; +double dryermotor[DIAGNOSTICS_LIMIT+1]; +double pollermotor[DIAGNOSTICS_LIMIT+1]; +double windermotor[DIAGNOSTICS_LIMIT+1]; +double screwmotor[DIAGNOSTICS_LIMIT+1]; +double mixertemperature[DIAGNOSTICS_LIMIT+1]; +double headzone1temperature[DIAGNOSTICS_LIMIT+1]; +double headzone2temperature[DIAGNOSTICS_LIMIT+1]; +double headzone3temperature[DIAGNOSTICS_LIMIT+1]; +double headzone4temperature[DIAGNOSTICS_LIMIT+1]; +double headzone5temperature[DIAGNOSTICS_LIMIT+1]; +double headzone6temperature[DIAGNOSTICS_LIMIT+1]; +double dryerzone1temperature[DIAGNOSTICS_LIMIT+1]; +double dryerzone2temperature[DIAGNOSTICS_LIMIT+1]; +double dryerzone3temperature[DIAGNOSTICS_LIMIT+1]; + + +double dispensermotorfrequency[MAX_SYSTEM_DISPENSERS][DIAGNOSTICS_LIMIT+1]; +double dispenserspressure[MAX_SYSTEM_DISPENSERS][DIAGNOSTICS_LIMIT+1]; double MidTankpressure[MAX_SYSTEM_DISPENSERS][1]; double HeatersCurrent[NUM_OF_CURRENT_HEATERS][1]; @@ -101,14 +101,14 @@ HeaterState **heatersstates; HeaterState HeaterInfo[HEATER_TYPE__MixerHeater+1]; DigitalInterfaceState **digitalinterfacestates; DigitalInterfaceState DigitalOutputState[MAX_HEATERS_NUM+2]; -/*double dispenser1motorfrequency[DIAGNOSTICS_LIMIT]; -double dispenser2motorfrequency[DIAGNOSTICS_LIMIT]; -double dispenser3motorfrequency[DIAGNOSTICS_LIMIT]; -double dispenser4motorfrequency[DIAGNOSTICS_LIMIT]; -double dispenser5motorfrequency[DIAGNOSTICS_LIMIT]; -double dispenser6motorfrequency[DIAGNOSTICS_LIMIT]; -double dispenser7motorfrequency[DIAGNOSTICS_LIMIT]; -double dispenser8motorfrequency[DIAGNOSTICS_LIMIT]; +/*double dispenser1motorfrequency[DIAGNOSTICS_LIMIT+1]; +double dispenser2motorfrequency[DIAGNOSTICS_LIMIT+1]; +double dispenser3motorfrequency[DIAGNOSTICS_LIMIT+1]; +double dispenser4motorfrequency[DIAGNOSTICS_LIMIT+1]; +double dispenser5motorfrequency[DIAGNOSTICS_LIMIT+1]; +double dispenser6motorfrequency[DIAGNOSTICS_LIMIT+1]; +double dispenser7motorfrequency[DIAGNOSTICS_LIMIT+1]; +double dispenser8motorfrequency[DIAGNOSTICS_LIMIT+1]; */ Task_Handle Diagnostics_Task_Handle; Mailbox_Handle DiagnosticsMsgQ = NULL; @@ -183,15 +183,15 @@ void SetDiagnosticCollectionLimit(int limit) } uint8_t HeaterCounterIndex[MAX_HEATERS_NUM]= {0,0,0,0,0,0,0,0,0,0}; -double HeaterTemperature[MAX_HEATERS_NUM][DIAGNOSTICS_LIMIT]; +double HeaterTemperature[MAX_HEATERS_NUM][DIAGNOSTICS_LIMIT+1]; uint8_t DancerCounterIndex[NUM_OF_DANCERS]= {0,0,0}; -double DancerValue[NUM_OF_DANCERS][DIAGNOSTICS_DANCER_LIMIT]; +double DancerValue[NUM_OF_DANCERS][DIAGNOSTICS_DANCER_LIMIT+1]; int8_t DancerErrorCounterIndex[NUM_OF_DANCERS]= {0,0,0}; -double DancerErrorValue[NUM_OF_DANCERS][DIAGNOSTICS_DANCER_LIMIT]; +double DancerErrorValue[NUM_OF_DANCERS][DIAGNOSTICS_DANCER_LIMIT+1]; uint8_t MotorCounterIndex[MAX_THREAD_MOTORS_NUM]= {0,0,0}; -double MotorValue[MAX_THREAD_MOTORS_NUM][DIAGNOSTICS_LIMIT]; +double MotorValue[MAX_THREAD_MOTORS_NUM][DIAGNOSTICS_LIMIT+1]; uint8_t SpeedCounterIndex= 0; -double SpeedValue[DIAGNOSTICS_DANCER_LIMIT]; +double SpeedValue[DIAGNOSTICS_DANCER_LIMIT+1]; void DiagnosticLoadMotor(int MotorId, int frequency) { diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index bacbe3bfb..74f8c8746 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -58,7 +58,7 @@ uint32_t HWConfigurationInit(void) uint8_t* buffer = NULL; uint32_t Bytes = 0,i,j,k=0; uint32_t status = OK; - UploadHardwareConfigurationRequest* UploadRequest; + UploadHardwareConfigurationRequest* UploadRequest=0; GeneralHwReady = false; Control_WD(ENABLE,250); diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index b9120ddef..8fe9e5c2e 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -433,7 +433,7 @@ void PrepareACHeater(int HeaterId,uint32_t Frequency, uint32_t SetTemperatue) ControlIdtoHeaterId [HeaterId] = AddControlCallback( HeaterControlCBFunction, Frequency/*eOneSecond*/,TemperatureSensorRead,(IfTypeHeaters*0x100+HeaterId),DryerInternalPT100Id,0); //HeaterPreviousRead[HeaterId] = TemperatureSensorRead(DryerInternalPT100Id); HeaterPreviousRead[HeaterId] = GetFilteredHeaterRead(HeaterId);// - Report("PrepareHeater AC Read", __FILE__,HeaterId, SetTemperatue, RpWarning,HeaterPreviousRead[HeaterId], 0); + //Report("PrepareHeater AC Read", __FILE__,HeaterId, SetTemperatue, RpWarning,HeaterPreviousRead[HeaterId], 0); HeaterPreviousRead[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain] = GetFilteredHeaterRead(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain);//TemperatureSensorRead(HeaterId2PT100Id[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain]); HeaterPreviousRead[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary] = GetFilteredHeaterRead(HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary);// = TemperatureSensorRead(HeaterId2PT100Id[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary]); } @@ -497,7 +497,7 @@ int PrepareDCHeater(int HeaterId, uint32_t Frequency, uint32_t SetTemperatue) LOG_ERROR (HeaterId,"PT100 not working properly"); return ERROR; } - Report("PrepareHeater Read", __FILE__,HeaterId, SetTemperatue, RpWarning,HeaterPreviousRead[HeaterId], 0); + //Report("PrepareHeater Read", __FILE__,HeaterId, SetTemperatue, RpWarning,HeaterPreviousRead[HeaterId], 0); if (ControlIdtoMaxHeaterId [HeaterId] == 0xFF) ControlIdtoMaxHeaterId [HeaterId] = AddControlCallback( DcHeaterMaxTempCBFunction, eOneSecond,TemperatureSensorRead,(IfTypeHeaters*0x100+HeaterId),HeaterId2PT100Id[HeaterId],0); @@ -658,11 +658,11 @@ uint32_t HeaterMaxTempCBFunction(uint32_t IfIndex, uint32_t eadValue) { if (HeaterMaxTempFlag[index] == true) { - ActivateHeater(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain); + /* ActivateHeater(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain); if (HeaterReady[HARDWARE_PID_CONTROL_TYPE__DryerAirTemperature]==false) { ActivateHeater(HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary); - } + }*/ // LOG_ERROR ((MinreadValue/100), "Heater Cooled Off max temperature, turned on"); } HeaterMaxTempFlag[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain] = false; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index faee55608..d8564963c 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -454,7 +454,7 @@ void ScrewTimerInterrupt(int ARG0) TimerDisable(Screw_timerBase, TIMER_A); } ROM_IntMasterEnable(); - Rotations+=0.1; + Rotations+=0.03; /*random++; if (random >= 2) random = -1;*/ diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 4131fbca5..9f5ece15a 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -751,7 +751,7 @@ uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId) //wait for all motors to get to the required speed (set the target speed for the control to check) //call the job state machine when the thread system is ready if ((InitialProcess==false) && (EnableIntersegment == true) && (IntersegmentLength >= 1.0)) //fix - avoid intersegment length 0 - { + {//add initial presegment and cleaning before first segment ThreadUpdateProcessLength (IntersegmentLength,(void *)ThreadInterSegmentEnded); REPORT_MSG (IntersegmentLength," ThreadPreSegmentState IntersegmentLength"); } diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c index 7c720f848..53057c170 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c @@ -158,6 +158,7 @@ uint32_t PreSegmentReady(int ModuleId, ModuleStateEnum result) if (PreSegmentWaiting[ModuleId] != ModuleWaiting) { LOG_ERROR (ModuleId, "Message from unrelated module!!"); + return OK; } PreSegmentWaiting[ModuleId] = result; @@ -232,11 +233,13 @@ uint32_t SegmentReady(int ModuleId, ModuleStateEnum result) assert (ModuleId Date: Tue, 2 Apr 2019 15:16:32 +0300 Subject: Embedded SW Release note - Version 1.3.8.2 File upload: prevent on job, reduce priority (watchdog) Report: packages filters introduced, please feel free to use them. robustness in communication improved large number of segments and gradient support - initial at the end of job the screw does not return back rockers - adjust values before and after loading the cart --- .../Embedded/Common/SWUpdate/FileSystem.c | 51 +- .../Embedded/Common/SWUpdate/FirmwareUpgrade.c | 1 + .../Embedded_SW/Embedded/Common/SW_Info/SW_Info.c | 2 +- .../Embedded/Common/report/distributor.c | 2 +- Software/Embedded_SW/Embedded/DataDef.h | 4 +- .../Embedded/Drivers/flash_ram/FlashProgram.c | 6 +- .../Embedded/Modules/AlarmHandling/AlarmHandling.c | 57 +- .../Embedded/Modules/Control/MillisecTask.c | 1 + .../Modules/Diagnostics/DiagnosticsHoming.c | 14 +- .../Embedded/Modules/General/GeneralHardware.c | 2 +- Software/Embedded_SW/Embedded/Modules/IDS/IDS.h | 1 + .../Embedded/Modules/IDS/IDS_dispenser.c | 2 +- Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h | 3 + .../Embedded_SW/Embedded/Modules/IDS/IDS_maint.c | 2 +- .../Embedded_SW/Embedded/Modules/IDS/IDS_print.c | 689 ++++++++++++++++----- .../Embedded/Modules/Thread/Thread_Winder.c | 6 +- .../Embedded/Modules/Thread/Thread_print.c | 33 +- .../Embedded/Software Release Notes.txt | 8 + .../Embedded/StateMachines/Printing/JobSTM.c | 21 +- .../Embedded/StateMachines/Printing/PrintingSTM.c | 233 ++++++- .../Embedded/StateMachines/Printing/PrintingSTM.h | 13 + 21 files changed, 915 insertions(+), 236 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index d57d3b14b..3357cfc06 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -55,6 +55,7 @@ int32_t FileSentLength = 0; static char g_cCwdBuf[50] = "/"; uint32_t WrittenBytes = 0; uint32_t ReadBytes = 0; +Task_Handle CommRxTaskHandle; ErrorCode getErrorCode(FRESULT Fresult) @@ -81,27 +82,34 @@ uint32_t FileUploadRequestFunc(MessageContainer* requestContainer) FileUploadResponse response = FILE_UPLOAD_RESPONSE__INIT; WrittenBytes=0; - UploadFileHandle = my_malloc(sizeof(FIL)); - if (UploadFileHandle == 0) + if (JobIsActive()) Fresult = FR_DENIED; else { - Fresult = f_open(UploadFileHandle,request->path,FA_READ | FA_WRITE |FA_OPEN_ALWAYS| FA_CREATE_ALWAYS); - if (Fresult == FR_OK) - { - FileLength = request->length; - response.has_maxchunklength = true; - response.maxchunklength = MAX_CHUNK_LENGTH; - strcpy(FileHandleChar, "1234"); - response.uploadid = FileHandleChar; //supporting only single file at each time. - } + UploadFileHandle = my_malloc(sizeof(FIL)); + if (UploadFileHandle == 0) + Fresult = FR_DENIED; else { - free (UploadFileHandle); - UploadFileHandle = 0; - } + Fresult = f_open(UploadFileHandle,request->path,FA_READ | FA_WRITE | FA_OPEN_ALWAYS | FA_CREATE_ALWAYS); + if (Fresult == FR_OK) + { + FileLength = request->length; + response.has_maxchunklength = true; + response.maxchunklength = MAX_CHUNK_LENGTH; + strcpy(FileHandleChar, "1234"); + response.uploadid = FileHandleChar; //supporting only single file at each time. + } + else + { + free (UploadFileHandle); + UploadFileHandle = 0; + } + } } + CommRxTaskHandle = Task_self(); + Task_setPri(CommRxTaskHandle, 4); responseContainer = createContainer(MESSAGE_TYPE__FileUploadResponse, requestContainer->token, false, &response, &file_upload_response__pack, &file_upload_response__get_packed_size); @@ -123,6 +131,7 @@ uint32_t FileChunkUploadRequestFunc(MessageContainer* requestContainer) { //uint32_t status = OK; FRESULT Fresult = FR_OK; + bool FileDone = false; MessageContainer responseContainer; @@ -142,6 +151,7 @@ uint32_t FileChunkUploadRequestFunc(MessageContainer* requestContainer) if(Fresult != FR_OK) { LOG_ERROR (Fresult,"f_write error"); + FileDone = true; } else { @@ -152,6 +162,7 @@ uint32_t FileChunkUploadRequestFunc(MessageContainer* requestContainer) f_close(ReceivedFileHandle); free (UploadFileHandle); FileReceivedLength = 0; + FileDone = true; } else { @@ -161,6 +172,7 @@ uint32_t FileChunkUploadRequestFunc(MessageContainer* requestContainer) f_close(ReceivedFileHandle); free (UploadFileHandle); FileReceivedLength = 0; + FileDone = true; } } } @@ -185,6 +197,8 @@ uint32_t FileChunkUploadRequestFunc(MessageContainer* requestContainer) file_chunk_upload_request__free_unpacked(request,NULL); my_free(responseContainer.data.data); SendChars(container_buffer, container_size); + if (FileDone == true) + Task_setPri(CommRxTaskHandle, 9); return OK; } @@ -504,7 +518,7 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) #define MAX_NUM_OF_FILES 10 DIR dir; FILINFO* fno[MAX_NUM_OF_FILES]; - char FullPath[MAX_NUM_OF_FILES][50]; + char FullPath[MAX_NUM_OF_FILES][100]; int i,NumOfFiles = 0; FRESULT Fresult = FR_OK; @@ -580,11 +594,14 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) } responseContainer.continuous = false; uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); - size_t container_size = message_container__pack(&responseContainer, container_buffer); + if (container_buffer) + { + size_t container_size = message_container__pack(&responseContainer, container_buffer); + SendChars(container_buffer, container_size); + } my_free(responseContainer.data.data); my_free(FilesInfo); get_files_request__free_unpacked(request,NULL); - SendChars(container_buffer, container_size); for (i = 0;i < NumOfFiles;i++) { if (fno[i]) diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c index 456c30290..a31f4bef8 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c @@ -21,6 +21,7 @@ #include #include +#include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" #include "drivers/FPGA/Full_Vme/FPGA_Programming_Up.h" #include "drivers/FPGA/Full_Vme/ispvme/vmopcode.h" #include "Common/Utilities/Utils.h" diff --git a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c index e037f2bad..7f22a613a 100644 --- a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c +++ b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c @@ -20,7 +20,7 @@ typedef struct } TangoVersion_t; -TangoVersion_t _gTangoVersion = {1,3,8,12}; +TangoVersion_t _gTangoVersion = {1,3,8,2}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; char _gTangoName [MAX_STRING_LEN] = "Tango01 ";//d diff --git a/Software/Embedded_SW/Embedded/Common/report/distributor.c b/Software/Embedded_SW/Embedded/Common/report/distributor.c index c026ad4d2..f011653ec 100644 --- a/Software/Embedded_SW/Embedded/Common/report/distributor.c +++ b/Software/Embedded_SW/Embedded/Common/report/distributor.c @@ -242,7 +242,7 @@ Void reportService(UArg arg0, UArg arg1) ReportInitParams InitParams; InitParams.DistributorQueueMaxMsgs = 30; InitParams.DistributorTaskPriority = 6; - InitParams.MaxNumOfFilterNames = 1;//30 + InitParams.MaxNumOfFilterNames = 30; InitParams.MaxNumberOfPrivateDistributors = 2; ReportInit (InitParams); diff --git a/Software/Embedded_SW/Embedded/DataDef.h b/Software/Embedded_SW/Embedded/DataDef.h index 424eff1d8..1b5f000f2 100644 --- a/Software/Embedded_SW/Embedded/DataDef.h +++ b/Software/Embedded_SW/Embedded/DataDef.h @@ -400,7 +400,7 @@ Supports diagnostic (--diag_suppress, - pds) #define HEAD6_PT100 TEMP_SENSE_AN_ENCLOSURETEMP3 #define MIXER_PT100 TEMP_SENSE_ANALOG_MIXCHIP_TEMP -/* + extern PackageHandle ControlFilter; extern PackageHandle HeatersFilter; extern PackageHandle JobFilter ; @@ -415,6 +415,6 @@ extern PackageHandle FPGAFilter; extern PackageHandle LoadFilter; extern PackageHandle InitFilter; extern PackageHandle MaintFilter; -*/ + #endif /* DATADEF_H */ diff --git a/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.c b/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.c index 637c91e7d..ac1cff75e 100644 --- a/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.c +++ b/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.c @@ -33,7 +33,7 @@ uint32_t ReadAppAndProgram(uint32_t ui32FlashStart,uint32_t ui32FileSize,void* b uint32_t ui32ProgAddr; uint32_t ui32BufferAddr; volatile uint32_t ui32Idx; - uint32_t ui32FlashEnd; + //uint32_t ui32FlashEnd; // @@ -41,7 +41,7 @@ uint32_t ReadAppAndProgram(uint32_t ui32FlashStart,uint32_t ui32FileSize,void* b // If reserved space is configured, then the ending address is reduced // by the amount of the reserved block. // - ui32FlashEnd = ui32FlashStart + ui32FileSize; + //ui32FlashEnd = ui32FlashStart + ui32FileSize; // @@ -68,7 +68,7 @@ uint32_t ReadAppAndProgram(uint32_t ui32FlashStart,uint32_t ui32FileSize,void* b // stick updater). // ui32ProgAddr = ui32FlashStart; - ui32BufferAddr = buffer; + ui32BufferAddr = (uint32_t)buffer; ui32Remaining = ui32FileSize; while(ui32Remaining) { diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index 7c0f9a6c1..8e76badfe 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -337,7 +337,7 @@ const AlarmHandlingItemStruc HardCodedAlarmItem[MAX_SYSTEM_ALARMS]={ char AlarmStorePath[25] ="0://SysInfo//AlarmPrm.cfg"; -bool DispenserInUse[MAX_SYSTEM_DISPENSERS] = {false,false,false,false,false,false,false,false}; +//bool DispenserInUse[MAX_SYSTEM_DISPENSERS] = {false,false,false,false,false,false,false,false}; bool EventsNotificationRequestAccepted = false; //read dispensers limit switches. 25 - send warning. up - stop job and send alarm //Cone missing @@ -471,7 +471,7 @@ uint32_t AlarmHandlingConsequentActions(uint32_t AlarmId, DebugLogCategory Sever MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1+Disp_i,Hard_Hiz); if (JobIsActive()) { - if (DispenserInUse[Disp_i] == false) + if (DispenserUsedInJob[Disp_i] == false) AlarmItem[AlarmId].Severity = DEBUG_LOG_CATEGORY__Info; } } @@ -481,7 +481,7 @@ uint32_t AlarmHandlingConsequentActions(uint32_t AlarmId, DebugLogCategory Sever MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1+Disp_i,Hard_Hiz); if (JobIsActive()) { - if (DispenserInUse[Disp_i] == false) + if (DispenserUsedInJob[Disp_i] == false) AlarmItem[AlarmId].Severity = DEBUG_LOG_CATEGORY__Info; } break; @@ -505,24 +505,26 @@ uint32_t AlarmHandlingConsequentActions(uint32_t AlarmId, DebugLogCategory Sever } JobEndReasonEnum AlarmHandlingPrepareJob(void *CurrentJob) { - JobTicket* JobTicket = CurrentJob; + //JobTicket* JobTicket = CurrentJob; EventType HeaterEventType[MAX_HEATERS_NUM*2] = {EVENT_TYPE__DRYER_ZONE_1_OVERTEMPERATURE,EVENT_TYPE__DRYER_ZONE_2_OVERTEMPERATURE,EVENT_TYPE__DRYER_ZONE_1_OVERTEMPERATURE,EVENT_TYPE__DYEING_HEAD_ZONE_1_OVERTEMPERATURE,EVENT_TYPE__DYEING_HEAD_ZONE_2_OVERTEMPERATURE, EVENT_TYPE__DYEING_HEAD_ZONE_3_OVERTEMPERATURE,EVENT_TYPE__DYEING_HEAD_ZONE_4_OVERTEMPERATURE,EVENT_TYPE__DYEING_HEAD_ZONE_5_OVERTEMPERATURE,EVENT_TYPE__DYEING_HEAD_ZONE_6_OVERTEMPERATURE, EVENT_TYPE__MIXER_OVERTEMPERATURE}; EventType HeaterEventTypeUnder[MAX_HEATERS_NUM*2] = {EVENT_TYPE__DRYER_ZONE_1_UNDERTEMPERATURE_B,EVENT_TYPE__DRYER_ZONE_2_UNDERTEMPERATURE_B,EVENT_TYPE__DRYER_ZONE_1_UNDERTEMPERATURE_B,EVENT_TYPE__DYEING_HEAD_ZONE_1_UNDERTEMPERATURE_B,EVENT_TYPE__DYEING_HEAD_ZONE_2_UNDERTEMPERATURE_B, EVENT_TYPE__DYEING_HEAD_ZONE_3_UNDERTEMPERATURE_B,EVENT_TYPE__DYEING_HEAD_ZONE_4_UNDERTEMPERATURE_B,EVENT_TYPE__DYEING_HEAD_ZONE_5_UNDERTEMPERATURE_B,EVENT_TYPE__DYEING_HEAD_ZONE_6_UNDERTEMPERATURE_B, EVENT_TYPE__MIXER_UNDERTEMPERATURE_B}; - int Segment_i,Brush_i,Dispenser_i,DispenserId,Alarm_i,Heater_i,AlarmId=0; + int Dispenser_i,Alarm_i,Heater_i,AlarmId=0; HeaterState HeaterState; - for (Dispenser_i = 0;Dispenser_i < MAX_SYSTEM_DISPENSERS;Dispenser_i++) - { - DispenserInUse[Dispenser_i] = false; - } + //for (Dispenser_i = 0;Dispenser_i < MAX_SYSTEM_DISPENSERS;Dispenser_i++) + //{ + // DispenserInUse[Dispenser_i] = false; + //} JobEndReasonEnum status = JOB_OK; - if (JobTicket->n_segments == 0) + IDS_MapDispenserUsedinJob(CurrentJob); + if (n_segments == 0) return OK; - for (Segment_i=0;Segment_in_segments;Segment_i++) + + /*for (Segment_i=0;Segment_in_segments;Segment_i++) { for (Brush_i=0;Brush_isegments[Segment_i]->n_brushstops;Brush_i++) { @@ -540,11 +542,12 @@ JobEndReasonEnum AlarmHandlingPrepareJob(void *CurrentJob) }//if dispensers }//for brush }//for segments + */ if (Configured[Module_IDS]) { for (Dispenser_i=0;Dispenser_ihas_type = true; AlarmState[Alarm_i].EventPtr->type = AlarmItem[Alarm_i].EventType; AlarmState[Alarm_i].EventPtr->message = AlarmItem[Alarm_i].EventName; + AlarmState[Alarm_i].Status = value; Report("Alarm ON ", __FILE__,__LINE__,AlarmItem[Alarm_i].EventType, RpMessage, value, Alarm_i); } } else { Report("Alarm OFF ", __FILE__,__LINE__,AlarmItem[Alarm_i].EventType, RpMessage, value, Alarm_i); + AlarmState[Alarm_i].Status = value; if (AlarmState[Alarm_i].EventPtr) my_free(AlarmState[Alarm_i].EventPtr); } @@ -1017,20 +1021,33 @@ void SendEventNotifications(void) response.n_events++; } } - response.events = (Event **)my_malloc(sizeof(Event*)*response.n_events); - if(response.events) + + if (response.n_events) { - for (i = 0;i=InitialDispenserPressure)||(DispenserHomingTime[DispenserId]>InitialDispenserTimeout)) { MotorStop(deviceID,Hard_Hiz); - MotorSetMicroStep(deviceID, MotorsCfg[deviceID].microstep); HomingActive[DispenserId]= false; Report("End backlash",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,(int)DispenserHomingTime[DispenserId],0); @@ -169,6 +168,7 @@ uint32_t IDS_Dispenser_Alarm_On (uint8_t deviceID) Enable_MidTank_Pressure_Reading(deviceID); status |= MotorSetMicroStep(deviceID, MotorsCfg[deviceID].microstep); status |= MotorStop(deviceID, Hard_Hiz); + JobEndReason = JOB_OUT_OF_DYE; return status; } uint32_t IDS_Dispenser_Alarm_Off (uint8_t deviceID) diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 38c139141..d868354dd 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -12,10 +12,18 @@ #include "../thread/thread.h" #include "PMR/Hardware/Hardwaremotor.pb-c.h" #include "PMR/Hardware/HardwareDispenser.pb-c.h" +#include "PMR/Printing/JobDescriptionFileBrushStop.pb-c.h" +#include "PMR/Printing/JobDescriptionFileSegment.pb-c.h" +#include "PMR/Printing/JobUploadStrategy.pb-c.h" +#include "PMR/Printing/JobSegment.pb-c.h" +#include "PMR/Printing/JobTicket.pb-c.h" #include "StateMachines/Printing/printingSTM.h" #include "drivers/motors/motor.h" #include "drivers/valves/valve.h" +#include "Common/SWUpdate/FileSystem.h" +#include "drivers/Flash_Memory/fatfs/ff.h" + #include "modules/heaters/heaters.h" #include "drivers/Flash_ram/FlashProgram.h" @@ -33,7 +41,8 @@ typedef struct }DispenserControlConfig_t; HardwarePidControl *DispensersControl;// = (HardwarePidControl *)GENHWCFG_MAP_IN_FLASH + 0x4000; #define LUBRICANT_DISPENSER 7 -#define MAX_DYE_DISPENSERS 7 +#define CLEANER_DISPENSER 7 +#define MAX_DYE_DISPENSERS 6 int32_t DispenserSamples[MAX_SYSTEM_DISPENSERS][MAX_CONTROL_SAMPLES] = {0}; int DispenserSamplePointer[MAX_SYSTEM_DISPENSERS] = {0}; double DispenserNormalizedErrorCoEfficient[MAX_SYSTEM_DISPENSERS] = {0}; @@ -45,7 +54,8 @@ bool IDS_Active = false; /******************** STRUCTURES AND ENUMs ********************************************/ uint32_t IDS_Valve_DistanceToSpoolReady(uint32_t deviceID, uint32_t ReadValue); uint32_t IDS_Valve_PresegmentReady(uint32_t deviceID, uint32_t ReadValue); -bool IDS_isDispenserUsedNextSegment(void *JobDetails,int DispenserId, int SegmentId); +uint32_t IDSBrushStopRestartCallback(uint32_t IfIndex, uint32_t readValue); +//bool IDS_isDispenserUsedNextSegment(void *JobDetails,int DispenserId, int SegmentId); /******************** GLOBAL PARAMETERS ********************************************/ DispenserControlConfig_t DispenserControlConfig[MAX_SYSTEM_DISPENSERS]; uint32_t ControlIdtoDispenserId [MAX_SYSTEM_DISPENSERS] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; @@ -122,7 +132,7 @@ void DispenserPrepareReady(void) return; //not all configured Dispensers are ready } } - REPORT_MSG(Module_IDS,"DispenserPrepareReady"); + REPORT_MSG(Module_IDS,"All Dispensers Prepare Ready"); PrepareReady(Module_IDS,ModuleDone); } //******************************************************************************************************************** @@ -137,45 +147,296 @@ void DispenserPrepareReady(void) return OK; // all configured heaters are ready } - bool IDS_MapDispenserUsedinJob(void *JobDetails) +/* + void OpenJobFile(); +void CloseJobFile(); +JobDescriptionFileSegment *GetNextSegmentFromJobFile(); +void FreeSegmentFileData(JobDescriptionFileSegment *Segment); +JobDescriptionFileBrushStop *GetNextBrushStopFromJobFile(); +void FreeBrushStopFileData(JobDescriptionFileBrushStop *BrushStop); + + */ + /************************************************************************************************************************************/ + uint32_t IDS_MapDispenserUsedinFileJobshort(void *JobDetails) + { + JobDescriptionFileBrushStop *BrushStop; + JobDescriptionFileSegment *Segment; + int Dispenser_i, Brush_i,DispenserId; + FRESULT Fresult = FR_OK; + uint32_t status = OK; + + for (Dispenser_i = 0;Dispenser_ihas_brushstopscount)&&(Segment->brushstopscount)) + { + for (Brush_i=0;Brush_ibrushstopscount;Brush_i++) + { + BrushStop = GetNextBrushStopFromJobFile(); + if (BrushStop) + { + if (BrushStop->n_dispensers) + { + for (Dispenser_i = 0;Dispenser_i < BrushStop->n_dispensers;Dispenser_i++) + { + //prepare the SW structures + DispenserId = BrushStop->dispensers[Dispenser_i]->index; + if (BrushStop->dispensers[Dispenser_i]->nanolitterpersecond>0.0) + { + DispenserUsedInJob[DispenserId] = true; + /*if(DispenserId == LUBRICANT_DISPENSER) + { + lubricant_speed = JobTicket->segments[0]->brushstops[0]->dispensers[Dispenser_i]->nanolitterpersecond/ + JobTicket->segments[0]->brushstops[0]->dispensers[Dispenser_i]->nanoliterperpulse; + REPORT_MSG (lubricant_speed*100, "LUBRICANT_SPEED*100"); + }*/ + } + }//for dispenser + }//if dispensers + else + { + LOG_ERROR (BrushStop->index, "no dispensers in brushstop"); + } + FreeBrushStopFileData(BrushStop); + BrushStop = NULL; + } + else + { + LOG_ERROR (BrushStop, "malloc error"); + status = ERROR; + } + }//for brushstops + }// if brush stop count + FreeSegmentFileData(Segment); + Segment = GetNextSegmentFromJobFile(); + } + FreeSegmentFileData(Segment); + CloseJobFile(); + } + return status; + + } + /************************************************************************************************************************************/ + uint32_t IDS_MapDispenserUsedinFileJob(void *JobDetails) { JobTicket* JobTicket = JobDetails; - int Dispenser_i, Segment_i,Brush_i,DispenserId; + uint8_t *SegmentPtr = 0, *BrushStopPtr = 0; + JobDescriptionFileBrushStop *BrushStop; + JobDescriptionFileSegment *Segment; + int Dispenser_i, Brush_i,DispenserId; + uint32_t Bytes = 0,readBytes = 0,ImmediateRead = 0,SegmentSize = 0,BrushStopSize = 0; + uint32_t status = OK; + FRESULT Fresult = FR_OK; + FIL *FileHandle = 0; //the system supports a single active file +/* + Parsing the job description file. +The job description file simply contains an array of segments and their brush stops. +The job description file is meant to be read brush stop by brush stop while the job is in progress. +The following diagram represents a single job description file segment structure. +The process of reading the whole file is simply repeating that reading order. + +Each JobDescriptionFileSegment contains a “BrushStopsCount” field that should be used to determine how many brush stops are associated +with the current segment and how many times the process of reading brush stops should be repeated. +1. 32bit integer containing the next JobFileDescriptionSegment message byte count +2. JobDescriptionFileSegment message +3. 32bit integer containing the next JobDescriptionFileBrushStop message byte count +4. JobDescriptionFileBrushStop message + +1. Read segment message length. +2. Read segment message. +a. Read brush stop message length. +b. Read brush stop message. +c. Go to step 2.a x Segment.BrushStopsCount. +3. Go to step 1 until end of file. + */ for (Dispenser_i = 0;Dispenser_in_segments == 0) - return false; + n_segments = 0; + if (JobTicket->uploadstrategy == JOB_UPLOAD_STRATEGY__JobDescriptionFile) + { + FileHandle = my_malloc(sizeof(FIL)); - for (Segment_i=0;Segment_in_segments;Segment_i++) + Fresult = FileOpen(JobTicket->jobdescriptionfile, &Bytes, FileHandle); + if (Fresult == FR_OK) { - for (Brush_i=0;Brush_isegments[Segment_i]->n_brushstops;Brush_i++) + while((readBytes < Bytes)&&(status == OK)) { - if (JobTicket->segments[Segment_i]->brushstops[Brush_i]->n_dispensers) + Fresult = f_read(FileHandle,&SegmentSize,4,&ImmediateRead ); + if (Fresult == FR_OK) { - for (Dispenser_i = 0;Dispenser_i < JobTicket->segments[Segment_i]->brushstops[Brush_i]->n_dispensers;Dispenser_i++) + readBytes += ImmediateRead; + SegmentPtr = my_malloc (SegmentSize); + if (SegmentPtr) { - //prepare the SW structures - DispenserId = JobTicket->segments[Segment_i]->brushstops[Brush_i]->dispensers[Dispenser_i]->index; - if (JobTicket->segments[Segment_i]->brushstops[Brush_i]->dispensers[Dispenser_i]->nanolitterpersecond>0.0) + Fresult = f_read(FileHandle,SegmentPtr,SegmentSize,&ImmediateRead ); + if (Fresult == FR_OK) { - DispenserUsedInJob[DispenserId] = true; - if(DispenserId == LUBRICANT_DISPENSER) + readBytes += ImmediateRead; + n_segments++; + Segment = job_description_file_segment__unpack(NULL, SegmentSize, SegmentPtr); + if ((Segment->has_brushstopscount)&&(Segment->brushstopscount)) + { + REPORT_MSG (Segment->brushstopscount, "Segment->brushstopscount"); + for (Brush_i=0;Brush_ibrushstopscount;Brush_i++) + { + if (status == ERROR) + break; + Fresult = f_read(FileHandle,&BrushStopSize,4,&ImmediateRead ); + if (Fresult == FR_OK) + { + readBytes += ImmediateRead; + BrushStopPtr = my_malloc (BrushStopSize); + if (BrushStopPtr) + { + Fresult = f_read(FileHandle,BrushStopPtr,BrushStopSize,&ImmediateRead ); + if (Fresult == FR_OK) + { + readBytes += ImmediateRead; + BrushStop = job_description_file_brush_stop__unpack(NULL, BrushStopSize, BrushStopPtr); + REPORT_MSG (BrushStopSize, "BrushStop"); + if (BrushStop->n_dispensers) + { + for (Dispenser_i = 0;Dispenser_i < BrushStop->n_dispensers;Dispenser_i++) + { + //prepare the SW structures + DispenserId = BrushStop->dispensers[Dispenser_i]->index; + if (BrushStop->dispensers[Dispenser_i]->nanolitterpersecond>0.0) + { + DispenserUsedInJob[DispenserId] = true; + } + }//for dispenser + }//if dispensers + else + { + LOG_ERROR (BrushStop->index, "no dispensers in brushstop"); + } + job_description_file_brush_stop__free_unpacked (BrushStop,NULL); + BrushStop = NULL; + } //read brush stop data + else + { + LOG_ERROR (Fresult, "f_read error"); + status = ERROR; + } + my_free(BrushStopPtr); + BrushStopPtr = NULL; + }//brushstop malloc ok + else + { + LOG_ERROR (BrushStopPtr, "malloc error"); + status = ERROR; + } + }//brushstop size read ok + else + { + LOG_ERROR (Fresult, "f_read error"); + status = ERROR; + } + }//for brushstops + }// if brush stop count + else { - lubricant_speed = JobTicket->segments[0]->brushstops[0]->dispensers[Dispenser_i]->nanolitterpersecond/ - JobTicket->segments[0]->brushstops[0]->dispensers[Dispenser_i]->nanoliterperpulse; - REPORT_MSG (lubricant_speed*100, "LUBRICANT_SPEED*100"); + LOG_ERROR (0, "no brushstops error"); + status = ERROR; } + job_description_file_segment__free_unpacked(Segment,NULL); + Segment = NULL; + }// read segment data + my_free(SegmentPtr); + SegmentPtr = NULL; + Task_sleep(10); + }//segment malloc + else + { + LOG_ERROR (SegmentPtr, "malloc error"); + status = ERROR; + } + }//segment read size + else + { + LOG_ERROR (Fresult, "f_read error"); + status = ERROR; + } + }//while(readBytes < Bytes) + } + else + { + LOG_ERROR (Fresult, "FileOpen error"); + status = ERROR; + } + }//file job + + if (SegmentPtr) + my_free(SegmentPtr); + if (BrushStopPtr) + my_free(BrushStopPtr); + if (Segment != NULL) + job_description_file_segment__free_unpacked(Segment,NULL); + if (BrushStop != NULL) + job_description_file_brush_stop__free_unpacked (BrushStop,NULL); + Fresult = f_close(FileHandle); + REPORT_MSG (n_segments, "Finished checking the file"); + return status; - } - }//for dispenser - }//if dispensers - }//for brush - }//for segments + } +/************************************************************************************************************************************/ + bool IDS_MapDispenserUsedinJob(void *JobDetails) + { + JobTicket* JobTicket = JobDetails; + int Dispenser_i, Segment_i,Brush_i,DispenserId; + + if (JobTicket->uploadstrategy == JOB_UPLOAD_STRATEGY__JobDescriptionFile) + { + return (IDS_MapDispenserUsedinFileJob(JobDetails)); + //return (IDS_MapDispenserUsedinFileJobshort(JobDetails)); + } + else + { + for (Dispenser_i = 0;Dispenser_isegments[Segment_i]->n_brushstops;Brush_i++) + { + if (JobTicket->segments[Segment_i]->brushstops[Brush_i]->n_dispensers) + { + for (Dispenser_i = 0;Dispenser_i < JobTicket->segments[Segment_i]->brushstops[Brush_i]->n_dispensers;Dispenser_i++) + { + //prepare the SW structures + DispenserId = JobTicket->segments[Segment_i]->brushstops[Brush_i]->dispensers[Dispenser_i]->index; + if (JobTicket->segments[Segment_i]->brushstops[Brush_i]->dispensers[Dispenser_i]->nanolitterpersecond>0.0) + { + DispenserUsedInJob[DispenserId] = true; + if(DispenserId == LUBRICANT_DISPENSER) + { + lubricant_speed = JobTicket->segments[0]->brushstops[0]->dispensers[Dispenser_i]->nanolitterpersecond/ + JobTicket->segments[0]->brushstops[0]->dispensers[Dispenser_i]->nanoliterperpulse; + REPORT_MSG (lubricant_speed*100, "LUBRICANT_SPEED*100"); + } + + } + }//for dispenser + }//if dispensers + }//for brush + }//for segments + } - return false; + return true; } @@ -214,7 +475,7 @@ void DispenserPrepareReady(void) //ValveCommand (Enable,MixerDirection); } //set 3 dancers to the profile positions - IDS_MapDispenserUsedinJob(JobDetails); + //IDS_MapDispenserUsedinJob(JobDetails); for (i = 0; i < MAX_SYSTEM_DISPENSERS; i++) { if (DispenserUsedInJob[i] == true) //we actually should check for all dispensers @@ -228,32 +489,6 @@ void DispenserPrepareReady(void) } DispenserPrepareReady(); return OK; -} -bool IDS_isDispenserUsedNextSegment(void *SegmentDetails,int DispenserId, int SegmentId) -{ - JobSegment* Segment = SegmentDetails; - int Dispenser_i,n_dispensers; - if (Segment->brushstops[0]->n_dispensers) - { - n_dispensers = Segment->brushstops[0]->n_dispensers; - for (Dispenser_i = 0;Dispenser_i < n_dispensers;Dispenser_i++) - { - if (DispenserId == Segment->brushstops[0]->dispensers[Dispenser_i]->index) //dispenser is in use next segment - { - if (Segment->brushstops[0]->dispensers[Dispenser_i]->nanolitterpersecond>0) - { - return true; - } - else - { - return false; - } - } - } - } - - return false; - } //******************************************************************************************************************** uint32_t IDS_Valve_PresegmentValveReady(uint32_t deviceID, uint32_t ReadValue) @@ -287,8 +522,17 @@ bool IDS_isDispenserUsedNextSegment(void *SegmentDetails,int DispenserId, int Se int lInterSegmentLength = 0; int InterSegmentStepsLimit = 0,InterSegmentStepsCount = 0; - int InterSegmentWFCFTime; + uint32_t InterSegmentStartSprayCleaner; + uint32_t InterSegmentStartRocking; + uint32_t InterSegmentCenterRockers; + uint32_t InterSegmentStartWFCFDispensers; + bool EnableCleaning = false; + + uint32_t DispenserPreSegmentControlId = 0xFF; + uint32_t BrushStopControlId = 0xFF; + uint32_t PreSegmentControlId = 0xFF; + //******************************************************************************************************************** uint32_t IDSPreSegmentStateCallbackRunner(uint32_t IfIndex, uint32_t ReadValue) @@ -313,19 +557,49 @@ This means that for each Pre-segment we must calculate: TW,TU,Tending, This means that for each segment we must calculate: Tx,Ty. */ +/*uint32_t InterSegmentStartSprayCleaner = 500; +uint32_t InterSegmentStartRocking = 1000; +uint32_t InterSegmentCenterRockers = 3000; +uint32_t InterSegmentStartWFCFDispensers = lInterSegmentLength-1500;*/ //InterSegmentStepsLimit = lInterSegmentLength*10;//100 millisec steps - InterSegmentStepsCount++; - if (InterSegmentStepsCount == InterSegmentStepsLimit) + InterSegmentStepsCount+=100; + if (InterSegmentStepsCount == lInterSegmentLength) { - IDS_Valve_PresegmentReady(1,0); + //IDS_Valve_PresegmentReady(1,0); + Report("End of Pre-segment Handling",__FILE__,__LINE__,InterSegmentStepsCount,RpWarning,(int)lInterSegmentLength,0); SafeRemoveControlCallback(DispenserPreSegmentControlId,IDSPreSegmentStateCallbackRunner); } + if (EnableCleaning == true) + { + if (InterSegmentStartSprayCleaner == InterSegmentStepsCount) + { + Report("Start Spray Cleaner",__FILE__,__LINE__,InterSegmentStepsCount,RpWarning,(int)lInterSegmentLength,0); + //startClenerSpray(speed); + } + if (InterSegmentStartRocking == InterSegmentStepsCount) + { + Report("Start cleaning rockers",__FILE__,__LINE__,InterSegmentStepsCount,RpWarning,(int)lInterSegmentLength,0); + //startRocking(leftspeed,rightspeed); + } + if (InterSegmentCenterRockers == InterSegmentStepsCount) + { + Report("Stop spray and center rockers",__FILE__,__LINE__,InterSegmentStepsCount,RpWarning,(int)lInterSegmentLength,0); + //stopClenerSpray(speed); + //centerRockers(); + } + } + if (InterSegmentStartWFCFDispensers == InterSegmentStepsCount) + { + Report("start dispensers at rate * WFCF",__FILE__,__LINE__,InterSegmentStepsCount,RpWarning,(int)lInterSegmentLength,0); + //startDispensersAtSegmentSpeed*1=WFCFClenerSpray(speed); + } return OK; } - +JobDescriptionFileBrushStop * FileBrushStop; uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) { JobSegment* Segment = SegmentDetails; + JobDispenser **Dispensers; //set the speed only before the first segment, speed is constant accros job int Dispenser_i,n_dispensers,DispenserId; TimerMotors_t HW_Motor_Id; @@ -339,7 +613,9 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) REPORT_MSG(SegmentId,"IDSPreSegmentState"); if (JobBrushStopId>=Segment->n_brushstops) { - LOG_ERROR(JobBrushStopId,"Error JobBrushStopId"); + LOG_ERROR(Segment->n_brushstops,"Error JobBrushStopId"); + JobEndReason = JOB_OUT_OF_DYE; + PreSegmentReady(Module_IDS,ModuleFail); return ERROR; } @@ -347,148 +623,248 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) if ((EnableIntersegment == true)&&(IntersegmentLength>0)) { Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste); //if intersegment is defined throw the ink away - lInterSegmentLength = ((IntersegmentLength*100)/dyeingspeed); - InterSegmentStepsLimit = lInterSegmentLength*10;//100 millisec steps - InterSegmentStepsCount = 0; - /*DispenserPreSegmentControlId = AddControlCallback( IDSPreSegmentStateCallbackRunner, 100,TemplateDataReadCBFunction ,0, 0, 0 ); - if (DispenserPreSegmentControlId == 0xFF) + if (SegmentId>0) { - Report("Add control callback failed",__FILE__,__LINE__,(int)InterSegmentLength,RpWarning,(int)0,0); - return ERROR; - }*/ + lInterSegmentLength = ((IntersegmentLength*100)*1000/dyeingspeed); + lInterSegmentLength-=(lInterSegmentLength%100); //round to a 100 multiplication + InterSegmentStepsCount = 0; + DispenserPreSegmentControlId = AddControlCallback( IDSPreSegmentStateCallbackRunner, 100,TemplateDataReadCBFunction ,0, 0, 0 ); + if (DispenserPreSegmentControlId == 0xFF) + { + Report("Add control callback failed",__FILE__,__LINE__,(int)100,RpWarning,(int)0,0); + return ERROR; + } + Report("Add control callback ",__FILE__,__LINE__,(int)100,RpWarning,(int)IntersegmentLength,0); + if (EnableCleaning == true) + { + InterSegmentStartSprayCleaner = 500; + InterSegmentStartRocking = 1000; + InterSegmentCenterRockers = 3000; + } + InterSegmentStartWFCFDispensers = lInterSegmentLength-1500; + } } - if (Segment->brushstops[JobBrushStopId]->n_dispensers) + if (uploadstrategy == JOB_UPLOAD_STRATEGY__Default) { + Dispensers = Segment->brushstops[JobBrushStopId]->dispensers; n_dispensers = Segment->brushstops[JobBrushStopId]->n_dispensers; + } + else + { + if (BrushStopControlId != 0xFF) + { + RemoveControlCallback(BrushStopControlId,IDSBrushStopRestartCallback); + BrushStopControlId = 0xFF; + } + FileBrushStop = GetNextBrushStopFromJobFile(); + if (FileBrushStop) + { + REPORT_MSG(FileBrushStop->index,"BrushStopRead Index"); + Dispensers = FileBrushStop->dispensers; + n_dispensers = FileBrushStop->n_dispensers; + } + else + { + LOG_ERROR(FileBrushStop,"BrushStopReadError"); + JobEndReason = JOB_OUT_OF_DYE; + SegmentReady(Module_IDS,ModuleFail); + } + } + if (n_dispensers) + { for (Dispenser_i = 0;Dispenser_i < n_dispensers;Dispenser_i++) { - DispenserId = Segment->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->index; - HW_Motor_Id = DispenserIdToMotorId[DispenserId]; - if (MotorsCfg[HW_Motor_Id].hardwaremotortype != DispenserIdToMotorId[DispenserId])//unconfigured dispenser - { - REPORT_MSG(DispenserId,"Dispenser PreSegment not configured"); - continue; - } + DispenserId = Dispensers[Dispenser_i]->index; DispenserPreSegmentReady[DispenserId] = false; } for (Dispenser_i = 0;Dispenser_i < n_dispensers;Dispenser_i++) { - DispenserId = Segment->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->index; + DispenserId = Dispensers[Dispenser_i]->index; HW_Motor_Id = DispenserIdToMotorId[DispenserId]; if (MotorsCfg[HW_Motor_Id].hardwaremotortype != DispenserIdToMotorId[DispenserId])//unconfigured dispenser { REPORT_MSG(DispenserId,"Dispenser PreSegment not configured"); + DispenserPreSegmentReady[DispenserId] = true; //27/03/19 check if job should be stopped continue; } REPORT_MSG(DispenserId,"IDS_Valve_Presegment start"); IDS_Dispenser_Set_Flow_Params(DispenserId,0,0); - if (Segment->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->dispenserstepdivision != DISPENSER_STEP_DIVISION__Auto) + if (Dispensers[Dispenser_i]->dispenserstepdivision != DISPENSER_STEP_DIVISION__Auto) { - MotorSetMicroStep(HW_Motor_Id, Segment->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->dispenserstepdivision); + MotorSetMicroStep(HW_Motor_Id, Dispensers[Dispenser_i]->dispenserstepdivision); } else { MotorSetMicroStep(HW_Motor_Id, MotorsCfg[HW_Motor_Id].microstep); } + MotorStop(HW_Motor_Id,Hard_Hiz); //26/03/19 test without valves + CurrentDispenserSpeed[DispenserId] = 0; + IDS_Valve_PresegmentReady(DispenserId,0); //27/03/19 to be removed when the presegment handler will be added + //REPORT_MSG(DispenserId,"Dispenser stopped pre Segment"); + } + } + + return OK; +} +//******************************************************************************************************************** - if (Segment->brushstops[0]->dispensers[Dispenser_i]->nanolitterpersecond==0) + char IdsMessage[100]; +uint32_t SegmentNumOfBrushStops = 0; +double BrushStopTime = 0; + +void IDS_StartBrushStop(int n_dispensers, JobDispenser** Dispensers) +{ + int Dispenser_i,DispenserId; + TimerMotors_t HW_Motor_Id; + double segmentfirst_speed; + Report("IDS_StartBrushStop",__FILE__,__LINE__,(int)JobBrushStopId,RpWarning,(int)0,0); + + if (n_dispensers) + { + for (Dispenser_i = 0; Dispenser_i < n_dispensers; Dispenser_i++) + { + DispenserId = Dispensers[Dispenser_i]->index; + HW_Motor_Id = DispenserIdToMotorId[DispenserId]; + if (MotorsCfg[HW_Motor_Id].hardwaremotortype + != DispenserIdToMotorId[DispenserId]) + continue; + + //(Speed*uStep*PPR)/((2*PI*Dispenser_Radius) + segmentfirst_speed = Dispensers[Dispenser_i]->nanolitterpersecond + / Dispensers[Dispenser_i]->nanoliterperpulse; + if (Dispensers[Dispenser_i]->dispenserstepdivision + != DISPENSER_STEP_DIVISION__Auto) { - MotorStop(HW_Motor_Id,Hard_Hiz); //26/03/19 test without valves - IDS_Valve_PresegmentReady(DispenserId,0); - //Control3WayValvesWithCallback ((Valves_t)DispenserId, MidTank_Dispenser, IDS_Valve_PresegmentValveReady); //direction: MidTank_Dispenser or Dispenser_Mixer - //IDS_Dispenser_Close_Valve_And_Stop_Motor(DispenserId,IDS_Valve_PresegmentValveReady); - REPORT_MSG(DispenserId,"Dispenser Not Used Next Segment"); + //MotorSetMicroStep(HW_Motor_Id, Dispensers[Dispenser_i]->dispenserstepdivision); + segmentfirst_speed /= + Dispensers[Dispenser_i]->dispenserstepdivision; //the dye supply is calculated based on a 1/8 microstep + IDS_Dispenser_Set_Flow_Params( + DispenserId, Dispensers[Dispenser_i]->nanoliterperpulse, + Dispensers[Dispenser_i]->dispenserstepdivision); } else { - if (IntersegmentLength&&(SegmentId>0)) //there is an intersegment, stop all the dispensers. otherwise stop only dispensers that are not in use in the next segment. - { - //Control3WayValvesWithCallback ((Valves_t)DispenserId, MidTank_Dispenser, IDS_Valve_PresegmentValveReady); //direction: MidTank_Dispenser or Dispenser_Mixer - MotorStop(HW_Motor_Id,Hard_Hiz); //26/03/19 test without valves - IDS_Valve_PresegmentReady(DispenserId,0); - //IDS_Dispenser_Close_Valve_And_Stop_Motor(DispenserId,IDS_Valve_PresegmentValveReady); - REPORT_MSG(DispenserId,"Dispenser Used Next Segment with intersegment"); - } - else - { - IDS_Valve_PresegmentReady(DispenserId,0); - } - REPORT_MSG(DispenserId,"Dispenser is Used Next Segment"); + //segmentfirst_speed/=MotorsCfg[HW_Motor_Id].microstep; //the dye supply is calculated based on a 1/8 microstep + IDS_Dispenser_Set_Flow_Params( + DispenserId, Dispensers[Dispenser_i]->nanoliterperpulse, + MotorsCfg[HW_Motor_Id].microstep); + } + if ((int) segmentfirst_speed > 0) + { + DispenserSegmentReady[DispenserId] = false; + //Control3WayValvesWithCallback (DispenserId, Dispenser_Mixer, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer + IDS_Dispenser_Start_Motor_and_Open_Valve(DispenserId, + segmentfirst_speed, + NULL); + usnprintf(IdsMessage, 80, + "Dispenser %d nl/sec %d nl/pulse %d speed %d", + DispenserId, + (int) Dispensers[Dispenser_i]->nanolitterpersecond, + (int) Dispensers[Dispenser_i]->nanoliterperpulse, + (int) segmentfirst_speed); + //REPORT_MSG(segmentfirst_speed,IdsMessage); + Report(IdsMessage, __FILE__, __LINE__, Dispenser_i, RpWarning, segmentfirst_speed, 0); + SendJobProgress(0.0, 0, false, IdsMessage); } } } +} +uint32_t IDSBrushStopRestartCallback(uint32_t IfIndex, uint32_t readValue) +{ + JobDispenser **Dispensers = NULL; + int n_dispensers = 0; + JobSegment* Segment = (void *)IfIndex; + if (uploadstrategy == JOB_UPLOAD_STRATEGY__Default) + { + Dispensers = Segment->brushstops[JobBrushStopId]->dispensers; + n_dispensers = Segment->brushstops[JobBrushStopId]->n_dispensers; + } + else + { + if (FileBrushStop) + FreeBrushStopFileData(FileBrushStop); + FileBrushStop = GetNextBrushStopFromJobFile(); + if (FileBrushStop) + { + REPORT_MSG(FileBrushStop->index,"BrushStopRead Index"); + Dispensers = FileBrushStop->dispensers; + n_dispensers = FileBrushStop->n_dispensers; + } + else + { + LOG_ERROR(FileBrushStop,"BrushStopReadError"); + JobEndReason = JOB_OUT_OF_DYE; + SegmentReady(Module_IDS,ModuleFail); + } + } + if (n_dispensers) + { + IDS_StartBrushStop(n_dispensers, Dispensers); + } + JobBrushStopId++; + Report("brushstop",__FILE__,__LINE__,(int)JobBrushStopId,RpWarning,(int)SegmentNumOfBrushStops,0); + if (JobBrushStopId >= SegmentNumOfBrushStops) + { + Report("last brushstop",__FILE__,__LINE__,(int)JobBrushStopId,RpWarning,(int)SegmentNumOfBrushStops,0); + SafeRemoveControlCallback(BrushStopControlId,IDSBrushStopRestartCallback); + BrushStopControlId = 0Xff; + } return OK; } -//******************************************************************************************************************** - - uint32_t IDS_Valve_SegmentReady(uint32_t deviceID, uint32_t ReadValue) - { - int i; - DispenserSegmentReady[deviceID] = true; - for (i=0;ibrushstops[JobBrushStopId]->n_dispensers) + + SegmentNumOfBrushStops = Segment->n_brushstops; + BrushStopTime = Segment->length/SegmentNumOfBrushStops; //brushstop in meters + BrushStopTime = ((BrushStopTime*100)/dyeingspeed);//brushstop in seconds + BrushStopTime *= 1000; //brushstop in millisecond + Report("IDSSegmentState",__FILE__,__LINE__,(int)BrushStopTime,RpWarning,(int)SegmentNumOfBrushStops,0); + if (uploadstrategy == JOB_UPLOAD_STRATEGY__Default) { + Dispensers = Segment->brushstops[JobBrushStopId]->dispensers; n_dispensers = Segment->brushstops[JobBrushStopId]->n_dispensers; - for (Dispenser_i = 0;Dispenser_i < n_dispensers;Dispenser_i++) + } + else + { + if (FileBrushStop) { - DispenserId = Segment->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->index; - HW_Motor_Id = DispenserIdToMotorId[DispenserId]; - if (MotorsCfg[HW_Motor_Id].hardwaremotortype != DispenserIdToMotorId[DispenserId])//unconfigured dispenser - continue; - //(Speed*uStep*PPR)/((2*PI*Dispenser_Radius) - segmentfirst_speed = Segment->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->nanolitterpersecond/ - Segment->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->nanoliterperpulse; - if (Segment->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->dispenserstepdivision != DISPENSER_STEP_DIVISION__Auto) - { - //MotorSetMicroStep(HW_Motor_Id, Segment->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->dispenserstepdivision); - segmentfirst_speed/=Segment->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->dispenserstepdivision; //the dye supply is calculated based on a 1/8 microstep - IDS_Dispenser_Set_Flow_Params ( DispenserId, Segment->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->nanoliterperpulse - , Segment->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->dispenserstepdivision); - } - else - { - //segmentfirst_speed/=MotorsCfg[HW_Motor_Id].microstep; //the dye supply is calculated based on a 1/8 microstep - IDS_Dispenser_Set_Flow_Params ( DispenserId, Segment->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->nanoliterperpulse - ,MotorsCfg[HW_Motor_Id].microstep); - } - if ((int)segmentfirst_speed > 0) - { - DispenserSegmentReady[DispenserId] = false; - //Control3WayValvesWithCallback (DispenserId, Dispenser_Mixer, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer - IDS_Dispenser_Start_Motor_and_Open_Valve(DispenserId,segmentfirst_speed,NULL); - usnprintf(IdsMessage, 80, "Dispenser %d nl/sec %d nl/pulse %d speed %d",Dispenser_i,(int)Segment->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->nanolitterpersecond, - (int)Segment->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->nanoliterperpulse,(int)segmentfirst_speed); - //REPORT_MSG(segmentfirst_speed,IdsMessage); - Report(IdsMessage,__FILE__,__LINE__,Dispenser_i,RpWarning,segmentfirst_speed,0); - SendJobProgress(0.0,0,false, IdsMessage); - - - } + Dispensers = FileBrushStop->dispensers; + n_dispensers = FileBrushStop->n_dispensers; + } + else + { + LOG_ERROR(FileBrushStop,"BrushStopReadError"); } } + IDS_StartBrushStop(n_dispensers, Dispensers); + JobBrushStopId++; + if ((BrushStopTime)&&(SegmentNumOfBrushStops > 1)) + { + BrushStopControlId = AddControlCallback( IDSBrushStopRestartCallback, BrushStopTime,TemplateDataReadCBFunction ,SegmentDetails, 0, 0 ); + if (BrushStopControlId == 0xFF) + { + Report("Add control callback failed",__FILE__,__LINE__,(int)BrushStopTime,RpWarning,(int)0,0); + return ERROR; + } + Report("Add control callback ",__FILE__,__LINE__,(int)BrushStopTime,RpWarning,(int)n_dispensers,0); + + } + else + { + if (FileBrushStop) + FreeBrushStopFileData(FileBrushStop); + FileBrushStop = NULL; + } + return OK; } //******************************************************************************************************************** @@ -513,6 +889,7 @@ uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId) return OK; //not all configured heaters are ready } } + REPORT_MSG(deviceID,"IDS_Valve_DistanceToSpoolReady End called"); DistanceToSpoolReady(Module_IDS,ModuleDone); return OK; // all configured heaters are ready } @@ -551,6 +928,14 @@ uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId) IDS_Active = false; Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste); REPORT_MSG(0,"Dispenser End Start"); + if (BrushStopControlId != 0xFF) + { + RemoveControlCallback(BrushStopControlId,IDSBrushStopRestartCallback); + BrushStopControlId = 0xFF; + } + if (FileBrushStop) + FreeBrushStopFileData(FileBrushStop); + FileBrushStop = NULL; for ( Dispenser_i = 0;Dispenser_i < MAX_SYSTEM_DISPENSERS;Dispenser_i++) { if (DispenserUsedInJob[Dispenser_i] == true) diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index d8564963c..1f7836ea5 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -288,7 +288,7 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) //Report(TempScrewStr,__FILE__,__LINE__,0,RpWarning,0, 0); //Report(ScrewStr,__FILE__,__LINE__,ScrewCurrentDirection,RpWarning,CalculationDirectionChangeCounter, 0); //REPORT_MSG(temp , "new winder speed"); - Report("new winder speed",__FILE__,ScrewNumberOfSteps,temp,RpWarning,ScrewSpeed,0); +// Report("new winder speed",__FILE__,ScrewNumberOfSteps,temp,RpWarning,ScrewSpeed,0); } /********************************************************************************/ @@ -382,8 +382,8 @@ uint32_t Winder_End(void) CurrentControlledSpeed[SCREW_MOTOR] = 0; ScrewsStopControlTimer(); //move the cart to the edge so the spool can be easily replaced - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, 1000, GPI_LS_SCREW_RIGHT, NULL,0); - + //MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, 1000, GPI_LS_SCREW_RIGHT, NULL,0); + MotorStop(HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz); return OK; } void Winder_ScrewHomeLimitSwitchInterrupt(void) diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 9f5ece15a..07a32b2a6 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -83,6 +83,11 @@ void ThreadInterSegmentEnded(void); void ThreadDistanceToSpoolEnded(void); uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue); +bool SegmentState = false; +bool PreSegmentState = false; +bool DTSState = false; +void SendSegmentFail(void); + double KeepNormalizedError = 0; bool ThreadControlActive = false; ////////////////////////Slow Motor State//////////////////////////////////// @@ -128,6 +133,7 @@ uint32_t Poolerinitialpos = 0xFFFF; void ThreadUpdateProcessLength (double length, void *Funcptr) { + REPORT_MSG(length,"ThreadUpdateProcessLength"); CurrentRequestedLength = length*100;//Centimetres CurrentProcessedLength = 0; ProcessedLengthFuncPtr = (ProcessedLengthFunc)Funcptr; @@ -436,7 +442,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) JobEndReason = JOB_THREAD_BREAK; ThreadControlActive = false; SendJobProgress(0.0,0,false, TMessage); - SegmentReady(Module_Thread,ModuleFail); + SendSegmentFail(); //AlarmHandlingSetAlarm(EVENT_TYPE__THREAD_BREAK,true); //EndState(CurrentJob,"ReadBreakSensor Error" ); LOG_ERROR(index, "ReadBreakSensor Error"); @@ -466,7 +472,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) JobEndReason = JOB_WINDER_DANCER_FAIL+DancerId; SendJobProgress(0.0,0,false, TMessage); //EndState(CurrentJob,TMessage ); - SegmentReady(Module_Thread,ModuleFail); + SendSegmentFail(); /*switch (index) { case POOLER_MOTOR: @@ -750,10 +756,13 @@ uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId) //set speed for both rocker motors //wait for all motors to get to the required speed (set the target speed for the control to check) //call the job state machine when the thread system is ready - if ((InitialProcess==false) && (EnableIntersegment == true) && (IntersegmentLength >= 1.0)) //fix - avoid intersegment length 0 + if ((InitialProcess==false) && (EnableIntersegment == true)) //&& (IntersegmentLength >= 1.0)) //fix - avoid intersegment length 0 {//add initial presegment and cleaning before first segment ThreadUpdateProcessLength (IntersegmentLength,(void *)ThreadInterSegmentEnded); REPORT_MSG (IntersegmentLength," ThreadPreSegmentState IntersegmentLength"); + SegmentState = false; + PreSegmentState = true; + DTSState = false; } else { @@ -766,6 +775,17 @@ uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId) return OK; } int REPSegmentId = 0; +void SendSegmentFail(void) +{ + if (SegmentState == true) + SegmentReady(Module_Thread,ModuleFail); + else if (PreSegmentState == true) + PreSegmentReady(Module_Thread,ModuleFail); + else if (DTSState == true) + DistanceToSpoolReady(Module_Thread,ModuleFail); + +} + void ThreadInterSegmentEnded(void) { REPORT_MSG (REPSegmentId,"ThreadInterSegmentEnded"); @@ -792,6 +812,9 @@ uint32_t ThreadSegmentState(void *SegmentDetails, int SegmentId) CurrentSegmentId = SegmentId; REPORT_MSG (seglength," ThreadSegmentState"); ThreadUpdateProcessLength (seglength,(void *)ThreadSegmentEnded); + SegmentState = true; + PreSegmentState = false; + DTSState = false; return OK; } @@ -801,6 +824,9 @@ uint32_t ThreadDistanceToSpoolState(void ) seglength = dryerbufferlength; REPORT_MSG (seglength,"ThreadDistanceToSpoolState"); ThreadUpdateProcessLength (seglength,(void *)ThreadDistanceToSpoolEnded); + SegmentState = false; + PreSegmentState = false; + DTSState = true; return OK; } @@ -816,6 +842,7 @@ char Endstr[150]; Report(Endstr,__FILE__,__LINE__,(int)TotalProcessedLength,RpWarning,(int)PoolerTotalProcessedLength,0); ThreadUpdateProcessLength (0.0,(void *)NULL); + TotalProcessedLength = 0.0; SetOriginMotorSpeed(0); #ifdef HUNDRED_MICROSECONDS_DANCER_READ MillisecLogClose(); diff --git a/Software/Embedded_SW/Embedded/Software Release Notes.txt b/Software/Embedded_SW/Embedded/Software Release Notes.txt index 356301dda..d62cee15e 100644 --- a/Software/Embedded_SW/Embedded/Software Release Notes.txt +++ b/Software/Embedded_SW/Embedded/Software Release Notes.txt @@ -1,3 +1,11 @@ +Embedded SW Release note - Version 1.3.8.2 +File upload: prevent on job, reduce priority (watchdog) +Report: packages filters introduced, please feel free to use them. +robustness in communication improved +large number of segments and gradient support - initial +at the end of job the screw does not return back +rockers - adjust values before and after loading the cart + Embedded SW Release note - Version 1.3.8.12 Prepare continous response on sw upgarde - test! Lubrication supported throughout the job - test! diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index 69361bbae..972f79939 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -37,6 +37,7 @@ #include "PMR/Printing/CurrentJobResponse.pb-c.h" #include "PMR/Printing/ResumeCurrentJobRequest.pb-c.h" #include "PMR/Printing/ResumeCurrentJobResponse.pb-c.h" +#include "PMR/Printing/JobUploadStrategy.pb-c.h" #include "PMR/Printing/JobStatus.pb-c.h" #include "PMR/Printing/AbortJobRequest.pb-c.h" #include "PMR/Printing/AbortJobResponse.pb-c.h" @@ -88,7 +89,7 @@ JobSegment *TSegment; JobSpool *Tspool; bool CopyConfigured[MAX_SYSTEM_MODULES]; char ErrorMsg[100]; - +JobUploadStrategy uploadstrategy = JOB_UPLOAD_STRATEGY__Default; ModuleStateEnum PrepareWaiting[MAX_SYSTEM_MODULES] = {ModuleIdle,ModuleIdle,ModuleIdle,ModuleIdle,ModuleIdle}; @@ -377,6 +378,7 @@ uint32_t ThreadJoggingFunc(int speed) { //load essential job prameters to enable thread running Ticket.n_segments = 1; + n_segments = 1; Ticket.segments = my_malloc(sizeof(Ticket.segments)); TSegment = my_malloc(sizeof(JobSegment)); Tspool = my_malloc(sizeof(JobSpool)); @@ -587,7 +589,7 @@ void JobRequestFunc(MessageContainer* requestContainer) ErrorCode error = ERROR_CODE__NONE; JobEndReasonEnum JobAlarmReason = JOB_OK; - if (JobActive == false) + if (JobActive == true) { LOG_ERROR(JobActive, "Job started while active"); } @@ -612,7 +614,17 @@ void JobRequestFunc(MessageContainer* requestContainer) if (CurrentRequest!= NULL) job_request__free_unpacked(CurrentRequest,NULL); CurrentRequest = request; - + n_segments = 0; + if (CurrentJob->uploadstrategy == JOB_UPLOAD_STRATEGY__JobDescriptionFile) + { + LOG_ERROR(JobActive, "Job upload strategy file"); + uploadstrategy = JOB_UPLOAD_STRATEGY__JobDescriptionFile; + } + else + { + uploadstrategy = JOB_UPLOAD_STRATEGY__Default; + n_segments = CurrentJob->n_segments; + } status = PASSED; JobEndReason = JOB_OK; JobAlarmReason = AlarmHandlingPrepareJob(CurrentJob); @@ -649,7 +661,8 @@ void JobRequestFunc(MessageContainer* requestContainer) } if (status == PASSED) { - Report("Job Request ",__FILE__,__LINE__,Ticket->processparameters->dyeingspeed,RpWarning,Ticket->n_segments, Ticket->intersegmentlength); + Report("Job Request ",__FILE__,__LINE__,Ticket->processparameters->dyeingspeed,RpWarning,n_segments, Ticket->intersegmentlength); + OpenJobFile(); StartJob(CurrentJob); } } diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c index 53057c170..c52ed8b4c 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c @@ -25,6 +25,10 @@ #include "PMR/Hardware/UploadHardWareConfigurationRequest.pb-c.h" #include "PMR/Hardware/HardwareMotorType.pb-c.h" #include "modules/General/process.h" +#include "PMR/Printing/JobDescriptionFileBrushStop.pb-c.h" +#include "PMR/Printing/JobDescriptionFileSegment.pb-c.h" +#include "Common/SWUpdate/FileSystem.h" +#include "drivers/Flash_Memory/fatfs/ff.h" ////////////////////////////////State machine operation//////////////////////////////////// //the state machine operation is used to operate in runtime correct profile flow execution //by recieved esign flow of the user from the UI @@ -38,7 +42,7 @@ static uint32_t PreSegmentState(void *Segment, int); static uint32_t SegmentState(void *Segment, int); uint32_t EndState(void *JobDetails, char *Message); //static uint32_t ExitState(void *JobDetails); - +uint16_t n_segments = 0; /********************************************************************** * the array and enum of PrintingState_t below must be in sync order ***********************************************************************/ @@ -65,9 +69,174 @@ ModuleStateEnum EndWaiting[MAX_SYSTEM_MODULES] = {ModuleIdle,ModuleIdle,M bool Configured[MAX_SYSTEM_MODULES] = {false,false,false,false,false}; bool SuspendLargeMessages = false; +/* +Parsing the job description file. +The job description file simply contains an array of segments and their brush stops. +The job description file is meant to be read brush stop by brush stop while the job is in progress. +The following diagram represents a single job description file segment structure. +The process of reading the whole file is simply repeating that reading order. + +Each JobDescriptionFileSegment contains a “BrushStopsCount” field that should be used to determine how many brush stops are associated +with the current segment and how many times the process of reading brush stops should be repeated. +1. 32bit integer containing the next JobFileDescriptionSegment message byte count +2. JobDescriptionFileSegment message +3. 32bit integer containing the next JobDescriptionFileBrushStop message byte count +4. JobDescriptionFileBrushStop message + +1. Read segment message length. +2. Read segment message. +a. Read brush stop message length. +b. Read brush stop message. +c. Go to step 2.a x Segment.BrushStopsCount. +3. Go to step 1 until end of file. +*/ -/******************************************************************************************************************** - * this function is for development initial stages. it analyses the hardware configuration to determine which modules are operational +//job file reading functions +uint32_t bBytes = 0,readbBytes = 0,ImmediateRead = 0,SegmentSize = 0,BrushStopSize = 0; +FRESULT Fresult = FR_OK; +uint8_t *SegmentPtr = 0, *BrushStopPtr = 0; +FIL *JobRequestFileHandle = 0; //the system supports a single active file +FRESULT OpenJobFile() +{ + //n_segments = 0; + if (CurrentJob->uploadstrategy == JOB_UPLOAD_STRATEGY__JobDescriptionFile) + { + JobRequestFileHandle = my_malloc(sizeof(FIL)); + + Fresult = FileOpen(CurrentJob->jobdescriptionfile, &bBytes, JobRequestFileHandle); + if (Fresult == FR_OK) + { + readbBytes = 0; + } + REPORT_MSG(bBytes,"OpenJobFile"); + } + return Fresult; +} +FRESULT CloseJobFile() +{ + Fresult = f_close(JobRequestFileHandle); + readbBytes = 0; + ImmediateRead = 0; + SegmentSize = 0; + BrushStopSize = 0; + my_free (JobRequestFileHandle); + JobRequestFileHandle = NULL; + if (BrushStopPtr) + my_free(BrushStopPtr); + if (SegmentPtr) + my_free(SegmentPtr); + REPORT_MSG(Fresult,"CloseJobFile"); + + return Fresult; +} +JobDescriptionFileSegment *GetNextSegmentFromJobFile() +{ + uint32_t status = OK; + JobDescriptionFileSegment *Segment = NULL; + if (JobRequestFileHandle == NULL) + { + LOG_ERROR(JobRequestFileHandle,"JobRequestFileHandle == NULL"); + return NULL; + } + if(readbBytes < bBytes) + { + Fresult = f_read(JobRequestFileHandle,&SegmentSize,4,&ImmediateRead ); + if (Fresult == FR_OK) + { + readbBytes += ImmediateRead; + if (SegmentPtr) + my_free(SegmentPtr); + SegmentPtr = my_malloc (SegmentSize); + if (SegmentPtr) + { + Fresult = f_read(JobRequestFileHandle,SegmentPtr,SegmentSize,&ImmediateRead ); + if (Fresult == FR_OK) + { + readbBytes += ImmediateRead; + //n_segments++; + Segment = job_description_file_segment__unpack(NULL, SegmentSize, SegmentPtr); + } + }// read segment data + my_free(SegmentPtr); + }//segment malloc + else + { + LOG_ERROR (SegmentPtr, "malloc error"); + status = ERROR; + } + }//segment read size + else + { + LOG_ERROR (Fresult, "f_read error"); + status = ERROR; + } + return Segment; +} +void FreeSegmentFileData(JobDescriptionFileSegment *Segment) +{ + job_description_file_segment__free_unpacked(Segment,NULL); + Segment = NULL; + if (SegmentPtr) + my_free(SegmentPtr); +} +JobDescriptionFileBrushStop *GetNextBrushStopFromJobFile() +{ + uint32_t status = OK; + JobDescriptionFileBrushStop *BrushStop = NULL; + if (JobRequestFileHandle == NULL) + { + LOG_ERROR(JobRequestFileHandle,"JobRequestFileHandle == NULL"); + return NULL; + } + Fresult = f_read(JobRequestFileHandle,&BrushStopSize,4,&ImmediateRead ); + if (Fresult == FR_OK) + { + readbBytes += ImmediateRead; + if (BrushStopPtr) + my_free(BrushStopPtr); + + BrushStopPtr = my_malloc (BrushStopSize); + if (BrushStopPtr) + { + Fresult = f_read(JobRequestFileHandle,BrushStopPtr,BrushStopSize,&ImmediateRead ); + if (Fresult == FR_OK) + { + readbBytes += ImmediateRead; + BrushStop = job_description_file_brush_stop__unpack(NULL, BrushStopSize, BrushStopPtr); + }//brushstop malloc ok + else + { + LOG_ERROR (Fresult, "f_read error"); + status = ERROR; + } + my_free(BrushStopPtr); + }//brushstop size read ok + else + { + LOG_ERROR (BrushStopPtr, "malloc error"); + status = ERROR; + } + }// if brush stop count + else + { + LOG_ERROR (0, "f_read error brush stop size error"); + status = ERROR; + } + REPORT_MSG(BrushStop->index,"BrushStop file Read Index"); + + return BrushStop; +} +void FreeBrushStopFileData(JobDescriptionFileBrushStop *BrushStop) +{ + REPORT_MSG(BrushStop->index,"Free BrushStop file Read Index"); + if (BrushStop) + job_description_file_brush_stop__free_unpacked (BrushStop,NULL); + BrushStop = NULL; + if (BrushStopPtr) + my_free(BrushStopPtr); +} +/************************************************************************************************************************************/ +/* this function is for development initial stages. it analyses the hardware configuration to determine which modules are operational * according to the configuration map */ @@ -233,8 +402,8 @@ uint32_t SegmentReady(int ModuleId, ModuleStateEnum result) assert (ModuleIdmessageData; - Report("PrintSTMMsgHandler",__FILE__,__LINE__, RpMessage,0x1000,Message->messageId,PrtMessage->messageId); + Report("PrintSTMMsgHandler",__FILE__,__LINE__, 1000,RpMessage,Message->messageId,PrtMessage->messageId); if ((Message->messageId != PrintMessage)&&(Message->messageId != Abort)) { @@ -456,10 +628,28 @@ void PrintSTMMsgHandler(void * msg) { case PrintRequest: SegmentId = 0; - PreSegmentState(CurrentJob->segments[SegmentId],SegmentId); + if (CurrentJob->uploadstrategy == JOB_UPLOAD_STRATEGY__JobDescriptionFile) + { + Segment = GetNextSegmentFromJobFile(); + SSegment.length = Segment->length; + SSegment.has_length = Segment->has_length; + SSegment.n_brushstops = Segment->brushstopscount; + PreSegmentState(&SSegment,SegmentId); + } + else + { + PreSegmentState(CurrentJob->segments[SegmentId],SegmentId); + } break; case PreSegmentResultsOk: - SegmentState(CurrentJob->segments[SegmentId],SegmentId); + if (CurrentJob->uploadstrategy == JOB_UPLOAD_STRATEGY__JobDescriptionFile) + { + SegmentState(&SSegment,SegmentId); + } + else + { + SegmentState(CurrentJob->segments[SegmentId],SegmentId); + } break; case PreSegmentResultsFail: EndState(CurrentJob, "PreSegment Failed"); @@ -467,8 +657,9 @@ void PrintSTMMsgHandler(void * msg) break; case SegmentResultsOk: SegmentId++; - LOG_ERROR(SegmentId, "SegmentResultsOk segmentId"); - if (SegmentId >= CurrentJob->n_segments) + //REPORT_MSG(SegmentId, "SegmentResultsOk segmentId"); + Report("SegmentResultsOk segmentId",__FILE__,__LINE__, SegmentId,RpMessage,n_segments,0); + if (SegmentId >= n_segments) { if (dryerbufferlength == 0) EndState(CurrentJob, "Job Ended"); @@ -477,7 +668,21 @@ void PrintSTMMsgHandler(void * msg) } else { - PreSegmentState(CurrentJob->segments[SegmentId],SegmentId); + if (CurrentJob->uploadstrategy == JOB_UPLOAD_STRATEGY__JobDescriptionFile) + { + if (Segment) + FreeSegmentFileData(Segment); + + Segment = GetNextSegmentFromJobFile(); + SSegment.length = Segment->length; + SSegment.has_length = Segment->has_length; + SSegment.n_brushstops = Segment->brushstopscount; + PreSegmentState(&SSegment,SegmentId); + } + else + { + PreSegmentState(CurrentJob->segments[SegmentId],SegmentId); + } } break; case SegmentResultsFail: diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.h b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.h index 878e063b5..d7d8262f4 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.h +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.h @@ -17,6 +17,9 @@ #include "PMR/Printing/JobRequest.pb-c.h" #include "PMR/Printing/JobTicket.pb-c.h" #include "PMR/Printing/JobResponse.pb-c.h" +#include "PMR/Printing/JobDescriptionFileBrushStop.pb-c.h" +#include "PMR/Printing/JobDescriptionFileSegment.pb-c.h" +#include "drivers/Flash_Memory/fatfs/ff.h" #define MAX_MSG_LEN 100 typedef enum @@ -166,8 +169,10 @@ uint32_t CurrentJobRequestFunc(MessageContainer* requestContainer); uint32_t ResumeCurrentJobRequestFunc(MessageContainer* requestContainer); bool JobIsActive(void); + extern bool SuspendLargeMessages; +extern uint16_t n_segments; void SendJobProgress(double ProcessedLength,int SegmentId, bool done, char *Message); uint32_t PrepareReady(int ModuleId, ModuleStateEnum result); @@ -179,4 +184,12 @@ uint32_t EndState(void *JobDetails, char *Message); bool GetHeatersPrepareWaiting(void); +extern JobUploadStrategy uploadstrategy; +FRESULT OpenJobFile(); +FRESULT CloseJobFile(); +JobDescriptionFileSegment *GetNextSegmentFromJobFile(); +void FreeSegmentFileData(JobDescriptionFileSegment *Segment); +JobDescriptionFileBrushStop *GetNextBrushStopFromJobFile(); +void FreeBrushStopFileData(JobDescriptionFileBrushStop *BrushStop); + #endif /* STATEMACHINES_PRINTSTM_H_ */ -- cgit v1.3.1 From 2bab30adc68e3166ca2ce613ba63224d909c84d9 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Wed, 3 Apr 2019 15:49:54 +0300 Subject: version 1.3.8.3 Power down scenario, Idle handling, some thread load improvements --- .../Embedded/Common/SWUpdate/FirmwareUpgrade.c | 14 +- .../Embedded/Common/SWUpdate/FirmwareUpgrade.h | 1 + .../Embedded_SW/Embedded/Common/SW_Info/SW_Info.c | 2 +- .../Embedded_SW/Embedded/Communication/Container.c | 3 + Software/Embedded_SW/Embedded/Main.c | 4 +- .../Embedded/Modules/AlarmHandling/AlarmHandling.c | 2 +- .../Embedded_SW/Embedded/Modules/General/buttons.c | 2 + .../Embedded_SW/Embedded/Modules/General/process.c | 2 + .../Embedded/Modules/IDS/IDS_dispenser.c | 34 ++- Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h | 1 + .../Embedded/Modules/Stubs_Handler/Progress.c | 3 +- .../Embedded/Modules/Thread/ThreadLoad.c | 11 +- .../Embedded/Modules/Thread/Thread_ex.h | 2 + .../Embedded/Modules/Thread/Thread_print.c | 2 +- .../Embedded_SW/Embedded/Modules/Waste/Waste.h | 1 + .../Embedded/Modules/Waste/Waste_init.c | 10 +- .../StateMachines/Initialization/InitSequence.c | 75 ++++- .../StateMachines/Initialization/PowerIdle.c | 99 +++++++ .../StateMachines/Initialization/PowerIdle.h | 22 ++ .../Initialization/PowerOffSequence.c | 327 +++++++++++++++++++++ .../Initialization/PowerOffSequence.h | 34 +++ .../Embedded/StateMachines/Printing/JobSTM.c | 6 + 22 files changed, 623 insertions(+), 34 deletions(-) create mode 100644 Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c create mode 100644 Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.h create mode 100644 Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c create mode 100644 Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.h (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c index a31f4bef8..d54280fee 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c @@ -36,10 +36,20 @@ char activateString[100]; char ActivateToken[36+1]={0}; bool Reboot = false; + +bool SwUpgradeActive(void) +{ + if (ActivateVersionControlId != 0xFF) + { + Reboot = false; + return true; + } + return false; +} uint32_t ActivateVersionCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) { - ActivateVersionResponse response = ACTIVATE_VERSION_RESPONSE__INIT; - MessageContainer responseContainer; + //ActivateVersionResponse response = ACTIVATE_VERSION_RESPONSE__INIT; + //MessageContainer responseContainer; usnprintf(activateString, 1000, "file %d of %d bytes %d of %d",CurrentRunningFile,NumberOfFiles,vme_index,CurrentFileSize); diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.h b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.h index 9af76f96f..6f817fe90 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.h +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.h @@ -11,6 +11,7 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer); uint32_t ValidateVersionRequestFunc(MessageContainer* requestContainer); +bool SwUpgradeActive(void); diff --git a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c index 7f22a613a..030c4229e 100644 --- a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c +++ b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c @@ -20,7 +20,7 @@ typedef struct } TangoVersion_t; -TangoVersion_t _gTangoVersion = {1,3,8,2}; +TangoVersion_t _gTangoVersion = {1,3,8,3}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; char _gTangoName [MAX_STRING_LEN] = "Tango01 ";//d diff --git a/Software/Embedded_SW/Embedded/Communication/Container.c b/Software/Embedded_SW/Embedded/Communication/Container.c index ad57c36ab..b0c063a5e 100644 --- a/Software/Embedded_SW/Embedded/Communication/Container.c +++ b/Software/Embedded_SW/Embedded/Communication/Container.c @@ -43,6 +43,7 @@ #include "Communication/CommunicationTask.h" #include "StateMachines/Printing/PrintingSTM.h" +#include "StateMachines/Initialization/PowerIdle.h" #include "Common/report/report.h" #include "Connection.h" @@ -130,6 +131,8 @@ void receive_callback(char* buffer, size_t length) if (requestContainer == NULL) return; // HeatingTestSendResonse(0, false,true,true, /*OriginalMotorSpd_2PPS[index]*/length,requestContainer->type,0,0, "Container"); + if (requestContainer->type != MESSAGE_TYPE__KeepAliveRequest) //user action resets the idle counter + resetIdleCounter(); msgId[index] = requestContainer->type; Length[index] = length; diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index 2147652e2..046f8291e 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -46,7 +46,7 @@ #include "StateMachines/Printing/PrintingSTM.h" #include "StateMachines/Initialization/InitSequence.h" - +#include "StateMachines/Initialization/PowerIdle.h" #include #include "drivers/SPI/SPI_Comm.h" #include "drivers/Uart_Comm/Uart.h" @@ -245,7 +245,7 @@ int main(void) // HWControlId = AddControlCallback( MainHWInitCallBackFunction, 2* eOneSecond/*eHundredMillisecond*/, MainDummyFunction,0,0, 0 ); Start_InitSequence(); - + PowerIdleInit(); BIOS_start(); diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index 8e76badfe..81c4a230b 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -1042,7 +1042,7 @@ void SendEventNotifications(void) else { LOG_ERROR(response.n_events,"events malloc error"); - return ERROR; + return; } } else diff --git a/Software/Embedded_SW/Embedded/Modules/General/buttons.c b/Software/Embedded_SW/Embedded/Modules/General/buttons.c index 4befb83ea..ee6204060 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/buttons.c +++ b/Software/Embedded_SW/Embedded/Modules/General/buttons.c @@ -22,6 +22,7 @@ #include "Modules/Thread/Thread_ex.h" #include "Modules/General/buttons.h" +#include "StateMachines/Initialization/PowerOffSequence.h" //int MachineOnOff(); int PowerDown(); @@ -86,6 +87,7 @@ bool Read_PWR_Button();//TODO move to GPIO folder int PowerDown() { bool ret = OK; + PowerOffInit(); return ret; } diff --git a/Software/Embedded_SW/Embedded/Modules/General/process.c b/Software/Embedded_SW/Embedded/Modules/General/process.c index 458bb35f2..277891861 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/process.c +++ b/Software/Embedded_SW/Embedded/Modules/General/process.c @@ -20,6 +20,7 @@ #include "modules/ids/ids_ex.h" #include "third_party/fatfs/src/ffconf.h" #include "Common/SWUpdate/FileSystem.h" +#include "StateMachines/Initialization/PowerIdle.h" @@ -210,6 +211,7 @@ void ProcessRequestFunc(MessageContainer* requestContainer) //REPORT_MSG (ProcessParams->dryerzone1temp,"Process Params Dryer"); + PowerIdleOutOfIdleState(); if (status == 0) status = HandleProcessParameters(ProcessParams); diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c index 492dce2cc..b33b531a3 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c @@ -245,6 +245,24 @@ void IDS_Dispenser_Content_Init (void) //================================== } uint16_t seconds_counter = 0; +uint32_t IDS_Dispenser_Store_Data (void) +{ + FRESULT Status = FR_OK; + IDSDispenserData.n_dispenserinfo = MAX_SYSTEM_DISPENSERS; + IDSDispenserData.dispenserinfo = dispenserdata; + uint8_t* response_buffer = my_malloc(dispenser_data__get_packed_size(&IDSDispenserData)); + size_t response_size = 0; + if (response_buffer) + { + response_size = dispenser_data__pack(&IDSDispenserData, response_buffer); + Status = FileWrite(response_buffer,response_size,DispenserStorePath); + my_free(response_buffer); + } + else + return ERROR; + + return Status; +} void IDS_Dispenser_Content_Calculation (char DispenserId) { assert (DispenserId=600)//3600) { + seconds_counter = 0; if (IDS_Dispenser_Data[DispenserId].consumedinnanolitter) { REPORT_MSG(IDS_Dispenser_Data[DispenserId].consumedinnanolitter,"Saving Dispenser Data" ); } - seconds_counter = 0; - IDSDispenserData.n_dispenserinfo = MAX_SYSTEM_DISPENSERS; - IDSDispenserData.dispenserinfo = dispenserdata; - uint8_t* response_buffer = my_malloc(dispenser_data__get_packed_size(&IDSDispenserData)); - size_t response_size = 0; - if (response_buffer) - { - response_size = dispenser_data__pack(&IDSDispenserData, response_buffer); - } - - FileWrite(response_buffer,response_size,DispenserStorePath); - my_free(response_buffer); - //dispenser_data__free_unpacked(response_size,NULL); - + IDS_Dispenser_Store_Data(); } } } diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h index 2e8d33e1a..9b2442698 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h @@ -69,6 +69,7 @@ uint32_t IDS_Dispenser_Close_Valve_And_Stop_Motor(int DispenserId, callback_fptr uint32_t IDS_Dispenser_Start_Motor_and_Open_Valve(int DispenserId, int MotorSpeed, callback_fptr callback); void IDS_Dispenser_Content_Calculation (char DispenserId); +uint32_t IDS_Dispenser_Store_Data (void); uint32_t IDS_MapDispenserUsedinFileJob(void *JobDetails); diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c index 919e84582..d041b648e 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c @@ -7,6 +7,7 @@ #include "driverlib/gpio.h" #include "Drivers/USB_Communication/USBCDCD.h" +#include "StateMachines/Initialization/PowerOffSequence.h" //#include "graphics_adapter.h" @@ -20,7 +21,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) ProgressResponse response = PROGRESS_RESPONSE__INIT; response.has_progress = true; - + PowerOffInit(); int i = 0; for (i = 0; i < request->amount; i++) { diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 3ee248fba..ab5075ab9 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -78,6 +78,13 @@ //RUN MOTOR A FULL CYCLE //RUN A MOTOR NUMBER OF STEPS //RUN CONTROL FOR A SINGLE DANCER + bool ThreadLoadingActive(void) + { + if ((LoadStages > THREAD_LOAD_INIT)&&(LoadStages < THREAD_LOAD_END)) + return true; + else + return false; + } uint32_t Thread_Load_Init(void) { void* buffer = NULL; @@ -245,9 +252,9 @@ { REPORT_MSG(LoadStages, "Thread Load State Machine step"); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANHEAD,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANHEAD].directionthreadwize, 200, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANHEAD], Thread_Load_HomingCallback,10000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANHEAD,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANHEAD].directionthreadwize, 80, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANHEAD], Thread_Load_HomingCallback,10000); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANMECH,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANMECH].directionthreadwize, 200, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANMECH], Thread_Load_HomingCallback,10000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANMECH,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANMECH].directionthreadwize, 80, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DH_CLEANMECH], Thread_Load_HomingCallback,10000); return OK; } uint32_t Thread_Load_Open_Covers(void) diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h index 69ac4b6ad..d7ce917c0 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h @@ -67,9 +67,11 @@ typedef enum THREAD_LOAD_END }THREAD_LOAD_STAGES_ENUM; uint32_t ThreadLoadStateMachine( THREAD_LOAD_STAGES_ENUM ReadValue); +bool ThreadLoadingActive(void); void ThreadLoadPollRequest(MessageContainer* requestContainer); void ThreadLoadRequest(MessageContainer* requestContainer); + #endif diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 07a32b2a6..a4208ad25 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -717,7 +717,7 @@ void SetOriginMotorSpeed(float process_speed) uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId) { //set the speed only before the first segment, speed is constant across all job segments and intersegments - JobSegment* Segment = SegmentDetails; + //JobSegment* Segment = SegmentDetails; float process_speed = dyeingspeed; if (dyeingspeed == 0) diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste.h b/Software/Embedded_SW/Embedded/Modules/Waste/Waste.h index 66428039f..f6b7d760a 100644 --- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste.h +++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste.h @@ -97,6 +97,7 @@ typedef enum U8 WHS_init(void); U8 WHS_HW_test(void); +bool WHS_IsEmptying(); diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c index 689a2bc95..447e954d4 100644 --- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c @@ -52,7 +52,6 @@ bool SetActiveWastCartridge(); - struct waste_cartridge_params { uint32_t serial_number; @@ -99,6 +98,15 @@ struct WHS_information struct WHS_information WHS_info; +bool WHS_IsEmptying() +{ + bool ret = false; + if ( WHS_info.sttMachine == WHS_emptying ) + { + ret = true; + } + return ret; +} /* -------- cartridge function ----*/ diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c index 017eb2126..64cb99918 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c @@ -23,6 +23,8 @@ #include "InitSequence.h" #include "drivers/I2C_Communication/DAC/Blower.h" +#include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h" +#include "drivers/Valves/Valve.h" #include "heaters/heaters_ex.h" @@ -38,7 +40,7 @@ INIT_SEQUENCE_MACHINE_READY_TO_DYE, INIT_SEQUENCE_END, }INIT_SEQUENCE_STAGES_ENUM; - INIT_SEQUENCE_STAGES_ENUM InitStages = INIT_SEQUENCE_INIT; + INIT_SEQUENCE_STAGES_ENUM InitStages = INIT_SEQUENCE_INIT, StoredInitStages = INIT_SEQUENCE_INIT; MACHINE_STATE_STAGES_ENUM MachineState = MACHINE_STATE_INIT; MACHINE_STATE_STAGES_ENUM GetMachineState(void) @@ -49,7 +51,9 @@ void SetMachineState(MACHINE_STATE_STAGES_ENUM NewState) { MachineState = NewState; } -uint32_t HWControlId; +uint32_t HWControlId,InitSchedulerControlId; +uint32_t MidTankControlId; + uint32_t RESET_Cause = 0; void InitSequenceResetReason(void); @@ -72,7 +76,7 @@ uint32_t InitSequenceCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) { ActivateHeadMagnet(); InitStages++; - InitSequenceStateMachine(InitStages); + //InitSequenceStateMachine(InitStages); } else { @@ -81,11 +85,23 @@ uint32_t InitSequenceCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) } return OK; } +/*******************************************************************************************************/ +uint32_t InitScheduler(uint32_t IfIndex, uint32_t BusyFlag) +{ + if (InitStages > StoredInitStages) + { + StoredInitStages = InitStages; + InitSequenceStateMachine(InitStages); + } + return OK; +} +/*******************************************************************************************************/ uint32_t Start_InitSequence(void) { MachineState = MACHINE_STATE_HW_CONFIG; HWControlId = AddControlCallback( InitSequenceCallBackFunction, 4* eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + InitSchedulerControlId = AddControlCallback( InitScheduler, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); return OK; } void InitSequenceResetReason(void) @@ -104,7 +120,7 @@ void InitSequenceResetReason(void) LOG_ERROR(RESET_Cause,"Reset Reason Register"); SysCtlResetCauseClear(RESET_Cause); InitStages++; - InitSequenceStateMachine(InitStages); + //InitSequenceStateMachine(InitStages); //return OK; } @@ -113,7 +129,7 @@ void InitSequenceBuiltInTestCallBack(uint32_t IfIndex, uint32_t BusyFlag) if (1)//BIT OK { InitStages++; - InitSequenceStateMachine(InitStages); + //InitSequenceStateMachine(InitStages); } else { @@ -127,6 +143,44 @@ uint32_t InitSequenceBuiltInTest(void) InitSequenceBuiltInTestCallBack(0,0); return OK; } +int MidTankOperationCounter = 0; +uint32_t InitSequenceMidTankCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) +{ + int MidTankOpenAir = 8; + int MidTankReadPressure = 16; + int MidTankCloseAir = 24; + int MidTankEnd = 32; + int portId; + + if (MidTankOperationCounter >= MidTankEnd) + { + SafeRemoveControlCallback(MidTankControlId, InitSequenceMidTankCallBackFunction); + } + else if (MidTankOperationCounter >= MidTankCloseAir) + { + //close air valve for midtank (MidTankOperationCounter-MidTankCloseAir) + portId = (MidTankOperationCounter - MidTankCloseAir) ; //0-7 + Disable_MidTank_Pressure_Reading(portId); + Valve_Set(IDS_Id_to_AirValve[portId], Atm_MidTank_OFF ); //Atm_MidTank_OFF/ON + } + else if (MidTankOperationCounter >= MidTankReadPressure) + { + //read pressure for midtank (MidTankOperationCounter-MidTankCloseAir) + for (portId = 0;portId < MAX_SYSTEM_DISPENSERS;portId++) + { + Read_MidTank_Pressure_Sensor(portId); + } + } + else if (MidTankOperationCounter >= MidTankOpenAir) + { + //open air valve for midtank (MidTankOperationCounter-MidTankOpenAir) + portId = (MidTankOperationCounter - MidTankOpenAir) ; //0-7 + Enable_MidTank_Pressure_Reading(portId); + Valve_Set(IDS_Id_to_AirValve[portId], Atm_MidTank_ON ); //Atm_MidTank_OFF/ON + } + MidTankOperationCounter++; + return OK; +} uint32_t InitSequenceBlowerCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) { if (SafeRemoveControlCallback(HWControlId, InitSequenceBlowerCallBackFunction )==OK) @@ -137,7 +191,7 @@ uint32_t InitSequenceBlowerCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) Control_Voltage_To_Blower(BlowerCfg.heatingvoltage); Safety_Init(); InitStages++; - InitSequenceStateMachine(InitStages); + //InitSequenceStateMachine(InitStages); return OK; } uint32_t InitSequenceInitialBlowerActivation(void) @@ -150,6 +204,8 @@ uint32_t InitSequenceInitialBlowerActivation(void) Control_Voltage_To_Blower(BlowerCfg.voltage); HWControlId = AddControlCallback( InitSequenceBlowerCallBackFunction, 10* eOneSecond/*eHundredMillisecond*/, TemplateDataReadCBFunction,0,0, 0 ); } + MidTankControlId = AddControlCallback( InitSequenceMidTankCallBackFunction, 300/*eHundredMillisecond*/, TemplateDataReadCBFunction,0,0, 0 ); + return OK; } int NumOfCheckedDispnsers = 0; @@ -159,7 +215,7 @@ uint32_t InitSequenceDispenserPressureBuildUpTestCallBackFunction(uint32_t IfInd if(NumOfCheckedDispnsers==0) { InitStages++; - InitSequenceStateMachine(InitStages); + //InitSequenceStateMachine(InitStages); MachineState = MACHINE_STATE_DISPENSER_PRESSURE_BUILDUP_TEST; } @@ -187,7 +243,7 @@ uint32_t InitSequenceThreadDetection(void) { InitStages++; MachineState = MACHINE_STATE_THREAD_DETECTION; - InitSequenceStateMachine(InitStages); + //InitSequenceStateMachine(InitStages); return OK; } @@ -201,7 +257,7 @@ uint32_t InitSequenceStartHeatingCallBackFunction(uint32_t IfIndex, uint32_t Bus else Report("Remove control callback failed",__FILE__,__LINE__,(int)HWControlId,RpWarning,(int)InitSequenceStartHeatingCallBackFunction,0); InitStages++; - InitSequenceStateMachine(InitStages); + //InitSequenceStateMachine(InitStages); } return OK; } @@ -267,6 +323,7 @@ uint32_t InitSequenceStateMachine( INIT_SEQUENCE_STAGES_ENUM ReadValue) break; default: LOG_ERROR(ReadValue,"ERROR IN INIT STATE MACHINE"); + RemoveControlCallback( InitSchedulerControlId,InitScheduler); break; } return OK; diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c new file mode 100644 index 000000000..c6136fc62 --- /dev/null +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c @@ -0,0 +1,99 @@ +/* + * PowerIdle.c + * + * Created on: Apr 3, 2019 + * Author: shlomo + */ +#include "modules/General/GeneralHardware.h" +#include "modules/General/Safety.h" +#include "modules/thread/thread.h" +#include "modules/ids/ids.h" +#include "modules/control/control.h" +#include "modules/AlarmHandling/AlarmHandling.h" +#include "modules/heaters/heaters_ex.h" +#include "modules/Diagnostics/Diagnostics.h" +#include "Modules/General/process.h" + +#include "StateMachines/Printing/PrintingSTM.h" +#include "InitSequence.h" + +#include "drivers/I2C_Communication/DAC/Blower.h" +#include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h" +#include "drivers/Valves/Valve.h" + +#include "heaters/heaters_ex.h" + +#define DEFAULT_IDLE_TIME_LIMIT 3600 +int powerIdleSecondsCounter = 0; +int powerIdleSecondsLimit = DEFAULT_IDLE_TIME_LIMIT; +bool powerIdleState = false; +bool machineActive = false; +uint32_t IdleControlId = 0xFF; +void PowerIdleSetIdle(void) +{ + ProcessParameters ProcessParametersClear; + ProcessParametersClear.dryerzone1temp = 80; + ProcessParametersClear.dryerzone2temp = 80; + ProcessParametersClear.dryerzone3temp = 80; + ProcessParametersClear.mixertemp = 0; + ProcessParametersClear.headzone1temp = 80; + ProcessParametersClear.headzone2temp = 80; + ProcessParametersClear.headzone3temp = 80; + ProcessParametersClear.headzone4temp = 80; + ProcessParametersClear.headzone5temp = 80; + ProcessParametersClear.headzone6temp = 80; + ProcessParametersClear.dyeingspeed = 40; + if (HandleProcessParameters(&ProcessParametersClear)!= OK) + { + LOG_ERROR (1, "Turn Heaters idle failed"); + return ERROR; + } + if (BlowerCfg.enabled == true) + { + Turn_the_Blower_On();//Turn on with the Default_Voltage + if (BlowerCfg.heatingvoltage) + Control_Voltage_To_Blower(BlowerCfg.heatingvoltage); + else + Control_Voltage_To_Blower(BlowerCfg.voltage-500); + } +} + +uint32_t PowerIdleCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) +{ + if (machineActive == true) + return OK; + if (++powerIdleSecondsCounter>=powerIdleSecondsLimit) + { + if (powerIdleState == false) + { + Report("PowerIdle Idle activated ",__FILE__,__LINE__,(int)powerIdleSecondsLimit,RpWarning,(int)powerIdleSecondsCounter,0); + powerIdleState = true; + //move to idle state + } + } + return OK; +} +void PowerIdleInit(void) +{ + IdleControlId = AddControlCallback( PowerIdleCallBackFunction, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + if (IdleControlId == 0xFF) + Report("AddControlCallback failed",__FILE__,__LINE__,(int)IdleControlId,RpWarning,(int)0,0); + Report("PowerIdleInit ",__FILE__,__LINE__,(int)powerIdleSecondsLimit,RpWarning,(int)0,0); + +} +int getIdleCounter (void) {return powerIdleSecondsCounter;} +void setIdleLimit (int Limit) {powerIdleSecondsLimit = Limit;} +void setmachineActive(bool Active){machineActive = Active;} +void resetIdleCounter (void) {powerIdleSecondsCounter = 0;} +bool getIdleState (void) {return powerIdleState;} +void PowerIdleOutOfIdleState(void) +{ + Report("PowerIdle Out of Idle ",__FILE__,__LINE__,(int)powerIdleSecondsLimit,RpWarning,(int)powerIdleSecondsCounter,0); + powerIdleSecondsCounter = 0; + if (powerIdleState == true) + { + powerIdleState = false; + //move to idle state + } + +} diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.h b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.h new file mode 100644 index 000000000..71edf8885 --- /dev/null +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.h @@ -0,0 +1,22 @@ +/* + * PowerIdle.h + * + * Created on: Apr 3, 2019 + * Author: shlomo + */ + +#ifndef STATEMACHINES_INITIALIZATION_POWERIDLE_H_ +#define STATEMACHINES_INITIALIZATION_POWERIDLE_H_ + +int getIdleCounter (void); +void setIdleLimit (int Limit); +void resetIdleCounter (void); +bool getIdleState (void); +void PowerIdleOutOfIdleState(void); +void setmachineActive(bool Active); +void PowerIdleInit(void); + + + + +#endif /* STATEMACHINES_INITIALIZATION_POWERIDLE_H_ */ diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c new file mode 100644 index 000000000..f0cf641ae --- /dev/null +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c @@ -0,0 +1,327 @@ +/* + * PowerOffSequence.c + * + * Created on: Apr 2, 2019 + * Author: shlomo + */ + + +#include "modules/General/GeneralHardware.h" +#include "modules/General/Safety.h" +#include "modules/thread/thread.h" +#include "modules/waste/waste.h" +#include "modules/ids/ids.h" +#include "modules/control/control.h" +#include "modules/AlarmHandling/AlarmHandling.h" +#include "modules/heaters/heaters_ex.h" +#include "modules/Diagnostics/Diagnostics.h" +#include "Modules/General/process.h" + +#include "Modules/Thread/Thread_ex.h" +#include "Common/SWUpdate/FirmwareUpgrade.h" + +#include "StateMachines/Printing/PrintingSTM.h" +#include "InitSequence.h" + +#include "drivers/I2C_Communication/DAC/Blower.h" +#include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h" +#include "drivers/Heater/TemperatureSensor.h" +#include "drivers/Valves/Valve.h" + +#include "heaters/heaters_ex.h" + +#include "PowerOffSequence.h" +/* + typedef enum + { + POWER_OFF_INIT, + POWER_OFF_HEAD_CLEAN, + POWER_OFF_MIXER_FLUSH, + POWER_OFF_HEATERS_OFF, + POWER_OFF_STORE_DATA, + POWER_OFF_WAIT_FOR_PROCESSES,//wait for waste emptying, ink filling, thread loading + POWER_OFF_STOP_RUNNING_JOB, + POWER_OFF_SET_VALVE_POSITION, + POWER_OFF_WAIT_FOR_TEMPERATURE, + POWER_OFF_TURN_OFF_DRYER_FAN, + POWER_OFF_TURN_OFF_COOLER, + POWER_OFF_TURN_OFF_BLOWER, + POWER_OFF_POWER_OFF, + POWER_OFF_MAX, + }POWER_OFF_STAGES_ENUM; +*/ +POWER_OFF_STAGES_ENUM PowerOffMachineState = POWER_OFF_INIT,StoredMachineState = POWER_OFF_INIT; +uint32_t PowerOffControlId = 0xFF; +uint32_t WaitForProcessControlId = 0xFF; +uint32_t PowerOffSequenceStateMachine( POWER_OFF_STAGES_ENUM ReadValue); + +/*******************************************************************************************************/ +uint32_t PowerOffScheduler(uint32_t IfIndex, uint32_t BusyFlag) +{ + if (PowerOffMachineState > StoredMachineState) + { + StoredMachineState = PowerOffMachineState; + PowerOffSequenceStateMachine (PowerOffMachineState); + } + return OK; +} +/*******************************************************************************************************/ +uint32_t PowerOffInit(void) +{ + LOG_ERROR(0,"Power Off Init"); + PowerOffMachineState = POWER_OFF_HEAD_CLEAN; + PowerOffControlId = AddControlCallback( PowerOffScheduler, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + return OK; +} +/*******************************************************************************************************/ +uint32_t PowerOffHeadClean(void) +{ + //TBD + PowerOffMachineState = POWER_OFF_MIXER_FLUSH; + return OK; +} +/*******************************************************************************************************/ +uint32_t PowerOffMixerFlush(void) +{ + //TBD + PowerOffMachineState = POWER_OFF_HEATERS_OFF; + return OK; +} +/*******************************************************************************************************/ +uint32_t PowerOffHeatersOff(void) +{ + ProcessParameters ProcessParametersClear; + ProcessParametersClear.dryerzone1temp = 0; + ProcessParametersClear.dryerzone2temp = 0; + ProcessParametersClear.dryerzone3temp = 0; + ProcessParametersClear.mixertemp = 0; + ProcessParametersClear.headzone1temp = 0; + ProcessParametersClear.headzone2temp = 0; + ProcessParametersClear.headzone3temp = 0; + ProcessParametersClear.headzone4temp = 0; + ProcessParametersClear.headzone5temp = 0; + ProcessParametersClear.headzone6temp = 0; + ProcessParametersClear.dyeingspeed = 40; + if (HandleProcessParameters(&ProcessParametersClear)!= OK) + { + LOG_ERROR (PowerOffMachineState, "Turn Off Heaters failed"); + return ERROR; + } + + PowerOffMachineState = POWER_OFF_STORE_DATA; + + return OK; +} +/*******************************************************************************************************/ +uint32_t PowerOffStoreData(void) +{ + //TBD + REPORT_MSG (PowerOffMachineState, "Store Data"); + IDS_Dispenser_Store_Data(); + PowerOffMachineState = POWER_OFF_WAIT_FOR_PROCESSES; + return OK; +} +/*******************************************************************************************************/ +int WaitForProcessCounter = 0; +uint32_t PowerOffWaitForProcessesCallback(uint32_t IfIndex, uint32_t BusyFlag) +{ + if ((WHS_IsEmptying()|| + //MidTankFillingActive()|| + ThreadLoadingActive()|| + SwUpgradeActive())&& + (WaitForProcessCounter++<900)) + { + REPORT_MSG (PowerOffMachineState, "On going processes, wait for end of process"); + } + else + { + PowerOffMachineState = POWER_OFF_SET_VALVE_POSITION; + SafeRemoveControlCallback(WaitForProcessControlId, PowerOffWaitForProcessesCallback); + WaitForProcessControlId = 0xFF; + } + return OK; +} +/*******************************************************************************************************/ +uint32_t PowerOffWaitForProcesses(void) +{ + int i; + REPORT_MSG (PowerOffMachineState, "Stop dispensers homing"); + for (i=0;i= MaxTemp)&&(readTemp < 28000)) + MaxTemp = readTemp; + readTemp = TemperatureSensorRead( TEMP_SENSE_ANALOG_DYEINGH_TEMP1); + if ((readTemp>= MaxTemp)&&(readTemp < 28000)) + MaxTemp = readTemp; + readTemp = TemperatureSensorRead( TEMP_SENSE_ANALOG_DYEINGH_TEMP2); + if ((readTemp>= MaxTemp)&&(readTemp < 28000)) + MaxTemp = readTemp; + readTemp = TemperatureSensorRead( TEMP_SENSE_ANALOG_DYEINGH_TEMP3); + if ((readTemp>= MaxTemp)&&(readTemp < 28000)) + MaxTemp = readTemp; + readTemp = TemperatureSensorRead( TEMP_SENSE_ANALOG_DYEINGH_TEMP4); + if ((readTemp>= MaxTemp)&&(readTemp < 28000)) + MaxTemp = readTemp; + readTemp = TemperatureSensorRead( TEMP_SENSE_ANALOG_DYEINGH_TEMP5); + if ((readTemp>= MaxTemp)&&(readTemp < 28000)) + MaxTemp = readTemp; + readTemp = TemperatureSensorRead( HEAD6_PT100); + if ((readTemp>= MaxTemp)&&(readTemp < 28000)) + MaxTemp = readTemp; + readTemp = TemperatureSensorRead( TEMP_SENSE_ANALOG_DRYER_TEMP1); + if ((readTemp>= MaxTemp)&&(readTemp < 28000)) + MaxTemp = readTemp; + +#define POWER_OFF_TEMP_THRESHOLD 10000 + + if ((MaxTemp>POWER_OFF_TEMP_THRESHOLD)&&(WaitForProcessCounter++<1800)) + { + Report("On going cooling down, wait for end of cooling",__FILE__,__LINE__,(int)MaxTemp,RpWarning,(int)WaitForProcessCounter,0); + } + else + { + Report("ended cooling down, wait for end of cooling",__FILE__,__LINE__,(int)MaxTemp,RpWarning,(int)WaitForProcessCounter,0); + PowerOffMachineState = POWER_OFF_TURN_OFF_DRYER_FAN; + SafeRemoveControlCallback(WaitForProcessControlId, PowerOffWaitForTemperatureCallback); + WaitForProcessControlId = 0xFF; + } + return OK; +} +/*******************************************************************************************************/ +uint32_t PowerOffWaitForTemperature(void) +{ + if (WaitForProcessControlId == 0xFF) + { + WaitForProcessCounter = 0; + WaitForProcessControlId = AddControlCallback( PowerOffWaitForTemperatureCallback, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + } + //TBD + return OK; +} +/*******************************************************************************************************/ +uint32_t PowerOffTurnOffDryerFan(void) +{ + Control_Dryer_Fan(STOP,75);//use START or STOP, 0 - 100% + PowerOffMachineState = POWER_OFF_TURN_OFF_COOLER; + + //TBD + return OK; +} +/*******************************************************************************************************/ +uint32_t PowerOffTurnOffCooler(void) +{ + uint32_t DeActivateChiller(); + PowerOffMachineState = POWER_OFF_TURN_OFF_BLOWER; + return OK; +} +/*******************************************************************************************************/ +uint32_t PowerOffTurnOffBlower(void) +{ + Turn_the_Blower_Off();//Turn off + PowerOffMachineState = POWER_OFF_POWER_OFF; + return OK; +} +/*******************************************************************************************************/ +uint32_t PowerOffPowerOff(void) +{ + int i; + for (i = 0;i<10;i++) + { + REPORT_MSG (10-i, "Power off in x seconds"); + Task_sleep (1000); + } + Power_Off(); + return OK; +} +/*******************************************************************************************************/ +uint32_t PowerOffSequenceStateMachine( POWER_OFF_STAGES_ENUM ReadValue) +{ + uint32_t status = OK; + + REPORT_MSG(ReadValue,"PowerOffSequenceStateMachine"); + switch (ReadValue) + { + case POWER_OFF_INIT: + break; + case POWER_OFF_HEAD_CLEAN: + status = PowerOffHeadClean(); + break; + case POWER_OFF_MIXER_FLUSH: + status = PowerOffMixerFlush(); + break; + case POWER_OFF_HEATERS_OFF: + status = PowerOffHeatersOff(); + break; + case POWER_OFF_STORE_DATA: + status = PowerOffStoreData(); + break; + case POWER_OFF_WAIT_FOR_PROCESSES: //wait for waste emptying: ink filling: thread loading + status = PowerOffWaitForProcesses(); + break; + case POWER_OFF_STOP_RUNNING_JOB: + status = PowerOffStopRunningJob(); + break; + case POWER_OFF_SET_VALVE_POSITION: + status = PowerOffSetValvePosition(); + break; + case POWER_OFF_WAIT_FOR_TEMPERATURE: + status = PowerOffWaitForTemperature(); + break; + case POWER_OFF_TURN_OFF_DRYER_FAN: + status = PowerOffTurnOffDryerFan(); + break; + case POWER_OFF_TURN_OFF_COOLER: + status = PowerOffTurnOffCooler(); + break; + case POWER_OFF_TURN_OFF_BLOWER: + status = PowerOffTurnOffBlower(); + break; + case POWER_OFF_POWER_OFF: + status = PowerOffPowerOff(); + break; + default: + LOG_ERROR(ReadValue,"ERROR IN POWER OFF STATE MACHINE"); + break; + } +return OK; +} + diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.h b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.h new file mode 100644 index 000000000..fa1e123bd --- /dev/null +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.h @@ -0,0 +1,34 @@ +/* + * PowerOffSequence.h + * + * Created on: Apr 2, 2019 + * Author: shlomo + */ + +#ifndef STATEMACHINES_INITIALIZATION_POWEROFFSEQUENCE_H_ +#define STATEMACHINES_INITIALIZATION_POWEROFFSEQUENCE_H_ + + typedef enum + { + POWER_OFF_INIT, + POWER_OFF_HEAD_CLEAN, + POWER_OFF_MIXER_FLUSH, + POWER_OFF_HEATERS_OFF, + POWER_OFF_STORE_DATA, + POWER_OFF_WAIT_FOR_PROCESSES,//wait for waste emptying, ink filling, thread loading + POWER_OFF_STOP_RUNNING_JOB, + POWER_OFF_SET_VALVE_POSITION, + POWER_OFF_WAIT_FOR_TEMPERATURE, + POWER_OFF_TURN_OFF_DRYER_FAN, + POWER_OFF_TURN_OFF_COOLER, + POWER_OFF_TURN_OFF_BLOWER, + POWER_OFF_POWER_OFF, + POWER_OFF_ERROR, + POWER_OFF_MAX, + }POWER_OFF_STAGES_ENUM; + + +uint32_t PowerOffInit(void); + + +#endif /* STATEMACHINES_INITIALIZATION_POWEROFFSEQUENCE_H_ */ diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index 972f79939..b5034a11c 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -59,6 +59,7 @@ #include "PMR/Diagnostics/ThreadAbortJoggingRequest.pb-c.h" #include "PMR/Diagnostics/ThreadAbortJoggingResponse.pb-c.h" +#include "StateMachines/Initialization/PowerIdle.h" #include "./printingSTM.h" #include "modules/thread/thread_ex.h" @@ -954,6 +955,7 @@ Void jobTask(UArg arg0, UArg arg1) case JobRequestMsg: JobEndReason = JOB_OK; JobActive = true; + setmachineActive(true); /*ValidateState (CurrentJob); break; case ValidationResultsOk:*/ @@ -977,6 +979,8 @@ Void jobTask(UArg arg0, UArg arg1) break; case PrintingResultsOk: JobActive = false; + setmachineActive(false); + resetIdleCounter(); CurrentJob = NULL; //if (CurrentRequest!= NULL) // job_request__free_unpacked(CurrentRequest,NULL); @@ -988,6 +992,8 @@ Void jobTask(UArg arg0, UArg arg1) break; case PrintingResultsFail: JobActive = false; + setmachineActive(false); + resetIdleCounter(); CurrentJob = NULL; //if (CurrentRequest!= NULL) // job_request__free_unpacked(CurrentRequest,NULL); -- cgit v1.3.1 From af171144af42c380f5df1569466af6487990977b Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Mon, 15 Apr 2019 15:51:21 +0300 Subject: Version 1.3.8.5 pre Itma1:waste and buttons improved --- .../Embedded/Common/SWUpdate/FirmwareUpgrade.c | 3 +- .../Embedded_SW/Embedded/Common/SW_Info/SW_Info.c | 2 +- .../PMR/Debugging/DebugDistributor.pb-c.c | 61 ++++++++++ .../PMR/Debugging/DebugDistributor.pb-c.h | 55 +++++++++ .../Debugging/SetupDebugDisributorsRequest.pb-c.c | 92 ++++++++++++++ .../Debugging/SetupDebugDisributorsRequest.pb-c.h | 72 +++++++++++ .../Debugging/SetupDebugDisributorsResponse.pb-c.c | 72 +++++++++++ .../Debugging/SetupDebugDisributorsResponse.pb-c.h | 70 +++++++++++ Software/Embedded_SW/Embedded/Main.c | 8 +- .../Modules/Diagnostics/DiagnosticActions.c | 6 + .../Embedded/Modules/Diagnostics/Diagnostics.c | 21 +++- .../Embedded_SW/Embedded/Modules/General/buttons.c | 133 +++++++-------------- .../Embedded_SW/Embedded/Modules/General/buttons.h | 4 +- .../Embedded_SW/Embedded/Modules/Waste/Waste.h | 17 ++- .../Embedded_SW/Embedded/Modules/Waste/Waste_ex.h | 1 + .../Embedded/Modules/Waste/Waste_init.c | 131 ++++++++++++++++---- 16 files changed, 623 insertions(+), 125 deletions(-) create mode 100644 Software/Embedded_SW/Embedded/Communication/PMR/Debugging/DebugDistributor.pb-c.c create mode 100644 Software/Embedded_SW/Embedded/Communication/PMR/Debugging/DebugDistributor.pb-c.h create mode 100644 Software/Embedded_SW/Embedded/Communication/PMR/Debugging/SetupDebugDisributorsRequest.pb-c.c create mode 100644 Software/Embedded_SW/Embedded/Communication/PMR/Debugging/SetupDebugDisributorsRequest.pb-c.h create mode 100644 Software/Embedded_SW/Embedded/Communication/PMR/Debugging/SetupDebugDisributorsResponse.pb-c.c create mode 100644 Software/Embedded_SW/Embedded/Communication/PMR/Debugging/SetupDebugDisributorsResponse.pb-c.h (limited to 'Software/Embedded_SW/Embedded/Common/SWUpdate') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c index d54280fee..01a30c21a 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c @@ -77,6 +77,7 @@ uint32_t ActivateVersionCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) } */ } +int File_i = 0; uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) { @@ -90,7 +91,6 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) fno = my_malloc(sizeof(FILINFO)); if (fno == 0) return ERROR; - int File_i; MessageContainer responseContainer; ActivateVersionRequest* request = activate_version_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); @@ -113,6 +113,7 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) if (NumberOfFiles) { CurrentRunningFile = 0; + File_i = 0; //add control 1 second ActivateVersionControlId = AddControlCallback( ActivateVersionCallBackFunction, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); } diff --git a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c index 1be48737d..075f0c5d9 100644 --- a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c +++ b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c @@ -20,7 +20,7 @@ typedef struct } TangoVersion_t; -TangoVersion_t _gTangoVersion = {1,3,8,49}; +TangoVersion_t _gTangoVersion = {1,3,8,5}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; char _gTangoName [MAX_STRING_LEN] = "Tango01 ";//d diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/DebugDistributor.pb-c.c b/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/DebugDistributor.pb-c.c new file mode 100644 index 000000000..df9728c6c --- /dev/null +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/DebugDistributor.pb-c.c @@ -0,0 +1,61 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: DebugDistributor.proto */ + +/* Do not generate deprecated warnings for self */ +#ifndef PROTOBUF_C__NO_DEPRECATED +#define PROTOBUF_C__NO_DEPRECATED +#endif + +#include "DebugDistributor.pb-c.h" +static const ProtobufCEnumValue debug_distributor__enum_values_by_number[14] = +{ + { "ControlFilter", "DEBUG_DISTRIBUTOR__ControlFilter", 0 }, + { "HeatersFilter", "DEBUG_DISTRIBUTOR__HeatersFilter", 1 }, + { "JobFilter", "DEBUG_DISTRIBUTOR__JobFilter", 2 }, + { "WasteFilter", "DEBUG_DISTRIBUTOR__WasteFilter", 3 }, + { "AlarmFilter", "DEBUG_DISTRIBUTOR__AlarmFilter", 4 }, + { "DiagnosticsFilter", "DEBUG_DISTRIBUTOR__DiagnosticsFilter", 5 }, + { "IDSFilter", "DEBUG_DISTRIBUTOR__IDSFilter", 6 }, + { "ThreadFilter", "DEBUG_DISTRIBUTOR__ThreadFilter", 7 }, + { "GeneralFilter", "DEBUG_DISTRIBUTOR__GeneralFilter", 8 }, + { "CommFilter", "DEBUG_DISTRIBUTOR__CommFilter", 9 }, + { "FPGAFilter", "DEBUG_DISTRIBUTOR__FPGAFilter", 10 }, + { "LoadFilter", "DEBUG_DISTRIBUTOR__LoadFilter", 11 }, + { "InitFilter", "DEBUG_DISTRIBUTOR__InitFilter", 12 }, + { "MaintFilter", "DEBUG_DISTRIBUTOR__MaintFilter", 13 }, +}; +static const ProtobufCIntRange debug_distributor__value_ranges[] = { +{0, 0},{0, 14} +}; +static const ProtobufCEnumValueIndex debug_distributor__enum_values_by_name[14] = +{ + { "AlarmFilter", 4 }, + { "CommFilter", 9 }, + { "ControlFilter", 0 }, + { "DiagnosticsFilter", 5 }, + { "FPGAFilter", 10 }, + { "GeneralFilter", 8 }, + { "HeatersFilter", 1 }, + { "IDSFilter", 6 }, + { "InitFilter", 12 }, + { "JobFilter", 2 }, + { "LoadFilter", 11 }, + { "MaintFilter", 13 }, + { "ThreadFilter", 7 }, + { "WasteFilter", 3 }, +}; +const ProtobufCEnumDescriptor debug_distributor__descriptor = +{ + PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC, + "DebugDistributor", + "DebugDistributor", + "DebugDistributor", + "", + 14, + debug_distributor__enum_values_by_number, + 14, + debug_distributor__enum_values_by_name, + 1, + debug_distributor__value_ranges, + NULL,NULL,NULL,NULL /* reserved[1234] */ +}; diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/DebugDistributor.pb-c.h b/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/DebugDistributor.pb-c.h new file mode 100644 index 000000000..c4385cf7e --- /dev/null +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/DebugDistributor.pb-c.h @@ -0,0 +1,55 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: DebugDistributor.proto */ + +#ifndef PROTOBUF_C_DebugDistributor_2eproto__INCLUDED +#define PROTOBUF_C_DebugDistributor_2eproto__INCLUDED + +#include + +PROTOBUF_C__BEGIN_DECLS + +#if PROTOBUF_C_VERSION_NUMBER < 1003000 +# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1003000 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +#endif + + + + +/* --- enums --- */ + +typedef enum _DebugDistributor { + DEBUG_DISTRIBUTOR__ControlFilter = 0, + DEBUG_DISTRIBUTOR__HeatersFilter = 1, + DEBUG_DISTRIBUTOR__JobFilter = 2, + DEBUG_DISTRIBUTOR__WasteFilter = 3, + DEBUG_DISTRIBUTOR__AlarmFilter = 4, + DEBUG_DISTRIBUTOR__DiagnosticsFilter = 5, + DEBUG_DISTRIBUTOR__IDSFilter = 6, + DEBUG_DISTRIBUTOR__ThreadFilter = 7, + DEBUG_DISTRIBUTOR__GeneralFilter = 8, + DEBUG_DISTRIBUTOR__CommFilter = 9, + DEBUG_DISTRIBUTOR__FPGAFilter = 10, + DEBUG_DISTRIBUTOR__LoadFilter = 11, + DEBUG_DISTRIBUTOR__InitFilter = 12, + DEBUG_DISTRIBUTOR__MaintFilter = 13 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(DEBUG_DISTRIBUTOR) +} DebugDistributor; + +/* --- messages --- */ + +/* --- per-message closures --- */ + + +/* --- services --- */ + + +/* --- descriptors --- */ + +extern const ProtobufCEnumDescriptor debug_distributor__descriptor; + +PROTOBUF_C__END_DECLS + + +#endif /* PROTOBUF_C_DebugDistributor_2eproto__INCLUDED */ diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/SetupDebugDisributorsRequest.pb-c.c b/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/SetupDebugDisributorsRequest.pb-c.c new file mode 100644 index 000000000..ebdad2054 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/SetupDebugDisributorsRequest.pb-c.c @@ -0,0 +1,92 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: SetupDebugDisributorsRequest.proto */ + +/* Do not generate deprecated warnings for self */ +#ifndef PROTOBUF_C__NO_DEPRECATED +#define PROTOBUF_C__NO_DEPRECATED +#endif + +#include "SetupDebugDisributorsRequest.pb-c.h" +void setup_debug_disributors_request__init + (SetupDebugDisributorsRequest *message) +{ + static const SetupDebugDisributorsRequest init_value = SETUP_DEBUG_DISRIBUTORS_REQUEST__INIT; + *message = init_value; +} +size_t setup_debug_disributors_request__get_packed_size + (const SetupDebugDisributorsRequest *message) +{ + assert(message->base.descriptor == &setup_debug_disributors_request__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t setup_debug_disributors_request__pack + (const SetupDebugDisributorsRequest *message, + uint8_t *out) +{ + assert(message->base.descriptor == &setup_debug_disributors_request__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t setup_debug_disributors_request__pack_to_buffer + (const SetupDebugDisributorsRequest *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &setup_debug_disributors_request__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +SetupDebugDisributorsRequest * + setup_debug_disributors_request__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (SetupDebugDisributorsRequest *) + protobuf_c_message_unpack (&setup_debug_disributors_request__descriptor, + allocator, len, data); +} +void setup_debug_disributors_request__free_unpacked + (SetupDebugDisributorsRequest *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &setup_debug_disributors_request__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +static const ProtobufCFieldDescriptor setup_debug_disributors_request__field_descriptors[1] = +{ + { + "DistributorActive", + 1, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_BOOL, + offsetof(SetupDebugDisributorsRequest, n_distributoractive), + offsetof(SetupDebugDisributorsRequest, distributoractive), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned setup_debug_disributors_request__field_indices_by_name[] = { + 0, /* field[0] = DistributorActive */ +}; +static const ProtobufCIntRange setup_debug_disributors_request__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 1 } +}; +const ProtobufCMessageDescriptor setup_debug_disributors_request__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "SetupDebugDisributorsRequest", + "SetupDebugDisributorsRequest", + "SetupDebugDisributorsRequest", + "", + sizeof(SetupDebugDisributorsRequest), + 1, + setup_debug_disributors_request__field_descriptors, + setup_debug_disributors_request__field_indices_by_name, + 1, setup_debug_disributors_request__number_ranges, + (ProtobufCMessageInit) setup_debug_disributors_request__init, + NULL,NULL,NULL /* reserved[123] */ +}; diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/SetupDebugDisributorsRequest.pb-c.h b/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/SetupDebugDisributorsRequest.pb-c.h new file mode 100644 index 000000000..65a5091ac --- /dev/null +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/SetupDebugDisributorsRequest.pb-c.h @@ -0,0 +1,72 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: SetupDebugDisributorsRequest.proto */ + +#ifndef PROTOBUF_C_SetupDebugDisributorsRequest_2eproto__INCLUDED +#define PROTOBUF_C_SetupDebugDisributorsRequest_2eproto__INCLUDED + +#include + +PROTOBUF_C__BEGIN_DECLS + +#if PROTOBUF_C_VERSION_NUMBER < 1003000 +# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1003000 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +#endif + + +typedef struct _SetupDebugDisributorsRequest SetupDebugDisributorsRequest; + + +/* --- enums --- */ + + +/* --- messages --- */ + +struct _SetupDebugDisributorsRequest +{ + ProtobufCMessage base; + size_t n_distributoractive; + protobuf_c_boolean *distributoractive; +}; +#define SETUP_DEBUG_DISRIBUTORS_REQUEST__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&setup_debug_disributors_request__descriptor) \ + , 0,NULL } + + +/* SetupDebugDisributorsRequest methods */ +void setup_debug_disributors_request__init + (SetupDebugDisributorsRequest *message); +size_t setup_debug_disributors_request__get_packed_size + (const SetupDebugDisributorsRequest *message); +size_t setup_debug_disributors_request__pack + (const SetupDebugDisributorsRequest *message, + uint8_t *out); +size_t setup_debug_disributors_request__pack_to_buffer + (const SetupDebugDisributorsRequest *message, + ProtobufCBuffer *buffer); +SetupDebugDisributorsRequest * + setup_debug_disributors_request__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void setup_debug_disributors_request__free_unpacked + (SetupDebugDisributorsRequest *message, + ProtobufCAllocator *allocator); +/* --- per-message closures --- */ + +typedef void (*SetupDebugDisributorsRequest_Closure) + (const SetupDebugDisributorsRequest *message, + void *closure_data); + +/* --- services --- */ + + +/* --- descriptors --- */ + +extern const ProtobufCMessageDescriptor setup_debug_disributors_request__descriptor; + +PROTOBUF_C__END_DECLS + + +#endif /* PROTOBUF_C_SetupDebugDisributorsRequest_2eproto__INCLUDED */ diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/SetupDebugDisributorsResponse.pb-c.c b/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/SetupDebugDisributorsResponse.pb-c.c new file mode 100644 index 000000000..514e7c05b --- /dev/null +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/SetupDebugDisributorsResponse.pb-c.c @@ -0,0 +1,72 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: SetupDebugDisributorsResponse.proto */ + +/* Do not generate deprecated warnings for self */ +#ifndef PROTOBUF_C__NO_DEPRECATED +#define PROTOBUF_C__NO_DEPRECATED +#endif + +#include "SetupDebugDisributorsResponse.pb-c.h" +void setup_debug_disributors_response__init + (SetupDebugDisributorsResponse *message) +{ + static const SetupDebugDisributorsResponse init_value = SETUP_DEBUG_DISRIBUTORS_RESPONSE__INIT; + *message = init_value; +} +size_t setup_debug_disributors_response__get_packed_size + (const SetupDebugDisributorsResponse *message) +{ + assert(message->base.descriptor == &setup_debug_disributors_response__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t setup_debug_disributors_response__pack + (const SetupDebugDisributorsResponse *message, + uint8_t *out) +{ + assert(message->base.descriptor == &setup_debug_disributors_response__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t setup_debug_disributors_response__pack_to_buffer + (const SetupDebugDisributorsResponse *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &setup_debug_disributors_response__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +SetupDebugDisributorsResponse * + setup_debug_disributors_response__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (SetupDebugDisributorsResponse *) + protobuf_c_message_unpack (&setup_debug_disributors_response__descriptor, + allocator, len, data); +} +void setup_debug_disributors_response__free_unpacked + (SetupDebugDisributorsResponse *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &setup_debug_disributors_response__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +#define setup_debug_disributors_response__field_descriptors NULL +#define setup_debug_disributors_response__field_indices_by_name NULL +#define setup_debug_disributors_response__number_ranges NULL +const ProtobufCMessageDescriptor setup_debug_disributors_response__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "SetupDebugDisributorsResponse", + "SetupDebugDisributorsResponse", + "SetupDebugDisributorsResponse", + "", + sizeof(SetupDebugDisributorsResponse), + 0, + setup_debug_disributors_response__field_descriptors, + setup_debug_disributors_response__field_indices_by_name, + 0, setup_debug_disributors_response__number_ranges, + (ProtobufCMessageInit) setup_debug_disributors_response__init, + NULL,NULL,NULL /* reserved[123] */ +}; diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/SetupDebugDisributorsResponse.pb-c.h b/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/SetupDebugDisributorsResponse.pb-c.h new file mode 100644 index 000000000..a3ecfb1d7 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Debugging/SetupDebugDisributorsResponse.pb-c.h @@ -0,0 +1,70 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: SetupDebugDisributorsResponse.proto */ + +#ifndef PROTOBUF_C_SetupDebugDisributorsResponse_2eproto__INCLUDED +#define PROTOBUF_C_SetupDebugDisributorsResponse_2eproto__INCLUDED + +#include + +PROTOBUF_C__BEGIN_DECLS + +#if PROTOBUF_C_VERSION_NUMBER < 1003000 +# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1003000 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +#endif + + +typedef struct _SetupDebugDisributorsResponse SetupDebugDisributorsResponse; + + +/* --- enums --- */ + + +/* --- messages --- */ + +struct _SetupDebugDisributorsResponse +{ + ProtobufCMessage base; +}; +#define SETUP_DEBUG_DISRIBUTORS_RESPONSE__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&setup_debug_disributors_response__descriptor) \ + } + + +/* SetupDebugDisributorsResponse methods */ +void setup_debug_disributors_response__init + (SetupDebugDisributorsResponse *message); +size_t setup_debug_disributors_response__get_packed_size + (const SetupDebugDisributorsResponse *message); +size_t setup_debug_disributors_response__pack + (const SetupDebugDisributorsResponse *message, + uint8_t *out); +size_t setup_debug_disributors_response__pack_to_buffer + (const SetupDebugDisributorsResponse *message, + ProtobufCBuffer *buffer); +SetupDebugDisributorsResponse * + setup_debug_disributors_response__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void setup_debug_disributors_response__free_unpacked + (SetupDebugDisributorsResponse *message, + ProtobufCAllocator *allocator); +/* --- per-message closures --- */ + +typedef void (*SetupDebugDisributorsResponse_Closure) + (const SetupDebugDisributorsResponse *message, + void *closure_data); + +/* --- services --- */ + + +/* --- descriptors --- */ + +extern const ProtobufCMessageDescriptor setup_debug_disributors_response__descriptor; + +PROTOBUF_C__END_DECLS + + +#endif /* PROTOBUF_C_SetupDebugDisributorsResponse_2eproto__INCLUDED */ diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index 60707f2ef..a125ef10c 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -176,9 +176,9 @@ int main(void) Control_Dryer_Fan(STOP,0);//Preventing unwanted movement at power up, since the default from FPGA is "0" (= START) #endif -//#ifdef WATCHDOG +#ifdef WATCHDOG InitWatchdog(ui32SysClock); -//#endif +#endif CommunicationTaskInit(); utilsInit(ui32SysClock); @@ -196,8 +196,8 @@ int main(void) Heaters_Init(); MotorsInit(); //Shai WHS_HW_test(); // for WHS sensor test -// WHS_init(); -// Buttons_Init(); + WHS_init(); + Buttons_Init(); //IDS_ModuleInit(); Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste); diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticActions.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticActions.c index c9bbe2df6..97489f431 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticActions.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticActions.c @@ -255,6 +255,12 @@ uint32_t SetDigitalOutRequestRequestFunc(MessageContainer* requestContainer) else Control_Dryer_Fan(STOP,0);//use START or STOP, 0 - 100%(); break; + case INTERFACE_IOS__GPO_WASTECH_PUMP2://valve + Valve_Set(VALVE_WASTE_TANK, request->value); + break; + case INTERFACE_IOS__GPO_WHS_WTANKPUMP2: + SetWastePump( request->value); + break; default: responseContainer.has_error = true; responseContainer.error = ERROR_CODE__GENERAL_ERROR; diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index d39c97621..5ef216264 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -29,6 +29,7 @@ #include "Modules/AlarmHandling/AlarmHandling.h" #include "Modules/heaters/heaters_ex.h" #include "modules/thread/thread_ex.h" +#include "modules/waste/waste.h" #include "PMR/Hardware/HardwareDancerType.pb-c.h" #include @@ -104,7 +105,7 @@ DoubleArray DiagnosticsDispenserPressure[MAX_SYSTEM_DISPENSERS]; HeaterState **heatersstates; HeaterState HeaterInfo[HEATER_TYPE__MixerHeater+1]; DigitalInterfaceState **digitalinterfacestates; -DigitalInterfaceState DigitalOutputState[MAX_HEATERS_NUM+2]; +DigitalInterfaceState DigitalOutputState[MAX_HEATERS_NUM+8]; /*double dispenser1motorfrequency[DIAGNOSTICS_LIMIT+1]; double dispenser2motorfrequency[DIAGNOSTICS_LIMIT+1]; double dispenser3motorfrequency[DIAGNOSTICS_LIMIT+1]; @@ -168,8 +169,8 @@ void DiagnosticsInit(void) heater_state__init(&HeaterInfo[i]); heatersstates[i] = &HeaterInfo[i]; } - digitalinterfacestates = (DigitalInterfaceState**)my_malloc(sizeof(DigitalInterfaceState *)*MAX_HEATERS_NUM); - for (i = 0;i #include @@ -24,33 +23,13 @@ #include "Modules/General/buttons.h" #include "StateMachines/Initialization/PowerOffSequence.h" +#include "StateMachines/Initialization/PowerIdle.h" -//int MachineOnOff(); int PowerDown(); int PowerUp(); int thredJog(); -/* -typedef enum -{ - OFFPB = 0, - COUNTPB , - SHORTPB , - LONGPB , - REPLONGPB //repeat long PB -}PBstat; -*/ -typedef enum -{ - MSEC = 0, - lESS200 , - LESS500 , - LESS5000 , - MORE5000 -}timems; - - //enum PBstat OnOffPBstate = OFFPB; //enum PBstat ret @@ -68,7 +47,7 @@ uint32_t StateMachine( button *pBtn); uint32_t ButtonJogCallBackFunction(uint32_t IfIndex, uint32_t ReadValue); uint32_t ButtonJogCBFunction(uint32_t IfIndex, uint32_t ReadValue); uint8_t thraedJogging(uint8_t off); -uint32_t setJoggingEnableCondition( button *pBtn); +//uint32_t setJoggingEnableCondition( button *pBtn); uint32_t joggingMachine( button *pBtn); //uint8_t OnOffPB, @@ -87,8 +66,8 @@ bool Read_PWR_Button();//TODO move to GPIO folder int PowerDown() { - bool ret = OK; - PowerOffInit(); + bool ret = !OK; + ret = PowerOffInit(); return ret; } @@ -100,42 +79,25 @@ int PowerUp() return ret; } - bool SetPowerMachineState(PBmachineState state) { bool ret = OK; switch ( state ) { case sttOFF: - power.state = state; - break; case sttON: + case sttIDLE: power.state = state; - break; + break; case sttDISABLE: - jog.state = state; - break; case sttENABLE: - jog.state = state; - break; - case sttIDLE: - power.state = state; - break; case sttJOGGING: jog.state = state; break; case sttRDY: - load.state = state; - break; case sttPRELOAD: - load.state = state; - break; case sttLOADING: - load.state = state; - break; case sttLOADSUCSESS: - load.state = state; - break; case sttLOADFAIL: load.state = state; break; @@ -190,9 +152,7 @@ uint32_t ButtonLoadCallBackFunction(uint32_t IfIndex, uint32_t ReadValue) uint32_t Buttons_Init(void) { - -// power.bttn_status = 0 ; -// power.bttn_name = "power"; //option + strcpy(power.bttn_name, "power"); power.bttn_status = release; // 0=release 1=press power.Action = OFFPB ; //off,short,long,count,replong power.color = BLUE; //off, blue, blink, bithing @@ -201,8 +161,7 @@ uint32_t Buttons_Init(void) AddControlCallback( ButtonPowerCBFunction, BUTTOMS_SAMPLE_TIME, ButtonPowerCallBackFunction, 0,0,0 ); // eFiftyMillisecond -// jog.bttn_status = 0 ; -// jog.bttn_name = "jog"; //option + strcpy(jog.bttn_name, "jog"); jog.bttn_status = release; // 0=release 1=press jog.Action = OFFPB ; //OFFPB,short,long,count,replong jog.color = colorOFF; //colorOFF, BLUE, BLINK, @@ -210,12 +169,11 @@ uint32_t Buttons_Init(void) jog.count = 0; AddControlCallback( ButtonJogCBFunction, BUTTOMS_SAMPLE_TIME, ButtonJogCallBackFunction, 0,0,0 ); // -// load.bttn_status = 0 ; -// load.bttn_name = "load"; //option + strcpy(load.bttn_name, "load"); load.bttn_status = release; // 0=release 1=press load.Action = OFFPB ; //OFFPB,short,long,count,replong load.color = colorOFF; //colorOFF, BLUE, BLINK, - load.state = sttOFF; // sttDISABLE, sttENABLE, sttJOGGING + load.state = sttRDY; // load.count = 0; AddControlCallback( ButtonLoadCBFunction, BUTTOMS_SAMPLE_TIME, ButtonLoadCallBackFunction, 0,0,0 ); // @@ -232,15 +190,12 @@ uint32_t ButtonPowerCBFunction(uint32_t IfIndex, uint32_t ReadValue) uint32_t ButtonJogCBFunction(uint32_t IfIndex, uint32_t ReadValue) { - jog.bttn_status = ReadValue; //if (ReadValue == press) { - setJoggingEnableCondition(&jog); + //setJoggingEnableCondition(&jog); joggingMachine(&jog); } - - return 0; } @@ -452,36 +407,36 @@ return 0; -uint32_t setJoggingEnableCondition( button *pBtn) -{ - uint8_t parameter = 3; - - if (0 -// to do : what are the conditions for enable / disable -// 1. -// 2. -// 3. -// ... - ) - { - pBtn->state = sttDISABLE; - REPORT_MSG(parameter," ------------ Jogging : setJoggingEnableCondition sttDISABLE ----------------- "); - pBtn->color = colorOFF; - Pannel_Leds(THREAD_JOGGING, MODE_OFF); //AVI+ - // ThreadAbortJoggingFunc(); - } - - else - { - pBtn->state = sttENABLE; -// REPORT_MSG(parameter," ------------ Jogging : setJoggingEnableCondition sttENABLE ----------------- "); - pBtn->color = BLUE; - Pannel_Leds(THREAD_JOGGING, MODE_ON); //AVI+ - //ThreadJoggingFunc(40); - } - -return 0; -} +//uint32_t setJoggingEnableCondition( button *pBtn) +//{ +// uint8_t parameter = 3; +// +// if (0 +//// to do : what are the conditions for enable / disable +//// 1. +//// 2. +//// 3. +//// ... +// ) +// { +// pBtn->state = sttDISABLE; +// REPORT_MSG(parameter," ------------ Jogging : setJoggingEnableCondition sttDISABLE ----------------- "); +// pBtn->color = colorOFF; +// Pannel_Leds(THREAD_JOGGING, MODE_OFF); //AVI+ +// // ThreadAbortJoggingFunc(); +// } +// +// else +// { +// pBtn->state = sttENABLE; +//// REPORT_MSG(parameter," ------------ Jogging : setJoggingEnableCondition sttENABLE ----------------- "); +// pBtn->color = BLUE; +// Pannel_Leds(THREAD_JOGGING, MODE_ON); //AVI+ +// //ThreadJoggingFunc(40); +// } +// +//return 0; +//} @@ -575,13 +530,14 @@ return 0; uint32_t LoadStatMachine( button *pBtn) { - //uint8_t parameter = 5; + uint8_t parameter = 5; //REPORT_MSG(parameter," ------------ start loading ----------------- "); Report(" ------------ start loading ----------------- ",__FILE__,__LINE__,pBtn->state,RpWarning,pBtn->color,0); switch (pBtn->state) { case sttRDY : + REPORT_MSG(parameter," ------------ load.state = sttRDY ----------------- "); switch (pBtn->Action) { case (SHORTPB): @@ -607,6 +563,7 @@ uint32_t LoadStatMachine( button *pBtn) } break; case sttPRELOAD: + REPORT_MSG(parameter," ------------ load.state = sttPRELOAD ----------------- "); switch (pBtn->Action) { case (SHORTPB): @@ -632,6 +589,7 @@ uint32_t LoadStatMachine( button *pBtn) } break; case sttLOADING: + REPORT_MSG(parameter," ------------ load.state = sttLOADING ----------------- "); break; // case sttLOADSUCSESS ????? // break; @@ -639,6 +597,7 @@ uint32_t LoadStatMachine( button *pBtn) // break; default: //sttDISABLE + REPORT_MSG(parameter," ------------ load.state = default ----------------- "); pBtn->color = colorOFF; Pannel_Leds(THREAD_LOAD, MODE_OFF);//AVI+ break; diff --git a/Software/Embedded_SW/Embedded/Modules/General/buttons.h b/Software/Embedded_SW/Embedded/Modules/General/buttons.h index 8b064bbcc..2ec6d32a0 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/buttons.h +++ b/Software/Embedded_SW/Embedded/Modules/General/buttons.h @@ -29,10 +29,12 @@ typedef enum { sttOFF = 0, sttON, + sttIDLE, + sttDISABLE, sttENABLE, - sttIDLE, sttJOGGING, + sttRDY, sttPRELOAD, sttLOADING, diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste.h b/Software/Embedded_SW/Embedded/Modules/Waste/Waste.h index bda01564f..74f7b40ef 100644 --- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste.h +++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste.h @@ -38,14 +38,14 @@ typedef enum typedef enum { - SENSORnotFULL = 0, - SENSORFULL + SENSORFULL = 0, + SENSORnotFULL } WHS_FullSensorStatus; typedef enum { - SENSOREMPTY = 0, - SENSORnotEMPTY + SENSORnotEMPTY = 0, + SENSOREMPTY } WHS_EmptySensorStatus; typedef enum @@ -99,6 +99,15 @@ U8 WHS_init(void); U8 WHS_HW_test(void); bool WHS_IsEmptying(); +bool WHS_IsContainerFull(); +bool WHS_IsContainerOverflow(); +bool WHS_WasteCartridgeLowerPresent(); +bool WHS_WasteCartridgeMiddlePresent(); +bool WHS_IsPumpActive(); +bool WHS_IsValveOpen(); + +bool SetWastePump( bool power); + #endif diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_ex.h b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_ex.h index e69de29bb..8b1378917 100644 --- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_ex.h @@ -0,0 +1 @@ + diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c index 9531b67d6..8aa358e32 100644 --- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c @@ -19,7 +19,7 @@ #define CartridgeWaste2CallBackTime eOneSecond #define STARTCOUNT 1 #define STOPCOUNT 0 -#define PumpTimeout 60 // minutes +#define PumpTimeout 1200 // seconds; 20 minutes, per Moty, 15/4/19 /*------------Waste Tank function-----------------------*/ @@ -98,6 +98,14 @@ struct WHS_information struct WHS_information WHS_info; +bool WHS_IsContainerFull(){return WHS_info.WHS_sensors.waste_tank_full_sensor;} +bool WHS_IsContainerOverflow(){return WHS_info.WHS_sensors.waste_tank_over_flow_sensor;} +bool WHS_WasteCartridgeLowerPresent(){return WHS_info.WHS_sensors.waste_cartridge1_precense_sensor;} +bool WHS_WasteCartridgeMiddlePresent(){return WHS_info.WHS_sensors.waste_cartridge2_precense_sensor;} +bool WHS_IsPumpActive(){return WHS_info.WHS_pump.status;} +bool WHS_IsValveOpen(){return WHS_info.WHS_valve;} + + bool WHS_IsEmptying() { @@ -141,13 +149,17 @@ bool CartridgeAuthentication(cartridge_name cart_name) { case waste_cartridge1: WHS_info.cartridge_1.autheticate = PASSED; + //Pannel_Leds(CART_2, MODE_ON); break; case waste_cartridge2: WHS_info.cartridge_2.autheticate = PASSED; + //Pannel_Leds(CART_3, MODE_ON); break; default: WHS_info.cartridge_1.autheticate = FAILED; WHS_info.cartridge_2.autheticate = FAILED; + //Pannel_Leds(CART_2, MODE_OFF); + //Pannel_Leds(CART_3, MODE_OFF); break; } ret = OK; @@ -231,7 +243,9 @@ bool SetValveDirection() * * */ bool ret = notOK; - if (WHS_info.WHS_valve != no_waste_cartridge) + //if (WHS_info.WHS_valve != no_waste_cartridge) + if (WHS_info.active_cartridge == waste_cartridge1) WHS_info.WHS_valve = 1; + else WHS_info.WHS_valve = 2; { Valve_Set(VALVE_WASTE_TANK, WHS_info.WHS_valve); ret = OK; @@ -258,6 +272,7 @@ U8 CartridgeWasteFilling(bool status) SetWastePump(OPEN); //WHS_info.WHS_pump.time = 0; REPORT_MSG(WHS_empty," ------------ WHS WHS_empty start PUMP ----------------- "); + ret=OK; } else // stop Waste cartridge filling { @@ -352,7 +367,7 @@ WHS_sttMachin UpdateStateMachine() bool initWHS_WasteTank() { WHS_info.WHS_sensors.waste_tank_empty_sensor = RdWasteTankEmptySensor(); - WHS_info.WHS_sensors.waste_tank_full_sensor = SENSORnotFULL;//RdWasteTankFullSensor(); + WHS_info.WHS_sensors.waste_tank_full_sensor = SENSORnotFULL;//;RdWasteTankFullSensor() UpdateStateMachine(); AddControlCallback(WasteTankCBFunction, WasteTankCallBackTime , WasteTankCallBackFunction, 0,0,0);//eOneMinute return OK; @@ -392,7 +407,7 @@ WHS_sensor FullSensorEvent() { WHS_info.event = WHS_full_sensor; ret = WHS_full_sensor; - WHS_info.WHS_sensors.waste_tank_full_sensor = !WHS_info.WHS_sensors.waste_tank_full_sensor; + WHS_info.WHS_sensors.waste_tank_full_sensor = 1-WHS_info.WHS_sensors.waste_tank_full_sensor; } return ret; } @@ -446,7 +461,10 @@ bool WasteTankCBFunction() if (WHS_info.WHS_sensors.waste_tank_empty_sensor == SENSORnotEMPTY) { if (WHS_info.sttMachine == WHS_empty) + { WHS_info.sttMachine = WHS_filling; + REPORT_MSG(WHS_filling," ------------ WHS_filling ----------------- "); + } else { REPORT_MSG(WHS_filling," ------------ WHS EMPTY sensor failed !!!!!!! ----------------- "); @@ -457,9 +475,10 @@ bool WasteTankCBFunction() if (WHS_info.sttMachine == WHS_emptying) { WHS_info.sttMachine = WHS_empty; + REPORT_MSG(WHS_filling," ------------ WHS_empty ----------------- "); ret = CartridgeWasteFilling(OFF); WHS_info.Cartridge_Cover_device_Id = RemoveControlCallback(WHS_info.Cartridge_Cover_device_Id, WasteTankCBFunction ); - WHS_info.Cartridge_Cover_device_Id = AddControlCallback( WasteTankCBFunction, CartridgeCoverCallBackTime, CartridgeCoverCallBackFunction, 0,0,0 );//eOneSecond + WHS_info.Cartridge_Cover_device_Id = AddControlCallback( WasteTankCBFunction, CartridgeCoverCallBackTime, CartridgeCoverCallBackFunction, 0,0,0 );//eOneSecond //SafeRemoveControlCallback(Cartridge_Cover_device_Id, CartridgeCoverCBFunction ); } else @@ -471,24 +490,25 @@ bool WasteTankCBFunction() case WHS_full_sensor: if (WHS_info.WHS_sensors.waste_tank_full_sensor == SENSORFULL) { - if (WHS_info.sttMachine == WHS_filling) - { - WHS_info.sttMachine = WHS_full; - WHS_info.Cartridge_Cover_device_Id = RemoveControlCallback(WHS_info.Cartridge_Cover_device_Id, WasteTankCBFunction ); - WHS_info.Cartridge_Cover_device_Id = AddControlCallback( WasteTankCBFunction, CartridgeCoverCallBackFastTime , CartridgeCoverCallBackFunction, 0,0,0 );//eTenMillisecond - ret = CartridgeWasteFilling(ON); - // cant start a new Job - } - else + WHS_info.sttMachine = WHS_full; + REPORT_MSG(WHS_emptying," ------------ WHS_full ----------------- "); + WHS_info.Cartridge_Cover_device_Id = RemoveControlCallback(WHS_info.Cartridge_Cover_device_Id, WasteTankCBFunction ); + WHS_info.Cartridge_Cover_device_Id = AddControlCallback( WasteTankCBFunction, CartridgeCoverCallBackFastTime , CartridgeCoverCallBackFunction, 0,0,0 );//eTenMillisecond + ret = CartridgeWasteFilling(ON); + if (ret != OK) { - REPORT_MSG(WHS_filling," ------------ WHS FULL sensor failed !!!!!!! ----------------- "); + //recreate the full event until cartridge is inserted + WHS_info.WHS_sensors.waste_tank_full_sensor = 1-WHS_info.WHS_sensors.waste_tank_full_sensor; } + + // cant start a new Job } else { if (WHS_info.sttMachine == WHS_full) { WHS_info.sttMachine = WHS_emptying; + REPORT_MSG(WHS_emptying," ------------ WHS_emptying ----------------- "); // can start a new JOB } else @@ -548,13 +568,15 @@ bool WasteTankCBFunction() case WHS_waste1_presence_sensor : if (WHS_info.WHS_sensors.waste_cartridge1_precense_sensor == WHS_CarteidgePrecense ) // waste cartridge 1 is inserted . { - SetCartridgeLED(waste_cartridge1, led_on); + //SetCartridgeLED(waste_cartridge1, led_on); + Pannel_Leds(CART_2, MODE_ON); RdWasteCartridgeParam(waste_cartridge1); + SetActiveWastCartridge(); + SetValveDirection(); if ( CartridgeAuthentication(waste_cartridge1)) // to define authentication { //WHS_info.cartridge_1.autheticate = PASSED; //='0' //???WHS_info.WHS_valve = waste_cartridge1; // or we should do it only before pumping???? - //???SetValveDirection(); // or we should do it only before pumping???? } else { @@ -564,6 +586,7 @@ bool WasteTankCBFunction() } else // waste cartridge 1 take out { + Pannel_Leds(CART_2, MODE_OFF); WHS_info.cartridge_1.autheticate = FAILED; //???if (WHS_info.cartridge_2.autheticate == PASSED) // or we should do it only before pumping???? //???{ @@ -582,7 +605,7 @@ bool WasteTankCBFunction() case WHS_waste2_presence_sensor : if (WHS_info.WHS_sensors.waste_cartridge2_precense_sensor == WHS_CarteidgePrecense ) // waste cartridge is inserted . { - SetCartridgeLED(waste_cartridge2, led_on); + Pannel_Leds(CART_3, MODE_ON);//SetCartridgeLED(waste_cartridge2, led_on); RdWasteCartridgeParam(waste_cartridge2); if ( CartridgeAuthentication(waste_cartridge2)) // to define authentication { @@ -598,6 +621,7 @@ bool WasteTankCBFunction() } else // waste cartridge 2 take out { + Pannel_Leds(CART_3, MODE_OFF); WHS_info.cartridge_2.autheticate = FAILED; /* if (WHS_info.cartridge_2.autheticate == PASSED) // or we should do it only before pumping???? @@ -616,6 +640,7 @@ bool WasteTankCBFunction() //SetActiveWastCartridge(); break; case WHS_Timeout: + REPORT_MSG(WHS_emptying," ------------ WHS_Timeout ----------------- "); AlarmHandlingSetAlarm( EVENT_TYPE__WASTE_CONTAINER_EMPTYING_TIMEOUT, true); CartridgeWasteFilling(OFF); break; @@ -633,11 +658,16 @@ bool WasteTankCBFunction() bool RdCartridgeCoverSensor() { + uint32_t parameter = 6 ; + + //REPORT_MSG(parameter," ------------ RD Cartridge Cover Sensor ----------------- "); bool ret = notOK; WHS_Read_GPI_Registers(); // WHS_info.WHS_sensors.cartridge_cover = Get_COVER_1_State(CartridgesDoor); // ret = WHS_info.WHS_sensors.cartridge_cover; ret = Get_COVER_1_State(CartridgesDoor); + if ((ret == OPEN ) && (ret != WHS_info.WHS_sensors.cartridge_cover)) Report(" ------------ RD Cartridge Cover Sensor is = OPEN(1) ----------------- ",__FILE__,__LINE__,ret,RpWarning,ret,0); + if ((ret == CLOSE ) && (ret != WHS_info.WHS_sensors.cartridge_cover)) REPORT_MSG(parameter," ------------ RD Cartridge Cover Sensor is = CLOSE(0) ----------------- "); return ret; } @@ -646,10 +676,14 @@ bool RdCartridgeCoverSensor() WHS_sensor CartridgeCoverCallBackFunction() { + uint32_t parameter = 6 ; + + WHS_sensor ret = WHS_no_event; //ret = RdCartridgeCoverSensor(); if (WHS_info.WHS_sensors.cartridge_cover != RdCartridgeCoverSensor()) { + REPORT_MSG(parameter," ------------ find : WHS_cartridge_cover_sensor event ----------------- "); WHS_info.event = WHS_cartridge_cover_sensor; WHS_info.WHS_sensors.cartridge_cover = !WHS_info.WHS_sensors.cartridge_cover; ret = WHS_cartridge_cover_sensor; @@ -659,10 +693,13 @@ WHS_sensor CartridgeCoverCallBackFunction() WHS_sensor CartridgeWaste1CallBackFunction() { + uint32_t parameter = 6 ; + WHS_sensor ret = WHS_no_event; //ret = RdCartridgeCoverSensor(); if (WHS_info.WHS_sensors.waste_cartridge1_precense_sensor != RdWasteCartridge1Sensor()) { + REPORT_MSG(parameter," ------------ find : WHS_waste1_presence_sensor event ----------------- "); WHS_info.event = WHS_waste1_presence_sensor; WHS_info.WHS_sensors.waste_cartridge1_precense_sensor = !WHS_info.WHS_sensors.waste_cartridge1_precense_sensor; ret = WHS_waste1_presence_sensor; @@ -672,10 +709,13 @@ WHS_sensor CartridgeWaste1CallBackFunction() WHS_sensor CartridgeWaste2CallBackFunction() { + uint32_t parameter = 6 ; + WHS_sensor ret = WHS_no_event; //ret = RdCartridgeCoverSensor(); if (WHS_info.WHS_sensors.waste_cartridge2_precense_sensor != RdWasteCartridge2Sensor()) { + REPORT_MSG(parameter," ------------ find : WHS_waste2_presence_sensor event ----------------- "); WHS_info.event = WHS_waste2_presence_sensor; WHS_info.WHS_sensors.waste_cartridge2_precense_sensor = !WHS_info.WHS_sensors.waste_cartridge2_precense_sensor; ret = WHS_waste2_presence_sensor; @@ -686,15 +726,45 @@ WHS_sensor CartridgeWaste2CallBackFunction() /*------------------------------- Cartridge Waste -----------------------------------------*/ bool InitWasteCartStatus() { + uint32_t parameter = 6 ; + WHS_info.WHS_sensors.cartridge_cover = RdCartridgeCoverSensor(); - WHS_info.WHS_sensors.waste_cartridge1_precense_sensor = RdWasteCartridge1Sensor(); - WHS_info.WHS_sensors.waste_cartridge2_precense_sensor = RdWasteCartridge2Sensor(); + + if (RdWasteCartridge1Sensor()) + { + REPORT_MSG(parameter," ------------ WHS_waste1_presence_sensor event ----------------- "); + WHS_info.WHS_sensors.waste_cartridge1_precense_sensor = WHS_CarteidgePrecense; + Pannel_Leds( CART_2, MODE_ON); + } + else + { + REPORT_MSG(parameter," ------------ WHS_waste1_NOT !!! presence_sensor ----------------- "); + WHS_info.WHS_sensors.waste_cartridge1_precense_sensor = WHS_CarteidgeNotPrecense; + Pannel_Leds( CART_2, MODE_OFF); + } + + if (RdWasteCartridge2Sensor()) + { + REPORT_MSG(parameter," ------------ WHS_waste2_presence_sensor event ----------------- "); + WHS_info.WHS_sensors.waste_cartridge2_precense_sensor = WHS_CarteidgePrecense; + Pannel_Leds( CART_3, MODE_ON); + } + else + { + REPORT_MSG(parameter," ------------ WHS_waste1_NOT !!! presence_sensor ----------------- "); + WHS_info.WHS_sensors.waste_cartridge2_precense_sensor = WHS_CarteidgeNotPrecense; + Pannel_Leds( CART_3, MODE_OFF); + } + + + if (WHS_info.WHS_sensors.waste_cartridge1_precense_sensor == WHS_CarteidgePrecense) CartridgeAuthentication(waste_cartridge1); if (WHS_info.WHS_sensors.waste_cartridge2_precense_sensor == WHS_CarteidgePrecense) CartridgeAuthentication(waste_cartridge2); SetActiveWastCartridge(); if (WHS_info.WHS_sensors.cartridge_cover == WHS_CartridgeCoverOPEN) { + REPORT_MSG(parameter," ------------ WHS_CartridgeCoverOPEN : add callback for cart1 and cart 1 ----------------- "); WHS_info.Cartridge_Waste1_device_Id = AddControlCallback( WasteTankCBFunction, eOneSecond, CartridgeWaste1CallBackFunction, 0,0,0 ); WHS_info.Cartridge_Waste2_device_Id = AddControlCallback( WasteTankCBFunction, eOneSecond, CartridgeWaste2CallBackFunction, 0,0,0 ); } @@ -725,12 +795,26 @@ bool RdWasteCartridge2Sensor() bool SetActiveWastCartridge() { + uint8_t parameter = 5; + bool ret = notOK; if (( WHS_info.WHS_sensors.waste_cartridge1_precense_sensor == PRECENSE ) && - (WHS_info.cartridge_1.autheticate == PASSED)) WHS_info.active_cartridge = waste_cartridge1; + (WHS_info.cartridge_1.autheticate == PASSED)) + { + REPORT_MSG(parameter," ------------ WHS : active_cartridge = waste_cartridge 1 ----------------- "); + WHS_info.active_cartridge = waste_cartridge1; + } else if (( WHS_info.WHS_sensors.waste_cartridge2_precense_sensor == PRECENSE) && - (WHS_info.cartridge_2.autheticate == PASSED)) WHS_info.active_cartridge = waste_cartridge2; - else WHS_info.active_cartridge = no_waste_cartridge; + (WHS_info.cartridge_2.autheticate == PASSED)) + { + REPORT_MSG(parameter," ------------ WHS : active_cartridge = waste_cartridge 2 ----------------- "); + WHS_info.active_cartridge = waste_cartridge2; + } + else + { + REPORT_MSG(parameter," ------------ WHS : NO active_cartridge ----------------- "); + WHS_info.active_cartridge = no_waste_cartridge; + } return ret; } @@ -911,6 +995,7 @@ U8 RdWaste2() U8 SetValve(bool value) { bool ret = notOK; + WHS_info.WHS_valve = value; ret = SetValveDirection( ); return ret; } -- cgit v1.3.1