UniControlBoardTest project removed from the solution.

This commit is contained in:
Milan Hanajik 2021-03-19 07:50:10 +01:00
parent 6eaa9dad90
commit e1dfe758cd
16 changed files with 0 additions and 1674 deletions

2
.gitignore vendored
View File

@ -42,8 +42,6 @@ ToFirstMonitor/bin/
ToFirstMonitor/obj/
ToSecondMonitor/bin/
ToSecondMonitor/obj/
UniControlBoardTest/bin/
UniControlBoardTest/obj/
Users/bin/
Users/obj/
UserManagement/bin/

12
TBF.sln
View File

@ -74,8 +74,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchematicDrawing", "Schemat
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResetBatchNr", "ResetBatchNr\ResetBatchNr.csproj", "{D7F5A111-B2DF-4761-9574-AB730DF573A6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniControlBoardTest", "UniControlBoardTest\UniControlBoardTest.csproj", "{B9A905C2-D1D4-4FAC-8DE2-2B58EC9C8307}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -330,16 +328,6 @@ Global
{D7F5A111-B2DF-4761-9574-AB730DF573A6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{D7F5A111-B2DF-4761-9574-AB730DF573A6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{D7F5A111-B2DF-4761-9574-AB730DF573A6}.Release|x86.ActiveCfg = Release|Any CPU
{B9A905C2-D1D4-4FAC-8DE2-2B58EC9C8307}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B9A905C2-D1D4-4FAC-8DE2-2B58EC9C8307}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B9A905C2-D1D4-4FAC-8DE2-2B58EC9C8307}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{B9A905C2-D1D4-4FAC-8DE2-2B58EC9C8307}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{B9A905C2-D1D4-4FAC-8DE2-2B58EC9C8307}.Debug|x86.ActiveCfg = Debug|Any CPU
{B9A905C2-D1D4-4FAC-8DE2-2B58EC9C8307}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B9A905C2-D1D4-4FAC-8DE2-2B58EC9C8307}.Release|Any CPU.Build.0 = Release|Any CPU
{B9A905C2-D1D4-4FAC-8DE2-2B58EC9C8307}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{B9A905C2-D1D4-4FAC-8DE2-2B58EC9C8307}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{B9A905C2-D1D4-4FAC-8DE2-2B58EC9C8307}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

View File

@ -1,198 +0,0 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Xml.Serialization;
namespace UniControlBoardTest
{
/// <summary>
/// Class to be serialized to an XML file...
/// </summary>
[XmlRootAttribute("Workplace620")]
public class LocalSettings
{
static XmlSerializer serializer = XmlSerializer.FromTypes(new[] { typeof(LocalSettings) })[0];
/// Configuration file ecryption/decryption key and initialization vector
static byte[] key = new byte[] { 83, 254, 105, 64, 184, 201, 195, 127, 52, 99, 77, 45, 252, 132, 163, 156 };
static byte[] IV = new byte[] { 189, 23, 137, 56, 204, 241, 242, 118, 28, 89, 9, 198, 224, 111, 186, 125 };
public int SerialPortNr;
public LocalSettings()
{
}
public LocalSettings(bool createNew)
: this()
{
if (createNew)
{
SerialPortNr = 1;
}
}
/// <summary>
/// Load public fields of this class from the XML file.
/// </summary>
/// <returns>LocalSettings object or null when Load() fails</returns>
public static LocalSettings Load(string fileName)
{
try
{
bool isEncrypted = true;
using (StreamReader reader = new StreamReader(fileName))
{
isEncrypted = !reader.ReadLine().StartsWith("<?xml version=");
reader.Close();
}
if (isEncrypted)
{
/// Write settings to a string
StringBuilder plain = new StringBuilder();
using (RijndaelManaged aes = new RijndaelManaged { Padding = PaddingMode.Zeros })
{
using (FileStream fsCrypt = new FileStream(fileName, FileMode.Open))
{
using (ICryptoTransform decryptor = aes.CreateDecryptor(key, IV))
{
using (CryptoStream cs = new CryptoStream(fsCrypt, decryptor, CryptoStreamMode.Read))
{
using (MemoryStream mStream = new MemoryStream())
{
using (var writer = new BinaryWriter(mStream))
{
int data;
while ((data = cs.ReadByte()) != -1)
{
if (data != 0) writer.Write((byte)data);
}
writer.Flush();
mStream.Position = 0;
using (var reader = new StreamReader(mStream))
{
return serializer.Deserialize(reader) as LocalSettings;
}
}
}
}
}
}
}
}
else
{
using (StreamReader reader = new StreamReader(fileName))
{
return serializer.Deserialize(reader) as LocalSettings;
}
}
}
catch (Exception e)
{
string msg = e.Message;
return null;
}
}
/// <summary>
/// Save public fields of this class to the XML file.
/// </summary>
public void Save()
{
try
{
/// Encrypt and write to file 'Program.LocalSettingsFileName'
using (RijndaelManaged aes = new RijndaelManaged { Padding = PaddingMode.Zeros })
{
using (FileStream fsCrypt = new FileStream(Program.LocalSettingsFileName, FileMode.Create))
{
using (ICryptoTransform encryptor = aes.CreateEncryptor(key, IV))
{
using (CryptoStream cs = new CryptoStream(fsCrypt, encryptor, CryptoStreamMode.Write))
{
using (MemoryStream mStream = new MemoryStream())
{
using (var writer = new StreamWriter(mStream))
{
/// Serialize and write settings to a memory stream
serializer.Serialize(writer, this);
writer.Flush();
mStream.Position = 0;
using (var reader = new StreamReader(mStream))
{
/// Encrypt and write to file 'Program.LocalSettingsFileName'
int data;
while ((data = mStream.ReadByte()) != -1) cs.WriteByte((byte)data);
}
}
}
}
}
}
}
}
catch (Exception e)
{
string msg = e.Message;
}
}
/// <summary>
/// Updates history stored in a string array by a new latest string.
/// </summary>
/// <param name="lastStrValue">Last entered string</param>
/// <returns>true = updated and saved</returns>
public bool UpdateHistory(string lastStrValue, ref string[] history)
{
const int MaxHistoryLen = 10;
if (string.IsNullOrEmpty(lastStrValue)) return false;
int currentHistoryLength = (history != null) ? history.Length : 0;
int match = -1;
for (int i = 0; i < currentHistoryLength; i++)
{
if (history[i] == lastStrValue)
{
match = i;
break;
}
}
if (match >= 0 || currentHistoryLength >= MaxHistoryLen)
{
/// History does not have to be extended (because of a match) or should not be extended (because of the lenght)
if (match < 0) match = currentHistoryLength - 1;
for (int j = match; j > 0; j--)
{
history[j] = history[j - 1];
}
history[0] = lastStrValue;
}
else
{
/// History wiil be extended, new item inserted at the beginning
string[] newHistory = new string[currentHistoryLength + 1];
newHistory[0] = lastStrValue;
for (int j = 1; j <= currentHistoryLength; j++)
{
newHistory[j] = history[j - 1];
}
history = newHistory;
}
Save();
return true;
}
}
}

