Initial commit
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{407E05EE-F1DE-4020-83AD-8C18EDE6B32C}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>IrdaDemo</RootNamespace>
|
||||
<AssemblyName>IrdaDemo</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<LangVersion>7.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<LangVersion>7.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == '_MANUAL_CONTROL|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\_MANUAL_CONTROL\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<LangVersion>7.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NLog.4.5.6\lib\net45\NLog.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\CommonCore\CommonCore.csproj">
|
||||
<Project>{1B02C79E-0B19-43E2-8F6B-71EF0C786C97}</Project>
|
||||
<Name>CommonCore</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Hardware\Interfaces\Ports\PortCore\PortCore.csproj">
|
||||
<Project>{2E139F63-B6FE-4EA9-A098-85364FE9B26C}</Project>
|
||||
<Name>PortCore</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Hardware\Interfaces\Ports\SerialPorts\SerialPorts.csproj">
|
||||
<Project>{72037E89-4F63-4B3F-BEFF-4138E578CE99}</Project>
|
||||
<Name>SerialPorts</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Hardware\WaterMeter\Genesis\GenesisConfig\GenesisConfig.csproj">
|
||||
<Project>{F013A56B-7BE6-4852-9CD8-B971CD1ADD0C}</Project>
|
||||
<Name>GenesisConfig</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Hardware\WaterMeter\Genesis\GenesisCore\GenesisCore.csproj">
|
||||
<Project>{04201E95-90A0-4B73-A72F-379739B2A3AE}</Project>
|
||||
<Name>GenesisCore</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Hardware\WaterMeter\Genesis\Registers\Registers.csproj">
|
||||
<Project>{F4AAF7E6-7333-4284-B735-E32DEB076C64}</Project>
|
||||
<Name>Registers</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Hardware\WaterMeter\WaterMeterCore\WaterMeterCore.csproj">
|
||||
<Project>{8203ABB8-38E5-472E-A742-33F38B7A74A6}</Project>
|
||||
<Name>WaterMeterCore</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Hardware\WaterMeter\WaterMeterCore\WaterMeterRegisters\WaterMeterRegisters.csproj">
|
||||
<Project>{26afcf1e-1287-48b8-a506-32b1e8a0dd0e}</Project>
|
||||
<Name>WaterMeterRegisters</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Utils\Logging\Logging.csproj">
|
||||
<Project>{4B88B0D3-E791-4774-9521-EABEACDC420E}</Project>
|
||||
<Name>Logging</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,233 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Xylem.Common.CommonCore.Consts;
|
||||
using Xylem.Common.Hardware.Interfaces.Ports.PortCore.EventArguments;
|
||||
using Xylem.Common.Hardware.Interfaces.Ports.SerialPorts;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
|
||||
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
|
||||
|
||||
namespace IrdaDemo
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
private static readonly String CurrentConfigDir =
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
ProgramConfig.GenesisBaseFolder);
|
||||
private const String CurrentConfigFile = ProgramConfig.NlogConfig;
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
|
||||
|
||||
//MeterBatch mb = new MeterBatch();
|
||||
//var meter = new GenesisMeter();
|
||||
//meter.SetupFromConfigFile(1, false);
|
||||
|
||||
//mb.AddMeter(meter);
|
||||
|
||||
//meter.SyncStreamingBuffer(SyncMarkRecord.DecodeEveryPackage);
|
||||
|
||||
//Console.ReadLine();
|
||||
|
||||
//2018-12-12 16:13:08.5276 | Debug | Slot:0, Port:COM240, Protocol:Request, Type:IrDA - SentData(0F-01-04-03-00-42-46-45-41-43-33-43-39-44-42-32-33)
|
||||
//2018 - 12 - 12 16:13:08.5366 | Debug | Slot:0, Port: COM240, Protocol: Request, Type: IrDA - DecodeRecord(10 - 00 - 00 - 03 - 00 - 42 - 46 - 45 - 41 - 43 - 33 - 43 - 39 - 44 - 42 - 32 - 33)
|
||||
Console.WriteLine("Enter Comport Number");
|
||||
var result = $"COM{Console.ReadLine()}";
|
||||
|
||||
|
||||
Console.WriteLine("Enter Password");
|
||||
var password = Console.ReadLine();
|
||||
|
||||
|
||||
//Console.WriteLine("Press 1 for PcbID error");
|
||||
//Console.WriteLine("Press 2 for freeze meter with write/read");
|
||||
//Console.WriteLine("Press 3 for 00-00-00-1A write error");
|
||||
////var meter = new GenesisMeter(0,
|
||||
//// new PortConfig()
|
||||
//// {BaudRate = 115200, PortName = result, Type = typeof(IrdaSerialPort).ToString()}, null);
|
||||
|
||||
//switch (Console.ReadLine())
|
||||
//{
|
||||
// case "1":
|
||||
// testPcb(result);
|
||||
// break;
|
||||
// case "2":
|
||||
// testWriteRead(result, password);
|
||||
// break;
|
||||
// case "3":
|
||||
testWriteError(result, password);
|
||||
// break;
|
||||
// default:
|
||||
// Console.WriteLine("unknown test number");
|
||||
// break;
|
||||
//}
|
||||
|
||||
|
||||
var applicationDataPath = Path.Combine(CurrentConfigDir, CurrentConfigFile);
|
||||
var currentApplicationFolder =
|
||||
Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
|
||||
CurrentConfigFile);
|
||||
|
||||
|
||||
if (File.Exists(currentApplicationFolder))
|
||||
{
|
||||
Console.WriteLine(currentApplicationFolder);
|
||||
}
|
||||
|
||||
if (File.Exists(applicationDataPath))
|
||||
{
|
||||
Console.WriteLine(applicationDataPath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Console.WriteLine("done");
|
||||
Console.ReadLine();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void testWriteError(string comport, string password)
|
||||
{
|
||||
|
||||
using (var meterBatch = new MeterBatch())
|
||||
{
|
||||
var meter = new GenesisMeter(0,
|
||||
new PortConfig()
|
||||
{ PortName = comport, Type = typeof(IrdaSerialPort).ToString() }, null);
|
||||
|
||||
meterBatch.AddMeter(meter);
|
||||
if (!string.IsNullOrEmpty(password))
|
||||
{
|
||||
meter.Login(password);
|
||||
}
|
||||
else
|
||||
{
|
||||
meter.Login();
|
||||
}
|
||||
|
||||
Console.WriteLine(meter.ReadRegister(Register.Genesisflow.LedMode).Length > 0
|
||||
? "connected"
|
||||
: "not connected");
|
||||
|
||||
var input = "Y";
|
||||
meter.RequestPort.OnRawRecordReceived += delegate (Object sender, BasePortDataEventArgs args)
|
||||
{
|
||||
var data = args.GetData();
|
||||
if (data.GetType() == typeof(List<Byte>))
|
||||
{
|
||||
Console.WriteLine($"Date{args.GetReceivedTime().ToString("HH:mm:ss:ffff")}; Meter>PC OnRawRecordReceived={BitConverter.ToString(((List<Byte>)data).ToArray())}");
|
||||
}
|
||||
};
|
||||
meter.RequestPort.OnRawRecordSendOut += delegate (Object sender, BasePortDataEventArgs args)
|
||||
{
|
||||
var data = args.GetData();
|
||||
if (data.GetType() == typeof(List<Byte>))
|
||||
{
|
||||
Console.WriteLine($"Date{args.GetReceivedTime().ToString("HH:mm:ss:ffff")}; PC>Meter OnRawRecordSendOut={BitConverter.ToString(((List<Byte>)data).ToArray())}");
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
while (input.ToUpper() == "Y")
|
||||
{
|
||||
Console.Clear();
|
||||
|
||||
var value = new Byte[] { 0x03, 0x00, 0x00, 0x00 };
|
||||
WriteAndLog(meter, value);
|
||||
value = new Byte[] { 0x06, 0x00, 0x00, 0x00 };
|
||||
WriteAndLog(meter, value);
|
||||
value = new Byte[] { 0x00, 0x00, 0x00, 0x00 };
|
||||
WriteAndLog(meter, value);
|
||||
|
||||
Console.WriteLine($"retry? (Y/N)");
|
||||
input = Console.ReadLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteAndLog(GenesisMeter meter, Byte[] value)
|
||||
{
|
||||
|
||||
Console.WriteLine($"####################{BitConverter.ToString(value)}##################################");
|
||||
Console.WriteLine($"Date{DateTimeOffset.UtcNow.ToString("HH:mm:ss:ffff")}; Write={BitConverter.ToString(value)}");
|
||||
var start = DateTimeOffset.UtcNow;
|
||||
meter.WriteRegister(Register.Genesisflow.LedMode, value);
|
||||
|
||||
|
||||
var resultRead = meter.ReadRegister(Register.Genesisflow.LedMode);
|
||||
if (resultRead.Length == 0)
|
||||
{
|
||||
Console.WriteLine($"!!!!!!!!!!ReadError!!!!!!!!");
|
||||
}
|
||||
else if (resultRead[0] != value[0])
|
||||
{
|
||||
Console.WriteLine($"!!!!!!!!!!WriteError!!!!!!!!");
|
||||
}
|
||||
var end = DateTimeOffset.UtcNow;
|
||||
|
||||
Console.WriteLine($"Date{DateTimeOffset.UtcNow.ToString("HH:mm:ss:ffff")}; read ={BitConverter.ToString(resultRead)}");
|
||||
Console.WriteLine($"Date{DateTimeOffset.UtcNow.ToString("HH:mm:ss:ffff")}; duration in ms {(end - start).TotalMilliseconds}");
|
||||
Console.WriteLine($"########################################################");
|
||||
}
|
||||
|
||||
private static void testPcb(string comport)
|
||||
{
|
||||
|
||||
|
||||
using (var meterBatch = new MeterBatch())
|
||||
{
|
||||
var meter = new GenesisMeter(0,
|
||||
new PortConfig()
|
||||
{ PortName = comport, Type = typeof(IrdaSerialPort).ToString() }, null);
|
||||
|
||||
meterBatch.AddMeter(meter);
|
||||
|
||||
Console.WriteLine($"read just pcb: {meter.GetPcbId()}");
|
||||
Console.WriteLine($"read just pcb: {meter.GetPcbId()}");
|
||||
Console.WriteLine($"read just pcb: {meter.GetPcbId()}");
|
||||
Console.WriteLine($"read Register.Configexchange.Privilege");
|
||||
meter.ReadRegister(Register.Configexchange.Privilege);
|
||||
Console.WriteLine($"read just pcb: {meter.GetPcbId()}");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static void testWriteRead(string comport, string password)
|
||||
{
|
||||
|
||||
using (var meterBatch = new MeterBatch())
|
||||
{
|
||||
var meter = new GenesisMeter(0,
|
||||
new PortConfig()
|
||||
{ PortName = comport, Type = typeof(IrdaSerialPort).ToString() }, null);
|
||||
|
||||
meterBatch.AddMeter(meter);
|
||||
if (!string.IsNullOrEmpty(password))
|
||||
{
|
||||
meter.Login(password);
|
||||
}
|
||||
else
|
||||
{
|
||||
meter.Login();
|
||||
}
|
||||
|
||||
Console.WriteLine(meter.ReadRegister(Register.Genesisflow.LedMode).Length > 0
|
||||
? "connected"
|
||||
: "not connected");
|
||||
|
||||
var initValue = meter.ReadRegister(Register.Genesisflow.CalFactor1);
|
||||
for (int i = 0; i < 500; i++)
|
||||
{
|
||||
meter.ReadRegister(Register.Genesisflow.CalFactor1);
|
||||
var result = meter.WriteRegister(Register.Genesisflow.CalFactor1, initValue, checkRegister: true);
|
||||
Console.WriteLine($"try nr{i} succeed {result}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("IrdaDemo")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("IrdaDemo")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("407e05ee-f1de-4020-83ad-8c18ede6b32c")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Reference in New Issue
Block a user