init
This commit is contained in:
@@ -0,0 +1,326 @@
|
||||
using System.Threading;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using DTS.Common.ICommunication;
|
||||
using System;
|
||||
using DTS.Common.Interface.Connection;
|
||||
using DTS.Common.Enums.DASFactory;
|
||||
using DTS.Common.Interface.DASFactory;
|
||||
|
||||
namespace DTS.DASLib.Service
|
||||
{
|
||||
public partial class TDAS<T> : Communication<T>,
|
||||
IDASCommunication,
|
||||
IConfigurationActions,
|
||||
IDiagnosticsActions,
|
||||
ITriggerCheckActions,
|
||||
IRealTimeActions,
|
||||
IArmActions,
|
||||
IDownloadActions where T : IConnection, new()
|
||||
{
|
||||
#region Trigger check
|
||||
void ITriggerCheckActions.PreStartTriggerCheck(ServiceCallback callback, object userData)
|
||||
{
|
||||
var info = new TriggerCheckPacket(callback, userData);
|
||||
info.Success();
|
||||
}
|
||||
void ITriggerCheckActions.PostStartTriggerCheck(ServiceCallback callback, object userData)
|
||||
{
|
||||
var info = new TriggerCheckPacket(callback, userData);
|
||||
info.Success();
|
||||
}
|
||||
private class TriggerCheckPacket : TDASServiceAsyncInfo
|
||||
{
|
||||
public TriggerCheckPacket(ServiceCallback cb, object ud)
|
||||
: base(cb, ud)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void ITriggerCheckActions.StartTriggerCheck(ServiceCallback callback, object userData)
|
||||
{
|
||||
var info = new TriggerCheckPacket(callback, userData);
|
||||
LaunchAsyncWorker("TDAS.StartTriggerCheck", AsyncStartTriggerCheck, info);
|
||||
}
|
||||
|
||||
private void AsyncStartTriggerCheck(object asyncInfo)
|
||||
{
|
||||
if (!(asyncInfo is TriggerCheckPacket info))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (null == DASArmStatus)
|
||||
{
|
||||
SetDASArmStatus(new ArmStatus(), true);
|
||||
}
|
||||
var status = DASArmStatus;
|
||||
try
|
||||
{
|
||||
status.IsArmed = true;
|
||||
status.IsRecording = false;
|
||||
status.IsTriggered = false;
|
||||
foreach (var module in DASInfo.Modules)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (module.TypeOfModule == DFConstantsAndEnums.ModuleType.EMPTYBANK)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IsG5())
|
||||
{
|
||||
var testTrigger = new Command.TDAS.TestTrigger(this)
|
||||
{
|
||||
ModuleIndex = module.ModuleArrayIndex,
|
||||
SubCommand = Command.TDAS.TestTrigger.SubCommandValues.ARM
|
||||
};
|
||||
testTrigger.SyncExecute();
|
||||
break;
|
||||
}
|
||||
|
||||
var qsn = new Command.TDAS.QuerySerialNumberBroadcast(this, module.ModuleArrayIndex);
|
||||
qsn.SyncExecute();
|
||||
|
||||
var ttb = new Command.TDAS.TestTriggerBroadcast(this, module.ModuleArrayIndex)
|
||||
{
|
||||
SubCommand = Command.TDAS.TestTrigger.SubCommandValues.ARM
|
||||
};
|
||||
ttb.SyncExecute();
|
||||
break;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
info.Error(ex.Message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
SetDASArmStatus(status, true);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
//assuming this is for logging purposes...unknown
|
||||
var ta = new Command.TDAS.TestAll(this) { Mode = Command.TDAS.TestAllCommandString.Modes.CURR };
|
||||
ta.SyncExecute();
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
info.Error(ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
info.Success();
|
||||
}
|
||||
|
||||
void ITriggerCheckActions.DoTriggerCheck(ServiceCallback callback, object userData)
|
||||
{
|
||||
var info = new TriggerCheckPacket(callback, userData);
|
||||
LaunchAsyncWorker("TDAS.DoTriggercheck", AsyncDoTriggerCheck, info);
|
||||
}
|
||||
void ITriggerCheckActions.DoStartCheck(ServiceCallback callback, object userData)
|
||||
{
|
||||
var info = new TriggerCheckPacket(callback, userData);
|
||||
LaunchAsyncWorker("TDAS.DoStartcheck", AsyncDoStartCheck, info);
|
||||
}
|
||||
private void AsyncDoStartCheck(object asyncInfo)
|
||||
{
|
||||
if (!(asyncInfo is TriggerCheckPacket info))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (null == DASArmStatus)
|
||||
{
|
||||
SetDASArmStatus(new ArmStatus(), false);
|
||||
}
|
||||
var status = DASArmStatus;
|
||||
try
|
||||
{
|
||||
var ta = new Command.TDAS.TestAll(this) { Mode = Command.TDAS.TestAllCommandString.Modes.PREV };
|
||||
try
|
||||
{
|
||||
ta.SyncExecute();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
info.Error(ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ta.StartedRecordingFlag == DFConstantsAndEnums.VoltageStatusColor.Yellow
|
||||
|| ta.StartedRecordingFlag == DFConstantsAndEnums.VoltageStatusColor.Red)
|
||||
{
|
||||
status.IsRecording = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
StartRecord = false;
|
||||
}
|
||||
|
||||
if (DASArmStatus.IsRecording)
|
||||
{
|
||||
status.IsArmed = false;
|
||||
}
|
||||
status.IsArmed = true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
SetDASArmStatus(status, true);
|
||||
}
|
||||
|
||||
info.Success();
|
||||
}
|
||||
|
||||
void ITriggerCheckActions.DoTriggerCheckSync()
|
||||
{
|
||||
//this function was created as part of
|
||||
//5211 Add check to ECM event line during ArmChecklist
|
||||
//however to minimize impact since the issue doesn't affect TDAS
|
||||
//I'll not make the changes to TDAS trigger check/armchecklist checks
|
||||
//instead for now I'll leave it as is
|
||||
//since this function shouldn't be used (unless we make the changes above), I'll leave it
|
||||
//with an exception to warn anyone that hooks it up not realizing the issue
|
||||
throw new NotImplementedException("DoTriggerCheckSync is not implemented for TDAS");
|
||||
}
|
||||
private void AsyncDoTriggerCheck(object asyncInfo)
|
||||
{
|
||||
if (!(asyncInfo is TriggerCheckPacket info))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var ta = new Command.TDAS.TestAll(this) { Mode = Command.TDAS.TestAllCommandString.Modes.PREV };
|
||||
ta.SyncExecute();
|
||||
|
||||
if (ta.TriggerFlag == DFConstantsAndEnums.VoltageStatusColor.Red
|
||||
|| ta.TriggerFlag == DFConstantsAndEnums.VoltageStatusColor.Yellow)
|
||||
{
|
||||
DASArmStatus.IsTriggered = true;
|
||||
SetDASArmStatus();
|
||||
try
|
||||
{
|
||||
var status = new ArmStatus();
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var module in DASInfo.Modules)
|
||||
{
|
||||
if (IsG5() && 0 < module.ModuleArrayIndex)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (module.TypeOfModule == DFConstantsAndEnums.ModuleType.EMPTYBANK)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var testTrigger = new Command.TDAS.TestTrigger(this, 5000);
|
||||
testTrigger.ModuleIndex = module.ModuleArrayIndex;
|
||||
testTrigger.SubCommand = Command.TDAS.TestTrigger.SubCommandValues.STATUS;
|
||||
try
|
||||
{
|
||||
testTrigger.SyncExecute();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Module probably timed out because it is still armed and never responded to the rack trigger/event line.
|
||||
status.IsArmed = true;
|
||||
status.IsTriggered = false;
|
||||
info.Error(module.SerialNumber + " did not trigger, but other modules did");
|
||||
return;
|
||||
}
|
||||
|
||||
if (testTrigger.TriggerStatus == Command.TDAS.TestTrigger.StatusValues.OFF)
|
||||
{
|
||||
status.IsTriggered = true;
|
||||
status.IsArmed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (status.IsTriggered)
|
||||
{
|
||||
info.Error(module.SerialNumber + " did not trigger, but other modules did");
|
||||
return;
|
||||
}
|
||||
|
||||
status.IsTriggered = false;
|
||||
status.IsArmed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally { SetDASArmStatus(status, true); }
|
||||
|
||||
info.Success();
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
info.Error(ex.Message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
info.Success();
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
info.Error(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
void ITriggerCheckActions.CancelTriggerCheck(ServiceCallback callback, object userData)
|
||||
{
|
||||
var info = new TriggerCheckPacket(callback, userData);
|
||||
LaunchAsyncWorker("TDAS.CancelTriggerCheck", AsyncCancelTriggerCheck, info);
|
||||
}
|
||||
|
||||
private void AsyncCancelTriggerCheck(object asyncInfo)
|
||||
{
|
||||
if (!(asyncInfo is TriggerCheckPacket info))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
foreach (var m in DASInfo.Modules)
|
||||
{
|
||||
if (m.SerialNumber == "EMPTY" || m.TypeOfModule == DFConstantsAndEnums.ModuleType.EMPTYBANK) continue;
|
||||
if (IsG5())
|
||||
{
|
||||
var testTrigger = new Command.TDAS.TestTrigger(this);
|
||||
testTrigger.ModuleIndex = m.ModuleArrayIndex;
|
||||
testTrigger.SubCommand = Command.TDAS.TestTrigger.SubCommandValues.OFF;
|
||||
testTrigger.SyncExecute();
|
||||
|
||||
var qsn = new Command.TDAS.QuerySerialNumber(this);
|
||||
qsn.ModuleIndex = m.ModuleArrayIndex;
|
||||
qsn.SyncExecute();
|
||||
break;
|
||||
}
|
||||
var qsc = new Command.TDAS.QuerySerialNumberBroadcast(this, m.ModuleArrayIndex);
|
||||
qsc.SyncExecute();
|
||||
|
||||
var tbc = new Command.TDAS.TestTriggerBroadcast(this, m.ModuleArrayIndex);
|
||||
tbc.SubCommand = Command.TDAS.TestTrigger.SubCommandValues.OFF;
|
||||
tbc.SyncExecute();
|
||||
|
||||
var qsnb = new Command.TDAS.QuerySerialNumberBroadcast(this, m.ModuleArrayIndex);
|
||||
qsnb.SyncExecute();
|
||||
break;
|
||||
}
|
||||
info.Success();
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
info.Error(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user