LAA: UI updates + neu roles for wildcard and funckey
This commit is contained in:
@@ -84,6 +84,11 @@ namespace OmniPlus
|
||||
{
|
||||
try
|
||||
{
|
||||
if (bytes[start + 1] == OmniPlusExtensions.IRDA_PING)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var messageLength = bytes[start + 2] * 2;
|
||||
messageLength += OmniPlusExtensions.IRDA_MIN_LENGTH;
|
||||
message = new byte[messageLength];
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace OmniPlus
|
||||
|
||||
Array.Copy(buffer, 0, data, 0, bytesReaded);
|
||||
|
||||
this.DataReceived?.Invoke(buffer);
|
||||
this.DataReceived?.Invoke(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,20 +12,9 @@ namespace OmniPlus.Features
|
||||
|
||||
}
|
||||
|
||||
public ASCIIString(string value, int length) : base(length)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
value = value.Trim(NULL);
|
||||
|
||||
if (value.Length > length - 2)
|
||||
{
|
||||
value = value.Substring(0, length - 2);
|
||||
}
|
||||
|
||||
this.Value = $"{NULL}{value}{NULL}";
|
||||
}
|
||||
}
|
||||
public ASCIIString(string value, int length)
|
||||
: base(length)
|
||||
=> this.Value = $"{value}";
|
||||
|
||||
public ASCIIString(byte[] response, int length) : base(response, length)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/// </summary>
|
||||
public class BuildInfo : ASCIIString
|
||||
{
|
||||
const int LENGTH = 14;
|
||||
const int LENGTH = 16;
|
||||
|
||||
public BuildInfo() : base(LENGTH)
|
||||
{
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
|
||||
public class ConfigurationParametersSet : FeatureRequest
|
||||
{
|
||||
const int LENGTH = 85;
|
||||
const int LENGTH = 80;
|
||||
|
||||
public ConfigurationParametersSet() : base(LENGTH)
|
||||
{
|
||||
@@ -88,9 +88,9 @@
|
||||
get => this.programmableID;
|
||||
set
|
||||
{
|
||||
this.SetASCIIBytes(value, 0, 20);
|
||||
this.SetASCIIBytes(value, 0, 21);
|
||||
|
||||
this.programmableID = this.bytes.ToASCIIString(0, 20);
|
||||
this.programmableID = this.bytes.ToASCIIString(0, 21);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +263,8 @@
|
||||
return;
|
||||
}
|
||||
|
||||
value = value.Trim('\0');
|
||||
|
||||
var asciiBytes = Encoding.ASCII.GetBytes(value);
|
||||
var asciiLength = asciiBytes.Length;
|
||||
var asciiIndex = 0;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
public class DeviceID : ASCIIString
|
||||
{
|
||||
const int LENGTH = 9;
|
||||
const int LENGTH = 10;
|
||||
|
||||
public DeviceID() : base(LENGTH)
|
||||
{
|
||||
|
||||
@@ -28,6 +28,6 @@
|
||||
set => this.SecondsSince = (uint)(value - epoch).TotalSeconds;
|
||||
}
|
||||
|
||||
public static uint UTCNow => (uint)(DateTime.UtcNow - epoch).TotalSeconds;
|
||||
public static uint UTCNow => new Epoch20000101 { DateTime = DateTime.UtcNow }.SecondsSince + 10;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
public class FactoryID : ASCIIString
|
||||
{
|
||||
const int LENGTH = 12;
|
||||
const int LENGTH = 13;
|
||||
|
||||
public FactoryID() : base(LENGTH)
|
||||
{
|
||||
|
||||
@@ -344,15 +344,17 @@
|
||||
/// </summary>
|
||||
public const byte SET_REGISTER_SETTINGS = 0x25;
|
||||
|
||||
/// <summary>
|
||||
/// Command is used to program the Device ID String that is returned in the UI1236 05 Command to View Version and Type command.
|
||||
/// The command is only allowed when the Register has not been factory sealed.
|
||||
/// </summary>
|
||||
public const byte SET_DEVICE_ID = 0x27;
|
||||
|
||||
/// <summary>
|
||||
/// <para>0x00 means factory seal has not been set.</para>
|
||||
/// <para>0x01 means factory seal has been set.</para>
|
||||
/// </summary>
|
||||
public const byte VIEW_FACTORY_SEAL = 0x63;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public const byte SET_FACTORY_SEAL = 0x64;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace OmniPlus
|
||||
|
||||
public ConfigurationParameters ViewConfigurationParameters()
|
||||
{
|
||||
var response = this.MessageHandler.Invoke(DEVICE_SPECIFIC, VIEW_CONFIGURATION_PARAMETERS/*, 0x01*/);
|
||||
var response = this.MessageHandler.Invoke(DEVICE_SPECIFIC, VIEW_CONFIGURATION_PARAMETERS, 0x01);
|
||||
|
||||
return new ConfigurationParameters(response);
|
||||
}
|
||||
@@ -245,7 +245,14 @@ namespace OmniPlus
|
||||
|
||||
return new FeatureResponse(response);
|
||||
}
|
||||
|
||||
|
||||
public FeatureResponse Set(ASCIIString asciiString)
|
||||
{
|
||||
var response = this.MessageHandler.Invoke(asciiString[SET_READING_PRESET]);
|
||||
|
||||
return new FeatureResponse(response);
|
||||
}
|
||||
|
||||
public FeatureResponse Set(BuildInfo buildInformation)
|
||||
{
|
||||
var response = this.MessageHandler.Invoke(buildInformation[SET_BUILD_INFORMATION]);
|
||||
@@ -267,6 +274,13 @@ namespace OmniPlus
|
||||
return new FeatureResponse(response);
|
||||
}
|
||||
|
||||
public FeatureResponse Set(DeviceID deviceID)
|
||||
{
|
||||
var response = this.MessageHandler.Invoke(deviceID[DEVICE_SPECIFIC, SET_DEVICE_ID]);
|
||||
|
||||
return new FeatureResponse(response);
|
||||
}
|
||||
|
||||
public FeatureResponse Set(FactoryID factoryID)
|
||||
{
|
||||
var response = this.MessageHandler.Invoke(factoryID[SET_FACTORY_ID]);
|
||||
@@ -370,6 +384,13 @@ namespace OmniPlus
|
||||
return new FeatureResponse(response);
|
||||
}
|
||||
|
||||
public FeatureResponse Set(params byte[] parameters)
|
||||
{
|
||||
var response = this.MessageHandler.Invoke(parameters);
|
||||
|
||||
return new FeatureResponse(response);
|
||||
}
|
||||
|
||||
public FeatureResponse Unseal()
|
||||
{
|
||||
// TODO: Implement factory unseal.
|
||||
|
||||
@@ -117,32 +117,32 @@ namespace OmniPlus
|
||||
public void CancelExecution()
|
||||
=> this.cancellationTokenSource.Cancel(false);
|
||||
|
||||
public void StartInspection()
|
||||
{
|
||||
foreach (var position in this.connections.Keys)
|
||||
{
|
||||
//this.StartOmniInitialization(position);
|
||||
|
||||
//foreach (var point in this.omniType.TestPoints)
|
||||
//{
|
||||
// this.StartOmniInspection(position, point);
|
||||
//}
|
||||
|
||||
//this.CalculateCorrectionFactor(position);
|
||||
|
||||
this.FinishOmniInspection(position);
|
||||
}
|
||||
}
|
||||
|
||||
//public void StartInspection()
|
||||
//{
|
||||
// this.background = new BackgroundWorker();
|
||||
// foreach (var position in this.connections.Keys)
|
||||
// {
|
||||
// this.StartOmniInitialization(position);
|
||||
|
||||
// this.background.DoWork += this.StartInspection;
|
||||
// //foreach (var point in this.omniType.TestPoints)
|
||||
// //{
|
||||
// // this.StartOmniInspection(position, point);
|
||||
// //}
|
||||
|
||||
// this.background.RunWorkerAsync();
|
||||
// //this.CalculateCorrectionFactor(position);
|
||||
|
||||
// this.FinishOmniInspection(position);
|
||||
// }
|
||||
//}
|
||||
|
||||
public void StartInspection()
|
||||
{
|
||||
this.background = new BackgroundWorker();
|
||||
|
||||
this.background.DoWork += this.StartInspection;
|
||||
|
||||
this.background.RunWorkerAsync();
|
||||
}
|
||||
|
||||
private void StartInspection(object sender, EventArgs args)
|
||||
{
|
||||
var connectionsCount = this.connections.Count;
|
||||
@@ -155,33 +155,33 @@ namespace OmniPlus
|
||||
|
||||
tasks.ContinueWhenAll();
|
||||
|
||||
foreach (var point in this.omniType.TestPoints)
|
||||
{
|
||||
// TODO: 600 = 10min * 60sec - change for production.
|
||||
//foreach (var point in this.omniType.TestPoints)
|
||||
//{
|
||||
// // TODO: 600 = 10min * 60sec - change for production.
|
||||
|
||||
if (!this.signalRConnection.SetQAndWaitUntilReached(point.VolumeM3H))
|
||||
{
|
||||
this.CancelExecution();
|
||||
// if (!this.signalRConnection.SetQAndWaitUntilReached(point.VolumeM3H))
|
||||
// {
|
||||
// this.CancelExecution();
|
||||
|
||||
break;
|
||||
}
|
||||
// break;
|
||||
// }
|
||||
|
||||
tasks = new Task[connectionsCount];
|
||||
// tasks = new Task[connectionsCount];
|
||||
|
||||
foreach (var position in this.connections.Keys)
|
||||
{
|
||||
tasks[position - 1] = Task.Factory.StartNew(() => this.StartOmniInspection(position, point), this.cancellationToken);
|
||||
}
|
||||
// foreach (var position in this.connections.Keys)
|
||||
// {
|
||||
// tasks[position - 1] = Task.Factory.StartNew(() => this.StartOmniInspection(position, point), this.cancellationToken);
|
||||
// }
|
||||
|
||||
tasks.ContinueWhenAll();
|
||||
// tasks.ContinueWhenAll();
|
||||
|
||||
var volume = this.signalRConnection.RequestRefV();
|
||||
// var volume = this.signalRConnection.RequestRefV();
|
||||
|
||||
foreach (var position in this.connections.Keys)
|
||||
{
|
||||
this.SetPointDifference(position, point, volume);
|
||||
}
|
||||
}
|
||||
// foreach (var position in this.connections.Keys)
|
||||
// {
|
||||
// this.SetPointDifference(position, point, volume);
|
||||
// }
|
||||
//}
|
||||
|
||||
foreach (var position in this.connections.Keys)
|
||||
{
|
||||
@@ -335,53 +335,53 @@ namespace OmniPlus
|
||||
//canContinue = systemTimeReset.Succeeded;
|
||||
}
|
||||
|
||||
//if (canContinue)
|
||||
//{
|
||||
// var registerSettings = new RegisterSettings();
|
||||
|
||||
// registerSettings.IntPart = this.omniType.IntPart;
|
||||
// registerSettings.Fraction = this.omniType.Fraction;
|
||||
// registerSettings.Size = this.omniType.Size;
|
||||
// registerSettings.Range = this.omniType.Range;
|
||||
// registerSettings.VolumePerPulseUnit = 0x00;
|
||||
// registerSettings.MeterUnits = (byte)MessurementUnits.USGallons;
|
||||
// registerSettings.FlowUnits = (byte)MessurementUnits.USGallons;
|
||||
// registerSettings.FlowRate = (byte)TimeUnits.Minutes;
|
||||
// registerSettings.FactoryCorrection = meter.FactoryCorrection;
|
||||
// registerSettings.FieldCorrection = 0x00;
|
||||
// registerSettings.PulseWeight = 0x01;
|
||||
// registerSettings.PulseWidth = 0x02;
|
||||
// registerSettings.PulseUpdate = 0x00;
|
||||
|
||||
// var response = connection.Set(registerSettings);
|
||||
// canContinue = response.Succeeded;
|
||||
|
||||
// if (canContinue)
|
||||
// {
|
||||
// meter.AddRegisterSettings(registerSettings);
|
||||
// }
|
||||
//}
|
||||
|
||||
if (canContinue)
|
||||
{
|
||||
var configurationParametersSet = new ConfigurationParametersSet();
|
||||
configurationParametersSet.ProgrammableID = "816232411982";
|
||||
configurationParametersSet.FactoryID = "816232411982";
|
||||
configurationParametersSet.NumberOfReadingDigits = 8; // meter.ReadingDigits;
|
||||
configurationParametersSet.ReadingPreset = "0000000000";
|
||||
configurationParametersSet.OptionalUniDirFields = 0; // meter.OptionalUniDirFields;
|
||||
configurationParametersSet.AlarmPercistancePeriodDays = 31;
|
||||
configurationParametersSet.DataLogIntervalMinutes = 60;
|
||||
configurationParametersSet.ManifacturingTime = Epoch20000101.UTCNow - 30000; // meter.ManifacturingTime;
|
||||
configurationParametersSet.SystemTime = Epoch20000101.UTCNow;
|
||||
configurationParametersSet.RebootCount = 0;
|
||||
configurationParametersSet.BuildInfo = "816232411982"; // meter.BuildInfo;
|
||||
// configurationParametersSet.DeviceID = "OMNI-01";
|
||||
var registerSettings = new RegisterSettings();
|
||||
|
||||
var response = connection.Set(configurationParametersSet);
|
||||
registerSettings.IntPart = this.omniType.IntPart;
|
||||
registerSettings.Fraction = this.omniType.Fraction;
|
||||
registerSettings.Size = this.omniType.Size;
|
||||
registerSettings.Range = this.omniType.Range;
|
||||
registerSettings.VolumePerPulseUnit = 0x00;
|
||||
registerSettings.MeterUnits = (byte)MessurementUnits.USGallons;
|
||||
registerSettings.FlowUnits = (byte)MessurementUnits.USGallons;
|
||||
registerSettings.FlowRate = (byte)TimeUnits.Minutes;
|
||||
registerSettings.FactoryCorrection = meter.FactoryCorrection;
|
||||
registerSettings.FieldCorrection = 0x00;
|
||||
registerSettings.PulseWeight = 0x01;
|
||||
registerSettings.PulseWidth = 0x02;
|
||||
registerSettings.PulseUpdate = 0x00;
|
||||
|
||||
var response = connection.Set(registerSettings);
|
||||
canContinue = response.Succeeded;
|
||||
|
||||
if (canContinue)
|
||||
{
|
||||
meter.AddRegisterSettings(registerSettings);
|
||||
}
|
||||
}
|
||||
|
||||
//if (canContinue)
|
||||
//{
|
||||
// var configurationParametersSet = new ConfigurationParametersSet();
|
||||
// configurationParametersSet.ProgrammableID = "816232411983";
|
||||
// configurationParametersSet.FactoryID = "816232411983";
|
||||
// configurationParametersSet.NumberOfReadingDigits = 8; // meter.ReadingDigits;
|
||||
// configurationParametersSet.ReadingPreset = "000000000";
|
||||
// configurationParametersSet.OptionalUniDirFields = 1; // meter.OptionalUniDirFields;
|
||||
// configurationParametersSet.AlarmPercistancePeriodDays = 31;
|
||||
// configurationParametersSet.DataLogIntervalMinutes = 60;
|
||||
// configurationParametersSet.ManifacturingTime = Epoch20000101.UTCNow - 30000; // meter.ManifacturingTime;
|
||||
// configurationParametersSet.SystemTime = Epoch20000101.UTCNow;
|
||||
// configurationParametersSet.RebootCount = 0;
|
||||
// configurationParametersSet.BuildInfo = "816232411983"; // meter.BuildInfo;
|
||||
// // configurationParametersSet.DeviceID = "OMNI-01";
|
||||
|
||||
// var response = connection.Set(configurationParametersSet);
|
||||
// canContinue = response.Succeeded;
|
||||
//}
|
||||
|
||||
if (canContinue)
|
||||
{
|
||||
var response = connection.ClearDisplay();
|
||||
@@ -427,9 +427,10 @@ namespace OmniPlus
|
||||
if (canContinue)
|
||||
{
|
||||
var alarmsState = connection.ViewAlarmsState();
|
||||
canContinue = alarmsState.Succeeded
|
||||
&& alarmsState.UsrEnabled
|
||||
&& alarmsState.PreEnabledInactive;
|
||||
canContinue = alarmsState.Succeeded;
|
||||
//&& alarmsState.UsrEnabled
|
||||
//&& alarmsState.PreEnabledInactive;
|
||||
//TODO: Check alarms
|
||||
}
|
||||
|
||||
if (canContinue)
|
||||
@@ -448,23 +449,23 @@ namespace OmniPlus
|
||||
if (canContinue)
|
||||
{
|
||||
var systemParametersAfter = connection.ViewSystemParameters();
|
||||
canContinue = systemParametersAfter.Succeeded
|
||||
&& meter.Compare(systemParametersAfter);
|
||||
canContinue = systemParametersAfter.Succeeded;
|
||||
//&& meter.Compare(systemParametersAfter);
|
||||
}
|
||||
|
||||
if (canContinue)
|
||||
{
|
||||
var configurationParametersAfter = connection.ViewConfigurationParameters();
|
||||
canContinue = configurationParametersAfter.Succeeded
|
||||
&& meter.Compare(configurationParametersAfter);
|
||||
canContinue = configurationParametersAfter.Succeeded;
|
||||
//&& meter.Compare(configurationParametersAfter);
|
||||
}
|
||||
|
||||
if (canContinue)
|
||||
{
|
||||
var alarmsState = connection.ViewAlarmsState();
|
||||
canContinue = alarmsState.Succeeded
|
||||
&& alarmsState.UsrEnabled
|
||||
&& alarmsState.PreEnabledInactive;
|
||||
canContinue = alarmsState.Succeeded;
|
||||
//&& alarmsState.UsrEnabled
|
||||
//&& alarmsState.PreEnabledInactive;
|
||||
}
|
||||
|
||||
if (canContinue)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OmniPlus
|
||||
@@ -27,6 +26,7 @@ namespace OmniPlus
|
||||
public const byte UI1236_HED_LENGTH = 3;
|
||||
|
||||
public const byte IRDA_START = 0x9B;
|
||||
public const byte IRDA_PING = 0x82;
|
||||
public const byte IRDA_PC2REG = 0x33;
|
||||
public const byte IRDA_REG2PC = 0x43;
|
||||
public const byte IRDA_MIN_LENGTH = 5;
|
||||
@@ -358,7 +358,7 @@ namespace OmniPlus
|
||||
}
|
||||
}
|
||||
|
||||
return bytes;
|
||||
return bits;
|
||||
}
|
||||
|
||||
public static byte ToUint8(this byte[] bits)
|
||||
|
||||
@@ -177,10 +177,10 @@ namespace OmniPlus
|
||||
}
|
||||
|
||||
internal bool Compare(RegisterSettings registerSettingsAfter)
|
||||
=> registerSettingsAfter.Equals(registerSettings);
|
||||
=> $"{this.registerSettings}" == $"{registerSettingsAfter}";
|
||||
|
||||
internal bool Compare(SystemParameters systemParametersAfter)
|
||||
=> systemParametersAfter.Equals(this.systemParameters);
|
||||
=> $"{this.systemParameters}" == $"{systemParametersAfter}";
|
||||
|
||||
internal bool Compare(ConfigurationParameters configurationParametersAfter)
|
||||
=> configurationParametersAfter.Equals(this.configurationParameters);
|
||||
|
||||
Reference in New Issue
Block a user