diff --git a/.gitignore b/.gitignore index 54d078242..c781b2d06 100644 --- a/.gitignore +++ b/.gitignore @@ -42,8 +42,6 @@ ToFirstMonitor/bin/ ToFirstMonitor/obj/ ToSecondMonitor/bin/ ToSecondMonitor/obj/ -UniControlBoardTest/bin/ -UniControlBoardTest/obj/ Users/bin/ Users/obj/ UserManagement/bin/ diff --git a/TBF.sln b/TBF.sln index f5c53c79f..71aa58194 100644 --- a/TBF.sln +++ b/TBF.sln @@ -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 diff --git a/UniControlBoardTest/App.config b/UniControlBoardTest/App.config deleted file mode 100644 index 56efbc7b5..000000000 --- a/UniControlBoardTest/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/UniControlBoardTest/LocalSettings.cs b/UniControlBoardTest/LocalSettings.cs deleted file mode 100644 index b4a3b0ef8..000000000 --- a/UniControlBoardTest/LocalSettings.cs +++ /dev/null @@ -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 -{ - /// - /// Class to be serialized to an XML file... - /// - [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; - } - } - - /// - /// Load public fields of this class from the XML file. - /// - /// LocalSettings object or null when Load() fails - public static LocalSettings Load(string fileName) - { - try - { - bool isEncrypted = true; - using (StreamReader reader = new StreamReader(fileName)) - { - isEncrypted = !reader.ReadLine().StartsWith(" - /// Save public fields of this class to the XML file. - /// - 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; - } - } - - /// - /// Updates history stored in a string array by a new latest string. - /// - /// Last entered string - /// true = updated and saved - 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; - } - } -} diff --git a/UniControlBoardTest/Program.cs b/UniControlBoardTest/Program.cs deleted file mode 100644 index b4255bc51..000000000 --- a/UniControlBoardTest/Program.cs +++ /dev/null @@ -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); - } - - - /// - /// The main entry point for the application. - /// - [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("--------------------------------------"); - } - } -} diff --git a/UniControlBoardTest/Properties/AssemblyInfo.cs b/UniControlBoardTest/Properties/AssemblyInfo.cs deleted file mode 100644 index 846b19847..000000000 --- a/UniControlBoardTest/Properties/AssemblyInfo.cs +++ /dev/null @@ -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")] diff --git a/UniControlBoardTest/Properties/Resources.Designer.cs b/UniControlBoardTest/Properties/Resources.Designer.cs deleted file mode 100644 index 803570ac8..000000000 --- a/UniControlBoardTest/Properties/Resources.Designer.cs +++ /dev/null @@ -1,71 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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. -// -//------------------------------------------------------------------------------ - -namespace UniControlBoardTest.Properties -{ - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // 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() - { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [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; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} diff --git a/UniControlBoardTest/Properties/Resources.resx b/UniControlBoardTest/Properties/Resources.resx deleted file mode 100644 index af7dbebba..000000000 --- a/UniControlBoardTest/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/UniControlBoardTest/Properties/Settings.Designer.cs b/UniControlBoardTest/Properties/Settings.Designer.cs deleted file mode 100644 index a0ec48802..000000000 --- a/UniControlBoardTest/Properties/Settings.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 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. -// -//------------------------------------------------------------------------------ - -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; - } - } - } -} diff --git a/UniControlBoardTest/Properties/Settings.settings b/UniControlBoardTest/Properties/Settings.settings deleted file mode 100644 index 39645652a..000000000 --- a/UniControlBoardTest/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/UniControlBoardTest/SampleConfig/log4netConfig.xml b/UniControlBoardTest/SampleConfig/log4netConfig.xml deleted file mode 100644 index fc3cd70f1..000000000 --- a/UniControlBoardTest/SampleConfig/log4netConfig.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/UniControlBoardTest/UniCBTestDlg.Designer.cs b/UniControlBoardTest/UniCBTestDlg.Designer.cs deleted file mode 100644 index 10b4440f4..000000000 --- a/UniControlBoardTest/UniCBTestDlg.Designer.cs +++ /dev/null @@ -1,444 +0,0 @@ -namespace UniControlBoardTest -{ - partial class UniCBTestDlg - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - 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; - } -} - diff --git a/UniControlBoardTest/UniCBTestDlg.cs b/UniControlBoardTest/UniCBTestDlg.cs deleted file mode 100644 index 8567f6285..000000000 --- a/UniControlBoardTest/UniCBTestDlg.cs +++ /dev/null @@ -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(); - } - } -} diff --git a/UniControlBoardTest/UniCBTestDlg.resx b/UniControlBoardTest/UniCBTestDlg.resx deleted file mode 100644 index 1af7de150..000000000 --- a/UniControlBoardTest/UniCBTestDlg.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/UniControlBoardTest/UniControlBoardTest.csproj b/UniControlBoardTest/UniControlBoardTest.csproj deleted file mode 100644 index 8dc06eba2..000000000 --- a/UniControlBoardTest/UniControlBoardTest.csproj +++ /dev/null @@ -1,121 +0,0 @@ - - - - - Debug - AnyCPU - {B9A905C2-D1D4-4FAC-8DE2-2B58EC9C8307} - WinExe - Properties - UniControlBoardTest - UniControlBoardTest - v4.7.2 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\log4net.2.0.2\lib\net40-full\log4net.dll - - - - - - - - - - - - - - - - - Form - - - UniCBTestDlg.cs - - - - - UniCBTestDlg.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - - - - {c8939821-ba5c-4988-a3d0-bf53b74865c7} - Common - - - {743df7db-c7b6-42eb-986d-0f485e5588e4} - Config - - - {439d0878-c76e-452b-b17d-209a89e91d36} - Dirichlet.Numerics - - - {0f79ca69-9dbc-41f3-a6fc-5a2937365343} - SchematicDrawing - - - {8648fd92-cda1-4c3a-b5f9-fe547ce1fa48} - TBF - - - - - - Always - - - - - \ No newline at end of file diff --git a/clean.bat b/clean.bat index f4663e817..e9d8e567c 100644 --- a/clean.bat +++ b/clean.bat @@ -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