Schematic drawing with live function, bench control by mouse, Dijkstra algo, vacuum, etc.

This commit is contained in:
Milan Hanajik
2020-06-14 13:01:53 +02:00
parent 2945049288
commit 1f67899a5c
223 changed files with 5684 additions and 3772 deletions
+6 -6
View File
@@ -12,7 +12,7 @@ using TBF.Resources;
namespace TBF.BenchControl.Elde.Diverter
{
public class Diverter : ComponentBase, IDevice, GenericDevices.IDiverter, GenericDevices.ISequenceCondition, GenericDevices.IHasCalendarEvents, SchematicDrawing.IDrawingItemCmpnt
public class Diverter : ComponentBase, IDevice, GenericDevices.IDiverter, GenericDevices.ISequenceCondition, GenericDevices.IHasCalendarEvents, SchematicDrawing.IDrawingItCmpnt
{
private static readonly ILog log = LogManager.GetLogger(typeof(Diverter));
public override string ToString() { return string.Format("Diverter({0})", Cfg.ToString(1)); }
@@ -33,7 +33,7 @@ namespace TBF.BenchControl.Elde.Diverter
public int DiverterNr { get { return diverterNr0 + 1; } } /// 1-based public diverter number
readonly DiverterCfg diverterCfg;
public SchematicDrawing.IDrawingItemCfg DrawingItemCfg { get { return diverterCfg as SchematicDrawing.IDrawingItemCfg; } }
public SchematicDrawing.IDrawingItem DrawingItem { get { return diverterCfg as SchematicDrawing.IDrawingItem; } }
readonly ControlBoardDev controlBoard;
readonly UInt128 mask; /// derived from bitPosition in the constructor
@@ -75,8 +75,8 @@ namespace TBF.BenchControl.Elde.Diverter
controlBoard = TbfComponents.FindComponent(cfg.ParentName, components) as ControlBoardDev;
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
if (diverterCfg.BitPosition < 0 || diverterCfg.BitPosition >= 64) throw new ArgumentOutOfRangeException("position");
this.mask = (((UInt128)1) << diverterCfg.BitPosition);
if (diverterCfg.BitNr < 0 || diverterCfg.BitNr >= 64) throw new ArgumentOutOfRangeException("position");
this.mask = (((UInt128)1) << diverterCfg.BitNr);
switchTimeStart = new FloatBox(diverterCfg.DfltSwithTimeStartMs / 1000.0f);
switchTimeEnd = new FloatBox(diverterCfg.DfltSwithTimeEndMs / 1000.0f);
@@ -193,7 +193,7 @@ namespace TBF.BenchControl.Elde.Diverter
public void RunDeviceBefore()
{
int adcValue = (int)controlBoard.AnalogInputRaw(diverterCfg.AdcNr, 0);
Handlers.OnAdcChanged(this, new CmdResponseArgs(CfgChangeCmd.GetAdc, diverterCfg.BitPosition, adcValue));
Handlers.OnAdcChanged(this, new CmdResponseArgs(CfgChangeCmd.GetAdc, diverterCfg.BitNr, adcValue));
}
public void RunDeviceAfter() { }
public void StopDevice() { }
@@ -243,7 +243,7 @@ namespace TBF.BenchControl.Elde.Diverter
else if (args.Command == CfgChangeCmd.GetAdc1 || args.Command == CfgChangeCmd.GetAdc2)
{
int adcValue = (int)controlBoard.AnalogInputRaw(diverterCfg.AdcNr, 0);
DiverterCfgCtrl.OnCmdResponse(this, new CmdResponseArgs(args.Command, diverterCfg.BitPosition, adcValue));
DiverterCfgCtrl.OnCmdResponse(this, new CmdResponseArgs(args.Command, diverterCfg.BitNr, adcValue));
}
else if (args.Command == CfgChangeCmd.DivToTank)
{
+31 -26
View File
@@ -5,11 +5,12 @@ using System;
using System.IO;
using System.Collections.Generic;
using System.Xml.Serialization;
using SchematicDrawing;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Elde.Diverter
{
public class DiverterCfg : ComponentCfgBase, IChildComponentCfg, GenericDevices.ICalibInfoCfg, SchematicDrawing.IDrawingItemCfg
public class DiverterCfg : ComponentCfgBase, IChildComponentCfg, GenericDevices.ICalibInfoCfg, IRouteBasedDrawingItem
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(DiverterCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
@@ -19,8 +20,9 @@ namespace TBF.BenchControl.Elde.Diverter
///
/// Serialized parameters
///
public int BitPosition; /// 0..63
public int AdcNr; /// 0..15(?), number of the analog input
public int BitNr { get; set; } /// 0..127
public bool Inverted { get; set; } /// When true the diverter function is inverted: 0 = to the tank, 1 = off
public int AdcNr; /// 0..15(?), number of the analog input
public int AdcValueToSink; /// 0..1023
public int AdcValueToTank; /// 0..1023
public int StartingLevel; /// 0..100 in %, threshold for the ADC value to start the test
@@ -35,52 +37,55 @@ namespace TBF.BenchControl.Elde.Diverter
public DateTime CalibValidDate { get; set; }
/// Schematic drawing info
public SchematicDrawing.Shape Shape { get; set; }
public Shape Shape { get; set; }
public int X { get; set; }
public int Y { get; set; }
public SchematicDrawing.Sz Sz { get; set; }
public SchematicDrawing.Orient Orient { get; set; }
public Sz Sz { get; set; }
public Orient Orient { get; set; }
public bool Flip { get; set; }
public int LblX { get; set; }
public int LblY { get; set; }
public SchematicDrawing.Orient LblOrient { get; set; }
public int ValX { get; set; }
public int ValY { get; set; }
public double ValFact { get; set; }
public string ValFmt { get; set; }
public SchematicDrawing.Orient ValOrient { get; set; }
public Orient LblOrient { get; set; }
[XmlIgnore]
public IList<GNode> GNodes { get; set; }
[XmlIgnore]
public IList<GEdge> EdgesToSet { get; set; }
/// Private parameterless constructor invoked by all other (public) constructors
DiverterCfg()
{
Name = "Div";
Shape = SchematicDrawing.Shape.Div;
ParentName = "CB";
BitPosition = 0;
AdcNr = 5; /// Div1: AdcNr=5 , Div2: AdcNr=6
AdcValueToSink = 100;
AdcValueToTank = 500;
StartingLevel = 50;
ThresholdLo = 10;
ThresholdHi = 90;
CalibCertificateNr = string.Empty;
GNodes = new List<GNode>();
EdgesToSet = new List<GEdge>();
}
public DiverterCfg(IComponentFactory factory)
: this()
{
this.Factory = factory;
Shape = Shape.Div;
Sz = Sz.M;
Factory = factory;
Name = "Div";
ParentName = "CB";
BitNr = 0;
AdcNr = 5; /// Div1: AdcNr=5 , Div2: AdcNr=6
AdcValueToSink = 100;
AdcValueToTank = 500;
StartingLevel = 50;
ThresholdLo = 10;
ThresholdHi = 90;
CalibCertificateNr = string.Empty;
}
public bool IsHidden() { return (X == 0) && (Y == 0); }
public string ToString(int i)
{
return string.Format("Name={0}, Parent={1}, Bit={2}, ADC#={3}, ADC2Sink={4}, ADC2Tank={5}, Gate={6}%, Lo={7}%, Lo={8}%",
Name,
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
BitPosition,
BitNr,
AdcNr,
AdcValueToSink,
AdcValueToTank,
@@ -6,6 +6,7 @@ using System.Windows.Forms;
using log4net;
using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.UI.Bench.Components;
namespace TBF.BenchControl.Elde.Diverter
{
@@ -38,9 +39,9 @@ namespace TBF.BenchControl.Elde.Diverter
parent = ParentForm as ComponentParametersDlg;
if (parent == null) return;
if (parent.TbfComponents != null)
if (parent.CmpntEntities != null)
{
foreach (var cmpnt in parent.TbfComponents)
foreach (var cmpnt in parent.CmpntEntities)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.ControlBoardFactory)
{
@@ -73,7 +74,7 @@ namespace TBF.BenchControl.Elde.Diverter
classNameLabel.Text = config.Factory.ClassName;
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
nameTextBox.Text = config.Name;
bitPositionTextBox.Text = config.BitPosition.ToString();
bitPositionTextBox.Text = config.BitNr.ToString();
adcNrTextBox.Text = config.AdcNr.ToString();
adcToSinkTextBox.Text = config.AdcValueToSink.ToString();
adcToTankTextBox.Text = config.AdcValueToTank.ToString();
@@ -198,9 +199,9 @@ namespace TBF.BenchControl.Elde.Diverter
}
int tmp = int.Parse(bitPositionTextBox.Text);
if (config.BitPosition != tmp)
if (config.BitNr != tmp)
{
config.BitPosition = tmp;
config.BitNr = tmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
@@ -367,7 +368,7 @@ namespace TBF.BenchControl.Elde.Diverter
void OnAdcChanged(object sender, CmdResponseArgs data)
{
if (data.Command == CfgChangeCmd.GetAdc && data.Id == config.BitPosition)
if (data.Command == CfgChangeCmd.GetAdc && data.Id == config.BitNr)
{
adcTextBox.Text = data.Response.ToString();
}