diff options
| author | Ronen Sberlo <ronen.s@twine-s.com> | 2020-10-27 14:38:11 +0200 |
|---|---|---|
| committer | Ronen Sberlo <ronen.s@twine-s.com> | 2020-10-27 14:38:11 +0200 |
| commit | fba4984f4d08397f7f1b897953d5d8cb068ee2bc (patch) | |
| tree | b2f68c048de180b093ea4f694b47955df436f473 /Software/Embedded_SW/Embedded/Modules | |
| parent | c1dbc0def7c7401432195461df5eb4face4025ba (diff) | |
| download | Tango-fba4984f4d08397f7f1b897953d5d8cb068ee2bc.tar.gz Tango-fba4984f4d08397f7f1b897953d5d8cb068ee2bc.zip | |
cartridge state update
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules')
| -rw-r--r-- | Software/Embedded_SW/Embedded/Modules/IFS/ifs.c | 26 | ||||
| -rw-r--r-- | Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c | 14 |
2 files changed, 31 insertions, 9 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c index d62ad3a43..b8b1915c4 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 @@ -154,6 +155,14 @@ bool CartridgeInkFull() } #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; @@ -276,7 +285,7 @@ void midTankStateMachine(void) break; } //check RFID? (TBD) - //IFS_State = CARTRIDGE_STATE__Inserted; + CartridgeStateUpdate(CARTRIDGE_SLOT__Ink, CARTRIDGE_STATE__Inserted, 0); // send request for validation to ppc inkAuthenticationPass = 2; //not defined @@ -298,13 +307,13 @@ 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; } @@ -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) { @@ -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,9 @@ 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; + CartridgeStateUpdate(CARTRIDGE_SLOT__Ink, CARTRIDGE_STATE__FillingCompleted, GetCartridgeFillPercent()); } + 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/Waste/Waste_maint.c b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c index 1de7f1319..d552c444e 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> @@ -259,6 +260,10 @@ bool RdWasteTankOverFlowSensor() return 0; } +int WHS_GetCartridgeFillPercent() +{ + return (((wasteLevel - wasteLevelEmpty) * 100) / WASTE_CARTRIDGE_SIZE); +} bool WHS_IsContainerFull() { return RdWasteTankFullSensor(); @@ -343,6 +348,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 +356,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); } @@ -451,15 +458,18 @@ void Waste_StateMachine(void) //start emptying 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); + CartridgeStateUpdate(activeCart, CARTRIDGE_STATE__Error, WHS_GetCartridgeFillPercent()); AlarmHandlingSetAlarm( EVENT_TYPE__WASTE_CONTAINER_EMPTYING_TIMEOUT, true); RemoveControlCallback(Cartridge_Cover_Control, Waste_DoorOpenDuringEmptying); timeout_counter = 0; @@ -473,8 +483,10 @@ void Waste_StateMachine(void) //if (cartNotAllFull() == false) AlarmHandlingSetAlarm( EVENT_TYPE__ALL_WASTE_CARTRIDGES_FULL, true); Report("WasteTankStateEmptying done", __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 +507,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: |
