diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-11-02 13:13:03 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-11-02 13:13:03 +0200 |
| commit | 2bfca4fac0ca1b3d489d20ce7c4799e05876ecb5 (patch) | |
| tree | 1dd9b88877101f62d9222cd6e6706c17ffe10cd9 /Software | |
| parent | 78e42a1f21ce22e895a82628354aba64a0a2d66a (diff) | |
| parent | f83a99d14efab540c664a4bed826caf213e7074d (diff) | |
| download | Tango-2bfca4fac0ca1b3d489d20ce7c4799e05876ecb5.tar.gz Tango-2bfca4fac0ca1b3d489d20ce7c4799e05876ecb5.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software')
61 files changed, 896 insertions, 564 deletions
diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index 56888b742..b59194af6 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -50,7 +50,7 @@ FIL *UploadFileHandle = 0; //the system supports a single active file FIL *DownloadFileHandle = 0; //the system supports a single active file char FileHandleChar[5]; char ErrorMsg[100]; -#define MAX_CHUNK_LENGTH 5500 +#define MAX_CHUNK_LENGTH 4096 int32_t FileLength = 0; int32_t FileReceivedLength = 0; int32_t FileSentLength = 0; @@ -662,15 +662,6 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) FRESULT Fresult = FR_OK; FileInfo **FilesInfo = (FileInfo**)my_malloc(sizeof(FileInfo *)*(MAX_NUM_OF_FILES)); FileInfo Data[MAX_NUM_OF_FILES]; - /* - time_t t; - struct tm *ltm; - char *curTime; - t = time(NULL); - ltm = localtime(&t); - curTime = asctime(ltm); - Report(curTime, __FILE__, ltm->tm_hour,ltm->tm_min , RpWarning, ltm->tm_sec, 0); - */ if (1)//(Semaphore_pend(FFS_Sem, BIOS_NO_WAIT)) { @@ -727,14 +718,6 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) Data[i].lastmodifieddate = fno[i]->fdate; Data[i].has_lastmodifiedtime = true; Data[i].lastmodifiedtime = fno[i]->ftime; - /* - t = (fno[i]->fdate<<16)+fno[i]->ftime; - ltm = localtime(&t); - curTime = asctime(ltm); - usnprintf(&Datestr, 100, "File info %s %s",fno[i]->fname, curTime); - Report(Datestr, __FILE__, __LINE__, t, RpWarning, (int)Data[i].lastmodifiedtime, 0); - Task_sleep(50); - */ if (i==0) usnprintf(&FullPath[i], 50, "%s", request->path); diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c index dbbe47ddb..2d39d25ec 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c @@ -165,6 +165,8 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) usnprintf(FullPath, 50, "%s%s%s", request->path,"/", VersionPackage->filedescriptors[File_i]->filename); FFresult = f_unlink("//SYSINFO//EMBPARAM.CFG"); FFresult |= f_rename (FullPath, "//SYSINFO//EMBPARAM.CFG"); + FlashInit(); + Reboot = true; LoadConfigurationParamsFromFile(true); Report("ConfigParams",__FILE__,FFresult,(int)NumberOfFiles,RpWarning,CurrentRunningFile,0); CurrentRunningFile++; @@ -173,7 +175,9 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) usnprintf(FullPath, 50, "%s%s%s", request->path,"/", VersionPackage->filedescriptors[File_i]->filename); FFresult = f_unlink("//SYSINFO//PROCESSP.CFG"); FFresult |= f_rename (FullPath, "//SYSINFO//PROCESSP.CFG"); - LoadProcessParamsFromFile(); + //LoadProcessParamsFromFile(); + FlashInit(); + Reboot = true; Report("ProcessParams",__FILE__,FFresult,(int)NumberOfFiles,RpWarning,CurrentRunningFile,0); CurrentRunningFile++; break; 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 585170666..9f5a27eeb 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,5,0,3}; +TangoVersion_t _gTangoVersion = {1,5,1,2}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; diff --git a/Software/Embedded_SW/Embedded/Common/report/reportInit.c b/Software/Embedded_SW/Embedded/Common/report/reportInit.c index 8890fa8b9..18ad17bee 100644 --- a/Software/Embedded_SW/Embedded/Common/report/reportInit.c +++ b/Software/Embedded_SW/Embedded/Common/report/reportInit.c @@ -109,6 +109,10 @@ uint32_t OpenLogFile(void) uint32_t CloseLogFile(void) { /* perform default error output */ + int len; + uint32_t Bytes = 0; + len = usnprintf(RepMessage, 80, "Closing Log File %s %s",__DATE__, __TIME__); + LogFresult = f_write(LogFileHandle,RepMessage,len,&Bytes ); LogFresult = f_close(LogFileHandle); LogFileHandle = NULL; return LogFresult; @@ -329,6 +333,8 @@ uint32_t ReportInitMessage(MessageContainer* requestContainer) // ReportInitParams InitParams; StartDebugLogRequest* request = start_debug_log_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); + Report("==============Saving file=================", __FILE__, __LINE__, _gTangoVersion.m_patch, RpWarning, _gTangoVersion.m_build, 0); + Task_sleep (100); ustrncpy (protobufToken, requestContainer->token,36); if (LogFileHandle != NULL) f_sync(LogFileHandle); diff --git a/Software/Embedded_SW/Embedded/Communication/Connection.c b/Software/Embedded_SW/Embedded/Communication/Connection.c index 0e90e5dbf..4bde97d46 100644 --- a/Software/Embedded_SW/Embedded/Communication/Connection.c +++ b/Software/Embedded_SW/Embedded/Communication/Connection.c @@ -139,7 +139,7 @@ void DisconnectionRequest(MessageContainer* requestContainer) int KeepAliveOneSecondCounter = 0; #define KEEPALIVE_COMMUNICATION_ABORT_LIMIT 10 bool KeepAliveActive = false; -bool keepalivetest = true; +bool keepalivetest = false; void KeepAliveRequestFunc(MessageContainer* requestContainer) { MessageContainer responseContainer; @@ -147,8 +147,6 @@ void KeepAliveRequestFunc(MessageContainer* requestContainer) //KeepAliveRequest* request = keep_alive_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); KeepAliveResponse response = KEEP_ALIVE_RESPONSE__INIT; - if (keepalivetest == false) - KeepAliveOneSecondCounter = 0; KeepAliveActive = true; responseContainer = createContainer(MESSAGE_TYPE__KeepAliveResponse, requestContainer->token, true, &response, &keep_alive_response__pack, &keep_alive_response__get_packed_size); //------------------------------------------------------------------------------------------- @@ -186,8 +184,9 @@ void KeepAliveRequest1Second(void) KARequestId++; //Report("keepalive request sent",__FILE__,__LINE__,KARequestId,RpWarning,msec_millisecondCounter, 0); - if (keepalivetest == false) - KeepAliveOneSecondCounter = 0; + if (keepalivetest == true) + return; + // KeepAliveOneSecondCounter = 0; //KeepAliveActive = true; responseContainer = createContainer(MESSAGE_TYPE__KeepAliveRequest, KARequestToken, true, &request, &keep_alive_request__pack, &keep_alive_request__get_packed_size); //------------------------------------------------------------------------------------------- @@ -199,6 +198,8 @@ void KeepAliveOneSecondCall(void) { if (FileUploadGetState()==false) return; + if (FileAnalysisGetState()==true) + return; KeepAliveRequest1Second(); if (KeepAliveActive == false) return; @@ -219,7 +220,7 @@ void KeepAliveOneSecondCall(void) JobStopReporting(); AlarmHandlingStop(); CommunicationMailboxFlush(); - //keepalivetest = false; + keepalivetest = false; //USBCDCD_init(); USBCDCD_Reinit(); //UART_ResetBuffers(); diff --git a/Software/Embedded_SW/Embedded/Communication/Container.c b/Software/Embedded_SW/Embedded/Communication/Container.c index d12d70aa2..221463d07 100644 --- a/Software/Embedded_SW/Embedded/Communication/Container.c +++ b/Software/Embedded_SW/Embedded/Communication/Container.c @@ -148,10 +148,11 @@ void receive_callback(char* buffer, size_t length) ReportWithPackageFilter(CommFilter,"Message received", __FILE__,__LINE__,requestContainer->type, RpMessage,length, 0); } #endif - if (requestContainer->type != MESSAGE_TYPE__KeepAliveRequest) + if ((requestContainer->type != MESSAGE_TYPE__KeepAliveRequest)||(requestContainer->type != MESSAGE_TYPE__KeepAliveResponse)) resetIdleCounter(); //ReportWithPackageFilter(CommFilter,"Message received", __FILE__,__LINE__,requestContainer->type, RpMessage,length, 0); - KeepAliveOneSecondCounter = 0; + if (keepalivetest == false) + KeepAliveOneSecondCounter = 0; /*msgId[RxIndex] = requestContainer->type; Length[RxIndex] = length; DataLength[RxIndex] = msec_millisecondCounter; diff --git a/Software/Embedded_SW/Embedded/DataDef.h b/Software/Embedded_SW/Embedded/DataDef.h index e87d406c8..fa3feb5cb 100644 --- a/Software/Embedded_SW/Embedded/DataDef.h +++ b/Software/Embedded_SW/Embedded/DataDef.h @@ -43,7 +43,6 @@ extern bool Special_Dispensers; //#define Use_WHS_Card //for real card only #define USE_OLD_HEAD_EEPROM -//#define USE_SHINKO_AUTO_COMM //Temporary //#define USE_RFID //#define USE_VOC_BUZZER_ALARM diff --git a/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC.c b/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC.c index 627ad45b9..f9092c889 100644 --- a/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC.c +++ b/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC.c @@ -430,14 +430,14 @@ void ADCAcquireStop(void) double VPressure_0 = 0; double A_offset =-2.429, B_slope_coefficient = 0.267;//A - offset, B - slope coefficient -double Calculate_Pitot_Pressure(bool flow ) // WHS - AN_AIRPRESS_1 +/*double Calculate_Pitot_Pressure(bool flow ) // WHS - AN_AIRPRESS_1 { //MPXV7002 (NXP) uint32_t VsampleInBits; - double Pressure = 0.0, temp, /*PKpa,PBar,*/VADC = 0.0 ,VSensor/*,PMicroBar*/; + double Pressure = 0.0, temp, /`*PKpa,PBar,*`/VADC = 0.0 ,VSensor/`*,PMicroBar*`/; VsampleInBits = ADC_GetReading(ADC_AIR_PRESSURE_1); @@ -465,18 +465,18 @@ double Calculate_Pitot_Pressure(bool flow ) // WHS - AN_AIRPRESS_1 { Pressure = A_offset + B_slope_coefficient * (sqrt(VSensor - VPressure_0)); - /* + /`* PKpa = 5 * VSensor; // ---- P[Kpa] -> BAR ---- PBar = PKpa / 100.0; PMicroBar = PBar/1000; - Pressure = PMicroBar;*/ + Pressure = PMicroBar;*`/ return Pressure; } -} +}*/ uint32_t Read_Dryer_Heaters_Current(HEATERS_CURRENT Heater_ID) // { diff --git a/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC.h b/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC.h index d7efd45d4..0dc1523fa 100644 --- a/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC.h +++ b/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC.h @@ -60,8 +60,8 @@ void ADCAcquireStop(void); void ADC0SS0Handler(void); -double Calculate_Pitot_Pressure(bool flow ) ; -uint8_t Calculate_Gas_Power_Consumption(); +//double Calculate_Pitot_Pressure(bool flow ) ; +//uint8_t Calculate_Gas_Power_Consumption(); uint32_t Read_Dryer_Heaters_Current(HEATERS_CURRENT Heater_ID); void CheckAcInputVoltage(); diff --git a/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC_VOC_Sensor.c b/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC_VOC_Sensor.c index e6a20904e..ea2f5a050 100644 --- a/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC_VOC_Sensor.c +++ b/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC_VOC_Sensor.c @@ -31,9 +31,9 @@ void VOCAlarmsInit(void) memset(Gas_PPM,0,sizeof(Gas_PPM)); } -void CalculateVOCAlarms(void) +/*void CalculateVOCAlarms(void) { - int i,slope1=0,/*slope2=0,*/slopeindex=0; + int i,slope1=0,/`*slope2=0,*`/slopeindex=0; double a; bool alarmstate = false; for (i = 0; i< MAX_VOC_SAMPLES; i++) @@ -46,13 +46,13 @@ void CalculateVOCAlarms(void) if ((slope1>0)&&(slope1 > VOC_Slope)) { slopeindex++; - if (slopeindex>=VOC_Slope_Time) + /`*if (slopeindex>=VOC_Slope_Time) { AlarmHandlingSetAlarm(EVENT_TYPE__VOC_SENSOR_ALARM_SLOPE,true); Report("CalculateVOCAlarms slope on",__FILE__,__LINE__,(int)slope1,RpWarning,slopeindex,0); alarmstate = true; VOC_SlopeAlarm = true; - } + }*`/ } else { @@ -67,7 +67,7 @@ void CalculateVOCAlarms(void) AlarmHandlingSetAlarm(EVENT_TYPE__VOC_SENSOR_ALARM_SLOPE,false); } - if (a/MAX_VOC_SAMPLES > VOC_AverageLimit) + /`*if (a/MAX_VOC_SAMPLES > VOC_AverageLimit) { AlarmHandlingSetAlarm(EVENT_TYPE__VOC_SENSOR_ALARM_TIME,true); Report("CalculateVOCAlarms time on",__FILE__,__LINE__,(int)a,RpWarning,VOC_AverageLimit,0); @@ -75,7 +75,7 @@ void CalculateVOCAlarms(void) else if (VOC_TimeAlarm == true) { AlarmHandlingSetAlarm(EVENT_TYPE__VOC_SENSOR_ALARM_TIME,false); - } + }*`/ } @@ -84,14 +84,14 @@ uint8_t Calculate_Gas_Power_Consumption() // WHS // TGS 2602 (FIGARO) -/* Concentrtion Sensor +/`* Concentrtion Sensor [ppm] [v] 0 0.353 18 0.438 33 2.919 100 4.196 316 4.571 -*/ +*`/ double VOC_Vsensor[] = { @@ -182,3 +182,4 @@ uint8_t Calculate_Gas_Power_Consumption() // WHS return 0xFF;//out of scale } +*/ diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c index 9d20d37a4..dbd6bbb60 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c @@ -166,8 +166,7 @@ void Read_Motors_Driver_ADC(void) } else { - ReportWithPackageFilter(GeneralFilter,"the motor's combined driver adc",__FILE__,__LINE__,i,RpMessage,MotorDriverResponse[i].ADC,0); - + //ReportWithPackageFilter(GeneralFilter,"the motor's combined driver adc",__FILE__,__LINE__,i,RpMessage,MotorDriverResponse[i].ADC,0); } } @@ -192,9 +191,7 @@ void Read_Motors_Driver_ADC(void) { FPGA_Get_Res(i); MotorDriverResponse[i].ADC = Fpga_Spi[i].RX_MISO; - LOG_ERROR (i, "the motor's driver type"); - ReportWithPackageFilter(GeneralFilter,"the motor's driver adc",__FILE__,__LINE__,i,RpMessage,MotorDriverResponse[i].ADC,0); - + //ReportWithPackageFilter(GeneralFilter,"the motor's driver adc",__FILE__,__LINE__,i,RpMessage,MotorDriverResponse[i].ADC,0); } } } @@ -255,7 +252,8 @@ uint32_t Read_Motors_Driver_Type(TimerMotors_t i) { //UnKnownMotDriver MotorDriverResponse[i].DriverType = UnKnownMotDriver; - ReportWithPackageFilter(GeneralFilter,"Unable to recognize the motor's driver type",__FILE__,__LINE__,i,RpMessage,MotorDriverResponse[i].ADC,0); + if (isMotorConfigured(i)) + ReportWithPackageFilter(GeneralFilter,"Unable to recognize the motor's driver type",__FILE__,__LINE__,i,RpMessage,MotorDriverResponse[i].ADC,0); status = ERROR; } } @@ -491,6 +489,8 @@ void FPGA_SetMotorsInit() { uint8_t i=0; + MotorConfiguredTimeout = 100; + //since powerstep in stby on powerup) F1_Moto_Driver_NSTBYRST1 = 0xFFFF; F1_Moto_Driver_NSTBYRST2 = 0xFFFF; diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.c index ce462876b..ea804fc04 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.c @@ -84,6 +84,7 @@ typedef enum WHS_SET_CLEAN_AIR, WHS_I2C_EEPROM_WRITE, WHS_I2C_EEPROM_READ, + WHS_I2C_RS485_DIRECTION_INIT, WHS_I2C_RS485_DIRECTION, WHS_stop }I2C_ReadingMessages; @@ -621,6 +622,16 @@ void Trigger_RS485_Direction(bool TX_OR_RX) return; } +void Trigger_RS485_Direction_Init() +{ + I2C_ReadingMessageStruc I2C_ReadingMessage; + + I2C_ReadingMessage.messageId = WHS_I2C_RS485_DIRECTION_INIT; + if (I2C_ReadingMsgQ != NULL) + Mailbox_post(I2C_ReadingMsgQ , &I2C_ReadingMessage, BIOS_NO_WAIT); + return; +} + void I2C_ReadingTask(UArg arg0, UArg arg1); void I2C_ReadingTask_Init(void) { @@ -837,6 +848,9 @@ void I2C_ReadingTask(UArg arg0, UArg arg1) case WHS_I2C_EEPROM_READ: // WHS_I2C_EEprom_Read(I2C_ReadingMessage.parameter, I2C_ReadingMessage.parameter2, I2C_ReadingMessage.parameter3); break; + case WHS_I2C_RS485_DIRECTION_INIT: + WHS_IO_RS485_Init(); + break; case WHS_I2C_RS485_DIRECTION: RS485_Change_Direction(I2C_ReadingMessage.parameter); break; diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.h index 7aab3b448..387a8f692 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.h +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.h @@ -18,6 +18,9 @@ void Trigger_WHS_MAX11614_Init(void); void Trigger_WHS_Rheostat_init(void); void Trigger_WHS_I2C_EEprom_Write(uint32_t address, uint16_t size, uint8_t *p_data); void Trigger_WHS_I2C_EEprom_Read(uint32_t address, uint16_t size, uint8_t *p_data); +void Trigger_RS485_Direction_Init(); +void Trigger_RS485_Direction(bool TX_OR_RX); + void Trigger_SetWHSFanSpeed (uint8_t fan_id, uint8_t speed); void Trigger_ReadWHSFanTacho (uint8_t fan_id); //todo diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_AD5272_Rheostat/WHS_Rheostat.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_AD5272_Rheostat/WHS_Rheostat.c index 47850cca4..ed5f5acde 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_AD5272_Rheostat/WHS_Rheostat.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_AD5272_Rheostat/WHS_Rheostat.c @@ -22,10 +22,10 @@ //uint8_t AD5272_Read_Buf[16] = {0}; AD5272 U40_AD5272; -#define VOCTable_MaxLine 26 + #define VOCTable_MaxColumn 2 -double VOCLookUpTable[VOCTable_MaxLine][VOCTable_MaxColumn] = +double VOCLookUpTable[][VOCTable_MaxColumn] = { //Based on VOC "sensor ppm calculation.xlsx" (see email "VOC sensor operational") // VOC[mV] PPM @@ -45,18 +45,11 @@ double VOCLookUpTable[VOCTable_MaxLine][VOCTable_MaxColumn] = 3800.0, 9.578252369 , 3900.0, 11.95664548 , 4000.0, 14.65340625 , - 4100.0, 17.6492742 , - 4200.0, 20.92324879 , - 4300.0, 24.45355263 , - 4400.0, 28.21831574 , - 4500.0, 32.1960535 , - 4600.0, 36.36599236 , - 4700.0, 40.70828334 , - 4800.0, 45.20413325 , - 4900.0, 49.83587589 , - 5000.0, 54.587 , + 4095.0, 17.49948080 ,//Max - 12 Bit 4095bit is 4.095mV }; +#define VOCTable_MaxLine (sizeof(VOCLookUpTable)/2/sizeof(double)) + bool WHS_WriteRdac(uint16_t value) { bool status= OK; diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_Max5805_ADC_Blower/WHS_Blower.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_Max5805_ADC_Blower/WHS_Blower.c index ce6b34dd9..43b636f7a 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_Max5805_ADC_Blower/WHS_Blower.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/D_Max5805_ADC_Blower/WHS_Blower.c @@ -439,9 +439,11 @@ void SendLimitedBlowerControl(int mV) if (JobIsActive()) { JobEndReason = JOB_SAFETY_CRITICAL_ALARM; + usnprintf(AlarmReasonStr, 100, "Waste airflow Error %d",mV); SendJobProgress(0.0,0,false, "Waste airflow Error"); AbortJob("Waste airflow Error"); //SegmentReady(Module_Heaters,ModuleFail); + ReportWithPackageFilter(HeatersFilter, "Waste airflow Error",__FILE__,__LINE__,mV,RpError, 0,0); HeatersEnd(); return; @@ -592,6 +594,8 @@ void WHS_Start_Blower_Control_Closed_Loop () return; //do not start before controller is initialized and running if (EnableControlLoop == false) return; //do not start loop + if (WHS_Type != WHS_TYPE_NEW) + return; //do not start loop if (count == close_loop_time) { diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.c index 5ce04aab9..3e36d3bba 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.c @@ -13,6 +13,7 @@ #include <Drivers/I2C_Communication/WHS_Card/D_EMC2302_Fan/WHS_Fan.h> #include <Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/TCA9555_Driver.h> #include <Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.h> +#include <Drivers/I2C_Communication/I2C_Task.h> WHS_I2C_EXP_U3_0x40_DIRECTION Whs_I2C_EXP_U3_0x40_DIRECTION; @@ -210,6 +211,17 @@ bool WHS_IO_Init() return status; } +bool WHS_IO_RS485_Init() +{ + bool status = OK; + + Whs_I2C_EXP_U4_0x42_DIRECTION.bits.OUTPUT_ACTLOW_DE_REn = D_TCA9555_DIR_OUTPUT; //P00 + + WHS_TCA9555Config(I2CExp2_ADDRESS);//direction + + return status; +} + bool WHS_IO_Init_HW_0() { @@ -717,12 +729,12 @@ uint8_t RS485_Change_Direction(bool TX_OR_RX)//TX or RX - trigger i2c task uint8_t RS485_Direction(bool TX_OR_RX)//TX or RX { - if(TX_OR_RX == TX) +/* if(TX_OR_RX == TX) Write_WHS_9555_io_value(I2CExp2_ADDRESS, D_TCA9555_PORT_0, 0, true); else Write_WHS_9555_io_value(I2CExp2_ADDRESS, D_TCA9555_PORT_0, 0, false); - - //RS485_Change_Direction(TX_OR_RX); +*/ + Trigger_RS485_Direction(TX_OR_RX); return OK; diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.h index e017bb14a..155e5f2aa 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.h +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.h @@ -1,5 +1,5 @@ /* - * WHD_IO.h + * WHS_IO.h * * Created on: Jun 30, 2019 * Author: Shai @@ -164,6 +164,7 @@ extern WHS_I2C_EXP_U4_0x42_VALUE Whs_I2C_EXP_U4_0x42_VALUE; bool WHS_IO_Init(); +bool WHS_IO_RS485_Init(); bool WHS_TCA9555Config(uint8_t TCA9555_ADDRESS); bool Write_WHS_9555_io_value(uint8_t addr, uint8_t port, uint8_t pin, bool value); bool WHS_Write_IO_AllReg(uint8_t TCA9555_ADDRESS); diff --git a/Software/Embedded_SW/Embedded/Drivers/RFID/RFID_Task.c b/Software/Embedded_SW/Embedded/Drivers/RFID/RFID_Task.c new file mode 100644 index 000000000..f5101d9e7 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Drivers/RFID/RFID_Task.c @@ -0,0 +1,45 @@ +/* + * RFID_Task.c + * + * Created on: Oct 23, 2019 + * Author: shlomo + */ + +#include <stdint.h> +#include <stdbool.h> +#include "include.h" +#include "inc/hw_memmap.h" + +#include <Drivers/RFID/RFID_Task.h> +Task_Handle RFID_Task_Handle; +Mailbox_Handle RFID_ReadingMsgQ = NULL; +typedef enum +{ + RFID_Initialization, +}RFID_ReadingMessages; + +typedef struct RFID_ReadingMessage{ + RFID_ReadingMessages messageId; + PANEL_BUTTON_OR_CRAT_ID CartId; +}RFID_ReadingMessageStruc; + +void RFID_Task(UArg arg0, UArg arg1) +{ + RFID_ReadingMessageStruc RFID_ReadingMessage; + RFID_ReadingMsgQ = Mailbox_create(sizeof(RFID_ReadingMessageStruc), 10, NULL,NULL); + RFID_Task_Handle = Task_self(); +// double dbl_setpoint_Q = 0.0; + + while(1) + { + Mailbox_pend(RFID_ReadingMsgQ , &RFID_ReadingMessage, BIOS_WAIT_FOREVER); + + switch (RFID_ReadingMessage.messageId) + { + case RFID_Initialization: + break; + default: + break; + } + } +} diff --git a/Software/Embedded_SW/Embedded/Drivers/RFID/RFID_Task.h b/Software/Embedded_SW/Embedded/Drivers/RFID/RFID_Task.h new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Software/Embedded_SW/Embedded/Drivers/RFID/RFID_Task.h diff --git a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c index 8b4445146..b448a9801 100644 --- a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c +++ b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c @@ -55,6 +55,7 @@ typedef uint32_t USBCDCDEventType; #define eUSBModeForceDevice USB_MODE_FORCE_DEVICE typedef unsigned long USBCDCDEventType; #endif +unsigned int gateUSBWaitkey,gateRxSerialkey; /* Defines */ //**************************************************************************** @@ -351,6 +352,7 @@ tUSBDCompositeDevice g_sCompDevice = // 8 /* 8 Bits of data. */ //}; +bool USB_Reinit = false; //***************************************************************************** // @@ -904,15 +906,19 @@ void USBCDCD_init(void) //----------------------------------------------------------- void USBCDCD_Reinit(void) { + USB_Reinit = true; + USBDCompositeTerm(USBDComposite); - USBDCDCTerm(USBDComposite); /* State specific variables */ state = USBCDCD_STATE_UNCONFIGURED; + if (gateRxSerialkey) + GateMutex_leave(gateRxSerial, gateRxSerialkey); + if (gateUSBWaitkey) + GateMutex_leave(gateUSBWait, gateUSBWaitkey); /* Set the USB stack mode to Device mode with VBUS monitoring */ //USBStackModeSet(0, eUSBModeForceDevice, 0); HWREGBITW(&g_ui32Flags, FLAG_USB_CONFIGURED) = 0; - //TODO: Notify disconnection! USBDisc++; // @@ -920,16 +926,15 @@ void USBCDCD_Reinit(void) // HWREGBITW(&g_ui32Flags, FLAG_STATUS_UPDATE) = 1; - USBBufferFlush(&txBuffer); - USBBufferFlush(&rxBuffer); - //USBBufferInit(&txBuffer); - //USBBufferInit(&rxBuffer); + USBBufferInit(&txBuffer); + USBBufferInit(&rxBuffer); - USBDComposite = USBDCDCInit(0, &g_sCDCDevice); + USBDComposite = USBDCompositeInit(0, &g_sCompDevice, DESCRIPTOR_BUFFER_SIZE, g_pui8DescriptorBuffer); if (!USBDComposite) { - System_abort("Error initializing the serial device"); + System_abort("Error initializing the composite device"); } + USB_Reinit = false; } //----------------------------------------------------------- @@ -942,7 +947,6 @@ unsigned int USBCDCD_receiveData(unsigned char *_pBuff, unsigned int _timeout) { unsigned int retValue = 0; - unsigned int key; switch (state) { @@ -954,7 +958,7 @@ unsigned int USBCDCD_receiveData(unsigned char *_pBuff, case USBCDCD_STATE_INIT: { /* Acquire lock */ - key = GateMutex_enter(gateRxSerial); + gateRxSerialkey = GateMutex_enter(gateRxSerial); state = USBCDCD_STATE_IDLE; @@ -962,18 +966,18 @@ unsigned int USBCDCD_receiveData(unsigned char *_pBuff, //retValue = rxData(_pBuff, _length, _timeout); /* Release lock */ - GateMutex_leave(gateRxSerial, key); + GateMutex_leave(gateRxSerial, gateRxSerialkey); break; } case USBCDCD_STATE_IDLE: { /* Acquire lock */ - key = GateMutex_enter(gateRxSerial); + gateRxSerialkey = GateMutex_enter(gateRxSerial); handleRx(); //retValue = rxData(_pBuff, _length, _timeout); /* Release lock */ - GateMutex_leave(gateRxSerial, key); + GateMutex_leave(gateRxSerial, gateRxSerialkey); break; } default: @@ -997,6 +1001,8 @@ unsigned int USBCDCD_sendData(const unsigned char *_pBuff, size[1] = (_length>>8) & 0xFF; size[0] = _length & 0xFF; + if (USB_Reinit ==true) + return OK; len = USBBufferWrite((tUSBBuffer *)&txBuffer, size, 4); /*if (len == 0) { @@ -1013,10 +1019,9 @@ unsigned int USBCDCD_sendData(const unsigned char *_pBuff, bool USBCDCD_waitForConnect(unsigned int _timeout) { bool ret = true; - unsigned int key; // Need exclusive access to prevent a race condition - key = GateMutex_enter(gateUSBWait); + gateUSBWaitkey = GateMutex_enter(gateUSBWait); if (state == USBCDCD_STATE_UNCONFIGURED) { @@ -1026,7 +1031,7 @@ bool USBCDCD_waitForConnect(unsigned int _timeout) } } - GateMutex_leave(gateUSBWait, key); + GateMutex_leave(gateUSBWait, gateUSBWaitkey); return (ret); } diff --git a/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/WHS_Controller_Comm/WHS_UART/WHS_Uart.c b/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/WHS_Controller_Comm/WHS_UART/WHS_Uart.c index ebefafbdd..36bef086d 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/WHS_Controller_Comm/WHS_UART/WHS_Uart.c +++ b/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/WHS_Controller_Comm/WHS_UART/WHS_Uart.c @@ -25,13 +25,14 @@ #include "drivers/Uart_Comm/WHS_Controller_Comm/WHS_UART/WHS_Uart.h" #include "Modules/Control/MillisecTask.h" #include <DataDef.h> +#include <Drivers/I2C_Communication/I2C_Task.h> //uint8_t Uart3_Tx_Buff[100]; //uint8_t Uart3_Rx_Buff[100]; -void InitConsole_WHS_UART3(void) +void InitConsole_WHS_UART3(int32_t ui32SysClock) { - uint32_t ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), SYS_CLK_FREQ); + //uint32_t ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), SYS_CLK_FREQ); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3); // @@ -78,17 +79,17 @@ void InitConsole_WHS_UART3(void) //ROM_UARTConfigSetExpClk(UART3_BASE,ROM_SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8| UART_CONFIG_STOP_ONE |UART_CONFIG_PAR_NONE)); //MAP_UARTConfigSetExpClk(UART3_BASE, ui32SysClock, 9600,(UART_CONFIG_WLEN_8 |UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); MAP_UARTConfigSetExpClk(UART3_BASE, ui32SysClock, 9600,(UART_CONFIG_WLEN_7 |UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_EVEN));//Shinko protocol - - - } +int Uart3TransmitResult = 0; uint8_t Uart3_Transmit(uint8_t * Uart3_Tx_Buff, uint32_t Length) { uint8_t i,Status = OK; + Uart3TransmitResult = 0; + uint8_t temp_buf[Size_Shinko_Req]; for(i = 1;i < Length;i++) //swap the order to switch endianness - need to send the LSB first @@ -100,7 +101,7 @@ uint8_t Uart3_Transmit(uint8_t * Uart3_Tx_Buff, uint32_t Length) for(i=0;i<Length-1;i++) { - ROM_UARTCharPut/*NonBlocking*/(UART3_BASE,temp_buf[i]);//send data + Uart3TransmitResult |=ROM_UARTCharPutNonBlocking(UART3_BASE,temp_buf[i]);//send data } return Status; @@ -112,16 +113,23 @@ uint8_t Uart3_Receive(uint8_t * Uart3_Rx_Buff, uint32_t RX_Length) uint8_t temp_buf[Size_Shinko_Res]; - for(i=0;i<RX_Length;i++) + if(Uart3TransmitResult != 0) { - temp_buf[i] = ROM_UARTCharGet/*NonBlocking*/(UART3_BASE);//Receive data - if ((i == 0) && (temp_buf[0] == 0) )// There isn't communication / The controller is not connected - Shinko_Header_Asccii_ACK = 0x06 + for(i=0;i<RX_Length;i++) { - #warning Add error / block communication - Status = ERROR; - break; + temp_buf[i] = ROM_UARTCharGet/*NonBlocking*/(UART3_BASE);//Receive data + if ((i == 0) && (temp_buf[0] == 0) )// There isn't communication / The controller is not connected - Shinko_Header_Asccii_ACK = 0x06 + { + Status = ERROR; + break; + } } } + else + { + Status = ERROR; + } + if(Status == OK) { @@ -131,6 +139,10 @@ uint8_t Uart3_Receive(uint8_t * Uart3_Rx_Buff, uint32_t RX_Length) Uart3_Rx_Buff[Size_Shinko_Res -1 -i] = temp_buf[i]; } } + else + { + ReportWithPackageFilter(HeatersFilter,"Shinko communication error ",__FILE__,__LINE__,Uart3TransmitResult,RpError, 0,0); + } return Status; } @@ -171,29 +183,30 @@ float Test_Uart3(uint8_t test_number) switch(test_number) { case 0: //---------------------------------- test Shinko ----------------------- - WHS_IO_Init();// Done in HWConfigurationInit - delayms(1); - InitConsole_WHS_UART3();// Done in HWConfigurationInit + //WHS_IO_Init();// Done in HWConfigurationInit + WHS_IO_RS485_Init(); delayms(1); + //InitConsole_WHS_UART3();// Done in HWConfigurationInit + //delayms(1); break; case 1: //---------------------------------- Shinko reading temperature ----------------------- //Read_value RS485_Direction(TX); - delayms(1); + Task_sleep (eOneMillisecond*1);//delayms(1); Reading_Shinko_Request_PV(); - delayms(15); + Task_sleep (eOneMillisecond*15);//delayms(15); RS485_Direction(RX); - delayms(5); + Task_sleep (eOneMillisecond*5);//delayms(5); RetVal=Reading_Shinko_Response_PV(); break; case 2: //---------------------------------- test Shinko ----------------------- //Read_Setup RS485_Direction(TX);//done in MilisecTask - delayms(1); + Task_sleep (eOneMillisecond*1);//delayms(1); Reading_Shinko_Request_SV();//done in MilisecTask - delayms(15); + Task_sleep (eOneMillisecond*15);//delayms(15); RS485_Direction(RX);//done in MilisecTask - delayms(5); + Task_sleep (eOneMillisecond*5);//delayms(5); RetVal=Reading_Shinko_Response_SV();//done in MilisecTask break; case 3: //---------------------------------- test Shinko ----------------------- @@ -279,86 +292,44 @@ unsigned short Calculate_CRC16 ( int Message_Length, char *Message) // for modbu } */ -typedef enum -{ - Stage_0 = 5, //to start after few sec from power up - Stage_1 = Stage_0 + 1, - Stage_2 = Stage_1 + 15, - Stage_3 = Stage_2 + 5, -}SHINKO_RW_STAGES_ENUM; +uint8_t Shinko_Read_Satage = 0, Shinko_first_read = 0;//public -uint8_t WHS_Shinko_Communication(SHINKO_RW_OPTIONS_ENUM RWOption) //reading every fourth cycle (Set HW, Request, Set HW, Response) +void Shinko_Cycle_Comm() { - //every 10sec start cycle of reading temperature and if there is request R/W the setup - uint8_t Status = OK; - static SHINKO_RW_STAGES_ENUM Shinko_Comm_Stage = 0; - static uint8_t Option = 0; - - switch(Shinko_Comm_Stage) + if (WHS_Type == WHS_TYPE_NEW) { - case Stage_0: - RS485_Direction(TX);//Set HW for TX - Option = RWOption;//change the read write option only in stage 0 ! (finish cycle with the same option) - Report("WHS_Shinko_Communication ", __FILE__,__LINE__,RWOption, RpMessage, Shinko_Comm_Stage, 0); - Shinko_Comm_Stage++; - break; - case Stage_1: - if(Option == R_SETUP) - { - Reading_Shinko_Request_SV();//Send Command - } - else - if(Option == R_Value) - { - Reading_Shinko_Request_PV();//Send Command - } - else - if((Option == W_SETUP) && (ShinkoTempDeg.Setup!= 0x00)) - { - Setting_Shinko_Request_SV();//Send Command - Shinko_Read = true;//flag to read the setup in the next cycle - } - Report("WHS_Shinko_Communication ", __FILE__,__LINE__,RWOption, RpMessage, Shinko_Comm_Stage, 0); - Shinko_Comm_Stage++; - break; - case Stage_2: - RS485_Direction(RX);//Set HW for RX - Report("WHS_Shinko_Communication ", __FILE__,__LINE__,RWOption, RpMessage, Shinko_Comm_Stage, 0); - Shinko_Comm_Stage++; - break; - case Stage_3: - if(Option == R_SETUP) - { - Status|=Reading_Shinko_Response_SV();//Get Response - } - else - if(Option == R_Value) - { - Status|=Reading_Shinko_Response_PV();//Get Response - } - else - if((Option == W_SETUP) && (ShinkoTempDeg.Setup!= 0x00)) - { - Status|=Setting_Shinko_Response_SV();//Get Response - } - else - { - Status = ERROR; - } + if ((Shinko_Read_Satage == 0) || (Shinko_first_read == 0)) + { + //Read_value + Trigger_RS485_Direction(TX); + Task_sleep (eOneMillisecond*1);//delayms(1); + Reading_Shinko_Request_PV(); + Task_sleep (eOneMillisecond*15);//delayms(15); + Trigger_RS485_Direction(RX); + Task_sleep (eOneMillisecond*5);//delayms(5); + Reading_Shinko_Response_PV(); - Report("WHS_Shinko_Communication ", __FILE__,__LINE__,RWOption, RpMessage, Shinko_Comm_Stage, 0); - Shinko_Comm_Stage = Stage_0; - if(Option == RWOption) - { - Shinko_Read = false; - } - break; - default: - //Shinko_Comm_Stage = Stage_0; - //Shinko_Read = false; - Shinko_Comm_Stage++; - break; - } + Shinko_Read_Satage = 1; + Shinko_first_read = 1; + } + else + if ((Shinko_Read_Satage == 1) || (Shinko_first_read == 1)) + { + //Read_Setup + Trigger_RS485_Direction(TX);//done in MilisecTask + Task_sleep (eOneMillisecond*1);//delayms(1); + Reading_Shinko_Request_SV();//done in MilisecTask + Task_sleep (eOneMillisecond*15);//delayms(15); + Trigger_RS485_Direction(RX);//done in MilisecTask + Task_sleep (eOneMillisecond*5);//delayms(5); + Reading_Shinko_Response_SV();//done in MilisecTask - return Status; + Shinko_Read_Satage = 0; + Shinko_first_read = 2; + } + else + { + Shinko_Read_Satage = 0; + } + } } diff --git a/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/WHS_Controller_Comm/WHS_UART/WHS_Uart.h b/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/WHS_Controller_Comm/WHS_UART/WHS_Uart.h index 0ce2259d0..9cae7f2a9 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/WHS_Controller_Comm/WHS_UART/WHS_Uart.h +++ b/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/WHS_Controller_Comm/WHS_UART/WHS_Uart.h @@ -8,19 +8,14 @@ #ifndef DRIVERS_UART_COMM_WHS_UART_WHS_UART_H_ #define DRIVERS_UART_COMM_WHS_UART_WHS_UART_H_ -typedef enum -{ - R_Value, - R_SETUP, - W_SETUP -}SHINKO_RW_OPTIONS_ENUM; - uint8_t Uart3_Transmit(uint8_t * Uart3_Tx_Buff, uint32_t Length); uint8_t Uart3_Receive(uint8_t * Uart3_Rx_Buff, uint32_t RX_Length); float Test_Uart3(uint8_t test_number); -void InitConsole_WHS_UART3(void); +void InitConsole_WHS_UART3(int32_t ui32SysClock); + +extern uint8_t Shinko_Read_Satage,Shinko_first_read; +void Shinko_Cycle_Comm(); -uint8_t WHS_Shinko_Communication(SHINKO_RW_OPTIONS_ENUM RWOption); #endif /* DRIVERS_UART_COMM_WHS_UART_WHS_UART_H_ */ diff --git a/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h b/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h index 655a980db..7da9f92a7 100644 --- a/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h +++ b/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h @@ -26,6 +26,8 @@ #define FLASH_SIZE 0X8000 +extern int base_flashErased; + //***************************************************************************** // // Read application data from a buffer and program it into flash. diff --git a/Software/Embedded_SW/Embedded/Embedded.cfg b/Software/Embedded_SW/Embedded/Embedded.cfg index cf0313d5e..cce6b3440 100644 --- a/Software/Embedded_SW/Embedded/Embedded.cfg +++ b/Software/Embedded_SW/Embedded/Embedded.cfg @@ -175,6 +175,12 @@ MillisecLowTaskParams.stackSize = 4096; MillisecLowTaskParams.priority = 12; Program.global.millisecLow = Task.create("&MillisecLowTask", MillisecLowTaskParams); +var RFID_TaskParams = new Task.Params(); +RFID_TaskParams.instance.name = "RFID"; +RFID_TaskParams.stackSize = 4096; +RFID_TaskParams.priority = 11; +Program.global.millisecLow = Task.create("&RFID_Task", RFID_TaskParams); + var ADCProcessTaskParams = new Task.Params(); ADCProcessTaskParams.instance.name = "adcProcess"; ADCProcessTaskParams.stackSize = 512; diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index 1db7b8541..de91e5b99 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -40,6 +40,8 @@ #include <DataDef.h> #include "Sys_PinOut_Config/MCU_MAIN_pinout.h" #include <Drivers/I2C_Communication/I2C.h> +#include "drivers/Uart_Comm/WHS_Controller_Comm/WHS_UART/WHS_Uart.h" +#include <Drivers/I2C_Communication/WHS_Card/IO_Extender_Ports_TCA9555/WHS_IO.h> /* #include "Drivers/SPI_SDCARD/SDSPI.h" @@ -226,7 +228,6 @@ int main(void) //Set the clock 120MHz uint32_t ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), SYS_CLK_FREQ); - // Enable the system tick. ROM_SysTickPeriodSet(ui32SysClock / TICKS_PER_SECOND); ROM_SysTickIntEnable(); @@ -320,6 +321,12 @@ int main(void) Set_Speed_Sensor_TypeII_Registers(10,5);//set default values #endif + if (WHS_Type == WHS_TYPE_NEW) + { + InitConsole_WHS_UART3(ui32SysClock);//Init WHS UART Shinko RS485 Communication + Trigger_RS485_Direction_Init();//init i/o + } + //EMAC_initEMAC(); ControlInit(); diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index 968ef689b..881a02f8e 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -73,6 +73,7 @@ bool AlarmHandlingActive = false; uint32_t AlarmHandlingControlId = 0xFF; uint32_t AlarmHandlingTick = 0; +int MotorConfiguredTimeout = 100; double CurrentAlarmHighLimit ,CurrentAlarmLowLimit; bool CheckHardLimitAlarms = false,CheckCurrentAlarms = false,CheckTamperAlarms = false,CheckMotorAlarms = false; uint8_t alarm_response_buffer[500]; @@ -504,7 +505,7 @@ uint32_t AlarmHandlingLoadFile(void) if (F_count == 4) { - ReportWithPackageFilter(AlarmFilter,"Writing four alarms", __FILE__,AlarmPtr,F_count, RpMessage, p_size, 0); + //ReportWithPackageFilter(AlarmFilter,"Writing four alarms", __FILE__,AlarmPtr,F_count, RpMessage, p_size, 0); F_count = 0; ReadAppAndProgram(AlarmPtr, p_size,FileAlarmItem); AlarmPtr+=p_size; @@ -812,6 +813,12 @@ uint32_t AlarmHandlingConsequentActions(uint32_t AlarmId, DebugLogCategory Sever } return OK; } +bool FileAnalysis = false; +bool FileAnalysisGetState(void) +{ + return FileAnalysis; +} + JobEndReasonEnum AlarmHandlingPrepareJob(void *CurrentJob) { //JobTicket* JobTicket = CurrentJob; @@ -828,6 +835,7 @@ JobEndReasonEnum AlarmHandlingPrepareJob(void *CurrentJob) ACTIVITY_GREEN_LED_ON; Task_setPri(TaskHandle1, 11); + FileAnalysis = true; Task_sleep(10); Report("Task_setPri", __FILE__, pri, 3, RpWarning, (int)TaskHandle1, 0); IDS_MapDispenserUsedinJob(CurrentJob); @@ -835,6 +843,7 @@ JobEndReasonEnum AlarmHandlingPrepareJob(void *CurrentJob) Report("Task_setPri", __FILE__, __LINE__, pri, RpWarning, (int)Task_self(), 0); Task_sleep(10); ACTIVITY_GREEN_LED_OFF; + FileAnalysis = false; if (n_segments == 0) { ReportWithPackageFilter(AlarmFilter,"no segments in the job", __FILE__,__LINE__,0, DEBUG_LOG_CATEGORY__Warning, 222, 0); @@ -976,7 +985,7 @@ JobEndReasonEnum AlarmHandlingPrepareJob(void *CurrentJob) if ((IFS_Availability[1] == IFS_RECOGNIZED_INIT_PASSED)&&(IFS_Availability[2] == IFS_RECOGNIZED_INIT_PASSED)) //ifs installed -check cartridges { - tempFoundReason = Waste_Prepare(); + tempFoundReason = Waste_CheckState(&AlarmId); if (tempFoundReason!=JOB_OK) { FoundReason = tempFoundReason; @@ -1044,6 +1053,7 @@ uint32_t AlarmHandling_ControlTrigger(uint32_t IfIndex, uint32_t ReadValue) return OK; } void AlarmHandlingInternalSetAlarm(uint32_t AlarmId, bool value); +StartEventsNotificationResponse PersistentEventsResponse = START_EVENTS_NOTIFICATION_RESPONSE__INIT; void AlarmHandlingSetAlarm(uint32_t AlarmId, bool value) { @@ -1059,46 +1069,77 @@ void AlarmHandlingSetAlarm(uint32_t AlarmId, bool value) } void AlarmHandlingInternalSetAlarm(uint32_t AlarmId, bool value) { - int Alarm_i; + int Alarm_i,Event_i; + Event **re_events; if (AlarmItem == NULL) return; for (Alarm_i = 0;Alarm_i < NumOfSystemAlarms;Alarm_i++) { if (AlarmItem[Alarm_i].EventType == AlarmId) { - if (AlarmState[Alarm_i].Status != value) + if (0) // PERSISTENT ALARM { - if (value == true) + PersistentEventsResponse.n_events++; + if (PersistentEventsResponse.events == NULL) + PersistentEventsResponse.events = (Event **)my_malloc(sizeof(Event*)*PersistentEventsResponse.n_events); + else { - // no need to call consequent actionsAlarmHandlingConsequentActions(Alarm_i, AlarmItem[Alarm_i].Severity); - // report the alarm! - AlarmState[Alarm_i].EventPtr = my_malloc (sizeof(Event)); - if (AlarmState[Alarm_i].EventPtr) + re_events = (Event **)my_malloc(sizeof(Event*)*PersistentEventsResponse.n_events); + for (Event_i = 0;Event_i < (PersistentEventsResponse.n_events-1);Event_i++) { - event__init(AlarmState[Alarm_i].EventPtr); - AlarmState[Alarm_i].EventPtr->has_type = true; - AlarmState[Alarm_i].EventPtr->type = AlarmItem[Alarm_i].EventType; - AlarmState[Alarm_i].EventPtr->message = NULL;//AlarmItem[Alarm_i].EventName; - AlarmState[Alarm_i].Status = value; - } - ReportWithPackageFilter(AlarmFilter,"Alarm ON ", __FILE__,AlarmState[Alarm_i].EventPtr,AlarmItem[Alarm_i].EventType, RpMessage, value, Alarm_i); - if ((AlarmItem[Alarm_i].Severity == DEBUG_LOG_CATEGORY__Critical)&&(JobIsActive())) - { - JobEndReason = getEndReason(Alarm_i); - SendJobProgress(0.0,0, false, "Critical alarm!!!!"); - AbortJob("Critical alarm"); - ReportWithPackageFilter(AlarmFilter, AlarmReasonStr,__FILE__,__LINE__,Alarm_i,RpError, 0,0); + re_events[Event_i] = PersistentEventsResponse.events[Event_i]; } + my_free(PersistentEventsResponse.events); + PersistentEventsResponse.events = re_events; } - else + AlarmState[Alarm_i].EventPtr = my_malloc (sizeof(Event)); + if (AlarmState[Alarm_i].EventPtr) { - ReportWithPackageFilter(AlarmFilter,"Alarm OFF ", __FILE__,__LINE__,AlarmItem[Alarm_i].EventType, RpMessage, value, Alarm_i); - if (AlarmState[Alarm_i].EventPtr) + event__init(AlarmState[Alarm_i].EventPtr); + AlarmState[Alarm_i].EventPtr->has_type = true; + AlarmState[Alarm_i].EventPtr->type = AlarmItem[Alarm_i].EventType; + AlarmState[Alarm_i].EventPtr->message = NULL;//AlarmItem[Alarm_i].EventName; + } + AlarmState[Alarm_i].Status = true; + PersistentEventsResponse.events[PersistentEventsResponse.n_events] = AlarmState[Alarm_i].EventPtr; + ReportWithPackageFilter(AlarmFilter,"Persistent Alarm ", __FILE__,PersistentEventsResponse.n_events,AlarmItem[Alarm_i].EventType, RpMessage, value, Alarm_i); + } + else + { + if (AlarmState[Alarm_i].Status != value) + { + if (value == true) { - my_free(AlarmState[Alarm_i].EventPtr); - AlarmState[Alarm_i].EventPtr = NULL; + // no need to call consequent actionsAlarmHandlingConsequentActions(Alarm_i, AlarmItem[Alarm_i].Severity); + // report the alarm! + AlarmState[Alarm_i].EventPtr = my_malloc (sizeof(Event)); + if (AlarmState[Alarm_i].EventPtr) + { + event__init(AlarmState[Alarm_i].EventPtr); + AlarmState[Alarm_i].EventPtr->has_type = true; + AlarmState[Alarm_i].EventPtr->type = AlarmItem[Alarm_i].EventType; + AlarmState[Alarm_i].EventPtr->message = NULL;//AlarmItem[Alarm_i].EventName; + AlarmState[Alarm_i].Status = value; + } + ReportWithPackageFilter(AlarmFilter,"Alarm ON ", __FILE__,AlarmState[Alarm_i].EventPtr,AlarmItem[Alarm_i].EventType, RpMessage, value, Alarm_i); + if ((AlarmItem[Alarm_i].Severity == DEBUG_LOG_CATEGORY__Critical)&&(JobIsActive())) + { + JobEndReason = getEndReason(Alarm_i); + SendJobProgress(0.0,0, false, "Critical alarm!!!!"); + AbortJob("Critical alarm"); + ReportWithPackageFilter(AlarmFilter, AlarmReasonStr,__FILE__,__LINE__,Alarm_i,RpError, 0,0); + } + } + else + { + ReportWithPackageFilter(AlarmFilter,"Alarm OFF ", __FILE__,__LINE__,AlarmItem[Alarm_i].EventType, RpMessage, value, Alarm_i); + if (AlarmState[Alarm_i].EventPtr) + { + my_free(AlarmState[Alarm_i].EventPtr); + AlarmState[Alarm_i].EventPtr = NULL; + } + AlarmState[Alarm_i].Status = value; } - AlarmState[Alarm_i].Status = value; } } break; @@ -1160,6 +1201,9 @@ uint32_t AlarmHandlingLoop(uint32_t tick) if (AlarmItem == NULL) return ERROR; int AlarmCounter=0; + if (MotorConfiguredTimeout) + MotorConfiguredTimeout--; + for (Alarm_i = 0;Alarm_i < NumOfSystemAlarms;Alarm_i++) { Status = false; @@ -1336,7 +1380,7 @@ uint32_t AlarmHandlingLoop(uint32_t tick) case ALARM_SOURCE_TYPE__MotorAlarm: if (CheckMotorAlarms) { - if ((FPGA_WD_Occurred == true)||(MachineReadyForHeating == false)) + if ((FPGA_WD_Occurred == true)||(MotorConfiguredTimeout > 0)) { Status = false; } diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.h b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.h index 3b39370bf..a8dd43a17 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.h +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.h @@ -10,6 +10,8 @@ #include "StateMachines/Printing/PrintingSTM.h" #include <PMR/Diagnostics/EventType.pb-c.h> +extern int MotorConfiguredTimeout; + uint32_t AlarmHandlingFlashLoad(void); uint32_t AlarmHandlingLoadFile(void); @@ -24,6 +26,7 @@ uint32_t AlarmHandlingStop(void); void AlarmHandlingSetAlarm(uint32_t AlarmId, bool Value); JobEndReasonEnum AlarmHandlingPrepareJob(void *CurrentJob); +bool FileAnalysisGetState(void); extern char AlarmReasonStr[100]; uint32_t StartEventsNotificationRequestFunc(MessageContainer* requestContainer); diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 6ce453538..689219583 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -598,7 +598,6 @@ void setRapidPressureRead(bool value) if (GetDiagnosticMode() == Diagnostic_Extreme_Mode) RapidPressureRead = true; } -bool Shinko_Read = false; uint16_t PumpCounter = 0; uint16_t realtimetest[101]; uint32_t MillisecLowLoop(uint32_t tick) @@ -640,6 +639,7 @@ uint32_t MillisecLowLoop(uint32_t tick) //Screw_ENC_Velocity_to_DAC(); - for testing the screw enc if (Head_Type > HEAD_TYPE_FLAT_WITHOUT_CARD) StartPT100 = TEMP_SENSE_ANALOG_DRYER_TEMP1; + if (Ten_msTick) { //Speed_Data = Read_Speed_Sensor_TypeII(); @@ -738,26 +738,6 @@ uint32_t MillisecLowLoop(uint32_t tick) if (isMotorConfigured(Motor_i)) MotorGetStatusFromFPGA(Motor_i); } -#ifdef USE_SHINKO_AUTO_COMM - if ((WHS_Type == WHS_TYPE_NEW)&&(Shinko_Read == true)) - { - if(ShinkoTempDeg.Read_Setup == 0x00)//didn't read it yet - { - WHS_Shinko_Communication(R_SETUP); - } - else - /*if(0)//TBD - need stop condition to write only once (all the steps) , Read_Setup != setup, Read_Setup != 0, Read_Setup != Prev_Read_Setup - { - // option to wrte + read setup and stop when read = write - WHS_Shinko_Communication(W_SETUP); - } - else*/ - { - //finish reading the setup before start reading the value - WHS_Shinko_Communication(R_Value); // Reading every fourth cycle (Set HW, Request, Set HW, Response) - } - } -#endif } if ((O500Millisecond_Tick)&&(RapidPressureRead == false)) { @@ -820,6 +800,11 @@ uint32_t MillisecLowLoop(uint32_t tick) Whs_emptying_cycle++; } */ + + if(Shinko_first_read < 2)//read the two steps once and than in cycle every 10 minutes, also will be used to read after updating the temperature + { + Shinko_Cycle_Comm(); + } } if (Head_Type == HEAD_TYPE_ARC) { HeadBlowersControlLoop(); @@ -837,15 +822,6 @@ uint32_t MillisecLowLoop(uint32_t tick) } if (Tensecond_Tick) { - #ifndef RUN_AS_MAIN_JIG - //Trigger_MidTank_Pressure_Read(); - for (Disp_i = 0;Disp_i < MAX_SYSTEM_DISPENSERS;Disp_i++) - { - Read_MidTank_Pressure_Sensor(Disp_i); - } - #endif - - Shinko_Read = true;//start cycle of R/W setup or value every 10Sec } if (OneMinute_Tick) { @@ -876,6 +852,17 @@ uint32_t MillisecLowLoop(uint32_t tick) { waste_seq_step1();// include 1Sec delay <- to open !!!! }*/ + if (WHS_Type == WHS_TYPE_NEW) + { + Shinko_Cycle_Comm(); + } +#ifndef RUN_AS_MAIN_JIG + //Trigger_MidTank_Pressure_Read(); + for (Disp_i = 0;Disp_i < MAX_SYSTEM_DISPENSERS;Disp_i++) + { + Read_MidTank_Pressure_Sensor(Disp_i); + } +#endif } if (OneHourTick) diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h index f7351d0b1..0d7c42ad6 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h @@ -50,7 +50,6 @@ void MillisecLogClose(void); #endif -extern bool Shinko_Read; extern bool watchdogCriticalAlarm; extern Task_Handle Millisecond_Task_Handle; diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.c b/Software/Embedded_SW/Embedded/Modules/Control/control.c index 14275533e..0a092821e 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c @@ -190,6 +190,7 @@ uint32_t ControlActivityLed( uint32_t Parameter1) if (JobIsActive()) { JobEndReason = JOB_MOTOR_ALARM; + usnprintf(AlarmReasonStr, 100, "Hardware Failure Error"); SendJobProgress(0.0,0,false, "Hardware Failure Error"); AbortJob("FPGA Watchdog Error"); } @@ -198,6 +199,8 @@ uint32_t ControlActivityLed( uint32_t Parameter1) ReportWithPackageFilter(FPGAFilter, "FPGA Watchdog Error",__FILE__,__LINE__,0,RpError, 0,0); ACTIVITY_GREEN_LED_ON; + MotorConfiguredTimeout = 100; + FPGA_SetMotorsInit(); Motor_ReconfigAllMotors(); } @@ -206,6 +209,20 @@ uint32_t ControlActivityLed( uint32_t Parameter1) else ACTIVITY_GREEN_LED_OFF; + if(power.color == colorOFF) Pannel_Leds(POWER_ON_OFF,MODE_OFF); + if(jog.color == colorOFF) Pannel_Leds(THREAD_JOGGING,MODE_OFF); + if(load.color == colorOFF) Pannel_Leds(THREAD_JOGGING,MODE_OFF); + if(cart1.color == colorOFF) Pannel_Leds(CART_1,MODE_OFF); + if(cart2.color == colorOFF) Pannel_Leds(CART_2,MODE_OFF); + if(cart3.color == colorOFF) Pannel_Leds(CART_3,MODE_OFF); + + if(power.color == colorON) Pannel_Leds(POWER_ON_OFF,MODE_ON); + if(jog.color == colorON) Pannel_Leds(THREAD_JOGGING,MODE_ON); + if(load.color == colorON) Pannel_Leds(THREAD_JOGGING,MODE_ON); + if(cart1.color == colorON) Pannel_Leds(CART_1,MODE_ON); + if(cart2.color == colorON) Pannel_Leds(CART_2,MODE_ON); + if(cart3.color == colorON) Pannel_Leds(CART_3,MODE_ON); + if(power.color == fastBILNK) Pannel_Leds(POWER_ON_OFF,MODE_OFF); else diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index d78b5114f..fef3f05a8 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -429,6 +429,13 @@ void LoadChillerState(HeaterType HeaterType,HeaterState *HeaterState) HeaterState->setpoint = (float)(ShinkoTempDeg.Read_Setup); HeaterState->has_currentvalue = true; HeaterState->currentvalue = (float)(ShinkoTempDeg.Read_value); + HeaterState->has_isactive = true; + HeaterState->isactive = false; + HeaterState->has_isrampingup = true; + HeaterState->isrampingup = false; + HeaterState->has_isinsetpoint = true; + HeaterState->isinsetpoint = true; + return; } @@ -634,7 +641,8 @@ void DiagnosticOneMinuteCollection(void) } DiagnosticsMonitor.n_overalltemperature = 1; - OverallTemperature = (max(MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP1),MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP2)))/100; + OverallTemperature = (max(MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP1),MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP2))); + OverallTemperature = (double)OverallTemperature/100.0; //OverallTemperature = ((int)(MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP1)/100)*1000 + (int)(MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP2)/100)); DiagnosticsMonitor.overalltemperature = &OverallTemperature; diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index 1defda43c..90c18caa0 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -186,12 +186,6 @@ uint32_t HWConfigurationInit(void) //WHS_init(); // remove call to old WHS #endif - if (WHS_Type == WHS_TYPE_NEW) - { -/* WHS_IO_Init(); - Task_sleep(1);//wait for WHS_IO_Init*/ - InitConsole_WHS_UART3();//WHS Shinko communication - } // Waste Init (WHS) Waste_Init(); @@ -473,6 +467,7 @@ uint32_t HWConfiguration(UploadHardwareConfigurationRequest* UploadRequest) //if (request->n_winders == 1) // status += InternalWinderConfigMessage(request->winders); + MotorConfiguredTimeout = 100; status += MotorsInit(); diff --git a/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.c b/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.c index d5816ab42..a0b1b30c2 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.c +++ b/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.c @@ -40,8 +40,9 @@ MachineState StoredMachineStatus = MACHINE_STATE__PowerUp; bool SetMAchineStateProblem = false; -void SetMachineStatus (MachineState State) +void SetMachineStatus (MachineState New_state) { + MachineState State = New_state; if (StoredMachineStatus == MACHINE_STATE__PowerOff) { ReportWithPackageFilter(GeneralFilter,"not changing MachineStatus while on power down",__FILE__,__LINE__,State,RpWarning,StoredMachineStatus, 0); @@ -53,9 +54,10 @@ void SetMachineStatus (MachineState State) { ReportWithPackageFilter(GeneralFilter,"SetMachineStatus problem",__FILE__,__LINE__,State,RpWarning,GetMachineState(), 0); SetMAchineStateProblem = true; + State = MACHINE_STATE__PowerUp; } } - ReportWithPackageFilter(GeneralFilter,"SetMachineStatus",__FILE__,__LINE__,State,RpWarning,StoredMachineStatus, 0); + ReportWithPackageFilter(GeneralFilter,"SetMachineStatus",__FILE__,GetMachineState(),State,RpWarning,StoredMachineStatus, 0); StoredMachineStatus = State; MachineUpdateResponseFunc(); @@ -68,7 +70,8 @@ bool temp_measure_alarm = false; int MachineUpdateResponseFunc(void) { int i; - int internaltemp1,internaltemp2,usetemp; + int internaltemp1,internaltemp2; + double usetemp; bool int1valid = true,int2valid = true; MessageContainer responseContainer; if (MachineUpdateToken[0] == 0) @@ -95,7 +98,9 @@ int MachineUpdateResponseFunc(void) MachineStatus.has_overalltemperature = true; if ((int2valid == true)&&(int1valid == true)) { - usetemp = (max(internaltemp1,internaltemp2))/100; + usetemp = (max(internaltemp1,internaltemp2)); + usetemp = (double)usetemp/100.0; + if (temp_measure_alarm == true) { AlarmHandlingSetAlarm(EVENT_TYPE__TEMPERATURE_MEASUREMENT_ERROR, false); @@ -107,14 +112,14 @@ int MachineUpdateResponseFunc(void) //AlarmHandlingSetAlarm(EVENT_TYPE__TEMPERATURE_MEASUREMENT_ERROR, true); temp_measure_alarm = true; if ((int2valid == false)&&(int1valid == true)) - usetemp = internaltemp1/100; + usetemp = (double)internaltemp1/100.0; else if ((int2valid == false)&&(int1valid == false)) { MachineStatus.has_overalltemperature = FALSE; usetemp = 0; } else if ((int1valid == false)&&(int2valid == true)) - usetemp = internaltemp2/100; + usetemp = (double)internaltemp2/100.0; } MachineStatus.overalltemperature = usetemp; @@ -239,7 +244,7 @@ return OK; * */ char WasteEmptyingToken[36+1] = {0}; -uint32_t CartridgeStateUpdate(CartridgeSlot Slot,CartridgeState State) +uint32_t CartridgeStateUpdate(CartridgeSlot Slot,CartridgeState State, double percentage) { if (WasteEmptyingToken[0] == 0) return ERROR; @@ -248,44 +253,46 @@ uint32_t CartridgeStateUpdate(CartridgeSlot Slot,CartridgeState State) CartridgeStatus CartridgeStatus = CARTRIDGE_STATUS__INIT; Cartridge CartData = CARTRIDGE__INIT; StartInkFillingStatusResponse response = START_INK_FILLING_STATUS_RESPONSE__INIT; - response.status->n_cartridgesstatuses = MAX_CARTRIDGES; + response.status->n_cartridgesstatuses = 1; response.status->cartridgesstatuses[0] = &CartridgeStatus; CartridgeStatus.has_state = true; CartridgeStatus.state = State; CartridgeStatus.cartridge = &CartData; + if (percentage>1) + { + CartridgeStatus.has_progresspercentage = true; + CartridgeStatus.progresspercentage = percentage; + } CartData.has_slot = true; CartData.slot = Slot; - - - /* -struct _CartridgeStatus -{ - ProtobufCMessage base; - Cartridge *cartridge; - protobuf_c_boolean has_state; - CartridgeState state; - protobuf_c_boolean has_progresspercentage; - double progresspercentage; - char *message; -}; - size_t n_cartridgesstatuses; - CartridgeStatus **cartridgesstatuses; -typedef enum _CartridgeState { - CARTRIDGE_STATE__None = 0, - CARTRIDGE_STATE__Absent = 1, - CARTRIDGE_STATE__Exists = 2, - CARTRIDGE_STATE__Inserted = 3, - CARTRIDGE_STATE__Filling = 4, - CARTRIDGE_STATE__FillingCompleted = 5, - CARTRIDGE_STATE__Emptying = 6, - CARTRIDGE_STATE__EmptyingCompleted = 7, - CARTRIDGE_STATE__Empty = 8, - CARTRIDGE_STATE__Full = 9, - CARTRIDGE_STATE__Error = 10 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(CARTRIDGE_STATE) -} CartridgeState; + struct _CartridgeStatus + { + ProtobufCMessage base; + Cartridge *cartridge; + protobuf_c_boolean has_state; + CartridgeState state; + protobuf_c_boolean has_progresspercentage; + double progresspercentage; + char *message; + }; + size_t n_cartridgesstatuses; + CartridgeStatus **cartridgesstatuses; + typedef enum _CartridgeState { + CARTRIDGE_STATE__None = 0, + CARTRIDGE_STATE__Absent = 1, + CARTRIDGE_STATE__Exists = 2, + CARTRIDGE_STATE__Inserted = 3, + CARTRIDGE_STATE__Filling = 4, + CARTRIDGE_STATE__FillingCompleted = 5, + CARTRIDGE_STATE__Emptying = 6, + CARTRIDGE_STATE__EmptyingCompleted = 7, + CARTRIDGE_STATE__Empty = 8, + CARTRIDGE_STATE__Full = 9, + CARTRIDGE_STATE__Error = 10 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(CARTRIDGE_STATE) + } CartridgeState; */ responseContainer = createContainer(MESSAGE_TYPE__StartInkFillingStatusResponse, WasteEmptyingToken, false, &response, &start_ink_filling_status_response__pack, &start_ink_filling_status_response__get_packed_size); @@ -313,9 +320,9 @@ uint32_t StartInkFillingStatusRequestFunc(MessageContainer* requestContainer) StartInkFillingStatusRequest* request = start_ink_filling_status_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); ustrncpy (WasteEmptyingToken, requestContainer->token,36); - CartridgeStateUpdate(CARTRIDGE_SLOT__Ink,CARTRIDGE_STATE__None); - CartridgeStateUpdate(CARTRIDGE_SLOT__WasteMiddle,CARTRIDGE_STATE__None); - CartridgeStateUpdate(CARTRIDGE_SLOT__WasteLower,CARTRIDGE_STATE__None); + CartridgeStateUpdate(CARTRIDGE_SLOT__Ink,CARTRIDGE_STATE__None,0); + CartridgeStateUpdate(CARTRIDGE_SLOT__WasteMiddle,CARTRIDGE_STATE__None,0); + CartridgeStateUpdate(CARTRIDGE_SLOT__WasteLower,CARTRIDGE_STATE__None,0); start_ink_filling_status_request__free_unpacked(request,NULL); return status; // case MESSAGE_TYPE__StartWasteEmptyingRequest: diff --git a/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.h b/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.h index b421785cc..b3b773b1e 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.h +++ b/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.h @@ -18,7 +18,7 @@ void SetMachineStatus (MachineState State); int MachineUpdateResponseFunc(void); uint32_t StartInkFillingStatusRequestFunc(MessageContainer* requestContainer); -uint32_t CartridgeStateUpdate(CartridgeSlot Slot,CartridgeState State); +uint32_t CartridgeStateUpdate(CartridgeSlot Slot,CartridgeState State, double percentage); diff --git a/Software/Embedded_SW/Embedded/Modules/General/buttons.c b/Software/Embedded_SW/Embedded/Modules/General/buttons.c index c03f7d913..0dda71d16 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/buttons.c +++ b/Software/Embedded_SW/Embedded/Modules/General/buttons.c @@ -416,9 +416,15 @@ uint32_t ButtonLoadCBFunction(uint32_t IfIndex, uint32_t ReadValue) if (ThreadLoadingActive() == false) { if (JobIsActive()) + { load.color = colorOFF; + Pannel_Leds(THREAD_LOAD, MODE_OFF); + } else + { load.color = colorON; + Pannel_Leds(THREAD_LOAD, MODE_ON); + } } break; } diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index d977fe3f3..56b46c98c 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -399,6 +399,7 @@ uint32_t HeatersTestInternalAlarmsCBFunction(uint32_t IfIndex, uint32_t readValu if (JobIsActive()) { JobEndReason = JOB_TEMPERATURE_ALARM; + usnprintf(AlarmReasonStr, 100, "Internal Temperature %d Error %d",index,readValue); SendJobProgress(0.0,0,false, "Internal Temperature Error"); AbortJob("Internal Over Temperature Error"); //SegmentReady(Module_Heaters,ModuleFail); @@ -1188,6 +1189,7 @@ uint32_t DcHeaterMaxTempCBFunction(uint32_t IfIndex, uint32_t readValue) if (JobIsActive()&&(HeaterReady[index]==true)) { JobEndReason = JOB_TEMPERATURE_ALARM; + usnprintf(AlarmReasonStr, 100, "Temperature %d Error %d",index,readValue); SendJobProgress(0.0,0,false, "Temperature Error"); AbortJob("Over Temperature Error"); //SegmentReady(Module_Heaters,ModuleFail); @@ -1239,6 +1241,7 @@ uint32_t DcHeaterMaxTempCBFunction(uint32_t IfIndex, uint32_t readValue) if (JobIsActive()&&(HeaterReady[index]==true)) { JobEndReason = JOB_TEMPERATURE_ALARM; + usnprintf(AlarmReasonStr, 100, "Temperature %d Error %d",index,readValue); SendJobProgress(0.0,0,false, "Temperature Error"); AbortJob("Under Temperature Error"); ReportWithPackageFilter(HeatersFilter, "Temperature Error",__FILE__,__LINE__,index,RpError, 0,0); diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c index 4fe32e7cd..ab2062293 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c @@ -20,6 +20,7 @@ #include "drivers/FPGA/FPGA_SPI_Comm.h" #include "drivers/Motors/Motor.h" #include "drivers/Valves/Valve.h" +#include "Modules/AlarmHandling/AlarmHandling.h" FPGA_GPI_ENUM Dispenser_Id_to_LS_Id[MAX_SYSTEM_DISPENSERS] = { @@ -84,7 +85,7 @@ uint32_t InitialDispenserSpeed = INITIAL_DISPENSER_SPEED; uint32_t ControlIdtoInactiveDispenserId [MAX_SYSTEM_DISPENSERS] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; -uint32_t IDS_StopHomeDispenserBuildPressure (uint32_t deviceID); +//uint32_t IDS_StopHomeDispenserBuildPressure (uint32_t deviceID); AutoHoming_Config_enum AutoHoming_Config = AutoHoming_off; void IDS_Dispenser_SetAutoHoming_Config(AutoHoming_Config_enum Config) @@ -350,6 +351,7 @@ uint32_t IDS_StopHomeDispenser (uint32_t DispenserId) CurrentDispenserSpeed[DispenserId] = 0; return OK; } +/* uint32_t IDS_StopHomeDispenserBuildPressure (uint32_t DispenserId) { assert(DispenserId < MAX_SYSTEM_DISPENSERS); @@ -380,7 +382,7 @@ uint32_t IDS_StopHomeDispenserBuildPressure (uint32_t DispenserId) } // HomingActive[DispenserId]= false; ReportWithPackageFilter(IDSFilter,"End homing for job start",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,(int)DispenserHomingTime[DispenserId],0); - /* else + /`* else { ReportWithPackageFilter(IDSFilter,"homing aborted,start backlash",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,(int)DispenserHomingTime[DispenserId],0); DispenserHomingControlId[DispenserId] = AddControlCallback( IDS_HomeDispenserBackMoveCallback, InitialDispenserTimeLag, GetDispenserPressure,motorId, motorId, 0 ); @@ -389,12 +391,12 @@ uint32_t IDS_StopHomeDispenserBuildPressure (uint32_t DispenserId) Task_sleep(10); MotorSetSpeed(motorId, 1000); CurrentDispenserSpeed[DispenserId] = 1000; - }*/ + }*`/ //IDS_Dispenser_RefillEnded ( DispenserId, MotorsCfg[motorId].microstep); return OK; } - +*/ uint32_t IDS_CheckDispenserLimitSwitch (LimitSwitchAlarms LS_Id) { int DispenserId; @@ -501,6 +503,7 @@ uint32_t IDS_Dispenser_Alarm_On (uint8_t DispenserId) status |= MotorStop(MotorId, Hard_Hiz); IDS_Dispenser_Init(DispenserId); JobEndReason = JOB_OUT_OF_DYE; + usnprintf(AlarmReasonStr, 100, "IDS_Dispenser_Alarm_On %d ",DispenserId); return status; } uint32_t IDS_Dispenser_Alarm_Off (uint8_t DispenserId) diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 462165ee7..d2fd74256 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -643,6 +643,7 @@ bool AdjustDispenserSpeedToPressure(int DispenserId, double RefMaxPressure,doubl endOfPrepareWCF = true; result = ModuleFail; JobEndReason = JOB_PRESSURE_ALARM; + usnprintf(AlarmReasonStr, 100, "IDS pressure timeout %d ",DispenserPrepareTimeout); pressureReady = true; ReportWithPackageFilter(IDSFilter,"pressure timeout!",__FILE__,DispenserBuildTimeCounter,NumofReadyDispensers,RpWarning,(int)(DispenserPreparePressure*100),0); for (i = 0; i < MAX_DYE_DISPENSERS; i++) @@ -1357,6 +1358,7 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) { ReportWithPackageFilter(IDSFilter,"Error JobBrushStopId",__FILE__,__LINE__,(int)Segment->n_brushstops,RpError,(int)0,0); JobEndReason = JOB_OUT_OF_DYE; + usnprintf(AlarmReasonStr, 100, "IDS brushstop error %d above %d ",JobBrushStopId,Segment->n_brushstops); PreSegmentReady(Module_IDS,ModuleFail); return ERROR; } @@ -1449,6 +1451,7 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) { ReportWithPackageFilter(IDSFilter,"End run - BrushStopReadError",__FILE__,__LINE__,(int)FileBrushStop,RpError,(int)0,0); JobEndReason = JOB_OUT_OF_DYE; + usnprintf(AlarmReasonStr, 100, "IDS brushstop read error"); PreSegmentReady(Module_IDS,ModuleFail); } } @@ -1663,6 +1666,7 @@ uint32_t IDSBrushStopRestartCallback(uint32_t IfIndex, uint32_t readValue) { Task_stat(Task_self(),&statbuf); ReportWithPackageFilter(IDSFilter,"BrushStopRead Error",__FILE__,statbuf.used,(int)statbuf.stackSize,RpWarning,(int)statbuf.stackHeap,0); + usnprintf(AlarmReasonStr, 100, "IDS brushstop error"); JobEndReason = JOB_OUT_OF_DYE; SegmentReady(Module_IDS,ModuleFail); } @@ -1944,6 +1948,6 @@ uint32_t IDS_StopLubrication(void) TimerMotors_t HW_Motor_Id = DispenserIdToMotorId[LUBRICANT_DISPENSER]; MotorStop(HW_Motor_Id,Hard_Hiz); CurrentDispenserSpeed[LUBRICANT_DISPENSER] = 0; - IDS_HomeDispenser (LUBRICANT_DISPENSER, 1000 , NULL); + //IDS_HomeDispenser (LUBRICANT_DISPENSER, 1000 , NULL); do not fill lubricant between jobs return OK; } diff --git a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c index d62ad3a43..b2498ee7f 100644 --- a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c +++ b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c @@ -28,6 +28,7 @@ #include "drivers/Valves/Valve.h" #include "../control/control.h" #include "Modules/General/buttons.h" +#include "Modules/General/MachineStatus.h" #define CARTRIDGE_EMPTY_QUANTITY_LIMIT 10 #define CARTRIDGE_EMPTY_CALCULATION_TIME 12 @@ -147,13 +148,20 @@ bool CartridgeInkFull() //currently sensor work properly only until 1.6 - 1.8 Liter (TBD) Report("DetectIfCartridgeFinished", __FILE__,__LINE__,int_MidTank_Pressure_1000, RpMessage, int_MidTank_Pressure_1000, 0); //return true; - //IFS_State = CARTRIDGE_STATE__FillingCompleted; } } return false; } #endif +int GetCartridgeFillPercent() +{ + double MidTank_Pressure = 0; + + MidTank_Pressure = Read_MidTank_Pressure_Sensor(midTankCartColor); + return (((MidTank_Pressure - midTankCapacity)* 100) / CARTRIDGE_CAPATICY); +} + bool midTankCart_door() { bool door; @@ -275,8 +283,8 @@ void midTankStateMachine(void) if (!RdInkCartridgeSensor()) { break; } - //check RFID? (TBD) - //IFS_State = CARTRIDGE_STATE__Inserted; + //check RFID - check cartridge OK + CartridgeStateUpdate(CARTRIDGE_SLOT__Ink, CARTRIDGE_STATE__Inserted, 0); // send request for validation to ppc inkAuthenticationPass = 2; //not defined @@ -298,16 +306,17 @@ void midTankStateMachine(void) Report("MidTank Cartridge authentication wait...", __FILE__, __LINE__, authenticationTimeOutCounter, RpMessage, 0, 0); if (authenticationTimeOutCounter > 60) { midTankState = MidTankStateIdle; - //IFS_State = CARTRIDGE_STATE__Error; + CartridgeStateUpdate(CARTRIDGE_SLOT__Ink, CARTRIDGE_STATE__Error, 0); } break; } if (inkAuthenticationPass == false) { Report("MidTank Cartridge authentication fail", __FILE__, __LINE__, 0, RpMessage, 0, 0); - //IFS_State = CARTRIDGE_STATE__Error; + CartridgeStateUpdate(CARTRIDGE_SLOT__Ink, CARTRIDGE_STATE__Error, 0); midTankState = MidTankStateIdle; break; } + // Cartridge status received from user - assume cartridge is full midTankCapacity = Get_MidTank_Pressure_Sensor(midTankCartColor); if ((midTankCapacity > MidTankEmptyLimit)&&(midTankCartColor!=MIDTANK_8))//enable lubricant filling in two stages @@ -316,13 +325,13 @@ void midTankStateMachine(void) cart1.color = fastBILNK; Report("Mid-tank not empty", __FILE__, __LINE__, midTankCapacity, RpMessage, MidTankEmptyLimit, 0); midTankState = MidTankStateIdle; - //IFS_State = CARTRIDGE_STATE__Exists; + CartridgeStateUpdate(CARTRIDGE_SLOT__Ink, CARTRIDGE_STATE__Error, 0); break; } Report("Mid-tank filling in process", __FILE__,__LINE__,(int)(MidTankEmptyLimit*1000), RpMessage, (int)(midTankCapacity*1000), 0); Pannel_Leds(CART_1, MODE_ON); cart1.color = BLINK; - //IFS_State = CARTRIDGE_STATE__Filling; + CartridgeStateUpdate(CARTRIDGE_SLOT__Ink, CARTRIDGE_STATE__Filling, 0); if (midTankCartColor == MIDTANK_8) { @@ -333,7 +342,7 @@ void midTankStateMachine(void) MidTankValvesAction(Cartridge_MidTank_ON); Report("midTankStateWait set valve", __FILE__, __LINE__, 0, RpMessage, 0, 0); - // RFID change status - TBD + // RFID change status - inkUsed, inkFill // set count down midTankTimeoutCounter = 1; @@ -347,7 +356,7 @@ void midTankStateMachine(void) Report("Cartridge extracted during filling!!!", __FILE__, __LINE__, midTankState, RpMessage, 0, 0); Report("Mid-tank # filling fail", __FILE__, __LINE__, midTankState, RpMessage, 0, 0); midTankState = MidTankStateIdle; - //IFS_State = CARTRIDGE_STATE__Absent; + CartridgeStateUpdate(CARTRIDGE_SLOT__Ink, CARTRIDGE_STATE__Absent, GetCartridgeFillPercent()); } // if time out or emptying done - idle if (midTankTimeoutCounter++ > CartridgeInkTimeout) { @@ -357,7 +366,7 @@ void midTankStateMachine(void) MidTankValvesAction(Cartridge_MidTank_OFF); Report("Mid-tank # filling fail", __FILE__, __LINE__, midTankState, RpMessage, 0, 0); Report("Call customer support", __FILE__, __LINE__, midTankState, RpMessage, 0, 0); - //IFS_State = CARTRIDGE_STATE__Error; + CartridgeStateUpdate(CARTRIDGE_SLOT__Ink, CARTRIDGE_STATE__Error, GetCartridgeFillPercent()); midTankState = MidTankStateIdle; } else if (CartridgeInkFull()) { midTankTimeoutCounter = 0; @@ -366,8 +375,10 @@ void midTankStateMachine(void) MidTankValvesAction(Cartridge_MidTank_OFF); Report("Mid-tank # filling done", __FILE__, __LINE__, midTankState, RpMessage, 0, 0); midTankState = MidTankStateIdle; - //IFS_State = CARTRIDGE_STATE__FillingCompleted; + // RFID change status - inkEmpty + CartridgeStateUpdate(CARTRIDGE_SLOT__Ink, CARTRIDGE_STATE__FillingCompleted, 100.0); } + CartridgeStateUpdate(CARTRIDGE_SLOT__Ink, CARTRIDGE_STATE__Filling, GetCartridgeFillPercent()); break; default: Report("wrong state", __FILE__, __LINE__, midTankState, RpMessage, 0, 0); diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c index fb8e97898..987257645 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c @@ -488,35 +488,35 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if(request->amount == 0xAD1) //Set_Check_Pressure_Bypass { - LOG_ERROR((request->delay)?1:0,"Set_Check_Pressure_Bypass"); + REPORT_MSG((request->delay)?1:0,"Set_Check_Pressure_Bypass"); response.progress = Set_Check_Pressure_Bypass(request->delay); response.has_progress = true; } else if(request->amount == 0xAD2) //Set_Thread_Rockers_Bypass { - LOG_ERROR((request->delay)?1:0,"Set_Thread_Rockers_Bypass"); + REPORT_MSG((request->delay)?1:0,"Set_Thread_Rockers_Bypass"); response.progress = Set_Thread_Rockers_Bypass(request->delay); response.has_progress = true; } else if(request->amount == 0xAD3) //Set_Auto_Shutdown_Bypass { - LOG_ERROR((request->delay)?1:0,"Set_Auto_Shutdown_Bypass"); + REPORT_MSG((request->delay)?1:0,"Set_Auto_Shutdown_Bypass"); response.progress = Set_Auto_Shutdown_Bypass(request->delay); response.has_progress = true; } else if(request->amount == 0xAD4) //Set_Auto_Idle_Bypass { - LOG_ERROR((request->delay)?1:0,"Set_Auto_Idle_Bypass"); + REPORT_MSG((request->delay)?1:0,"Set_Auto_Idle_Bypass"); response.progress = Set_Auto_Idle_Bypass(request->delay); response.has_progress = true; } else if(request->amount == 0xAD5) //Set SecondFeederCorrection { - LOG_ERROR(request->delay,"Set SecondFeederCorrection"); + REPORT_MSG(request->delay,"Set SecondFeederCorrection"); SecondFeederCorrection = request->delay; response.progress = SecondFeederCorrection; response.has_progress = true; @@ -524,7 +524,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if(request->amount == 0xAD6) //Set skip open lids { - LOG_ERROR(request->delay,"Set SkipOpenLids"); + REPORT_MSG(request->delay,"Set SkipOpenLids"); SkipOpenLids = request->delay; response.progress = SkipOpenLids; response.has_progress = true; @@ -532,7 +532,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if(request->amount == 0xAD7) //Set actuators cleaning sequence { - LOG_ERROR(request->delay,"Set actuators cleaning sequence"); + REPORT_MSG(request->delay,"Set actuators cleaning sequence"); ActuatorsCleaningSequence = request->delay; response.progress = ActuatorsCleaningSequence; response.has_progress = true; @@ -540,7 +540,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if(request->amount == 0xAD8) //Set ignore cone missing { - LOG_ERROR(request->delay,"Set ignore cone missing"); + REPORT_MSG(request->delay,"Set ignore cone missing"); IgnoreConeMissing = request->delay; response.progress = IgnoreConeMissing; response.has_progress = true; @@ -548,7 +548,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if(request->amount == 0xAD9) //halt { - LOG_ERROR(request->delay,"halt"); + REPORT_MSG(request->delay,"halt"); memset (0,0,100000); response.progress = IgnoreConeMissing; response.has_progress = true; @@ -559,7 +559,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) response.progress = Power_Step_01_Mode(((request->delay &0x00FF00)>>8), request->delay &0x0000FF); response.has_progress = true; } - else + /*else if((request->amount == 0xAB) && (request->delay == 0xAB)) //Get pressure with flow (orifice flow meter) { response.progress = Calculate_Pitot_Pressure(true); @@ -572,7 +572,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) response.progress = Calculate_Pitot_Pressure(false); response.has_progress = true; - } + }*/ else if((request->amount == 0xAC) && (request->delay == 0xAC)) //VAC { @@ -909,7 +909,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) FRESULT iFResult = Init_Flash_File_System(true); if(iFResult != FR_OK) { - LOG_ERROR (iFResult, "Error during init Flash File System"); + REPORT_MSG (iFResult, "Error during init Flash File System"); assert(iFResult); } #ifdef WATCHDOG @@ -918,17 +918,17 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) ROM_WatchdogReloadSet(WATCHDOG0_BASE, timeout); #endif } - else + /*else if((request->amount == 0x0C) && (request->delay == 0x0C)) //Get Gas Sensor { response.progress = (double)Calculate_Gas_Power_Consumption(); response.has_progress = true; - } + }*/ else if((request->amount == 0xDD) && (request->delay == 0xDD)) //Read Input Voltage { - LOG_ERROR(request->delay,"CheckAcInputVoltage"); + REPORT_MSG(request->delay,"CheckAcInputVoltage"); CheckAcInputVoltage(); response.progress = (double)Input_Voltage; @@ -937,7 +937,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if((request->amount == 0x0CE) && (request->delay == 0x0CE)) //Get Gas Sensor { - LOG_ERROR(request->delay,"FlashInit"); + REPORT_MSG(request->delay,"FlashInit"); HeatersEnd(); FlashInit(); response.progress = (double)OK; @@ -947,8 +947,12 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if((request->amount == 0x0CD) && (request->delay == 0x0CD)) //Get Gas Sensor { - LOG_ERROR(request->delay,"Load embedded parameters from file and restart"); + REPORT_MSG(request->delay,"Load embedded parameters from file and restart"); + base_flashErased = false; LoadConfigurationParamsFromFile(true); + REPORT_MSG(255,"Update successful, Rebooting in 5 seconds"); + Task_sleep (eOneSecond*5); + Power_Reset(); response.progress = (double)OK; response.has_progress = true; @@ -956,7 +960,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if(request->amount == 0x0CC) //Cartridge Validation Response Demo { - LOG_ERROR(request->delay,"ResponseDemo"); + REPORT_MSG(request->delay,"ResponseDemo"); ResponseDemo(request->delay); response.progress = (double)OK; response.has_progress = true; @@ -964,7 +968,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if(request->amount == 0xE0) //fast refresh for pressure { - LOG_ERROR(request->delay,"setRapidPressureRead"); + REPORT_MSG(request->delay,"setRapidPressureRead"); setRapidPressureRead(request->delay); response.progress = (double)OK; response.has_progress = true; @@ -972,7 +976,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) /*else if(request->amount == 0xE1) //fast refresh for pressure { - LOG_ERROR(request->delay,"Starting Dispenser PID"); + REPORT_MSG(request->delay,"Starting Dispenser PID"); IDS_Start_Pid_Testing(request->delay); response.progress = (double)OK; response.has_progress = true; @@ -980,7 +984,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if(request->amount == 0xE2) //fast refresh for pressure { - LOG_ERROR(request->delay,"Stoping Dispenser PID"); + REPORT_MSG(request->delay,"Stoping Dispenser PID"); IDS_Stop_Pid_Testing(request->delay); response.progress = (double)OK; response.has_progress = true; @@ -1024,7 +1028,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if(request->amount == 0xB1) //fast refresh for pressure { - LOG_ERROR(request->delay,"Set loading arm center"); + REPORT_MSG(request->delay,"Set loading arm center"); Read_Dryer_ENC_Position(); Task_sleep(500); Read_Dryer_ENC_Position(); @@ -1036,7 +1040,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if(request->amount == 0xB2) //Set loading arm cycles { - LOG_ERROR(request->delay,"Set loading arm cycles"); + REPORT_MSG(request->delay,"Set loading arm cycles"); response.progress = (double)MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,request->delay); response.has_progress = true; @@ -1044,7 +1048,8 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if(request->amount == 0xB3) //fast refresh for pressure { - LOG_ERROR(request->amount,"keep alive test"); + REPORT_MSG(request->amount,"keep alive test"); + keepalivetest = request->amount; response.progress = keepalivetest; response.has_progress = true; @@ -1052,9 +1057,9 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if(request->amount == 0xB4) //IDS_Dispenser_Content_Init { - LOG_ERROR(request->amount,"IDS_Dispenser_Content_Init"); + REPORT_MSG(request->amount,"IDS_Dispenser_Content_Init"); IDS_Dispenser_Content_Init(); - response.progress = keepalivetest; + response.progress = 0; response.has_progress = true; } @@ -1063,7 +1068,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) { if (request->delay<=100) { - LOG_ERROR(request->delay,"set stub_heating_limit"); + REPORT_MSG(request->delay,"set stub_heating_limit"); stub_heating_limit = request->delay; } response.progress = request->delay; @@ -1074,7 +1079,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if(request->amount == 0xB6) //fast refresh for pressure { - LOG_ERROR(request->delay,"set vac read test"); + REPORT_MSG(request->delay,"set vac read test"); VAC_Test = (double)request->delay; response.progress = request->delay; response.has_progress = true; @@ -1085,7 +1090,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) if(request->amount == 0xB7) //fast refresh for pressure { specialHeaterState = request->delay?true:false; - LOG_ERROR(specialHeaterState,"set specialHeaterState"); + REPORT_MSG(specialHeaterState,"set specialHeaterState"); response.progress = specialHeaterState; response.has_progress = true; @@ -1095,7 +1100,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) { if (request->delay == 1) {//init waste Waste_Init(); - LOG_ERROR(request->delay,"Waste_Init"); + REPORT_MSG(request->delay,"Waste_Init"); } response.progress = request->delay; response.has_progress = true; @@ -1105,7 +1110,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) { if ((request->delay == 0) || (request->delay == 1)) { doorState = request->delay; - LOG_ERROR(request->delay,"door"); + REPORT_MSG(request->delay,"door"); } response.progress = request->delay; response.has_progress = true; @@ -1149,7 +1154,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if(request->amount == 0xB14) { - LOG_ERROR(request->amount,"IDS_Cleaning_Move_Actuators"); + REPORT_MSG(request->amount,"IDS_Cleaning_Move_Actuators"); Init_CleaningStageCounter(); IDS_Cleaning_Move_Actuators(); @@ -1160,7 +1165,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) if(request->amount == 0xB15) { TimerMotors_t MotorId = HARDWARE_MOTOR_TYPE__MOTO_DH_LID; - LOG_ERROR(request->amount,"Motor soft stop"); + REPORT_MSG(request->amount,"Motor soft stop"); MotorStop(MotorId,Soft_Stop); response.progress = 0xB15; @@ -1170,7 +1175,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) if(request->amount == 0xB16) { TimerMotors_t MotorId = HARDWARE_MOTOR_TYPE__MOTO_DH_LID; - LOG_ERROR(request->amount,"MotorMovetoLimitSwitch"); + REPORT_MSG(request->amount,"MotorMovetoLimitSwitch"); MotorMovetoLimitSwitch(MotorId,1 - MotorsCfg[MotorId].directionthreadwize, 50, Motor_Id_to_LS_IdDown[MotorId], cleaningMotorCBFunction,30000); ReportWithPackageFilter(IDSFilter,"IDS_Cleaning_Motor_Homing", __FILE__, __LINE__, 1, RpWarning, 0, 0); @@ -1180,7 +1185,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if(request->amount == 0xB17) { - LOG_ERROR(request->delay,"HeadBlowersOff"); + REPORT_MSG(request->delay,"HeadBlowersOff"); HeadBlowersOff(request->delay); response.progress = 0xB17; @@ -1190,7 +1195,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) if(request->amount == 0xB18) { enable = HeadBlowersOffGet(); - LOG_ERROR(enable, "HeadBlowersOffGet"); + REPORT_MSG(enable, "HeadBlowersOffGet"); response.progress = 0xB18; response.has_progress = true; @@ -1198,7 +1203,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if(request->amount == 0xB19) { - LOG_ERROR(request->amount,"ThreadCheckArcHeadCovers"); + REPORT_MSG(request->amount,"ThreadCheckArcHeadCovers"); ThreadCheckArcHeadCovers(); ReportWithPackageFilter(IDSFilter,"ThreadCheckArcHeadCovers", __FILE__, __LINE__, 1, RpWarning, 0, 0); @@ -1208,24 +1213,32 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if(request->amount == 0xB20) //Set loading arm cycles { - LOG_ERROR(request->delay,"Set winding calibration data"); + REPORT_MSG(request->delay,"Set winding calibration data"); response.progress = (double)MCU_E2PromProgram(EEPROM_STORAGE_WINDER_CALIBRATION,request->delay); response.has_progress = true; } else + if(request->amount == 0xB21) //Set loading arm cycles + { + REPORT_MSG(request->delay,"Set screw max speed"); + + response.progress = (double)MotorSetMaxSpeed(HARDWARE_MOTOR_TYPE__MOTO_SCREW,request->delay); + response.has_progress = true; + } + else if(request->amount == 0xC3) //suspend I2C task { if (request->delay == 0) { - LOG_ERROR(request->delay,"Suspend I2C"); + REPORT_MSG(request->delay,"Suspend I2C"); PowerOffHeatersOff(); Task_sleep(1000); Task_setPri (I2C_Task_Handle,-1); } else { - LOG_ERROR(request->delay,"Resume"); + REPORT_MSG(request->delay,"Resume"); Task_setPri (I2C_Task_Handle,17); } response.progress = request->delay; @@ -1236,7 +1249,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) if(request->amount == 0xC11) { IgnoreMidTank = request->delay; - LOG_ERROR(IgnoreMidTank, "IgnoreMidTank"); + REPORT_MSG(IgnoreMidTank, "IgnoreMidTank"); response.progress = request->delay; response.has_progress = true; @@ -1246,7 +1259,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) if(request->amount == 0xC12) { MidTankMitigation = request->delay; - LOG_ERROR(MidTankMitigation, "MidTankMitigation"); + REPORT_MSG(MidTankMitigation, "MidTankMitigation"); response.progress = request->delay; response.has_progress = true; @@ -1255,7 +1268,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) if(request->amount == 0xC13) { MidTankMitigationOff = request->delay; - LOG_ERROR(MidTankMitigationOff, "MidTankMitigationOff"); + REPORT_MSG(MidTankMitigationOff, "MidTankMitigationOff"); response.progress = request->delay; response.has_progress = true; @@ -1264,7 +1277,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) if(request->amount == 0xC14) { MidTankMitigationOn = request->delay; - LOG_ERROR(MidTankMitigationOn, "MidTankMitigationOn"); + REPORT_MSG(MidTankMitigationOn, "MidTankMitigationOn"); response.progress = request->delay; response.has_progress = true; @@ -1278,7 +1291,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) else if(request->amount == 0xF1) { - LOG_ERROR(request->delay,"NumberOfRotationPerPassage"); + REPORT_MSG(request->delay,"NumberOfRotationPerPassage"); NumberOfRotationPerPassage = (float)(request->delay)/1000; } else @@ -1314,7 +1327,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) //free(container_buffer); if (RestartNeeded == true) { - LOG_ERROR(255,"Update successful, Rebooting in 5 seconds"); + REPORT_MSG(255,"Update successful, Rebooting in 5 seconds"); Task_sleep (eOneSecond*5); Power_Reset(); RestartNeeded = false; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index f7ed9065f..63072e4d8 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -339,6 +339,7 @@ else { load.color = colorON; + Pannel_Leds(THREAD_LOAD, MODE_ON); ThreadLoadingReport(); } } @@ -852,6 +853,7 @@ LoadStages = THREAD_LOAD_INIT; load.color = colorON; + Pannel_Leds(THREAD_LOAD, MODE_ON); return OK; } uint32_t Thread_Load_switchCallback(uint32_t deviceID, uint32_t BusyFlag) diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index 0440d2241..a6cb25c45 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -167,6 +167,7 @@ uint32_t Winder_Prepare(void *JobDetails) if (IgnoreConeMissing == false) { JobEndReason = JOB_THREAD_BREAK; + usnprintf(AlarmReasonStr, 100, "No cone in winder"); PrepareReady(Module_Winder,ModuleFail); AlarmHandlingSetAlarm(EVENT_TYPE__WINDER_CONE_DOES_NOT_EXIST,true); return ERROR; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 94350f752..bc4e6cb8f 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -459,6 +459,7 @@ uint32_t checkBreakSensor(uint32_t index) JobEndReason = JOB_THREAD_BREAK; ThreadControlActive = false; SendJobProgress(0.0,0,false, TMessage); + strcpy(AlarmReasonStr,TMessage); SendSegmentFail(); //AlarmHandlingSetAlarm(EVENT_TYPE__THREAD_BREAK,true); //EndState(CurrentJob,"ReadBreakSensor Error" ); @@ -482,6 +483,7 @@ uint32_t checkBreakSensor(uint32_t index) { //consider applying the debouce parameters later usnprintf(TMessage, 60, "thread speed too low"); + strcpy(AlarmReasonStr,TMessage); JobEndReason = JOB_THREAD_BREAK; ThreadControlActive = false; SendJobProgress(0.0,0,false, TMessage); @@ -685,6 +687,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) JobEndReason = JOB_WINDER_DANCER_FAIL+HARDWARE_DANCER_0; #endif SendJobProgress(0.0,0,false, TMessage); + strcpy(AlarmReasonStr,TMessage); //EndState(CurrentJob,TMessage ); SendSegmentFail(); /*switch (index) @@ -1115,6 +1118,7 @@ uint32_t ThreadPrepareState(void *JobDetails) { ReportWithPackageFilter(ThreadFilter,"Dyeing head is open!!!",__FILE__,__LINE__,HARDWARE_MOTOR_TYPE__MOTO_DH_LID,RpWarning,LIMIT,0); //JobEndReason = JOB_LIDS_OPEN; + // usnprintf(AlarmReasonStr, 100, "Dyeing head is open!!!"); //PrepareReady(Module_Thread,ModuleFail); //return ERROR; } @@ -1122,6 +1126,7 @@ uint32_t ThreadPrepareState(void *JobDetails) { ReportWithPackageFilter(ThreadFilter,"Dryer lid is open!!!",__FILE__,__LINE__,HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID,RpWarning,LIMIT,0); //JobEndReason = JOB_LIDS_OPEN; + // usnprintf(AlarmReasonStr, 100, "Dyeing head is open!!!"); //PrepareReady(Module_Thread,ModuleFail); //return ERROR; }*/ @@ -1135,6 +1140,7 @@ uint32_t ThreadPrepareState(void *JobDetails) if (SkipOpenLids == false) { JobEndReason = JOB_LIDS_OPEN; + usnprintf(AlarmReasonStr, 100, "Dyeing head is open!!!"); PrepareReady(Module_Thread,ModuleFail); return ERROR; } @@ -1155,6 +1161,7 @@ uint32_t ThreadPrepareState(void *JobDetails) if (SkipOpenLids == false) { JobEndReason = JOB_LIDS_OPEN; + usnprintf(AlarmReasonStr, 100, "Dryer lid is open!!!"); PrepareReady(Module_Thread,ModuleFail); return ERROR; } diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_ex.h b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_ex.h index 8a075bfd4..db15a9ffd 100644 --- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_ex.h @@ -44,7 +44,7 @@ bool WHS_IsContainerFull(); bool WHS_WasteCartridgeLowerPresent(); bool WHS_WasteCartridgeMiddlePresent(); bool WHS_IsEmptying(); -uint32_t Waste_CheckState(void); +uint32_t Waste_CheckState(int *AlarmId); uint32_t Waste_Prepare(void); bool WHS_IsVocPpmOverAlarmLimit(); void setWastePrepareValues(float HeadLimit,float WasteLimit); diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c index c87dc88c3..5471397aa 100644 --- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c +++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c @@ -22,6 +22,7 @@ #include "CartridgeValidationResponse.pb-c.h" #include "Modules/General/buttons.h" #include "modules/General/process.h" +#include "Modules/General/MachineStatus.h" #include "Modules/IFS/ifs.h" #include <Drivers/I2C_Communication/I2C_Task.h> #include <Drivers/I2C_Communication/WHS_Card/D_MAX11614_ADC/WHS_MAX11614_A2D.h> @@ -36,7 +37,7 @@ bool DoorState = OPEN; uint32_t timeout_counter = 0; int wasteLevel = 0; WasteCartridgeEnum SelectedCard = MaxWasteCartridges; -CartridgeStateEnum CartState[MaxWasteCartridges]; +CartridgeStateEnum CartState[MaxWasteCartridges];// = {CartridgeStateOUT,CartridgeStateOUT,CartridgeStateOUT}; uint32_t Cartridge_Cover_Control; button *CartLed[MaxWasteCartridges] = {0, &cart2, &cart3}; WasteTankStateEnum WasteTankState = WasteTankStateIdle; @@ -49,7 +50,7 @@ bool setWasteValve (WasteCartridgeEnum WasteCartridge); #define WASTE_LEVEL_OVERFLOW 2700 #define WASTE_LEVEL_FULL 2300 #define WASTE_LEVEL_EMPTY 900 -#define WASTE_EMPTING_TIMEOUT 1200 +#define WASTE_EMPTING_TIMEOUT 1500 double wasteLevelOverflow = WASTE_LEVEL_OVERFLOW; double wasteLevelFull = WASTE_LEVEL_FULL; double wasteLevelEmpty = WASTE_LEVEL_EMPTY; @@ -65,6 +66,7 @@ void cartCART_INSERTED (WasteCartridgeEnum CartId) if (CartState[CartId] != CartridgeStateOUT) Report("Cartridges Cart inserted wrong state", __FILE__, __LINE__, CartId, RpMessage, CartState[CartId], 0); CartState[CartId] = CartridgeStateIN; + Pannel_Leds((CartId == WasteCartridge_middle)?CART_2:CART_3, MODE_ON); CartLed[CartId]->color = colorON; Report("Cartridges Cart inserted", __FILE__, __LINE__, CartId, RpMessage, CartState[CartId], 0); @@ -77,6 +79,7 @@ void cartCART_EXTRACTED(WasteCartridgeEnum CartId) //{called from polling functi Report("Cartridges Cart extracted", __FILE__, __LINE__, CartId, RpMessage, CartState[CartId], 0); CartState[CartId] = CartridgeStateOUT; + Pannel_Leds((CartId == WasteCartridge_middle)?CART_2:CART_3, MODE_OFF); CartLed[CartId]->color = colorOFF; if (init==0) WHS_Set_IFS_Clearing_Suction(NUM_OF_MIDTANKS); @@ -259,6 +262,14 @@ bool RdWasteTankOverFlowSensor() return 0; } +int WHS_GetCartridgeFillPercent() +{ + return (((wasteLevel - wasteLevelEmpty) * 100) / WASTE_CARTRIDGE_SIZE); +} +int WHS_GetCartridgeFill() +{ + return (wasteLevelFull - wasteLevel); +} bool WHS_IsContainerFull() { return RdWasteTankFullSensor(); @@ -343,6 +354,7 @@ void Waste_StateMachine_OneSecond_Call(void) if ((Is_Cartridge_Present(CART_2) != cartGetPresence(WasteCartridge_middle)) || (init)) { if (Is_Cartridge_Present(CART_2)) { cartCART_INSERTED(WasteCartridge_middle); + CartridgeStateUpdate(CARTRIDGE_SLOT__WasteMiddle, CARTRIDGE_STATE__Inserted, 0); } else { cartCART_EXTRACTED(WasteCartridge_middle); } @@ -350,6 +362,7 @@ void Waste_StateMachine_OneSecond_Call(void) if ((Is_Cartridge_Present(CART_3) != cartGetPresence(WasteCartridge_lower)) || (init)) { if (Is_Cartridge_Present(CART_3)) { cartCART_INSERTED(WasteCartridge_lower); + CartridgeStateUpdate(CARTRIDGE_SLOT__WasteLower, CARTRIDGE_STATE__Inserted, 0); } else { cartCART_EXTRACTED(WasteCartridge_lower); } @@ -383,6 +396,7 @@ void Waste_StateMachine_OneSecond_Call(void) void Waste_StateMachine(void) { uint32_t activeCart; + char str[100]; switch (WasteTankState) { case WasteTankStateIdle: @@ -417,7 +431,8 @@ void Waste_StateMachine(void) //Report("Close cartridge cover", __FILE__, __LINE__, DoorState, RpMessage, 0, 0); break; } - //check RFID? (TBD) + // check RFID - check cartridge OK (inkEmpty) + // RFID change status - set WasteEmpty //move to next state WasteTankState = WasteTankStateFull; @@ -432,7 +447,6 @@ void Waste_StateMachine(void) activeCart = cartGetActiveCart(); //Report("WasteTankStateEmptying set valve", __FILE__, __LINE__, activeCart, RpMessage, 0, 0); setWasteValve(activeCart); - // RFID change status - TBD // set count down timeout_counter = 1; @@ -440,6 +454,7 @@ void Waste_StateMachine(void) // set emptying limit wasteLevelEmpty = wasteLevel - WASTE_CARTRIDGE_SIZE; + wasteLevelFull = wasteLevel; waste_seq_step1_cont(); // start a timer to observe door opening @@ -447,19 +462,23 @@ void Waste_StateMachine(void) Report("add control Cartridge Cover Door", __FILE__, __LINE__, 0, RpMessage, 0, 0); SetWastePump(OPEN); - Report("WasteTankStateEmptying set Pump Open", __FILE__, __LINE__, activeCart, RpMessage, 0, 0); + Report("WasteTankStateEmptying set Pump Open", __FILE__, activeCart, wasteLevel, RpMessage, wasteLevelEmpty, 0); //start emptying + // RFID change status - set wasteFilling WasteTankState = WasteTankStateEmptying; + CartridgeStateUpdate(activeCart, CARTRIDGE_STATE__Emptying, 0); break; case WasteTankStateEmptying: // if time out or emptying done - idle + activeCart = cartGetActiveCart(); if (timeout_counter++ > WASTE_EMPTING_TIMEOUT) { SetWastePump(CLOSE); cartFILLING_END(); - // RFID change status - TBD WasteTankState = WasteTankStateIdle; - Report("WasteTankStateEmptying TimeOut", __FILE__, __LINE__, 0, RpMessage, 0, 0); + usnprintf(str, 100, "WasteTankStateEmptying Timeout. time:%d:%d volume:%d", timeout_counter/60, timeout_counter%60, WHS_GetCartridgeFill()); + Report(str, __FILE__, __LINE__, 0, RpMessage, 0, 0); + CartridgeStateUpdate(activeCart, CARTRIDGE_STATE__Error, WHS_GetCartridgeFillPercent()); AlarmHandlingSetAlarm( EVENT_TYPE__WASTE_CONTAINER_EMPTYING_TIMEOUT, true); RemoveControlCallback(Cartridge_Cover_Control, Waste_DoorOpenDuringEmptying); timeout_counter = 0; @@ -467,14 +486,17 @@ void Waste_StateMachine(void) SetWastePump(CLOSE); cartFILLING_END(); waste_seq_cont_stop(); - // RFID change status - TBD + // RFID change status - set wasteFull WasteTankState = WasteTankStateIdle; RemoveControlCallback(Cartridge_Cover_Control, Waste_DoorOpenDuringEmptying); //if (cartNotAllFull() == false) AlarmHandlingSetAlarm( EVENT_TYPE__ALL_WASTE_CARTRIDGES_FULL, true); - Report("WasteTankStateEmptying done", __FILE__, __LINE__, 0, RpMessage, 0, 0); + usnprintf(str, 100, "WasteTankStateEmptying done. time:%d:%d volume:%d", timeout_counter/60, timeout_counter%60, WHS_GetCartridgeFill()); + Report(str, __FILE__, __LINE__, 0, RpMessage, 0, 0); + CartridgeStateUpdate(activeCart, CARTRIDGE_STATE__EmptyingCompleted, WHS_GetCartridgeFillPercent()); timeout_counter = 0; } + CartridgeStateUpdate(activeCart, CARTRIDGE_STATE__Emptying, WHS_GetCartridgeFillPercent()); #ifdef WHS_DEBUG wasteLevel -= 100; timeout_counter += 10; @@ -495,7 +517,7 @@ void Waste_StateMachine(void) AlarmHandlingSetAlarm( EVENT_TYPE__ALL_WASTE_CARTRIDGES_FULL, true); Report("WasteTankStatePaused done", __FILE__, __LINE__, 0, RpMessage, 0, 0); timeout_counter = 0; - + CartridgeStateUpdate(activeCart, CARTRIDGE_STATE__Error, WHS_GetCartridgeFillPercent()); } break; default: @@ -503,7 +525,7 @@ void Waste_StateMachine(void) break; } } -uint32_t Waste_CheckState(void) +uint32_t Waste_CheckState(int *AlarmId) { //check if the waste is ready to run - waste level not above overflow level and no cartridge in the slots if (wasteLevel > wasteLevelOverflow) @@ -512,6 +534,7 @@ uint32_t Waste_CheckState(void) JobEndReason = JOB_SAFETY_CRITICAL_ALARM; usnprintf(AlarmReasonStr, 100, "cannot start a job with waste tank overflow"); AlarmHandlingSetAlarm( EVENT_TYPE__WASTE_CONTAINER_OVERFLOW, true); + *AlarmId = EVENT_TYPE__WASTE_CONTAINER_OVERFLOW; //PrepareReady(Module_Waste,ModuleFail); return JOB_SAFETY_CRITICAL_ALARM; } @@ -525,11 +548,13 @@ uint32_t Waste_CheckState(void) Report("cannot start a job with cartridges in the IFS", __FILE__, __LINE__, wasteLevel, RpMessage, wasteLevelOverflow, 0); JobEndReason = JOB_WASTE_HANDLING_PROBLEM; AlarmHandlingSetAlarm( EVENT_TYPE__ALL_WASTE_CARTRIDGES_FULL, true); + *AlarmId = EVENT_TYPE__ALL_WASTE_CARTRIDGES_FULL; usnprintf(AlarmReasonStr, 100, "cannot start a job with cartridges in the IFS"); //PrepareReady(Module_Waste,ModuleFail); return JOB_WASTE_HANDLING_PROBLEM; } } +int Waste_Prepare_Timeout = 0; bool WHS_FlowReady = false,HeadIn_FlowReady = false,HeadOut_FlowReady = false; uint32_t WasteReadyControlId = 0xFF; float AllowedRangeForHeadBlowerDeviation = 0.07,AllowedRangeForWasteBlowerDeviation = 0.20; @@ -565,7 +590,7 @@ uint32_t Waste_PrepareCallbak(uint32_t IfIndex, uint32_t ReadValue) Report("Module waste HeadOut_FlowReady ready", __FILE__, __LINE__, (int)(HeadOut_Flow*100), RpMessage, WHS_FlowReady, 0); HeadOut_FlowReady = true; } - if (Head_Type <HEAD_TYPE_FLAT) + if (Head_Type <=HEAD_TYPE_FLAT) headready = true; else if ((HeadIn_FlowReady == true)&&(HeadOut_FlowReady == true)) headready = true; @@ -575,6 +600,17 @@ uint32_t Waste_PrepareCallbak(uint32_t IfIndex, uint32_t ReadValue) whsready = true; if ((headready == true)&&(whsready == true)) ready = true; + if ((Waste_Prepare_Timeout%30 == 0)||(Waste_Prepare_Timeout>250)) + { + Report("Module waste preparing values", __FILE__, (int)(HeadFlow*100), (int)(HeadIn_Flow*100), RpMessage, (int)(HeadOut_Flow*100), 0); + } + if (Waste_Prepare_Timeout++>300) + { + SafeRemoveControlCallback(WasteReadyControlId,Waste_PrepareCallbak); + WasteReadyControlId = 0xFF; + Report("Module waste prepare failed!", __FILE__, __LINE__, headready, RpMessage, headready, 0); + PrepareReady(Module_Waste,ModuleFail); + } if (ready == true) { SafeRemoveControlCallback(WasteReadyControlId,Waste_PrepareCallbak); @@ -590,6 +626,7 @@ uint32_t Waste_Prepare(void) WHS_FlowReady = false;HeadIn_FlowReady = false;HeadOut_FlowReady = false; if (WasteReadyControlId != 0xFF) RemoveControlCallback(WasteReadyControlId,Waste_PrepareCallbak); + Waste_Prepare_Timeout = 0; //check that blowers are within 10% of designated flow: WHS, head blowers WasteReadyControlId = AddControlCallback("Cartridge Cover Door", Waste_PrepareCallbak, eOneSecond, TemplateDataReadCBFunction, 0, 0, 0); Report("Module waste prepare", __FILE__, __LINE__, Head_Type, RpMessage, WHS_Type, 0); @@ -609,6 +646,7 @@ bool WHS_IsVocPpmOverAlarmLimit() if( ( Latest_Gas_Sens_PPM > VocPpmAlarmLimit ) || //PPM ( (Latest_Gas_Sens_PPM > VocPpmAlarmLimit90Percent) && (ReadingVocEverySec == true) ) ) //Hysteresis { + //Report("VOC nearing alarm state", __FILE__, (int)(Latest_Gas_Sens_PPM*100), VocPpmAlarmLimit, RpMessage, counter, 0); //reading every sec ReadingVocEverySec = true; if(counter < 0xFF) @@ -616,11 +654,11 @@ bool WHS_IsVocPpmOverAlarmLimit() counter++; } - if(counter > VocPpmLimitForXSec)//Sec + /*if(counter > VocPpmLimitForXSec)//Sec { AlarmHandlingSetAlarm(EVENT_TYPE__VOC_SENSOR_ALARM_SLOPE,true); return true;//Buzzer ON if defined - } + }*/ } else { diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/newWHS_init.c b/Software/Embedded_SW/Embedded/Modules/Waste/newWHS_init.c index 614fd05eb..070f3c7e7 100644 --- a/Software/Embedded_SW/Embedded/Modules/Waste/newWHS_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Waste/newWHS_init.c @@ -86,10 +86,6 @@ bool newWHS_init(void) //Set_All_WHS_Fans(0xFF); // delayms(4000); //Trigger_SetWHSBlowerVoltage (0x0C00); - //Task_sleep(1); - //InitConsole_WHS_UART3();//WHS Shinko communication - - return status; } diff --git a/Software/Embedded_SW/Embedded/Software Release Notes.txt b/Software/Embedded_SW/Embedded/Software Release Notes.txt index 32df32c54..5a9bb858f 100644 --- a/Software/Embedded_SW/Embedded/Software Release Notes.txt +++ b/Software/Embedded_SW/Embedded/Software Release Notes.txt @@ -1,3 +1,46 @@ +Embedded SW Release note - Version 1.5.1(2) - Pack 3 +============================================================= +timeout for waste prepare (+logs) +mcu==> keepalive testing + USB restart WORKS +RFID task for development +machine ambient temperature deciaml points +machine status - return to PREPARING after a jog while heating + + +Embedded SW Release note - Version 1.5.1(1) - Pack 3 +============================================================= +chunk size 4096 - check transfer time +keep alive started; fixed keep alive failure on file analysis +fixed pressure sensors V0 read on init +improved error log file +Flash savings - but embedded parameter changing requires reset +removed old VOC code +removed VOC alarms until hrdware is debugged +Alarm reason om job failures +prevent all WHS changes on old whs +fixed LEDs handling +not homing lubricant after jobs + + +Embedded SW Release note - Version 1.5.1(0) - Pack 3 +============================================================= +Memory saving - removal of unused and unnecessary code. +tasks priorities fixed. +shinko reading fixed. +MCU keepalive activated. +fix bug #3928 in alarm handling job prepare +embedded parameters control for: + Power-Off Disable Cleaning + sublimation blower activity time + Allowed Range For Head Blower Deviation; + Allowed Range For Waste Blower Deviation; +fix machine state bug +arc heaters and blowers PID and alarms +dispensers valves open - fixed +block power down request when power down is active +fix job reporting on prepare and prepare failure + + Embedded SW Release note - Version 1.5.0.1 - Pack 3 ============================================================= *ARC head: Identification, Initialization, Configuration, Heaters, Blowers, temperature and air flow control, cleaning, Alarm handling diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c index 399831531..0c007f755 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c @@ -252,14 +252,20 @@ uint32_t InitSequenceBlowerCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) if (ResetReason & SYSCTL_CAUSE_POR) { V0[0] = PressureSensorInit(0); V0[1] = PressureSensorInit(1); - ReportWithPackageFilter(InitFilter,"store pressure sensor v0[0],v0[1]", __FILE__,__LINE__, (int)V0[0], RpMessage, (int)V0[1], 0); - if (V0[0] > 0) { + ReportWithPackageFilter(InitFilter,"read pressure sensor v0[0],v0[1]", __FILE__,__LINE__, (int)V0[0], RpMessage, (int)V0[1], 0); + if (V0[0] > 1000) { MCU_E2PromProgram(EEPROM_ORIFICE1_ZERO_VALUE, V0[0]); ReportWithPackageFilter(InitFilter,"store pressure sensor v0[0]", __FILE__,__LINE__, (int)V0[0], RpMessage, 0, 0); + } else { + MCU_E2PromRead(EEPROM_ORIFICE1_ZERO_VALUE, &V0[0]); + ReportWithPackageFilter(InitFilter,"load from EEPROM", __FILE__,__LINE__, (int)V0[0], RpMessage, 0, 0); } - if (V0[1] > 0) { + if (V0[1] > 1000) { MCU_E2PromProgram(EEPROM_ORIFICE1_ZERO_VALUE, V0[1]); ReportWithPackageFilter(InitFilter,"store pressure sensor v0[1]", __FILE__,__LINE__, (int)V0[1], RpMessage, 0, 0); + } else { + MCU_E2PromRead(EEPROM_ORIFICE1_ZERO_VALUE, &V0[1]); + ReportWithPackageFilter(InitFilter,"load from EEPROM", __FILE__,__LINE__, (int)V0[1], RpMessage, 0, 0); } } else { MCU_E2PromRead(EEPROM_ORIFICE1_ZERO_VALUE, &V0[0]); @@ -620,7 +626,7 @@ uint32_t InitSequenceStartHeating(void) TimerMotors_t MotorId = HARDWARE_MOTOR_TYPE__MOTO_DH_LID; SetMachineReadyForHeating(true); - Shinko_Read = true; + if(Head_Type == HEAD_TYPE_ARC) { MotorMovetoLimitSwitch(MotorId,1-MotorsCfg[MotorId].directionthreadwize, 30, Motor_Id_to_LS_IdDown[MotorId], cleaningMotorCBFunction,30000); } else if(Head_Type == HEAD_TYPE_FLAT){ diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c index dc7c09499..3a0c94e27 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c @@ -363,6 +363,7 @@ uint32_t PowerOffStopRunningJob(void) { REPORT_MSG (PowerOffMachineState, "Stop running job"); JobEndReason = JOB_ABORTED_BY_USER; + usnprintf(AlarmReasonStr, 100, "Power off pressed"); AbortJob("Power off pressed"); } PowerOffMachineState++; diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index ca859f390..7a8265cbb 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -391,7 +391,7 @@ uint32_t ThreadJoggingFunc(int speed) if ((JobIsActive() == true)||(JoggingJobActive == true)||(MachineReadyForHeating == false)||(FPGABurningActive==true)) { status = ERROR; - Report("Jog JobIsActive", __FILE__, __LINE__, JobIsActive(), RpWarning, JoggingJobActive, 0); + Report("Jog JobIsActive or machine initialisation", __FILE__, __LINE__, JobIsActive(), RpWarning, JoggingJobActive, 0); } else { @@ -1014,11 +1014,14 @@ void JobRequestFunc(MessageContainer* requestContainer) responseContainer = createContainer(MESSAGE_TYPE__JobResponse, JobToken, true, &response, &job_response__pack, &job_response__get_packed_size); responseContainer.has_error = true; responseContainer.error = error; + if (strlen(ErrorMsg)) + responseContainer.errormessage = ErrorMsg; container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); } if (container_buffer) { size_t container_size = message_container__pack(&responseContainer, container_buffer); + ErrorMsg[0] = 0; my_free(responseContainer.data.data); SendChars((char*)container_buffer, container_size); //We keep the job request until it is done @@ -1152,6 +1155,8 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes { responseContainer.has_error = true; responseContainer.error = JobError_to_ErrorCode[JobEndReason]; + if (strlen(ErrorMsg)) + responseContainer.errormessage = ErrorMsg; } if (JobAbortedByUser == true) { @@ -1165,6 +1170,7 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes { size_t container_size = message_container__pack(&responseContainer, container_buffer); // if (SendChars(container_buffer, container_size) == false) //comm tx mailbox full + ErrorMsg[0] = 0; if (SendCharsWithType(container_buffer, container_size,MESSAGE_TYPE__JobResponse) == false) //comm tx mailbox full { //AlarmHandlingToken[0] = 0; @@ -1200,6 +1206,9 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes default: break; } + if (strlen(AlarmReasonStr)) + strncpy(ErrorMsg,AlarmReasonStr,100); + } JobMessageStruc JobMessage; diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c index 3b0844934..9e43bfb07 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c @@ -28,6 +28,7 @@ #include "modules/Heaters/Heaters_ex.h" #include "modules/Diagnostics/Diagnostics.h" #include "modules/ids/ids_ex.h" +#include "Modules/AlarmHandling/AlarmHandling.h" #include "PMR/Hardware/UploadHardWareConfigurationRequest.pb-c.h" #include "PMR/Hardware/HardwareMotorType.pb-c.h" @@ -756,6 +757,7 @@ void PrintSTMMsgHandler(void * msg) if (RewindJobFile() != FR_OK) { JobEndReason = JOB_FILE_PROBLEM; + usnprintf(AlarmReasonStr, 100, "Job file processing error"); if (dryerbufferlength <= 0.1) EndState(CurrentJob, "Job Ended"); else @@ -795,6 +797,7 @@ void PrintSTMMsgHandler(void * msg) else { JobEndReason = JOB_FILE_PROBLEM; + usnprintf(AlarmReasonStr, 100, "Job file processing error"); if (dryerbufferlength <= 0.1) EndState(CurrentJob, "Job Ended"); else @@ -814,6 +817,7 @@ void PrintSTMMsgHandler(void * msg) { Report("SegmentLoading failed",__FILE__,__LINE__, Segment,RpMessage,(int)(Segment->length*100),0); JobEndReason = JOB_FILE_PROBLEM; + usnprintf(AlarmReasonStr, 100, "Job file processing error"); if (dryerbufferlength <= 0.1) EndState(CurrentJob, "Job Ended"); else diff --git a/Software/Embedded_SW/Embedded/embeddedparametersbuild.cs b/Software/Embedded_SW/Embedded/embeddedparametersbuild.cs index 599b192db..6627a4d60 100644 --- a/Software/Embedded_SW/Embedded/embeddedparametersbuild.cs +++ b/Software/Embedded_SW/Embedded/embeddedparametersbuild.cs @@ -140,6 +140,19 @@ double PowerOffDisableCleaning = new Double(); PowerOffDisableCleaning = 0.0 configurationParameters.GeneralParameters.Add(PowerOffDisableCleaning); +double SublimationBlowTime = new Double(); +SublimationBlowTime = 30.0 +configurationParameters.GeneralParameters.Add(SublimationBlowTime); + +double AllowedRangeForHeadBlowerDeviation = new Double(); +AllowedRangeForHeadBlowerDeviation = 7; +configurationParameters.GeneralParameters.Add(AllowedRangeForHeadBlowerDeviation); + +double AllowedRangeForWasteBlowerDeviation = new Double(); +AllowedRangeForWasteBlowerDeviation = 20; +configurationParameters.GeneralParameters.Add(AllowedRangeForWasteBlowerDeviation); + + File.WriteAllBytes("C:/temp/EmbParam.cfg",configurationParameters.ToBytes()); diff --git a/Software/PMR/Messages/EmbeddedParameters/ConfigurationParameters.proto b/Software/PMR/Messages/EmbeddedParameters/ConfigurationParameters.proto index 49d95d1d9..da01452f4 100644 --- a/Software/PMR/Messages/EmbeddedParameters/ConfigurationParameters.proto +++ b/Software/PMR/Messages/EmbeddedParameters/ConfigurationParameters.proto @@ -94,5 +94,6 @@ message ConfigurationParameters double IDS_PreSegment_WFCF_TimeBeforeSegment = 36; uint32 FileVersion = 37; + string Description = 38; } diff --git a/Software/Stubs Collection/Procedures/Winder Calibration.pproj b/Software/Stubs Collection/Procedures/Winder Calibration.pproj index 0f1908344..88b3a0cd1 100644 --- a/Software/Stubs Collection/Procedures/Winder Calibration.pproj +++ b/Software/Stubs Collection/Procedures/Winder Calibration.pproj @@ -1 +1 @@ -{"$id":"1","Name":"Winder Calibration","Visibility":"Public","Description":"This procedure lets the FSE to set the correct location for the winder arm.","Scripts":{"$id":"2","$values":[{"$id":"3","Code":"using System;\r\nusing System.Collections.Generic;\r\nusing System.Collections.ObjectModel;\r\nusing System.ComponentModel;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading;\r\nusing System.Threading.Tasks;\r\nusing System.IO;\r\nusing Google.Protobuf;\r\nusing Tango.BL.Enumerations;\r\nusing Tango.PMR.Stubs;\r\nusing Tango.PMR.Diagnostics;\r\nusing Tango.FSE.Common.Diagnostics;\r\nusing Tango.PMR.IO;\r\nusing Tango.FSE.Procedures;\r\nusing System.IO;\r\nusing System.Windows.Forms;\r\n\r\n\r\n\r\npublic class Program\r\n{\r\n public void OnExecute(IProcedureContext context)\r\n {\r\n\t\tuint SCREW_MOTOR = 14;\r\n\t\tint offset = 200;\r\n\t\tint Calibration_Offset = 0;\r\n\t\tbool Located = false;\r\n\t\tstring box_msg = \"Keep your hands away from the winder\";\r\n\t\tMessageBox.Show(box_msg);\r\n\t\tMotorHomingRequest motorHomingRequest = new MotorHomingRequest();\r\n\t\tmotorHomingRequest.MotorType = Tango.PMR.Hardware.HardwareMotorType.MotoScrew;\r\n\t\tmotorHomingRequest.Speed = 800;\r\n\t\tmotorHomingRequest.Direction = Tango.PMR.Diagnostics.MotorDirection.Forward;\r\n\t\t\r\n \toffset = context.GetInput<int>(\"Initial Offset\");\r\n\r\n\t\tStubMotorMovRequest stubMotorMovRequest = new StubMotorMovRequest();\r\n\t\tstubMotorMovRequest.MotorID = SCREW_MOTOR;\r\n\t\tstubMotorMovRequest.Direction = true;\r\n\t\twhile (Located == false)\r\n\t\t{\r\n\t\t\tcontext.Send<MotorHomingResponse>(motorHomingRequest);\r\n\t\t\tThread.Sleep(3000);\r\n\t\t\tstubMotorMovRequest.Position = (uint)(offset + Calibration_Offset)*8;\r\n\t\t\tcontext.Send<StubMotorMovResponse>(stubMotorMovRequest);\r\n\t\t\tThread.Sleep(3000);\r\n\r\n \tLocated =\tcontext.RequestUserInputFor<bool>(Located,\"Is Winder located well?\",\"Please fill in the form\");\r\n\r\n\t\t\t\r\n\t\t\tif (Located == false)\r\n\t\t\t{\r\n\t\t\t\toffset = context.RequestUserInputFor<int>(Offset,\"Enter new value for calibration offset\",\" (15 steps = 1mm. minus - toward the machine\");\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tProgressRequest progressRequest = new ProgressRequest();\r\n\t\tprogressRequest.Amount = 0xB20;\r\n\t\tprogressRequest.Delay = Calibration_Offset;\r\n\t\tcontext.Send<ProgressResponse>(progressRequest);\r\n\t\tbox_msg = \"Writing new winder offset \" + Calibration_Offset+ \"to the main card EEPROM\";\r\n\t\tMessageBox.Show(box_msg);\r\n\r\n }\r\n}","Name":"Program.csx","IsEntryPoint":true},{"$id":"4","Code":"using System;\r\nusing System.Collections.Generic;\r\nusing System.Collections.ObjectModel;\r\nusing System.ComponentModel;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading;\r\nusing System.Threading.Tasks;\r\nusing Google.Protobuf;\r\nusing Tango.BL.Enumerations;\r\nusing Tango.PMR.Stubs;\r\nusing Tango.PMR.Diagnostics;\r\nusing Tango.FSE.Common.Diagnostics;\r\nusing Tango.FSE.Procedures;\r\n\r\npublic class Service\r\n{\r\n public double Calc(double a, double b)\r\n {\r\n return a + b;\r\n }\r\n}","Name":"Service.csx","IsEntryPoint":false}]},"Inputs":{"$id":"5","$values":[{"$id":"6","Type":"Default","SelectionInputs":{"$id":"7","$values":[{"$id":"8","Name":"Enable Tamper Check","Value":"1.0"},{"$id":"9","Name":"Disable Tamper Check","Value":"0.0"}]},"DisplayName":"Initial offset","Description":"Initial offset for the winder arm","Key":"Initial Offset","Value":"200"},{"$id":"10","Type":"Boolean","SelectionInputs":{"$id":"11","$values":[]},"DisplayName":"Located","Description":"is winder located correctly?","Key":"Located","Value":"0"},{"$id":"12","Type":"Default","SelectionInputs":{"$id":"13","$values":[]},"DisplayName":"Calibration offset","Description":"Controls the 3 parameter.","Key":"Offset","Value":"0"}]},"Variables":{"$id":"14","$values":[]},"ReferenceAssemblies":{"$id":"15","$values":[{"$id":"16","File":"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\mscorlib.dll","HintType":"System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"},{"$id":"17","File":"C:\\WINDOWS\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Core\\v4.0_4.0.0.0__b77a5c561934e089\\System.Core.dll","HintType":"System.Linq.Enumerable, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"},{"$id":"18","File":"C:\\WINDOWS\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Windows.Forms\\v4.0_4.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll","HintType":"System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"},{"$id":"19","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Tango.FSE.Procedures.dll","HintType":"Tango.FSE.Procedures.ProcedureProject, Tango.FSE.Procedures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"},{"$id":"20","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Tango.FSE.Common.dll","HintType":"Tango.FSE.Common.Diagnostics.IDiagnosticsProvider, Tango.FSE.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"},{"$id":"21","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Tango.BL.dll","HintType":"Tango.BL.Enumerations.TechMonitors, Tango.BL, Version=2.0.36.1608, Culture=neutral, PublicKeyToken=null"},{"$id":"22","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Tango.PMR.dll","HintType":"Tango.PMR.Common.MessageType, Tango.PMR, Version=2.0.40.1608, Culture=neutral, PublicKeyToken=null"},{"$id":"23","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Tango.Transport.dll","HintType":"Tango.Transport.ITransporter, Tango.Transport, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"},{"$id":"24","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Tango.Integration.dll","HintType":"Tango.Integration.Operation.IMachineOperator, Tango.Integration, Version=2.0.31.1608, Culture=neutral, PublicKeyToken=null"},{"$id":"25","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Google.Protobuf.dll","HintType":"Google.Protobuf.IMessage, Google.Protobuf, Version=3.4.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604"},{"$id":"26","File":"C:\\WINDOWS\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Drawing\\v4.0_4.0.0.0__b03f5f7f11d50a3a\\System.Drawing.dll","HintType":"System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"}]},"Resources":{"$id":"27","$values":[]},"Dialogs":{"$id":"28","$values":[]},"ID":"2bd29884-5eb9-4d27-be4e-6cfa31dc9f66","ApartmentState":"MTA"}
\ No newline at end of file +{"$id":"1","Name":"Winder Calibration","Visibility":"Public","Description":"This procedure lets the FSE to set the correct location for the winder arm.","Scripts":{"$id":"2","$values":[{"$id":"3","Code":"using System;\r\nusing System.Collections.Generic;\r\nusing System.Collections.ObjectModel;\r\nusing System.ComponentModel;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading;\r\nusing System.Threading.Tasks;\r\nusing System.IO;\r\nusing Google.Protobuf;\r\nusing Tango.BL.Enumerations;\r\nusing Tango.PMR.Stubs;\r\nusing Tango.PMR.Diagnostics;\r\nusing Tango.FSE.Common.Diagnostics;\r\nusing Tango.PMR.IO;\r\nusing Tango.FSE.Procedures;\r\nusing System.IO;\r\nusing System.Windows.Forms;\r\n\r\n\r\n\r\npublic class Program\r\n{\r\n public void OnExecute(IProcedureContext context)\r\n {\r\n\t\tuint SCREW_MOTOR = 14;\r\n\t\tint offset = 200;\r\n\t\tint Calibration_Offset = 0;\r\n\t\tbool Located = false;\r\n\t\tstring box_msg = \"Keep your hands away from the winder\";\r\n\t\tMessageBox.Show(box_msg);\r\n\t\t\r\n\t\tMotorHomingRequest motorHomingRequest = new MotorHomingRequest();\r\n\t\tmotorHomingRequest.MotorType = Tango.PMR.Hardware.HardwareMotorType.MotoScrew;\r\n\t\tmotorHomingRequest.Speed = 800;\r\n\t\tmotorHomingRequest.Direction = Tango.PMR.Diagnostics.MotorDirection.Forward;\r\n\r\n\t\tProgressRequest progressRequest = new ProgressRequest();\r\n\t\tprogressRequest.Amount = 0xB21;\r\n\t\tprogressRequest.Delay = 500;\r\n\t\tcontext.Send<ProgressResponse>(progressRequest);\r\n\t\t\r\n \toffset = 200;//context.GetInput<int>(\"Initial Offset\");\r\n\r\n\t\tStubMotorMovRequest stubMotorMovRequest = new StubMotorMovRequest();\r\n\t\tstubMotorMovRequest.MotorID = SCREW_MOTOR;\r\n\t\tstubMotorMovRequest.Direction = false;\r\n\t\twhile (Located == false)\r\n\t\t{\r\n\t\t\tcontext.Send<MotorHomingResponse>(motorHomingRequest);\r\n\t\t\tThread.Sleep(1000);\r\n\t\t\tstubMotorMovRequest.Position = (uint)((offset + Calibration_Offset)*16);\r\n\t\t\t//stubMotorMovRequest.Direction = \r\n\t\t\tcontext.Send<StubMotorMovResponse>(stubMotorMovRequest);\r\n\t\t\tThread.Sleep(1000);\r\n\r\n \tLocated =\tcontext.RequestUserInputFor<bool>(Located,\"Is Winder located well?\",\"Please fill in the form\");\r\n\r\n\t\t\t\r\n\t\t\tif (Located == false)\r\n\t\t\t{\r\n\t\t\t\tCalibration_Offset = context.RequestUserInputFor<int>(Calibration_Offset,\"Enter new value for calibration offset\",\" (15 steps = 1mm. minus - toward the machine\");\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tprogressRequest.Amount = 0xB20;\r\n\t\tprogressRequest.Delay = Calibration_Offset;\r\n\t\tcontext.Send<ProgressResponse>(progressRequest);\r\n\t\tbox_msg = \"Writing new winder offset \" + Calibration_Offset+ \" to the main card EEPROM\";\r\n\t\t\r\n\t\tprogressRequest.Amount = 0xB21;\r\n\t\tprogressRequest.Delay = 1000000;\r\n\t\tcontext.Send<ProgressResponse>(progressRequest);\r\n\r\n\t\tMessageBox.Show(box_msg);\r\n\r\n }\r\n}","Name":"Program.csx","IsEntryPoint":true},{"$id":"4","Code":"using System;\r\nusing System.Collections.Generic;\r\nusing System.Collections.ObjectModel;\r\nusing System.ComponentModel;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading;\r\nusing System.Threading.Tasks;\r\nusing Google.Protobuf;\r\nusing Tango.BL.Enumerations;\r\nusing Tango.PMR.Stubs;\r\nusing Tango.PMR.Diagnostics;\r\nusing Tango.FSE.Common.Diagnostics;\r\nusing Tango.FSE.Procedures;\r\n\r\npublic class Service\r\n{\r\n public double Calc(double a, double b)\r\n {\r\n return a + b;\r\n }\r\n}","Name":"Service.csx","IsEntryPoint":false}]},"Inputs":{"$id":"5","$values":[]},"Variables":{"$id":"6","$values":[]},"ReferenceAssemblies":{"$id":"7","$values":[{"$id":"8","File":"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\mscorlib.dll","HintType":"System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"},{"$id":"9","File":"C:\\WINDOWS\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Core\\v4.0_4.0.0.0__b77a5c561934e089\\System.Core.dll","HintType":"System.Linq.Enumerable, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"},{"$id":"10","File":"C:\\WINDOWS\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Windows.Forms\\v4.0_4.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll","HintType":"System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"},{"$id":"11","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Tango.FSE.Procedures.dll","HintType":"Tango.FSE.Procedures.ProcedureProject, Tango.FSE.Procedures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"},{"$id":"12","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Tango.FSE.Common.dll","HintType":"Tango.FSE.Common.Diagnostics.IDiagnosticsProvider, Tango.FSE.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"},{"$id":"13","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Tango.BL.dll","HintType":"Tango.BL.Enumerations.TechMonitors, Tango.BL, Version=2.0.36.1608, Culture=neutral, PublicKeyToken=null"},{"$id":"14","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Tango.PMR.dll","HintType":"Tango.PMR.Common.MessageType, Tango.PMR, Version=2.0.40.1608, Culture=neutral, PublicKeyToken=null"},{"$id":"15","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Tango.Transport.dll","HintType":"Tango.Transport.ITransporter, Tango.Transport, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"},{"$id":"16","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Tango.Integration.dll","HintType":"Tango.Integration.Operation.IMachineOperator, Tango.Integration, Version=2.0.31.1608, Culture=neutral, PublicKeyToken=null"},{"$id":"17","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Google.Protobuf.dll","HintType":"Google.Protobuf.IMessage, Google.Protobuf, Version=3.4.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604"},{"$id":"18","File":"C:\\WINDOWS\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Drawing\\v4.0_4.0.0.0__b03f5f7f11d50a3a\\System.Drawing.dll","HintType":"System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"}]},"Resources":{"$id":"19","$values":[]},"Dialogs":{"$id":"20","$values":[]},"ID":"2bd29884-5eb9-4d27-be4e-6cfa31dc9f66","ApartmentState":"MTA"}
\ No newline at end of file diff --git a/Software/Stubs Collection/Procedures/Winder Calibration.txt b/Software/Stubs Collection/Procedures/Winder Calibration.txt index a06e94e31..b73f25e1e 100644 --- a/Software/Stubs Collection/Procedures/Winder Calibration.txt +++ b/Software/Stubs Collection/Procedures/Winder Calibration.txt @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; @@ -29,37 +29,49 @@ public class Program bool Located = false; string box_msg = "Keep your hands away from the winder"; MessageBox.Show(box_msg); + MotorHomingRequest motorHomingRequest = new MotorHomingRequest(); motorHomingRequest.MotorType = Tango.PMR.Hardware.HardwareMotorType.MotoScrew; motorHomingRequest.Speed = 800; - motorHomingRequest.Direction = Tango.PMR.Diagnostics.MotorDirection.Backward; + motorHomingRequest.Direction = Tango.PMR.Diagnostics.MotorDirection.Forward; + + ProgressRequest progressRequest = new ProgressRequest(); + progressRequest.Amount = 0xB21; + progressRequest.Delay = 500; + context.Send<ProgressResponse>(progressRequest); - offset = context.GetInput<int>("Initial Offset"); + offset = 200;//context.GetInput<int>("Initial Offset"); StubMotorMovRequest stubMotorMovRequest = new StubMotorMovRequest(); stubMotorMovRequest.MotorID = SCREW_MOTOR; - stubMotorMovRequest.Direction = true; + stubMotorMovRequest.Direction = false; while (Located == false) { context.Send<MotorHomingResponse>(motorHomingRequest); - Thread.Sleep(3000); - stubMotorMovRequest.Position = (uint)(offset + Calibration_Offset); + Thread.Sleep(2000); + stubMotorMovRequest.Position = (uint)((offset + Calibration_Offset)*16); + //stubMotorMovRequest.Direction = context.Send<StubMotorMovResponse>(stubMotorMovRequest); - Thread.Sleep(3000); + Thread.Sleep(1000); + Located = context.RequestUserInputFor<bool>(Located,"Is Winder located well?","Please fill in the form"); - Located = context.GetInput<bool>("Is Winder located well?"); + if (Located == false) { - offset = context.GetInput<int>("Enter new value for calibration offset (15 steps = 1mm. minus - toward the machine"); + Calibration_Offset = context.RequestUserInputFor<int>(Calibration_Offset,"Enter new value for calibration offset"," (15 steps = 1mm. minus - toward the machine"); } } - ProgressRequest progressRequest = new ProgressRequest(); progressRequest.Amount = 0xB20; progressRequest.Delay = Calibration_Offset; context.Send<ProgressResponse>(progressRequest); - box_msg = "Writing new winder offset " + Calibration_Offset+ "to the main card EEPROM"; + box_msg = "Writing new winder offset " + Calibration_Offset+ " to the main card EEPROM"; + + progressRequest.Amount = 0xB21; + progressRequest.Delay = 1000000; + context.Send<ProgressResponse>(progressRequest); + MessageBox.Show(box_msg); } diff --git a/Software/Stubs Collection/stubs/Scripts/WHS_Test_EEPROM.cs b/Software/Stubs Collection/stubs/Scripts/WHS_Test_EEPROM.cs index 88de4de01..5c3708af7 100644 --- a/Software/Stubs Collection/stubs/Scripts/WHS_Test_EEPROM.cs +++ b/Software/Stubs Collection/stubs/Scripts/WHS_Test_EEPROM.cs @@ -12,9 +12,9 @@ using Tango.Stubs; //---------------------- const Int32 I2C_ID = 3; //MCU_I2C3 -const Int32 TCA9548A_address = 0xE2; +const Int32 TCA9548A_address = 0xE0; const Int32 I2C_Slave_Add = 0xA0; // //eeprom address - 32kByte -int Head_Mux_Channel_ID = 0; //WHS MUX channel +int Head_Mux_Channel_ID = 1; //WHS MUX channel //---------------------- diff --git a/Software/Stubs Collection/stubs/embeddedparametersbuild_w_cleaning.cs b/Software/Stubs Collection/stubs/embeddedparametersbuild_w_cleaning.cs index 6627a4d60..7319b8f41 100644 --- a/Software/Stubs Collection/stubs/embeddedparametersbuild_w_cleaning.cs +++ b/Software/Stubs Collection/stubs/embeddedparametersbuild_w_cleaning.cs @@ -137,11 +137,11 @@ SetAutoFill = 3.0; configurationParameters.GeneralParameters.Add(SetAutoFill); double PowerOffDisableCleaning = new Double(); -PowerOffDisableCleaning = 0.0 +PowerOffDisableCleaning = 0.0; configurationParameters.GeneralParameters.Add(PowerOffDisableCleaning); double SublimationBlowTime = new Double(); -SublimationBlowTime = 30.0 +SublimationBlowTime = 30.0; configurationParameters.GeneralParameters.Add(SublimationBlowTime); double AllowedRangeForHeadBlowerDeviation = new Double(); @@ -149,7 +149,7 @@ AllowedRangeForHeadBlowerDeviation = 7; configurationParameters.GeneralParameters.Add(AllowedRangeForHeadBlowerDeviation); double AllowedRangeForWasteBlowerDeviation = new Double(); -AllowedRangeForWasteBlowerDeviation = 20; +AllowedRangeForWasteBlowerDeviation = 10; configurationParameters.GeneralParameters.Add(AllowedRangeForWasteBlowerDeviation); diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.cpp b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.cpp index d501046a4..23be99668 100644 --- a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.cpp +++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.cpp @@ -55,7 +55,7 @@ #define dETol 2.0 # define ROUNDINGDigits 2.0 #define maxPerRegion 100.0 -#define LowVolumeThreshold 0.0 +#define LowVolumeThreshold 0.5 #define LowVolHalf LowVolumeThreshold/2 #define GradientEndThr 0.95 @@ -65,7 +65,8 @@ Tango::ColorLib::ColorConverter::ColorConverter() : m_maxNlPerCM(NULL), m_nInks(0), m_nVolumes(0), m_GradStops(NULL), m_nGradStops(0), m_colortable(NULL), m_ProcessRangesMaxP(NULL), - m_nProcessRanges(0), m_NormGamutRegionMaxLim(NULL) + m_nProcessRanges(0), m_NormGamutRegionMaxLim(NULL), m_LowVolThr_nlcm(NULL), + m_LowVolThrHalf_nlcm(NULL) { m_whitepointLab.Set(-1, -1, -1); m_whitepointXYZ_Strip.Set(-1, -1, -1); @@ -104,6 +105,17 @@ Tango::ColorLib::ColorConverter::~ColorConverter() delete[] m_ProcessRangesMaxP; m_ProcessRangesMaxP = NULL; } + if (m_LowVolThr_nlcm != NULL) + { + delete[]m_LowVolThr_nlcm; + m_LowVolThr_nlcm = NULL; + } + + if (m_LowVolThrHalf_nlcm != NULL) + { + delete[]m_LowVolThrHalf_nlcm; + m_LowVolThrHalf_nlcm = NULL; + } /* if (m_ProcessRangesMinP != NULL) { delete[] m_ProcessRangesMinP; @@ -244,10 +256,13 @@ void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(ConversionInput *conv //Limit inks based on m_maxNlpercm //Inks are limited in their nonlinear form //Output Volume is in % - LimitInks(NLInkOut, InkOutP); + /* LimitInks(NLInkOut, InkOutP); NLInkPToVolume(DoubleToVector(InkOutP, m_nInks), Vol); GamutRegion[i] = GetGamutRegion(Vol, m_ProcessRangesMaxP); - NLcmtoPercentage(Vol, Vol); + LimitLowVolume(Vol, GamutRegion[i], Vol); + NLcmtoPercentage(Vol, Vol); */ + LimitNLInks2Volume(NLInkOut, GamutRegion[i], Vol); + //m_A2BTransform->evalInkP2Lab(InkOut, Lab1P, GamutRegion[i]); //Convert to CT WP @@ -1115,65 +1130,6 @@ void Tango::ColorLib::ColorConverter::NLInkPToVolume(VectorXd NLInk, VectorXd &V for (int i = 0; i < m_nInks; ++i) Volume(i) = RVolNorm(i); } - for (int i = 0; i < m_nInks; ++i) - { - if (Volume(i) < LowVolHalf) - Volume(i) = 0; - else if (Volume(i) >= LowVolHalf && Volume(i) <= LowVolumeThreshold) - Volume(i) = LowVolumeThreshold; - } - - /* int countBelowThresh=0; - int *indBelowThresh= new int[m_nInks]; - for (int i = 0; i < m_nInks; ++i) - { - if (Volume(i) < LowVolumeThreshold) - { - countBelowThresh++; - indBelowThresh[i] = i; - } - } - if (countBelowThresh == 0) - { - delete[] indBelowThresh; - indBelowThresh = NULL; - } - else - { - int pow2ThCount = pow(2, countBelowThresh); - double **THTable = new double*[pow2ThCount]; - for (int i = 0; i < pow2ThCount; ++i) - THTable[i] = new double[m_nInks]; - for (int j = 0; j < pow2ThCount; ++j) - for (int i = 0; i < m_nInks; ++i) - THTable[j][i] = Volume(i); - - int indC = -1; - for (int i = 0; i < m_nInks; ++i) - { - for (int j = 0; j < countBelowThresh; ++i) - { - indC = indC + 1; - THTable[indC][i] = 0; - indC = indC + 1; - THTable[indC][i] = LowVolumeThreshold; - } - } - //Calculate dE between NLInk and THTable converted to NLInk - //Choose the value with the smallest dE - VectorXd VolumeTh(m_nInks); - VectorXd NLInksTh(m_nInks); - for (int j = 0; j < pow2ThCount; ++j) - { - for (int j = 0; j < m_nInks; ++j) - VolumeTh(j) = THTable[j][i]; - VolumeToNLInkP(VolumeTh, NLInksTh); - - - } - - }*/ - return; } @@ -1258,7 +1214,9 @@ void Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(InputCoordinates LimitInks(NLInkP, InkOutP); NLInkPToVolume(DoubleToVector(InkOutP, m_nInks), Volume); GamutRegion = GetGamutRegion(Volume, m_ProcessRangesMaxP); +// LimitLowVolume(Volume, GamutRegion, Volume); NLcmtoPercentage(Volume, Volume); +// LimitNLInks2Volume(NLInkP, GamutRegion, Volume); VolumeToNLInkP(Volume, NLInkP); VectorToDouble(NLInkP, InkOutP); //Convert to RGB @@ -1462,6 +1420,7 @@ size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t i m_ProcessRangesMaxP[i] = conversionInput->processranges[i]->maxinkuptake; } + SetLowVolThr_nlcm(); VectorXd InkOut(m_nInks); VectorXd RGBOut(3); VectorXd LabOut(3); @@ -1495,17 +1454,19 @@ size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t i //Limit inks based on m_maxNlpercm //Inks are limited in their nonlinear form //Output Volume is in % - double *InkOutP = new double[m_nInks]; - LimitInks(NLInkOut, InkOutP); + // double *InkOutP = new double[m_nInks]; + /* LimitInks(NLInkOut, InkOutP); NLInkPToVolume(DoubleToVector(InkOutP, m_nInks), Volume); GamutRegion = GetGamutRegion(Volume, m_ProcessRangesMaxP); - NLcmtoPercentage(Volume, Volume); + LimitLowVolume(Volume, GamutRegion, Volume); + NLcmtoPercentage(Volume, Volume);*/ + LimitNLInks2Volume(NLInkOut, GamutRegion, Volume); //OutputCoordinates outputCoords = OUTPUT_COORDINATES__INIT; - if (InkOutP != NULL) + /* if (InkOutP != NULL) { delete[] InkOutP; InkOutP = NULL; - } + }*/ } OutputCoordinates *outputCoords = (OutputCoordinates*)malloc(sizeof(OutputCoordinates)); @@ -2542,7 +2503,7 @@ void Tango::ColorLib::ColorConverter::findStops(Gradient &GradStop1, Gradient &G } } if(indGrad<ninterstops) - nOut = indGrad; + nOut = indGrad +1; else { throw std::exception("Number of subdivisions exceed allocation"); @@ -2723,17 +2684,19 @@ void Tango::ColorLib::ColorConverter::ConvertGradStoptoVolume(InputCoordinates* } VectorXd NLInkOut(m_nInks); VectorXd VolumeOut(m_nInks); - double *InkOutL = new double[m_nInks]; +/* double *InkOutL = new double[m_nInks];*/ ConvertToNLInks(InkOut, NLInkOut); - LimitInks(NLInkOut, InkOutL); +/* LimitInks(NLInkOut, InkOutL); // InkOutL in [nl/cm] NLInkPToVolume(DoubleToVector(InkOutL, m_nInks), Volume); GamutRegion = GetGamutRegion(Volume, m_ProcessRangesMaxP); - NLcmtoPercentage(Volume, Volume); - if (InkOutL != NULL) + LimitLowVolume(Volume, GamutRegion, Volume); + NLcmtoPercentage(Volume, Volume);*/ + LimitNLInks2Volume(NLInkOut, GamutRegion, Volume); +/* if (InkOutL != NULL) { delete[] InkOutL; InkOutL = NULL; - } + }*/ return; } @@ -2813,7 +2776,7 @@ void Tango::ColorLib::ColorConverter::PrepareGradient(GradientConversionInput* c { m_ProcessRangesMaxP[i] = conversionInput->processranges[i]->maxinkuptake; } - + SetLowVolThr_nlcm(); VectorXd InkOut(m_nInks); VectorXd RGBOut(3); VectorXd LabOut(3); @@ -3157,6 +3120,40 @@ void Tango::ColorLib::ColorConverter::NLcmtoPercentage(VectorXd InVolume, Vector OutVolume(i) =100* InVolume(i) / m_maxNlPerCM(i); } +void Tango::ColorLib::ColorConverter::LimitLowVolume(VectorXd InVolume, int &GamutRegion, VectorXd &OutVolume) +{ + int indGR = 0; + //Find Gamut Region + for (int i = 1; i < m_nProcessRanges; ++i) + { + if (GamutRegion == i) + indGR = i; + } + //Limit Volume based on Gamut Region + double sumVol = 0; + for (int i = 0; i < m_nInks; ++i) + { + if (InVolume(i) >= m_LowVolThr_nlcm[indGR]) + OutVolume(i) = InVolume(i); + else if (InVolume(i) < m_LowVolThrHalf_nlcm[indGR]) + OutVolume(i) = 0.0; + else + OutVolume(i) = m_LowVolThr_nlcm[indGR]; + sumVol += OutVolume(i); + } + //recalculate GamutRegion + if (indGR == 0) + return; + else + { + for (int i = 1; i < indGR+1; ++i) + { + if((sumVol>m_ProcessRangesMaxP[i-1]) & (sumVol<= m_ProcessRangesMaxP[i ])) + GamutRegion = i; + } + } +} + int Tango::ColorLib::ColorConverter::GetGamutRegion(VectorXd Volume, double *GamutLimits) { double TotalVolume = 0.0; @@ -3233,10 +3230,12 @@ void Tango::ColorLib::ColorConverter::ProcessGradientStops(InputCoordinates **in C_RGB_XYZ_Lab Lab(LabOutV[0], LabOutV[1], LabOutV[2]); C_RGB_XYZ_Lab RGB(RGBOut); ConvertToNLInks(InkOut, NLInkOut); - LimitInks(NLInkOut, InkOutL); + /* LimitInks(NLInkOut, InkOutL); NLInkPToVolume(DoubleToVector(InkOutL, m_nInks), Volume); GamutRegion = GetGamutRegion(Volume, m_ProcessRangesMaxP); - NLcmtoPercentage(Volume, Volume); + LimitLowVolume(Volume, GamutRegion, Volume); + NLcmtoPercentage(Volume, Volume);*/ + LimitNLInks2Volume(NLInkOut, GamutRegion, Volume); //fill data //fill volume //allocate m_GradStops[i].Volume @@ -3295,4 +3294,36 @@ bool Tango::ColorLib::ColorConverter::CheckLabInRGBGamut( C_RGB_XYZ_Lab Lab) if (dE < 0.01) retVal = true; return(retVal); -}
\ No newline at end of file +} + +void Tango::ColorLib::ColorConverter::SetLowVolThr_nlcm() +{ + if (m_LowVolThr_nlcm == NULL) + m_LowVolThr_nlcm = new double[m_nProcessRanges]; + if(m_LowVolThrHalf_nlcm == NULL) + m_LowVolThrHalf_nlcm = new double[m_nProcessRanges]; + //fill thresholds + for (int i = 0; i < m_nProcessRanges; ++i) + { + m_LowVolThr_nlcm[i] = LowVolumeThreshold * m_ProcessRangesMaxP[i]/100; + m_LowVolThrHalf_nlcm[i] = LowVolHalf * m_ProcessRangesMaxP[i]/100; + } +} + +void Tango::ColorLib::ColorConverter::LimitNLInks2Volume(VectorXd NLInks, int &GamutRegion, VectorXd &Volume) +{ + VectorXd NLInkOut(m_nInks); + double *InkOutL = new double[m_nInks]; + ConvertToNLInks(NLInks, NLInkOut); + LimitInks(NLInkOut, InkOutL); // InkOutL in [nl/cm] + NLInkPToVolume(DoubleToVector(InkOutL, m_nInks), Volume); + GamutRegion = GetGamutRegion(Volume, m_ProcessRangesMaxP); + LimitLowVolume(Volume, GamutRegion, Volume); + NLcmtoPercentage(Volume, Volume); + + if (InkOutL != NULL) + { + delete[]InkOutL; + InkOutL = NULL; + } +} diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.h b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.h index 03dc7d381..af621a082 100644 --- a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.h +++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.h @@ -85,6 +85,7 @@ namespace Tango void VolumeToNLInkP(VectorXd Volume, VectorXd &NLInkP); void NLInkPToVolume(VectorXd NLInkP, VectorXd &Volume); void SetMaxNLperCM(double maxNlPerCM, int i); + void SetLowVolThr_nlcm(); size_t P_IsInGamut(uint8_t * input_buffer, size_t input_buffer_size, uint8_t *& output_buffer); private: ColorTable *m_colortable; @@ -108,6 +109,8 @@ namespace Tango //double *m_ProcessRangesMinInkUptake; C_RGB_XYZ_Lab m_WP; VectorXd m_maxNlPerCM; + double *m_LowVolThr_nlcm; + double *m_LowVolThrHalf_nlcm; void readColorTransformations(ConversionInput* conversionInput); // void readColorTables(bool has_rddata, uint8_t *data, int nprocessranges); void readCalibrationTables(InputLiquid **inputliquids, int n_inputliquids); @@ -156,6 +159,8 @@ namespace Tango void ConvertCMYKColorToLinearInks(InputCoordinates* inputcoordinates, VectorXd &InkOut, VectorXd &RGBOut, VectorXd &LabOut, int &GamutRegion, bool &InGamut, SURROUND sur, CAM02CS CS); + void LimitLowVolume(VectorXd InVolume, int &GamutRegion, VectorXd &OutVolume); + void LimitNLInks2Volume(VectorXd NLInks, int &GamutRegion, VectorXd &OutVolume); }; } } diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/ColorConvert.cpp b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/ColorConvert.cpp index 4dbedae96..f66447d2c 100644 --- a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/ColorConvert.cpp +++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/ColorConvert.cpp @@ -2,6 +2,7 @@ #include <cmath> #include <algorithm> +using namespace std; /*#define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> @@ -855,7 +856,7 @@ for (int i = 0; i < 3; ++i) //Step 7: achromatic response : -double A = (2*LMSp_a(0) + LMSp_a(1) +(1 / 20)*LMSp_a(2) - 0.305)* m_ParamsCIECam02.N_bb; +double A = std::max((2*LMSp_a(0) + LMSp_a(1) +(1 / 20)*LMSp_a(2) - 0.305)* m_ParamsCIECam02.N_bb, 0.0); //Step 8: correlate of lightness : diff --git a/Software/Visual_Studio/Tango.ColorLib.GradientTest.CLI/Program.cs b/Software/Visual_Studio/Tango.ColorLib.GradientTest.CLI/Program.cs index f054057d2..437ae1df0 100644 --- a/Software/Visual_Studio/Tango.ColorLib.GradientTest.CLI/Program.cs +++ b/Software/Visual_Studio/Tango.ColorLib.GradientTest.CLI/Program.cs @@ -79,9 +79,9 @@ namespace Tango.ColorLib.GradientTest.CLI { ColorSpace = ColorSpace.Rgb, Offset = 0, - Red = 25, - Green = 139, - Blue = 246, + Red = 255, + Green = 0, + Blue = 0, /* ColorSpace = ColorSpace.Lab, Offset = 0, L=44, @@ -99,10 +99,10 @@ namespace Tango.ColorLib.GradientTest.CLI input.Stops.Add(new GradientInputStop() { ColorSpace = ColorSpace.Rgb, - Offset = 0.3, - Red = 255, - Green = 144, - Blue = 40, + Offset =0.5, + Red =0, + Green =255, + Blue = 0, //ColorSpace = ColorSpace.Lab, // Offset = 0.3, // L = 80.092825, @@ -115,85 +115,94 @@ namespace Tango.ColorLib.GradientTest.CLI // Yellow = 0, // Key = 0, }); - //Volume Stop 3 - GradientInputStop a = new GradientInputStop() - { - ColorSpace = ColorSpace.Volume, - Offset = 1.0, - }; - a.LiquidVolumes.Add(new LiquidVolume() - { - LiquidType = LiquidType.Cyan, - Volume = 100 - }); - a.LiquidVolumes.Add(new LiquidVolume() - { - LiquidType = LiquidType.Magenta, - Volume = 0 - }); - a.LiquidVolumes.Add(new LiquidVolume() - { - LiquidType = LiquidType.Yellow, - Volume = 0 - }); - a.LiquidVolumes.Add(new LiquidVolume() - { - LiquidType = LiquidType.Black, - Volume = 0 - }); - input.Stops.Add(a); - /* GradientInputStop c = new GradientInputStop() - { - ColorSpace = ColorSpace.Volume, - Offset = 0.5, - }; - c.LiquidVolumes.Add(new LiquidVolume() - { - LiquidType = LiquidType.Cyan, - Volume = 0 - }); - c.LiquidVolumes.Add(new LiquidVolume() - { - LiquidType = LiquidType.Magenta, - Volume = 100 - }); - c.LiquidVolumes.Add(new LiquidVolume() - { - LiquidType = LiquidType.Yellow, - Volume = 0 - }); - c.LiquidVolumes.Add(new LiquidVolume() - { - LiquidType = LiquidType.Black, - Volume = 0 - }); - input.Stops.Add(c); - GradientInputStop b = new GradientInputStop() - { - ColorSpace = ColorSpace.Volume, - Offset = 1.0, - }; - b.LiquidVolumes.Add(new LiquidVolume() - { - LiquidType = LiquidType.Cyan, - Volume = 0 - }); - b.LiquidVolumes.Add(new LiquidVolume() - { - LiquidType = LiquidType.Magenta, - Volume = 80 - }); - b.LiquidVolumes.Add(new LiquidVolume() - { - LiquidType = LiquidType.Yellow, - Volume = 20 - }); - b.LiquidVolumes.Add(new LiquidVolume() + //RGB Stop 2 + input.Stops.Add(new GradientInputStop() { - LiquidType = LiquidType.Black, - Volume = 0 + ColorSpace = ColorSpace.Rgb, + Offset = 1, + Red = 0, + Green = 255, + Blue = 255, }); - input.Stops.Add(b);*/ + /* //Volume Stop 3 + GradientInputStop a = new GradientInputStop() + { + ColorSpace = ColorSpace.Volume, + Offset = 1.0, + }; + a.LiquidVolumes.Add(new LiquidVolume() + { + LiquidType = LiquidType.Cyan, + Volume = 100 + }); + a.LiquidVolumes.Add(new LiquidVolume() + { + LiquidType = LiquidType.Magenta, + Volume = 0 + }); + a.LiquidVolumes.Add(new LiquidVolume() + { + LiquidType = LiquidType.Yellow, + Volume = 0 + }); + a.LiquidVolumes.Add(new LiquidVolume() + { + LiquidType = LiquidType.Black, + Volume = 0 + }); + input.Stops.Add(a);*/ + /* GradientInputStop c = new GradientInputStop() + { + ColorSpace = ColorSpace.Volume, + Offset = 0.5, + }; + c.LiquidVolumes.Add(new LiquidVolume() + { + LiquidType = LiquidType.Cyan, + Volume = 0 + }); + c.LiquidVolumes.Add(new LiquidVolume() + { + LiquidType = LiquidType.Magenta, + Volume = 100 + }); + c.LiquidVolumes.Add(new LiquidVolume() + { + LiquidType = LiquidType.Yellow, + Volume = 0 + }); + c.LiquidVolumes.Add(new LiquidVolume() + { + LiquidType = LiquidType.Black, + Volume = 0 + }); + input.Stops.Add(c); + GradientInputStop b = new GradientInputStop() + { + ColorSpace = ColorSpace.Volume, + Offset = 1.0, + }; + b.LiquidVolumes.Add(new LiquidVolume() + { + LiquidType = LiquidType.Cyan, + Volume = 0 + }); + b.LiquidVolumes.Add(new LiquidVolume() + { + LiquidType = LiquidType.Magenta, + Volume = 80 + }); + b.LiquidVolumes.Add(new LiquidVolume() + { + LiquidType = LiquidType.Yellow, + Volume = 20 + }); + b.LiquidVolumes.Add(new LiquidVolume() + { + LiquidType = LiquidType.Black, + Volume = 0 + }); + input.Stops.Add(b);*/ //RGB Stop 4 /* input.Stops.Add(new GradientInputStop() { |
