(1) Changes similar to Fuzhou300 done for Petersburg200, (2) Bug in RRoute for 128-bit route fixed, (3) Route display/logging

This commit is contained in:
Milan Hanajik 2017-07-24 14:19:39 +03:00
parent ec27a5843b
commit 467e51374d
2 changed files with 35 additions and 49 deletions

View File

@ -43,8 +43,8 @@ namespace TBF.BenchControl.Elde
public float Pressure(int prsNr0) { return ctrlBrdComponent.pressure[prsNr0]; }
public float Temperature(int tmpNr0) { return ctrlBrdComponent.temperature[tmpNr0]; }
public RegulValveState RegulValveState(int rvNr1) { return (RegulValveState)ctrlBrdComponent.rValveStatus[rvNr1 - 1]; }
#if GENESIS || BERLIN
public UInt128 RRoute { get { return ((UInt128)ctrlBrdComponent.rRouteH << 64) | (UInt128)ctrlBrdComponent.rRoute; } }
#if GENESIS || BERLIN || PETERSBURG_200
public UInt128 RRoute { get { return ((UInt128)ctrlBrdComponent.rRouteH << 64) | (UInt128)ctrlBrdComponent.rRoute; } }
#else
public UInt128 RRoute { get { return ctrlBrdComponent.rRoute; } }
#endif
@ -301,33 +301,37 @@ namespace TBF.BenchControl.Elde
// shortImp,
// stopDevs));
#if FUZHOU300
///
/// The following code deals with the situation that all FM controlled pums share bit #39.
/// The following code deals with the situation that all FM controlled pumps share bit #39.
/// In settings the bits of pumps should be sent as follows: P1=50, P2=51, P3=52, P4=53, P5=54 and P7=55
/// (in FUZHOU300 the FM pump bit should be set set to value FMIndex+50).
///
bool bit39 = (route & 0x00FC000000000000) != 0; /// true if any of bits 50 through 55 is set
route = route & 0xFF03FFFFFFFFFFFF;
if (bit39) route = route | 0x0000008000000000;
log.DebugFormat("SendCommand route = {0}", Utils.ShowRoute(route));
#elif PETERSBURG_200
///
/// The following code deals with the situation that all pumps share bit #80.
/// In settings the bits of pumps should be sent as follows: P1=64, P2=65, P3=66, P4=67 and P5=68
///
bool bit80 = (route & (((UInt128)0x1F) << 64)) != 0; /// true if any of bits 64 through 68 is set
if (bit80) route = route | (((UInt128)1) << 80);
#endif
log.InfoFormat("SendCommand(Cmd={0},Ref#={1},Route={2} {3} {4} {5} {6},TotalPls={7},MassPls={8},TstM={9},filt={10},FM=[{11}{12}{13}{14}{15}{16}],Reg={17},ShrtImp={18},Stop={19})",
log.InfoFormat("SendCommand(Cmd={0},Ref#={1},Route={2},TotalPls={3},MassPls={4},TM={5},filt={6},FM=[{7}{8}{9}{10}{11}{12}],Reg={13},ShrtImp={14},Stop={15})",
cmd, /// 0
refFlowMeterNr, /// 1
((route >> 64) & 0xFFFF).ToString("X4"), /// 2
((route >> 48) & 0xFFFF).ToString("X4"), /// 3
((route >> 32) & 0xFFFF).ToString("X4"), /// 4
((route >> 16) & 0xFFFF).ToString("X4"), /// 5
(route & 0xFFFF).ToString("X4"), /// 6
totalRefPulses, massRefPulses, testMethods, filterConstant, /// 7, 8, 9, 10
fmFreq[0].ToString(), /// 11
(fmFreq.Length > 1) ? ("," + fmFreq[1].ToString()) : "", /// 12
(fmFreq.Length > 2) ? ("," + fmFreq[2].ToString()) : "", /// 13
(fmFreq.Length > 3) ? ("," + fmFreq[3].ToString()) : "", /// 14
(fmFreq.Length > 4) ? ("," + fmFreq[4].ToString()) : "", /// 15
(fmFreq.Length > 5) ? ("," + fmFreq[5].ToString()) : "", /// 16
regConst, shortImp, stopDevs); /// 17, 18, 19
Utils.ShowRoute(route), /// 2
totalRefPulses, massRefPulses, testMethods, filterConstant, /// 3, 4, 5, 6
fmFreq[0].ToString(), /// 7
(fmFreq.Length > 1) ? ("," + fmFreq[1].ToString()) : "", /// 8
(fmFreq.Length > 2) ? ("," + fmFreq[2].ToString()) : "", /// 9
(fmFreq.Length > 3) ? ("," + fmFreq[3].ToString()) : "", /// 10
(fmFreq.Length > 4) ? ("," + fmFreq[4].ToString()) : "", /// 11
(fmFreq.Length > 5) ? ("," + fmFreq[5].ToString()) : "", /// 12
regConst, shortImp, stopDevs); /// 13, 14, 15
#if DN100 || MUNICH
ctrlBrdComponent.SendCommand((uint)cmd, (byte)refFlowMeterNr, (ulong)route, (uint)totalRefPulses, (uint)testMethods,
@ -344,25 +348,13 @@ namespace TBF.BenchControl.Elde
ctrlBrdComponent.SendCommand((uint)cmd, (byte)refFlowMeterNr, (ulong)route, pulsesArr, (uint)testMethods,
filterConstant, fmFreq, (uint)regConst, (uint)shortImp, (uint)stopDevs);
#endif
log.InfoFormat("DoSendCommand() Route = {0}", Utils.ShowRoute(route));
UInt128 bufferedRoute = route;
if (lastRoute != bufferedRoute)
if (lastRoute != route) /// This is to update the MainWnd status bar on changes only
{
UInt128 rRoute = RRoute;
string routeStr = string.Format("{0}-{1}-{2}-{3}-{4} ({5}-{6}-{7}-{8}-{9})",
((bufferedRoute >> 64) & 0xFFFF).ToString("X4"),
((bufferedRoute >> 48) & 0xFFFF).ToString("X4"),
((bufferedRoute >> 32) & 0xFFFF).ToString("X4"),
((bufferedRoute >> 16) & 0xFFFF).ToString("X4"),
(bufferedRoute & 0xFFFF).ToString("X4"),
((rRoute >> 64) & 0xFFFF).ToString("X4"),
((rRoute >> 48) & 0xFFFF).ToString("X4"),
((rRoute >> 32) & 0xFFFF).ToString("X4"),
((rRoute >> 16) & 0xFFFF).ToString("X4"),
(rRoute & 0xFFFF).ToString("X4"));
log.InfoFormat("DoSendCommand() Route = {0}", routeStr);
Program.MainWnd.UpdateRoute(routeStr);
lastRoute = bufferedRoute;
Program.MainWnd.UpdateRoute(string.Format("{0} ({1})", Utils.ShowRoute(route), Utils.ShowRoute(rRoute)));
lastRoute = route;
}
}
@ -374,8 +366,9 @@ namespace TBF.BenchControl.Elde
}
private StatusP lastStatusP;
private UInt128 lastRoute;
private StatusP lastStatusP; /// This is to update the MainWnd status bar on changes only
private UInt128 lastRoute; /// This is to update the MainWnd status bar on changes only
public void RunDeviceBefore()
{

View File

@ -433,19 +433,12 @@ namespace TBF
public static string ShowRoute(UInt128 route)
{
string str = string.Empty;
int i = 0;
for (UInt128 bitmask = ((UInt128)1 << 127); bitmask > 0; bitmask /= 2)
{
str += ((route & bitmask) != 0) ? "1" : "0";
i++;
if (i < 64)
{
if ((i % 16) == 0) str += "-";
else if ((i % 8) == 0) str += " ";
}
}
return str;
return string.Format("{0}-{1} {2}-{3}-{4}-{5}", ((route >> 80) & 0xFFFF).ToString("X4"), /// 0
((route >> 64) & 0xFFFF).ToString("X4"), /// 1
((route >> 48) & 0xFFFF).ToString("X4"), /// 2
((route >> 32) & 0xFFFF).ToString("X4"), /// 3
((route >> 16) & 0xFFFF).ToString("X4"), /// 4
(route & 0xFFFF).ToString("X4")); /// 5
}
public static string ToMyString(DateTime dateTime)