init
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
using DTS.Common.ICommunication;
|
||||
|
||||
namespace DTS.DASLib.Command
|
||||
{
|
||||
/// <summary>
|
||||
/// this is a base class for slice commands, it contains
|
||||
/// additional logic that ribeye doesn't have (deviceid, device group)
|
||||
/// </summary>
|
||||
public abstract class SliceCommandBase : AbstractCommandBase
|
||||
{
|
||||
protected SliceCommandPacketBase command
|
||||
{
|
||||
get => baseCommand as SliceCommandPacketBase;
|
||||
set => baseCommand = value;
|
||||
}
|
||||
|
||||
protected SliceCommandPacketBase response
|
||||
{
|
||||
get => baseResponse as SliceCommandPacketBase;
|
||||
set => baseResponse = value;
|
||||
}
|
||||
|
||||
public byte DeviceID
|
||||
{
|
||||
get => command.DeviceID;
|
||||
set => command.DeviceID = value;
|
||||
}
|
||||
|
||||
public byte DeviceGroup
|
||||
{
|
||||
get => command.DeviceGroup;
|
||||
set => command.DeviceGroup = value;
|
||||
}
|
||||
public SliceCommandBase(DTS.Common.Interface.DASFactory.ICommunication sock) : base(sock) { }
|
||||
public SliceCommandBase(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec) : base(sock, TimeoutMillisec) { }
|
||||
|
||||
/// <summary>
|
||||
/// adds the serial number information to the log header
|
||||
/// </summary>
|
||||
/// <param name="list"></param>
|
||||
public override void CommandToString(ref List<List<string>> list)
|
||||
{
|
||||
list[0].Add((null == recorder || null == recorder.DASInfo || DeviceID < 0) ? "<unknown>" : recorder.DASInfo.StackSerialNumber(DeviceID));
|
||||
if (null != recorder && null != recorder.Transport) { list[0].Add(recorder.Transport.GetConnectionData()); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// adds serial number information to log header
|
||||
/// </summary>
|
||||
/// <param name="lines"></param>
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
lines[0].Add((null == recorder || null == recorder.DASInfo || DeviceID < 0) ? "<unknown>" : recorder.DASInfo.StackSerialNumber(DeviceID));
|
||||
}
|
||||
|
||||
private static SemaphoreSlim _slicePool = new SemaphoreSlim(15, 15);
|
||||
private static int _slicePoolDelayMs = 10;
|
||||
|
||||
/// <summary>
|
||||
/// initializes the semaphore for SLICE, note if the semaphore is going to
|
||||
/// be changed by the application it needs to be done before communication starts.
|
||||
/// 10852 Add semaphore to SLICE communication to improve SLICE 6 multiple IP performance
|
||||
/// </summary>
|
||||
/// <param name="spots"></param>
|
||||
/// <param name="delayMs"></param>
|
||||
public static void Initialize(int spots, int delayMs)
|
||||
{
|
||||
_slicePoolDelayMs = delayMs;
|
||||
_slicePool = new SemaphoreSlim(spots, spots);
|
||||
}
|
||||
public override void SyncExecute()
|
||||
{
|
||||
//_slicePool.Wait();
|
||||
//var start = DateTime.Now;
|
||||
try
|
||||
{
|
||||
base.SyncExecute();
|
||||
}
|
||||
finally
|
||||
{
|
||||
//_slicePool.Release();
|
||||
//var elapsed = DateTime.Now.Subtract(start);
|
||||
//if (elapsed.TotalMilliseconds < _slicePoolDelayMs)
|
||||
//{
|
||||
// Thread.Sleep(Convert.ToInt32(_slicePoolDelayMs - elapsed.TotalMilliseconds));
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user