193 lines
5.8 KiB
C#
193 lines
5.8 KiB
C#
///
|
|
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Xml.Serialization;
|
|
using Common;
|
|
using Config.Entities;
|
|
using TBF.Resources;
|
|
using TBF.BenchControl.Generic;
|
|
|
|
namespace TBF.BenchControl.DataEntry.iPerl
|
|
{
|
|
public enum Direction
|
|
{
|
|
#if LANG_SK
|
|
[Description("iPERL normálne (R-L)")] Forward_RL,
|
|
[Description("iPERL opačne (L-R)")] Reversed_LR,
|
|
[Description("640")] S640,
|
|
#elif LANG_DE
|
|
[Description("iPERL Forward (R-L)")] Forward_RL,
|
|
[Description("iPERL Reversed (L-R)")] Reversed_LR,
|
|
[Description("640")] S640,
|
|
#else
|
|
[Description("iPERL Forward (R-L)")] Forward_RL,
|
|
[Description("iPERL Reversed (L-R)")] Reversed_LR,
|
|
[Description("640")] S640,
|
|
#endif
|
|
Count,
|
|
}
|
|
|
|
public enum Orders
|
|
{
|
|
#if LANG_SK
|
|
[Description("Ľubovolné")] Arbitrary,
|
|
[Description("Aktívne z Oracle")] FromOracle,
|
|
[Description("Združené a aktívne z Oracle")] CombinedAndFromOracle,
|
|
#elif LANG_DE
|
|
[Description("Arbitrary")] Arbitrary,
|
|
[Description("Active from Oracle")] FromOracle,
|
|
[Description("Combined and active from Oracle")] CombinedAndFromOracle,
|
|
#else
|
|
[Description("Arbitrary")] Arbitrary,
|
|
[Description("Active from Oracle")] FromOracle,
|
|
[Description("Combined and active from Oracle")] CombinedAndFromOracle,
|
|
#endif
|
|
Count,
|
|
}
|
|
|
|
public class EntryFormCfg : ComponentCfgBase, IComponentCfg, IParamsProvider
|
|
{
|
|
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(EntryFormCfg) })[0];
|
|
public override XmlSerializer GetSerializer() { return Serializer; }
|
|
|
|
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities)
|
|
{
|
|
return new Configs.ParamsProvider.ComponentCfgCtrl(this, null);
|
|
}
|
|
|
|
///
|
|
/// Serialized parameters
|
|
///
|
|
public Direction Direction;
|
|
public Orders Orders;
|
|
|
|
/// Private parameterless constructor invoked by all other (public) constructors
|
|
EntryFormCfg() { }
|
|
|
|
public EntryFormCfg(string name, IComponentFactory factory)
|
|
: this()
|
|
{
|
|
Name = name;
|
|
Factory = factory;
|
|
ParentName = string.Empty;
|
|
InitializeAll();
|
|
}
|
|
|
|
public string ComponentName { get { return Name; } }
|
|
|
|
public void InitializeAll()
|
|
{
|
|
Direction = Direction.Forward_RL;
|
|
Orders = Orders.Arbitrary;
|
|
}
|
|
|
|
string[] paramNames = new string[]
|
|
{
|
|
Strings.Direction,
|
|
Strings.Orders,
|
|
};
|
|
public string ParamName(int i) { return paramNames[i]; }
|
|
public int ParamsCount() { return paramNames.Length; }
|
|
|
|
public ICollection<string> ParamValues(int i)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
return new string[]
|
|
{
|
|
Direction.Forward_RL.ToDescription(),
|
|
Direction.Reversed_LR.ToDescription(),
|
|
Direction.S640.ToDescription(),
|
|
};
|
|
case 1:
|
|
return new string[]
|
|
{
|
|
Orders.Arbitrary.ToDescription(),
|
|
Orders.FromOracle.ToDescription(),
|
|
Orders.CombinedAndFromOracle.ToDescription(),
|
|
};
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
public string ToString(int i)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0: return Direction.ToDescription();
|
|
case 1: return Orders.ToDescription();
|
|
default:
|
|
return string.Format("Name={0}, Direction={1}, Orders={2}", Name, Direction, Orders);
|
|
}
|
|
}
|
|
|
|
public CfgUpdateFlags UpdateParam(int i, string str)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
for (Direction d = 0; d < Direction.Count; d++)
|
|
if (d.ToDescription() == str)
|
|
{
|
|
Direction = d;
|
|
return CfgUpdateFlags.RestartRqrd;
|
|
}
|
|
break;
|
|
|
|
case 1:
|
|
for (Orders o = 0; o < Orders.Count; o++)
|
|
if (o.ToDescription() == str)
|
|
{
|
|
Orders = o;
|
|
return CfgUpdateFlags.RestartRqrd;
|
|
}
|
|
break;
|
|
}
|
|
|
|
return CfgUpdateFlags.None;
|
|
}
|
|
|
|
public bool ValidateParam(int i, string str, out string message)
|
|
{
|
|
message = string.Empty;
|
|
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
case 1:
|
|
if (ParamValues(i).Contains(str)) return true;
|
|
break;
|
|
default:
|
|
message = "Invalid index";
|
|
return false;
|
|
}
|
|
|
|
message = ParamName(i) + " is invalid";
|
|
return false;
|
|
}
|
|
|
|
void CopyContentTo(EntryFormCfg prms)
|
|
{
|
|
prms.Direction = this.Direction;
|
|
prms.Orders = this.Orders;
|
|
}
|
|
|
|
public IParamsProvider Clone()
|
|
{
|
|
EntryFormCfg pars = new EntryFormCfg();
|
|
CopyContentTo(pars);
|
|
return pars;
|
|
}
|
|
|
|
public bool UpdateEmbeddedDbEntity()
|
|
{
|
|
return true; /// =OK, do nothing
|
|
}
|
|
}
|
|
}
|