init
This commit is contained in:
144
DataPRO/SLICECommands/StackUtilityCommands.cs
Normal file
144
DataPRO/SLICECommands/StackUtilityCommands.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DTS.DASLib.Communication;
|
||||
using DTS.DASLib.Utility;
|
||||
|
||||
namespace DTS.DASLib.Command.SLICE
|
||||
{
|
||||
public abstract class Commands_Stack_Utility: CommandBase
|
||||
{
|
||||
protected enum Commands
|
||||
{
|
||||
ArbitraryFlashWrite = 0x01,
|
||||
ArbitraryFlashRead,
|
||||
FlashSelfTest,
|
||||
BusPowerControl,
|
||||
ForceEnumeration,
|
||||
GainSet,
|
||||
GainQuery,
|
||||
DACSet,
|
||||
DACQuery,
|
||||
SwitchSet,
|
||||
SwitchQuery,
|
||||
FilterSet,
|
||||
FilterQuery,
|
||||
};
|
||||
|
||||
protected Commands_Stack_Utility(ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
this.command.Type = CommandPacket.CommandType.StackUtility;
|
||||
}
|
||||
|
||||
protected Commands_Stack_Utility(ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
this.command.Type = CommandPacket.CommandType.StackUtility;
|
||||
}
|
||||
}
|
||||
|
||||
public class BusPowerControl: Commands_Stack_Utility
|
||||
{
|
||||
private bool _on;
|
||||
|
||||
public bool PowerOn
|
||||
{
|
||||
get { return _on; }
|
||||
set
|
||||
{
|
||||
_on = value;
|
||||
if(_on)
|
||||
this.command.SetParameter(0, (byte)1);
|
||||
else
|
||||
this.command.SetParameter(0, (byte)0);
|
||||
}
|
||||
}
|
||||
|
||||
public BusPowerControl(ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
this.command.Command = (byte)Commands.BusPowerControl;
|
||||
this.command.Parameter = new byte[1];
|
||||
PowerOn = false;
|
||||
}
|
||||
|
||||
public BusPowerControl(ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
this.command.Command = (byte)Commands.BusPowerControl;
|
||||
this.command.Parameter = new byte[1];
|
||||
PowerOn = false;
|
||||
}
|
||||
|
||||
public override string CommandToString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("Sending command BusPowerControl");
|
||||
sb.AppendFormat("PowerOn: {0}", PowerOn);
|
||||
sb.AppendLine();
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public override string ResponseToString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendFormat("Response for command BusPowerControl: {0}", ResponseStatus);
|
||||
sb.AppendLine();
|
||||
sb.AppendFormat("PowerOn: {0}", PowerOn);
|
||||
sb.AppendLine();
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public class ForceEnumeration: Commands_Stack_Utility
|
||||
{
|
||||
int _SLICECount;
|
||||
|
||||
public int SLICECount { get { return _SLICECount; } }
|
||||
|
||||
public ForceEnumeration(ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
this.command.Command = (byte)Commands.ForceEnumeration;
|
||||
this.command.Parameter = new byte[0];
|
||||
_SLICECount = 0;
|
||||
}
|
||||
|
||||
public ForceEnumeration(ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
this.command.Command = (byte)Commands.ForceEnumeration;
|
||||
this.command.Parameter = new byte[0];
|
||||
_SLICECount = 0;
|
||||
}
|
||||
|
||||
protected override CommandReceiveAction WholePackage()
|
||||
{
|
||||
if(response.Status == CommandPacket.CommandStatus.StatusNoError)
|
||||
{
|
||||
byte b;
|
||||
response.GetParameter(0, out b);
|
||||
_SLICECount = (int)b;
|
||||
}
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
}
|
||||
|
||||
public override string CommandToString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("Sending command ForceEnumeration");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public override string ResponseToString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendFormat("Response for command ForceEnumeration: {0}", ResponseStatus);
|
||||
sb.AppendLine();
|
||||
sb.AppendFormat("SLICECount: {0}", SLICECount);
|
||||
sb.AppendLine();
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user