UniCB : Indication of serial connection, ver. 3.1.1598
This commit is contained in:
@@ -81,6 +81,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
byte[] rcvdData; /// Buffer for all recevied but nut processed data. May contain data from several read attempts
|
||||
int[] cumulativeSums;
|
||||
int rcvdBytesCount; /// Count of valid bytes in rcvdData buffer
|
||||
int lastReceivedTime; /// StateMachine.Time time stamp of the last received valid frame
|
||||
|
||||
///
|
||||
/// Route / digital outputs / states of electromagnetic valves
|
||||
@@ -93,7 +94,20 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
/// Action.ChangeRoute an dafter obtaining RRoute from the control board
|
||||
|
||||
/// State of digital outputs obtained from the control board
|
||||
public UInt128 RRoute { get { return (UInt128)Data.Vystupy ^ valvesToInvert; } }
|
||||
public UInt128 RRoute
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((StateMachine.Time - lastReceivedTime) < 5)
|
||||
{
|
||||
return (UInt128)(Data.Vystupy ^ valvesToInvert);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((UInt128)1) << cbCfg.BitNr; /// No connection to control board
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UInt128 displayedRoute; /// A route displayed on the screen (inversions are not applied)
|
||||
UInt128 bitsChangedByUI; /// Ones in this word indicate which valves/pumpes were changed in UI by mouse clicks
|
||||
@@ -257,7 +271,11 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
/// </summary>
|
||||
public void RunDeviceBefore()
|
||||
{
|
||||
if (cbCfg.DebugLevel != DebugMode.Normal || serialPort == null || !serialPort.IsOpen) return;
|
||||
if (cbCfg.DebugLevel != DebugMode.Normal || serialPort == null || !serialPort.IsOpen)
|
||||
{
|
||||
benchModelRoute |= ((UInt128)1) << cbCfg.BitNr;
|
||||
return;
|
||||
}
|
||||
|
||||
/// Read new received bytes and append them to a buffer
|
||||
int bytesCount = serialPort.BytesToRead;
|
||||
@@ -284,52 +302,51 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
do
|
||||
{
|
||||
bool anyProcessed = false;
|
||||
string msg = string.Empty;
|
||||
if (ScopeAnalyzerData.FrameFitsData(rcvdData, cumulativeSums, rcvdBytesCount, offset))
|
||||
{
|
||||
/// Scope analyzer data received
|
||||
scopeAnalyzerData = ScopeAnalyzerData.GetData(rcvdData, offset);
|
||||
string s = Telegram.LogTelegram("Scope analyzer data ", rcvdData, offset, ScopeAnalyzerData.MessageLen);
|
||||
Debug.WriteLine(s);
|
||||
log.Debug(s);
|
||||
msg = Telegram.LogTelegram("Scope analyzer data ", rcvdData, offset, ScopeAnalyzerData.MessageLen);
|
||||
offset += ScopeAnalyzerData.MessageLen;
|
||||
lastValidOffset = offset;
|
||||
anyProcessed = true;
|
||||
}
|
||||
else if (GeneralData.FrameFitsData(rcvdData, cumulativeSums, rcvdBytesCount, offset))
|
||||
{
|
||||
/// Regular data received
|
||||
Data.UpdateData(rcvdData, offset);
|
||||
string s = Telegram.LogTelegram("General data ", rcvdData, offset, GeneralData.MessageLen);
|
||||
Debug.WriteLine(s);
|
||||
log.Debug(s);
|
||||
msg = Telegram.LogTelegram("General data ", rcvdData, offset, GeneralData.MessageLen);
|
||||
offset += GeneralData.MessageLen;
|
||||
lastValidOffset = offset;
|
||||
anyProcessed = true;
|
||||
}
|
||||
else if (SwitchCountersData.FrameFitsData(rcvdData, cumulativeSums, rcvdBytesCount, offset))
|
||||
{
|
||||
/// Switch counter data received
|
||||
switchCounterData = SwitchCountersData.GetData(rcvdData, offset);
|
||||
string s = Telegram.LogTelegram("Switch counter data ", rcvdData, offset, SwitchCountersData.MessageLen);
|
||||
Debug.WriteLine(s);
|
||||
log.Debug(s);
|
||||
msg = Telegram.LogTelegram("Switch counter data ", rcvdData, offset, SwitchCountersData.MessageLen);
|
||||
offset += SwitchCountersData.MessageLen;
|
||||
lastValidOffset = offset;
|
||||
anyProcessed = true;
|
||||
}
|
||||
else if (DivTransitionData.FrameFitsData(rcvdData, cumulativeSums, rcvdBytesCount, offset))
|
||||
{
|
||||
/// Diverter transition data received
|
||||
divTransitionData = DivTransitionData.GetData(rcvdData, offset);
|
||||
string s = Telegram.LogTelegram("Diverter transition data ", rcvdData, offset, DivTransitionData.MessageLen);
|
||||
Debug.WriteLine(s);
|
||||
log.Debug(s);
|
||||
msg = Telegram.LogTelegram("Diverter transition data ", rcvdData, offset, DivTransitionData.MessageLen);
|
||||
offset += DivTransitionData.MessageLen;
|
||||
lastValidOffset = offset;
|
||||
anyProcessed = true;
|
||||
}
|
||||
|
||||
if (!anyProcessed) offset++;
|
||||
if (anyProcessed)
|
||||
{
|
||||
lastValidOffset = offset;
|
||||
lastReceivedTime = StateMachine.Time;
|
||||
Debug.WriteLine(msg);
|
||||
log.Debug(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
while (offset < rcvdBytesCount);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
/// <summary>
|
||||
/// Holds backup and security options - serializable configuration.
|
||||
/// </summary>
|
||||
public class UniCBCfg : ComponentCfgBase, Generic.IComponentCfg, Config.Entities.IParamsProvider, IDrawingItemWithMeasuredVal
|
||||
public class UniCBCfg : ComponentCfgBase, Generic.IComponentCfg, Config.Entities.IParamsProvider, IDrawingItemWithMeasuredVal, IRouteBasedDrawingItem
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(UniCBCfg) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
@@ -50,6 +50,9 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
public double MsrdValLimLo { get; set; }
|
||||
public double MsrdValLimHi { get; set; }
|
||||
|
||||
public int BitNr { get { return 64; } } /// Bit-position
|
||||
public bool Inverted { get { return false; } } /// When true the valve function is inverted: 0 = open, 1 = closed
|
||||
|
||||
[XmlIgnore]
|
||||
public IList<GNode> GNodes { get; set; }
|
||||
[XmlIgnore]
|
||||
|
||||
Reference in New Issue
Block a user