aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/StateMachines
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2020-06-07 16:28:45 +0300
committerShlomo Hecht <shlomo@twine-s.com>2020-06-07 16:28:45 +0300
commit22eaa079a4bd20c81d221b2fa623756fc338e168 (patch)
treeb1158f5d125f4b1cdc9b1c180200148377bbad9e /Software/Embedded_SW/Embedded/StateMachines
parent4ae18ae6866056b9cb385b97f65a40e336402e18 (diff)
downloadTango-22eaa079a4bd20c81d221b2fa623756fc338e168.tar.gz
Tango-22eaa079a4bd20c81d221b2fa623756fc338e168.zip
thread loading messages 1
Diffstat (limited to 'Software/Embedded_SW/Embedded/StateMachines')
-rw-r--r--Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.h2
-rw-r--r--Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c70
2 files changed, 70 insertions, 2 deletions
diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.h b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.h
index b8fb8efd7..8ce835a06 100644
--- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.h
+++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.h
@@ -29,6 +29,8 @@
MACHINE_STATE_MAX,
}MACHINE_STATE_STAGES_ENUM;
+extern char PowerUpToken[36+1];
+
uint32_t Start_InitSequence(void);
void StopInitSequence(void);
MACHINE_STATE_STAGES_ENUM GetMachineState(void);
diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c
index 69df1c183..27ad14ea6 100644
--- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c
+++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c
@@ -13,8 +13,15 @@
#include "modules/heaters/heaters_ex.h"
#include "modules/Diagnostics/Diagnostics.h"
#include "Modules/General/process.h"
-#include "PMR/MachineStatus/MachineStatus.pb-c.h"
#include "Modules/General/MachineStatus.h"
+#include "Modules/General/buttons.h"
+
+#include "PMR/Power/StartPowerUpRequest.pb-c.h"
+#include "PMR/Power/AbortPowerUpRequest.pb-c.h"
+#include "PMR/Power/StartPowerUpResponse.pb-c.h"
+#include "PMR/Power/AbortPowerUpResponse.pb-c.h"
+#include "PMR/Power/PowerUpState.pb-c.h"
+#include "PMR/MachineStatus/MachineStatus.pb-c.h"
#include "StateMachines/Printing/PrintingSTM.h"
#include "StateMachines/Initialization/PowerOffSequence.h"
@@ -24,7 +31,7 @@
#include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h"
#include "drivers/Valves/Valve.h"
#include <Drivers/I2C_Communication/WHS_Card/D_Max5805_ADC_Blower/WHS_Blower.h>
-#include "Modules/General/buttons.h"
+#include "drivers/Heater/TemperatureSensor.h"
#include "heaters/heaters_ex.h"
@@ -166,9 +173,67 @@ void setIdleLimit (int Limit) {powerIdleSecondsLimit = Limit;}
void setmachineActive(bool Active){machineActive = Active;}
void resetIdleCounter (void) {powerIdleSecondsCounter = 0;}
bool getIdleState (void) {return powerIdleState;}
+uint32_t OutOfIdleUpdate(bool last)
+{
+ uint32_t status = NOT_SUPPORTED;
+
+ double calculate;
+ int result = 0;
+ MessageContainer responseContainer;
+ ErrorCode Error = ERROR_CODE__NONE;
+
+ StartPowerUpResponse response = START_POWER_UP_RESPONSE__INIT;
+
+ if (PowerUpToken[0] == 0)
+ return OK;
+/* response.has_state = true;
+ response.has_progresspercentage = true;
+
+ if (last == false)
+ {
+ response.state = POWER_UP_STATE__HeatingStarted;
+ if (dryerzone1temp < 1)
+ response.progresspercentage = 30.0;
+ else
+ {
+ calculate = (double)((MillisecGetTemperatures(TEMP_SENSE_ANALOG_DRYER_TEMP1)/100)/(dryerzone1temp))*70.0;
+ if (calculate > 0)
+ result = (int)calculate;
+ response.progresspercentage = 30.0 + result;
+ }
+ //Report("Heating calculation",__FILE__,(int)dryerzone1temp,(int)response.progresspercentage,RpWarning,(int)result,0);
+ response.message = "Heating up";
+ }
+ else
+ {
+ response.state = POWER_UP_STATE__MachineReadyToDye;
+ response.progresspercentage = 100.0;
+ response.message = "Ready to dye";
+ }
+ //Report("PowerUpUpdate",__FILE__,last,(int)response.progresspercentage,RpWarning,(int)stage,0);
+ Report("OutOfIdleUpdate",__FILE__,last,response.state,RpWarning,(int)response.progresspercentage,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;
+ if (Error != ERROR_CODE__NONE)
+ {
+ responseContainer.has_error = true;
+ responseContainer.error = Error;
+ responseContainer.errormessage = response.message;
+ }
+ uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer));
+ size_t container_size = message_container__pack(&responseContainer, container_buffer);
+ my_free(responseContainer.data.data);
+
+ SendChars((char*)container_buffer, container_size);
+ //MessageContainer responseContainer;
+*/
+ return status;
+}
uint32_t PowerIdleStartHeatingCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag)
{
+ OutOfIdleUpdate(false);
if (HeaterCheckReady()==true)
{
//MachineStateDetail = MACHINE_STATE_MACHINE_READY_TO_DYE;
@@ -178,6 +243,7 @@ uint32_t PowerIdleStartHeatingCallBackFunction(uint32_t IfIndex, uint32_t BusyFl
Report("Remove control callback failed",__FILE__,__LINE__,(int)IdleHeatingControlId,RpWarning,(int)PowerIdleStartHeatingCallBackFunction,0);
//InitSequenceStateMachine(InitStages);
SetMachineStatus(MACHINE_STATE__Ready);
+ OutOfIdleUpdate(true);
}
return OK;