Uni.RegValveAnalog : Initial implementation for UNI, ver. 3.5.2015
This commit is contained in:
@@ -52,6 +52,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
public int PID { get; set; } /// SetFlow
|
||||
public int TolerRV { get; set; } /// SetFlow
|
||||
public int StabTime { get; set; } /// SetFlow
|
||||
public int InitDacVal { get; set; } /// SetFlow
|
||||
public int DivThreshold { get; set; } /// StartTest argument
|
||||
|
||||
|
||||
@@ -74,6 +75,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
MassPulsesCount = 0;
|
||||
RVMovePar1 = 0;
|
||||
RVMovePar2 = 0;
|
||||
InitDacVal = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -173,8 +175,11 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
RVMovePar1 = rvMovePar1,
|
||||
RVMovePar2 = rvMovePar2,
|
||||
PID = pid,
|
||||
TolerRV = 0,
|
||||
TolerRV = (regValveId == TBF.Rig.Uni.RegValveAnalog.RegValve.RVAnalogIdx)
|
||||
? Convert.ToInt32(Math.Round(13.1072 * 0.015 * freqLo)) : 0,
|
||||
StabTime = stabTime,
|
||||
InitDacVal = (regValveId == TBF.Rig.Uni.RegValveAnalog.RegValve.RVAnalogIdx)
|
||||
? Convert.ToInt32(Math.Round(13.1072 * freqLo)) : 0,
|
||||
};
|
||||
}
|
||||
void SetSetFlowArgs(Action action)
|
||||
@@ -186,6 +191,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
PID = action.PID;
|
||||
TolerRV = action.TolerRV;
|
||||
StabTime = action.StabTime;
|
||||
InitDacVal = action.InitDacVal;
|
||||
}
|
||||
/// Check whether new action arguments are compatible with alredy collected arguments (true = yes)
|
||||
bool CheckSharedSetFlowArgs(Action newAction)
|
||||
@@ -570,7 +576,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
}
|
||||
}
|
||||
|
||||
log.InfoFormat("Combined action: {0} Rt={1} Et={2} RV={3} Div#={4} Cmd={5} Sync={6} wDiv={7} S/S={8} Prolng={9} ToTank={10} Puls={11} MPls={12} RVMode={13} P1={14} P2={15} pid={16}",
|
||||
log.InfoFormat("Combined action: {0} Rt={1} Et={2} RV={3} Div#={4} Cmd={5} Sync={6} wDiv={7} S/S={8} Prolng={9} ToTank={10} Puls={11} MPls={12} RVMode={13} P1={14} P2={15} Ao1={19}",
|
||||
((int)combinedAction.ActionId).ToString("X3"),
|
||||
combinedAction.Route.ToString("X32"),
|
||||
combinedAction.FlowMId,
|
||||
@@ -590,6 +596,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
combinedAction.PID,
|
||||
combinedAction.TolerRV,
|
||||
combinedAction.StabTime,
|
||||
combinedAction.InitDacVal,
|
||||
combinedAction.DivThreshold);
|
||||
|
||||
return combinedAction;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
readonly bool readDivTransition;
|
||||
readonly Statistics divStartPlotter;
|
||||
readonly Statistics divStopPlotter;
|
||||
readonly TBF.Rig.Uni.RegValve.RegValve regV;
|
||||
readonly GenericDevices.IRegValve regV;
|
||||
readonly TBF.Rig.GenericDevices.IFlowMeter flowMeter;
|
||||
readonly TBF.Rig.Uni.Diverter.Diverter diverter;
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
flowMeter = devices.FlowMeter;
|
||||
if (flowMeter == null) throw new ArgumentNullException("Invalid flow meter");
|
||||
|
||||
regV = devices.RegValve as TBF.Rig.Uni.RegValve.RegValve;
|
||||
regV = devices.RegValve as GenericDevices.IRegValve;
|
||||
if (regV == null) throw new ArgumentNullException("Invalid regulation valve");
|
||||
|
||||
diverter = (withDiverter && devices.Diverter is TBF.Rig.Uni.Diverter.Diverter)
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
public ulong State; /// bytes 5,6,7,8,9,80,81 = 7 bytes = 56 bits
|
||||
public uint Chyby485;
|
||||
public ulong Vystupy;
|
||||
public uint[] StavDA = new uint[2];
|
||||
public int[] StavDA = new int[2];
|
||||
public double[] ReferenceFreq = new double[4];
|
||||
public int[] EtPulses = new int[Const.WMsCount + 1]; /// EtPulses[0]=total pulses, EtPulses[1..WMsCount] gated et.pulses for respective WM
|
||||
public int EtPulsesK;
|
||||
@@ -93,7 +93,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
((ulong)data[offs + (int)Poz.Stat6] << 48);
|
||||
|
||||
Vystupy = GetUInt64(data, offs + (int)Poz.Vyst); /// Byte 10 .. 17
|
||||
StavDA[1] = GetUInt16(data, offs + (int)Poz.SDA2); /// Byte 18,19
|
||||
StavDA[1] = Convert.ToInt32(GetUInt16(data, offs + (int)Poz.SDA2)); /// Byte 18,19
|
||||
Vstupy = GetUInt40(data, offs + (int)Poz.Vst); /// Byte 20,21,22,23,24
|
||||
|
||||
/// A/D converters: Feedback from RV-s and diverters
|
||||
@@ -151,7 +151,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
}
|
||||
RestartReadingOfWMPulses = false;
|
||||
|
||||
StavDA[0] = GetUInt16(data, offs + (int)Poz.SDA); /// Byte 255,256
|
||||
StavDA[0] = Convert.ToInt32(GetUInt16(data, offs + (int)Poz.SDA)); /// Byte 255,256
|
||||
byte spare3 = data[offs + (int)Poz.spare3]; /// Byte 257
|
||||
|
||||
/// Impulzy perioda (???)
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(OutputMessage));
|
||||
|
||||
public const int PayloadLen = 38;
|
||||
public const byte MessageCode = (byte)' ';
|
||||
|
||||
|
||||
static Action arguments = new Action();
|
||||
@@ -43,7 +42,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
message[0] = Const.STX;
|
||||
message[1] = 1; /// Control board addres
|
||||
message[2] = (byte)PayloadLen; /// Payload length
|
||||
message[3] = MessageCode;
|
||||
message[3] = (byte)' '; /// Message code
|
||||
|
||||
/// Command
|
||||
message[4] = GetCommand(action);
|
||||
@@ -82,7 +81,8 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
message[26] = 0;
|
||||
|
||||
/// Regulation valve
|
||||
message[27] = (action.RegVId < 0) ? (byte)0 : (byte)(action.RegVId | (int)action.RegVMode);
|
||||
message[27] = (action.RegVId < 0 || (action.RegVId == TBF.Rig.Uni.RegValveAnalog.RegValve.RVAnalogIdx && action.RegVMode == RegValveMode.TargetFrequency))
|
||||
? (byte)0 : (byte)(action.RegVId | (int)action.RegVMode);
|
||||
message[28] = (byte)(action.RVMovePar1 & 0xFF);
|
||||
message[29] = (byte)((action.RVMovePar1 >> 8) & 0xFF);
|
||||
message[30] = (byte)(action.RVMovePar2 & 0xFF);
|
||||
@@ -90,12 +90,12 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
message[32] = GetRVStopParam(action);
|
||||
|
||||
/// DA1
|
||||
message[33] = 0; /// PrudParL
|
||||
message[34] = 0; /// PrudParH
|
||||
message[33] = (byte)(arguments.InitDacVal & 0xFF);
|
||||
message[34] = (byte)((arguments.InitDacVal >> 8) & 0xFF);
|
||||
|
||||
message[35] = (byte)Math.Max(1, Math.Min(255, arguments.PID)); /// PIDRV
|
||||
message[36] = 0; // (byte)Math.Max(4, Math.Min(255, action.TolerRV)); /// TolerRV (4..20 mA reg.valve only)
|
||||
message[37] = (byte)Math.Max(0, Math.Min(255, arguments.StabTime)); /// StabRV
|
||||
message[35] = (byte)Math.Max(1, Math.Min(255, arguments.PID)); /// PIDRV
|
||||
message[36] = (byte)Math.Max(4, Math.Min(255, action.TolerRV)); /// TolerRV (4..20 mA reg.valve only)
|
||||
message[37] = (byte)Math.Max(0, Math.Min(255, arguments.StabTime)); /// StabRV
|
||||
message[38] = (byte)((arguments.DivThreshold >> 2) & 0xFF);
|
||||
|
||||
message[39] = 0;
|
||||
@@ -144,11 +144,19 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
return (byte)StopDevs.All;
|
||||
}
|
||||
|
||||
static byte GetRVStopParam(Action action)
|
||||
static byte GetRVStopParam(Action a)
|
||||
{
|
||||
if (action.IsStop()) return (byte)0x20;
|
||||
if ((action.ActionId & ActionID.RegVlvStop) != 0) return (byte)0x20;
|
||||
return (byte)0;
|
||||
if (a.IsStop() || (a.ActionId & ActionID.RegVlvStop) != 0)
|
||||
{
|
||||
return (byte)0x20;
|
||||
}
|
||||
|
||||
if ((a.ActionId & ActionID.SetFlow) != 0 && a.RegVId == TBF.Rig.Uni.RegValveAnalog.RegValve.RVAnalogIdx)
|
||||
{
|
||||
return (byte)0x42;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -804,8 +804,17 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
{
|
||||
if (IsUIBlocked && isFromUI) return;
|
||||
|
||||
actionQueue.Enqueue(Action.RegVlvStop(isFromUI, regVId));
|
||||
log.InfoFormat("Enqueue( RegVlvStop(rv={0}) )", regVId);
|
||||
if (regVId < TBF.Rig.Uni.RegValveAnalog.RegValve.RVAnalogIdx)
|
||||
{
|
||||
actionQueue.Enqueue(Action.RegVlvStop(isFromUI, regVId));
|
||||
log.InfoFormat("Enqueue( RegVlvStop(rv={0}) )", regVId);
|
||||
}
|
||||
else if (regVId == TBF.Rig.Uni.RegValveAnalog.RegValve.RVAnalogIdx)
|
||||
{
|
||||
int dacVal = Data.StavDA[0];
|
||||
actionQueue.Enqueue(Action.RegVlvMoveToPos(isFromUI, regVId, dacVal));
|
||||
log.InfoFormat("Enqueue( RegVlvMoveToPos(rv={0}, positionLo={1}) )", regVId, dacVal);
|
||||
}
|
||||
foreach (var a in actionQueue) log.DebugFormat(" {0}", a);
|
||||
}
|
||||
|
||||
@@ -825,7 +834,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
/// <param name="time">Time in seconds, positive value opens the reg. valve</param>
|
||||
public void RegVlvIncrMove(bool isFromUI, int regVId, double time)
|
||||
{
|
||||
if (IsUIBlocked && isFromUI) return;
|
||||
if (IsUIBlocked && isFromUI || regVId >= TBF.Rig.Uni.RegValveAnalog.RegValve.RVAnalogIdx) return;
|
||||
|
||||
var newAction = Action.RegVlvIncrMove(isFromUI, regVId, time);
|
||||
|
||||
@@ -861,7 +870,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
/// <param name="position">Reg. valve position (0 .. 1.0)</param>
|
||||
public void RegVlvMoveToPos(bool isFromUI, int regVId, int adcValLo, int adcValHi = -1)
|
||||
{
|
||||
if (IsUIBlocked && isFromUI) return;
|
||||
if (IsUIBlocked && isFromUI || regVId > TBF.Rig.Uni.RegValveAnalog.RegValve.RVAnalogIdx) return;
|
||||
|
||||
actionQueue.Enqueue(Action.RegVlvMoveToPos(isFromUI, regVId, adcValLo, adcValHi));
|
||||
log.InfoFormat("Enqueue( RegVlvMoveToPos(rv={0}, positionLo={1}, positionHi={2}) )", regVId, adcValLo, adcValHi);
|
||||
|
||||
Reference in New Issue
Block a user