2018-10-03 10:34:59 +00:00
|
|
|
|
///
|
2021-08-18 06:52:34 +00:00
|
|
|
|
/// Copyright (c) 2018-2021 Sensus Slovensko a.s.
|
2018-10-03 10:34:59 +00:00
|
|
|
|
///
|
|
|
|
|
|
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
|
|
|
|
|
|
{
|
2020-05-06 07:45:23 +00:00
|
|
|
|
public class TempMeterCfg : ComponentCfgBase, IChildComponentCfg, Config.Entities.IParamsProvider, TBF.BenchControl.GenericDevices.ICalibInfoCfg
|
2018-10-03 10:34:59 +00:00
|
|
|
|
{
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
2020-05-06 07:45:23 +00:00
|
|
|
|
/// Calibration info serialized parameters displayed in Metrology tab page
|
2021-08-18 06:52:34 +00:00
|
|
|
|
public string CalibCertificateNr { get; set; }
|
|
|
|
|
|
public DateTime CalibDate { get; set; }
|
|
|
|
|
|
public DateTime CalibValidDate { get; set; }
|
2020-05-06 07:45:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
2018-10-03 10:34:59 +00:00
|
|
|
|
/// Private parameterless constructor invoked by all other (public) constructors
|
2021-08-18 06:52:34 +00:00
|
|
|
|
TempMeterCfg() { }
|
2018-10-03 10:34:59 +00:00
|
|
|
|
|
|
|
|
|
|
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;
|
2021-08-18 06:52:34 +00:00
|
|
|
|
|
|
|
|
|
|
CalibCertificateNr = string.Empty;
|
|
|
|
|
|
CalibDate = TBF.UI.Constants.MinDate;
|
|
|
|
|
|
CalibValidDate = TBF.UI.Constants.MaxDate;
|
2018-10-03 10:34:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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; }
|
2021-07-28 11:31:18 +00:00
|
|
|
|
public ICollection<string> ParamValues(int i) { return null; }
|
2018-10-03 10:34:59 +00:00
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-12-14 09:53:24 +00:00
|
|
|
|
public bool UpdateEmbeddedDbEntity()
|
2018-10-03 10:34:59 +00:00
|
|
|
|
{
|
2018-12-14 09:53:24 +00:00
|
|
|
|
return true; /// =OK, do nothing
|
2018-10-03 10:34:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|