init
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
|
||||
|
||||
namespace DTS.DASLib.Service
|
||||
{
|
||||
internal interface IDownloadActions
|
||||
{
|
||||
/// <summary>
|
||||
/// Download the data specified in the WhatToDownload property
|
||||
/// </summary>
|
||||
/// <param name="callback">The function to call with information</param>
|
||||
/// <param name="userData">Whatever you want to pass along</param>
|
||||
void Download(ServiceCallback callback, object userData);
|
||||
|
||||
/// <summary>
|
||||
/// Cancel the current operation
|
||||
/// </summary>
|
||||
void Cancel();
|
||||
|
||||
/// <summary>
|
||||
/// Cancels the current operation (with a smaller clear cancel time)
|
||||
/// </summary>
|
||||
void ForceCancel();
|
||||
/// <summary>
|
||||
/// Clear the cancel flag
|
||||
/// </summary>
|
||||
void ClearCancel();
|
||||
/// <summary>
|
||||
/// Retrieve info about available events to download
|
||||
/// </summary>
|
||||
/// <param name="callback">The function to call with information</param>
|
||||
/// <param name="userData">Whatever you want to pass along</param>
|
||||
void QueryDownload(ServiceCallback callback, object userData, int eventIndex, TDASServiceSetupInfo setupInfo);
|
||||
|
||||
/// <summary>
|
||||
/// Figure out if events have been downloaded
|
||||
/// </summary>
|
||||
/// <param name="callback">The function to call with information</param>
|
||||
/// <param name="userData">Whatever you want to pass along</param>
|
||||
void QueryDownloadedStatus(ServiceCallback callback, object userData);
|
||||
|
||||
/// <summary>
|
||||
/// Update the recorded trigger sample numbers in HW
|
||||
/// </summary>
|
||||
/// <param name="callback">The function to call with information</param>
|
||||
/// <param name="userData">Whatever you want to pass along</param>
|
||||
void SetTriggerSampleNumbers(ServiceCallback callback, object userData);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Set event status to downloaded (to be used when there is no data to download)
|
||||
/// </summary>
|
||||
/// <param name="callback">The function to call with information</param>
|
||||
/// <param name="userData">Whatever you want to pass along</param>
|
||||
///
|
||||
void SetDownloaded(ServiceCallback callback, object userData);
|
||||
/// <summary>
|
||||
/// updates an event with new information
|
||||
/// </summary>
|
||||
/// <param name="eventIndex"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="guid"></param>
|
||||
/// <param name="totalSamples"></param>
|
||||
/// <param name="triggerSamples"></param>
|
||||
/// <param name="startRecordSample"></param>
|
||||
/// <param name="callback"></param>
|
||||
/// <param name="userData"></param>
|
||||
void SetEventInfo(int eventIndex,
|
||||
string id,
|
||||
Guid guid,
|
||||
ulong totalSamples,
|
||||
ulong[] triggerSamples,
|
||||
ulong startRecordSample,
|
||||
UInt32 eventHasDownloaded,
|
||||
ServiceCallback callback,
|
||||
object userData);
|
||||
|
||||
/// <summary>
|
||||
/// corrects the T0 and Total samples recorded attributes
|
||||
/// note that not all IDownloadAction devices support
|
||||
/// devices that don't support will return an error and complete
|
||||
/// this functionality searches ADC on a device for rails and
|
||||
/// local peaks and troughs
|
||||
/// 18469 Implement missing trigger(t0) recovery(Circular Buffer / Hybrid Recorder)
|
||||
/// </summary>
|
||||
/// <param name="callback"></param>
|
||||
/// <param name="userData"></param>
|
||||
void CorrectT0s(ServiceCallback callback,
|
||||
object userData);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
using System.Threading;
|
||||
using DTS.Common.Interface.DASFactory;
|
||||
using DTS.DASLib.Command.SLICE;
|
||||
|
||||
namespace DTS.DASLib.Service
|
||||
{
|
||||
public class SLICEBaseInputReader
|
||||
{
|
||||
private readonly ICommunication _comm;
|
||||
|
||||
public SLICEBaseInputReader(DTS.Common.Interface.DASFactory.ICommunication comm)
|
||||
{
|
||||
_comm = comm;
|
||||
}
|
||||
|
||||
public virtual double InputMilliVolts
|
||||
{
|
||||
get
|
||||
{
|
||||
var measure = new MeasureBaseDiagnosticChannel(_comm);
|
||||
measure.Channel = MeasureBaseDiagnosticChannel.BaseDiagnosticChannelList.InputVoltage;
|
||||
measure.DeviceGroup = 0;
|
||||
measure.DeviceID = 0;
|
||||
measure.SyncExecute();
|
||||
return measure.Measurement * 1000.0;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual double TemperatureC
|
||||
{
|
||||
get
|
||||
{
|
||||
var measure = new MeasureBaseDiagnosticChannel(_comm);
|
||||
measure.Channel = MeasureBaseDiagnosticChannel.BaseDiagnosticChannelList.TemperatureC;
|
||||
measure.DeviceGroup = 0;
|
||||
measure.DeviceID = 0;
|
||||
measure.SyncExecute();
|
||||
return measure.Measurement;
|
||||
}
|
||||
}
|
||||
|
||||
public bool BatteryIsCharging
|
||||
{
|
||||
get
|
||||
{
|
||||
var setSwitch = new QuerySwitchImmediate(_comm);
|
||||
setSwitch.Switch = (byte)Switches.BaseSwitches.ChargeStatus;
|
||||
setSwitch.SwitchText = Switches.BaseSwitches.ChargeStatus.ToString();
|
||||
setSwitch.SyncExecute();
|
||||
return setSwitch.Setting == 1;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual double DirectBackupMilliVolts
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!ShouldMeasureBackupPower())
|
||||
{
|
||||
return 0D;
|
||||
}
|
||||
var measure = new MeasureBaseDiagnosticChannel(_comm);
|
||||
measure.Channel = MeasureBaseDiagnosticChannel.BaseDiagnosticChannelList.BackupVoltage;
|
||||
measure.DeviceGroup = 0;
|
||||
measure.DeviceID = 0;
|
||||
measure.SyncExecute();
|
||||
return measure.Measurement * 1000.0;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// returns true if the unit should check/enable/disable backup power
|
||||
/// originally part of the S6 performance improvements
|
||||
/// note that S6 should not have battery power
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool ShouldEnableBackupPower()
|
||||
{
|
||||
switch (_comm)
|
||||
{
|
||||
case EthernetSlice6 _:
|
||||
case EthernetSlice2 _:
|
||||
case EthernetSlice6Air _:
|
||||
case EthernetSlice6AirBridge _:
|
||||
case EthernetTsrAir _:
|
||||
case WinUSBSlice6 _:
|
||||
case CDCUSBSlice _:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// previously there was no ShouldMeasureBackupPower
|
||||
/// and only ShouldEnableBackupPower existed, however
|
||||
/// TSR AIR SHOULD measure backup power and SHOULD NOT
|
||||
/// enable backup power ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool ShouldMeasureBackupPower()
|
||||
{
|
||||
switch (_comm)
|
||||
{
|
||||
case EthernetSlice6 _:
|
||||
case EthernetSlice6Air _:
|
||||
case EthernetSlice6AirBridge _:
|
||||
case WinUSBSlice6 _:
|
||||
case CDCUSBSlice _:
|
||||
return false;
|
||||
case EthernetSlice2 _:
|
||||
case EthernetTsrAir _:
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public double BackupMilliVolts
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ShouldEnableBackupPower())
|
||||
{
|
||||
EnableBackupPower();
|
||||
// wait for a second
|
||||
Thread.Sleep(1500);
|
||||
}
|
||||
return DirectBackupMilliVolts;
|
||||
}
|
||||
finally
|
||||
{
|
||||
DisableBackupPower();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EnableBackupPower()
|
||||
{
|
||||
if (!ShouldEnableBackupPower()) { return; }
|
||||
var setSwitch = new SetSwitchImmediate(_comm);
|
||||
setSwitch.Switch = (byte)Switches.BaseSwitches.BackupPower;
|
||||
setSwitch.SwitchText = Switches.BaseSwitches.BackupPower.ToString();
|
||||
setSwitch.Setting = 1;
|
||||
setSwitch.SyncExecute();
|
||||
}
|
||||
|
||||
private void DisableBackupPower()
|
||||
{
|
||||
if (!ShouldEnableBackupPower()) { return; }
|
||||
var setSwitch = new SetSwitchImmediate(_comm);
|
||||
setSwitch.Switch = (byte)Switches.BaseSwitches.BackupPower;
|
||||
setSwitch.SwitchText = Switches.BaseSwitches.BackupPower.ToString();
|
||||
setSwitch.Setting = 0;
|
||||
setSwitch.SyncExecute();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user