diff --git a/TestBenchFramework/BenchControl/Keithley/RS232/Factory.cs b/TestBenchFramework/BenchControl/Keithley/Multimeter_2010_RS232/Factory.cs similarity index 71% rename from TestBenchFramework/BenchControl/Keithley/RS232/Factory.cs rename to TestBenchFramework/BenchControl/Keithley/Multimeter_2010_RS232/Factory.cs index b6d173ef5..8d0954da8 100644 --- a/TestBenchFramework/BenchControl/Keithley/RS232/Factory.cs +++ b/TestBenchFramework/BenchControl/Keithley/Multimeter_2010_RS232/Factory.cs @@ -4,11 +4,11 @@ using System.Collections.Generic; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Keithley.RS232 +namespace TBF.BenchControl.Keithley.Multimeter_2010_RS232 { public class Factory : IComponentFactory { - public string ClassName { get { return this.GetType().Namespace.Substring(17) + ".Multimeter"; } } + public string ClassName { get { return GetType().Namespace.Substring(17); } } public void ResetStaticProperties() { Multimeter.ResetStaticProperties(); } @@ -16,7 +16,7 @@ namespace TBF.BenchControl.Keithley.RS232 public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Multimeter(cfg); } - public IComponentCfg DefaultConfig() { return new MultimeterCfg(this); } + public IComponentCfg DefaultConfig() { return new MultimeterCfg(GetType().Namespace.Substring(17), this); } public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { diff --git a/TestBenchFramework/BenchControl/Keithley/Multimeter_2010_RS232/Multimeter.cs b/TestBenchFramework/BenchControl/Keithley/Multimeter_2010_RS232/Multimeter.cs new file mode 100644 index 000000000..a598a0241 --- /dev/null +++ b/TestBenchFramework/BenchControl/Keithley/Multimeter_2010_RS232/Multimeter.cs @@ -0,0 +1,259 @@ +/// +/// Copyright (c) 2016 Sensus Metering Systems +/// +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO.Ports; +using System.Text; +using System.Threading; +using log4net; +using Config.Entities; +using TBF.BenchControl.Generic; +using TBF.Boxes; + +namespace TBF.BenchControl.Keithley.Multimeter_2010_RS232 +{ + /// + /// Root component for Modbus communication via serial port (RS485) + /// + public class Multimeter : ComponentBase, IDevice + { + private static readonly ILog log = LogManager.GetLogger(typeof(Multimeter)); + public override string ToString() { return string.Format("{0}({1})", GetType().Namespace.Substring(17), Cfg.ToString(1)); } + + private readonly MultimeterCfg multimeterCfg; + + + /// + /// Main result + /// + public const int ChannelFrom = 1; + public const int ChannelTo = 5; + /// + public double[] Resistance; /// ChannelNr in range is used as an index to this array + + + /// Private fields + SerialPort serialPort; + + IList listOfReadOperations; + IList listOfChannels; + int nextChannelIx; /// index to listOfChannels + int currentChannel; /// current channel (ChannelFrom .. ChannelTo), 0 = invalid, updated when sending :rout:clos command + enum ScanState + { + Off, + Start_Reset, + Reset_SwitchCh, + SwitchCh_Read, + Read_SwitchCh, + } + ScanState scanState; + + + public Multimeter() + { + Resistance = new double[ChannelTo + 1]; + } + + /// + /// Ambient temperature / humidity / pressure meter 'Greco' connected via serial interface (RS232) + /// Connection settings: 19200 Bd 8-bits No-parity 1-stop-bit Flow control: none or hardware. + /// + public Multimeter(Generic.IComponentCfg cfg) + : base(cfg) + { + multimeterCfg = cfg as MultimeterCfg; + serialPort = null; + + Resistance = new double[ChannelTo + 1]; + for (int i = 0; i < Resistance.Length; i++) Resistance[i] = 0; + + listOfReadOperations = new List(); + listOfChannels = new List(); + nextChannelIx = 0; + currentChannel = 0; /// invalid, no :rout:clos command yet + scanState = ScanState.Off; + + log.Debug(this.ToString()); + } + + ~Multimeter() + { + } + + /// + /// Start reading temperature from specified channel + /// + /// channel in range ChannelFrom .. ChannelTo + /// true when successful + public bool StartReadingMultimeter(int channel) + { + log.DebugFormat("StartReadingMultimeter({0})", channel); + + if (channel < ChannelFrom || channel > ChannelTo) return false; /// Invalid channel + + listOfReadOperations.Add(channel); + + if (!listOfChannels.Contains(channel)) + { + listOfChannels.Add(channel); + if (listOfChannels.Count == 1) StartScanning(); /// Count changed from 0 to 1 + } + + return true; + } + + /// + /// Stop reading temperature from specified channel + /// + /// channel in range ChannelFrom .. ChannelTo + /// true when successful + public bool StopReadingMultimeter(int channel) + { + log.DebugFormat("StopReadingMultimeter({0})", channel); + + if (channel < ChannelFrom || channel > ChannelTo) return false; /// Invalid channel + + if (!listOfReadOperations.Remove(channel)) return false; /// Channel not found on the list (no matching StartReading...) + + for (int i = 0; i < listOfChannels.Count; i++) + { + if (listOfChannels[i] == channel) + { + listOfChannels.RemoveAt(i); + if (listOfChannels.Count == 0) + { + StopScanning(); + } + else if (nextChannelIx > i) + { + nextChannelIx--; + } + } + } + + return true; + } + + + public double ReadResistance(int channelNr) + { + if (channelNr < ChannelFrom || channelNr > ChannelTo) return 0; + return Resistance[channelNr]; + } + + + private void StartScanning() + { + for (int i = 0; i < Resistance.Length; i++) Resistance[i] = 0; /// Reset resistances (0 == invalid) + /// + nextChannelIx = 0; + currentChannel = 0; /// invalid, no :rout:clos command yet + scanState = ScanState.Start_Reset; + } + + private void StopScanning() + { + scanState = ScanState.Off; + } + + + public void Initialize() + { + if (multimeterCfg.DebugLevel == DebugMode.Simulate) + { + log.FatalFormat("Simulated device {0}", ToString()); + return; + } + + string comPortName = "COM" + multimeterCfg.ComPortNr.ToString(); + serialPort = new SerialPort(comPortName, multimeterCfg.BaudRate, multimeterCfg.Parity, multimeterCfg.DataBits, multimeterCfg.StopBits); + serialPort.Handshake = multimeterCfg.Handshake; + serialPort.Open(); + + log.FatalFormat("Successfully initialized device {0}", ToString()); + } + + + public void SendMessage(string message) + { + if (multimeterCfg.DebugLevel == DebugMode.Simulate) return; + serialPort.Write(message + "\r\n"); + log.DebugFormat("Sending message {0}", message); + } + + + /// Run this device + public void RunDeviceBefore() + { + if ((scanState == ScanState.Read_SwitchCh) && (currentChannel >= ChannelFrom) && (currentChannel <= ChannelTo)) + { + string completeStr = serialPort.ReadExisting(); + int len = completeStr.Length - 2; + if (len > 0) + { + string resStr = completeStr.Substring(0, len); + log.DebugFormat("Received message {0}", resStr); + double res; + if (completeStr.IndexOf("\r\n") == len && + double.TryParse(resStr, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out res)) + { + Resistance[currentChannel] = res; + } + } + } + } + + + /// Run this device + public void RunDeviceAfter() + { + switch (scanState) + { + case ScanState.Start_Reset: + + SendMessage("*RST"); + SendMessage("*CLS"); + SendMessage(":conf:fres"); + scanState = ScanState.Reset_SwitchCh; + return; + + case ScanState.Reset_SwitchCh: + case ScanState.Read_SwitchCh: + + if (nextChannelIx >= 0 && nextChannelIx < listOfChannels.Count) + { + /// Update 'curentChannel' + currentChannel = listOfChannels[nextChannelIx]; + + /// Switch to the 'curentChannel' + SendMessage(string.Format(":rout:clos (@{0})", currentChannel)); + + /// Increase 'nextChannelIx' + nextChannelIx++; + if (nextChannelIx >= listOfChannels.Count) nextChannelIx = 0; + } + scanState = ScanState.SwitchCh_Read; + return; + + case ScanState.SwitchCh_Read: + + SendMessage(":read?"); + scanState = ScanState.Read_SwitchCh; + return; + + default: /// Scanning is off + return; + } + } + + + /// Stop this device + public void StopDevice() + { + serialPort.Close(); + } + } +} diff --git a/TestBenchFramework/BenchControl/Keithley/RS232/MultimeterCfg.cs b/TestBenchFramework/BenchControl/Keithley/Multimeter_2010_RS232/MultimeterCfg.cs similarity index 89% rename from TestBenchFramework/BenchControl/Keithley/RS232/MultimeterCfg.cs rename to TestBenchFramework/BenchControl/Keithley/Multimeter_2010_RS232/MultimeterCfg.cs index 6a2fd6288..3a5307cec 100644 --- a/TestBenchFramework/BenchControl/Keithley/RS232/MultimeterCfg.cs +++ b/TestBenchFramework/BenchControl/Keithley/Multimeter_2010_RS232/MultimeterCfg.cs @@ -7,7 +7,7 @@ using System.IO.Ports; using System.Xml.Serialization; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Keithley.RS232 +namespace TBF.BenchControl.Keithley.Multimeter_2010_RS232 { public class MultimeterCfg : ComponentCfgBase, Generic.IComponentCfg { @@ -26,7 +26,13 @@ namespace TBF.BenchControl.Keithley.RS232 /// Private parameterless constructor invoked by all other (public) constructors MultimeterCfg() { - Name = "Keithley"; + } + + public MultimeterCfg(string name, IComponentFactory factory) + : this() + { + this.Name = name; + this.Factory = factory; ParentName = string.Empty; ComPortNr = 5; BaudRate = 9600; @@ -36,12 +42,6 @@ namespace TBF.BenchControl.Keithley.RS232 Handshake = System.IO.Ports.Handshake.None; } - public MultimeterCfg(IComponentFactory factory) - : this() - { - this.Factory = factory; - } - public string ToString(int i) { return string.Format("Name={0}, Com{1}, {2}Bd, {3}-bits, parity={4}, stopBits={5}, {6}", diff --git a/TestBenchFramework/BenchControl/Keithley/RS232/MultimeterCfgCtrl.cs b/TestBenchFramework/BenchControl/Keithley/Multimeter_2010_RS232/MultimeterCfgCtrl.cs similarity index 98% rename from TestBenchFramework/BenchControl/Keithley/RS232/MultimeterCfgCtrl.cs rename to TestBenchFramework/BenchControl/Keithley/Multimeter_2010_RS232/MultimeterCfgCtrl.cs index 116b8fd2f..c74b84e92 100644 --- a/TestBenchFramework/BenchControl/Keithley/RS232/MultimeterCfgCtrl.cs +++ b/TestBenchFramework/BenchControl/Keithley/Multimeter_2010_RS232/MultimeterCfgCtrl.cs @@ -8,7 +8,7 @@ using log4net; using TBF.BenchControl.Generic; using TBF.Resources; -namespace TBF.BenchControl.Keithley.RS232 +namespace TBF.BenchControl.Keithley.Multimeter_2010_RS232 { public partial class MultimeterCfgCtrl : UserControl, IComponentCfgCtrl { diff --git a/TestBenchFramework/BenchControl/Keithley/RS232/MultimeterCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/Keithley/Multimeter_2010_RS232/MultimeterCfgCtrl.designer.cs similarity index 99% rename from TestBenchFramework/BenchControl/Keithley/RS232/MultimeterCfgCtrl.designer.cs rename to TestBenchFramework/BenchControl/Keithley/Multimeter_2010_RS232/MultimeterCfgCtrl.designer.cs index 9f47819ab..b225f4ed6 100644 --- a/TestBenchFramework/BenchControl/Keithley/RS232/MultimeterCfgCtrl.designer.cs +++ b/TestBenchFramework/BenchControl/Keithley/Multimeter_2010_RS232/MultimeterCfgCtrl.designer.cs @@ -1,7 +1,7 @@ /// /// Copyright (c) 2016 Sensus Metering Systems /// -namespace TBF.BenchControl.Keithley.RS232 +namespace TBF.BenchControl.Keithley.Multimeter_2010_RS232 { partial class MultimeterCfgCtrl { diff --git a/TestBenchFramework/BenchControl/Keithley/RS232/MultimeterCfgCtrl.resx b/TestBenchFramework/BenchControl/Keithley/Multimeter_2010_RS232/MultimeterCfgCtrl.resx similarity index 100% rename from TestBenchFramework/BenchControl/Keithley/RS232/MultimeterCfgCtrl.resx rename to TestBenchFramework/BenchControl/Keithley/Multimeter_2010_RS232/MultimeterCfgCtrl.resx diff --git a/TestBenchFramework/BenchControl/Keithley/RS232/Multimeter.cs b/TestBenchFramework/BenchControl/Keithley/RS232/Multimeter.cs deleted file mode 100644 index a3f91a378..000000000 --- a/TestBenchFramework/BenchControl/Keithley/RS232/Multimeter.cs +++ /dev/null @@ -1,134 +0,0 @@ -/// -/// Copyright (c) 2016 Sensus Metering Systems -/// -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO.Ports; -using System.Text; -using System.Threading; -using log4net; -using Config.Entities; -using TBF.BenchControl.Generic; -using TBF.Boxes; - -namespace TBF.BenchControl.Keithley.RS232 -{ - /// - /// Root component for Modbus communication via serial port (RS485) - /// - public class Multimeter : ComponentBase, IDevice, GenericDevices.IModbus - { - private static readonly ILog log = LogManager.GetLogger(typeof(Multimeter)); - public override string ToString() { return string.Format("Keithley.RS232.Multimeter({0})", Cfg.ToString(1)); } - - private readonly MultimeterCfg modbusCommonCfg; - - /// Private fields - SerialPort serialPort; - Thread workerThread; - bool stopWorkerThread; - - public Multimeter() - { - } - - /// - /// Ambient temperature / humidity / pressure meter 'Greco' connected via serial interface (RS232) - /// Connection settings: 19200 Bd 8-bits No-parity 1-stop-bit Flow control: none or hardware. - /// - public Multimeter(Generic.IComponentCfg cfg) - : base(cfg) - { - modbusCommonCfg = cfg as MultimeterCfg; - serialPort = null; - log.Debug(this.ToString()); - } - - ~Multimeter() - { - } - - public float ReadTemperature(int channelNr) - { - return 25.0f; - } - - - public void Initialize() - { - if (modbusCommonCfg.DebugLevel == DebugMode.Simulate) - { - log.FatalFormat("Simulated device {0}", ToString()); - return; - } - - string comPortName = "COM" + modbusCommonCfg.ComPortNr.ToString(); - serialPort = new SerialPort(comPortName, modbusCommonCfg.BaudRate, modbusCommonCfg.Parity, modbusCommonCfg.DataBits, modbusCommonCfg.StopBits); - serialPort.Handshake = modbusCommonCfg.Handshake; - serialPort.Open(); - - stopWorkerThread = false; - workerThread = new Thread(Worker); - workerThread.Start(); - - log.FatalFormat("Successfully initialized device {0}", ToString()); - } - - - /// - /// Send a modbus message. - /// This function calculates and overwrites the last 2 bytes - /// of the message - CRC as specified in Modbus specification. - /// - /// Message incl CRC, CRC bytes dont have to be set - public void SendMessage(byte[] message) - { - if (modbusCommonCfg.DebugLevel == DebugMode.Simulate) return; - - Telegram.UpdateTelegramCRC(message); - log.Debug(Telegram.LogTelegram("Sending message ", message)); - serialPort.Write(message, 0, message.Length); - } - - void Worker() - { - while (!stopWorkerThread) - { - Thread.Sleep(250); - if (stopWorkerThread) break; - int nrBytes = serialPort.BytesToRead; - if (nrBytes > 0) - { - char[] buffer = new char[nrBytes]; - serialPort.Read(buffer, 0, nrBytes); - string s = Telegram.LogTelegram("Received: ", new string(buffer)); - /// ODO: Add handler - //OnQuidoReceived(this, new QuidoReceivedEventArgs(s)); - } - } - } - - - /// Run this device - public void RunDeviceBefore() - { - } - - /// Run this device - public void RunDeviceAfter() - { - } - - /// Stop this device - public void StopDevice() - { - if (serialPort != null) - { - stopWorkerThread = true; - workerThread.Join(2000); - serialPort.Close(); - } - } - } -} diff --git a/TestBenchFramework/BenchControl/Keithley/TempMeter/Factory.cs b/TestBenchFramework/BenchControl/Keithley/TempMeter/Factory.cs index 8ea2ee2f2..0e3e607e8 100644 --- a/TestBenchFramework/BenchControl/Keithley/TempMeter/Factory.cs +++ b/TestBenchFramework/BenchControl/Keithley/TempMeter/Factory.cs @@ -8,7 +8,7 @@ namespace TBF.BenchControl.Keithley.TempMeter { public class Factory : IComponentFactory { - public string ClassName { get { return this.GetType().Namespace.Substring(17); } } + public string ClassName { get { return GetType().Namespace.Substring(17); } } public void ResetStaticProperties() { TempMeter.ResetStaticProperties(); } @@ -16,7 +16,7 @@ namespace TBF.BenchControl.Keithley.TempMeter public IComponent GetComponent(IComponentCfg cfg, IList components) { return new TempMeter(cfg, components); } - public IComponentCfg DefaultConfig() { return new TempMeterCfg(this); } + public IComponentCfg DefaultConfig() { return new TempMeterCfg(GetType().Namespace.Substring(17), this); } public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { diff --git a/TestBenchFramework/BenchControl/Keithley/TempMeter/ReadTempOp.cs b/TestBenchFramework/BenchControl/Keithley/TempMeter/ReadTempOp.cs index 1adb3f907..6085db1c7 100644 --- a/TestBenchFramework/BenchControl/Keithley/TempMeter/ReadTempOp.cs +++ b/TestBenchFramework/BenchControl/Keithley/TempMeter/ReadTempOp.cs @@ -4,7 +4,7 @@ using System; using log4net; using TBF.Boxes; -using TBF.BenchControl.Keithley.RS232; +using TBF.BenchControl.Keithley.Multimeter_2010_RS232; namespace TBF.BenchControl.Keithley.TempMeter { @@ -40,7 +40,8 @@ namespace TBF.BenchControl.Keithley.TempMeter /// Start this operation public void Start() { - temp.Val = tempMeter.ReadTemperature(); + tempMeter.Multimeter.StartReadingMultimeter(tempMeter.Channel); + temp.Val = 0; } /// Run this operation @@ -56,6 +57,7 @@ namespace TBF.BenchControl.Keithley.TempMeter /// Stop this operation public void Stop() { + tempMeter.Multimeter.StopReadingMultimeter(tempMeter.Channel); } } } diff --git a/TestBenchFramework/BenchControl/Keithley/TempMeter/TempMeter.cs b/TestBenchFramework/BenchControl/Keithley/TempMeter/TempMeter.cs index 77ba5c174..ae11ff9de 100644 --- a/TestBenchFramework/BenchControl/Keithley/TempMeter/TempMeter.cs +++ b/TestBenchFramework/BenchControl/Keithley/TempMeter/TempMeter.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using log4net; using TBF.Boxes; -using TBF.BenchControl.Keithley.RS232; +using TBF.BenchControl.Keithley.Multimeter_2010_RS232; namespace TBF.BenchControl.Keithley.TempMeter { @@ -18,7 +18,11 @@ namespace TBF.BenchControl.Keithley.TempMeter public readonly Multimeter Multimeter; /// parent component - public int Idx0 { get { return tempMtrCfg.Idx0; } } /// 0..3 + public int Channel { get { return tempMtrCfg.Channel; } } /// 1..5 + + Dictionary operations; + Dictionary operations2; + public TempMeter() { @@ -32,14 +36,24 @@ namespace TBF.BenchControl.Keithley.TempMeter Multimeter = (Multimeter)TbfComponents.FindComponent(cfg.ParentName, components); if (Multimeter == null) throw new Exception("Cannot find " + Name + " parent"); + operations = new Dictionary(); + operations2 = new Dictionary(); + log.Debug(this.ToString()); } public float ReadTemperature() { - return Multimeter.ReadTemperature(Idx0); + double resistance = Multimeter.ReadResistance(Channel); + + return Resistance2Temperature(resistance); } + private float Resistance2Temperature(double resistance) + { + return 30.0F + (float)tempMtrCfg.Channel; /// TODO: implement + } + /// /// Events: TempDone, Error /// @@ -47,7 +61,17 @@ namespace TBF.BenchControl.Keithley.TempMeter /// ReadTempOp instance reference casted to IOperaton public IOperation ReadTempOp(ref FloatBox temp) { - return new ReadTempOp(this, ref temp); + IOperation operation; + if (operations.TryGetValue(temp, out operation)) + { + return operation; + } + else + { + operation = new ReadTempOp(this, ref temp); + operations.Add(temp, operation); + return operation; + } } /// @@ -58,7 +82,17 @@ namespace TBF.BenchControl.Keithley.TempMeter /// ReadTempOp instance reference casted to IOperaton public IOperation ReadTempOp(ref FloatBox temp, Event tempDone) { - return new ReadTempOp(this, ref temp, tempDone); + IOperation operation; + if (operations2.TryGetValue(temp, out operation)) + { + return operation; + } + else + { + operation = new ReadTempOp(this, ref temp, tempDone); + operations2.Add(temp, operation); + return operation; + } } } } diff --git a/TestBenchFramework/BenchControl/Keithley/TempMeter/TempMeterCfg.cs b/TestBenchFramework/BenchControl/Keithley/TempMeter/TempMeterCfg.cs index 9e763c60e..d5af492e2 100644 --- a/TestBenchFramework/BenchControl/Keithley/TempMeter/TempMeterCfg.cs +++ b/TestBenchFramework/BenchControl/Keithley/TempMeter/TempMeterCfg.cs @@ -16,28 +16,28 @@ namespace TBF.BenchControl.Keithley.TempMeter /// /// Serialized parameters /// - public int Idx0; /// 0..3 + public int Channel; /// 1..5 /// Private parameterless constructor invoked by all other (public) constructors TempMeterCfg() { - Name = "T"; - ParentName = "Keithley"; - Idx0 = 0; } - public TempMeterCfg(IComponentFactory factory) + public TempMeterCfg(string name, IComponentFactory factory) : this() { + this.Name = name; this.Factory = factory; + ParentName = "Keithley.Multimeter_2010_RS232"; + Channel = 1; } public string ToString(int i) { - return string.Format("Name={0}, Parent={1}, Idx0={2}", + return string.Format("Name={0}, Parent={1}, Channel={2}", Name, (string.IsNullOrEmpty(ParentName) ? "-" : ParentName), - Idx0); + Channel); } } } diff --git a/TestBenchFramework/BenchControl/Keithley/TempMeter/TempMeterCfgCtrl.Designer.cs b/TestBenchFramework/BenchControl/Keithley/TempMeter/TempMeterCfgCtrl.Designer.cs index c4573c9ad..f88fa89e8 100644 --- a/TestBenchFramework/BenchControl/Keithley/TempMeter/TempMeterCfgCtrl.Designer.cs +++ b/TestBenchFramework/BenchControl/Keithley/TempMeter/TempMeterCfgCtrl.Designer.cs @@ -31,99 +31,99 @@ namespace TBF.BenchControl.Keithley.TempMeter /// private void InitializeComponent() { - this.positionTextBox = new System.Windows.Forms.TextBox(); - this.positionLabel = new System.Windows.Forms.Label(); - this.parentNameLabel = new System.Windows.Forms.Label(); - this.nameTextBox = new System.Windows.Forms.TextBox(); - this.nameLabel = new System.Windows.Forms.Label(); - this.classNameLabel = new System.Windows.Forms.Label(); - this.parentNameComboBox = new System.Windows.Forms.ComboBox(); - this.SuspendLayout(); - // - // positionTextBox - // - this.positionTextBox.Enabled = false; - this.positionTextBox.Location = new System.Drawing.Point(130, 82); - this.positionTextBox.Name = "positionTextBox"; - this.positionTextBox.Size = new System.Drawing.Size(46, 20); - this.positionTextBox.TabIndex = 6; - // - // positionLabel - // - this.positionLabel.AutoSize = true; - this.positionLabel.Location = new System.Drawing.Point(20, 85); - this.positionLabel.Name = "positionLabel"; - this.positionLabel.Size = new System.Drawing.Size(44, 13); - this.positionLabel.TabIndex = 5; - this.positionLabel.Text = "Position"; - // - // parentNameLabel - // - this.parentNameLabel.AutoSize = true; - this.parentNameLabel.Location = new System.Drawing.Point(20, 61); - this.parentNameLabel.Name = "parentNameLabel"; - this.parentNameLabel.Size = new System.Drawing.Size(69, 13); - this.parentNameLabel.TabIndex = 3; - this.parentNameLabel.Text = "Parent Name"; - // - // nameTextBox - // - this.nameTextBox.Enabled = false; - this.nameTextBox.Location = new System.Drawing.Point(130, 34); - this.nameTextBox.Name = "nameTextBox"; - this.nameTextBox.Size = new System.Drawing.Size(130, 20); - this.nameTextBox.TabIndex = 2; - // - // nameLabel - // - this.nameLabel.AutoSize = true; - this.nameLabel.Location = new System.Drawing.Point(20, 37); - this.nameLabel.Name = "nameLabel"; - this.nameLabel.Size = new System.Drawing.Size(35, 13); - this.nameLabel.TabIndex = 1; - this.nameLabel.Text = "Name"; - // - // classNameLabel - // - this.classNameLabel.AutoSize = true; - this.classNameLabel.Location = new System.Drawing.Point(127, 10); - this.classNameLabel.Name = "classNameLabel"; - this.classNameLabel.Size = new System.Drawing.Size(83, 13); - this.classNameLabel.TabIndex = 0; - this.classNameLabel.Text = "ComonentName"; - // - // parentNameComboBox - // - this.parentNameComboBox.Enabled = false; - this.parentNameComboBox.FormattingEnabled = true; - this.parentNameComboBox.Location = new System.Drawing.Point(130, 58); - this.parentNameComboBox.Name = "parentNameComboBox"; - this.parentNameComboBox.Size = new System.Drawing.Size(130, 21); - this.parentNameComboBox.TabIndex = 4; - // - // TempMeterCfgCtrl - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.parentNameComboBox); - this.Controls.Add(this.positionTextBox); - this.Controls.Add(this.positionLabel); - this.Controls.Add(this.parentNameLabel); - this.Controls.Add(this.nameTextBox); - this.Controls.Add(this.nameLabel); - this.Controls.Add(this.classNameLabel); - this.Name = "TempMeterCfgCtrl"; - this.Size = new System.Drawing.Size(300, 240); - this.Load += new System.EventHandler(this.TempMeterCfgCtrl_Load); - this.ResumeLayout(false); - this.PerformLayout(); + this.channelTextBox = new System.Windows.Forms.TextBox(); + this.channelLabel = new System.Windows.Forms.Label(); + this.parentNameLabel = new System.Windows.Forms.Label(); + this.nameTextBox = new System.Windows.Forms.TextBox(); + this.nameLabel = new System.Windows.Forms.Label(); + this.classNameLabel = new System.Windows.Forms.Label(); + this.parentNameComboBox = new System.Windows.Forms.ComboBox(); + this.SuspendLayout(); + // + // channelTextBox + // + this.channelTextBox.Enabled = false; + this.channelTextBox.Location = new System.Drawing.Point(130, 82); + this.channelTextBox.Name = "channelTextBox"; + this.channelTextBox.Size = new System.Drawing.Size(46, 20); + this.channelTextBox.TabIndex = 6; + // + // channelLabel + // + this.channelLabel.AutoSize = true; + this.channelLabel.Location = new System.Drawing.Point(20, 85); + this.channelLabel.Name = "channelLabel"; + this.channelLabel.Size = new System.Drawing.Size(73, 13); + this.channelLabel.TabIndex = 5; + this.channelLabel.Text = "Channel (1..5)"; + // + // parentNameLabel + // + this.parentNameLabel.AutoSize = true; + this.parentNameLabel.Location = new System.Drawing.Point(20, 61); + this.parentNameLabel.Name = "parentNameLabel"; + this.parentNameLabel.Size = new System.Drawing.Size(69, 13); + this.parentNameLabel.TabIndex = 3; + this.parentNameLabel.Text = "Parent Name"; + // + // nameTextBox + // + this.nameTextBox.Enabled = false; + this.nameTextBox.Location = new System.Drawing.Point(130, 34); + this.nameTextBox.Name = "nameTextBox"; + this.nameTextBox.Size = new System.Drawing.Size(130, 20); + this.nameTextBox.TabIndex = 2; + // + // nameLabel + // + this.nameLabel.AutoSize = true; + this.nameLabel.Location = new System.Drawing.Point(20, 37); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(35, 13); + this.nameLabel.TabIndex = 1; + this.nameLabel.Text = "Name"; + // + // classNameLabel + // + this.classNameLabel.AutoSize = true; + this.classNameLabel.Location = new System.Drawing.Point(127, 10); + this.classNameLabel.Name = "classNameLabel"; + this.classNameLabel.Size = new System.Drawing.Size(83, 13); + this.classNameLabel.TabIndex = 0; + this.classNameLabel.Text = "ComonentName"; + // + // parentNameComboBox + // + this.parentNameComboBox.Enabled = false; + this.parentNameComboBox.FormattingEnabled = true; + this.parentNameComboBox.Location = new System.Drawing.Point(130, 58); + this.parentNameComboBox.Name = "parentNameComboBox"; + this.parentNameComboBox.Size = new System.Drawing.Size(130, 21); + this.parentNameComboBox.TabIndex = 4; + // + // TempMeterCfgCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.parentNameComboBox); + this.Controls.Add(this.channelTextBox); + this.Controls.Add(this.channelLabel); + this.Controls.Add(this.parentNameLabel); + this.Controls.Add(this.nameTextBox); + this.Controls.Add(this.nameLabel); + this.Controls.Add(this.classNameLabel); + this.Name = "TempMeterCfgCtrl"; + this.Size = new System.Drawing.Size(300, 240); + this.Load += new System.EventHandler(this.TempMeterCfgCtrl_Load); + this.ResumeLayout(false); + this.PerformLayout(); } #endregion - private System.Windows.Forms.TextBox positionTextBox; - private System.Windows.Forms.Label positionLabel; + private System.Windows.Forms.TextBox channelTextBox; + private System.Windows.Forms.Label channelLabel; private System.Windows.Forms.Label parentNameLabel; private System.Windows.Forms.TextBox nameTextBox; private System.Windows.Forms.Label nameLabel; diff --git a/TestBenchFramework/BenchControl/Keithley/TempMeter/TempMeterCfgCtrl.cs b/TestBenchFramework/BenchControl/Keithley/TempMeter/TempMeterCfgCtrl.cs index 6d94aeb54..128f46ed0 100644 --- a/TestBenchFramework/BenchControl/Keithley/TempMeter/TempMeterCfgCtrl.cs +++ b/TestBenchFramework/BenchControl/Keithley/TempMeter/TempMeterCfgCtrl.cs @@ -5,7 +5,9 @@ using System; using System.Globalization; using System.Windows.Forms; using log4net; +using TBF.BenchControl; using TBF.BenchControl.Generic; +using TBF.Resources; namespace TBF.BenchControl.Keithley.TempMeter { @@ -35,6 +37,8 @@ namespace TBF.BenchControl.Keithley.TempMeter private void TempMeterCfgCtrl_Load(object sender, EventArgs e) { + Localize(); + parent = ParentForm as ComponentParametersDlg; if (parent == null) return; @@ -42,7 +46,7 @@ namespace TBF.BenchControl.Keithley.TempMeter { foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Keithley.RS232.Factory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Keithley.Multimeter_2010_RS232.Factory) { parentNameComboBox.Items.Add(cmpnt.Name); } @@ -52,6 +56,13 @@ namespace TBF.BenchControl.Keithley.TempMeter Redraw(); } + void Localize() + { + nameLabel.Text = Strings.Name; + parentNameLabel.Text = Strings.Parent_name; + channelLabel.Text = string.Format("{0} (1..5)", Strings.Channel); + } + public void Closing() { } @@ -63,14 +74,14 @@ namespace TBF.BenchControl.Keithley.TempMeter classNameLabel.Text = config.Factory.ClassName; nameTextBox.Text = config.Name; parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName; - positionTextBox.Text = config.Idx0.ToString(); + channelTextBox.Text = config.Channel.ToString(); } public void Unlock() { nameTextBox.Enabled = true; parentNameComboBox.Enabled = true; - positionTextBox.Enabled = true; + channelTextBox.Enabled = true; } public CfgUpdateFlags VerifyCfg(ref string message) @@ -81,12 +92,12 @@ namespace TBF.BenchControl.Keithley.TempMeter if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text)) { flags |= CfgUpdateFlags.Error; - message += Environment.NewLine + "Invalid 'Parent Name'"; + message += Environment.NewLine + string.Format(Strings.Invalid_0, Strings.Parent_name); } - if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 0 || dummy > 7) + if (!int.TryParse(channelTextBox.Text, out dummy) || dummy < 1 || dummy > 5) { flags |= CfgUpdateFlags.Error; - message += Environment.NewLine + "'Position' should be between 0 and 7"; + message += Environment.NewLine + "'Channel' should be in the range 1 .. 5"; } return flags; @@ -100,7 +111,7 @@ namespace TBF.BenchControl.Keithley.TempMeter config.Name = nameTextBox.Text; config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; - config.Idx0 = int.Parse(positionTextBox.Text); + config.Channel = int.Parse(channelTextBox.Text); return flags; } diff --git a/TestBenchFramework/BenchControl/TbfComponents.cs b/TestBenchFramework/BenchControl/TbfComponents.cs index a6a2e6ff6..906186f85 100644 --- a/TestBenchFramework/BenchControl/TbfComponents.cs +++ b/TestBenchFramework/BenchControl/TbfComponents.cs @@ -51,7 +51,7 @@ namespace TBF.BenchControl Factories.Add(new Cameras.IdcCamera.IdcCameraFactory()); Factories.Add(new WaterMeters.iPerl.WaterMeterFactory()); /// iPerl Factories.Add(new TestMethods.iPerlCommunication.TestMethodFactory()); /// iPerlCommunication - Factories.Add(new Keithley.RS232.Factory()); /// Keithley.RS232.Multimeter + Factories.Add(new Keithley.Multimeter_2010_RS232.Factory()); /// Keithley.Multimeter_2010_RS232 Factories.Add(new Keithley.TempMeter.Factory()); /// Keithley.TempMeter Factories.Add(new ResultsPrinters.LabelPrinter.PrinterFactory()); /// LabelPrinter Factories.Add(new TestMethods.LeakTest.TestMethodFactory()); diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index 41046133f..d74211f92 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -519,6 +519,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Channel. + /// + internal static string Channel { + get { + return ResourceManager.GetString("Channel", resourceCulture); + } + } + /// /// Looks up a localized string similar to Checking tank capacity. /// @@ -2265,6 +2274,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Parent name. + /// + internal static string Parent_name { + get { + return ResourceManager.GetString("Parent_name", resourceCulture); + } + } + /// /// Looks up a localized string similar to Part. /// diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index e7ee8345f..3de837a95 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -1552,4 +1552,10 @@ Prompt + + Channel + + + Parent name + \ No newline at end of file diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj index a143b2e37..e01226fdd 100644 --- a/TestBenchFramework/TBF.csproj +++ b/TestBenchFramework/TBF.csproj @@ -377,13 +377,13 @@ - - - - + + + + UserControl - + MultimeterCfgCtrl.cs @@ -1682,7 +1682,7 @@ ValveCfgCtrl.cs - + MultimeterCfgCtrl.cs