Keithley modifications.

This commit is contained in:
Milan Hanajik
2016-08-23 15:21:17 +02:00
parent fc0bdda553
commit 700b9b3122
17 changed files with 461 additions and 265 deletions
@@ -4,11 +4,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using TBF.BenchControl.Generic; using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Keithley.RS232 namespace TBF.BenchControl.Keithley.Multimeter_2010_RS232
{ {
public class Factory : IComponentFactory 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(); } public void ResetStaticProperties() { Multimeter.ResetStaticProperties(); }
@@ -16,7 +16,7 @@ namespace TBF.BenchControl.Keithley.RS232
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Multimeter(cfg); } public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> 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) public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{ {
@@ -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
{
/// <summary>
/// Root component for Modbus communication via serial port (RS485)
/// </summary>
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 <ChannelFrom, ChannelTo> is used as an index to this array
/// Private fields
SerialPort serialPort;
IList<int> listOfReadOperations;
IList<int> 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];
}
/// <summary>
/// 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.
/// </summary>
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<int>();
listOfChannels = new List<int>();
nextChannelIx = 0;
currentChannel = 0; /// invalid, no :rout:clos command yet
scanState = ScanState.Off;
log.Debug(this.ToString());
}
~Multimeter()
{
}
/// <summary>
/// Start reading temperature from specified channel
/// </summary>
/// <param name="channel">channel in range ChannelFrom .. ChannelTo</param>
/// <returns>true when successful</returns>
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;
}
/// <summary>
/// Stop reading temperature from specified channel
/// </summary>
/// <param name="channel">channel in range ChannelFrom .. ChannelTo</param>
/// <returns>true when successful</returns>
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);
}
/// <summary>Run this device</summary>
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;
}
}
}
}
/// <summary>Run this device</summary>
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;
}
}
/// <summary>Stop this device</summary>
public void StopDevice()
{
serialPort.Close();
}
}
}
@@ -7,7 +7,7 @@ using System.IO.Ports;
using System.Xml.Serialization; using System.Xml.Serialization;
using TBF.BenchControl.Generic; using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Keithley.RS232 namespace TBF.BenchControl.Keithley.Multimeter_2010_RS232
{ {
public class MultimeterCfg : ComponentCfgBase, Generic.IComponentCfg public class MultimeterCfg : ComponentCfgBase, Generic.IComponentCfg
{ {
@@ -26,7 +26,13 @@ namespace TBF.BenchControl.Keithley.RS232
/// Private parameterless constructor invoked by all other (public) constructors /// Private parameterless constructor invoked by all other (public) constructors
MultimeterCfg() MultimeterCfg()
{ {
Name = "Keithley"; }
public MultimeterCfg(string name, IComponentFactory factory)
: this()
{
this.Name = name;
this.Factory = factory;
ParentName = string.Empty; ParentName = string.Empty;
ComPortNr = 5; ComPortNr = 5;
BaudRate = 9600; BaudRate = 9600;
@@ -36,12 +42,6 @@ namespace TBF.BenchControl.Keithley.RS232
Handshake = System.IO.Ports.Handshake.None; Handshake = System.IO.Ports.Handshake.None;
} }
public MultimeterCfg(IComponentFactory factory)
: this()
{
this.Factory = factory;
}
public string ToString(int i) public string ToString(int i)
{ {
return string.Format("Name={0}, Com{1}, {2}Bd, {3}-bits, parity={4}, stopBits={5}, {6}", return string.Format("Name={0}, Com{1}, {2}Bd, {3}-bits, parity={4}, stopBits={5}, {6}",
@@ -8,7 +8,7 @@ using log4net;
using TBF.BenchControl.Generic; using TBF.BenchControl.Generic;
using TBF.Resources; using TBF.Resources;
namespace TBF.BenchControl.Keithley.RS232 namespace TBF.BenchControl.Keithley.Multimeter_2010_RS232
{ {
public partial class MultimeterCfgCtrl : UserControl, IComponentCfgCtrl public partial class MultimeterCfgCtrl : UserControl, IComponentCfgCtrl
{ {
@@ -1,7 +1,7 @@
/// ///
/// Copyright (c) 2016 Sensus Metering Systems /// Copyright (c) 2016 Sensus Metering Systems
/// ///
namespace TBF.BenchControl.Keithley.RS232 namespace TBF.BenchControl.Keithley.Multimeter_2010_RS232
{ {
partial class MultimeterCfgCtrl partial class MultimeterCfgCtrl
{ {
@@ -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
{
/// <summary>
/// Root component for Modbus communication via serial port (RS485)
/// </summary>
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()
{
}
/// <summary>
/// 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.
/// </summary>
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());
}
/// <summary>
/// Send a modbus message.
/// This function calculates and overwrites the last 2 bytes
/// of the message - CRC as specified in Modbus specification.
/// </summary>
/// <param name="message">Message incl CRC, CRC bytes dont have to be set</param>
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));
}
}
}
/// <summary>Run this device</summary>
public void RunDeviceBefore()
{
}
/// <summary>Run this device</summary>
public void RunDeviceAfter()
{
}
/// <summary>Stop this device</summary>
public void StopDevice()
{
if (serialPort != null)
{
stopWorkerThread = true;
workerThread.Join(2000);
serialPort.Close();
}
}
}
}
@@ -8,7 +8,7 @@ namespace TBF.BenchControl.Keithley.TempMeter
{ {
public class Factory : IComponentFactory 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(); } public void ResetStaticProperties() { TempMeter.ResetStaticProperties(); }
@@ -16,7 +16,7 @@ namespace TBF.BenchControl.Keithley.TempMeter
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new TempMeter(cfg, components); } public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> 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) public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{ {
@@ -4,7 +4,7 @@
using System; using System;
using log4net; using log4net;
using TBF.Boxes; using TBF.Boxes;
using TBF.BenchControl.Keithley.RS232; using TBF.BenchControl.Keithley.Multimeter_2010_RS232;
namespace TBF.BenchControl.Keithley.TempMeter namespace TBF.BenchControl.Keithley.TempMeter
{ {
@@ -40,7 +40,8 @@ namespace TBF.BenchControl.Keithley.TempMeter
/// <summary>Start this operation</summary> /// <summary>Start this operation</summary>
public void Start() public void Start()
{ {
temp.Val = tempMeter.ReadTemperature(); tempMeter.Multimeter.StartReadingMultimeter(tempMeter.Channel);
temp.Val = 0;
} }
/// <summary>Run this operation</summary> /// <summary>Run this operation</summary>
@@ -56,6 +57,7 @@ namespace TBF.BenchControl.Keithley.TempMeter
/// <summary>Stop this operation</summary> /// <summary>Stop this operation</summary>
public void Stop() public void Stop()
{ {
tempMeter.Multimeter.StopReadingMultimeter(tempMeter.Channel);
} }
} }
} }
@@ -5,7 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using log4net; using log4net;
using TBF.Boxes; using TBF.Boxes;
using TBF.BenchControl.Keithley.RS232; using TBF.BenchControl.Keithley.Multimeter_2010_RS232;
namespace TBF.BenchControl.Keithley.TempMeter namespace TBF.BenchControl.Keithley.TempMeter
{ {
@@ -18,7 +18,11 @@ namespace TBF.BenchControl.Keithley.TempMeter
public readonly Multimeter Multimeter; /// parent component 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<FloatBox, IOperation> operations;
Dictionary<FloatBox, IOperation> operations2;
public TempMeter() public TempMeter()
{ {
@@ -32,12 +36,22 @@ namespace TBF.BenchControl.Keithley.TempMeter
Multimeter = (Multimeter)TbfComponents.FindComponent(cfg.ParentName, components); Multimeter = (Multimeter)TbfComponents.FindComponent(cfg.ParentName, components);
if (Multimeter == null) throw new Exception("Cannot find " + Name + " parent"); if (Multimeter == null) throw new Exception("Cannot find " + Name + " parent");
operations = new Dictionary<FloatBox, IOperation>();
operations2 = new Dictionary<FloatBox, IOperation>();
log.Debug(this.ToString()); log.Debug(this.ToString());
} }
public float ReadTemperature() 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
} }
/// <summary> /// <summary>
@@ -47,7 +61,17 @@ namespace TBF.BenchControl.Keithley.TempMeter
/// <returns>ReadTempOp instance reference casted to IOperaton</returns> /// <returns>ReadTempOp instance reference casted to IOperaton</returns>
public IOperation ReadTempOp(ref FloatBox temp) 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;
}
} }
/// <summary> /// <summary>
@@ -58,7 +82,17 @@ namespace TBF.BenchControl.Keithley.TempMeter
/// <returns>ReadTempOp instance reference casted to IOperaton</returns> /// <returns>ReadTempOp instance reference casted to IOperaton</returns>
public IOperation ReadTempOp(ref FloatBox temp, Event tempDone) 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;
}
} }
} }
} }
@@ -16,28 +16,28 @@ namespace TBF.BenchControl.Keithley.TempMeter
/// ///
/// Serialized parameters /// Serialized parameters
/// ///
public int Idx0; /// 0..3 public int Channel; /// 1..5
/// Private parameterless constructor invoked by all other (public) constructors /// Private parameterless constructor invoked by all other (public) constructors
TempMeterCfg() TempMeterCfg()
{ {
Name = "T";
ParentName = "Keithley";
Idx0 = 0;
} }
public TempMeterCfg(IComponentFactory factory) public TempMeterCfg(string name, IComponentFactory factory)
: this() : this()
{ {
this.Name = name;
this.Factory = factory; this.Factory = factory;
ParentName = "Keithley.Multimeter_2010_RS232";
Channel = 1;
} }
public string ToString(int i) public string ToString(int i)
{ {
return string.Format("Name={0}, Parent={1}, Idx0={2}", return string.Format("Name={0}, Parent={1}, Channel={2}",
Name, Name,
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName), (string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
Idx0); Channel);
} }
} }
} }
@@ -31,8 +31,8 @@ namespace TBF.BenchControl.Keithley.TempMeter
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.positionTextBox = new System.Windows.Forms.TextBox(); this.channelTextBox = new System.Windows.Forms.TextBox();
this.positionLabel = new System.Windows.Forms.Label(); this.channelLabel = new System.Windows.Forms.Label();
this.parentNameLabel = new System.Windows.Forms.Label(); this.parentNameLabel = new System.Windows.Forms.Label();
this.nameTextBox = new System.Windows.Forms.TextBox(); this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label(); this.nameLabel = new System.Windows.Forms.Label();
@@ -40,22 +40,22 @@ namespace TBF.BenchControl.Keithley.TempMeter
this.parentNameComboBox = new System.Windows.Forms.ComboBox(); this.parentNameComboBox = new System.Windows.Forms.ComboBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// positionTextBox // channelTextBox
// //
this.positionTextBox.Enabled = false; this.channelTextBox.Enabled = false;
this.positionTextBox.Location = new System.Drawing.Point(130, 82); this.channelTextBox.Location = new System.Drawing.Point(130, 82);
this.positionTextBox.Name = "positionTextBox"; this.channelTextBox.Name = "channelTextBox";
this.positionTextBox.Size = new System.Drawing.Size(46, 20); this.channelTextBox.Size = new System.Drawing.Size(46, 20);
this.positionTextBox.TabIndex = 6; this.channelTextBox.TabIndex = 6;
// //
// positionLabel // channelLabel
// //
this.positionLabel.AutoSize = true; this.channelLabel.AutoSize = true;
this.positionLabel.Location = new System.Drawing.Point(20, 85); this.channelLabel.Location = new System.Drawing.Point(20, 85);
this.positionLabel.Name = "positionLabel"; this.channelLabel.Name = "channelLabel";
this.positionLabel.Size = new System.Drawing.Size(44, 13); this.channelLabel.Size = new System.Drawing.Size(73, 13);
this.positionLabel.TabIndex = 5; this.channelLabel.TabIndex = 5;
this.positionLabel.Text = "Position"; this.channelLabel.Text = "Channel (1..5)";
// //
// parentNameLabel // parentNameLabel
// //
@@ -106,8 +106,8 @@ namespace TBF.BenchControl.Keithley.TempMeter
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.parentNameComboBox); this.Controls.Add(this.parentNameComboBox);
this.Controls.Add(this.positionTextBox); this.Controls.Add(this.channelTextBox);
this.Controls.Add(this.positionLabel); this.Controls.Add(this.channelLabel);
this.Controls.Add(this.parentNameLabel); this.Controls.Add(this.parentNameLabel);
this.Controls.Add(this.nameTextBox); this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel); this.Controls.Add(this.nameLabel);
@@ -122,8 +122,8 @@ namespace TBF.BenchControl.Keithley.TempMeter
#endregion #endregion
private System.Windows.Forms.TextBox positionTextBox; private System.Windows.Forms.TextBox channelTextBox;
private System.Windows.Forms.Label positionLabel; private System.Windows.Forms.Label channelLabel;
private System.Windows.Forms.Label parentNameLabel; private System.Windows.Forms.Label parentNameLabel;
private System.Windows.Forms.TextBox nameTextBox; private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel; private System.Windows.Forms.Label nameLabel;
@@ -5,7 +5,9 @@ using System;
using System.Globalization; using System.Globalization;
using System.Windows.Forms; using System.Windows.Forms;
using log4net; using log4net;
using TBF.BenchControl;
using TBF.BenchControl.Generic; using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.Keithley.TempMeter namespace TBF.BenchControl.Keithley.TempMeter
{ {
@@ -35,6 +37,8 @@ namespace TBF.BenchControl.Keithley.TempMeter
private void TempMeterCfgCtrl_Load(object sender, EventArgs e) private void TempMeterCfgCtrl_Load(object sender, EventArgs e)
{ {
Localize();
parent = ParentForm as ComponentParametersDlg; parent = ParentForm as ComponentParametersDlg;
if (parent == null) return; if (parent == null) return;
@@ -42,7 +46,7 @@ namespace TBF.BenchControl.Keithley.TempMeter
{ {
foreach (var cmpnt in parent.TbfComponents) 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); parentNameComboBox.Items.Add(cmpnt.Name);
} }
@@ -52,6 +56,13 @@ namespace TBF.BenchControl.Keithley.TempMeter
Redraw(); Redraw();
} }
void Localize()
{
nameLabel.Text = Strings.Name;
parentNameLabel.Text = Strings.Parent_name;
channelLabel.Text = string.Format("{0} (1..5)", Strings.Channel);
}
public void Closing() public void Closing()
{ {
} }
@@ -63,14 +74,14 @@ namespace TBF.BenchControl.Keithley.TempMeter
classNameLabel.Text = config.Factory.ClassName; classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name; nameTextBox.Text = config.Name;
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName; parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
positionTextBox.Text = config.Idx0.ToString(); channelTextBox.Text = config.Channel.ToString();
} }
public void Unlock() public void Unlock()
{ {
nameTextBox.Enabled = true; nameTextBox.Enabled = true;
parentNameComboBox.Enabled = true; parentNameComboBox.Enabled = true;
positionTextBox.Enabled = true; channelTextBox.Enabled = true;
} }
public CfgUpdateFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
@@ -81,12 +92,12 @@ namespace TBF.BenchControl.Keithley.TempMeter
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text)) if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{ {
flags |= CfgUpdateFlags.Error; 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; 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; return flags;
@@ -100,7 +111,7 @@ namespace TBF.BenchControl.Keithley.TempMeter
config.Name = nameTextBox.Text; config.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.Idx0 = int.Parse(positionTextBox.Text); config.Channel = int.Parse(channelTextBox.Text);
return flags; return flags;
} }
@@ -51,7 +51,7 @@ namespace TBF.BenchControl
Factories.Add(new Cameras.IdcCamera.IdcCameraFactory()); Factories.Add(new Cameras.IdcCamera.IdcCameraFactory());
Factories.Add(new WaterMeters.iPerl.WaterMeterFactory()); /// iPerl Factories.Add(new WaterMeters.iPerl.WaterMeterFactory()); /// iPerl
Factories.Add(new TestMethods.iPerlCommunication.TestMethodFactory()); /// iPerlCommunication 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 Keithley.TempMeter.Factory()); /// Keithley.TempMeter
Factories.Add(new ResultsPrinters.LabelPrinter.PrinterFactory()); /// LabelPrinter Factories.Add(new ResultsPrinters.LabelPrinter.PrinterFactory()); /// LabelPrinter
Factories.Add(new TestMethods.LeakTest.TestMethodFactory()); Factories.Add(new TestMethods.LeakTest.TestMethodFactory());
+18
View File
@@ -519,6 +519,15 @@ namespace TBF.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Channel.
/// </summary>
internal static string Channel {
get {
return ResourceManager.GetString("Channel", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Checking tank capacity. /// Looks up a localized string similar to Checking tank capacity.
/// </summary> /// </summary>
@@ -2265,6 +2274,15 @@ namespace TBF.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Parent name.
/// </summary>
internal static string Parent_name {
get {
return ResourceManager.GetString("Parent_name", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Part. /// Looks up a localized string similar to Part.
/// </summary> /// </summary>
@@ -1552,4 +1552,10 @@
<data name="Prompt" xml:space="preserve"> <data name="Prompt" xml:space="preserve">
<value>Prompt</value> <value>Prompt</value>
</data> </data>
<data name="Channel" xml:space="preserve">
<value>Channel</value>
</data>
<data name="Parent_name" xml:space="preserve">
<value>Parent name</value>
</data>
</root> </root>
+6 -6
View File
@@ -377,13 +377,13 @@
<Compile Include="BenchControl\GenericDevices\IBenchInfo.cs" /> <Compile Include="BenchControl\GenericDevices\IBenchInfo.cs" />
<Compile Include="BenchControl\GenericDevices\ISimultTestMethod.cs" /> <Compile Include="BenchControl\GenericDevices\ISimultTestMethod.cs" />
<Compile Include="BenchControl\HeatMetersPath.cs" /> <Compile Include="BenchControl\HeatMetersPath.cs" />
<Compile Include="BenchControl\Keithley\RS232\Factory.cs" /> <Compile Include="BenchControl\Keithley\Multimeter_2010_RS232\Factory.cs" />
<Compile Include="BenchControl\Keithley\RS232\Multimeter.cs" /> <Compile Include="BenchControl\Keithley\Multimeter_2010_RS232\Multimeter.cs" />
<Compile Include="BenchControl\Keithley\RS232\MultimeterCfg.cs" /> <Compile Include="BenchControl\Keithley\Multimeter_2010_RS232\MultimeterCfg.cs" />
<Compile Include="BenchControl\Keithley\RS232\MultimeterCfgCtrl.cs"> <Compile Include="BenchControl\Keithley\Multimeter_2010_RS232\MultimeterCfgCtrl.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="BenchControl\Keithley\RS232\MultimeterCfgCtrl.designer.cs"> <Compile Include="BenchControl\Keithley\Multimeter_2010_RS232\MultimeterCfgCtrl.designer.cs">
<DependentUpon>MultimeterCfgCtrl.cs</DependentUpon> <DependentUpon>MultimeterCfgCtrl.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="BenchControl\Keithley\TempMeter\ReadTempOp.cs" /> <Compile Include="BenchControl\Keithley\TempMeter\ReadTempOp.cs" />
@@ -1682,7 +1682,7 @@
<EmbeddedResource Include="BenchControl\Elde\Valve\ValveCfgCtrl.resx"> <EmbeddedResource Include="BenchControl\Elde\Valve\ValveCfgCtrl.resx">
<DependentUpon>ValveCfgCtrl.cs</DependentUpon> <DependentUpon>ValveCfgCtrl.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="BenchControl\Keithley\RS232\MultimeterCfgCtrl.resx"> <EmbeddedResource Include="BenchControl\Keithley\Multimeter_2010_RS232\MultimeterCfgCtrl.resx">
<DependentUpon>MultimeterCfgCtrl.cs</DependentUpon> <DependentUpon>MultimeterCfgCtrl.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="BenchControl\Keithley\TempMeter\TempMeterCfgCtrl.resx"> <EmbeddedResource Include="BenchControl\Keithley\TempMeter\TempMeterCfgCtrl.resx">