Name updated, Categories folder to ModbuPoints, less generic to be self documented
This commit is contained in:
@@ -7,10 +7,9 @@
|
||||
* This file contains the implementation for the FailState, which defines
|
||||
* the behavior of the equipment when it has entered a fault condition.
|
||||
*/
|
||||
#include "States/State_Fail.h"
|
||||
#include "States/State_Standby.h"
|
||||
|
||||
#include "Categories/ModbusPoint.h"
|
||||
#include "States/State_Fail.h"
|
||||
#include "ModbusPoints/Modbus_Point.h"
|
||||
#include "Equipment/Equipment.h"
|
||||
#include "Strategies/Strategy_SingleValue.h"
|
||||
#include "Strategies/Strategy_PID.h"
|
||||
@@ -55,7 +54,7 @@ template<>
|
||||
State<ModbusRTU>* FailState<ModbusRTU>::update(Equipment<ModbusRTU>* equipment) {
|
||||
// STATE control, add conditions if change to a different state is needed
|
||||
Serial.println("Fail update function");
|
||||
ModbusPoint<ModbusRTU>* clearAlm = equipment->getModbusPoint("Clear Alm");
|
||||
Modbus_Point<ModbusRTU>* clearAlm = equipment->getModbus_Point("Clear Alm");
|
||||
int nextStateId = clearAlm ? clearAlm->getValue() : 0;
|
||||
if (nextStateId == 1){
|
||||
return new StandbyState<ModbusRTU>();
|
||||
@@ -72,7 +71,7 @@ template<>
|
||||
void FailState<ModbusRTU>::enterState(Equipment<ModbusRTU>* equipment) {
|
||||
// Logic to run when the equipment enters this state
|
||||
Serial.println("Enter Fail State...");
|
||||
ModbusPoint<ModbusRTU>* alarm_common = equipment->getModbusPoint("Alarm Common");
|
||||
Modbus_Point<ModbusRTU>* alarm_common = equipment->getModbus_Point("Alarm Common");
|
||||
alarm_common->setValue(1);
|
||||
}
|
||||
|
||||
@@ -84,6 +83,6 @@ template<>
|
||||
void FailState<ModbusRTU>::exitState(Equipment<ModbusRTU>* equipment) {
|
||||
// Cleanup logic to run when the equipment leaves this state
|
||||
Serial.println("Exit Fail State...");
|
||||
ModbusPoint<ModbusRTU>* alarm_common = equipment->getModbusPoint("Alarm Common");
|
||||
Modbus_Point<ModbusRTU>* alarm_common = equipment->getModbus_Point("Alarm Common");
|
||||
alarm_common->setValue(0);
|
||||
}
|
||||
@@ -7,15 +7,16 @@
|
||||
* This file contains the implementation for the RunningState, which defines
|
||||
* the behavior of the equipment when it is actively running.
|
||||
*/
|
||||
#include "States/State_Running.h"
|
||||
|
||||
#include "States/State_Standby.h"
|
||||
#include "States/State_Running.h"
|
||||
#include "States/State_Fail.h"
|
||||
#include "Strategies/Strategy_Behavior.h"
|
||||
#include "Strategies/Strategy_PID.h"
|
||||
#include "Strategies/Strategy_Totalizer.h"
|
||||
#include "Equipment/Equipment.h"
|
||||
#include "Categories/ModbusPoint.h"
|
||||
#include "Categories/ModbusFloatDecorator.h"
|
||||
#include "ModbusPoints/Modbus_Point.h"
|
||||
#include "ModbusPoints/Modbus_FloatDecorator.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@@ -64,14 +65,14 @@ template<>
|
||||
State<ModbusRTU>* RunningState<ModbusRTU>::update(Equipment<ModbusRTU>* equipment) {
|
||||
// STATE control, add conditions if change to a different state is needed
|
||||
Serial.println("Running update function");
|
||||
ModbusPoint<ModbusRTU>* On_Off_Command = equipment->getModbusPoint("ON/OFF Command By BMS");
|
||||
Modbus_Point<ModbusRTU>* On_Off_Command = equipment->getModbus_Point("ON/OFF Command By BMS");
|
||||
int nextStateId = On_Off_Command ? On_Off_Command->getValue() : 0;
|
||||
Serial.println(nextStateId);
|
||||
if (nextStateId == 0){
|
||||
return new StandbyState<ModbusRTU>();
|
||||
}
|
||||
|
||||
ModbusPoint<ModbusRTU>* faultCode = equipment->getModbusPoint("Fault Code");
|
||||
Modbus_Point<ModbusRTU>* faultCode = equipment->getModbus_Point("Fault Code");
|
||||
int faultCodeValue = faultCode ? faultCode->getValue() : 0;
|
||||
if (faultCodeValue != 0) {
|
||||
// A fault has been triggered, transition to FailState
|
||||
@@ -105,7 +106,7 @@ void RunningState<ModbusRTU>::enterState(Equipment<ModbusRTU>* equipment) {
|
||||
|
||||
// Loop through and set all motor statuses to 0
|
||||
for (const auto& desc : motorStatusDescriptions) {
|
||||
ModbusPoint<ModbusRTU>* point = equipment->getModbusPoint(desc);
|
||||
Modbus_Point<ModbusRTU>* point = equipment->getModbus_Point(desc);
|
||||
if (point) {
|
||||
point->setValue(1);
|
||||
}
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
* This file contains the implementation for the StandbyState, which defines
|
||||
* the behavior of the equipment when it is in an idle or standby mode.
|
||||
*/
|
||||
#include "States/State_Standby.h"
|
||||
#include "States/State_Running.h"
|
||||
#include "Categories/ModbusPoint.h"
|
||||
#include "Categories/ModbusFloatDecorator.h"
|
||||
#include "States/State_Fail.h"
|
||||
#include "ModbusPoints/Modbus_Point.h"
|
||||
#include "ModbusPoints/Modbus_FloatDecorator.h"
|
||||
#include "Equipment/Equipment.h"
|
||||
#include "Strategies/Strategy_Random.h"
|
||||
|
||||
@@ -53,7 +53,7 @@ template<>
|
||||
State<ModbusRTU>* StandbyState<ModbusRTU>::update(Equipment<ModbusRTU>* equipment) {
|
||||
// STATE control, add conditions if change to a different state is needed
|
||||
Serial.println("Standby update function");
|
||||
ModbusPoint<ModbusRTU>* chillerOnOff = equipment->getModbusPoint("Chiller On-Off");
|
||||
Modbus_Point<ModbusRTU>* chillerOnOff = equipment->getModbus_Point("Chiller On-Off");
|
||||
int nextStateId = chillerOnOff ? chillerOnOff->getValue() : 0;
|
||||
Serial.println(nextStateId);
|
||||
if (nextStateId == 1){
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
* @see Equipment.h for the main equipment logic.
|
||||
* @see State.h for different equipment states.
|
||||
* @see Strategies/Strategy_Behavior.h for value generation strategies.
|
||||
* @see ModbusPoint.h for the base class for all Modbus points.
|
||||
* @see Modbus_Point.h for the base class for all Modbus points.
|
||||
*/
|
||||
//=================================================================================================================================
|
||||
//Libraries and declaration of variables.
|
||||
#include <Arduino.h>
|
||||
#include "config.h"
|
||||
#include "Categories/ModbusPointFactory.h"
|
||||
#include "ModbusPoints/Modbus_PointFactory.h"
|
||||
|
||||
//=================================================================================================================================
|
||||
/**
|
||||
@@ -47,10 +47,10 @@ void setup() {
|
||||
mb.slave(MODBUS_ID); // Set the slave ID
|
||||
|
||||
for(int i = 0; i < map_size; i++){
|
||||
ModbusPoint<ModbusRTU>* point = createModbusPoint(&mb, mb_map[i].category, mb_map[i].address, mb_map[i].value, mb_map[i].description);
|
||||
Modbus_Point<ModbusRTU>* point = createModbus_Point(&mb, mb_map[i].category, mb_map[i].address, mb_map[i].value, mb_map[i].description);
|
||||
if (point) {
|
||||
point->addToModbusServer();
|
||||
EquipmentInstance.addModbusPoint(mb_map[i].description, point);
|
||||
EquipmentInstance.addModbus_Point(mb_map[i].description, point);
|
||||
}
|
||||
}
|
||||
Serial.println("Setup function ended");
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* This file contains the implementation for the FailState, which defines
|
||||
* the behavior of the equipment when it has entered a fault condition.
|
||||
*/
|
||||
#include "Categories/ModbusPoint.h"
|
||||
#include "ModbusPoints/Modbus_Point.h"
|
||||
#include "Equipment/Equipment.h"
|
||||
#include "Strategies/Strategy_Ramp.h"
|
||||
#include "Strategies/Strategy_SingleValue.h"
|
||||
@@ -56,7 +56,7 @@ template<>
|
||||
State<ModbusIP>* FailState<ModbusIP>::update(Equipment<ModbusIP>* equipment) {
|
||||
// STATE control, add conditions if change to a different state is needed
|
||||
Serial.println("Fail update function");
|
||||
ModbusPoint<ModbusIP>* alarmReset = equipment->getModbusPoint("Alarm Reset");
|
||||
Modbus_Point<ModbusIP>* alarmReset = equipment->getModbus_Point("Alarm Reset");
|
||||
int nextStateId = alarmReset ? alarmReset->getValue() : 0;
|
||||
if (nextStateId == 1){
|
||||
return new StandbyState<ModbusIP>();
|
||||
@@ -74,7 +74,7 @@ template<>
|
||||
void FailState<ModbusIP>::enterState(Equipment<ModbusIP>* equipment) {
|
||||
// Logic to run when the equipment enters this state
|
||||
Serial.println("Enter Fail State...");
|
||||
ModbusPoint<ModbusIP>* alarm_common = equipment->getModbusPoint("Alarm Common");
|
||||
Modbus_Point<ModbusIP>* alarm_common = equipment->getModbus_Point("Alarm Common");
|
||||
alarm_common->setValue(1);
|
||||
}
|
||||
|
||||
@@ -87,6 +87,6 @@ template<>
|
||||
void FailState<ModbusIP>::exitState(Equipment<ModbusIP>* equipment) {
|
||||
// Cleanup logic to run when the equipment leaves this state
|
||||
Serial.println("Exit Fail State...");
|
||||
ModbusPoint<ModbusIP>* alarm_common = equipment->getModbusPoint("Alarm Common");
|
||||
Modbus_Point<ModbusIP>* alarm_common = equipment->getModbus_Point("Alarm Common");
|
||||
alarm_common->setValue(0);
|
||||
}
|
||||
@@ -7,8 +7,8 @@
|
||||
* This file contains the implementation for the RunningState, which defines
|
||||
* the behavior of the equipment when it is actively running.
|
||||
*/
|
||||
#include "Categories/ModbusPoint.h"
|
||||
#include "Categories/ModbusFloatDecorator.h"
|
||||
#include "ModbusPoints/Modbus_Point.h"
|
||||
#include "ModbusPoints/Modbus_FloatDecorator.h"
|
||||
#include "Equipment/Equipment.h"
|
||||
#include "Strategies/Strategy_Ramp.h"
|
||||
#include "Strategies/Strategy_Random.h"
|
||||
@@ -67,14 +67,14 @@ template<>
|
||||
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");
|
||||
ModbusPoint<ModbusIP>* On_Off_Command = equipment->getModbusPoint("ON/OFF Command By BMS");
|
||||
Modbus_Point<ModbusIP>* On_Off_Command = equipment->getModbus_Point("ON/OFF Command By BMS");
|
||||
int nextStateId = On_Off_Command ? On_Off_Command->getValue() : 0;
|
||||
Serial.println(nextStateId);
|
||||
if (nextStateId == 0){
|
||||
return new StandbyState<ModbusIP>();
|
||||
}
|
||||
|
||||
ModbusPoint<ModbusIP>* faultCode = equipment->getModbusPoint("Fault Code");
|
||||
Modbus_Point<ModbusIP>* faultCode = equipment->getModbus_Point("Fault Code");
|
||||
int faultCodeValue = faultCode ? faultCode->getValue() : 0;
|
||||
switch (faultCodeValue){
|
||||
case 1:
|
||||
@@ -155,7 +155,7 @@ void RunningState<ModbusIP>::enterState(Equipment<ModbusIP>* equipment) {
|
||||
|
||||
// Loop through and set all motor statuses to 0
|
||||
for (const auto& desc : motorStatusDescriptions) {
|
||||
ModbusPoint<ModbusIP>* point = equipment->getModbusPoint(desc);
|
||||
Modbus_Point<ModbusIP>* point = equipment->getModbus_Point(desc);
|
||||
if (point) {
|
||||
point->setValue(1);
|
||||
}
|
||||
@@ -179,7 +179,7 @@ void RunningState<ModbusIP>::exitState(Equipment<ModbusIP>* equipment) {
|
||||
|
||||
// Loop through and set all motor statuses to 0
|
||||
for (const auto& desc : motorStatusDescriptions) {
|
||||
ModbusPoint<ModbusIP>* point = equipment->getModbusPoint(desc);
|
||||
Modbus_Point<ModbusIP>* point = equipment->getModbus_Point(desc);
|
||||
if (point) {
|
||||
point->setValue(0);
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
* This file contains the implementation for the StandbyState, which defines
|
||||
* the behavior of the equipment when it is in an idle or standby mode.
|
||||
*/
|
||||
#include "Categories/ModbusPoint.h"
|
||||
#include "Categories/ModbusFloatDecorator.h"
|
||||
#include "ModbusPoints/Modbus_Point.h"
|
||||
#include "ModbusPoints/Modbus_FloatDecorator.h"
|
||||
#include "Equipment/Equipment.h"
|
||||
#include "Strategies/Strategy_Ramp.h"
|
||||
#include "Strategies/Strategy_Random.h"
|
||||
@@ -109,7 +109,7 @@ void StandbyState<ModbusIP>::enterState(Equipment<ModbusIP>* equipment) {
|
||||
|
||||
// Loop through and set all alarms to 0
|
||||
for (const auto& desc : alarmDescriptions) {
|
||||
ModbusPoint<ModbusIP>* point = equipment->getModbusPoint(desc);
|
||||
Modbus_Point<ModbusIP>* point = equipment->getModbus_Point(desc);
|
||||
if (point) {
|
||||
point->setValue(0);
|
||||
}
|
||||
@@ -117,7 +117,7 @@ void StandbyState<ModbusIP>::enterState(Equipment<ModbusIP>* equipment) {
|
||||
|
||||
// Loop through and set all motor statuses to 0
|
||||
for (const auto& desc : motorStatusDescriptions) {
|
||||
ModbusPoint<ModbusIP>* point = equipment->getModbusPoint(desc);
|
||||
Modbus_Point<ModbusIP>* point = equipment->getModbus_Point(desc);
|
||||
if (point) {
|
||||
point->setValue(0);
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
* @see Equipment.h for the main equipment logic.
|
||||
* @see State.h for different equipment states.
|
||||
* @see Strategies/Strategy_Behavior.h for value generation strategies.
|
||||
* @see ModbusPoint.h for the base class for all Modbus points.
|
||||
* @see Modbus_Point.h for the base class for all Modbus points.
|
||||
*/
|
||||
//=================================================================================================================================
|
||||
//Libraries and declaration of variables.
|
||||
#include <WiFi.h>
|
||||
#include "config.h"
|
||||
#include "Categories/ModbusPointFactory.h"
|
||||
#include "ModbusPoints/Modbus_PointFactory.h"
|
||||
#if defined(USE_MODBUS_IP)
|
||||
#include <ModbusIP_ESP8266.h>
|
||||
#else
|
||||
@@ -54,10 +54,10 @@ void setup() {
|
||||
Serial.println("Server Created");
|
||||
Serial.println(map_size);
|
||||
for(int i = 0; i < map_size; i++){
|
||||
ModbusPoint<ModbusIP>* point = createModbusPoint(&mb, mb_map[i].category, mb_map[i].address, mb_map[i].value, mb_map[i].description);
|
||||
Modbus_Point<ModbusIP>* point = createModbus_Point(&mb, mb_map[i].category, mb_map[i].address, mb_map[i].value, mb_map[i].description);
|
||||
if (point) {
|
||||
point->addToModbusServer();
|
||||
EquipmentInstance.addModbusPoint(mb_map[i].description, point);
|
||||
EquipmentInstance.addModbus_Point(mb_map[i].description, point);
|
||||
}
|
||||
}
|
||||
Serial.println("All modbus Points created");
|
||||
|
||||
Reference in New Issue
Block a user