MagFluxToolBox - FrmSetup adapted to MagFlux device

This commit is contained in:
Thomas Wiedebusch
2023-04-20 05:32:53 +02:00
parent 7ff63d4ec7
commit 9c328a057c
17 changed files with 1422 additions and 33 deletions
+67
View File
@@ -163,6 +163,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "modbus_master_csharp", "..\
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagFluxToolBox", "Ui\MagFluxToolBox\MagFluxToolBox.csproj", "{A5E7CE52-3101-4E9B-B896-C2C0FADE4812}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagFluxToolBox", "Ui\MagFluxToolBox\MagFluxToolBox.csproj", "{A5E7CE52-3101-4E9B-B896-C2C0FADE4812}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagFluxConfig", "Hardware\WaterMeter\MagFlux\MagFluxConfig\MagFluxConfig.csproj", "{70398B99-B134-4BBD-968B-7399B70C3CE2}"
EndProject
Global Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution GlobalSection(SharedMSBuildProjectFiles) = preSolution
Utils\DateTimeServerShared\DateTimeServerShared.projitems*{4806d89a-fbfb-41bc-aaa7-2242444bf55a}*SharedItemsImports = 4 Utils\DateTimeServerShared\DateTimeServerShared.projitems*{4806d89a-fbfb-41bc-aaa7-2242444bf55a}*SharedItemsImports = 4
@@ -3653,6 +3655,70 @@ Global
{A5E7CE52-3101-4E9B-B896-C2C0FADE4812}.XP32bit|x64.Build.0 = Release|Any CPU {A5E7CE52-3101-4E9B-B896-C2C0FADE4812}.XP32bit|x64.Build.0 = Release|Any CPU
{A5E7CE52-3101-4E9B-B896-C2C0FADE4812}.XP32bit|x86.ActiveCfg = Release|Any CPU {A5E7CE52-3101-4E9B-B896-C2C0FADE4812}.XP32bit|x86.ActiveCfg = Release|Any CPU
{A5E7CE52-3101-4E9B-B896-C2C0FADE4812}.XP32bit|x86.Build.0 = Release|Any CPU {A5E7CE52-3101-4E9B-B896-C2C0FADE4812}.XP32bit|x86.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}._MANUAL_CONTROL|Any CPU.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}._MANUAL_CONTROL|Any CPU.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}._MANUAL_CONTROL|Mixed Platforms.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}._MANUAL_CONTROL|x64.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}._MANUAL_CONTROL|x64.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}._MANUAL_CONTROL|x86.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}._MANUAL_CONTROL|x86.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.COM|Any CPU.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.COM|Any CPU.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.COM|Mixed Platforms.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.COM|Mixed Platforms.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.COM|x64.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.COM|x64.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.COM|x86.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.COM|x86.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.Debug|x64.ActiveCfg = Debug|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.Debug|x64.Build.0 = Debug|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.Debug|x86.ActiveCfg = Debug|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.Debug|x86.Build.0 = Debug|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.GenesisDisplayTool_V01|Any CPU.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.GenesisDisplayTool_V01|Any CPU.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.GenesisDisplayTool_V01|Mixed Platforms.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.GenesisDisplayTool_V01|Mixed Platforms.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.GenesisDisplayTool_V01|x64.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.GenesisDisplayTool_V01|x64.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.GenesisDisplayTool_V01|x86.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.GenesisDisplayTool_V01|x86.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.PerformTest|Any CPU.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.PerformTest|Any CPU.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.PerformTest|Mixed Platforms.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.PerformTest|Mixed Platforms.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.PerformTest|x64.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.PerformTest|x64.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.PerformTest|x86.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.PerformTest|x86.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.Release|Any CPU.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.Release|x64.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.Release|x64.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.Release|x86.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.Release|x86.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.ReleaseTest|Any CPU.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.ReleaseTest|Any CPU.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.ReleaseTest|Mixed Platforms.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.ReleaseTest|Mixed Platforms.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.ReleaseTest|x64.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.ReleaseTest|x64.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.ReleaseTest|x86.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.ReleaseTest|x86.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.XP32bit|Any CPU.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.XP32bit|Any CPU.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.XP32bit|Mixed Platforms.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.XP32bit|Mixed Platforms.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.XP32bit|x64.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.XP32bit|x64.Build.0 = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.XP32bit|x86.ActiveCfg = Release|Any CPU
{70398B99-B134-4BBD-968B-7399B70C3CE2}.XP32bit|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@@ -3726,6 +3792,7 @@ Global
{B4F8545B-F379-42A5-BDE9-763FD7B79598} = {C9393A97-C0BB-4D59-A879-B572BE04CE15} {B4F8545B-F379-42A5-BDE9-763FD7B79598} = {C9393A97-C0BB-4D59-A879-B572BE04CE15}
{F14940F8-3C86-4BB7-A915-B021E4B3052D} = {B4F8545B-F379-42A5-BDE9-763FD7B79598} {F14940F8-3C86-4BB7-A915-B021E4B3052D} = {B4F8545B-F379-42A5-BDE9-763FD7B79598}
{A5E7CE52-3101-4E9B-B896-C2C0FADE4812} = {03D4F23E-7E4A-4091-BC96-036C996D351A} {A5E7CE52-3101-4E9B-B896-C2C0FADE4812} = {03D4F23E-7E4A-4091-BC96-036C996D351A}
{70398B99-B134-4BBD-968B-7399B70C3CE2} = {C9393A97-C0BB-4D59-A879-B572BE04CE15}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4BCB7B69-696C-436A-86F7-C91EA5588164} SolutionGuid = {4BCB7B69-696C-436A-86F7-C91EA5588164}
@@ -0,0 +1,88 @@
using System;
namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxConfig
{
/// <summary>
/// Setup of communication timeouts and retries for request and streaming protocol,
/// this timeout starts the retry.
///
/// The individual timings of the hardware will be covert by the
/// <see cref="TransmitPortSettings.ResponseTimeoutMs"/>
/// injected by the different transmit protocols:
/// <see cref="IrdaTransmitProtocol"/>
/// <see cref="LedTransmitProtocol"/>
/// <see cref="RfidTransmitProtocol"/>
/// <see cref="UartTransmitProtocol"/>
/// </summary>
public static class CommunicationConfig
{
private static Int32 _requestRetries = DefaultRequestRetries;
/// <summary>
/// Maximum retries for one command at request protocol
/// at missing response.
/// </summary>
public static Int32 RequestRetries
{
get => _requestRetries;
set => _requestRetries = value > MaxRequestRetries ? MaxRequestRetries : value;
}
/// <summary>
/// Acceptable error code as valid answer to skip retries,
/// this might be 0x0004 for not installed application.
/// </summary>
public const UInt16 SkipRetryErrorCode = 0x0004;
/// <summary>
/// Default retries for one command at request protocol
/// at missing response.
/// </summary>
public const Int32 DefaultRequestRetries = 2;
/// <summary>
/// Limit retries to this value.
/// </summary>
private const Int32 MaxRequestRetries = 6;
/// <summary>
/// Send delay between records in milliseconds before
/// new record is going to be send or between retries,
/// this time is independent of the timeout, it is
/// used to delay the next send record after successful
/// response from meter.
/// </summary>
public const Int32 InterRecordSendDelayMs = 5;
//public const Int32 InterRecordSendDelayMs = 50;
/// <summary>
/// Timeout before retry will be initiated in milliseconds
/// for the response of the request protocol. This is an
/// offset value, the transmission specific timing will be
/// added from the transmit protocol timeout. This timeout
/// will be multiplied with the (retry + 1)!
/// </summary>
public const Int32 ResponseTimeoutMs = 250;
// public const Int32 ResponseTimeoutMs = 100;
/// <summary>
/// Timeout before retry will be initiated if the meter is
/// not ready indicated by a wakeup-message or decoding error.
/// </summary>
public const Int32 BusyTimeoutMs = 500;
// public const Int32 BusyTimeoutMs = 1000;
/// <summary>
/// Time to avoid automatic lock off of genesis device due to
/// missing communication with request protocol in seconds
/// </summary>
public const Int32 KeepSessionTimeS = 60 * 3;
/// <summary>
/// Time to update intermediate record for overflow detection
/// during a measurement and update of short-term measurement
/// in seconds
/// </summary>
public const Int32 MeasurementUpdateTimeS = 10;
}
}
@@ -0,0 +1,24 @@
using System;
namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxConfig.Const
{
public static class MeterConfig
{
/// <summary>
/// Calibration Factor on init from meter
/// Is also the factor to convert CalibrationFactors to readable number,
/// this is the default if the ProcessConfig.json file cannot be read.
/// </summary>
public const UInt16 CalibrationDefault = 15625;
/// <summary>
/// Channels for calibration
/// </summary>
public const Int32 CalibChannels = 3;
/// <summary>
/// Maximum calibration value in percent
/// </summary>
public const Double DefaultMaxCalibFactorTolerancePercent = 100.0;
}
}
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" 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>{70398B99-B134-4BBD-968B-7399B70C3CE2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxConfig</RootNamespace>
<AssemblyName>Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxConfig</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CommunicationConfig.cs" />
<Compile Include="Const\MeterConfig.cs" />
<Compile Include="PortConfig.cs" />
<Compile Include="ProcessConfig.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SlotConfig.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -0,0 +1,63 @@
using System;
using System.IO.Ports;
namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxConfig
{
/// <summary>
/// Collection of port settings
/// </summary>
public struct PortConfig
{
private String _portName;
/// <summary>
/// Assigns a port name and creates the serial port object
/// Port name e.g. "COM2"
/// </summary>
public String PortName
{
get =>
//if the serial port object does not exists
GetSerialPort() == null ? "NA" : _portName;
set
{
if (value == null) return;
_portName = value;
//create a serial port object
if (GetSerialPort() == null)
{
SetSerialPort(new SerialPort(value));
}
else
{
GetSerialPort().PortName = value;
}
}
}
/// <summary>
/// setup of port type from name (referenced as "Type" in config file)
/// </summary>
public String Type { get; set; }
private SerialPort _serialPort;
/// <summary>
/// using dotNets <see cref="GetSerialPort()"/> for connection
/// </summary>
public SerialPort GetSerialPort()
{
return _serialPort;
}
/// <summary>
/// using dotNets <see cref="GetSerialPort()"/> for connection
/// </summary>
private void SetSerialPort(SerialPort value)
{
_serialPort = value;
}
}
}
@@ -0,0 +1,121 @@
using System;
using System.ComponentModel;
using System.IO;
using Newtonsoft.Json;
namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxConfig
{
/// <summary>
/// Configuration of meter
/// </summary>
public class ProcessConfig
{
/// <summary>
/// ctor
/// </summary>
public ProcessConfig()
{
UseRegisterWatchService = false;
UseErrorLogger = false;
AutoUpdateFiles = false;
ProductionMode = true;
}
/// <summary>
/// Load configuration file from AppRoaming or working directory
/// </summary>
/// <param name="file"></param>
public ProcessConfig(String file)
{
// check for AppRoaming
var configFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
nameof(MagFlux), file);
if (!File.Exists(configFile))
{
// take actual working directory
configFile = Path.Combine(file);
if (!File.Exists(configFile))
{
UseRegisterWatchService = false;
UseErrorLogger = false;
return;
}
}
using (var tr = new StreamReader(configFile))
{
var meterConfig = JsonConvert.DeserializeObject<ProcessConfig>(tr.ReadToEnd());
UseRegisterWatchService = meterConfig.UseRegisterWatchService;
RegisterWatchServiceUrl = meterConfig.RegisterWatchServiceUrl;
UseMinMaxCheck = meterConfig.UseMinMaxCheck;
UseErrorLogger = meterConfig.UseErrorLogger;
ErrorLoggerServiceUrl = meterConfig.ErrorLoggerServiceUrl;
UseCalibrationLogger = meterConfig.UseCalibrationLogger;
CalibrationLoggerServiceUrl = meterConfig.CalibrationLoggerServiceUrl;
AutoUpdateFiles = meterConfig.AutoUpdateFiles;
ProductionMode = meterConfig.ProductionMode;
}
}
/// <summary>
/// Write file to AppRoaming and backup it to actual working directory
/// </summary>
/// <param name="file"></param>
public void Update(String file)
{
var configFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
nameof(MagFlux), file);
File.WriteAllText(configFile, JsonConvert.SerializeObject(this));
File.WriteAllText(file, JsonConvert.SerializeObject(this));
}
/// <summary>
///
/// </summary>
public Boolean UseRegisterWatchService { get; set; }
/// <summary>
///
/// </summary>
public String RegisterWatchServiceUrl { get; set; }
/// <summary>
///
/// </summary>
public Boolean UseMinMaxCheck { get; set; }
/// <summary>
///
/// </summary>
public Boolean UseErrorLogger { get; set; }
/// <summary>
///
/// </summary>
public String ErrorLoggerServiceUrl { get; set; }
/// <summary>
///
/// </summary>
public Boolean UseCalibrationLogger { get; set; }
/// <summary>
///
/// </summary>
public String CalibrationLoggerServiceUrl { get; set; }
/// <summary>
///
/// </summary>
public Boolean AutoUpdateFiles { get; set; }
[DefaultValue(true)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public Boolean ProductionMode { get; set; } = true;
}
}
@@ -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("Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxConfig")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Xylem")]
[assembly: AssemblyProduct("MagFluxConfig")]
[assembly: AssemblyCopyright("Copyright © Xylem 2023")]
[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("70398b99-b134-4bbd-968b-7399b70c3ce2")]
// 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")]
@@ -0,0 +1,26 @@
using System;
namespace Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxConfig
{
/// <summary>
/// Container for port configuration
/// </summary>
public class SlotConfig
{
/// <summary>
/// Slot number
/// </summary>
public Int32 Slot { get; set; }
/// <summary>
/// Request port settings
/// </summary>
public PortConfig Request { get; set; }
/// <summary>
/// Streaming port settings
/// </summary>
public PortConfig Streaming { get; set; }
}
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net48" />
</packages>
+338
View File
@@ -0,0 +1,338 @@
namespace Xylem.Common.Ui.MagFluxToolBox
{
partial class FrmSetup
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnReload = new System.Windows.Forms.Button();
this.btnStore = new System.Windows.Forms.Button();
this.tabPage4 = new System.Windows.Forms.TabPage();
this.lblGlobalCurrentPath = new System.Windows.Forms.Label();
this.btnGlobalSearch = new System.Windows.Forms.Button();
this.btnGlobalDefaultLan = new System.Windows.Forms.Button();
this.btnGlobalDefaultLocal = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.lblLocalCurrentPath = new System.Windows.Forms.Label();
this.btnLocalSearch = new System.Windows.Forms.Button();
this.btnLocalDefaultLan = new System.Windows.Forms.Button();
this.btnLocalDefaultLocal = new System.Windows.Forms.Button();
this.lblLocalPath = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.btnAddRow = new System.Windows.Forms.Button();
this.dgvConfig = new System.Windows.Forms.DataGridView();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.cbxSlot = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.cbxRequestPort = new System.Windows.Forms.DataGridViewComboBoxColumn();
this.cbxStreamingPort = new System.Windows.Forms.DataGridViewComboBoxColumn();
this.tabPage4.SuspendLayout();
this.tabPage1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgvConfig)).BeginInit();
this.tabControl1.SuspendLayout();
this.SuspendLayout();
//
// btnReload
//
this.btnReload.Location = new System.Drawing.Point(12, 12);
this.btnReload.Name = "btnReload";
this.btnReload.Size = new System.Drawing.Size(140, 43);
this.btnReload.TabIndex = 1;
this.btnReload.Text = "Reload Setup";
this.btnReload.UseVisualStyleBackColor = true;
this.btnReload.Click += new System.EventHandler(this.BtnReload_Click);
//
// btnStore
//
this.btnStore.Location = new System.Drawing.Point(158, 12);
this.btnStore.Name = "btnStore";
this.btnStore.Size = new System.Drawing.Size(140, 43);
this.btnStore.TabIndex = 2;
this.btnStore.Text = "Save Setup";
this.btnStore.UseVisualStyleBackColor = true;
this.btnStore.Click += new System.EventHandler(this.BtnStore_Click);
//
// tabPage4
//
this.tabPage4.Controls.Add(this.lblGlobalCurrentPath);
this.tabPage4.Controls.Add(this.btnGlobalSearch);
this.tabPage4.Controls.Add(this.btnGlobalDefaultLan);
this.tabPage4.Controls.Add(this.btnGlobalDefaultLocal);
this.tabPage4.Controls.Add(this.label6);
this.tabPage4.Controls.Add(this.lblLocalCurrentPath);
this.tabPage4.Controls.Add(this.btnLocalSearch);
this.tabPage4.Controls.Add(this.btnLocalDefaultLan);
this.tabPage4.Controls.Add(this.btnLocalDefaultLocal);
this.tabPage4.Controls.Add(this.lblLocalPath);
this.tabPage4.Controls.Add(this.label4);
this.tabPage4.Controls.Add(this.label3);
this.tabPage4.Controls.Add(this.label2);
this.tabPage4.Location = new System.Drawing.Point(4, 22);
this.tabPage4.Name = "tabPage4";
this.tabPage4.Size = new System.Drawing.Size(760, 361);
this.tabPage4.TabIndex = 3;
this.tabPage4.Text = "Logging";
this.tabPage4.UseVisualStyleBackColor = true;
this.tabPage4.Enter += new System.EventHandler(this.tabPage4_Click);
//
// lblGlobalCurrentPath
//
this.lblGlobalCurrentPath.AutoSize = true;
this.lblGlobalCurrentPath.Location = new System.Drawing.Point(132, 211);
this.lblGlobalCurrentPath.Name = "lblGlobalCurrentPath";
this.lblGlobalCurrentPath.Size = new System.Drawing.Size(10, 13);
this.lblGlobalCurrentPath.TabIndex = 12;
this.lblGlobalCurrentPath.Text = "-";
//
// btnGlobalSearch
//
this.btnGlobalSearch.Location = new System.Drawing.Point(52, 307);
this.btnGlobalSearch.Name = "btnGlobalSearch";
this.btnGlobalSearch.Size = new System.Drawing.Size(314, 29);
this.btnGlobalSearch.TabIndex = 11;
this.btnGlobalSearch.Text = "Search";
this.btnGlobalSearch.UseVisualStyleBackColor = true;
this.btnGlobalSearch.Click += new System.EventHandler(this.btnGlobalSearch_Click);
//
// btnGlobalDefaultLan
//
this.btnGlobalDefaultLan.Location = new System.Drawing.Point(52, 272);
this.btnGlobalDefaultLan.Name = "btnGlobalDefaultLan";
this.btnGlobalDefaultLan.Size = new System.Drawing.Size(314, 29);
this.btnGlobalDefaultLan.TabIndex = 10;
this.btnGlobalDefaultLan.Text = "\\\\sla12buma\\MagFlux$\\${machinename}";
this.btnGlobalDefaultLan.UseVisualStyleBackColor = true;
this.btnGlobalDefaultLan.Click += new System.EventHandler(this.btnGlobalDefaultLan_Click);
//
// btnGlobalDefaultLocal
//
this.btnGlobalDefaultLocal.Location = new System.Drawing.Point(52, 237);
this.btnGlobalDefaultLocal.Name = "btnGlobalDefaultLocal";
this.btnGlobalDefaultLocal.Size = new System.Drawing.Size(314, 29);
this.btnGlobalDefaultLocal.TabIndex = 9;
this.btnGlobalDefaultLocal.Text = "C:\\MagFluxLog\\";
this.btnGlobalDefaultLocal.UseVisualStyleBackColor = true;
this.btnGlobalDefaultLocal.Click += new System.EventHandler(this.btnGlobalDefaultLocal_Click);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(49, 211);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(66, 13);
this.label6.TabIndex = 8;
this.label6.Text = "CurrentPath:";
//
// lblLocalCurrentPath
//
this.lblLocalCurrentPath.AutoSize = true;
this.lblLocalCurrentPath.Location = new System.Drawing.Point(132, 57);
this.lblLocalCurrentPath.Name = "lblLocalCurrentPath";
this.lblLocalCurrentPath.Size = new System.Drawing.Size(10, 13);
this.lblLocalCurrentPath.TabIndex = 7;
this.lblLocalCurrentPath.Text = "-";
//
// btnLocalSearch
//
this.btnLocalSearch.Location = new System.Drawing.Point(52, 153);
this.btnLocalSearch.Name = "btnLocalSearch";
this.btnLocalSearch.Size = new System.Drawing.Size(314, 29);
this.btnLocalSearch.TabIndex = 6;
this.btnLocalSearch.Text = "Search";
this.btnLocalSearch.UseVisualStyleBackColor = true;
this.btnLocalSearch.Click += new System.EventHandler(this.btnLocalSearch_Click);
//
// btnLocalDefaultLan
//
this.btnLocalDefaultLan.Location = new System.Drawing.Point(52, 118);
this.btnLocalDefaultLan.Name = "btnLocalDefaultLan";
this.btnLocalDefaultLan.Size = new System.Drawing.Size(314, 29);
this.btnLocalDefaultLan.TabIndex = 5;
this.btnLocalDefaultLan.Text = "\\\\sla12buma\\MagFlux$\\${machinename}";
this.btnLocalDefaultLan.UseVisualStyleBackColor = true;
this.btnLocalDefaultLan.Click += new System.EventHandler(this.btnLocalDefaultLan_Click);
//
// btnLocalDefaultLocal
//
this.btnLocalDefaultLocal.Location = new System.Drawing.Point(52, 83);
this.btnLocalDefaultLocal.Name = "btnLocalDefaultLocal";
this.btnLocalDefaultLocal.Size = new System.Drawing.Size(314, 29);
this.btnLocalDefaultLocal.TabIndex = 4;
this.btnLocalDefaultLocal.Text = "C:\\MagFluxLog\\";
this.btnLocalDefaultLocal.UseVisualStyleBackColor = true;
this.btnLocalDefaultLocal.Click += new System.EventHandler(this.btnLocalDefaultLocal_Click);
//
// lblLocalPath
//
this.lblLocalPath.AutoSize = true;
this.lblLocalPath.Location = new System.Drawing.Point(121, 57);
this.lblLocalPath.Name = "lblLocalPath";
this.lblLocalPath.Size = new System.Drawing.Size(0, 13);
this.lblLocalPath.TabIndex = 3;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(49, 57);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(66, 13);
this.label4.TabIndex = 2;
this.label4.Text = "CurrentPath:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(13, 190);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(37, 13);
this.label3.TabIndex = 1;
this.label3.Text = "Global";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(13, 32);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(103, 13);
this.label2.TabIndex = 0;
this.label2.Text = "Local (only ToolBox)";
//
// tabPage1
//
this.tabPage1.Controls.Add(this.btnAddRow);
this.tabPage1.Controls.Add(this.dgvConfig);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(760, 361);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Slots";
this.tabPage1.UseVisualStyleBackColor = true;
//
// btnAddRow
//
this.btnAddRow.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnAddRow.Location = new System.Drawing.Point(6, 255);
this.btnAddRow.Name = "btnAddRow";
this.btnAddRow.Size = new System.Drawing.Size(199, 29);
this.btnAddRow.TabIndex = 5;
this.btnAddRow.Text = "Add Slot";
this.btnAddRow.UseVisualStyleBackColor = true;
this.btnAddRow.Click += new System.EventHandler(this.btnAddRow_Click);
//
// dgvConfig
//
this.dgvConfig.AllowUserToAddRows = false;
this.dgvConfig.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dgvConfig.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvConfig.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.cbxSlot,
this.cbxRequestPort,
this.cbxStreamingPort});
this.dgvConfig.Location = new System.Drawing.Point(6, 6);
this.dgvConfig.Name = "dgvConfig";
this.dgvConfig.Size = new System.Drawing.Size(746, 243);
this.dgvConfig.TabIndex = 4;
this.dgvConfig.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DgvConfig_CellContentClick);
this.dgvConfig.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.dgvConfig_DataError);
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage4);
this.tabControl1.Location = new System.Drawing.Point(12, 74);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(768, 387);
this.tabControl1.TabIndex = 17;
//
// cbxSlot
//
this.cbxSlot.HeaderText = "Slot";
this.cbxSlot.Name = "cbxSlot";
//
// cbxRequestPort
//
this.cbxRequestPort.HeaderText = "RequestPort";
this.cbxRequestPort.Name = "cbxRequestPort";
//
// cbxStreamingPort
//
this.cbxStreamingPort.HeaderText = "StreamingPort";
this.cbxStreamingPort.Name = "cbxStreamingPort";
//
// FrmSetup
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(780, 671);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.btnStore);
this.Controls.Add(this.btnReload);
this.MinimumSize = new System.Drawing.Size(755, 410);
this.Name = "FrmSetup";
this.Text = "Setup";
this.Load += new System.EventHandler(this.FrmSetup_Load);
this.tabPage4.ResumeLayout(false);
this.tabPage4.PerformLayout();
this.tabPage1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dgvConfig)).EndInit();
this.tabControl1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button btnReload;
private System.Windows.Forms.Button btnStore;
private System.Windows.Forms.TabPage tabPage4;
private System.Windows.Forms.Label lblGlobalCurrentPath;
private System.Windows.Forms.Button btnGlobalSearch;
private System.Windows.Forms.Button btnGlobalDefaultLan;
private System.Windows.Forms.Button btnGlobalDefaultLocal;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label lblLocalCurrentPath;
private System.Windows.Forms.Button btnLocalSearch;
private System.Windows.Forms.Button btnLocalDefaultLan;
private System.Windows.Forms.Button btnLocalDefaultLocal;
private System.Windows.Forms.Label lblLocalPath;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.Button btnAddRow;
private System.Windows.Forms.DataGridView dgvConfig;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.DataGridViewTextBoxColumn cbxSlot;
private System.Windows.Forms.DataGridViewComboBoxColumn cbxRequestPort;
private System.Windows.Forms.DataGridViewComboBoxColumn cbxStreamingPort;
}
}
+421
View File
@@ -0,0 +1,421 @@
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.IO.Ports;
using System.Linq;
using System.Windows.Forms;
using System.Xml.Linq;
using Xylem.Common.CommonCore.Consts;
using Xylem.Common.Hardware.Interfaces.Ports.SerialPorts;
using Xylem.Common.Hardware.WaterMeter.MagFlux.MagFluxConfig;
using Xylem.Common.Utils.Logging;
namespace Xylem.Common.Ui.MagFluxToolBox
{
/// <summary>
/// Setup of GTB
/// </summary>
public partial class FrmSetup : Form
{
private const String RequestPortString = "RequestPort";
private const String StreamingPortString = "StreamingPort";
private const String SlotString = "Slot";
private const String ValueString = "Value";
private const String TextString = "Text";
private String _fileString;
private readonly String _serialConfigFile;
private readonly DataTable _slotConfigDataTable = new DataTable();
/// <summary>
/// Ctor
/// </summary>
public FrmSetup()
{
_serialConfigFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"MagFlux", ProgramConfig.SerialConfigFileName);
//build header of data table for reference by name
_slotConfigDataTable.Columns.Add(SlotString, typeof(String));
_slotConfigDataTable.Columns.Add(StreamingPortString, typeof(String));
_slotConfigDataTable.Columns.Add(RequestPortString, typeof(String));
InitializeComponent();
cbxSlot.Name = SlotString;
cbxRequestPort.Name = RequestPortString;
cbxStreamingPort.Name = StreamingPortString;
cbxSlot.HeaderText = SlotString;
cbxRequestPort.HeaderText = RequestPortString;
cbxStreamingPort.HeaderText = StreamingPortString;
LoadFromFile();
}
private void BtnReload_Click(Object sender, EventArgs e)
{
LoadFromFile();
}
private void BtnStore_Click(Object sender, EventArgs e)
{
StoreToPc();
}
private void StoreToPc()
{
var newFileContent = new List<SlotConfig>();
for (var row = 0; row < dgvConfig.Rows.Count; row++)
{
var slotStr = (String)dgvConfig.Rows[row].Cells[SlotString].Value;
int.TryParse(slotStr, out var slot);
var requestPort = new PortConfig()
{
PortName = (String)dgvConfig.Rows[row].Cells[RequestPortString].Value,
Type = typeof(UartSerialPort).FullName
};
var streamingPort = new PortConfig()
{
PortName = (String)dgvConfig.Rows[row].Cells[StreamingPortString].Value,
Type = typeof(UartSerialPort).FullName
};
if (!string.IsNullOrEmpty(slotStr))
{
newFileContent.Add(new SlotConfig()
{
Slot = slot, Request = requestPort, Streaming = streamingPort
});
}
}
var text = JsonConvert.SerializeObject(newFileContent);
// Overwrite only on changed content
if (text == _fileString)
{
LoadFromFile();
return;
}
//save file only on changed content
if (File.Exists(_serialConfigFile))
{
var backupSerialConfigFile = $"{Path.GetDirectoryName(_serialConfigFile)}" +
$"\\Backup_{DateTime.Now:yyyyMMdd}_{DateTime.Now:HHmmss}" +
$"_{ProgramConfig.SerialConfigFileName}";
File.Move(_serialConfigFile, backupSerialConfigFile);
}
File.WriteAllText(_serialConfigFile, text);
LoadFromFile();
}
private void LoadFromFile()
{
_slotConfigDataTable.Clear();
dgvConfig.Rows.Clear();
if (!File.Exists(_serialConfigFile))
{
return;
}
SlotConfig[] meterConfigList;
using (var tr = new StreamReader(_serialConfigFile))
{
_fileString = tr.ReadToEnd();
meterConfigList = JsonConvert.DeserializeObject<SlotConfig[]>(_fileString);
}
foreach (var item in meterConfigList)
{
var row = _slotConfigDataTable.NewRow();
row[SlotString] = item.Slot;
row[RequestPortString] = item.Request.PortName;
row[StreamingPortString] = item.Streaming.PortName;
_slotConfigDataTable.Rows.Add(row);
}
foreach (DataRow row in _slotConfigDataTable.Rows)
{
dgvConfig.Rows.Add(AddRowToGrid(row));
}
}
private DataGridViewRow AddRowToGrid(DataRow row = null)
{
var newRow = new DataGridViewRow();
var slotCell = new DataGridViewTextBoxCell();
newRow.Cells.Add(slotCell);
var requestPortCell = new DataGridViewComboBoxCell
{
DataSource = GetPorts(),
DisplayMember = TextString,
ValueMember = ValueString
};
newRow.Cells.Add(requestPortCell);
var streamingPortCell = new DataGridViewComboBoxCell
{
DataSource = GetPorts(),
DisplayMember = TextString,
ValueMember = ValueString
};
newRow.Cells.Add(streamingPortCell);
if (row == null)
{
return newRow;
}
slotCell.Value = row[SlotString];
streamingPortCell.Value = row[StreamingPortString];
requestPortCell.Value = row[RequestPortString];
return newRow;
}
private DataTable GetPorts()
{
var ret = new DataTable();
ret.Columns.Add(ValueString);
ret.Columns.Add(TextString);
var portList = SerialPort.GetPortNames().ToList();
foreach (var item in portList)
{
ret.Rows.Add(item, item);
}
foreach (DataRow row in _slotConfigDataTable.Rows)
{
if (portList.All(pl => pl != (String)row[StreamingPortString]))
{
ret.Rows.Add(row[StreamingPortString].ToString(), BaseSerialPort.PortNotAssigned);
}
if (portList.All(pl => pl != (String)row[RequestPortString]))
{
ret.Rows.Add(row[RequestPortString].ToString(), BaseSerialPort.PortNotAssigned);
}
}
return ret;
}
private static DataTable GetTypes()
{
var ret = new DataTable();
ret.Columns.Add(ValueString);
ret.Columns.Add(TextString);
ret.Rows.Add(typeof(UartSerialPort).FullName, nameof(UartSerialPort));
//ret.Rows.Add(typeof(RfidSerialPort).FullName, nameof(RfidSerialPort));
//ret.Rows.Add(typeof(IrdaSerialPort).FullName, nameof(IrdaSerialPort));
return ret;
}
private ConcurrentBag<String> _countRawData = new ConcurrentBag<String>();
private void DgvConfig_CellContentClick(Object sender, DataGridViewCellEventArgs e)
{
//if (!dgvConfig.Columns[e.ColumnIndex].Name.Contains(StreamingDetectString) &&
// !dgvConfig.Columns[e.ColumnIndex].Name.Contains(RequestDetectString))
//{
// return;
//}
//StoreToPc();
//var slotString = (String)dgvConfig.Rows[e.RowIndex].Cells[SlotString].Value;
//int.TryParse(slotString, out var slot);
//using (var mb = new MeterBatch())
//{
// using (var meter = new GenesisMeter())
// {
// meter.SetupFromConfigFile(slot, false);
// mb.AddMeter(meter);
// const String checkMark = "\u2714";
// if (dgvConfig.Columns[e.ColumnIndex].Name.Contains(StreamingDetectString))
// {
// _countRawData = new ConcurrentBag<String>();
// meter.StreamingPort.OnRawRecordReceived += delegate (Object o, BasePortDataEventArgs rawMsg)
// {
// _countRawData.Add((String)rawMsg.GetData());
// };
// Thread.Sleep(500);
// if (_countRawData.Any())
// {
// var text = $"SUCCESS\nSlot: {slot}\nStreaming port: {meter.StreamingPort.GetPortName()}\n\n{checkMark}";
// MessageBox.Show(text, @"SUCCESS", MessageBoxButtons.OK);
// dgvConfig.Rows[e.RowIndex].Cells[StreamingDetectString].Style.BackColor = Color.Green;
// }
// else
// {
// var text = $"FAILED\nSlot: {slot}\nStreaming port: {meter.StreamingPort.GetPortName()}";
// MessageBox.Show(text, @"FAILED", MessageBoxButtons.OK, MessageBoxIcon.Error);
// dgvConfig.Rows[e.RowIndex].Cells[StreamingDetectString].Style.BackColor = Color.Red;
// }
// _countRawData = new ConcurrentBag<String>();
// }
// else
// {
// meter.Logout();
// var pcbId = meter.GetPcbId();
// if (string.IsNullOrEmpty(pcbId))
// {
// var text = $"FAILED\nSlot: {slot}\nRequest port: {meter.RequestPort.GetPortName()}";
// MessageBox.Show(text, @"FAILED", MessageBoxButtons.OK, MessageBoxIcon.Error);
// dgvConfig.Rows[e.RowIndex].Cells[RequestDetectString].Style.BackColor = Color.Red;
// }
// else
// {
// var text = $"SUCCESS\nSlot: {slot}\nRequest port: {meter.RequestPort.GetPortName()}\n\n{checkMark}";
// MessageBox.Show(text, @"SUCCESS", MessageBoxButtons.OK);
// dgvConfig.Rows[e.RowIndex].Cells[RequestDetectString].Style.BackColor = Color.Green;
// }
// }
// }
//}
}
private void dgvConfig_DataError(Object sender, DataGridViewDataErrorEventArgs e)
{
}
private void FrmSetup_Load(Object sender, EventArgs e)
{
}
private void tabPage4_Click(Object sender, EventArgs e)
{
try
{
var path = NLogHelper.GetCurrentApplicationFolder();
var a = XElement.Load(path);
lblLocalCurrentPath.Text = a.Elements().First(
s => s.Name.LocalName == "variable").Attributes().First(
s => s.Value == "BasePath").NextAttribute.Value;
}
catch (Exception ex)
{
lblLocalCurrentPath.Text = ex.Message;
}
try
{
var path = NLogHelper.GetApplicationDataPath();
var b = XElement.Load(path);
lblGlobalCurrentPath.Text = b.Elements().First(
s => s.Name.LocalName == "variable").Attributes().First(
s => s.Value == "BasePath").NextAttribute.Value;
}
catch (Exception ex)
{
lblGlobalCurrentPath.Text = ex.Message;
}
}
private void Add(String path, String newDest)
{
try
{
var a = XElement.Load(path);
var firstIsVariable = a.Elements().First();
if (firstIsVariable.Name.LocalName != "variable")
{
var newElm = new XElement("variable", null);
newElm.SetAttributeValue("name", "BasePath");
newElm.SetAttributeValue("value", newDest);
a.AddFirst(newElm);
}
else if (a.Elements().First(b => b.Name.LocalName == "variable").Attributes()
.All(s => s.Value != "BasePath"))
{
var newElm = new XElement("variable", null);
newElm.SetAttributeValue("name", "BasePath");
newElm.SetAttributeValue("value", newDest);
a.AddFirst(newElm);
}
else
{
a.Elements().First(b => b.Name.LocalName == "variable").Attributes()
.First(s => s.Value == "BasePath").NextAttribute.Value = newDest;
}
a.Save(path);
tabPage4_Click(this, null);
}
catch (Exception)
{
// ignore;
}
}
private void btnLocalDefaultLocal_Click(Object sender, EventArgs e)
{
Add(NLogHelper.GetCurrentApplicationFolder(), "C:\\MagFluxLog\\");
}
private void btnLocalDefaultLan_Click(Object sender, EventArgs e)
{
//Add(NLogHelper.GetCurrentApplicationFolder(), "\\\\sla12buma\\cordonelds$\\${machinename}");
}
private void btnGlobalDefaultLocal_Click(Object sender, EventArgs e)
{
Add(NLogHelper.GetApplicationDataPath(), "C:\\MagFluxLog\\");
}
private void btnGlobalDefaultLan_Click(Object sender, EventArgs e)
{
//Add(NLogHelper.GetApplicationDataPath(), "\\\\sla12buma\\cordonelds$\\${{machinename}}");
}
private void btnGlobalSearch_Click(Object sender, EventArgs e)
{
var dia = new FolderBrowserDialog();
dia.ShowDialog();
Add(NLogHelper.GetApplicationDataPath(), dia.SelectedPath);
}
private void btnLocalSearch_Click(Object sender, EventArgs e)
{
var dia = new FolderBrowserDialog();
dia.ShowDialog();
Add(NLogHelper.GetCurrentApplicationFolder(), dia.SelectedPath);
}
private void btnAddRow_Click(Object sender, EventArgs e)
{
dgvConfig.Rows.Add(AddRowToGrid());
}
}
}
+129
View File
@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="cbxSlot.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="cbxRequestPort.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="cbxStreamingPort.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>
@@ -33,6 +33,9 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\packages\NLog.4.6.7\lib\net45\NLog.dll</HintPath> <HintPath>..\..\packages\NLog.4.6.7\lib\net45\NLog.dll</HintPath>
</Reference> </Reference>
@@ -60,12 +63,22 @@
<Compile Include="FrmMainForm.Designer.cs"> <Compile Include="FrmMainForm.Designer.cs">
<DependentUpon>FrmMainForm.cs</DependentUpon> <DependentUpon>FrmMainForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="FrmSetup.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmSetup.Designer.cs">
<DependentUpon>FrmSetup.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FrmMainForm.resx"> <EmbeddedResource Include="FrmMainForm.resx">
<DependentUpon>FrmMainForm.cs</DependentUpon> <DependentUpon>FrmMainForm.cs</DependentUpon>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="FrmSetup.resx">
<DependentUpon>FrmSetup.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -95,6 +108,22 @@
<Project>{1B02C79E-0B19-43E2-8F6B-71EF0C786C97}</Project> <Project>{1B02C79E-0B19-43E2-8F6B-71EF0C786C97}</Project>
<Name>CommonCore</Name> <Name>CommonCore</Name>
</ProjectReference> </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\MagFlux\MagFluxConfig\MagFluxConfig.csproj">
<Project>{70398b99-b134-4bbd-968b-7399b70c3ce2}</Project>
<Name>MagFluxConfig</Name>
</ProjectReference>
<ProjectReference Include="..\..\Hardware\WaterMeter\WaterMeterCore\WaterMeterCore.csproj">
<Project>{8203abb8-38e5-472e-a742-33f38b7a74a6}</Project>
<Name>WaterMeterCore</Name>
</ProjectReference>
<ProjectReference Include="..\..\SoftwareAccessHelper\SoftwareAccessHelper.csproj"> <ProjectReference Include="..\..\SoftwareAccessHelper\SoftwareAccessHelper.csproj">
<Project>{a33e3c6d-eaae-4a20-a0ee-f9e6922fd029}</Project> <Project>{a33e3c6d-eaae-4a20-a0ee-f9e6922fd029}</Project>
<Name>SoftwareAccessHelper</Name> <Name>SoftwareAccessHelper</Name>
@@ -8,9 +8,9 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTitle("MagFluxToolBox")] [assembly: AssemblyTitle("MagFluxToolBox")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyCompany("Xylem")]
[assembly: AssemblyProduct("MagFluxToolBox")] [assembly: AssemblyProduct("MagFluxToolBox")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2023")] [assembly: AssemblyCopyright("Copyright © Xylem 2023")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
+11 -27
View File
@@ -28,32 +28,18 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.gpGerneral = new System.Windows.Forms.GroupBox();
this.btnTest = new System.Windows.Forms.Button(); this.btnTest = new System.Windows.Forms.Button();
this.btnSetup = new System.Windows.Forms.Button(); this.btnSetup = new System.Windows.Forms.Button();
this.lblVersionNumber = new System.Windows.Forms.Label(); this.lblVersionNumber = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.picLogo = new System.Windows.Forms.PictureBox(); this.picLogo = new System.Windows.Forms.PictureBox();
this.gpGerneral.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picLogo)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picLogo)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// gpGerneral
//
this.gpGerneral.Controls.Add(this.btnTest);
this.gpGerneral.Controls.Add(this.btnSetup);
this.gpGerneral.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.gpGerneral.Location = new System.Drawing.Point(12, 110);
this.gpGerneral.Name = "gpGerneral";
this.gpGerneral.Size = new System.Drawing.Size(181, 245);
this.gpGerneral.TabIndex = 19;
this.gpGerneral.TabStop = false;
this.gpGerneral.Text = "General";
//
// btnTest // btnTest
// //
this.btnTest.Location = new System.Drawing.Point(6, 61); this.btnTest.Location = new System.Drawing.Point(230, 161);
this.btnTest.Name = "btnTest"; this.btnTest.Name = "btnTest";
this.btnTest.Size = new System.Drawing.Size(152, 40); this.btnTest.Size = new System.Drawing.Size(152, 40);
this.btnTest.TabIndex = 19; this.btnTest.TabIndex = 19;
@@ -63,7 +49,7 @@
// //
// btnSetup // btnSetup
// //
this.btnSetup.Location = new System.Drawing.Point(6, 15); this.btnSetup.Location = new System.Drawing.Point(232, 115);
this.btnSetup.Name = "btnSetup"; this.btnSetup.Name = "btnSetup";
this.btnSetup.Size = new System.Drawing.Size(152, 40); this.btnSetup.Size = new System.Drawing.Size(152, 40);
this.btnSetup.TabIndex = 1; this.btnSetup.TabIndex = 1;
@@ -74,7 +60,7 @@
// lblVersionNumber // lblVersionNumber
// //
this.lblVersionNumber.AutoSize = true; this.lblVersionNumber.AutoSize = true;
this.lblVersionNumber.Location = new System.Drawing.Point(156, 5); this.lblVersionNumber.Location = new System.Drawing.Point(127, 31);
this.lblVersionNumber.Name = "lblVersionNumber"; this.lblVersionNumber.Name = "lblVersionNumber";
this.lblVersionNumber.Size = new System.Drawing.Size(37, 13); this.lblVersionNumber.Size = new System.Drawing.Size(37, 13);
this.lblVersionNumber.TabIndex = 23; this.lblVersionNumber.TabIndex = 23;
@@ -86,7 +72,7 @@
this.pictureBox1.Image = global::MagFluxToolBox.Properties.Resources.MagFluxVerySmall; this.pictureBox1.Image = global::MagFluxToolBox.Properties.Resources.MagFluxVerySmall;
this.pictureBox1.Location = new System.Drawing.Point(12, 5); this.pictureBox1.Location = new System.Drawing.Point(12, 5);
this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(84, 90); this.pictureBox1.Size = new System.Drawing.Size(85, 96);
this.pictureBox1.TabIndex = 25; this.pictureBox1.TabIndex = 25;
this.pictureBox1.TabStop = false; this.pictureBox1.TabStop = false;
// //
@@ -105,20 +91,20 @@
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(390, 367); this.ClientSize = new System.Drawing.Size(394, 211);
this.Controls.Add(this.btnTest);
this.Controls.Add(this.pictureBox1); this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.btnSetup);
this.Controls.Add(this.picLogo); this.Controls.Add(this.picLogo);
this.Controls.Add(this.lblVersionNumber); this.Controls.Add(this.lblVersionNumber);
this.Controls.Add(this.gpGerneral); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.MaximizeBox = false; this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(410, 410); this.MaximumSize = new System.Drawing.Size(410, 250);
this.MinimumSize = new System.Drawing.Size(410, 410); this.MinimumSize = new System.Drawing.Size(410, 250);
this.Name = "FrmMainForm"; this.Name = "FrmMainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "MagFlux ToolBox"; this.Text = "MagFluxToolBox";
this.Load += new System.EventHandler(this.FrmMainForm_Load); this.Load += new System.EventHandler(this.FrmMainForm_Load);
this.gpGerneral.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picLogo)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.picLogo)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
@@ -127,8 +113,6 @@
} }
#endregion #endregion
private System.Windows.Forms.GroupBox gpGerneral;
private System.Windows.Forms.Button btnSetup; private System.Windows.Forms.Button btnSetup;
private System.Windows.Forms.Label lblVersionNumber; private System.Windows.Forms.Label lblVersionNumber;
private System.Windows.Forms.Button btnTest; private System.Windows.Forms.Button btnTest;
+4 -4
View File
@@ -110,10 +110,10 @@ namespace Xylem.Common.Ui.MagFluxToolBox
private void btnSetup_Click(Object sender, EventArgs e) private void btnSetup_Click(Object sender, EventArgs e)
{ {
//var form = new FrmSetup(); var form = new FrmSetup();
//form.Show(); form.Show();
//form.Closed += Form_Closed; form.Closed += Form_Closed;
//Hide(); Hide();
} }
private void btnTest_Click(Object sender, EventArgs e) private void btnTest_Click(Object sender, EventArgs e)
+1
View File
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net48" />
<package id="NLog" version="4.6.7" targetFramework="net48" /> <package id="NLog" version="4.6.7" targetFramework="net48" />
</packages> </packages>