You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2022/08/18 14:51:09 UTC

[plc4x] 01/02: feat(plc4go/cbus): added some more dummy implementations for value types

This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 6906355d798538ddaaa35ddd309abb8dc275949a
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Aug 18 16:23:59 2022 +0200

    feat(plc4go/cbus): added some more dummy implementations for value types
---
 plc4go/internal/cbus/ValueHandler.go               | 223 +++++++++++++++++++--
 .../cbus/c-bus_air_conditioning_application.mspec  |   8 +-
 2 files changed, 211 insertions(+), 20 deletions(-)

diff --git a/plc4go/internal/cbus/ValueHandler.go b/plc4go/internal/cbus/ValueHandler.go
index 7524a71ae..ba999cc88 100644
--- a/plc4go/internal/cbus/ValueHandler.go
+++ b/plc4go/internal/cbus/ValueHandler.go
@@ -43,7 +43,7 @@ func (m ValueHandler) NewPlcValue(field apiModel.PlcField, value interface{}) (a
 		CAL_IDENTIFY_REPLY.GetName(),
 		CAL_STATUS.GetName(),
 		CAL_STATUS_EXTENDED.GetName():
-		panic("implement me")
+		panic("Implement me") //TODO: implement me
 	case SAL.GetName():
 		var curValues []any
 		if field.GetQuantity() > 1 {
@@ -63,7 +63,11 @@ func (m ValueHandler) NewPlcValue(field apiModel.PlcField, value interface{}) (a
 		salCommand := field.salCommand
 		switch field.application.ApplicationId() {
 		case readWriteModel.ApplicationId_FREE_USAGE:
-			panic("Not yet implemented") // TODO: implement
+			switch salCommand {
+			// TODO:implement
+			default:
+				return nil, errors.Errorf("Unsupported command %s for %s", salCommand, field.application.ApplicationId())
+			}
 		case readWriteModel.ApplicationId_TEMPERATURE_BROADCAST:
 			switch salCommand {
 			case readWriteModel.TemperatureBroadcastCommandType_BROADCAST_EVENT.PLC4XEnumName():
@@ -83,7 +87,11 @@ func (m ValueHandler) NewPlcValue(field apiModel.PlcField, value interface{}) (a
 				return nil, errors.Errorf("Unsupported command %s for %s", salCommand, field.application.ApplicationId())
 			}
 		case readWriteModel.ApplicationId_ROOM_CONTROL_SYSTEM:
-			panic("Implement me")
+			switch salCommand {
+			// TODO:implement
+			default:
+				return nil, errors.Errorf("Unsupported command %s for %s", salCommand, field.application.ApplicationId())
+			}
 		case readWriteModel.ApplicationId_LIGHTING,
 			readWriteModel.ApplicationId_VENTILATION,
 			readWriteModel.ApplicationId_IRRIGATION_CONTROL,
@@ -133,34 +141,217 @@ func (m ValueHandler) NewPlcValue(field apiModel.PlcField, value interface{}) (a
 				}
 				return group, nil
 			case readWriteModel.LightingCommandType_LABEL.PLC4XEnumName():
-				panic("Implement me")
+				panic("Implement me") //TODO: implement me
 			default:
 				return nil, errors.Errorf("Unsupported command %s for %s", salCommand, field.application.ApplicationId())
 			}
 		case readWriteModel.ApplicationId_AIR_CONDITIONING:
-			panic("Implement me")
+			switch salCommand {
+			case readWriteModel.AirConditioningCommandType_SET_ZONE_GROUP_OFF.PLC4XEnumName():
+				zoneGroup, err := m.IEC61131ValueHandler.NewPlcValueFromType(spiValues.IEC61131_BYTE, curValues[0])
+				if err != nil {
+					return nil, errors.Wrap(err, "error creating value for zoneGroup")
+				}
+				return zoneGroup, nil
+			case readWriteModel.AirConditioningCommandType_ZONE_HVAC_PLANT_STATUS.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.AirConditioningCommandType_ZONE_HUMIDITY_PLANT_STATUS.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.AirConditioningCommandType_ZONE_TEMPERATURE.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.AirConditioningCommandType_ZONE_HUMIDITY.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.AirConditioningCommandType_REFRESH.PLC4XEnumName():
+				zoneGroup, err := m.IEC61131ValueHandler.NewPlcValueFromType(spiValues.IEC61131_BYTE, curValues[0])
+				if err != nil {
+					return nil, errors.Wrap(err, "error creating value for zoneGroup")
+				}
+				return zoneGroup, nil
+			case readWriteModel.AirConditioningCommandType_SET_ZONE_HVAC_MODE.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.AirConditioningCommandType_SET_PLANT_HVAC_LEVEL.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.AirConditioningCommandType_SET_ZONE_HUMIDITY_MODE.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.AirConditioningCommandType_SET_PLANT_HUMIDITY_LEVEL.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.AirConditioningCommandType_SET_HVAC_UPPER_GUARD_LIMIT.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.AirConditioningCommandType_SET_HVAC_LOWER_GUARD_LIMIT.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.AirConditioningCommandType_SET_HVAC_SETBACK_LIMIT.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.AirConditioningCommandType_SET_HUMIDITY_UPPER_GUARD_LIMIT.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.AirConditioningCommandType_SET_HUMIDITY_LOWER_GUARD_LIMIT.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.AirConditioningCommandType_SET_ZONE_GROUP_ON.PLC4XEnumName():
+				zoneGroup, err := m.IEC61131ValueHandler.NewPlcValueFromType(spiValues.IEC61131_BYTE, curValues[0])
+				if err != nil {
+					return nil, errors.Wrap(err, "error creating value for zoneGroup")
+				}
+				return zoneGroup, nil
+			case readWriteModel.AirConditioningCommandType_SET_HUMIDITY_SETBACK_LIMIT.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.AirConditioningCommandType_HVAC_SCHEDULE_ENTRY.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.AirConditioningCommandType_HUMIDITY_SCHEDULE_ENTRY.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			default:
+				return nil, errors.Errorf("Unsupported command %s for %s", salCommand, field.application.ApplicationId())
+			}
 		case readWriteModel.ApplicationId_TRIGGER_CONTROL:
-			panic("Implement me")
+			switch salCommand {
+			case readWriteModel.TriggerControlCommandType_TRIGGER_EVENT.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.TriggerControlCommandType_TRIGGER_MIN.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.TriggerControlCommandType_TRIGGER_MAX.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.TriggerControlCommandType_INDICATOR_KILL.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			case readWriteModel.TriggerControlCommandType_LABEL.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			default:
+				return nil, errors.Errorf("Unsupported command %s for %s", salCommand, field.application.ApplicationId())
+			}
 		case readWriteModel.ApplicationId_ENABLE_CONTROL:
-			panic("Implement me")
+			switch salCommand {
+			case readWriteModel.EnableControlCommandType_SET_NETWORK_VARIABLE.PLC4XEnumName():
+				panic("Implement me") //TODO: implement me
+			default:
+				return nil, errors.Errorf("Unsupported command %s for %s", salCommand, field.application.ApplicationId())
+			}
 		case readWriteModel.ApplicationId_SECURITY:
-			panic("Implement me")
+			switch salCommand {
+			case readWriteModel.SecurityCommandType_OFF.PLC4XEnumName():
+				panic("Implement me") // TODO: implement
+			case readWriteModel.SecurityCommandType_ON.PLC4XEnumName():
+				panic("Implement me") // TODO: implement
+			case readWriteModel.SecurityCommandType_EVENT.PLC4XEnumName():
+				panic("Implement me") // TODO: implement
+			default:
+				return nil, errors.Errorf("Unsupported command %s for %s", salCommand, field.application.ApplicationId())
+			}
 		case readWriteModel.ApplicationId_METERING:
-			panic("Implement me")
+			switch salCommand {
+			case readWriteModel.MeteringCommandType_EVENT.PLC4XEnumName():
+				panic("Implement me") // TODO: implement
+			default:
+				return nil, errors.Errorf("Unsupported command %s for %s", salCommand, field.application.ApplicationId())
+			}
 		case readWriteModel.ApplicationId_ACCESS_CONTROL:
-			panic("Implement me")
+			switch salCommand {
+			case readWriteModel.AccessControlCommandType_CLOSE_ACCESS_POINT.PLC4XEnumName():
+				panic("Implement me") // TODO: implement
+			case readWriteModel.AccessControlCommandType_LOCK_ACCESS_POINT.PLC4XEnumName():
+				panic("Implement me") // TODO: implement
+			case readWriteModel.AccessControlCommandType_ACCESS_POINT_LEFT_OPEN.PLC4XEnumName():
+				panic("Implement me") // TODO: implement
+			case readWriteModel.AccessControlCommandType_ACCESS_POINT_FORCED_OPEN.PLC4XEnumName():
+				panic("Implement me") // TODO: implement
+			case readWriteModel.AccessControlCommandType_ACCESS_POINT_CLOSED.PLC4XEnumName():
+				panic("Implement me") // TODO: implement
+			case readWriteModel.AccessControlCommandType_REQUEST_TO_EXIT.PLC4XEnumName():
+				panic("Implement me") // TODO: implement
+			case readWriteModel.AccessControlCommandType_VALID_ACCESS.PLC4XEnumName():
+				panic("Implement me") // TODO: implement
+			case readWriteModel.AccessControlCommandType_INVALID_ACCESS.PLC4XEnumName():
+				panic("Implement me") // TODO: implement
+			default:
+				return nil, errors.Errorf("Unsupported command %s for %s", salCommand, field.application.ApplicationId())
+			}
 		case readWriteModel.ApplicationId_CLOCK_AND_TIMEKEEPING:
-			panic("Implement me")
+			switch salCommand {
+			case readWriteModel.ClockAndTimekeepingCommandType_UPDATE_NETWORK_VARIABLE.PLC4XEnumName():
+				panic("Implement me") // TODO: implement
+			case readWriteModel.ClockAndTimekeepingCommandType_REQUEST_REFRESH.PLC4XEnumName():
+				panic("Implement me") // TODO: implement
+			default:
+				return nil, errors.Errorf("Unsupported command %s for %s", salCommand, field.application.ApplicationId())
+			}
 		case readWriteModel.ApplicationId_TELEPHONY_STATUS_AND_CONTROL:
-			panic("Implement me")
+			switch salCommand {
+			case readWriteModel.TelephonyCommandType_EVENT.PLC4XEnumName():
+				panic("Implement me") // TODO: implement
+			default:
+				return nil, errors.Errorf("Unsupported command %s for %s", salCommand, field.application.ApplicationId())
+			}
 		case readWriteModel.ApplicationId_MEASUREMENT:
-			panic("Implement me")
+			switch salCommand {
+			case readWriteModel.MeasurementCommandType_MEASUREMENT_EVENT.PLC4XEnumName():
+				panic("Implement me") // TODO: implement
+			default:
+				return nil, errors.Errorf("Unsupported command %s for %s", salCommand, field.application.ApplicationId())
+			}
 		case readWriteModel.ApplicationId_TESTING:
-			panic("Implement me")
+			switch salCommand {
+			// TODO:implement
+			default:
+				return nil, errors.Errorf("Unsupported command %s for %s", salCommand, field.application.ApplicationId())
+			}
 		case readWriteModel.ApplicationId_MEDIA_TRANSPORT_CONTROL:
-			panic("Implement me")
+			switch salCommand {
+			case readWriteModel.MediaTransportControlCommandType_STOP.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_PLAY.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_PAUSE_RESUME.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_SELECT_CATEGORY.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_SELECT_SELECTION.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_SELECT_TRACK.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_SHUFFLE_ON_OFF.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_REPEAT_ON_OFF.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_NEXT_PREVIOUS_CATEGORY.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_NEXT_PREVIOUS_SELECTION.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_NEXT_PREVIOUS_TRACK.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_FAST_FORWARD.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_REWIND.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_SOURCE_POWER_CONTROL.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_TOTAL_TRACKS.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_STATUS_REQUEST.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_ENUMERATE_CATEGORIES_SELECTIONS_TRACKS.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_ENUMERATION_SIZE.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_TRACK_NAME.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_SELECTION_NAME.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_CATEGORY_NAME.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.MediaTransportControlCommandType_FAST_FORWARD.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			default:
+				return nil, errors.Errorf("Unsupported command %s for %s", salCommand, field.application.ApplicationId())
+			}
 		case readWriteModel.ApplicationId_ERROR_REPORTING:
-			panic("Implement me")
+			switch salCommand {
+			case readWriteModel.ErrorReportingCommandType_DEPRECATED.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.ErrorReportingCommandType_ERROR_REPORT.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.ErrorReportingCommandType_ACKNOWLEDGE.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			case readWriteModel.ErrorReportingCommandType_CLEAR_MOST_SEVERE.PLC4XEnumName():
+				panic("Implement me") // TODO: implement me
+			default:
+				return nil, errors.Errorf("Unsupported command %s for %s", salCommand, field.application.ApplicationId())
+			}
 		default:
 			return nil, errors.Errorf("No support for %s", field.application)
 		}
diff --git a/protocols/c-bus/src/main/resources/protocols/cbus/c-bus_air_conditioning_application.mspec b/protocols/c-bus/src/main/resources/protocols/cbus/c-bus_air_conditioning_application.mspec
index de0276110..e66664f7e 100644
--- a/protocols/c-bus/src/main/resources/protocols/cbus/c-bus_air_conditioning_application.mspec
+++ b/protocols/c-bus/src/main/resources/protocols/cbus/c-bus_air_conditioning_application.mspec
@@ -30,8 +30,8 @@
             [simple   byte                format              ]
             [simple   HVACModeAndFlags    hvacModeAndFlags    ]
             [simple   HVACStartTime       startTime           ]
-            [optional HVACTemperature     level 'hvacModeAndFlags.isLevelTemperature'   ]
-            [optional HVACRawLevels       rawLevel 'hvacModeAndFlags.isLevelRaw'        ]
+            [optional HVACTemperature     level               'hvacModeAndFlags.isLevelTemperature'   ]
+            [optional HVACRawLevels       rawLevel            'hvacModeAndFlags.isLevelRaw'           ]
         ]
         ['HUMIDITY_SCHEDULE_ENTRY'          *HumidityScheduleEntry
             [simple   byte                      zoneGroup               ]
@@ -40,8 +40,8 @@
             [simple   byte                      format                  ]
             [simple   HVACHumidityModeAndFlags  humidityModeAndFlags    ]
             [simple   HVACStartTime             startTime               ]
-            [optional HVACHumidity              level    'humidityModeAndFlags.isLevelHumidity'   ]
-            [optional HVACRawLevels             rawLevel 'humidityModeAndFlags.isLevelRaw'        ]
+            [optional HVACHumidity              level                   'humidityModeAndFlags.isLevelHumidity'   ]
+            [optional HVACRawLevels             rawLevel                'humidityModeAndFlags.isLevelRaw'        ]
         ]
         ['REFRESH'                          *Refresh
             [simple   byte                      zoneGroup               ]