View File

@ -1,182 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Forms;
using log4net;
namespace UniControlBoardTest
{
static class Program
{
/// Constants
public const string ConfigFName = "config.xml";
public const string BackupConfigFName = "config.backup.xml";
public const string Log4NetConfigFName = "log4netConfig.xml";
/// Program information
public static readonly string ProcessName;
public static readonly string Version; /// version string
public static readonly DateTime BuildDateTime; /// date and time of program build
public static readonly string ExeDirectory;
public static readonly string ConfigDirectory;
public static readonly string LogDirectory;
public static readonly string LocalSettingsFileName;
public static readonly string LocalSettingsBackupName;
/// Local settings
public static LocalSettings LocalSettings;
/// log4net
static ILog log;
static Program()
{
/// Program version string
Assembly thisAssembly = Assembly.GetExecutingAssembly();
ProcessName = Path.GetFileNameWithoutExtension(thisAssembly.Location);
Version ver = thisAssembly.GetName().Version;
Version = string.Format("{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build);
BuildDateTime = new FileInfo(thisAssembly.Location).LastWriteTime;
/// Local program configuration directory including the trailing backslash
ExeDirectory = Path.GetDirectoryName(thisAssembly.Location);
ConfigDirectory = Path.Combine(ExeDirectory, "..", "Cfg");
LogDirectory = Path.Combine(ExeDirectory, "..", "Logs");
LocalSettingsFileName = Path.Combine(ConfigDirectory, ConfigFName);
LocalSettingsBackupName = Path.Combine(ConfigDirectory, BackupConfigFName);
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
/// Check if another instance is running
if (System.Diagnostics.Process.GetProcessesByName(ProcessName).Length > 1)
{
MessageBox.Show(string.Format("Another instance of {0} is already running", ProcessName));
return;
}
bool configDirectoryCreated = false;
if (!Directory.Exists(ConfigDirectory))
{
MessageBox.Show("Program is running for the 1st time on this PC\r\nDefault settings are used",
"Warning",
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
///
/// Create a new config subdirectory
///
configDirectoryCreated = true;
Directory.CreateDirectory(ConfigDirectory);
Program.LocalSettings = new LocalSettings(true);
Program.LocalSettings.Save();
if (File.Exists(Path.Combine(ExeDirectory, "SampleConfig", Log4NetConfigFName)))
{
File.Copy(Path.Combine(ExeDirectory, "SampleConfig", Log4NetConfigFName),
Path.Combine(ConfigDirectory, Log4NetConfigFName));
}
File.SetAttributes(Path.Combine(ConfigDirectory, Log4NetConfigFName), FileAttributes.Normal);
}
///
/// Configue and start logging
///
log4net.Config.XmlConfigurator.Configure(new FileInfo(Path.Combine(ConfigDirectory, Log4NetConfigFName)));
log = LogManager.GetLogger(typeof(Program));
log.Fatal("--------------------------------------------------------------------------------");
log.FatalFormat("{0} ver.{1}", ProcessName, Version);
log.FatalFormat("Executable directory is {0}", ExeDirectory);
if (configDirectoryCreated)
{
log.Fatal("A new config directory and configuration files created !");
}
///
/// Load the local settings (logging not available yet)
///
LocalSettings = LocalSettings.Load(Path.Combine(ConfigDirectory, ConfigFName));
if (LocalSettings == null)
{
/// Loading local seetings from regular config file failed. Use the backup
LocalSettings = LocalSettings.Load(Path.Combine(ConfigDirectory, BackupConfigFName));
if (LocalSettings == null)
{
log.FatalFormat("Local settings: Could not load file {0}, nor {1}.", ConfigFName, BackupConfigFName);
log.Fatal("Application terminated.");
MessageBox.Show(string.Format("Could not load file {0}, nor {1}.", ConfigFName, BackupConfigFName), "Fatal error");
return; /// Fatal error
}
else
{
LocalSettings.Save(); /// Save the settings to overwrite the wrong file
log.FatalFormat("Local settings: Could not load file {0}, successfully loaded {1}", ConfigFName, BackupConfigFName);
}
}
else
{
/// Loading local seetings from the regular config file was successful. Update the backup
File.Copy(Path.Combine(ConfigDirectory, ConfigFName), Path.Combine(ConfigDirectory, BackupConfigFName), true);
}
try
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new UniCBTestDlg());
}
catch (Exception e)
{
LogException(log, "Exception in Application.Run(new UniCBTestDlg())", e);
MessageBox.Show("Program crashed:" +
Environment.NewLine + Environment.NewLine + e.Message +
((e.InnerException == null) ? string.Empty : (Environment.NewLine + e.InnerException.Message)) +
Environment.NewLine + e.StackTrace,
"Fatal error",
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
}
}
static void MyHandler(object sender, UnhandledExceptionEventArgs args)
{
Exception e = args.ExceptionObject as Exception;
if (e == null) return;
LogException(log, "Unhandled exception", e);
MessageBox.Show("Program crashed:" +
Environment.NewLine + Environment.NewLine + e.Message +
((e.InnerException == null) ? string.Empty : (Environment.NewLine + e.InnerException.Message)) +
Environment.NewLine + e.StackTrace,
"Fatal error",
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
}
static void LogException(ILog log, string description, Exception e)
{
log.FatalFormat("---------------( {0} )---------------", description);
log.FatalFormat("Message : {0}", e.Message);
if (e.InnerException != null)
{
log.FatalFormat("InnerMessage : {0}", e.InnerException.Message);
}
log.FatalFormat("StackTrace : {0}{1}", Environment.NewLine, e.StackTrace);
log.Fatal("--------------------------------------");
}
}
}

View File

@ -1,36 +0,0 @@
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("UniControlBoardTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UniControlBoardTest")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[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("089442b2-9c6f-4485-a6cf-3920c4c15cfb")]
// 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")]

View File

@ -1,71 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace UniControlBoardTest.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("UniControlBoardTest.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@ -1,117 +0,0 @@
<?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.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: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" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,30 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace UniControlBoardTest.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -1,7 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -1,23 +0,0 @@
<log4net>
<!-- Program log appenders -->
<appender name="UniCBTestLog" type="log4net.Appender.RollingFileAppender">
<file value="..\Logs\WorkplaceLog.txt" />
<appendToFile value="true" />
<rollingMode value="Date" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %-5level %logger - %message%newline" />
</layout>
</appender>
<!-- Set root logger -->
<root>
<level value="WARN" />
</root>
<!-- Set program loggers -->
<logger name="UniControlBoardTest"> <appender-ref ref="UniCBTestLog" /> <level value="WARN" /> </logger>
<!-- Set program logging levels -->
<logger name="UniControlBoardTest.UniCBTestDlg"> <level value="DEBUG" /> </logger>
</log4net>

View File

@ -1,444 +0,0 @@
namespace UniControlBoardTest
{
partial class UniCBTestDlg
{
/// <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.serialPortGroupBox = new System.Windows.Forms.GroupBox();
this.comLabel = new System.Windows.Forms.Label();
this.connectButton = new System.Windows.Forms.Button();
this.serialPortTextBox = new System.Windows.Forms.TextBox();
this.commandGroupBox = new System.Windows.Forms.GroupBox();
this.valveChgFlagComboBox = new System.Windows.Forms.ComboBox();
this.regValveParamsTextBox = new System.Windows.Forms.TextBox();
this.regValveParamsLabel = new System.Windows.Forms.Label();
this.regValveModeLabel = new System.Windows.Forms.Label();
this.regvalveNrLabel = new System.Windows.Forms.Label();
this.regValveModeComboBox = new System.Windows.Forms.ComboBox();
this.regValveNrTextBox = new System.Windows.Forms.TextBox();
this.valvesTextBox = new System.Windows.Forms.TextBox();
this.valvesLabel = new System.Windows.Forms.Label();
this.checkBox10 = new System.Windows.Forms.CheckBox();
this.checkBox9 = new System.Windows.Forms.CheckBox();
this.checkBox8 = new System.Windows.Forms.CheckBox();
this.checkBox7 = new System.Windows.Forms.CheckBox();
this.checkBox6 = new System.Windows.Forms.CheckBox();
this.pulsesCountLabel = new System.Windows.Forms.Label();
this.pulsesCountTextBox = new System.Windows.Forms.TextBox();
this.etalonLabel = new System.Windows.Forms.Label();
this.etalonTextBox = new System.Windows.Forms.TextBox();
this.checkBox5 = new System.Windows.Forms.CheckBox();
this.checkBox4 = new System.Windows.Forms.CheckBox();
this.checkBox3 = new System.Windows.Forms.CheckBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.commandComboBox = new System.Windows.Forms.ComboBox();
this.sendButton = new System.Windows.Forms.Button();
this.responseGroupBox = new System.Windows.Forms.GroupBox();
this.serialPortGroupBox.SuspendLayout();
this.commandGroupBox.SuspendLayout();
this.SuspendLayout();
//
// serialPortGroupBox
//
this.serialPortGroupBox.Controls.Add(this.comLabel);
this.serialPortGroupBox.Controls.Add(this.connectButton);
this.serialPortGroupBox.Controls.Add(this.serialPortTextBox);
this.serialPortGroupBox.Location = new System.Drawing.Point(24, 13);
this.serialPortGroupBox.Name = "serialPortGroupBox";
this.serialPortGroupBox.Size = new System.Drawing.Size(888, 55);
this.serialPortGroupBox.TabIndex = 0;
this.serialPortGroupBox.TabStop = false;
this.serialPortGroupBox.Text = "Serial port";
//
// comLabel
//
this.comLabel.AutoSize = true;
this.comLabel.Location = new System.Drawing.Point(116, 25);
this.comLabel.Name = "comLabel";
this.comLabel.Size = new System.Drawing.Size(31, 13);
this.comLabel.TabIndex = 2;
this.comLabel.Text = "COM";
//
// connectButton
//
this.connectButton.Location = new System.Drawing.Point(20, 20);
this.connectButton.Name = "connectButton";
this.connectButton.Size = new System.Drawing.Size(80, 23);
this.connectButton.TabIndex = 1;
this.connectButton.Text = "Connect";
this.connectButton.UseVisualStyleBackColor = true;
this.connectButton.Click += new System.EventHandler(this.connectButton_Click);
//
// serialPortTextBox
//
this.serialPortTextBox.Location = new System.Drawing.Point(153, 22);
this.serialPortTextBox.Name = "serialPortTextBox";
this.serialPortTextBox.Size = new System.Drawing.Size(27, 20);
this.serialPortTextBox.TabIndex = 0;
this.serialPortTextBox.TextChanged += new System.EventHandler(this.serialPortTextBox_TextChanged);
//
// commandGroupBox
//
this.commandGroupBox.Controls.Add(this.valveChgFlagComboBox);
this.commandGroupBox.Controls.Add(this.regValveParamsTextBox);
this.commandGroupBox.Controls.Add(this.regValveParamsLabel);
this.commandGroupBox.Controls.Add(this.regValveModeLabel);
this.commandGroupBox.Controls.Add(this.regvalveNrLabel);
this.commandGroupBox.Controls.Add(this.regValveModeComboBox);
this.commandGroupBox.Controls.Add(this.regValveNrTextBox);
this.commandGroupBox.Controls.Add(this.valvesTextBox);
this.commandGroupBox.Controls.Add(this.valvesLabel);
this.commandGroupBox.Controls.Add(this.checkBox10);
this.commandGroupBox.Controls.Add(this.checkBox9);
this.commandGroupBox.Controls.Add(this.checkBox8);
this.commandGroupBox.Controls.Add(this.checkBox7);
this.commandGroupBox.Controls.Add(this.checkBox6);
this.commandGroupBox.Controls.Add(this.pulsesCountLabel);
this.commandGroupBox.Controls.Add(this.pulsesCountTextBox);
this.commandGroupBox.Controls.Add(this.etalonLabel);
this.commandGroupBox.Controls.Add(this.etalonTextBox);
this.commandGroupBox.Controls.Add(this.checkBox5);
this.commandGroupBox.Controls.Add(this.checkBox4);
this.commandGroupBox.Controls.Add(this.checkBox3);
this.commandGroupBox.Controls.Add(this.checkBox2);
this.commandGroupBox.Controls.Add(this.checkBox1);
this.commandGroupBox.Controls.Add(this.commandComboBox);
this.commandGroupBox.Controls.Add(this.sendButton);
this.commandGroupBox.Location = new System.Drawing.Point(24, 74);
this.commandGroupBox.Name = "commandGroupBox";
this.commandGroupBox.Size = new System.Drawing.Size(888, 125);
this.commandGroupBox.TabIndex = 1;
this.commandGroupBox.TabStop = false;
this.commandGroupBox.Text = "Command";
//
// valveChgFlagComboBox
//
this.valveChgFlagComboBox.FormattingEnabled = true;
this.valveChgFlagComboBox.Location = new System.Drawing.Point(650, 19);
this.valveChgFlagComboBox.Name = "valveChgFlagComboBox";
this.valveChgFlagComboBox.Size = new System.Drawing.Size(115, 21);
this.valveChgFlagComboBox.TabIndex = 24;
this.valveChgFlagComboBox.SelectedIndexChanged += new System.EventHandler(this.valveChgFlagComboBox_SelectedIndexChanged);
//
// regValveParamsTextBox
//
this.regValveParamsTextBox.Location = new System.Drawing.Point(506, 93);
this.regValveParamsTextBox.Name = "regValveParamsTextBox";
this.regValveParamsTextBox.Size = new System.Drawing.Size(126, 20);
this.regValveParamsTextBox.TabIndex = 23;
this.regValveParamsTextBox.TextChanged += new System.EventHandler(this.regValveParamsTextBox_TextChanged);
//
// regValveParamsLabel
//
this.regValveParamsLabel.AutoSize = true;
this.regValveParamsLabel.Location = new System.Drawing.Point(428, 96);
this.regValveParamsLabel.Name = "regValveParamsLabel";
this.regValveParamsLabel.Size = new System.Drawing.Size(79, 13);
this.regValveParamsLabel.TabIndex = 22;
this.regValveParamsLabel.Text = "Reg. v. params";
//
// regValveModeLabel
//
this.regValveModeLabel.AutoSize = true;
this.regValveModeLabel.Location = new System.Drawing.Point(428, 71);
this.regValveModeLabel.Name = "regValveModeLabel";
this.regValveModeLabel.Size = new System.Drawing.Size(71, 13);
this.regValveModeLabel.TabIndex = 21;
this.regValveModeLabel.Text = "Reg. v. mode";
//
// regvalveNrLabel
//
this.regvalveNrLabel.AutoSize = true;
this.regvalveNrLabel.Location = new System.Drawing.Point(428, 47);
this.regvalveNrLabel.Name = "regvalveNrLabel";
this.regvalveNrLabel.Size = new System.Drawing.Size(57, 13);
this.regvalveNrLabel.TabIndex = 20;
this.regvalveNrLabel.Text = "Reg, v. nr.";
//
// regValveModeComboBox
//
this.regValveModeComboBox.FormattingEnabled = true;
this.regValveModeComboBox.Location = new System.Drawing.Point(506, 68);
this.regValveModeComboBox.Name = "regValveModeComboBox";
this.regValveModeComboBox.Size = new System.Drawing.Size(126, 21);
this.regValveModeComboBox.TabIndex = 19;
this.regValveModeComboBox.SelectedIndexChanged += new System.EventHandler(this.regValveModeComboBox_SelectedIndexChanged);
//
// regValveNrTextBox
//
this.regValveNrTextBox.Location = new System.Drawing.Point(506, 44);
this.regValveNrTextBox.Name = "regValveNrTextBox";
this.regValveNrTextBox.Size = new System.Drawing.Size(126, 20);
this.regValveNrTextBox.TabIndex = 18;
this.regValveNrTextBox.TextChanged += new System.EventHandler(this.regValveNrTextBox_TextChanged);
//
// valvesTextBox
//
this.valvesTextBox.Location = new System.Drawing.Point(506, 20);
this.valvesTextBox.Name = "valvesTextBox";
this.valvesTextBox.Size = new System.Drawing.Size(126, 20);
this.valvesTextBox.TabIndex = 17;
this.valvesTextBox.TextChanged += new System.EventHandler(this.valvesTextBox_TextChanged);
//
// valvesLabel
//
this.valvesLabel.AutoSize = true;
this.valvesLabel.Location = new System.Drawing.Point(428, 23);
this.valvesLabel.Name = "valvesLabel";
this.valvesLabel.Size = new System.Drawing.Size(39, 13);
this.valvesLabel.TabIndex = 16;
this.valvesLabel.Text = "Valves";
//
// checkBox10
//
this.checkBox10.AutoSize = true;
this.checkBox10.Location = new System.Drawing.Point(284, 97);
this.checkBox10.Name = "checkBox10";
this.checkBox10.Size = new System.Drawing.Size(86, 17);
this.checkBox10.TabIndex = 15;
this.checkBox10.Text = "checkBox10";
this.checkBox10.UseVisualStyleBackColor = true;
this.checkBox10.Visible = false;
//
// checkBox9
//
this.checkBox9.AutoSize = true;
this.checkBox9.Location = new System.Drawing.Point(284, 78);
this.checkBox9.Name = "checkBox9";
this.checkBox9.Size = new System.Drawing.Size(80, 17);
this.checkBox9.TabIndex = 14;
this.checkBox9.Text = "checkBox9";
this.checkBox9.UseVisualStyleBackColor = true;
this.checkBox9.Visible = false;
//
// checkBox8
//
this.checkBox8.AutoSize = true;
this.checkBox8.Location = new System.Drawing.Point(284, 59);
this.checkBox8.Name = "checkBox8";
this.checkBox8.Size = new System.Drawing.Size(80, 17);
this.checkBox8.TabIndex = 13;
this.checkBox8.Text = "checkBox8";
this.checkBox8.UseVisualStyleBackColor = true;
this.checkBox8.Visible = false;
//
// checkBox7
//
this.checkBox7.AutoSize = true;
this.checkBox7.Location = new System.Drawing.Point(284, 40);
this.checkBox7.Name = "checkBox7";
this.checkBox7.Size = new System.Drawing.Size(80, 17);
this.checkBox7.TabIndex = 12;
this.checkBox7.Text = "checkBox7";
this.checkBox7.UseVisualStyleBackColor = true;
this.checkBox7.Visible = false;
//
// checkBox6
//
this.checkBox6.AutoSize = true;
this.checkBox6.Location = new System.Drawing.Point(284, 21);
this.checkBox6.Name = "checkBox6";
this.checkBox6.Size = new System.Drawing.Size(80, 17);
this.checkBox6.TabIndex = 11;
this.checkBox6.Text = "checkBox6";
this.checkBox6.UseVisualStyleBackColor = true;
this.checkBox6.Visible = false;
//
// pulsesCountLabel
//
this.pulsesCountLabel.AutoSize = true;
this.pulsesCountLabel.Location = new System.Drawing.Point(124, 80);
this.pulsesCountLabel.Name = "pulsesCountLabel";
this.pulsesCountLabel.Size = new System.Drawing.Size(68, 13);
this.pulsesCountLabel.TabIndex = 10;
this.pulsesCountLabel.Text = "Pulses count";
//
// pulsesCountTextBox
//
this.pulsesCountTextBox.Location = new System.Drawing.Point(203, 76);
this.pulsesCountTextBox.Name = "pulsesCountTextBox";
this.pulsesCountTextBox.Size = new System.Drawing.Size(66, 20);
this.pulsesCountTextBox.TabIndex = 9;
this.pulsesCountTextBox.TextChanged += new System.EventHandler(this.pulsesCountTextBox_TextChanged);
//
// etalonLabel
//
this.etalonLabel.AutoSize = true;
this.etalonLabel.Location = new System.Drawing.Point(124, 53);
this.etalonLabel.Name = "etalonLabel";
this.etalonLabel.Size = new System.Drawing.Size(52, 13);
this.etalonLabel.TabIndex = 8;
this.etalonLabel.Text = "Etalon nr.";
//
// etalonTextBox
//
this.etalonTextBox.Location = new System.Drawing.Point(203, 49);
this.etalonTextBox.Name = "etalonTextBox";
this.etalonTextBox.Size = new System.Drawing.Size(66, 20);
this.etalonTextBox.TabIndex = 7;
this.etalonTextBox.TextChanged += new System.EventHandler(this.etalonTextBox_TextChanged);
//
// checkBox5
//
this.checkBox5.AutoSize = true;
this.checkBox5.Location = new System.Drawing.Point(284, 97);
this.checkBox5.Name = "checkBox5";
this.checkBox5.Size = new System.Drawing.Size(80, 17);
this.checkBox5.TabIndex = 6;
this.checkBox5.Text = "checkBox5";
this.checkBox5.UseVisualStyleBackColor = true;
this.checkBox5.Visible = false;
//
// checkBox4
//
this.checkBox4.AutoSize = true;
this.checkBox4.Location = new System.Drawing.Point(284, 78);
this.checkBox4.Name = "checkBox4";
this.checkBox4.Size = new System.Drawing.Size(80, 17);
this.checkBox4.TabIndex = 5;
this.checkBox4.Text = "checkBox4";
this.checkBox4.UseVisualStyleBackColor = true;
this.checkBox4.Visible = false;
//
// checkBox3
//
this.checkBox3.AutoSize = true;
this.checkBox3.Location = new System.Drawing.Point(284, 59);
this.checkBox3.Name = "checkBox3";
this.checkBox3.Size = new System.Drawing.Size(80, 17);
this.checkBox3.TabIndex = 4;
this.checkBox3.Text = "checkBox3";
this.checkBox3.UseVisualStyleBackColor = true;
this.checkBox3.Visible = false;
//
// checkBox2
//
this.checkBox2.AutoSize = true;
this.checkBox2.Location = new System.Drawing.Point(284, 40);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(80, 17);
this.checkBox2.TabIndex = 3;
this.checkBox2.Text = "checkBox2";
this.checkBox2.UseVisualStyleBackColor = true;
this.checkBox2.Visible = false;
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(284, 21);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(80, 17);
this.checkBox1.TabIndex = 2;
this.checkBox1.Text = "checkBox1";
this.checkBox1.UseVisualStyleBackColor = true;
this.checkBox1.Visible = false;
//
// commandComboBox
//
this.commandComboBox.FormattingEnabled = true;
this.commandComboBox.Location = new System.Drawing.Point(119, 21);
this.commandComboBox.Name = "commandComboBox";
this.commandComboBox.Size = new System.Drawing.Size(150, 21);
this.commandComboBox.TabIndex = 1;
this.commandComboBox.SelectedIndexChanged += new System.EventHandler(this.commandComboBox_SelectedIndexChanged);
//
// sendButton
//
this.sendButton.Location = new System.Drawing.Point(20, 20);
this.sendButton.Name = "sendButton";
this.sendButton.Size = new System.Drawing.Size(80, 23);
this.sendButton.TabIndex = 0;
this.sendButton.Text = "Send";
this.sendButton.UseVisualStyleBackColor = true;
this.sendButton.Click += new System.EventHandler(this.sendButton_Click);
//
// responseGroupBox
//
this.responseGroupBox.Location = new System.Drawing.Point(24, 205);
this.responseGroupBox.Name = "responseGroupBox";
this.responseGroupBox.Size = new System.Drawing.Size(888, 100);
this.responseGroupBox.TabIndex = 2;
this.responseGroupBox.TabStop = false;
this.responseGroupBox.Text = "Response";
//
// UniCBTestDlg
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(936, 632);
this.Controls.Add(this.responseGroupBox);
this.Controls.Add(this.commandGroupBox);
this.Controls.Add(this.serialPortGroupBox);
this.Name = "UniCBTestDlg";
this.Text = "UNI Control Board Test";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.UniCBTestDlg_FormClosing);
this.Load += new System.EventHandler(this.UniCBTestDlg_Load);
this.serialPortGroupBox.ResumeLayout(false);
this.serialPortGroupBox.PerformLayout();
this.commandGroupBox.ResumeLayout(false);
this.commandGroupBox.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox serialPortGroupBox;
private System.Windows.Forms.Label comLabel;
private System.Windows.Forms.Button connectButton;
private System.Windows.Forms.TextBox serialPortTextBox;
private System.Windows.Forms.GroupBox commandGroupBox;
private System.Windows.Forms.Button sendButton;
private System.Windows.Forms.GroupBox responseGroupBox;
private System.Windows.Forms.ComboBox commandComboBox;
private System.Windows.Forms.CheckBox checkBox5;
private System.Windows.Forms.CheckBox checkBox4;
private System.Windows.Forms.CheckBox checkBox3;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Label etalonLabel;
private System.Windows.Forms.TextBox etalonTextBox;
private System.Windows.Forms.Label pulsesCountLabel;
private System.Windows.Forms.TextBox pulsesCountTextBox;
private System.Windows.Forms.CheckBox checkBox10;
private System.Windows.Forms.CheckBox checkBox9;
private System.Windows.Forms.CheckBox checkBox8;
private System.Windows.Forms.CheckBox checkBox7;
private System.Windows.Forms.CheckBox checkBox6;
private System.Windows.Forms.TextBox regValveParamsTextBox;
private System.Windows.Forms.Label regValveParamsLabel;
private System.Windows.Forms.Label regValveModeLabel;
private System.Windows.Forms.Label regvalveNrLabel;
private System.Windows.Forms.ComboBox regValveModeComboBox;
private System.Windows.Forms.TextBox regValveNrTextBox;
private System.Windows.Forms.TextBox valvesTextBox;
private System.Windows.Forms.Label valvesLabel;
private System.Windows.Forms.ComboBox valveChgFlagComboBox;
}
}

View File

@ -1,303 +0,0 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using log4net;
using Dirichlet.Numerics;
using TBF.Rig.ControlBoard.Uni;
namespace UniControlBoardTest
{
public partial class UniCBTestDlg : Form
{
private static readonly ILog log = LogManager.GetLogger(typeof(UniCBTestDlg));
readonly UniCBCfg cBoardCfg;
Timer timer;
UniCB cBoard;
bool connected;
public UniCBTestDlg()
{
InitializeComponent();
cBoardCfg = new UniCBCfg("CB", new Factory());
/// Display serial port nr. n UI
serialPortTextBox.Text = Program.LocalSettings.SerialPortNr.ToString();
connectButton.Enabled = false;
PortDisconnected();
timer = new Timer();
timer.Interval = 1000; // ms
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
}
private void UniCBTestDlg_Load(object sender, EventArgs e)
{
/// Command combo
commandComboBox.Items.Add(Command.None.ToString());
commandComboBox.Items.Add(Command.Start.ToString());
commandComboBox.Items.Add(Command.Stop.ToString());
commandComboBox.Items.Add(Command.GetDiverterTransitionData.ToString());
commandComboBox.Items.Add(Command.GetScopeAnalyzerData.ToString());
commandComboBox.Items.Add(Command.ResetScopeAnalyzer.ToString());
commandComboBox.Items.Add(Command.GetSwitchCounterData.ToString());
/// Start command check boxes
checkBox1.Text = StartParam.DiverterStart.ToString();
checkBox2.Text = StartParam.SynchroMethod.ToString();
checkBox3.Text = StartParam.DirectGateStart.ToString();
checkBox4.Text = StartParam.StartStopMethod.ToString();
checkBox5.Text = StartParam.CalibrationMode.ToString();
/// Stop command check boxes
checkBox6.Text = StopDevs.Reference.ToString();
checkBox7.Text = StopDevs.Diverter.ToString();
checkBox8.Text = StopDevs.GatePulse.ToString();
checkBox9.Text = StopDevs.TimeMeasurement.ToString();
checkBox10.Text = StopDevs.BypassDevCoupled2Div.ToString();
/// Valve change flags combo
valveChgFlagComboBox.Items.Add(ValveChgFlag.DoNotChange.ToString());
valveChgFlagComboBox.Items.Add(ValveChgFlag.Change.ToString());
valveChgFlagComboBox.Items.Add(ValveChgFlag.SendPressureMeterAddresses.ToString());
/// Reg. valve mode combo
regValveModeComboBox.Items.Add(RegValveMode.None.ToString());
regValveModeComboBox.Items.Add(RegValveMode.PulseWidth.ToString());
regValveModeComboBox.Items.Add(RegValveMode.TargetPosition.ToString());
regValveModeComboBox.Items.Add(RegValveMode.TargetFrequency.ToString());
regValveModeComboBox.Items.Add(RegValveMode.Stop.ToString());
int portNr;
connectButton.Enabled = int.TryParse(serialPortTextBox.Text, out portNr) && (portNr > 0);
if (connectButton.Enabled) connectButton.Focus();
}
private void UniCBTestDlg_FormClosing(object sender, FormClosingEventArgs e)
{
int portNr;
if (int.TryParse(serialPortTextBox.Text, out portNr))
{
Program.LocalSettings.SerialPortNr = portNr;
Program.LocalSettings.Save();
}
}
private void serialPortTextBox_TextChanged(object sender, EventArgs e)
{
int comPortNr;
connectButton.Enabled = int.TryParse(serialPortTextBox.Text, out comPortNr) && (comPortNr > 0);
}
private void connectButton_Click(object sender, EventArgs e)
{
int comPortNr;
if (!connected && int.TryParse(serialPortTextBox.Text, out comPortNr) && comPortNr > 0)
{
try
{
cBoardCfg.ComPortNr = comPortNr;
cBoard = new UniCB(cBoardCfg as TBF.Rig.Generic.IComponentCfg);
cBoard.Initialize();
PortConnected();
}
catch (Exception)
{
MessageBox.Show(string.Format("Cannot open serial port COM{0}", comPortNr), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
else if (connected && cBoard != null)
{
cBoard.StopDevice();
cBoard.StopDevice2();
PortDisconnected();
}
}
void PortConnected()
{
connected = true;
connectButton.Text = "Disconnect";
serialPortTextBox.Enabled = false;
commandGroupBox.Enabled = true;
sendButton.Enabled = IsCommandParamsValid();
responseGroupBox.Enabled = true;
}
void PortDisconnected()
{
connected = false;
connectButton.Text = "Connect";
serialPortTextBox.Enabled = true;
commandGroupBox.Enabled = false;
responseGroupBox.Enabled = false;
}
private void commandComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if ((string)commandComboBox.SelectedItem == Command.Start.ToString())
{
etalonLabel.Visible = etalonTextBox.Visible = true;
pulsesCountLabel.Visible = pulsesCountTextBox.Visible = true;
checkBox1.Visible = checkBox2.Visible = checkBox3.Visible = checkBox4.Visible = checkBox5.Visible = true;
checkBox6.Visible = checkBox7.Visible = checkBox8.Visible = checkBox9.Visible = checkBox10.Visible = false;
}
else if ((string)commandComboBox.SelectedItem == Command.Stop.ToString())
{
etalonLabel.Visible = etalonTextBox.Visible = false;
pulsesCountLabel.Visible = pulsesCountTextBox.Visible = false;
checkBox1.Visible = checkBox2.Visible = checkBox3.Visible = checkBox4.Visible = checkBox5.Visible = false;
checkBox6.Visible = checkBox7.Visible = checkBox8.Visible = checkBox9.Visible = checkBox10.Visible = true;
}
else
{
etalonLabel.Visible = etalonTextBox.Visible = false;
pulsesCountLabel.Visible = pulsesCountTextBox.Visible = false;
checkBox1.Visible = checkBox2.Visible = checkBox3.Visible = checkBox4.Visible = checkBox5.Visible = false;
checkBox6.Visible = checkBox7.Visible = checkBox8.Visible = checkBox9.Visible = checkBox10.Visible = false;
}
sendButton.Enabled = IsCommandParamsValid();
}
private void etalonTextBox_TextChanged(object sender, EventArgs e)
{
sendButton.Enabled = IsCommandParamsValid();
}
private void pulsesCountTextBox_TextChanged(object sender, EventArgs e)
{
sendButton.Enabled = IsCommandParamsValid();
}
private void regValveModeComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
sendButton.Enabled = IsCommandParamsValid();
}
private void valveChgFlagComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
sendButton.Enabled = IsCommandParamsValid();
}
private void regValveNrTextBox_TextChanged(object sender, EventArgs e)
{
sendButton.Enabled = IsCommandParamsValid();
}
private void valvesTextBox_TextChanged(object sender, EventArgs e)
{
sendButton.Enabled = IsCommandParamsValid();
}
private void regValveParamsTextBox_TextChanged(object sender, EventArgs e)
{
sendButton.Enabled = IsCommandParamsValid();
}
bool IsCommandParamsValid()
{
int tmp;
UInt128 route;
if (commandComboBox.Visible && !commandComboBox.Items.Contains(commandComboBox.Text)) return false;
if (etalonTextBox.Visible && !(int.TryParse(etalonTextBox.Text, out tmp) && (tmp >= 0) && (tmp <= 7))) return false;
if (pulsesCountTextBox.Visible && !(int.TryParse(pulsesCountTextBox.Text, out tmp) && (tmp >= 0) && (tmp <= 0xFFFFFF))) return false;
if (valvesTextBox.Visible && !UInt128.TryParse(valvesTextBox.Text, out route)) return false;
if (valveChgFlagComboBox.Visible && !valveChgFlagComboBox.Items.Contains(valveChgFlagComboBox.Text)) return false;
if (regValveNrTextBox.Visible && !(int.TryParse(regValveNrTextBox.Text, out tmp) && (tmp >= 0) && (tmp <= 255))) return false;
if (valveChgFlagComboBox.Visible && !valveChgFlagComboBox.Items.Contains(valveChgFlagComboBox.Text)) return false;
if (regValveModeComboBox.Visible && !regValveModeComboBox.Items.Contains(regValveModeComboBox.Text)) return false;
return true;
}
Command GetCommand()
{
Command[] values = (Command[])Enum.GetValues(typeof(Command));
foreach (var val in values)
if (val.ToString() == commandComboBox.Text)
return val;
return 0;
}
byte GetCmdParameter(byte cmd)
{
if ((cmd & 0x07) == (byte)Command.Start)
{
byte cmdParam = (byte)int.Parse(etalonTextBox.Text);
if (checkBox1.Checked) cmdParam |= 8;
if (checkBox2.Checked) cmdParam |= 0x10;
if (checkBox3.Checked) cmdParam |= 0x20;
if (checkBox4.Checked) cmdParam |= 0x40;
if (checkBox5.Checked) cmdParam |= 0x80;
return cmdParam;
}
if ((cmd & 0x07) == (byte)Command.Stop)
{
byte cmdParam = 0;
if (checkBox6.Checked) cmdParam |= 1;
if (checkBox7.Checked) cmdParam |= 2;
if (checkBox8.Checked) cmdParam |= 8;
if (checkBox9.Checked) cmdParam |= 0x10;
if (checkBox10.Checked) cmdParam |= 0x20;
return cmdParam;
}
return 0;
}
UInt128 GetRoute()
{
return UInt128.Parse(valvesTextBox.Text);
}
ValveChgFlag GetValveChgFlag()
{
ValveChgFlag[] values = (ValveChgFlag[])Enum.GetValues(typeof(ValveChgFlag));
foreach (var val in values)
if (val.ToString() == valveChgFlagComboBox.Text)
return val;
return 0;
}
RegValveMode GetRegValveMode()
{
RegValveMode[] values = (RegValveMode[])Enum.GetValues(typeof(RegValveMode));
foreach (var val in values)
if (val.ToString() == regValveModeComboBox.Text)
return val;
return 0;
}
private void sendButton_Click(object sender, EventArgs e)
{
if (connected && cBoard != null && IsCommandParamsValid())
{
//cBoard.SendCommand(GetCommand(),
// etalonTextBox.Visible ? int.Parse(etalonTextBox.Text) : 0,
// regValveNrTextBox.Visible ? int.Parse(regValveNrTextBox.Text) : 0,
// 1,
// pulsesCountTextBox.Visible ? ulong.Parse(pulsesCountTextBox.Text) : 0,
// pulsesCountTextBox.Visible ? ulong.Parse(pulsesCountTextBox.Text) : 0,
// valvesTextBox.Visible ? UInt128.Parse(valvesTextBox.Text) : 0);
}
}
void timer_Tick(object sender, EventArgs e)
{
if (!connected || cBoard == null) return;
cBoard.RunDeviceBefore();
/// Do something
cBoard.RunDeviceAfter();
}
}
}

View File

@ -1,120 +0,0 @@
<?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>
</root>

View File

@ -1,121 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.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>{B9A905C2-D1D4-4FAC-8DE2-2B58EC9C8307}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UniControlBoardTest</RootNamespace>
<AssemblyName>UniControlBoardTest</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</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>
</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>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.2\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="LocalSettings.cs" />
<Compile Include="UniCBTestDlg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UniCBTestDlg.Designer.cs">
<DependentUpon>UniCBTestDlg.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="UniCBTestDlg.resx">
<DependentUpon>UniCBTestDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj">
<Project>{c8939821-ba5c-4988-a3d0-bf53b74865c7}</Project>
<Name>Common</Name>
</ProjectReference>
<ProjectReference Include="..\Config\Config.csproj">
<Project>{743df7db-c7b6-42eb-986d-0f485e5588e4}</Project>
<Name>Config</Name>
</ProjectReference>
<ProjectReference Include="..\Dirichlet.Numerics\Dirichlet.Numerics.csproj">
<Project>{439d0878-c76e-452b-b17d-209a89e91d36}</Project>
<Name>Dirichlet.Numerics</Name>
</ProjectReference>
<ProjectReference Include="..\SchematicDrawing\SchematicDrawing.csproj">
<Project>{0f79ca69-9dbc-41f3-a6fc-5a2937365343}</Project>
<Name>SchematicDrawing</Name>
</ProjectReference>
<ProjectReference Include="..\TBF\TBF.csproj">
<Project>{8648fd92-cda1-4c3a-b5f9-fe547ce1fa48}</Project>
<Name>TBF</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="SampleConfig\log4netConfig.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</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>

View File

@ -42,8 +42,6 @@ rmdir /s /q ToFirstMonitor\bin
rmdir /s /q ToFirstMonitor\obj
rmdir /s /q ToSecondMonitor\bin
rmdir /s /q ToSecondMonitor\obj
rmdir /s /q UniControlBoardTest\bin
rmdir /s /q UniControlBoardTest\obj
rmdir /s /q Users\bin
rmdir /s /q Users\obj
rmdir /s /q UserManagement\bin