(1) SLM_END Elde comp. updated (03.10.2018), (2) Elde.TempMeterMeret component added, (3) MeretRS485Address array size increased for 2 new Meret temp.meters for SLM_END, ver. 2.18.1012
This commit is contained in:
parent
5da9b1e94e
commit
a8df9b50de
@ -141,11 +141,11 @@ namespace TBF.BenchControl.Elde
|
||||
public uint[,] RegValveCalib = new uint[8,2] {{100,500},{100,500},{100,500},{100,500},{100,500},{100,500},{100,500},{100,500}};
|
||||
public byte[] MeretRS485Address = new byte[4];
|
||||
public float[] EtCalib = new float[5] { 1, 1, 1, 1, 1 };
|
||||
#elif IZRAEL_50
|
||||
public uint[,] RegValveCalib = new uint[8, 2] { { 100, 500 }, { 100, 500 }, { 100, 500 }, { 100, 500 }, { 100, 500 }, { 100, 500 }, { 100, 500 }, { 100, 500 } };
|
||||
public byte[] MeretRS485Address = new byte[7]; /// Mpdbus addresses of Pr1, Pr2, Pr3, Pr4, Pr5, Pr6, T9
|
||||
#elif IZRAEL_50 || SLM_END
|
||||
public uint[,] RegValveCalib = new uint[8,2] {{100,500},{100,500},{100,500},{100,500},{100,500},{100,500},{100,500},{100,500}};
|
||||
public byte[] MeretRS485Address = new byte[7]; /// Modbus addresses of Pr1, Pr2, Pr3, Pr4, Pr5, Pr6, T9 (Izrael) or Pr1, Pr2, Pr3, Pr4, T9, T10 (SLM END)
|
||||
public float[] EtCalib = new float[5] { 1, 1, 1, 1, 1 };
|
||||
#elif SLM_END || WARSAW_END
|
||||
#elif WARSAW_END
|
||||
public uint[,] RegValveCalib = new uint[8,2] {{100,500},{100,500},{100,500},{100,500},{100,500},{100,500},{100,500},{100,500}};
|
||||
public byte[] MeretRS485Address = new byte[4];
|
||||
public float[] EtCalib = new float[5] { 1, 1, 1, 1, 1 };
|
||||
|
||||
26
TBF/BenchControl/Elde/TempMeterMeret/Factory.cs
Normal file
26
TBF/BenchControl/Elde/TempMeterMeret/Factory.cs
Normal file
@ -0,0 +1,26 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System.Collections.Generic;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Elde.TempMeterMeret
|
||||
{
|
||||
public class Factory : IComponentFactory
|
||||
{
|
||||
public string ClassName { get { return "TempMeterMeret"; } }
|
||||
|
||||
public void ResetStaticProperties() { TempMeter.ResetStaticProperties(); }
|
||||
|
||||
public IComponent DummyComponent() { return new TempMeter(); }
|
||||
|
||||
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new TempMeter(cfg, components); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new TempMeterCfg(this); }
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(TempMeterCfg.Serializer, component, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
61
TBF/BenchControl/Elde/TempMeterMeret/ReadTempOp.cs
Normal file
61
TBF/BenchControl/Elde/TempMeterMeret/ReadTempOp.cs
Normal file
@ -0,0 +1,61 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.BenchControl.Elde.TempMeterMeret
|
||||
{
|
||||
public class ReadTempOp : IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(ReadTempOp));
|
||||
public override string ToString() { return string.Format("ReadTempOp({0},.,{1})", tempMeter.Name, eventDone); }
|
||||
|
||||
/// Set by the constructor
|
||||
TempMeter tempMeter;
|
||||
Event eventDone;
|
||||
DoubleBox temp;
|
||||
|
||||
/// <summary>
|
||||
/// Events: TempInDone, TempOutDone, TempDivDone or Error
|
||||
/// </summary>
|
||||
/// <param name="tempMeter">TempMeter reference</param>
|
||||
/// <param name="temp">Reference to the variable, value is in degree Celsius</param>
|
||||
/// <param name="eventDone">Event to be returned by Run() when completed OK</param>
|
||||
public ReadTempOp(TempMeter tempMeter, ref DoubleBox temp, Event eventDone)
|
||||
{
|
||||
if (tempMeter == null) throw new ArgumentNullException("tempMeter");
|
||||
this.tempMeter = tempMeter;
|
||||
this.temp = temp;
|
||||
this.eventDone = eventDone;
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
public ReadTempOp(TempMeter tempMeter, ref DoubleBox temp)
|
||||
: this(tempMeter, ref temp, Event.TempDone)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
temp.Val = tempMeter.ReadTemperature();
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>
|
||||
/// Event.TempInDone, Event.TempOutDone or Event.TempDivDone
|
||||
/// </returns>
|
||||
public Event Run()
|
||||
{
|
||||
temp.Val = tempMeter.ReadTemperature();
|
||||
return eventDone;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
62
TBF/BenchControl/Elde/TempMeterMeret/TempMeter.cs
Normal file
62
TBF/BenchControl/Elde/TempMeterMeret/TempMeter.cs
Normal file
@ -0,0 +1,62 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using log4net;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.BenchControl.Elde.TempMeterMeret
|
||||
{
|
||||
public class TempMeter : ComponentBase, GenericDevices.ITempMeter
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(TempMeter));
|
||||
public override string ToString() { return string.Format("TempMeter({0})", Cfg.ToString(1)); }
|
||||
|
||||
readonly TempMeterCfg tempMtrCfg;
|
||||
|
||||
public readonly ControlBoardDev ControlBoard;
|
||||
|
||||
public TempMeter() {}
|
||||
|
||||
public TempMeter(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
|
||||
: base(cfg)
|
||||
{
|
||||
tempMtrCfg = cfg as TempMeterCfg;
|
||||
|
||||
ControlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
|
||||
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
|
||||
|
||||
/// Prepare data for SendCalibData() control board component method
|
||||
ControlBoard.MeretRS485Address[tempMtrCfg.MeretIdx0] = tempMtrCfg.ModbusAddress;
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
public double ReadTemperature()
|
||||
{
|
||||
return Config.Formulas.CorrectedValue((double)ControlBoard.Temperature(tempMtrCfg.TempIdx0), Corrections);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Events: TempDone, Error
|
||||
/// </summary>
|
||||
/// <param name="temp">Reference to a variable for the temperature in Celsius</param>
|
||||
/// <returns>ReadTempOp instance reference casted to IOperaton</returns>
|
||||
public IOperation ReadTempOp(ref DoubleBox temp)
|
||||
{
|
||||
return new ReadTempOp(this, ref temp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Events: tempDone, Error
|
||||
/// </summary>
|
||||
/// <param name="temp">Reference to a variable for the temperature in Celsius</param>
|
||||
/// <param name="tempDone">Event returned when measurement done</param>
|
||||
/// <returns>ReadTempOp instance reference casted to IOperaton</returns>
|
||||
public IOperation ReadTempOp(ref DoubleBox temp, Event tempDone)
|
||||
{
|
||||
return new ReadTempOp(this, ref temp, tempDone);
|
||||
}
|
||||
}
|
||||
}
|
||||
183
TBF/BenchControl/Elde/TempMeterMeret/TempMeterCfg.cs
Normal file
183
TBF/BenchControl/Elde/TempMeterMeret/TempMeterCfg.cs
Normal file
@ -0,0 +1,183 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using Config.Entities;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Elde.TempMeterMeret
|
||||
{
|
||||
public class TempMeterCfg : ComponentCfgBase, IChildComponentCfg, Config.Entities.IParamsProvider
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TempMeterCfg) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public IComponentCfgCtrl GetControl()
|
||||
{
|
||||
IList<string> parents = new List<string>();
|
||||
parents.Add("CB");
|
||||
// TODO:
|
||||
//if (StateMachine.Components != null)
|
||||
//{
|
||||
// foreach (var cmpnt in StateMachine.Components)
|
||||
// {
|
||||
// if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is TBF.BenchControl.Modbus.Common.Factory)
|
||||
// {
|
||||
// parents.Add(cmpnt.Name);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
return new Configs.ParamsProvider.ComponentCfgCtrl(this, parents);
|
||||
}
|
||||
|
||||
///
|
||||
/// Serialized parameters
|
||||
///
|
||||
public int TempIdx0; /// 0..19
|
||||
public byte ModbusAddress; /// 1..247
|
||||
public int MeretIdx0; /// Meter pressure meters count .. (Meter pressure meters count + Meter temperature meters count - 1)
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
TempMeterCfg()
|
||||
{
|
||||
Name = "T";
|
||||
ParentName = "CB";
|
||||
}
|
||||
|
||||
public TempMeterCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
Factory = factory;
|
||||
Name = "T";
|
||||
ParentName = "CB";
|
||||
InitializeAll();
|
||||
}
|
||||
|
||||
public string ComponentName { get { return Name; } }
|
||||
|
||||
public void InitializeAll()
|
||||
{
|
||||
TempIdx0 = 8;
|
||||
ModbusAddress = 1;
|
||||
MeretIdx0 = 4;
|
||||
}
|
||||
|
||||
|
||||
string[] paramNames = new string[]
|
||||
{
|
||||
"Temp. index (0)",
|
||||
"Modbus address",
|
||||
"Meret index (0)",
|
||||
};
|
||||
public string ParamName(int i) { return paramNames[i]; }
|
||||
public int ParamsCount() { return paramNames.Length; }
|
||||
public IList<string> ParamValues(int i) { return null; }
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
if (i == -1)
|
||||
{
|
||||
return string.Format("Name={0}, Parent={1}, TempIx0={2}, Modbus address={3}, MeretIx0={4}",
|
||||
Name,
|
||||
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
|
||||
TempIdx0, ModbusAddress, MeretIdx0);
|
||||
}
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0: return TempIdx0.ToString();
|
||||
case 1: return ModbusAddress.ToString();
|
||||
case 2: return MeretIdx0.ToString();
|
||||
default: return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public CfgUpdateFlags UpdateParam(int i, string strValue)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
int ival = int.Parse(strValue);
|
||||
if (TempIdx0 != ival)
|
||||
{
|
||||
TempIdx0 = ival;
|
||||
return CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
else return CfgUpdateFlags.None;
|
||||
|
||||
case 1:
|
||||
byte addr = byte.Parse(strValue);
|
||||
if (ModbusAddress != addr)
|
||||
{
|
||||
ModbusAddress = addr;
|
||||
return CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
else return CfgUpdateFlags.None;
|
||||
|
||||
case 2:
|
||||
int ival2 = int.Parse(strValue);
|
||||
if (MeretIdx0 != ival2)
|
||||
{
|
||||
MeretIdx0 = ival2;
|
||||
return CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
else return CfgUpdateFlags.None;
|
||||
|
||||
default:
|
||||
return CfgUpdateFlags.None;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ValidateParam(int i, string strValue, out string message)
|
||||
{
|
||||
message = string.Empty;
|
||||
int dummy;
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
if (int.TryParse(strValue, out dummy) && dummy >= 0 && dummy <= 19) return true;
|
||||
break;
|
||||
case 1:
|
||||
if (int.TryParse(strValue, out dummy) && dummy >= 1 && dummy <= 247) return true;
|
||||
message = ParamName(i) + " is invalid. Address range is 1 .. 247";
|
||||
return false;
|
||||
case 2:
|
||||
if (int.TryParse(strValue, out dummy) && dummy >= 0 && dummy <= 19) return true;
|
||||
break;
|
||||
default:
|
||||
message = "Invalid index";
|
||||
return false;
|
||||
}
|
||||
|
||||
message = ParamName(i) + " is invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
void CopyContentTo(TempMeterCfg prms)
|
||||
{
|
||||
prms.ParentName = this.ParentName;
|
||||
prms.TempIdx0 = this.TempIdx0;
|
||||
prms.ModbusAddress = this.ModbusAddress;
|
||||
prms.MeretIdx0 = this.MeretIdx0;
|
||||
}
|
||||
|
||||
|
||||
public Config.Entities.IParamsProvider Clone()
|
||||
{
|
||||
TempMeterCfg pars = new TempMeterCfg();
|
||||
CopyContentTo(pars);
|
||||
return pars;
|
||||
}
|
||||
|
||||
public void UpdateEmbeddedDbEntity()
|
||||
{
|
||||
/// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -148,7 +148,8 @@ namespace TBF.BenchControl
|
||||
Factories.Add(new Elde.RegulValveTandem.RegulValveTandemFactory());
|
||||
Factories.Add(new Elde.TempMeter.TempMeterFactory());
|
||||
Factories.Add(new Elde.TempMeterInternal.TempMeterFactory());
|
||||
Factories.Add(new Elde.Valve.ValveFactory());
|
||||
Factories.Add(new Elde.TempMeterMeret.Factory()); /// Meret temp. meter connected to control board Modbus
|
||||
Factories.Add(new Elde.Valve.ValveFactory());
|
||||
Factories.Add(new Elde.ValveEx.ValveFactory());
|
||||
Factories.Add(new Various.ErrorFlags.Factory());
|
||||
Factories.Add(new WaterMeters.Munich.WaterMeterFactory()); /// 'WaterMeters.Munich'
|
||||
|
||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.18.1010.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1010.0")]
|
||||
[assembly: AssemblyVersion("2.18.1012.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1012.0")]
|
||||
|
||||
@ -502,6 +502,10 @@
|
||||
<DependentUpon>TempMeterCfgCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Elde\TempMeterInternal\TempMeterFactory.cs" />
|
||||
<Compile Include="BenchControl\Elde\TempMeterMeret\ReadTempOp.cs" />
|
||||
<Compile Include="BenchControl\Elde\TempMeterMeret\TempMeter.cs" />
|
||||
<Compile Include="BenchControl\Elde\TempMeterMeret\TempMeterCfg.cs" />
|
||||
<Compile Include="BenchControl\Elde\TempMeterMeret\Factory.cs" />
|
||||
<Compile Include="BenchControl\Elde\ValveEx\Valve.cs" />
|
||||
<Compile Include="BenchControl\Elde\ValveEx\ValveCfg.cs" />
|
||||
<Compile Include="BenchControl\Elde\ValveEx\ValveCfgCtrl.cs">
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user