diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-11-05 19:44:19 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-11-05 19:44:19 +0200 |
| commit | e62a6eef152e02ce5aff62238401280d2cd3c995 (patch) | |
| tree | 37761fd5046751f2e0750e0ab4af6acdf8ac8063 /Software | |
| parent | b9009a814b9c91010e44534b42fa15fe164757a3 (diff) | |
| parent | b41e559ca8801bbf6c71f14aadb00215c80686d5 (diff) | |
| download | Tango-e62a6eef152e02ce5aff62238401280d2cd3c995.tar.gz Tango-e62a6eef152e02ce5aff62238401280d2cd3c995.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software')
25 files changed, 461 insertions, 215 deletions
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 ab651f7de..1ec53d6ec 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,1,3}; +TangoVersion_t _gTangoVersion = {1,5,1,4}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Printing/HeadCleaningParameters.pb-c.c b/Software/Embedded_SW/Embedded/Communication/PMR/Printing/HeadCleaningParameters.pb-c.c index 699470ded..a5fba86d3 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/Printing/HeadCleaningParameters.pb-c.c +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Printing/HeadCleaningParameters.pb-c.c @@ -52,7 +52,7 @@ void head_cleaning_parameters__free_unpacked assert(message->base.descriptor == &head_cleaning_parameters__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } -static const ProtobufCFieldDescriptor head_cleaning_parameters__field_descriptors[1] = +static const ProtobufCFieldDescriptor head_cleaning_parameters__field_descriptors[2] = { { "", @@ -66,14 +66,27 @@ static const ProtobufCFieldDescriptor head_cleaning_parameters__field_descriptor 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, + { + "", + 2, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_DOUBLE, + offsetof(HeadCleaningParameters, has_archeadcleaningmotorspeed), + offsetof(HeadCleaningParameters, archeadcleaningmotorspeed), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, }; static const unsigned head_cleaning_parameters__field_indices_by_name[] = { + 1, /* field[1] = ArcHeadCleaningMotorSpeed */ 0, /* field[0] = CleanerFlow */ }; static const ProtobufCIntRange head_cleaning_parameters__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 1 } + { 0, 2 } }; const ProtobufCMessageDescriptor head_cleaning_parameters__descriptor = { @@ -83,7 +96,7 @@ const ProtobufCMessageDescriptor head_cleaning_parameters__descriptor = "", "", sizeof(HeadCleaningParameters), - 1, + 2, head_cleaning_parameters__field_descriptors, head_cleaning_parameters__field_indices_by_name, 1, head_cleaning_parameters__number_ranges, diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Printing/HeadCleaningParameters.pb-c.h b/Software/Embedded_SW/Embedded/Communication/PMR/Printing/HeadCleaningParameters.pb-c.h index 9213143bb..08c7b7248 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/Printing/HeadCleaningParameters.pb-c.h +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Printing/HeadCleaningParameters.pb-c.h @@ -28,10 +28,12 @@ struct _HeadCleaningParameters ProtobufCMessage base; protobuf_c_boolean has_cleanerflow; double cleanerflow; + protobuf_c_boolean has_archeadcleaningmotorspeed; + double archeadcleaningmotorspeed; }; #define HEAD_CLEANING_PARAMETERS__INIT \ { PROTOBUF_C_MESSAGE_INIT (&head_cleaning_parameters__descriptor) \ - , 0, 0 } + , 0, 0, 0, 0 } /* HeadCleaningParameters methods */ diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Printing/ProcessParameters.pb-c.c b/Software/Embedded_SW/Embedded/Communication/PMR/Printing/ProcessParameters.pb-c.c index 44acaa3ad..a27a2202e 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/Printing/ProcessParameters.pb-c.c +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Printing/ProcessParameters.pb-c.c @@ -52,7 +52,7 @@ void process_parameters__free_unpacked assert(message->base.descriptor == &process_parameters__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } -static const ProtobufCFieldDescriptor process_parameters__field_descriptors[32] = +static const ProtobufCFieldDescriptor process_parameters__field_descriptors[31] = { { "", @@ -426,21 +426,8 @@ static const ProtobufCFieldDescriptor process_parameters__field_descriptors[32] 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, - { - "", - 32, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_DOUBLE, - offsetof(ProcessParameters, has_archeadcleaningmotorspeed), - offsetof(ProcessParameters, archeadcleaningmotorspeed), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, }; static const unsigned process_parameters__field_indices_by_name[] = { - 31, /* field[31] = ArcHeadCleaningMotorSpeed */ 13, /* field[13] = DryerAirFlow */ 17, /* field[17] = DryerBufferLength */ 14, /* field[14] = DryerZone1Temp */ @@ -476,7 +463,7 @@ static const unsigned process_parameters__field_indices_by_name[] = { static const ProtobufCIntRange process_parameters__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 32 } + { 0, 31 } }; const ProtobufCMessageDescriptor process_parameters__descriptor = { @@ -486,7 +473,7 @@ const ProtobufCMessageDescriptor process_parameters__descriptor = "", "", sizeof(ProcessParameters), - 32, + 31, process_parameters__field_descriptors, process_parameters__field_indices_by_name, 1, process_parameters__number_ranges, diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Printing/ProcessParameters.pb-c.h b/Software/Embedded_SW/Embedded/Communication/PMR/Printing/ProcessParameters.pb-c.h index aa762a3d6..9a6453221 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/Printing/ProcessParameters.pb-c.h +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Printing/ProcessParameters.pb-c.h @@ -88,12 +88,10 @@ struct _ProcessParameters double lblowertemp; protobuf_c_boolean has_pressurebuildup; double pressurebuildup; - protobuf_c_boolean has_archeadcleaningmotorspeed; - double archeadcleaningmotorspeed; }; #define PROCESS_PARAMETERS__INIT \ { PROTOBUF_C_MESSAGE_INIT (&process_parameters__descriptor) \ - , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } /* ProcessParameters methods */ diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c index 95651eba2..0b308408c 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c @@ -350,15 +350,15 @@ uint32_t Dryer_Read_Blower_Tach() return RPM; } */ +uint32_t Drayer_Fan_Speed_RPM = 0; +uint32_t Get_Dryer_Fan_Tacho() +{ + return Drayer_Fan_Speed_RPM; +} uint32_t Read_Dryer_Fan_Tacho() { - - uint32_t Drayer_Fan_Speed_RPM = 0; - Drayer_Fan_Speed_RPM = Calculate_Tacho_Fan_Speed(FPGA_Freq, 12, F1_Prescaler1_reg5, F1_Tacho_reg8); - - return Drayer_Fan_Speed_RPM; } diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.h index e660b450a..121211c69 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.h +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.h @@ -15,6 +15,7 @@ void Control_Dryer_Fan_PWM(uint8_t PWM_Command_Precent); void Machine_Idle_Breathing_Led(); uint32_t Read_Dryer_Fan_Tacho(); +uint32_t Get_Dryer_Fan_Tacho(); void Set_Speed_Sensor_TypeII_Registers(uint32_t Counter, uint32_t Prescaler); uint32_t Read_Speed_Sensor_TypeII(); diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c index 495f27652..00502d3ba 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c @@ -905,8 +905,6 @@ void Pumps_Control(PUMPS_ENUM Pump_Id, bool Direction) //1 - OPEN, 0 - CLOSE ?? //F1_GPO_Reg.bits.F1_GPO_WASTECH_PUMP2 = Direction; SecondaryPumpActive = Direction; } - else - LOG_ERROR(WHS_Type,"Pump activated on new whs"); break; case WHS_WTANKPUMP2: #ifndef EVALUATION_BOARD diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index 127ccbabf..e736d45ea 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -1,3 +1,4 @@ + /* * AlarmHandling.c @@ -491,14 +492,14 @@ uint32_t AlarmHandlingLoadFile(void) { FileAlarmItem[F_count].AlarmDirection = AlarmParametersTable->alarmitem[i]->alarmdirection; FileAlarmItem[F_count].AlarmDirection = AlarmParametersTable->alarmitem[i]->alarmdirection; - FileAlarmItem[F_count].Frequency = AlarmParametersTable->alarmitem[i]->frequency; //1/10/100/1000 + //FileAlarmItem[F_count].Frequency = AlarmParametersTable->alarmitem[i]->frequency; //1/10/100/1000 FileAlarmItem[F_count].AlarmSource = AlarmParametersTable->alarmitem[i]->alarmsource; FileAlarmItem[F_count].DeviceId = AlarmParametersTable->alarmitem[i]->deviceid; FileAlarmItem[F_count].ModuleDeviceId = AlarmParametersTable->alarmitem[i]->moduledeviceid; FileAlarmItem[F_count].AlarmValue = AlarmParametersTable->alarmitem[i]->alarmvalue; FileAlarmItem[F_count].AlarmDirection = AlarmParametersTable->alarmitem[i]->alarmdirection; FileAlarmItem[F_count].Severity = AlarmParametersTable->alarmitem[i]->severity; - FileAlarmItem[F_count].Predecessor = AlarmParametersTable->alarmitem[i]->predecessor; + //FileAlarmItem[F_count].Predecessor = AlarmParametersTable->alarmitem[i]->predecessor; FileAlarmItem[F_count].DebounceValue = AlarmParametersTable->alarmitem[i]->debouncevalue; FileAlarmItem[F_count].EventType = AlarmParametersTable->alarmitem[i]->eventtype; FileAlarmItem[F_count].isPersistent = AlarmParametersTable->alarmitem[i]->ispersistent; @@ -1080,7 +1081,7 @@ void AlarmHandlingInternalSetAlarm(uint32_t AlarmId, bool value) if (AlarmItem[Alarm_i].EventType == AlarmId) { //if (0) // PERSISTENT ALARM - if ((AlarmItem[Alarm_i].isPersistent == true)) // PERSISTENT ALARM simulate + if ((AlarmItem[Alarm_i].isPersistent == true)&&(value == true)) // PERSISTENT ALARM simulate Currently looking for "true" value, otherwise the currently existing OFF event appears { if (PersistentEventsResponse.events == NULL) PersistentEventsResponse.events = (Event **)my_malloc(sizeof(Event*)*(PersistentEventsResponse.n_events+1)); @@ -1213,29 +1214,8 @@ uint32_t AlarmHandlingLoop(uint32_t tick) if (AlarmItem[Alarm_i].AlarmSource > ALARM_SOURCE_TYPE__FluidLevelAlarm) continue; AlarmCounter++; - if (tick%AlarmItem[Alarm_i].Frequency == 0) + switch (AlarmItem[Alarm_i].AlarmSource) { - switch (AlarmItem[Alarm_i].AlarmSource) - { - /*case ALARM_SOURCE_TYPE__TemperatureAlarm: - ivalue = MillisecGetTemperatures((TEMPERATURE_SENSOR_ID_ENUM)AlarmItem[Alarm_i].DeviceId); - if (AlarmItem[Alarm_i].AlarmDirection == true) - { - if (ivalue/100 >= AlarmItem[Alarm_i].AlarmValue) - { - //LOG_ERROR (ivalue/100,"Temperature spike"); - Status = true; - } - } - else - { - if (ivalue/100 <= AlarmItem[Alarm_i].AlarmValue) - { - //LOG_ERROR (ivalue/100,"iTemperature spike"); - Status = true; - } - } - break;*/ case ALARM_SOURCE_TYPE__CoversAlarm: if (CheckTamperAlarms) { @@ -1261,14 +1241,6 @@ uint32_t AlarmHandlingLoop(uint32_t tick) if (CheckHardLimitAlarms) { Status = AlarmState[Alarm_i].Status; - /*if (AlarmItem[Alarm_i].AlarmDirection == true) - { - value = Get_Notification_Disp_UP(AlarmItem[Alarm_i].DeviceId); - } - else - { - value = Get_Notification_Disp_Down(AlarmItem[Alarm_i].DeviceId); - } polling in the safety */ } else { @@ -1422,21 +1394,6 @@ uint32_t AlarmHandlingLoop(uint32_t tick) default: Status = false; } - /*value = MotorGetStatus((TimerMotors_t)AlarmItem[Alarm_i].DeviceId); - if (AlarmItem[Alarm_i].AlarmDirection == true) - { - if (value && AlarmItem[Alarm_i].AlarmValue) - { - Status = true; - } - } - else - { - if ((value && AlarmItem[Alarm_i].AlarmValue)==false) - { - Status = true; - } - }*/ } } else @@ -1473,7 +1430,7 @@ uint32_t AlarmHandlingLoop(uint32_t tick) case ALARM_SOURCE_TYPE__TachoAlarm: // add by shai Status = false; - if (CheckTamperAlarms) + if (CheckMotorAlarms) { // ReportWithPackageFilter(AlarmFilter,"------------FANS_RPM[Alarm_i]----------------", __FILE__,__LINE__,Alarm_i, RpMessage, value, 0); @@ -1560,16 +1517,19 @@ uint32_t AlarmHandlingLoop(uint32_t tick) } else { - value = Read_Dryer_Fan_Tacho(); + + value = Get_Dryer_Fan_Tacho(); if (AlarmItem[Alarm_i].Severity == DEBUG_LOG_CATEGORY__Critical ) - if ((AlarmItem[Alarm_i].AlarmDirection == UNDER_VALUE) && (value == DRYER_FAN_STOP)) + { + if (value == DRYER_FAN_STOP) { Status = true; - //ReportWithPackageFilter(AlarmFilter,"----------- DRYER FAN RPM Error----------------", __FILE__,__LINE__,0, RpMessage, value, 0); } + //ReportWithPackageFilter(AlarmFilter,"----------- DRYER FAN RPM ----------------", __FILE__,__LINE__,msec_millisecondCounter, RpMessage, value, 0); + } else if (AlarmItem[Alarm_i].Severity == DEBUG_LOG_CATEGORY__Warning) { - if ((AlarmItem[Alarm_i].AlarmDirection == UNDER_VALUE) && (value < DRYER_FAN_MIN_RPM)) + if ((value>0)&&(value < DRYER_FAN_MIN_RPM)) { Status = true; //ReportWithPackageFilter(AlarmFilter,"----------- DRYER FAN RPM Error----------------", __FILE__,__LINE__,0, RpMessage, value, 0); @@ -1621,78 +1581,77 @@ uint32_t AlarmHandlingLoop(uint32_t tick) break; default: break; - } //switch - if (AlarmItem[Alarm_i].DebounceValue > 0) //handle debouncing + } //switch + if (AlarmItem[Alarm_i].DebounceValue > 0) //handle debouncing + { + if (Status == true) //increase counter { - if (Status == true) //increase counter + AlarmState[Alarm_i].DebounceCounter++; + if (AlarmState[Alarm_i].Status == false) // alarm is not set yet { - AlarmState[Alarm_i].DebounceCounter++; - if (AlarmState[Alarm_i].Status == false) // alarm is not set yet + if (AlarmState[Alarm_i].DebounceCounter < AlarmItem[Alarm_i].DebounceValue) //had not reached the debounce value { - if (AlarmState[Alarm_i].DebounceCounter < AlarmItem[Alarm_i].DebounceValue) //had not reached the debounce value - { - Status = false; //do not set the alarm - } //else alarm will be set - } - else // alarm is already set - { - AlarmState[Alarm_i].DebounceCounter = AlarmItem[Alarm_i].DebounceValue; // do not go over the debounce value - } + Status = false; //do not set the alarm + } //else alarm will be set } - else //status == false - decrease counter + else // alarm is already set { - AlarmState[Alarm_i].DebounceCounter--; - if (AlarmState[Alarm_i].Status == true) // alarm is set - { - if (AlarmState[Alarm_i].DebounceCounter > 0) // had not reached zero yet - { - Status = true; // do not reset the alarm yet - } // else reset the alarm - } - else // if the alarm is off - { - AlarmState[Alarm_i].DebounceCounter = 0; //do not go below 0 - } + AlarmState[Alarm_i].DebounceCounter = AlarmItem[Alarm_i].DebounceValue; // do not go over the debounce value } } - /*if (AlarmItem[Alarm_i].Predecessor!=0xFF) - { - if (AlarmState[AlarmItem[Alarm_i].Predecessor].Status == true) //higher hierarchy alarm is on - Status = false; - }*/ - if (Status != AlarmState[Alarm_i].Status) //change in alarm Status + else //status == false - decrease counter { - if (Status == true) // alarm on + AlarmState[Alarm_i].DebounceCounter--; + if (AlarmState[Alarm_i].Status == true) // alarm is set { - // report the alarm! - AlarmState[Alarm_i].EventPtr = my_malloc (sizeof(Event)); - if (AlarmState[Alarm_i].EventPtr) + if (AlarmState[Alarm_i].DebounceCounter > 0) // had not reached zero yet { - 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; - AlarmHandlingConsequentActions(Alarm_i, AlarmItem[Alarm_i].Severity); - ReportWithPackageFilter(AlarmFilter,"Alarm ON ", __FILE__,__LINE__,AlarmItem[Alarm_i].EventType, RpMessage, value, Alarm_i); + Status = true; // do not reset the alarm yet + } // else reset the alarm } - else // alarm off + else // if the alarm is off { - ReportWithPackageFilter(AlarmFilter,"Alarm OFF ", __FILE__,__LINE__,AlarmItem[Alarm_i].EventType, RpMessage, 0, Alarm_i); - if (AlarmState[Alarm_i].EventPtr) - { - //ROM_IntMasterDisable(); - Save_Alarm_i = Alarm_i; - Save_Alarm_ptr = AlarmState[Alarm_i].EventPtr; - Save_Alarm_Type = AlarmItem[Alarm_i].EventType; - my_free(AlarmState[Alarm_i].EventPtr); - AlarmState[Alarm_i].EventPtr = NULL; - //ROM_IntMasterEnable(); - } - AlarmState[Alarm_i].Status = false; - AlarmHandlingConsequentActions(Alarm_i, DEBUG_LOG_CATEGORY__Info); + AlarmState[Alarm_i].DebounceCounter = 0; //do not go below 0 + } + } + } + /*if (AlarmItem[Alarm_i].Predecessor!=0xFF) + { + if (AlarmState[AlarmItem[Alarm_i].Predecessor].Status == true) //higher hierarchy alarm is on + Status = false; + }*/ + if (Status != AlarmState[Alarm_i].Status) //change in alarm Status + { + if (Status == true) // alarm on + { + // 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 = true; + AlarmHandlingConsequentActions(Alarm_i, AlarmItem[Alarm_i].Severity); + ReportWithPackageFilter(AlarmFilter,"Alarm ON ", __FILE__,__LINE__,AlarmItem[Alarm_i].EventType, RpMessage, value, Alarm_i); + } + else // alarm off + { + ReportWithPackageFilter(AlarmFilter,"Alarm OFF ", __FILE__,__LINE__,AlarmItem[Alarm_i].EventType, RpMessage, 0, Alarm_i); + if (AlarmState[Alarm_i].EventPtr) + { + //ROM_IntMasterDisable(); + Save_Alarm_i = Alarm_i; + Save_Alarm_ptr = AlarmState[Alarm_i].EventPtr; + Save_Alarm_Type = AlarmItem[Alarm_i].EventType; + my_free(AlarmState[Alarm_i].EventPtr); + AlarmState[Alarm_i].EventPtr = NULL; + //ROM_IntMasterEnable(); } + AlarmState[Alarm_i].Status = false; + AlarmHandlingConsequentActions(Alarm_i, DEBUG_LOG_CATEGORY__Info); } } } diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 689219583..1057ddbc3 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -610,21 +610,21 @@ uint32_t MillisecLowLoop(uint32_t tick) //call all modules Millisec functions //test dancers and speed encoders //check all callback units (state machine waiting for completion of a change) - bool Ten_msTick, Fifty_msTick, Hundred_msTick , m20msecTick,m70msecTick,m90msecTick, Onesecond_Tick,Tensecond_Tick,OneMinute_Tick,TenMinutes_Tick,OneHourTick,Gradient_Tick; - bool O700Millisecond_Tick,O200Millisecond_Tick,O400Millisecond_Tick,O500Millisecond_Tick,O600Millisecond_Tick; + bool Ten_msTick, Fifty_msTick, Hundred_msTick , m20msecTick,m90msecTick, Onesecond_Tick,Tensecond_Tick,OneMinute_Tick,TenMinutes_Tick,OneHourTick,Gradient_Tick; + bool O700Millisecond_Tick,O200Millisecond_Tick,O400Millisecond_Tick,O500Millisecond_Tick,O600Millisecond_Tick,O800Millisecond_Tick; //bool O100Millisecond_Tick,O200Millisecond_Tick,O400Millisecond_Tick,O500Millisecond_Tick,O600Millisecond_Tick,O800Millisecond_Tick,O900Millisecond_Tick; Ten_msTick = (tick%eTenMillisecond == 0) ?true:false; Fifty_msTick = (tick%eHundredMillisecond == 40) ?true:false; //eFiftyMillisecond Hundred_msTick = (tick%eHundredMillisecond == 0) ?true:false; m20msecTick = (tick%eHundredMillisecond == 20) ?true:false; - m70msecTick = (tick%eHundredMillisecond == 70) ?true:false; + //m70msecTick = (tick%eHundredMillisecond == 70) ?true:false; m90msecTick = (tick%eHundredMillisecond == 90) ?true:false; O700Millisecond_Tick = (tick%eOneSecond == 700) ?true:false; O200Millisecond_Tick = (tick%eOneSecond == 200) ?true:false; O400Millisecond_Tick = (tick%eOneSecond == 400) ?true:false; O500Millisecond_Tick = (tick%eOneSecond == 500) ?true:false; O600Millisecond_Tick = (tick%eOneSecond == 600) ?true:false; - //O800Millisecond_Tick = (tick%eOneSecond == 800) ?true:false; + O800Millisecond_Tick = (tick%eOneSecond == 800) ?true:false; //O900Millisecond_Tick = (tick%eOneSecond == 900) ?true:false; Gradient_Tick = (tick%400 == 0) ?true:false; Onesecond_Tick = (tick%eOneSecond == 0) ?true:false; @@ -660,10 +660,10 @@ uint32_t MillisecLowLoop(uint32_t tick) Trigger_PT100_Read();//call every 50mSec (minimum delay 30mSec) //Set_HeadCard_PT100();//call every 50mSec (minimum delay 30mSec) } - if(m70msecTick) + /*if(m70msecTick) { AlarmHandling_ControlTrigger(0,0); - } + }*/ if (m90msecTick) { for (Sensor_i = StartPT100;Sensor_i < MAX_HEAD_CARD_TEMP_SENS_ID;Sensor_i++) @@ -717,14 +717,11 @@ uint32_t MillisecLowLoop(uint32_t tick) } if (Gradient_Tick) DispensersCollectionCall(); - if (O700Millisecond_Tick) - { - Trigger_Heater_Current_Read(); - } if (O200Millisecond_Tick) { Trigger_WHS_MAX11614_Read_allADC(); FPGA_GetAllDispensersValveBusyOCD(); + Read_Dryer_Fan_Tacho(); temp = Read_Fans_Tacho(); DrawerFansStatus = temp & 0x1F; SystemFansStatus = temp & 0xE0; @@ -755,6 +752,14 @@ uint32_t MillisecLowLoop(uint32_t tick) } } } + if (O700Millisecond_Tick) + { + Trigger_Heater_Current_Read(); + } + if (O800Millisecond_Tick) + { + AlarmHandling_ControlTrigger(0,0); + } if (Onesecond_Tick) { //char Lenstr[160]; diff --git a/Software/Embedded_SW/Embedded/Modules/General/process.c b/Software/Embedded_SW/Embedded/Modules/General/process.c index 4538d0336..872f772e2 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/process.c +++ b/Software/Embedded_SW/Embedded/Modules/General/process.c @@ -41,8 +41,7 @@ double dryerairflow = 5.0; double pressurebuildup = 0; double dryerzone1temp = 0; int32_t tableindex = 0; -double headBlowersFlow[2] = {1.0,1.0}; -double ArcCleaningMotorSpeed = 0.0; +double headBlowersFlow[2] = {1.5,1.5}; double dryerbufferMeters = 0; double dryerbufferCentimeters = 0; @@ -134,6 +133,10 @@ uint32_t HandleProcessParameters(ProcessParameters* ProcessParams,bool saveData) { if (ProcessParams->has_headairflow == false) ProcessParams->headairflow = headairflow; + if (ProcessParams->has_lblowerflow == false) + ProcessParams->lblowerflow = headBlowersFlow[HEAD_FAN_LEFT]; + if (ProcessParams->has_rblowerflow == false) + ProcessParams->rblowerflow = headBlowersFlow[HEAD_FAN_RIGHT]; if (ProcessParams->has_feedertension == false) ProcessParams->feedertension = feedertension; if (ProcessParams->has_windertension == false) @@ -159,7 +162,6 @@ uint32_t HandleProcessParameters(ProcessParameters* ProcessParams,bool saveData) dryerairflow = ProcessParams->dryerairflow; pressurebuildup = ProcessParams->pressurebuildup; dryerzone1temp = ProcessParams->dryerzone1temp; - ArcCleaningMotorSpeed = ProcessParams->archeadcleaningmotorspeed; if (MachineReadyForHeating == false) { diff --git a/Software/Embedded_SW/Embedded/Modules/General/process.h b/Software/Embedded_SW/Embedded/Modules/General/process.h index 4a1583aa8..f7f16d11e 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/process.h +++ b/Software/Embedded_SW/Embedded/Modules/General/process.h @@ -20,7 +20,6 @@ extern double dryerairflow; extern double pressurebuildup; extern double dryerzone1temp; extern double headBlowersFlow[2]; -extern double ArcCleaningMotorSpeed; extern int32_t tableindex; diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_Blowers.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_Blowers.c index 69ac7fbb3..59a0aee51 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_Blowers.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_Blowers.c @@ -51,7 +51,7 @@ #define ARC_ALARM_LIMIT 3 #define PRESSURE_SENSOR_CP 0.269 -#define PRESSURE_SENSOR_B 1.6668 +#define PRESSURE_SENSOR_B 0.45 extern uint16_t Head_Fan_Tach[2]; extern uint8_t Head_Fan_PWM_Command[2]; @@ -316,14 +316,15 @@ void HeadBlowersControlLoop () int blowerId; static int count[2] = {0, 0}; - ArcHeadAlarms(); - if (GetMachineState() < MACHINE_STATE_WAIT_FOR_COOLER) return; //do not start before controller is initialized and running if (!HeadBlowersEnable) { return; } + + ArcHeadAlarms(); + for (blowerId = 0; blowerId <= 1; blowerId++) { if (count[blowerId] == HeadBlowersCloseLoopTime[blowerId]) { count[blowerId] = 0; @@ -377,7 +378,9 @@ double PressureSensorGetPressure(uint8_t SensorId) V0 = PressureSensorV0[FanId]; Vm = (double)(MillisecGetTemperatures(SensorId)); Vm /= 10.0; - Q = (sqrt(Vm - V0 + 22) - PRESSURE_SENSOR_B) * PRESSURE_SENSOR_CP; + if ((Vm - V0 + 22)<0) + return 0.0; + Q = sqrt(Vm - V0 + 22) * PRESSURE_SENSOR_CP - PRESSURE_SENSOR_B; return Q; } diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index e702d7072..84013add6 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -560,8 +560,8 @@ uint32_t HeatersSingleHeaterEnd(int HeaterId) } DeActivateHeater(HEATER_TYPE__DryerMainHeater); DeActivateHeater(HEATER_TYPE__DryerSecondaryHeater); - //Disable_Reading_Heaters_Current(HeaterId2CurrentId[HEATER_TYPE__DryerMainHeater]); - //Disable_Reading_Heaters_Current(HeaterId2CurrentId[HEATER_TYPE__DryerSecondaryHeater]); + Disable_Reading_Heaters_Current(HeaterId2CurrentId[HEATER_TYPE__DryerMainHeater]); + Disable_Reading_Heaters_Current(HeaterId2CurrentId[HEATER_TYPE__DryerSecondaryHeater]); HeaterPIDConfig[HeaterId].m_SetParam = 0; HeaterCmd[HeaterId].targettemperatue = 0; HeaterReady[HeaterId] = true; @@ -1449,8 +1449,8 @@ uint32_t HeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) } }*/ HeaterReady[index] = true; - //Disable_Reading_Heaters_Current(HeaterId2CurrentId[HEATER_TYPE__DryerMainHeater]); - //Disable_Reading_Heaters_Current(HeaterId2CurrentId[HEATER_TYPE__DryerSecondaryHeater]); + Disable_Reading_Heaters_Current(HeaterId2CurrentId[HEATER_TYPE__DryerMainHeater]); + Disable_Reading_Heaters_Current(HeaterId2CurrentId[HEATER_TYPE__DryerSecondaryHeater]); } return OK; diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h b/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h index 1c17c4f6b..d86d7ab2d 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h @@ -16,6 +16,7 @@ extern uint32_t InitialDispenserSpeed; extern double InitialDispenserPressure; extern uint32_t InitialDispenserTimeout; +extern double ArcCleaningMotorSpeed; extern uint32_t DispenserIdToMotorId[MAX_SYSTEM_DISPENSERS]; diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_Cleaning.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_Cleaning.c index 0e28134c4..0ae017c13 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_Cleaning.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_Cleaning.c @@ -19,7 +19,7 @@ #include "drivers/motors/motor.h" #include "drivers/valves/valve.h" #include "Drivers/I2C_Communication/Head_Card/IO_Ports/Head_IO.h" - +double ArcCleaningMotorSpeed = 750; int SaveLeftRockerSpeed = 50, SaveRightRockerSpeed = 50; typedef enum { diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index c8cab116f..5b6ad643d 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -795,6 +795,8 @@ bool AdjustDispenserSpeedToPressure(int DispenserId, double RefMaxPressure,doubl { if (JobTicket->headcleaningparameters->has_cleanerflow) cleanerFlow = JobTicket->headcleaningparameters->cleanerflow; + if (JobTicket->headcleaningparameters->has_archeadcleaningmotorspeed) + ArcCleaningMotorSpeed = JobTicket->headcleaningparameters->archeadcleaningmotorspeed; } if ((cleanerFlow>200)&&(cleanerFlow<1150)) { diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c index b9b916eb6..5b216d25c 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c @@ -1233,6 +1233,19 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) response.has_progress = true; } else + if(request->amount == 0xB23) //Set loading arm cycles + { + REPORT_MSG(request->delay,"Control dryer fan tacho"); + if (request->delay>0) + Control_Dryer_Fan(START,request->delay);//use START or STOP, 0 - 100%(); + else + Control_Dryer_Fan(STOP,0);//use START or STOP, 0 - 100%(); + Task_sleep(1000); + + response.progress = (double)Get_Dryer_Fan_Tacho(); + response.has_progress = true; + } + else if(request->amount == 0xC3) //suspend I2C task { if (request->delay == 0) diff --git a/Software/Embedded_SW/Embedded/Software Release Notes.txt b/Software/Embedded_SW/Embedded/Software Release Notes.txt index 341cf3a48..4e1f7104f 100644 --- a/Software/Embedded_SW/Embedded/Software Release Notes.txt +++ b/Software/Embedded_SW/Embedded/Software Release Notes.txt @@ -1,3 +1,12 @@ +Embedded SW Release note - Version 1.5.1(4) - Pack 3 +============================================================= +fix tunnel pressure calculation +support standby request +waste prepare failure - fix report +fix fan alarms +improve event handling +fix StartPowerUpResponse handling + Embedded SW Release note - Version 1.5.1(3) - Pack 3 ============================================================= preparations for persistent alarms diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c index 5d2bf2922..d5e125337 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c @@ -91,8 +91,11 @@ MACHINE_STATE_STAGES_ENUM GetMachineState(void) } void SetMachineState(MACHINE_STATE_STAGES_ENUM NewState) { - MachineStateDetail = NewState; - PowerUpUpdate(NewState); + if (MachineStateDetail != NewState) + { + MachineStateDetail = NewState; + PowerUpUpdate(NewState); + } } void StopInitSequence(void) { @@ -146,7 +149,7 @@ uint32_t InitScheduler(uint32_t IfIndex, uint32_t BusyFlag) StoredInitStages = InitStages; InitSequenceStateMachine(InitStages); } - PowerUpUpdate(MachineStateDetail); + //PowerUpUpdate(MachineStateDetail); return OK; } /*******************************************************************************************************/ @@ -246,7 +249,7 @@ uint32_t InitSequenceBlowerCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) WHS_enable_control_loop(true); WHS_Set_SetPoint_Q_value(headairflow); - AlarmHandlingSetAlarm (EVENT_TYPE__MACHINE_STATE_INITIAL_BLOWER_FAILED,OFF); //handle alarm detection and operation + //AlarmHandlingSetAlarm (EVENT_TYPE__MACHINE_STATE_INITIAL_BLOWER_FAILED,OFF); //handle alarm detection and operation waste_seq_step1();// include 1Sec delay <- to open !!!! @@ -748,6 +751,14 @@ uint32_t InitSequenceStateMachine( INIT_SEQUENCE_STAGES_ENUM ReadValue) return OK; } char PowerUpToken[36+1] = {0}; +//char init_string[100]; +uint32_t PowerUpLoadControlId = 0xFF; +uint32_t PowerUpUpdateCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) +{ + + PowerUpUpdate(MachineStateDetail); + return OK; +} uint32_t PowerUpUpdate(MACHINE_STATE_STAGES_ENUM stage) { uint32_t status = NOT_SUPPORTED; @@ -762,7 +773,7 @@ uint32_t PowerUpUpdate(MACHINE_STATE_STAGES_ENUM stage) if (PowerUpToken[0] == 0) return OK; - Report("PowerUpUpdate",__FILE__,last,InitStages,RpWarning,(int)stage,0); + //Report("PowerUpUpdate",__FILE__,last,InitStages,RpWarning,(int)stage,0); response.has_state = true; response.has_progresspercentage = true; @@ -874,7 +885,8 @@ uint32_t PowerUpUpdate(MACHINE_STATE_STAGES_ENUM stage) Error = ERROR_CODE__POWER_UP_NO_CFG_FILE; break; } - //Report("PowerUpUpdate",__FILE__,last,(int)response.progresspercentage,RpWarning,(int)stage,0); + //usnprintf(init_string, 80, "PowerUpUpdate token %s",PowerUpToken); + Report("PowerUpUpdate",__FILE__,InitStages,(int)response.progresspercentage,RpWarning,(int)stage,0); responseContainer = createContainer(MESSAGE_TYPE__StartPowerUpResponse, PowerUpToken, last, &response, &start_power_up_response__pack, &start_power_up_response__get_packed_size); responseContainer.has_continuous = true; responseContainer.continuous = true; @@ -891,8 +903,18 @@ uint32_t PowerUpUpdate(MACHINE_STATE_STAGES_ENUM stage) SendChars((char*)container_buffer, container_size); //MessageContainer responseContainer; + if (last == true) + { + if (PowerUpLoadControlId!= 0xFF) + { + RemoveControlCallback(PowerUpLoadControlId, PowerUpUpdateCallBackFunction); + PowerUpLoadControlId = 0xFF; + } + } return status; } + + uint32_t PowerUpUpdateFunc(MessageContainer* requestContainer) { uint32_t status = NOT_SUPPORTED; @@ -900,11 +922,13 @@ uint32_t PowerUpUpdateFunc(MessageContainer* requestContainer) // MachineUpdateInitParams InitParams; - Report("PowerUpUpdateFunc",__FILE__,__LINE__,(int)0,RpWarning,(int)0,0); StartPowerUpRequest* request = start_power_up_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); ustrncpy (PowerUpToken, requestContainer->token,36); + //usnprintf(init_string, 80, "PowerUpUpdateFunc token %s",PowerUpToken); + Report("PowerUpUpdateFunc",__FILE__,__LINE__,(int)0,RpWarning,(int)0,0); + PowerUpLoadControlId = AddControlCallback("PowerUpLoad", PowerUpUpdateCallBackFunction, 2* eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); - PowerUpUpdate(MachineStateDetail); + //PowerUpUpdate(MachineStateDetail); start_power_up_request__free_unpacked(request,NULL); return status; } diff --git a/Software/Stubs Collection/stubs/embeddedparametersbuild_w_cleaning.cs b/Software/Stubs Collection/stubs/embeddedparametersbuild_w_cleaning.cs index 7319b8f41..f7533ea7e 100644 --- a/Software/Stubs Collection/stubs/embeddedparametersbuild_w_cleaning.cs +++ b/Software/Stubs Collection/stubs/embeddedparametersbuild_w_cleaning.cs @@ -149,10 +149,12 @@ AllowedRangeForHeadBlowerDeviation = 7; configurationParameters.GeneralParameters.Add(AllowedRangeForHeadBlowerDeviation); double AllowedRangeForWasteBlowerDeviation = new Double(); -AllowedRangeForWasteBlowerDeviation = 10; +AllowedRangeForWasteBlowerDeviation = 20; configurationParameters.GeneralParameters.Add(AllowedRangeForWasteBlowerDeviation); - +double Voltage_Hysteresis = new Double(); +Voltage_Hysteresis = 4; +configurationParameters.GeneralParameters.Add(Voltage_Hysteresis); File.WriteAllBytes("C:/temp/EmbParam.cfg",configurationParameters.ToBytes()); diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.cpp b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.cpp index 23be99668..23caef58a 100644 --- a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.cpp +++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.cpp @@ -253,14 +253,6 @@ void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(ConversionInput *conv VectorXd NLInkOut(m_nInks); ConvertToNLInks(DoubleToVector(InkOut, m_nInks), NLInkOut); - //Limit inks based on m_maxNlpercm - //Inks are limited in their nonlinear form - //Output Volume is in % - /* LimitInks(NLInkOut, InkOutP); - NLInkPToVolume(DoubleToVector(InkOutP, m_nInks), Vol); - GamutRegion[i] = GetGamutRegion(Vol, m_ProcessRangesMaxP); - LimitLowVolume(Vol, GamutRegion[i], Vol); - NLcmtoPercentage(Vol, Vol); */ LimitNLInks2Volume(NLInkOut, GamutRegion[i], Vol); //m_A2BTransform->evalInkP2Lab(InkOut, Lab1P, GamutRegion[i]); @@ -1451,15 +1443,6 @@ size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t i // Right now calibration is in the [0-100] range, values exceeding [0-100] are not transformed ConvertToNLInks(InkOut, NLInkOut); - //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); - NLInkPToVolume(DoubleToVector(InkOutP, m_nInks), Volume); - GamutRegion = GetGamutRegion(Volume, m_ProcessRangesMaxP); - LimitLowVolume(Volume, GamutRegion, Volume); - NLcmtoPercentage(Volume, Volume);*/ LimitNLInks2Volume(NLInkOut, GamutRegion, Volume); //OutputCoordinates outputCoords = OUTPUT_COORDINATES__INIT; /* if (InkOutP != NULL) @@ -2684,20 +2667,9 @@ void Tango::ColorLib::ColorConverter::ConvertGradStoptoVolume(InputCoordinates* } VectorXd NLInkOut(m_nInks); VectorXd VolumeOut(m_nInks); -/* double *InkOutL = new double[m_nInks];*/ - ConvertToNLInks(InkOut, 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);*/ - LimitNLInks2Volume(NLInkOut, GamutRegion, Volume); -/* if (InkOutL != NULL) - { - delete[] InkOutL; - InkOutL = NULL; - }*/ + ConvertToNLInks(InkOut, NLInkOut); + LimitNLInks2VolumeThr(NLInkOut, GamutRegion, Volume); return; } @@ -2943,6 +2915,11 @@ void Tango::ColorLib::ColorConverter::PrepareGradient(GradientConversionInput* c ColorSpace SubStopsCS = COLOR_SPACE__LAB; //double NormFactor = m_ProcessRangesMaxP[m_nProcessRanges - 1] / 100.0; + + //Low Volume Threshold will be applied at the end of the sequence + //This is to avoid smoothing to reduce the ink % below the LowVolume threshold + //In order to keep continuity the simple Low Volume threshold will be applied. + VectorXd VolumeStop(m_nInks); MatrixXd MatVolume(nTotalStops, m_nInks); for (int iS = 0; iS < nTotalStops; ++iS) @@ -2959,6 +2936,7 @@ void Tango::ColorLib::ColorConverter::PrepareGradient(GradientConversionInput* c //Smooth Volumes VectorXd VIn(nTotalStops); VectorXd VOut(nTotalStops); + int FilterWidth = 7; for (int iSep = 0; iSep < m_nInks; ++iSep) { @@ -2969,7 +2947,14 @@ void Tango::ColorLib::ColorConverter::PrepareGradient(GradientConversionInput* c outputStops[jS]->outputliquids[iSep]->volume = VOut(jS); } //Temp Output - + for (int i = 0; i < nTotalStops; ++i) + { + for (int j = 0; j < m_nInks; ++j) + VolumeStop(j) = outputStops[i]->outputliquids[j]->volume; + LimitLowVolumeP(VolumeStop, GamutRegion, VolumeStop); + for (int j = 0; j < m_nInks; ++j) + outputStops[i]->outputliquids[j]->volume = VolumeStop(j); + } for (int i = 0; i < nTotalStops; ++i) { fprintf(stdout, "%d\t%6.3f\t%6.3f\t%6.3f\t%6.3f\t%6.3f\t%6.3f\t%6.3f\t%6.3f\t%d\t%d\t%d\n", i, @@ -3154,6 +3139,39 @@ void Tango::ColorLib::ColorConverter::LimitLowVolume(VectorXd InVolume, int &Gam } } +void Tango::ColorLib::ColorConverter::LimitLowVolumeP(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) >= LowVolumeThreshold) + OutVolume(i) = InVolume(i); + else if (InVolume(i) < LowVolHalf) + OutVolume(i) = 0.0; + else + OutVolume(i) = LowVolumeThreshold; + sumVol += OutVolume(i); + } + //recalculate GamutRegion + if (indGR == 0) + return; + else + { + for (int i = 1; i < indGR + 1; ++i) + { + if ((sumVol > m_NormGamutRegionMaxLim[i - 1]) & (sumVol <= m_NormGamutRegionMaxLim[i])) + GamutRegion = i; + } + } +} int Tango::ColorLib::ColorConverter::GetGamutRegion(VectorXd Volume, double *GamutLimits) { double TotalVolume = 0.0; @@ -3230,11 +3248,7 @@ 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); - NLInkPToVolume(DoubleToVector(InkOutL, m_nInks), Volume); - GamutRegion = GetGamutRegion(Volume, m_ProcessRangesMaxP); - LimitLowVolume(Volume, GamutRegion, Volume); - NLcmtoPercentage(Volume, Volume);*/ + LimitNLInks2Volume(NLInkOut, GamutRegion, Volume); //fill data //fill volume @@ -3312,10 +3326,29 @@ void Tango::ColorLib::ColorConverter::SetLowVolThr_nlcm() void Tango::ColorLib::ColorConverter::LimitNLInks2Volume(VectorXd NLInks, int &GamutRegion, VectorXd &Volume) { - VectorXd NLInkOut(m_nInks); + //VectorXd NLInkOut(m_nInks); + double *InkOutL = new double[m_nInks]; + //ConvertToNLInks(NLInks, NLInkOut); + LimitInks(NLInks, InkOutL); // InkOutL in [nl/cm] + NLInkPToVolume(DoubleToVector(InkOutL, m_nInks), Volume); + GamutRegion = GetGamutRegion(Volume, m_ProcessRangesMaxP); + //LimitLowVolume(Volume, GamutRegion, Volume); + GetClosestInk(Volume, GamutRegion, Volume); + //NLcmtoPercentage(Volume, Volume); + + if (InkOutL != NULL) + { + delete[]InkOutL; + InkOutL = NULL; + } +} + +void Tango::ColorLib::ColorConverter::LimitNLInks2VolumeThr(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] +// ConvertToNLInks(NLInks, NLInkOut); + LimitInks(NLInks, InkOutL); // InkOutL in [nl/cm] NLInkPToVolume(DoubleToVector(InkOutL, m_nInks), Volume); GamutRegion = GetGamutRegion(Volume, m_ProcessRangesMaxP); LimitLowVolume(Volume, GamutRegion, Volume); @@ -3327,3 +3360,175 @@ void Tango::ColorLib::ColorConverter::LimitNLInks2Volume(VectorXd NLInks, int &G InkOutL = NULL; } } + +void Tango::ColorLib::ColorConverter::GetClosestInk(VectorXd Volume, int &GamutRegion, VectorXd &BestVolume) +{ + VectorXd LabOut(3); + NumConversions D2B; + double *diffVolume = new double[m_nInks]; + int *LVThrIndex = new int[m_nInks]; + int indCount = -1; + for (int i = 0; i < m_nInks; ++i) + { + if (Volume(i) > 1.e-05) + diffVolume[i] = std::abs(Volume(i) - std::max(Volume(i), m_LowVolThr_nlcm[GamutRegion])); + else + diffVolume[i] = 0; + if (diffVolume[i] > 1.0E-04) + { + indCount++; + LVThrIndex[indCount] = i; + } + } + + if (diffVolume != NULL) + { + delete[]diffVolume; + diffVolume = NULL; + } + + NLcmtoPercentage(Volume, Volume); + indCount++; + if (indCount > 0) + { + double LabTarget[3]; + ConvertVolumeToLabRel(Volume, LabOut, GamutRegion); + VectorToDouble(LabOut, LabTarget); + int pwr2LVThr = (int)pow(2, indCount); + double **VolumeComb = new double*[pwr2LVThr]; + for (int i = 0; i < pwr2LVThr; ++i) + { + VolumeComb[i] = new double[m_nInks]; + for (int j=0; j<m_nInks; ++j) + VolumeComb[ i][j] = Volume(j); + } + int **binPerm = new int*[pwr2LVThr]; + for (int i = 0; i < pwr2LVThr; ++i) + { + binPerm[i] = new int[indCount]; + for (int k = 0; k < indCount ; ++k) + binPerm[i][k] = -1; + D2B.DecToBinary(i, binPerm[i], indCount); + } + double *dE = new double[pwr2LVThr]; + double mindE = 10000.0; + int indMindE = -1; + for (int i = 0; i < pwr2LVThr; ++i) + { + for (int j=0; j<indCount ; ++j) + VolumeComb[i][LVThrIndex[j]] = (double)(binPerm[i][j])* LowVolumeThreshold; + } + //find the volume with smallest dE from Target. + //Convert Volume to Lab and calculate dE from Volume + double sumVolComb = 0; + for (int isum = 0; isum < m_nInks; ++isum) + sumVolComb += VolumeComb[0][isum]; + int istart = 0; + if (sumVolComb < 1.0e-04) + istart = 1; + + for (int i = istart; i < pwr2LVThr; ++i) + { + ConvertVolumeToLabRel(DoubleToVector(VolumeComb[i], m_nInks), LabOut, GamutRegion); + m_Conv02->SymmetricaldECMC(LabOut, DoubleToVector(LabTarget,3), dE[i]); + if (dE[i] < mindE) + { + mindE = dE[i]; + indMindE = i; + BestVolume = DoubleToVector(VolumeComb[i], m_nInks); + } + } + if (binPerm != NULL) + { + for (int i = 0; i < pwr2LVThr; ++i) + delete[]binPerm[i]; + delete[]binPerm; + binPerm = NULL; + } + if (VolumeComb != NULL) + { + for (int i = 0; i < pwr2LVThr; ++i) + delete[]VolumeComb[i]; + delete[]VolumeComb; + VolumeComb = NULL; + } + if (dE != NULL) + { + delete[]dE; + dE = NULL; + } + } + else + BestVolume = Volume; +} + +void Tango::ColorLib::ColorConverter::ConvertVolumeToLabRel(VectorXd &Volume, VectorXd &LabOut, int GamutRegion) +{ + VectorXd NLInkP(m_nInks); + VectorXd InkOut((int)(m_nInks)); + //Convert to Nonlinear Inks + double SumVol_Ink = 0.0; + //Volume is in [nl/cm] + VolumeToNLInkP(Volume, NLInkP); + double *InkOutP = new double[m_nInks]; + double *LinInkP = new double[m_nInks]; + + //Limit inks based on m_maxNlpercm + //Inks are limited in their nonlinear form + + LimitInks(NLInkP, InkOutP); + NLInkPToVolume(DoubleToVector(InkOutP, m_nInks), Volume); + GamutRegion = GetGamutRegion(Volume, m_ProcessRangesMaxP); + NLcmtoPercentage(Volume, Volume); //Volume is back to percentage + VolumeToNLInkP(Volume, NLInkP); + VectorToDouble(NLInkP, InkOutP); + //Convert to RGB + //GamutRegion = 0; + //Convert to Lab + + double *LabOutP = new double[3]; + + for (int i = 0; i < m_nInks; ++i) + InkOutP[i] *= m_colortable->GetInverseNormFactor(); + + m_colortable->m_A2BTransform->evalInkP2Lab(InkOutP, LabOutP, GamutRegion); + //LabOutP is in Relative Colorimetric + ColorConvert CConvertD65(D65, D65); + double *LabOutFinal1 = new double[3]; + double *LabOutFinal = new double[3]; + + CConvertD65.ChangeWP(LabOutP, LabOutFinal1, m_whitepointXYZ_Strip, m_WP); //To Absolute + for (int i = 0; i < 3; ++i) + LabOutFinal[i] = LabOutFinal1[i]; + + LabOut = DoubleToVector(LabOutFinal, 3); + + if (InkOutP != NULL) + { + delete[]InkOutP; + InkOutP = NULL; + } + if (LinInkP != NULL) + { + delete[]LinInkP; + LinInkP = NULL; + } + if (LabOutP != NULL) + { + delete[] LabOutP; + LabOutP = NULL; + } + + if (LabOutFinal1 != NULL) + { + delete[] LabOutFinal1; + LabOutFinal1 = NULL; + } + if (LabOutFinal != NULL) + { + delete[] LabOutFinal; + LabOutFinal = NULL; + } + return; + +}
\ No newline at end of file diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.h b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.h index af621a082..e4190e75e 100644 --- a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.h +++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/ColorConverter.h @@ -78,6 +78,7 @@ namespace Tango void ConvertVolumeToRGBDisplay(InputCoordinates *IC, int n_processRanges,int colorspace, VectorXd &InkOut, VectorXd &RGBOut, VectorXd &LabOut, int &GamutRegion); + void ConvertVolumeToLabRel(VectorXd &Volume, VectorXd &LabOut, int GamutRegion); size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t input_buffer_size, uint8_t *& output_buffer); size_t Tango::ColorLib::ColorConverter::GenerateGradient(uint8_t * input_buffer, size_t input_buffer_size, uint8_t *& output_buffer); void ConvertToNLInks(VectorXd InkIn, VectorXd &InkOut); @@ -160,7 +161,10 @@ namespace Tango VectorXd &InkOut, VectorXd &RGBOut, VectorXd &LabOut, int &GamutRegion, bool &InGamut, SURROUND sur, CAM02CS CS); void LimitLowVolume(VectorXd InVolume, int &GamutRegion, VectorXd &OutVolume); + void LimitLowVolumeP(VectorXd InVolume, int &GamutRegion, VectorXd &OutVolume); void LimitNLInks2Volume(VectorXd NLInks, int &GamutRegion, VectorXd &OutVolume); + void LimitNLInks2VolumeThr(VectorXd NLInks, int &GamutRegion, VectorXd &Volume); + void GetClosestInk(VectorXd Volume, int &GamutRegion, VectorXd &BestVolume); }; } } diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/NumConversions.cpp b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/NumConversions.cpp index 050ad0283..f541b370c 100644 --- a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/NumConversions.cpp +++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/NumConversions.cpp @@ -65,3 +65,21 @@ void NumConversions::getchar(uint32_t num, char &tmpC) tmpC[i] = getChar[nlen - 1 - i]; }*/ } + +void NumConversions::DecToBinary(int DecNumber, int *&BinOut, int nsize) +{ + //Store in reverse order, meaning the way it comes out of the calculation + // array to store binary number + + // counter for binary array + int i = 0; + for (int i = 0; i < nsize; ++i) + BinOut[i] = 0; + while (DecNumber > 0 && i<nsize) + { + // store remainder in binary array + BinOut[i] = DecNumber % 2; + DecNumber = DecNumber / 2; + i++; + } +}
\ No newline at end of file diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/NumConversions.h b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/NumConversions.h index 51559f71a..a2ac26306 100644 --- a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/NumConversions.h +++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v4/Utils/NumConversions.h @@ -12,6 +12,7 @@ class NumConversions int ByteToInt(uint8_t *byteN, int Start); uint16_t ByteToShort(uint8_t *byteN, int Start); void getchar(uint32_t num, char &tmpC); + void DecToBinary(int DecNumber,int *&BinOut, int nsize); private: }; #endif //__NUMCONVERSIONS_H__
\ No newline at end of file |
