save
This commit is contained in:
@@ -61,7 +61,10 @@ State<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
|
||||
// STATE control, add conditions if change to a different state is needed
|
||||
Serial.println("Running update function");
|
||||
float State_Ctrl = getPointValue(equipment, "State Control");
|
||||
if (State_Ctrl == 1){
|
||||
if (State_Ctrl == 0.0f){
|
||||
return new StandbyState<ModbusIP>();
|
||||
}
|
||||
if (State_Ctrl == 2.0f){
|
||||
return new StandbyState<ModbusIP>();
|
||||
}
|
||||
|
||||
@@ -92,7 +95,9 @@ void RunningState<ModbusIP>::enterState(Equipment<ModbusIP>* equipment) {
|
||||
// Logic to run when the equipment enters this state
|
||||
Serial.println("Enter Running State...");
|
||||
// You could also update a Modbus register to show the "standby" state
|
||||
setPointValue(equipment, "Status", 4);
|
||||
|
||||
setBitValue(equipment, "Status", 2, true);
|
||||
setBitValue(equipment, "Tripped", 0, false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -57,9 +57,16 @@ State<ModbusIP>* StandbyState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
|
||||
// STATE control, add conditions if change to a different state is needed
|
||||
Serial.println("Standby update function");
|
||||
float State_Ctrl = getPointValue(equipment, "State Control");
|
||||
if (State_Ctrl == 2){
|
||||
if (State_Ctrl == 1.0f){
|
||||
return new RunningState<ModbusIP>();
|
||||
}
|
||||
|
||||
if (State_Ctrl == 0.0f){
|
||||
setBitValue(equipment, "Tripped", 0, false);
|
||||
}
|
||||
if (State_Ctrl == 2.0f){
|
||||
setBitValue(equipment, "Tripped", 0, true);
|
||||
}
|
||||
// Apply any strategies defined for the standby state
|
||||
_applyStrategies(equipment);
|
||||
return nullptr;
|
||||
@@ -75,11 +82,13 @@ template<>
|
||||
void StandbyState<ModbusIP>::enterState(Equipment<ModbusIP>* equipment) {
|
||||
// Logic to run when the equipment enters this state
|
||||
Serial.println("Enter Standby State...");
|
||||
setPointValue(equipment, "Status", 0);
|
||||
|
||||
setPointValue(equipment, "Amps A", 0.0f);
|
||||
setPointValue(equipment, "Amps B", 0.0f);
|
||||
setPointValue(equipment, "Amps C", 0.0f);
|
||||
setPointValue(equipment, "Amps N", 0.0f);
|
||||
|
||||
setBitValue(equipment, "Status", 2, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
* @{
|
||||
*/
|
||||
#include <ModbusIP_ESP8266.h>
|
||||
const char *ssid = "wifi_name"; /**< @brief The SSID of the WiFi network. */
|
||||
const char *password = "wifi_password"; /**< @brief The password for the WiFi network. */
|
||||
IPAddress local_IP(192, 168, 1, 238); /**< @brief The static IP address for the device. */
|
||||
IPAddress gateway(192, 138, 1, 1); /**< @brief The gateway IP address. */
|
||||
const char *ssid = "QTS_CDR_Arduino"; /**< @brief The SSID of the WiFi network. */
|
||||
const char *password = "123abc456"; /**< @brief The password for the WiFi network. */
|
||||
IPAddress local_IP(172, 17, 33, 149); /**< @brief The static IP address for the device. */
|
||||
IPAddress gateway(172, 17, 33, 1); /**< @brief The gateway IP address. */
|
||||
IPAddress subnet(255, 255, 255, 0); /**< @brief The subnet mask. */
|
||||
|
||||
ModbusIP mb;
|
||||
|
||||
@@ -68,7 +68,10 @@ State<ModbusIP>* RunningState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
|
||||
// STATE control, add conditions if change to a different state is needed
|
||||
Serial.println("Running update function");
|
||||
float State_Ctrl = getPointValue(equipment, "State Control");
|
||||
if (State_Ctrl == 1){
|
||||
if (State_Ctrl == 0.0f){
|
||||
return new StandbyState<ModbusIP>();
|
||||
}
|
||||
if (State_Ctrl == 2.0f){
|
||||
return new StandbyState<ModbusIP>();
|
||||
}
|
||||
// Apply any strategies defined for the standby state
|
||||
@@ -116,7 +119,9 @@ void RunningState<ModbusIP>::enterState(Equipment<ModbusIP>* equipment) {
|
||||
// Logic to run when the equipment enters this state
|
||||
Serial.println("Enter Running State...");
|
||||
// You could also update a Modbus register to show the "standby" state
|
||||
setPointValue(equipment, "CB Position", 4096);
|
||||
|
||||
setBitValue(equipment, "CB Position", 12, true);
|
||||
setBitValue(equipment, "CB Position", 9, false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -57,9 +57,17 @@ State<ModbusIP>* StandbyState<ModbusIP>::update(Equipment<ModbusIP>* equipment)
|
||||
// STATE control, add conditions if change to a different state is needed
|
||||
Serial.println("Standby update function");
|
||||
float State_Ctrl = getPointValue(equipment, "State Control");
|
||||
if (State_Ctrl == 2){
|
||||
if (State_Ctrl == 1.0f){
|
||||
return new RunningState<ModbusIP>();
|
||||
}
|
||||
|
||||
if (State_Ctrl == 0.0f){
|
||||
setBitValue(equipment, "CB Position", 9, false);
|
||||
}
|
||||
|
||||
if (State_Ctrl == 2.0f){
|
||||
setBitValue(equipment, "CB Position", 9, true);
|
||||
}
|
||||
// Apply any strategies defined for the standby state
|
||||
_applyStrategies(equipment);
|
||||
return nullptr;
|
||||
@@ -86,6 +94,7 @@ void StandbyState<ModbusIP>::enterState(Equipment<ModbusIP>* equipment) {
|
||||
setPointValue(equipment, "Amps A", 0.0f);
|
||||
setPointValue(equipment, "Amps B", 0.0f);
|
||||
setPointValue(equipment, "Amps C", 0.0f);
|
||||
setBitValue(equipment, "CB Position", 12, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <ModbusIP_ESP8266.h>
|
||||
const char *ssid = "QTS_CDR_Arduino"; /**< @brief The SSID of the WiFi network. */
|
||||
const char *password = "123abc456"; /**< @brief The password for the WiFi network. */
|
||||
IPAddress local_IP(172, 17, 33, 132); /**< @brief The static IP address for the device. */
|
||||
IPAddress local_IP(172, 17, 33, 141); /**< @brief The static IP address for the device. */
|
||||
IPAddress gateway(172, 17, 33, 1); /**< @brief The gateway IP address. */
|
||||
IPAddress subnet(255, 255, 255, 0); /**< @brief The subnet mask. */
|
||||
|
||||
@@ -64,7 +64,7 @@ modbusMap mb_map[] =
|
||||
{HR, 10, 0, "Load"},
|
||||
{HR, 11, 0, "Rating"},
|
||||
|
||||
{IR, 207, 0, "CB Position"}, //bit 9 tripp bit 12 open closed
|
||||
{IR, 207, 0, "CB Position"}, //bit 9 trip bit 12 open closed
|
||||
{IR_FLOAT, 215, 0, "Amps A"},
|
||||
{IR_FLOAT, 217, 0, "Amps B"},
|
||||
{IR_FLOAT, 219, 0, "Amps C"},
|
||||
|
||||
Reference in New Issue
Block a user