Cordonel FW power correction
This commit is contained in:
@@ -1,101 +1,115 @@
|
||||
namespace CommonConsole
|
||||
{
|
||||
using OmniPlus;
|
||||
using OmniPlus.Features;
|
||||
using OmniPlus.Features.Enums;
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
var optionalUniDir = BitConverter.ToInt16(new byte[] { 0xFC, 0x01 }, 0);
|
||||
var protokoll = new StringBuilder();
|
||||
var connection = new OmniIrdaConnection("COM36");
|
||||
connection.StateChenged += x => protokoll.AppendLine(x.ToString());
|
||||
connection.StateChenged += Console.WriteLine;
|
||||
connection.Open();
|
||||
var hexString = "5E-CC-02-1A-00-00-00-00-5E-CC-02-1A-00-00-00-00-5E-CC-02-1A-00-00-00-00-5E-CC-02-1A-00-00-00-00";
|
||||
var bytes = new List<byte>();
|
||||
var hex = string.Empty;
|
||||
|
||||
if (connection.FactorySeal().Sealed)
|
||||
foreach (var @char in hexString)
|
||||
{
|
||||
var _sealed = connection.FactorySeal(false);
|
||||
if (('0' <= @char && @char <= '9') || ('A' <= @char && @char <= 'F') || ('a' <= @char && @char <= 'f'))
|
||||
{
|
||||
hex += @char;
|
||||
}
|
||||
|
||||
var system = connection.ViewSystemParameters();
|
||||
var register = connection.ViewRegisterSettings();
|
||||
var configuration = connection.ViewConfigurationParameters();
|
||||
var systemReset = connection.Set(new SystemTime());
|
||||
|
||||
Thread.Sleep(10000);
|
||||
|
||||
var response = connection.Set(new RegisterSettings
|
||||
if (hex.Length == 2)
|
||||
{
|
||||
IntPart = register.IntPart,
|
||||
Fraction = register.Fraction,
|
||||
Size = register.Size,
|
||||
Range = register.Range,
|
||||
VolumePerPulseUnit = 0x00,
|
||||
MeterUnits = (byte)MessurementUnits.USGallons,
|
||||
FlowUnits = (byte)MessurementUnits.USGallons,
|
||||
FlowRate = (byte)TimeUnits.Minutes,
|
||||
FactoryCorrection = 0x00,
|
||||
FieldCorrection = 0x00,
|
||||
PulseWeight = 1,
|
||||
PulseWidth = 2,
|
||||
PulseUpdate = 0,
|
||||
});
|
||||
bytes.Add(Convert.ToByte(hex, 16));
|
||||
|
||||
response = connection.Set(new ConfigurationParametersSet
|
||||
{
|
||||
BuildInfo = "816232411982",
|
||||
ProgrammableID = "816232411982",
|
||||
FactoryID = "816232411982",
|
||||
AlarmPercistancePeriodDays = 31,
|
||||
DataLogIntervalMinutes = 60,
|
||||
ManifacturingTime = system.ManifacturingTime.SecondsSince,
|
||||
NumberOfReadingDigits = 8,
|
||||
OptionalUniDirFields = 0x01FC,
|
||||
ReadingPreset = "000000010",
|
||||
RebootCount = 0,
|
||||
SystemTime = Epoch20000101.UTCNow,
|
||||
DeviceID = "OMNI-02"
|
||||
});
|
||||
hex = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
response = connection.ClearDisplay();
|
||||
response = connection.Set(new LeakAlarm
|
||||
{
|
||||
FlowRateGPM = 0.25F,
|
||||
TimeLimit = 24 * 60 * 60
|
||||
});
|
||||
response = connection.Set(new HighFlowAlarm
|
||||
{
|
||||
FlowRateGPM = 25F,
|
||||
TimeLimit = 1 * 60 * 60
|
||||
});
|
||||
response = connection.Set(new ReverseFlowAlarm
|
||||
{
|
||||
FlowRateGPM = -1F,
|
||||
TimeLimit = 60
|
||||
});
|
||||
response = connection.ClearAlarms();
|
||||
response = connection.EnableNFC();
|
||||
var alarmsState = connection.ViewAlarmsState();
|
||||
response = connection.ViewAlarmSettings(0x01);
|
||||
response = connection.ViewAlarmSettings(0x02);
|
||||
response = connection.ViewAlarmSettings(0x04);
|
||||
response = connection.FactorySeal(true);
|
||||
response = connection.FactorySeal();
|
||||
system = connection.ViewSystemParameters();
|
||||
register = connection.ViewRegisterSettings();
|
||||
configuration = connection.ViewConfigurationParameters();
|
||||
//var optionalUniDir = BitConverter.ToInt16(new byte[] { 0xFC, 0x01 }, 0);
|
||||
//var protokoll = new StringBuilder();
|
||||
//var connection = new OmniIrdaConnection("COM36");
|
||||
//connection.StateChenged += x => protokoll.AppendLine(x.ToString());
|
||||
//connection.StateChenged += Console.WriteLine;
|
||||
//connection.Open();
|
||||
|
||||
connection.Close();
|
||||
//if (connection.FactorySeal().Sealed)
|
||||
//{
|
||||
// var _sealed = connection.FactorySeal(false);
|
||||
//}
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(protokoll.ToString());
|
||||
//var system = connection.ViewSystemParameters();
|
||||
//var register = connection.ViewRegisterSettings();
|
||||
//var configuration = connection.ViewConfigurationParameters();
|
||||
//var systemReset = connection.Set(new SystemTime());
|
||||
|
||||
//Thread.Sleep(10000);
|
||||
|
||||
//var response = connection.Set(new RegisterSettings
|
||||
//{
|
||||
// IntPart = register.IntPart,
|
||||
// Fraction = register.Fraction,
|
||||
// Size = register.Size,
|
||||
// Range = register.Range,
|
||||
// VolumePerPulseUnit = 0x00,
|
||||
// MeterUnits = (byte)MessurementUnits.USGallons,
|
||||
// FlowUnits = (byte)MessurementUnits.USGallons,
|
||||
// FlowRate = (byte)TimeUnits.Minutes,
|
||||
// FactoryCorrection = 0x00,
|
||||
// FieldCorrection = 0x00,
|
||||
// PulseWeight = 1,
|
||||
// PulseWidth = 2,
|
||||
// PulseUpdate = 0,
|
||||
//});
|
||||
|
||||
//response = connection.Set(new ConfigurationParametersSet
|
||||
//{
|
||||
// BuildInfo = "816232411982",
|
||||
// ProgrammableID = "816232411982",
|
||||
// FactoryID = "816232411982",
|
||||
// AlarmPercistancePeriodDays = 31,
|
||||
// DataLogIntervalMinutes = 60,
|
||||
// ManifacturingTime = system.ManifacturingTime.SecondsSince,
|
||||
// NumberOfReadingDigits = 8,
|
||||
// OptionalUniDirFields = 0x01FC,
|
||||
// ReadingPreset = "000000010",
|
||||
// RebootCount = 0,
|
||||
// SystemTime = Epoch20000101.UTCNow,
|
||||
// DeviceID = "OMNI-02"
|
||||
//});
|
||||
|
||||
//response = connection.ClearDisplay();
|
||||
//response = connection.Set(new LeakAlarm
|
||||
//{
|
||||
// FlowRateGPM = 0.25F,
|
||||
// TimeLimit = 24 * 60 * 60
|
||||
//});
|
||||
//response = connection.Set(new HighFlowAlarm
|
||||
//{
|
||||
// FlowRateGPM = 25F,
|
||||
// TimeLimit = 1 * 60 * 60
|
||||
//});
|
||||
//response = connection.Set(new ReverseFlowAlarm
|
||||
//{
|
||||
// FlowRateGPM = -1F,
|
||||
// TimeLimit = 60
|
||||
//});
|
||||
//response = connection.ClearAlarms();
|
||||
//response = connection.EnableNFC();
|
||||
//var alarmsState = connection.ViewAlarmsState();
|
||||
//response = connection.ViewAlarmSettings(0x01);
|
||||
//response = connection.ViewAlarmSettings(0x02);
|
||||
//response = connection.ViewAlarmSettings(0x04);
|
||||
//response = connection.FactorySeal(true);
|
||||
//response = connection.FactorySeal();
|
||||
//system = connection.ViewSystemParameters();
|
||||
//register = connection.ViewRegisterSettings();
|
||||
//configuration = connection.ViewConfigurationParameters();
|
||||
|
||||
//connection.Close();
|
||||
|
||||
//Console.WriteLine();
|
||||
//Console.WriteLine(protokoll.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
public Byte? ProductionRadioSystemState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Pulse adapter was installed during at EOL - Production
|
||||
/// Pulse adapter was installed during at EOL - Production VAKO
|
||||
/// </summary>
|
||||
public Boolean ProductionPulseAdapterIsInstalled { get; set; }
|
||||
|
||||
@@ -56,11 +56,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
/// </summary>
|
||||
public Boolean ProductionPulseEvenDistribution { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Detected region at EOL - Production
|
||||
/// </summary>
|
||||
public String ProductionRegion { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Maintenance readout
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
|
||||
public T GetValue<T>(int index = -1)
|
||||
{
|
||||
if (index > 0)
|
||||
if (index >= 0)
|
||||
{
|
||||
if (!this.sqlDataReader.IsDBNull(index))
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Common.SqlExtensions;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@@ -7,10 +8,12 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using Xylem.Common.Cryptology.Security;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
|
||||
using Xylem.Common.Logic.ProductionOrderCore.OrderData;
|
||||
using Xylem.Common.Logic.ServiceCore;
|
||||
@@ -891,6 +894,178 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("api/fwupdate/databaseateol/{pcbid}")]
|
||||
public IHttpActionResult DataBaseAtEOL(string pcbid)
|
||||
{
|
||||
var databaseAtEOL = SQLConnection
|
||||
.CreateSQLConnection(GlobalConfig.connectionString.Value, error =>
|
||||
{
|
||||
throw new Exception(error);
|
||||
})
|
||||
.CreateCommand($@"
|
||||
DECLARE @pcb AS VARCHAR(15) = @{nameof(pcbid)};
|
||||
DECLARE @latestRegisters AS TABLE (
|
||||
[PcbId] VARCHAR(10)
|
||||
, [Address] VARCHAR(10)
|
||||
, [Value] VARCHAR(250)
|
||||
, [Date] DATETIME);
|
||||
|
||||
INSERT INTO @latestRegisters
|
||||
SELECT [h].[PcbId]
|
||||
, [h].[Address]
|
||||
, [h].[Value]
|
||||
, [h].[Date]
|
||||
FROM (SELECT [PcbId]
|
||||
, [Address]
|
||||
, [Value]
|
||||
, [date] AS [Date]
|
||||
, RANK() OVER (PARTITION BY [Address] ORDER BY [Id] DESC) AS [Row]
|
||||
FROM [GenesisMeterRegisterHistory]
|
||||
WHERE [PcbId] = @pcb)
|
||||
AS [h]
|
||||
WHERE [h].[Row] = 1
|
||||
|
||||
SELECT (SELECT MAX([PcbId]) FROM @latestRegisters) AS [PcbId]
|
||||
, (SELECT MAX([Date]) FROM @latestRegisters) AS [ProductionDate]
|
||||
, (SELECT [Value] FROM @latestRegisters WHERE [Address] = '01-0A') AS [TotalUsedSeconds]
|
||||
, (SELECT [Value] FROM @latestRegisters WHERE [Address] = '01-09') AS [TotalUsedCharge]
|
||||
, (SELECT [Value] FROM @latestRegisters WHERE [Address] = '10-09') AS [RadioSystemState]
|
||||
, (SELECT [Value] FROM @latestRegisters WHERE [Address] = '12-03') AS [PulseMode]
|
||||
, (SELECT [Value] FROM @latestRegisters WHERE [Address] = '14-02') AS [PulseSequenceCounter]
|
||||
, (SELECT [Value] FROM @latestRegisters WHERE [Address] = '12-11') AS [PulseEvenDistribution]
|
||||
, (SELECT CAST(CASE WHEN COUNT(1) > 0 THEN 1 ELSE 0 END AS BIT)
|
||||
FROM [MapPcbIdToSerialNumber] AS [pcb2sn]
|
||||
LEFT JOIN [AlleAuftragPositionen] AS [aap]
|
||||
ON [aap].[SerienNrVon] <= [pcb2sn].[MapPcbIdToSerialNumber_SerialNumber]
|
||||
AND [aap].[SerienNrBis] >= [pcb2sn].[MapPcbIdToSerialNumber_SerialNumber]
|
||||
LEFT JOIN [Identnr] AS [idnr]
|
||||
ON [idnr].[IdentNr] = [aap].[IdentNr]
|
||||
WHERE [pcb2sn].[MapPcbIdToSerialNumber_PcbId] = @pcb
|
||||
AND [idnr].[Typ] = 'GNS'
|
||||
AND SUBSTRING([idnr].[VakoCode], 48, 1) IN ('K', 'Q')) AS [PulseAdapterIsInstalled]")
|
||||
.SetParameter(nameof(pcbid), pcbid)
|
||||
.FirstOrDefault(x =>
|
||||
{
|
||||
var model = new PowerCorrection();
|
||||
|
||||
model.PcbId = x.GetValue<string>(0);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(model.PcbId))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
model.ProductionDateTimeUtc = x.GetValue<DateTime>(1);
|
||||
model.ProductionTotalUsedSeconds_s = x.GetValue<string>(2).ToUint();
|
||||
model.ProductionTotalUsedCharge_uAs = x.GetValue<string>(3).ToUlong();
|
||||
model.ProductionRadioSystemState = x.GetValue<string>(4).ToNullableByte();
|
||||
model.ProductionPulseMode = x.GetValue<string>(5).ToByte();
|
||||
model.ProductionPulseSequenceCounter = x.GetValue<string>(6).ToByte();
|
||||
model.ProductionPulseEvenDistribution = x.GetValue<string>(7).ToBool();
|
||||
model.ProductionPulseAdapterIsInstalled = x.GetValue<bool>(8);
|
||||
|
||||
return model;
|
||||
});
|
||||
|
||||
return this.Json(databaseAtEOL, new JsonSerializerSettings
|
||||
{
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore,
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static class BitConverterExtensions
|
||||
{
|
||||
public static bool ToBool(this string hexString)
|
||||
{
|
||||
var bytes = hexString.ToByteArray();
|
||||
|
||||
if (bytes.Length >= 1)
|
||||
{
|
||||
return BitConverter.ToBoolean(bytes, 0);
|
||||
}
|
||||
|
||||
return default(bool);
|
||||
}
|
||||
|
||||
public static byte ToByte(this string hexString)
|
||||
{
|
||||
var bytes = hexString.ToByteArray();
|
||||
|
||||
if (bytes.Length >= 1)
|
||||
{
|
||||
return bytes[0];
|
||||
}
|
||||
|
||||
return default(byte);
|
||||
}
|
||||
|
||||
public static byte? ToNullableByte(this string hexString)
|
||||
{
|
||||
var bytes = hexString.ToByteArray();
|
||||
|
||||
if (bytes.Length >= 1)
|
||||
{
|
||||
return bytes[0];
|
||||
}
|
||||
|
||||
return default(byte?);
|
||||
}
|
||||
|
||||
public static uint ToUint(this string hexString)
|
||||
{
|
||||
var bytes = hexString.ToByteArray();
|
||||
|
||||
if (bytes.Length >= 4)
|
||||
{
|
||||
return BitConverter.ToUInt32(bytes, 0);
|
||||
}
|
||||
|
||||
return default(uint);
|
||||
}
|
||||
|
||||
public static ulong ToUlong(this string hexString)
|
||||
{
|
||||
var bytes = hexString.ToByteArray();
|
||||
|
||||
if (bytes.Length >= 8)
|
||||
{
|
||||
return BitConverter.ToUInt64(bytes, 0);
|
||||
}
|
||||
|
||||
return default(ulong);
|
||||
}
|
||||
|
||||
public static byte[] ToByteArray(this string hexString)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(hexString))
|
||||
{
|
||||
var bytes = new List<byte>();
|
||||
var hex = string.Empty;
|
||||
|
||||
foreach (var @char in hexString)
|
||||
{
|
||||
if (('0' <= @char && @char <= '9') || ('A' <= @char && @char <= 'F') || ('a' <= @char && @char <= 'f'))
|
||||
{
|
||||
hex += @char;
|
||||
}
|
||||
|
||||
if (hex.Length == 2)
|
||||
{
|
||||
bytes.Add(Convert.ToByte(hex, 16));
|
||||
|
||||
hex = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
return bytes.ToArray();
|
||||
}
|
||||
|
||||
return Array.Empty<Byte>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
{
|
||||
using LaaProductionSQL;
|
||||
using global::Common.SqlExtensions;
|
||||
|
||||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
@@ -50,9 +50,6 @@
|
||||
<LangVersion>7</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="LaaProductionSQL, Version=1.0.4.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\LaaProductionSQL.1.0.4\lib\netstandard2.0\LaaProductionSQL.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.4.1.0\lib\net472\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -434,6 +431,10 @@
|
||||
<Project>{f7e3df42-4d35-4a0c-9182-90438f9956e1}</Project>
|
||||
<Name>ServiceCore</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\OmniPlus\SqlExtensions\SqlExtensions.csproj">
|
||||
<Project>{B8523894-2C40-4FF0-A399-B7A91FAE45EA}</Project>
|
||||
<Name>SqlExtensions</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SoftwareAccessHelper\SoftwareAccessHelper.csproj">
|
||||
<Project>{A33E3C6D-EAAE-4A20-A0EE-F9E6922FD029}</Project>
|
||||
<Name>SoftwareAccessHelper</Name>
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
<package id="EntityFramework" version="6.1.3" targetFramework="net46" />
|
||||
<package id="jQuery" version="1.10.2" targetFramework="net46" />
|
||||
<package id="jQuery.Validation" version="1.11.1" targetFramework="net46" />
|
||||
<package id="LaaProductionSQL" version="1.0.4" targetFramework="net472" />
|
||||
<package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net46" />
|
||||
<package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net46" />
|
||||
<package id="Microsoft.AspNet.Identity.Owin" version="2.2.1" targetFramework="net46" />
|
||||
|
||||
Reference in New Issue
Block a user