From bfa69ef611b0aca51cf362a9efccf3466e6415f2 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Thu, 28 Oct 2021 13:54:27 +0200 Subject: [PATCH] Inputs mapped to route bits 80..119, UniCB to bit 120, Emergency stop from bit 96* (not from State), ver. 3.1.1788 --- TBF/Properties/AssemblyInfo.cs | 4 ++-- TBF/Rig/ControlBoard/Uni/UniCB.cs | 21 +++++++++++++------ TBF/Rig/ControlBoard/Uni/UniCBCfg.cs | 2 +- .../Various/EmergencyStop/Configuration.cs | 4 ++-- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index aa2003a58..f8303a063 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("3.1.1785.0")] -[assembly: AssemblyFileVersion("3.1.1785.0")] +[assembly: AssemblyVersion("3.1.1788.0")] +[assembly: AssemblyFileVersion("3.1.1788.0")] diff --git a/TBF/Rig/ControlBoard/Uni/UniCB.cs b/TBF/Rig/ControlBoard/Uni/UniCB.cs index 50efed19f..029017cae 100644 --- a/TBF/Rig/ControlBoard/Uni/UniCB.cs +++ b/TBF/Rig/ControlBoard/Uni/UniCB.cs @@ -104,6 +104,7 @@ namespace TBF.Rig.ControlBoard.Uni UInt128 routeMask; /// Set in the constructor, bits of outputs that can be controlled by Action.ChangeRoute are set. /// Regulation valve control outputs and diverters cannot be controlled by Action.ChangeRoute /// Depends on the control board configuration + UInt128 invInputsMask; /// Typically 0xff000000 0000ffff ffffffff ffffffff, inputs are mapped to route bits 80..119 ulong valvesToInvert; /// From configurations of valve and pump components. Inversion is applied when creating /// a message to be sent by serial port UInt128 displayedRoutePlusUI; /// A route displayed on the screen plus the modifications from UI (inversions are not applied) @@ -208,6 +209,10 @@ namespace TBF.Rig.ControlBoard.Uni if (cbCfg.RelaysGInstalled) routeMask |= 0xFF000000000000; if (cbCfg.RelaysHInstalled) routeMask |= 0xFF00000000000000; + invInputsMask = (UInt128)0xffffffffffffffffL; + invInputsMask |= (((UInt128)0xffff) << 64); + invInputsMask |= (((UInt128)0xff) << 120); + lastRcvdStMTime = StateMachine.Time; /// To indicate the serial connection state lastSentTime = DateTime.Now; lastReceivedTime = DateTime.Now; @@ -431,21 +436,25 @@ namespace TBF.Rig.ControlBoard.Uni } } + /// + /// Map Inputs bits 0..39 to Route bits 80..119 + /// + route = (route & invInputsMask) | ((UInt128)Data.Vstupy) << 80; + + /// + /// Map UniCB indication to Route bit BitNr (default 120) + /// if (cbCfg.DebugLevel == DebugMode.Normal && (StateMachine.Time - lastRcvdStMTime) >= 5) { /// No connection to control board ... set indicator bit route |= ((UInt128)1) << cbCfg.BitNr; } + /// /// Handle emergency stop signal /// - bool emergencyStop = ((State & (UInt64)StatusP.EmgcyStopActive) != 0); - /// - if (emergencyStop) - route |= (((UInt128)1) << (cbCfg.BitNr + 1)); - else - route &= ~(((UInt128)1) << (cbCfg.BitNr + 1)); + bool emergencyStop = ((Data.Vstupy & 0x10000) == 0); /// if (emergencyStop && !isEmergencyStop) { diff --git a/TBF/Rig/ControlBoard/Uni/UniCBCfg.cs b/TBF/Rig/ControlBoard/Uni/UniCBCfg.cs index 74440e6e8..33f8f8131 100644 --- a/TBF/Rig/ControlBoard/Uni/UniCBCfg.cs +++ b/TBF/Rig/ControlBoard/Uni/UniCBCfg.cs @@ -53,7 +53,7 @@ namespace TBF.Rig.ControlBoard.Uni public double MsrdValLimHi { get; set; } [XmlIgnore] - public int BitNr { get { return 80; } } /// Bit-position + public int BitNr { get { return 120; } } /// Bit-position [XmlIgnore] public bool Inverted { get { return false; } } /// When true the valve function is inverted: 0 = open, 1 = closed [XmlIgnore] diff --git a/TBF/Rig/Various/EmergencyStop/Configuration.cs b/TBF/Rig/Various/EmergencyStop/Configuration.cs index 56f196115..ed807c092 100644 --- a/TBF/Rig/Various/EmergencyStop/Configuration.cs +++ b/TBF/Rig/Various/EmergencyStop/Configuration.cs @@ -34,9 +34,9 @@ namespace TBF.Rig.Various.EmergencyStop public Orient LblOrient { get; set; } [XmlIgnore] - public int BitNr { get { return 81; } } /// Bit-position + public int BitNr { get { return 96; } } /// Bit-position [XmlIgnore] - public bool Inverted { get { return false; } } /// When true the valve function is inverted: 0 = open, 1 = closed + public bool Inverted { get { return true; } } /// When true the valve function is inverted: 0 = open, 1 = closed [XmlIgnore] public IList GNodes { get; set; } [XmlIgnore]