From d641f383b8ada15c8dde9e5bd3c49c5c434c674e Mon Sep 17 00:00:00 2001 From: Ernst Swanepoel Date: Fri, 9 Jan 2026 14:58:04 +0100 Subject: [PATCH] Update to Q2.4.x Added additional Local Storage settings and endpoint. Updated defined limits. Updated Setting for CAN42S, CHS42X and THM427. --- .gitignore | 1 + DeviceFeatures/LocalStorage.cs | 22 +++ GenericDefines/EndPoints.cs | 1 + GenericDefines/Generic.cs | 10 +- InternalChannels/XMC1XX/XMC100IcpChannel.cs | 8 +- InternalChannels/XMC237/XMC237GpsChannel.cs | 35 +---- InternalChannels/XMC237/XMC237IcpChannel.cs | 8 +- InternalChannels/XMC23X/XMC23XModule.cs | 157 ++++++++++++++++++++ InternalModules/CAN/CAN42S2Module.cs | 41 +++++ InternalModules/CHS/CHS42X4Channel.cs | 3 + InternalModules/THM/THM427Channel.cs | 16 +- QProtocol.csproj | 6 +- 12 files changed, 257 insertions(+), 51 deletions(-) create mode 100644 InternalChannels/XMC23X/XMC23XModule.cs diff --git a/.gitignore b/.gitignore index dfcfd56..0fca7e5 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ *.user *.userosscache *.sln.docstates +*.idea # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs diff --git a/DeviceFeatures/LocalStorage.cs b/DeviceFeatures/LocalStorage.cs index fda4df7..babe3a0 100644 --- a/DeviceFeatures/LocalStorage.cs +++ b/DeviceFeatures/LocalStorage.cs @@ -54,12 +54,21 @@ public struct SettingsPreRunDurationInSecondsAsSingle public const Single LowerLimit = 0F; } + public struct SettingsRecordingDurationInSecondsAsUInt32 + { + public const UInt32 UpperLimit = 4294967295; + public const UInt32 LowerLimit = 0; + } + [Serializable] public class Settings { [RestfulProperties("Pre-run Duration")] public Single PreRunDurationInSeconds { get; set; } + [RestfulProperties("Recording Duration")] + public UInt32 RecordingDurationInSeconds { get; set; } + [RestfulProperties("Measurement Name")] public String MeasurementName { get; set; } @@ -85,6 +94,19 @@ public class RecordingStats [RestfulProperties("UsagePercentage")] public UInt32 UsagePercentage { get; set; } + + [RestfulProperties("RecordingDuration")] + public UInt32 RecordingDuration { get; set; } + + [RestfulProperties("RecordingSecondsLeft")] + public UInt32 RecordingSecondsLeft { get; set; } + } + + [Serializable] + public class Measurement + { + [RestfulProperties("Name")] + public String Name { get; set; } } } } diff --git a/GenericDefines/EndPoints.cs b/GenericDefines/EndPoints.cs index 34bc81d..a62bb54 100644 --- a/GenericDefines/EndPoints.cs +++ b/GenericDefines/EndPoints.cs @@ -28,6 +28,7 @@ public class EndPoints public const System.String RecordingState = "/recording/state/"; public const System.String RecordingStats = "/recording/stats/"; public const System.String LocalStorageSettings = "/localStorage/settings/"; + public const System.String LocalStorageMeasurementList = "/localStorage/measurement/list/"; public const System.String SystemSettings = "/system/settings/"; public const System.String SystemSettingsApply = "/system/settings/apply/"; public const System.String SystemSettingsResetToDefaults = "/system/settings/resetToDefaults/"; diff --git a/GenericDefines/Generic.cs b/GenericDefines/Generic.cs index aa11529..4b548b4 100644 --- a/GenericDefines/Generic.cs +++ b/GenericDefines/Generic.cs @@ -38,14 +38,14 @@ public enum Bool public enum DataResolution { + [RestfulProperties("16 bit")] + _16b = 0, + [RestfulProperties("32 bit")] - _32b = 0, + _32b = 1, [RestfulProperties("24 bit")] - _24b = 1, - - [RestfulProperties("16 bit")] - _16b = 2, + _24b = 2, } public enum SettingState diff --git a/InternalChannels/XMC1XX/XMC100IcpChannel.cs b/InternalChannels/XMC1XX/XMC100IcpChannel.cs index 067ae26..b2106a2 100644 --- a/InternalChannels/XMC1XX/XMC100IcpChannel.cs +++ b/InternalChannels/XMC1XX/XMC100IcpChannel.cs @@ -136,14 +136,14 @@ public struct DCatSettingsLowerADCOverloadLimitVoltageAsSingle public struct DCatSettingsOpenIcpSensorIntegrityLimitAsInt32 { - public const Int32 UpperLimit = 2147483647; - public const Int32 LowerLimit = -2147483648; + public const Int32 UpperLimit = 32767; + public const Int32 LowerLimit = -32768; } public struct DCatSettingsShortedIcpSensorIntegrityLimitAsInt32 { - public const Int32 UpperLimit = 2147483647; - public const Int32 LowerLimit = -2147483648; + public const Int32 UpperLimit = 32767; + public const Int32 LowerLimit = -32768; } [Serializable] diff --git a/InternalChannels/XMC237/XMC237GpsChannel.cs b/InternalChannels/XMC237/XMC237GpsChannel.cs index 1715a4f..3be329e 100644 --- a/InternalChannels/XMC237/XMC237GpsChannel.cs +++ b/InternalChannels/XMC237/XMC237GpsChannel.cs @@ -47,27 +47,6 @@ public enum MessageRate _10Hz = 3, } - public enum MessageClass - { - [RestfulProperties("NMEA")] - NMEA = 0, - } - - public enum NmeaMessageId - { - [RestfulProperties("NMEA GGA")] - Gga = 0, - - [RestfulProperties("NMEA GSA")] - Gsa = 1, - - [RestfulProperties("NMEA RMC")] - Rmc = 2, - - [RestfulProperties("NMEA VTG")] - Vtg = 3, - } - public interface ISettings { } @@ -83,20 +62,8 @@ public class XMC237GpsChannelOperationMode public class EnabledSettings : ISettings { - [RestfulProperties("Message rate")] + [RestfulProperties("Message Rate")] public MessageRate MessageRate { get; set; } = MessageRate._1Hz; - - [RestfulProperties("NMEA GGA")] - public GenericDefines.Generic.Status NmeaGga { get; set; } = GenericDefines.Generic.Status.Disabled; - - [RestfulProperties("NMEA GSA")] - public GenericDefines.Generic.Status NmeaGsa { get; set; } = GenericDefines.Generic.Status.Disabled; - - [RestfulProperties("NMEA RMC")] - public GenericDefines.Generic.Status NmeaRmc { get; set; } = GenericDefines.Generic.Status.Disabled; - - [RestfulProperties("NMEA VTG")] - public GenericDefines.Generic.Status NmeaVtg { get; set; } = GenericDefines.Generic.Status.Disabled; } [Serializable] diff --git a/InternalChannels/XMC237/XMC237IcpChannel.cs b/InternalChannels/XMC237/XMC237IcpChannel.cs index b38a4fa..de3ecf9 100644 --- a/InternalChannels/XMC237/XMC237IcpChannel.cs +++ b/InternalChannels/XMC237/XMC237IcpChannel.cs @@ -136,14 +136,14 @@ public struct DCatSettingsLowerADCOverloadLimitVoltageAsSingle public struct DCatSettingsOpenIcpSensorIntegrityLimitAsInt32 { - public const Int32 UpperLimit = 2147483647; - public const Int32 LowerLimit = -2147483648; + public const Int32 UpperLimit = 32767; + public const Int32 LowerLimit = -32768; } public struct DCatSettingsShortedIcpSensorIntegrityLimitAsInt32 { - public const Int32 UpperLimit = 2147483647; - public const Int32 LowerLimit = -2147483648; + public const Int32 UpperLimit = 32767; + public const Int32 LowerLimit = -32768; } [Serializable] diff --git a/InternalChannels/XMC23X/XMC23XModule.cs b/InternalChannels/XMC23X/XMC23XModule.cs new file mode 100644 index 0000000..a4cd4fd --- /dev/null +++ b/InternalChannels/XMC23X/XMC23XModule.cs @@ -0,0 +1,157 @@ +// ------------------------------------------------------------------------- +// Copyright (c) Mecalc (Pty) Limited. All rights reserved. +// ------------------------------------------------------------------------- + +using QProtocol.Advanced; +using QProtocol.Attributes; +using QProtocol.GenericDefines; +using QProtocol.Interfaces; +using QProtocol.JsonProperties; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace QProtocol.InternalChannels.XMC23X +{ + [Serializable] + public class XMC23XModule : Item + { + public XMC23XModule(Item itemInfo) + : base(itemInfo) + { + } + + public const System.Int32 MaxNumberOfChannels = 63; + + public enum OperationMode + { + [RestfulProperties("Disabled")] + Disabled = 0, + + [RestfulProperties("Enabled")] + Enabled = 1, + } + + public enum DevicePresence + { + [RestfulProperties("Absent")] + Absent = 0, + + [RestfulProperties("Present")] + Present = 1, + } + + public enum DeviceType + { + [RestfulProperties("Invalid")] + Invalid = 0, + + [RestfulProperties("Config")] + Config = 1, + + [RestfulProperties("CAN FD")] + CanFd = 2, + + [RestfulProperties("GPS")] + Gps = 3, + + [RestfulProperties("Headset PCM Stereo")] + HeadsetPcmStereo = 4, + } + + public struct ConfiguredChannelsIDAsUInt32 + { + public const UInt32 UpperLimit = 4294967295; + public const UInt32 LowerLimit = 0; + } + + [Serializable] + public class ConfiguredChannels + { + [RestfulProperties("Channel ID")] + public UInt32 ID { get; set; } + + [RestfulProperties("Device Type")] + public DeviceType XMC23XDeviceType { get; set; } + + [RestfulProperties("Device Presence")] + public DevicePresence DevicePresence { get; set; } + } + + public interface ISettings + { + } + + [Serializable] + public class XMC23XModuleOperationMode + { + [RestfulProperties("Operation Mode")] + public OperationMode OperationMode { get; set; } = OperationMode.Enabled; + } + + [Serializable] + public class EnabledSettings : ISettings + { + + [RestfulProperties("")] + public Int32 Reserved { get; set; } + } + + [Serializable] + public class SettingsCollection + where T : ISettings + { + public T Settings { get; set; } + + public Data Data { get; set; } + } + + + public void PutItemSettings(SettingsCollection settings) + where T : ISettings + { + var jsonObject = new ItemSettings(this); + jsonObject.UpdateFromSettings(settings.Settings); + jsonObject.UpdateFromData(settings.Data); + base.PutItemSettings(jsonObject); + } + + public SettingsCollection GetItemSettings() + where T : ISettings + { + var jsonObject = base.GetItemSettings(); + return new SettingsCollection + { + Settings = jsonObject.ConvertToSettings(), + Data = jsonObject.ConvertToData() + }; + } + + public SettingsCollection GetItemSettingsDefaults() + where T : ISettings + { + var jsonObject = base.GetItemSettingsDefaults(); + return new SettingsCollection + { + Settings = jsonObject.ConvertToSettings(), + Data = jsonObject.ConvertToData() + }; + } + + public void PutItemOperationMode(OperationMode operationMode) + { + var operationModeSettings = new ItemOperationMode(this) + { + Settings = Setting.ConvertFrom(new XMC23XModuleOperationMode() {OperationMode = operationMode}), + }; + + base.PutItemOperationMode(operationModeSettings); + } + + public new OperationMode GetItemOperationMode() + { + var jsonObject = base.GetItemOperationMode(); + return Setting.ConvertTo(jsonObject.Settings).OperationMode; + } + } +} diff --git a/InternalModules/CAN/CAN42S2Module.cs b/InternalModules/CAN/CAN42S2Module.cs index 9451e95..98852c6 100644 --- a/InternalModules/CAN/CAN42S2Module.cs +++ b/InternalModules/CAN/CAN42S2Module.cs @@ -48,12 +48,44 @@ public class EnabledSettings : ISettings { } + [Serializable] + public class SettingsCollection + where T : ISettings + { + public T Settings { get; set; } + + public Data Data { get; set; } + } + + + public SettingsCollection GetItemSettingsDefaults() + where T : ISettings + { + var jsonObject = base.GetItemSettingsDefaults(); + return new SettingsCollection + { + Settings = jsonObject.ConvertToSettings(), + Data = jsonObject.ConvertToData() + }; + } + public new OperationMode GetItemOperationMode() { var jsonObject = base.GetItemOperationMode(); return Setting.ConvertTo(jsonObject.Settings).OperationMode; } + public SettingsCollection GetItemSettings() + where T : ISettings + { + var jsonObject = base.GetItemSettings(); + return new SettingsCollection + { + Settings = jsonObject.ConvertToSettings(), + Data = jsonObject.ConvertToData() + }; + } + public void PutItemOperationMode(OperationMode operationMode) { var operationModeSettings = new ItemOperationMode(this) @@ -63,5 +95,14 @@ public void PutItemOperationMode(OperationMode operationMode) base.PutItemOperationMode(operationModeSettings); } + + public void PutItemSettings(SettingsCollection settings) + where T : ISettings + { + var jsonObject = new ItemSettings(this); + jsonObject.UpdateFromSettings(settings.Settings); + jsonObject.UpdateFromData(settings.Data); + base.PutItemSettings(jsonObject); + } } } diff --git a/InternalModules/CHS/CHS42X4Channel.cs b/InternalModules/CHS/CHS42X4Channel.cs index 9e02270..623bd62 100644 --- a/InternalModules/CHS/CHS42X4Channel.cs +++ b/InternalModules/CHS/CHS42X4Channel.cs @@ -110,6 +110,9 @@ public enum ChargeInputCoupling { [RestfulProperties("AC With 1 Hz Filter")] AcWith1HzFilter = 0, + + [RestfulProperties("AC")] + Ac = 1, } public interface ISettings diff --git a/InternalModules/THM/THM427Channel.cs b/InternalModules/THM/THM427Channel.cs index cafafad..f2d8894 100644 --- a/InternalModules/THM/THM427Channel.cs +++ b/InternalModules/THM/THM427Channel.cs @@ -45,8 +45,11 @@ public enum OperationMode [RestfulProperties("Thermocouple Type U Input")] ThermocoupleTypeUInput = 6, + [RestfulProperties("Thermocouple Type N Input")] + ThermocoupleTypeNInput = 7, + [RestfulProperties("PT100 Input")] - Pt100Input = 7, + Pt100Input = 8, } public enum VoltageRange @@ -158,6 +161,17 @@ public class Pt100Input : ISettings public TemperatureSIUnits TemperatureSIUnits { get; set; } = TemperatureSIUnits.Celsius; } + [Serializable] + public class ThermocoupleTypeNInput : ISettings + { + + [RestfulProperties("Voltage Range")] + public TemperatureModeVoltageRange TemperatureModeVoltageRange { get; set; } = TemperatureModeVoltageRange._100mV; + + [RestfulProperties("Temperature SI Unit")] + public TemperatureSIUnits TemperatureSIUnits { get; set; } = TemperatureSIUnits.Celsius; + } + [Serializable] public class SettingsCollection where T : ISettings diff --git a/QProtocol.csproj b/QProtocol.csproj index 15d5be5..21938b6 100644 --- a/QProtocol.csproj +++ b/QProtocol.csproj @@ -4,10 +4,10 @@ netstandard2.0 AnyCPU;x86;x64 Debug;Release;BuildServer - 2.3.0.0 - 2.3.0.0 + 2.4.0.0 + 2.4.0.0 Mecalc (Pty) Ltd - Mecalc (Pty) Ltd © 2023 + Mecalc (Pty) Ltd © 2023 Mecalc (Pty) Ltd True latest