This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1 @@
12

View File

@@ -0,0 +1 @@
12

View File

@@ -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));
//}
}
}
}
}

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram />

View File

@@ -0,0 +1,440 @@
<?xml version="1.0" encoding="utf-8"?>
<DirectedGraph DataVirtualized="True" Layout="Sugiyama" ZoomLevel="-1" xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="@10" Category="CodeSchema_Assembly" AssemblyTimestamp="12/14/2018 20:59:11" Bounds="-177.494798819339,45.3125833333333,174.97,25" CodeSchemaProperty_StrongName="SliceDBCommands, Version=1.6.81.0, Culture=neutral, PublicKeyToken=null" DelayedChildNodesState="NotFetched" DelayedCrossGroupLinksState="Fetched" FilePath="$(dea48a0b-999e-48e8-8601-cb05b6b765de.OutputPath)" Group="Collapsed" Label="SliceDBCommands.dll">
<Category Ref="FileSystem.Category.FileOfType.dll" />
</Node>
<Node Id="@12" Category="CodeSchema_Assembly" AssemblyTimestamp="12/14/2018 20:59:12" Bounds="-371.881565486005,45.3125,164.386666666667,25" CodeSchemaProperty_StrongName="SLICECommands, Version=1.6.81.0, Culture=neutral, PublicKeyToken=null" DelayedChildNodesState="NotFetched" DelayedCrossGroupLinksState="Fetched" FilePath="$(d015f93d-9507-4484-977b-4cf1bdc0b30e.OutputPath)" Group="Collapsed" Label="SLICECommands.dll">
<Category Ref="FileSystem.Category.FileOfType.dll" />
</Node>
<Node Id="@14" Category="CodeSchema_Assembly" AssemblyTimestamp="12/14/2018 20:59:11" Bounds="231.928734513995,45.3125,164.19,25" CodeSchemaProperty_StrongName="TDASCommands, Version=1.6.81.0, Culture=neutral, PublicKeyToken=null" DelayedChildNodesState="NotFetched" DelayedCrossGroupLinksState="Fetched" FilePath="$(14b4a79f-a4b5-4c4c-a041-0105eed82782.OutputPath)" Group="Collapsed" Label="TDASCommands.dll">
<Category Ref="FileSystem.Category.FileOfType.dll" />
</Node>
<Node Id="@16" Category="CodeSchema_Assembly" AssemblyTimestamp="12/14/2018 20:59:14" Bounds="-44.2683500953703,-64.6876166666667,135.89,25" CodeSchemaProperty_StrongName="DASFactory, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DelayedChildNodesState="NotFetched" DelayedCrossGroupLinksState="Fetched" FilePath="$(02eeba8c-7b22-4bc3-bf3a-8de23eaf2e61.OutputPath)" Group="Collapsed" Label="DASFactory.dll">
<Category Ref="FileSystem.Category.FileOfType.dll" />
</Node>
<Node Id="@2" Category="CodeSchema_Assembly" AssemblyTimestamp="12/14/2018 21:00:10" Bounds="117.812507273767,-139.687716666667,129.18,25" CodeSchemaProperty_StrongName="DataPRO, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DelayedChildNodesState="NotFetched" DelayedCrossGroupLinksState="Fetched" FilePath="$(8baa9433-8034-4fde-822c-537c59d3a7ec.OutputPath)" Group="Collapsed" Label="DataPRO.exe" UseManualLocation="True">
<Category Ref="CodeMap_WpfProject" />
<Category Ref="FileSystem.Category.FileOfType.exe" />
</Node>
<Node Id="@4" Category="CodeSchema_Assembly" AssemblyTimestamp="12/14/2018 20:59:11" Bounds="-12.2683288605816,100.312683333333,133.77,25" CodeSchemaProperty_StrongName="ICommand, Version=1.6.81.0, Culture=neutral, PublicKeyToken=null" DelayedChildNodesState="NotFetched" DelayedCrossGroupLinksState="Fetched" FilePath="$(58e70872-8acc-4957-bb8e-d3746bcc536d.OutputPath)" Group="Collapsed" Label="ICommand.dll" />
<Node Id="@6" Category="CodeSchema_Assembly" AssemblyTimestamp="12/14/2018 20:59:13" Bounds="4.74883362620589,-9.68751666666668,115.97,25" CodeSchemaProperty_StrongName="IService, Version=1.6.81.0, Culture=neutral, PublicKeyToken=null" DelayedChildNodesState="NotFetched" DelayedCrossGroupLinksState="Fetched" FilePath="$(c9c45b72-05a3-4962-bc13-a78b1f4b1925.OutputPath)" Group="Collapsed" Label="IService.dll">
<Category Ref="FileSystem.Category.FileOfType.dll" />
</Node>
<Node Id="@8" Category="CodeSchema_Assembly" AssemblyTimestamp="12/14/2018 20:59:11" Bounds="27.4753011806614,45.3125833333333,174.453333333333,25" CodeSchemaProperty_StrongName="Ribeye Commands, Version=1.6.81.0, Culture=neutral, PublicKeyToken=null" DelayedChildNodesState="NotFetched" DelayedCrossGroupLinksState="Fetched" FilePath="$(53abd0f3-7d8d-43cd-99d7-06c45246d93e.OutputPath)" Group="Collapsed" Label="Ribeye Commands.dll">
<Category Ref="FileSystem.Category.FileOfType.dll" />
</Node>
</Nodes>
<Links>
<Link Source="@10" Target="@4" Category="InheritsFrom" Bounds="-57.1402063188802,70.3125833333333,70.4750449869209,26.8010034600893" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="375">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_FieldRead" />
<Category Ref="CodeSchema_FieldWrite" />
<Category Ref="CodeSchema_ReturnTypeLink" />
</Link>
<Link Source="@12" Target="@4" Category="References" Bounds="-211.76899818276,70.2595262042781,191.629938440522,30.6114773435068" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="1719">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_FieldRead" />
<Category Ref="CodeSchema_FieldWrite" />
<Category Ref="CodeSchema_FunctionPointer" />
<Category Ref="CodeSchema_ReturnTypeLink" />
<Category Ref="Implements" />
<Category Ref="InheritsFrom" />
</Link>
<Link Source="@14" Target="@4" Category="References" Bounds="122.376908548554,70.3125,132.690871718339,28.133475535438" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="442">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_FieldRead" />
<Category Ref="CodeSchema_FieldWrite" />
<Category Ref="CodeSchema_FunctionPointer" />
<Category Ref="CodeSchema_ReturnTypeLink" />
<Category Ref="InheritsFrom" />
</Link>
<Link Source="@16" Target="@10" Category="CodeSchema_Calls" Bounds="-70.6229498301613,-39.6876166666667,81.3807085959602,78.741963727204" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="7">
<Category Ref="CodeMap_ProjectReference" />
</Link>
<Link Source="@16" Target="@12" Category="References" Bounds="-245.586626840792,-39.6876166666667,233.653668824858,82.0191805207747" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="159">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
</Link>
<Link Source="@16" Target="@14" Category="CodeSchema_Calls" Bounds="56.6706017984722,-39.6876166666667,215.94293941237,81.8115620505097" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="30">
<Category Ref="CodeMap_ProjectReference" />
</Link>
<Link Source="@16" Target="@4" Category="References" Bounds="-2.4352719783783,-39.6876182556152,43.8318822383881,132.490077972412" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="94">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
</Link>
<Link Source="@16" Target="@6" Category="References" Bounds="32.5532664293215,-39.6876166666667,16.0930225012287,22.6621011176714" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="531">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_FieldWrite" />
<Category Ref="CodeSchema_ReturnTypeLink" />
</Link>
<Link Source="@16" Target="@8" Category="CodeSchema_Calls" Bounds="65.0691528320313,-39.6876182556152,61.6118392944336,76.1888618469238" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="6">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_FieldRead" />
</Link>
<Link Source="@2" Target="@14" Category="References" Bounds="191.295823023052,-114.687716666667,108.617156935812,152.666845524603" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="11">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
</Link>
<Link Source="@2" Target="@16" Category="References" Bounds="58.2682468002986,-114.687716666667,97.6799861843111,46.155105748047" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="62">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
</Link>
<Link Source="@2" Target="@4" Category="References" Bounds="124.239486694336,-114.687713623047,81.4401245117188,213.188179016113" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="110">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_ReturnTypeLink" />
</Link>
<Link Source="@2" Target="@6" Category="References" Bounds="80.3358170747098,-114.687716666667,90.560104666154,98.3785593988733" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="7433">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_FieldWrite" />
<Category Ref="CodeSchema_ReturnTypeLink" />
</Link>
<Link Source="@6" Target="@10" Category="CodeSchema_Calls" Bounds="-46.827632277619,15.3124833333333,74.8470671014717,26.9510166111526" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="50">
<Category Ref="CodeMap_ProjectReference" />
</Link>
<Link Source="@6" Target="@12" Category="References" Bounds="-202.126942242109,11.8252217236356,207.110104607883,32.3222076917732" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="2084">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_FieldRead" />
<Category Ref="CodeSchema_FieldWrite" />
<Category Ref="CodeSchema_ReturnTypeLink" />
<Category Ref="InheritsFrom" />
</Link>
<Link Source="@6" Target="@14" Category="References" Bounds="117.790990419989,14.8628861970343,130.329541871057,28.5253285139701" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="675">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_ReturnTypeLink" />
</Link>
<Link Source="@6" Target="@4" Category="References" Bounds="17.34108543396,15.3124837875366,27.8616542816162,77.5488519668579" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="923">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_FieldRead" />
<Category Ref="CodeSchema_ReturnTypeLink" />
</Link>
<Link Source="@6" Target="@8" Category="References" Bounds="74.5447517475189,15.3124833333333,22.1652030067121,23.4583827216558" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="39">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_FieldRead" />
</Link>
<Link Source="@8" Target="@4" Category="References" Bounds="74.9110788046124,70.3125833333333,26.1351646195079,23.9232681928351" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="93">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_FieldRead" />
<Category Ref="CodeSchema_FieldWrite" />
<Category Ref="CodeSchema_ReturnTypeLink" />
<Category Ref="Implements" />
<Category Ref="InheritsFrom" />
</Link>
</Links>
<Categories>
<Category Id="CodeMap_ProjectReference" Label="Project Reference" CanBeDataDriven="True" CanLinkedNodesBeDataDriven="True" IncomingActionLabel="Referenced By" OutgoingActionLabel="References" />
<Category Id="CodeMap_WpfProject" Label="WPF Project" CanBeDataDriven="True" IsProviderRoot="False" NavigationActionLabel="WPF Projects" />
<Category Id="CodeSchema_Assembly" Label="Assembly" BasedOn="File" CanBeDataDriven="True" DefaultAction="Microsoft.Contains" Icon="CodeSchema_Assembly" NavigationActionLabel="Assemblies" />
<Category Id="CodeSchema_Calls" Label="Calls" CanBeDataDriven="True" CanLinkedNodesBeDataDriven="True" IncomingActionLabel="Called By" OutgoingActionLabel="Calls" />
<Category Id="CodeSchema_FieldRead" Label="Field Read" BasedOn="CodeSchema_FieldReference" CanBeDataDriven="True" CanLinkedNodesBeDataDriven="True" IncomingActionLabel="Read By" OutgoingActionLabel="Reads Fields" />
<Category Id="CodeSchema_FieldReference" Label="Field Reference" CanBeDataDriven="True" CanLinkedNodesBeDataDriven="True" IncomingActionLabel="Referenced By" OutgoingActionLabel="References Fields" />
<Category Id="CodeSchema_FieldWrite" Label="Field Write" BasedOn="CodeSchema_FieldReference" CanBeDataDriven="True" CanLinkedNodesBeDataDriven="True" IncomingActionLabel="Written By" OutgoingActionLabel="Writes Fields" />
<Category Id="CodeSchema_FunctionPointer" Label="Function Pointer" CanBeDataDriven="True" CanLinkedNodesBeDataDriven="True" IncomingActionLabel="Function Pointers" OutgoingActionLabel="Function Pointers" />
<Category Id="CodeSchema_ReturnTypeLink" Label="Return" CanBeDataDriven="True" CanLinkedNodesBeDataDriven="True" IncomingActionLabel="Return types" OutgoingActionLabel="Return types" />
<Category Id="File" Label="File" CanBeDataDriven="True" DefaultAction="Microsoft.Contains" Icon="File" NavigationActionLabel="Files" />
<Category Id="FileSystem.Category.FileOfType.dll" BasedOn="CodeSchema_Assembly" CanBeDataDriven="True" IsProviderRoot="False" />
<Category Id="FileSystem.Category.FileOfType.exe" BasedOn="CodeSchema_Assembly" CanBeDataDriven="True" IsProviderRoot="False" />
<Category Id="Implements" Label="Implements" />
<Category Id="InheritsFrom" Label="Inherits From" />
<Category Id="References" Label="References" CanBeDataDriven="True" CanLinkedNodesBeDataDriven="True" IncomingActionLabel="Referenced By" OutgoingActionLabel="References" />
</Categories>
<Properties>
<Property Id="AssemblyTimestamp" DataType="System.DateTime" />
<Property Id="Bounds" DataType="System.Windows.Rect" />
<Property Id="CanBeDataDriven" Label="CanBeDataDriven" Description="CanBeDataDriven" DataType="System.Boolean" />
<Property Id="CanLinkedNodesBeDataDriven" Label="CanLinkedNodesBeDataDriven" Description="CanLinkedNodesBeDataDriven" DataType="System.Boolean" />
<Property Id="CodeSchemaProperty_StrongName" Label="StrongName" Description="StrongName" DataType="System.String" />
<Property Id="DataVirtualized" Label="Data Virtualized" Description="If true, the graph can contain nodes and links that represent data for virtualized nodes/links (i.e. not actually created in the graph)." DataType="System.Boolean" />
<Property Id="DefaultAction" Label="DefaultAction" Description="DefaultAction" DataType="System.String" />
<Property Id="DelayedChildNodesState" Label="Delayed Child Nodes State" Description="Unspecified if the delayed child nodes state is not specified. NotFetched if the group contains child nodes that are not fetched into the graph yet. Fetched if the group has all its delayed child nodes already fetched." DataType="Microsoft.VisualStudio.GraphModel.DelayedDataState" />
<Property Id="DelayedCrossGroupLinksState" Label="Delayed Cross-Group Links State" Description="Unspecified if the delayed cross-group links state is not specified. NotFetched if delayed cross-group links on this node are not fetched into the graph yet. Fetched if all delayed cross-group links have already fetched." DataType="Microsoft.VisualStudio.GraphModel.DelayedDataState" />
<Property Id="Expression" DataType="System.String" />
<Property Id="FilePath" Label="File Path" Description="File Path" DataType="System.String" />
<Property Id="Group" Label="Group" Description="Display the node as a group" DataType="Microsoft.VisualStudio.GraphModel.GraphGroupStyle" />
<Property Id="GroupLabel" DataType="System.String" />
<Property Id="Icon" Label="Icon" Description="Icon" DataType="System.String" />
<Property Id="IncomingActionLabel" Label="IncomingActionLabel" Description="IncomingActionLabel" DataType="System.String" />
<Property Id="IsEnabled" DataType="System.Boolean" />
<Property Id="IsProviderRoot" Label="IsProviderRoot" Description="IsProviderRoot" DataType="System.Boolean" />
<Property Id="IsSourceVirtualized" Label="Link Source Virtualized" Description="If true, the link source end contains data for virtualized nodes/links (i.e. not actually created in the graph)." DataType="System.Boolean" />
<Property Id="IsTargetVirtualized" Label="Link Target Virtualized" Description="If true, the link target end contains data for virtualized nodes/links (i.e. not actually created in the graph)." DataType="System.Boolean" />
<Property Id="Label" Label="Label" Description="Displayable label of an Annotatable object" DataType="System.String" />
<Property Id="Layout" DataType="System.String" />
<Property Id="NavigationActionLabel" Label="NavigationActionLabel" Description="NavigationActionLabel" DataType="System.String" />
<Property Id="OutgoingActionLabel" Label="OutgoingActionLabel" Description="OutgoingActionLabel" DataType="System.String" />
<Property Id="TargetType" DataType="System.Type" />
<Property Id="UseManualLocation" DataType="System.Boolean" />
<Property Id="Value" DataType="System.String" />
<Property Id="ValueLabel" DataType="System.String" />
<Property Id="Visibility" Label="Visibility" Description="Defines whether a node in the graph is visible or not" DataType="System.Windows.Visibility" />
<Property Id="Weight" Label="Weight" Description="Weight" DataType="System.Double" />
<Property Id="ZoomLevel" DataType="System.String" />
</Properties>
<QualifiedNames>
<Name Id="Assembly" Label="Assembly" ValueType="Uri" />
</QualifiedNames>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=$(8baa9433-8034-4fde-822c-537c59d3a7ec.OutputPathUri)" />
<Alias n="2" Id="(@1)" />
<Alias n="3" Uri="Assembly=$(58e70872-8acc-4957-bb8e-d3746bcc536d.OutputPathUri)" />
<Alias n="4" Id="(@3)" />
<Alias n="5" Uri="Assembly=$(c9c45b72-05a3-4962-bc13-a78b1f4b1925.OutputPathUri)" />
<Alias n="6" Id="(@5)" />
<Alias n="7" Uri="Assembly=$(53abd0f3-7d8d-43cd-99d7-06c45246d93e.OutputPathUri)" />
<Alias n="8" Id="(@7)" />
<Alias n="9" Uri="Assembly=$(dea48a0b-999e-48e8-8601-cb05b6b765de.OutputPathUri)" />
<Alias n="10" Id="(@9)" />
<Alias n="11" Uri="Assembly=$(d015f93d-9507-4484-977b-4cf1bdc0b30e.OutputPathUri)" />
<Alias n="12" Id="(@11)" />
<Alias n="13" Uri="Assembly=$(14b4a79f-a4b5-4c4c-a041-0105eed82782.OutputPathUri)" />
<Alias n="14" Id="(@13)" />
<Alias n="15" Uri="Assembly=$(02eeba8c-7b22-4bc3-bf3a-8de23eaf2e61.OutputPathUri)" />
<Alias n="16" Id="(@15)" />
</IdentifierAliases>
<Styles>
<Style TargetType="Node" GroupLabel="Results" ValueLabel="True">
<Condition Expression="HasCategory('QueryResult')" />
<Setter Property="Background" Value="#FFBCFFBE" />
</Style>
<Style TargetType="Node" GroupLabel="Test Project" ValueLabel="Test Project">
<Condition Expression="HasCategory('CodeMap_TestProject')" />
<Setter Property="Icon" Value="CodeMap_TestProject" />
<Setter Property="Background" Value="#FF307A69" />
</Style>
<Style TargetType="Node" GroupLabel="Web Project" ValueLabel="Web Project">
<Condition Expression="HasCategory('CodeMap_WebProject')" />
<Setter Property="Icon" Value="CodeMap_WebProject" />
</Style>
<Style TargetType="Node" GroupLabel="Windows Store Project" ValueLabel="Windows Store Project">
<Condition Expression="HasCategory('CodeMap_WindowsStoreProject')" />
<Setter Property="Icon" Value="CodeMap_WindowsStoreProject" />
</Style>
<Style TargetType="Node" GroupLabel="Phone Project" ValueLabel="Phone Project">
<Condition Expression="HasCategory('CodeMap_PhoneProject')" />
<Setter Property="Icon" Value="CodeMap_PhoneProject" />
</Style>
<Style TargetType="Node" GroupLabel="Portable Library" ValueLabel="Portable Library">
<Condition Expression="HasCategory('CodeMap_PortableLibraryProject')" />
<Setter Property="Icon" Value="CodeMap_PortableLibraryProject" />
</Style>
<Style TargetType="Node" GroupLabel="WPF Project" ValueLabel="WPF Project">
<Condition Expression="HasCategory('CodeMap_WpfProject')" />
<Setter Property="Icon" Value="CodeMap_WpfProject" />
</Style>
<Style TargetType="Node" GroupLabel="VSIX Project" ValueLabel="VSIX Project">
<Condition Expression="HasCategory('CodeMap_VsixProject')" />
<Setter Property="Icon" Value="CodeMap_VsixProject" />
</Style>
<Style TargetType="Node" GroupLabel="Modeling Project" ValueLabel="Modeling Project">
<Condition Expression="HasCategory('CodeMap_ModelingProject')" />
<Setter Property="Icon" Value="CodeMap_ModelingProject" />
</Style>
<Style TargetType="Node" GroupLabel="Assembly" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Assembly')" />
<Setter Property="Background" Value="#FF094167" />
<Setter Property="Stroke" Value="#FF094167" />
<Setter Property="Icon" Value="CodeSchema_Assembly" />
</Style>
<Style TargetType="Node" GroupLabel="Namespace" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Namespace')" />
<Setter Property="Background" Value="#FF0E619A" />
<Setter Property="Stroke" Value="#FF0E619A" />
<Setter Property="Icon" Value="CodeSchema_Namespace" />
</Style>
<Style TargetType="Node" GroupLabel="Interface" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Interface')" />
<Setter Property="Background" Value="#FF1382CE" />
<Setter Property="Stroke" Value="#FF1382CE" />
<Setter Property="Icon" Value="CodeSchema_Interface" />
</Style>
<Style TargetType="Node" GroupLabel="Struct" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Struct')" />
<Setter Property="Background" Value="#FF1382CE" />
<Setter Property="Stroke" Value="#FF1382CE" />
<Setter Property="Icon" Value="CodeSchema_Struct" />
</Style>
<Style TargetType="Node" GroupLabel="Enumeration" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Enum')" />
<Setter Property="Background" Value="#FF1382CE" />
<Setter Property="Stroke" Value="#FF1382CE" />
<Setter Property="Icon" Value="CodeSchema_Enum" />
<Setter Property="LayoutSettings" Value="List" />
</Style>
<Style TargetType="Node" GroupLabel="Delegate" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Delegate')" />
<Setter Property="Background" Value="#FF1382CE" />
<Setter Property="Stroke" Value="#FF1382CE" />
<Setter Property="Icon" Value="CodeSchema_Delegate" />
</Style>
<Style TargetType="Node" GroupLabel="Class" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Type')" />
<Setter Property="Background" Value="#FF0E70C0" />
<Setter Property="Stroke" Value="#FF0E70C0" />
<Setter Property="Icon" Value="CodeSchema_Class" />
</Style>
<Style TargetType="Node" GroupLabel="Property" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Property')" />
<Setter Property="Background" Value="#FFE0E0E0" />
<Setter Property="Stroke" Value="#FFE0E0E0" />
<Setter Property="Icon" Value="CodeSchema_Property" />
</Style>
<Style TargetType="Node" GroupLabel="Method" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Method') Or HasCategory('CodeSchema_CallStackUnresolvedMethod')" />
<Setter Property="Background" Value="#FFE0E0E0" />
<Setter Property="Stroke" Value="#FFE0E0E0" />
<Setter Property="Icon" Value="CodeSchema_Method" />
<Setter Property="LayoutSettings" Value="List" />
</Style>
<Style TargetType="Node" GroupLabel="Event" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Event')" />
<Setter Property="Background" Value="#FFE0E0E0" />
<Setter Property="Stroke" Value="#FFE0E0E0" />
<Setter Property="Icon" Value="CodeSchema_Event" />
</Style>
<Style TargetType="Node" GroupLabel="Field" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Field')" />
<Setter Property="Background" Value="#FFE0E0E0" />
<Setter Property="Stroke" Value="#FFE0E0E0" />
<Setter Property="Icon" Value="CodeSchema_Field" />
</Style>
<Style TargetType="Node" GroupLabel="Out Parameter" ValueLabel="Has category">
<Condition Expression="CodeSchemaProperty_IsOut = 'True'" />
<Setter Property="Icon" Value="CodeSchema_OutParameter" />
</Style>
<Style TargetType="Node" GroupLabel="Parameter" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Parameter')" />
<Setter Property="Icon" Value="CodeSchema_Parameter" />
</Style>
<Style TargetType="Node" GroupLabel="Local Variable" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_LocalExpression')" />
<Setter Property="Icon" Value="CodeSchema_LocalExpression" />
</Style>
<Style TargetType="Node" GroupLabel="Externals" ValueLabel="Has category">
<Condition Expression="HasCategory('Externals')" />
<Setter Property="Background" Value="#FF424242" />
<Setter Property="Stroke" Value="#FF424242" />
</Style>
<Style TargetType="Link" GroupLabel="Inherits From" ValueLabel="True">
<Condition Expression="HasCategory('InheritsFrom')" />
<Setter Property="Stroke" Value="#FF00A600" />
<Setter Property="StrokeDashArray" Value="2 0" />
<Setter Property="DrawArrow" Value="true" />
</Style>
<Style TargetType="Link" GroupLabel="Implements" ValueLabel="True">
<Condition Expression="HasCategory('Implements')" />
<Setter Property="Stroke" Value="#8000A600" />
<Setter Property="StrokeDashArray" Value="2 2" />
<Setter Property="DrawArrow" Value="true" />
</Style>
<Style TargetType="Link" GroupLabel="Calls" ValueLabel="True">
<Condition Expression="HasCategory('CodeSchema_Calls')" />
<Setter Property="Stroke" Value="#FFFF00FF" />
<Setter Property="StrokeDashArray" Value="2 0" />
<Setter Property="DrawArrow" Value="true" />
</Style>
<Style TargetType="Link" GroupLabel="Function Pointer" ValueLabel="True">
<Condition Expression="HasCategory('CodeSchema_FunctionPointer')" />
<Setter Property="Stroke" Value="#FFFF00FF" />
<Setter Property="StrokeDashArray" Value="2 2" />
<Setter Property="DrawArrow" Value="true" />
</Style>
<Style TargetType="Link" GroupLabel="Field Read" ValueLabel="True">
<Condition Expression="HasCategory('CodeSchema_FieldRead')" />
<Setter Property="Stroke" Value="#FF00AEEF" />
<Setter Property="StrokeDashArray" Value="2 2" />
<Setter Property="DrawArrow" Value="true" />
</Style>
<Style TargetType="Link" GroupLabel="Field Write" ValueLabel="True">
<Condition Expression="HasCategory('CodeSchema_FieldWrite')" />
<Setter Property="Stroke" Value="#FF00AEEF" />
<Setter Property="DrawArrow" Value="true" />
<Setter Property="IsHidden" Value="false" />
</Style>
<Style TargetType="Link" GroupLabel="Inherits From" ValueLabel="True" Visibility="Hidden">
<Condition Expression="HasCategory('InheritsFrom') And Target.HasCategory('CodeSchema_Class')" />
<Setter Property="TargetDecorator" Value="OpenArrow" />
</Style>
<Style TargetType="Link" GroupLabel="Implements" ValueLabel="True" Visibility="Hidden">
<Condition Expression="HasCategory('Implements') And Target.HasCategory('CodeSchema_Interface')" />
<Setter Property="TargetDecorator" Value="OpenArrow" />
</Style>
<Style TargetType="Link" GroupLabel="Comment Link" ValueLabel="True" Visibility="Hidden">
<Condition Expression="Source.HasCategory('Comment')" />
<Setter Property="Stroke" Value="#FFE5C365" />
</Style>
<Style TargetType="Node" GroupLabel="Cursor Location Changed" ValueLabel="True" Visibility="Hidden">
<Condition Expression="IsCursorLocation" />
<Setter Property="IndicatorWest" Value="WestIndicator" />
</Style>
<Style TargetType="Node" GroupLabel="Disabled Breakpoint Location Changed" ValueLabel="True" Visibility="Hidden">
<Condition Expression="DisabledBreakpointCount" />
<Setter Property="IndicatorWest" Value="WestIndicator" />
</Style>
<Style TargetType="Node" GroupLabel="Enabled Breakpoint Location Changed" ValueLabel="True" Visibility="Hidden">
<Condition Expression="EnabledBreakpointCount" />
<Setter Property="IndicatorWest" Value="WestIndicator" />
</Style>
<Style TargetType="Node" GroupLabel="Instruction Pointer Location Changed" ValueLabel="True" Visibility="Hidden">
<Condition Expression="IsInstructionPointerLocation" />
<Setter Property="IndicatorWest" Value="WestIndicator" />
</Style>
<Style TargetType="Node" GroupLabel="Current Callstack Changed" ValueLabel="True" Visibility="Hidden">
<Condition Expression="IsCurrentCallstackFrame" />
<Setter Property="IndicatorWest" Value="WestIndicator" />
</Style>
<Style TargetType="Link" GroupLabel="Return" ValueLabel="True" Visibility="Hidden">
<Condition Expression="HasCategory('CodeSchema_ReturnTypeLink')" />
</Style>
<Style TargetType="Link" GroupLabel="References" ValueLabel="True" Visibility="Hidden">
<Condition Expression="HasCategory('References')" />
</Style>
<Style TargetType="Link" GroupLabel="Uses Attribute" ValueLabel="True" Visibility="Hidden">
<Condition Expression="HasCategory('CodeSchema_AttributeUse')" />
</Style>
<Style TargetType="Node" GroupLabel="Solution Folder" ValueLabel="True" Visibility="Hidden">
<Condition Expression="HasCategory('CodeMap_SolutionFolder')" />
<Setter Property="Background" Value="#FFDEBA83" />
</Style>
<Style TargetType="Link" GroupLabel="Project Reference" ValueLabel="Project Reference">
<Condition Expression="HasCategory('CodeMap_ProjectReference')" />
<Setter Property="Stroke" Value="#9A9A9A" />
<Setter Property="StrokeDashArray" Value="2 2" />
<Setter Property="DrawArrow" Value="true" />
</Style>
<Style TargetType="Link" GroupLabel="External Reference" ValueLabel="External Reference">
<Condition Expression="HasCategory('CodeMap_ExternalReference')" />
<Setter Property="Stroke" Value="#9A9A9A" />
<Setter Property="StrokeDashArray" Value="2 2" />
<Setter Property="DrawArrow" Value="true" />
</Style>
</Styles>
<Paths>
<Path Id="02eeba8c-7b22-4bc3-bf3a-8de23eaf2e61.OutputPath" Value="C:\Users\robert.nelsen\Desktop\DataPro\SourceCode\DataPro_Diagraming\DataPRO\DASFactory\bin\Debug\DASFactory.dll" />
<Path Id="02eeba8c-7b22-4bc3-bf3a-8de23eaf2e61.OutputPathUri" Value="file:///C:/Users/robert.nelsen/Desktop/DataPro/SourceCode/DataPro_Diagraming/DataPRO/DASFactory/bin/Debug/DASFactory.dll" />
<Path Id="14b4a79f-a4b5-4c4c-a041-0105eed82782.OutputPath" Value="C:\Users\robert.nelsen\Desktop\DataPro\SourceCode\DataPro_Diagraming\DataPRO\TDASCommands\bin\Debug\TDASCommands.dll" />
<Path Id="14b4a79f-a4b5-4c4c-a041-0105eed82782.OutputPathUri" Value="file:///C:/Users/robert.nelsen/Desktop/DataPro/SourceCode/DataPro_Diagraming/DataPRO/TDASCommands/bin/Debug/TDASCommands.dll" />
<Path Id="53abd0f3-7d8d-43cd-99d7-06c45246d93e.OutputPath" Value="C:\Users\robert.nelsen\Desktop\DataPro\SourceCode\DataPro_Diagraming\DataPRO\RibeyeCommands\bin\Debug\Ribeye Commands.dll" />
<Path Id="53abd0f3-7d8d-43cd-99d7-06c45246d93e.OutputPathUri" Value="file:///C:/Users/robert.nelsen/Desktop/DataPro/SourceCode/DataPro_Diagraming/DataPRO/RibeyeCommands/bin/Debug/Ribeye Commands.dll" />
<Path Id="58e70872-8acc-4957-bb8e-d3746bcc536d.OutputPath" Value="C:\Users\robert.nelsen\Desktop\DataPro\SourceCode\DataPro_Diagraming\DataPRO\ICommand\bin\Debug\ICommand.dll" />
<Path Id="58e70872-8acc-4957-bb8e-d3746bcc536d.OutputPathUri" Value="file:///C:/Users/robert.nelsen/Desktop/DataPro/SourceCode/DataPro_Diagraming/DataPRO/ICommand/bin/Debug/ICommand.dll" />
<Path Id="8baa9433-8034-4fde-822c-537c59d3a7ec.OutputPath" Value="C:\Users\robert.nelsen\Desktop\DataPro\SourceCode\DataPro_Diagraming\DataPRO\DataPRO\bin\Debug\DataPRO.exe" />
<Path Id="8baa9433-8034-4fde-822c-537c59d3a7ec.OutputPathUri" Value="file:///C:/Users/robert.nelsen/Desktop/DataPro/SourceCode/DataPro_Diagraming/DataPRO/DataPRO/bin/Debug/DataPRO.exe" />
<Path Id="c9c45b72-05a3-4962-bc13-a78b1f4b1925.OutputPath" Value="C:\Users\robert.nelsen\Desktop\DataPro\SourceCode\DataPro_Diagraming\DataPRO\IService\bin\Debug\IService.dll" />
<Path Id="c9c45b72-05a3-4962-bc13-a78b1f4b1925.OutputPathUri" Value="file:///C:/Users/robert.nelsen/Desktop/DataPro/SourceCode/DataPro_Diagraming/DataPRO/IService/bin/Debug/IService.dll" />
<Path Id="d015f93d-9507-4484-977b-4cf1bdc0b30e.OutputPath" Value="C:\Users\robert.nelsen\Desktop\DataPro\SourceCode\DataPro_Diagraming\DataPRO\SLICECommands\bin\Debug\SLICECommands.dll" />
<Path Id="d015f93d-9507-4484-977b-4cf1bdc0b30e.OutputPathUri" Value="file:///C:/Users/robert.nelsen/Desktop/DataPro/SourceCode/DataPro_Diagraming/DataPRO/SLICECommands/bin/Debug/SLICECommands.dll" />
<Path Id="dea48a0b-999e-48e8-8601-cb05b6b765de.OutputPath" Value="C:\Users\robert.nelsen\Desktop\DataPro\SourceCode\DataPro_Diagraming\DataPRO\SLICEDBCommands\bin\Debug\SliceDBCommands.dll" />
<Path Id="dea48a0b-999e-48e8-8601-cb05b6b765de.OutputPathUri" Value="file:///C:/Users/robert.nelsen/Desktop/DataPro/SourceCode/DataPro_Diagraming/DataPRO/SLICEDBCommands/bin/Debug/SliceDBCommands.dll" />
</Paths>
</DirectedGraph>

View File

@@ -0,0 +1,238 @@
using DTS.Common.Interface.DASFactory;
using System;
using System.Collections.Generic;
using System.Linq;
using static DTS.Common.Enums.DASFactory.DFConstantsAndEnums;
namespace DTS.DASLib.Command.Classes
{
/// <summary>
/// DiscoveredDevice class is used by the multicast autodiscovery mechanism to describe response payload from devices
/// </summary>
public class DiscoveredDevice : IDiscoveredDevice, IComparable<DiscoveredDevice>
{
//Addresses are strings so SortableBindingList can be used unmodified
#region UDP payload properties
/// <summary>
/// Device Serial Number
/// </summary>
public string Serial { get; set; }
/// <summary>
/// Device type
/// </summary>
public MultiCastDeviceClasses DevClass { get; set; }
/// <summary>
/// Device Mac
/// </summary>
public string Mac { get; set; }
public IDiscoveredDevice Parent { get; set; }
public bool IsParent(IDiscoveredDevice possibleChild)
{
if (null == Connections)
{
return false;
}
var matches = from connection in Connections where connection.MACAddress == possibleChild.Mac select connection;
var connectedEthernetDevices = matches as ConnectedEthernetDevice[] ?? matches.ToArray();
if (!connectedEthernetDevices.Any()) { return false; }
//if it matches it's our DIRECT uplink/parent if it contains all of our children and no other children ON THIS PORT.
var port = connectedEthernetDevices[0].Port;
var childrenOnPort = from connection in Connections where connection.Port == port select connection;
return childrenOnPort.Count() == 1 + possibleChild.Connections.Length;
}
public int GetPort(IDiscoveredDevice device)
{
var matches = from connection in Connections where connection.MACAddress == device.Mac select connection;
var connectedEthernetDevices = matches as ConnectedEthernetDevice[] ?? matches.ToArray();
if (!connectedEthernetDevices.Any()) { return -1; }
return connectedEthernetDevices[0].Port;
}
private List<IDiscoveredDevice> _orderedList = null;
public int GetSlot(IDiscoveredDevice child, Dictionary<string, IDiscoveredDevice> lookup)
{
if (null == _orderedList)
{
_orderedList = new List<IDiscoveredDevice>();
foreach (var macAddress in Connections.Select(x => x.MACAddress))
{
if (!lookup.ContainsKey(macAddress)) continue;
var device = lookup[macAddress];
if (null == device) continue;
_orderedList.Add(device);
_orderedList.Sort(new DiscoveredChildrenSorter());
}
}
var slot = _orderedList.IndexOf(child);
return slot <= 0 ? 1 : 1 + slot;
}
public int GetSlotOnPort(IDiscoveredDevice child, Dictionary<string, IDiscoveredDevice> lookup)
{
var matches = from device in _orderedList where device.Port == child.Port select device;
var slotOnPort = matches.ToList().IndexOf(child);
return slotOnPort <= 0 ? 1 : 1 + slotOnPort;
}
/// <summary>
/// so what we want here is first alphabetic by ultimate parent, then
/// by slot within each parent
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
public int CompareTo(DiscoveredDevice other)
{
var myUltimateParent = GetParent(this);
var otherUltimateParent = GetParent(other);
if (null == myUltimateParent && null == otherUltimateParent)
{
//both SLICE6dbs or both without a chain...
return String.Compare(Serial, other.Serial, StringComparison.Ordinal);
}
if (null == myUltimateParent)
{
if (otherUltimateParent == this)
{
return -1;
}
return string.Compare(Serial, otherUltimateParent.Serial, StringComparison.Ordinal);
}
if (null == otherUltimateParent)
{
if (myUltimateParent == other)
{
return 1;
}
return string.Compare(myUltimateParent.Serial, other.Serial, StringComparison.Ordinal);
}
//we both have parents, if they aren't the same, then use their serial numbers
if (myUltimateParent != otherUltimateParent)
{
return string.Compare(myUltimateParent.Serial, otherUltimateParent.Serial, StringComparison.Ordinal);
}
//same parent, first compare port
if (Port != other.Port) { return Port.CompareTo(other.Port); }
//on same port, then use slot
return PositionOnDistributor.CompareTo(other.PositionOnDistributor);
}
public static IDiscoveredDevice GetParent(IDiscoveredDevice device)
{
var target = device;
while (null != target.Parent) { target = target.Parent; }
return target != device ? target : null;
}
public class DiscoveredChildrenSorter : IComparer<IDiscoveredDevice>
{
int IComparer<IDiscoveredDevice>.Compare(IDiscoveredDevice x, IDiscoveredDevice y)
{
if (x == y) { return 0; }
if (null == x) { return -1; }
if (null == y) { return 1; }
return x.Port != y.Port ? x.Port.CompareTo(y.Port) : y.Connections.Length.CompareTo(x.Connections.Length);
}
}
public bool IsModule { get; set; }
/// <summary>
/// if I'm on a SLICE6DB, what port am I on
/// </summary>
public int Port { get; set; }
/// <summary>
/// starting at the first device in the chain on the first point, up until the last device on the last chain/port, where is this device
/// this is used to as we don't show SLICE6 devices when on a SLICE6Db, but we still need to know which devices is where for showing
/// the channels in the UI
/// </summary>
public int PositionOnDistributor { get; set; }
/// <summary>
/// where is this device in a chain of devices, only used for SLICE6 on a SLICE6Db right now
/// </summary>
public int PositionOnChain { get; set; }
/// <summary>
/// Is DHCP enabled
/// </summary>
public bool Dhcp { get; set; }
/// <summary>
/// Device IP
/// </summary>
public string Ip { get; set; }
/// <summary>
/// Device Subnet
/// </summary>
public string Subnet { get; set; }
/// <summary>
/// Device Gateway
/// </summary>
public string Gateway { get; set; }
/// <summary>
/// Device DNS Sever
/// </summary>
public string Dns { get; set; }
/// <summary>
/// Is Device connected to another host
/// </summary>
public bool Connected { get; set; }
/// <summary>
/// Host IP that device is connected to
/// </summary>
public string ConnectedIp { get; set; }
/// <summary>
/// Host Name Resolution that device is connected to
/// </summary>
public string ConnectedHost { get; set; }
/// <summary>
/// User entry for Distributor ID that device is connected to
/// </summary>
public ushort SystemId { get; set; }
/// <summary>
/// User entry for location of device
/// </summary>
public string Location { get; set; }
/// <summary>
/// Firmware version string
/// [Product Name]-[FW/BL]-[REL/DBG]-[Board #]-[FW Ver Name]
/// </summary>
public string FirmwareVersion { get; set; }
/// <summary>
/// Build Server number for the firmware
/// </summary>
public string BuildId { get; set; }
#endregion
public IConnectedEthernetDevice[] Connections { get; set; }
public DiscoveredDevice()
{
Connections = new IConnectedEthernetDevice[0];
}
}
public class ConnectedEthernetDevice : IConnectedEthernetDevice
{
public string MACAddress { get; }
public int Port { get; }
public ConnectedEthernetDevice(string macAddress, int port) { MACAddress = macAddress; Port = port; }
public string SerialNumber { get; set; }
}
}

View File

@@ -0,0 +1,60 @@
using System;
using System.Text;
// ReSharper disable InconsistentNaming
namespace DTS.DASLib.Command
{
/// <summary>
/// this is an abstraction of the LogEntryBase classes, I extracted the common
/// functionality and put it here
/// this class in turn is used by SliceCommandLogEntry and CommonLogEntry(ribeye)
/// the reason for the additional classes is the structure of the packets and how the log looks
/// differs slightly between ribeye and slice
/// I'm not sure these classes are in use?
/// 6/14/2010 - dtm
/// </summary>
public abstract class CommandLogEntryBase
{
protected StringBuilder sb;
protected CommandPacketBase command;
/// <summary>
/// construct a CommandLogEntryBase object
/// </summary>
/// <param name="_command">underlying command</param>
public CommandLogEntryBase(CommandPacketBase _command)
{
sb = new StringBuilder();
command = _command;
sb.AppendFormat("=== {0:08d} ==={1}", _command.SequenceNumber, Environment.NewLine);
}
/// <summary>
/// adds command data into log
/// </summary>
/// <param name="CommandName"></param>
public void TagCommonCommandData(string CommandName)
{
sb.AppendFormat("Log Entry Type:\t\t{0} command{1}", CommandName, Environment.NewLine);
}
/// <summary>
/// adds response data into log
/// </summary>
/// <param name="CommandName"></param>
public void TagCommonResponseData(string CommandName)
{
sb.AppendFormat("Response Status:\t\t{0}{1}", command.Status, Environment.NewLine);
sb.AppendFormat("Response Timestamp:\t{0} {1}{2}", DateTime.Now.ToShortDateString(),
DateTime.Now.ToLongTimeString(), Environment.NewLine);
}
/// <summary>
/// returns the log entry represented as a string
/// </summary>
/// <returns></returns>
public override string ToString()
{
return sb.ToString();
}
}
}

View File

@@ -0,0 +1,321 @@
using System;
using System.Collections.Generic;
using System.Text;
using DTS.Common.DASResource;
using DTS.Common.Enums.DASFactory;
namespace DTS.DASLib.Command
{
/// <summary>
/// this is an abstraction of the common functions and behaviors of the CommandPackets
/// 6/14/2010 - dtm
/// </summary>
public abstract class CommandPacketBase
{
/// <summary>
/// the state of command packet
/// </summary>
public enum PacketState
{
#pragma warning disable 1591
OK,
TooShort,
Unknown
#pragma warning restore 1591
};
/// <summary>
/// corresponding strings for CommandStatus enum
/// </summary>
public static String[] StatusLabels =
{
#pragma warning disable 1591
// 0x00
Strings.CmdStatusNoErr,
// 0x01
Strings.CmdStatusInvalidParam,
// 0x02
Strings.CmdStatusInvalidParamLen,
// 0x03
Strings.CmdStatusInvalidCmdType,
// 0x04
Strings.CmdStatusInvalidCmd,
// 0x05
Strings.CmdStatusInvalidCRC,
// 0x06
Strings.CmdStatusInvalidCmdMode,
// 0x07
Strings.CmdStatusUnimplemented,
// 0x08
Strings.CmdStatusInvalidRecCRC,
// 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
Strings.CmdStatusInvalidDevID,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0x10
Strings.CmdStatusFlashErase,
// 0x11
Strings.CmdStatusFlashWrite,
// 0x12
Strings.CmdStatusFlashBlockCRC,
// 0x13
Strings.CmdStatusFlashImageCRC,
// 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0x20
Strings.CmdStatusInvalidAttrib,
// 0x21
Strings.CmdStatusAttribSet,
// 0x22
Strings.CmdStatusAttribBackup,
// 0x23
Strings.CmdStatusAttribBuffer,
// 0x24 - 0x2F
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0x30 - 0x3F
Strings.CmdStatusSampleRate,
Strings.CmdStatusEventLen,
Strings.CmdStatusArmMode,
Strings.CmdStatusUnimplArmMode,
Strings.CmdStatusEventTooLarge,
Strings.CmdStatusMemFull,
Strings.CmdStatusInvalidSliceCount,
Strings.CmdStatusShortedStart,
Strings.CmdStatusShortedTrigger,
Strings.CmdStatusInvalidPreTrig,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0x40 - 0x4F
Strings.CmdStatusStartSDWrite,
Strings.CmdStatusFlushSDBlock,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0x50 - 0x5F
Strings.CmdStatusSwitchReq,
Strings.CmdStatusSwitchSetting,
Strings.CmdStatusSwitchChannel,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0x60 - 0x6F
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0x70 - 0x7F
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0x80 - 0x8F
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0x90 - 0x9F
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0xA0 - 0xAF
Strings.CmdStatusSlicebusInvalidHeaderCRC,
Strings.CmdStatusSlicebusInvalidDataCRC,
Strings.CmdStatusSlicebusNullDescriptor,
Strings.CmdStatusSlicebusNotImplemented,
Strings.CmdStatusSlicebusNoResponse,
Strings.CmdStatusSlicebusNullCommandBuffer,
Strings.CmdStatusSlicebusCommandBufferTooShort,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0xB0 - 0xBF
Strings.CmdStatusSetupRequestedSensorRangeTooSmall,
Strings.CmdStatusSetupInvalidStackChannel,
Strings.CmdStatusSetupInvalidChannelRequested,
Strings.CmdStatusSetupInconsistentChannelCountFound,
Strings.CmdStatusSetupNoShuntTargetsSet,
Strings.CmdStatusSetupNoBridgeResistancesSet,
Strings.CmdStatusSetupChannelDoesNotSupportShunt,
Strings.CmdStatusSetupShuntDACOutputExceeded,
Strings.CmdStatusSetupRequestedSensorRangeTooLarge,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0xC0 - 0xCF
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0xD0 - 0xDF
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0xE0 - 0xEF
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0xF0 - 0xFF
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
#pragma warning restore 1591
};
/// <summary>
/// the status of the packet
/// </summary>
public DFConstantsAndEnums.CommandStatus Status;
/// <summary>
/// the command, use SetCommand to assign
/// </summary>
private byte _Command;
/// <summary>
/// string description of the command, for logging
/// </summary>
private string _CommandDescription;
/// <summary>
/// assigns a command to the packet structure
/// </summary>
/// <param name="command">byte command information</param>
/// <param name="commandDescription">string describing command</param>
public void SetCommand(byte command, string commandDescription)
{
_Command = command;
_CommandDescription = commandDescription;
}
/// <summary>
/// returns command (byte) information
/// </summary>
/// <returns></returns>
public byte GetCommand() { return _Command; }
/// <summary>
/// returns a string description of command
/// </summary>
/// <returns></returns>
public string GetCommandDescription() { return _CommandDescription; }
/// <summary>
/// wether or not to log
/// </summary>
public bool ShouldLog;
public bool AlreadyRun { get; set; }
public byte[] OriginalBytes;
/// <summary>
/// the command put into byte array form, for executing to hardware
/// </summary>
/// <returns></returns>
public abstract byte[] ToBytes();
/// <summary>
/// this is an enum CommandType, inheritting classes implement CommandType themselves, so
/// the we don't know the possible values of the enum in the base class,
/// however we do know we'll need to store and use the enum value
/// </summary>
public object Type;
/// <summary>
/// produce a string representing the command
/// </summary>
/// <returns>formatted string</returns>
public override string ToString()
{
return GetCommand().ToString();
//return this.Command.ToString();
}
public UInt16 SequenceNumber;
/// <summary>
/// each CommandPacket can have it's own enum of commandtypes
/// so, we just let the inheritting classes define them on their own
/// and just request a method of getting the resulting object post
/// conversion back
/// </summary>
/// <param name="b">byte to be converted</param>
/// <returns>CommandType, an enum contained in inheritting classes</returns>
public abstract object ConvertByteToCommandType(byte b);
/// <summary>
/// verify if the packet is valid or not
/// </summary>
/// <param name="Bytes"></param>
/// <returns></returns>
public abstract PacketState VerifyPacket(byte[] Bytes);
/// <summary>
/// get the next sequence number.
/// note sliceDB, slice, and ribeye all have different counters for
/// packets, so they could all have a sequence #1 independently
/// </summary>
public abstract void GetNextSequenceNumber();
/// <summary>
/// triggers the packet's logic to compute a checksum or CRC
/// different packets may use different methods (slice-crc, ribeye-checksum)
/// </summary>
public abstract void ComputeCRCs();
/// <summary>
/// formats a header for the log entry for the response packet
/// incoming (response) packets may have less information, so the
/// associated outgoing packet is also passed in
/// </summary>
/// <param name="commandPacket">outgoing command packet</param>
/// <param name="lines">two dimensional array of string log data</param>
public void GetPacketLogHeader(CommandPacketBase commandPacket, ref List<List<string>> lines, DateTime executeTime)
{
lines.Add(new List<string>());
string type = null != Type ? Type.ToString() : "";
ushort sequence = SequenceNumber;
if (0 == sequence && null != commandPacket) { sequence = commandPacket.SequenceNumber; }
var sSequence = $"[{sequence.ToString("00000000")}]\\[{SequenceNumber.ToString("00000000")}]";
lines[0].Add(string.Format("{0} - {1} {2} - ({3}ms)", type, commandPacket.GetCommandDescription(), sSequence, DateTime.Now.Subtract(executeTime).TotalMilliseconds));
if (Status != DFConstantsAndEnums.CommandStatus.StatusNoError)
{
lines.Add(new List<string>() { Status.ToString() });
}
}
/// <summary>
/// returns a header for the log entry for a command packet
/// </summary>
/// <param name="lines">two dimensional array of string log data</param>
public void GetPacketLogHeader(ref List<List<string>> lines)
{
lines.Add(new List<string>());
lines[0].Add(string.Format("{0} - {1} [{2:00000000}]", Type.ToString(), GetCommandDescription(), SequenceNumber));
if (Status != DFConstantsAndEnums.CommandStatus.StatusNoError)
{
lines.Add(new List<string>() { Status.ToString() });
}
}
}
}

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace DTS.DASLib.Command
{
public enum CommandStatus
{
Success,
Failure,
Canceled
}
public enum CommandErrorReason
{
SendFailed,
ReceiveFailed,
InvalidMode,
Canceled
}
public class CommandException : ApplicationException
{
public CommandErrorReason Error { get; set; }
public CommandException(CommandErrorReason _err)
{
Error = _err;
}
public CommandException(CommandErrorReason _err, string msg)
: base(msg)
{
Error = _err;
}
}
public enum CommandReceiveAction
{
StopReceiving,
ContinueReceiving
}
public interface ICommandReport
{
object CallbackObject { get; set; }
CommandStatus Status { get; set; }
}
public delegate CommandReceiveAction CommandCallback(ICommandReport report);
public interface ICommand
{
void Execute(CommandCallback Callback,
object CallbackObject);
void SyncExecute();
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace DTS.DASLib.Command
{
/// <summary>
/// class encapsulating the return status and value from a command
/// 6/14/2010 - dtm
/// </summary>
public class CommandReport : ICommandReport
{
public object CallbackObject { get; set; }
public CommandStatus Status { get; set; }
public CommandReport(CommandStatus _Status, object _CallbackObject)
{
Status = _Status;
CallbackObject = _CallbackObject;
}
}
}

View File

@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="DTS.DASLib.Command.AbstractCommandBase" Collapsed="true">
<Position X="3.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>IkAKwgFVAAMAAUyAwIACIIBCACAAIAgEDAUQCWBTIEg=</HashCode>
<FileName>AbstractCommandBase.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="DTS.DASLib.Command.CommandLogEntryBase" Collapsed="true">
<Position X="7.75" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAGAAAAAAAEAAQAAAAAAAAAAAAQAAA=</HashCode>
<FileName>CommandLogEntryBase.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.CommandPacketBase" Collapsed="true">
<Position X="0.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>EAAAAAGEAAAAAAAMAAiBABQAAAAAACAAAwkAAQBAAAA=</HashCode>
<FileName>CommandPacketBase.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.CommandReport" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="9.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAA=</HashCode>
<FileName>CommandReport.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" Collapsed="true" />
</Class>
<Class Name="DTS.DASLib.Command.CommandException" Collapsed="true">
<Position X="6" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.SliceCommandBase" Collapsed="true">
<Position X="3.5" Y="1.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AgAAAECAAIAAAQAAAAAAAABEAAQAAAAAAAAAEAAAAEA=</HashCode>
<FileName>SliceCommandBase.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.SliceCommandPacketBase" Collapsed="true">
<Position X="0.5" Y="1.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAQAQCAAIAwAgEoEQAABIAAEEgRAGAEAAAAEAAAAAA=</HashCode>
<FileName>SliceCommandPacketBase.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Classes.DiscoveredDevice" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="7.75" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>ABEIQAAAAJAAQAQABAIAYgAkGBAQAICAAAACICQAIAA=</HashCode>
<FileName>Classes\DiscoveredDevice.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" Collapsed="true" />
</Class>
<Class Name="DTS.DASLib.Command.Classes.ConnectedEthernetDevice" Collapsed="true">
<Position X="6" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAACAEAAACAAAAAAAAAAAA=</HashCode>
<FileName>Classes\DiscoveredDevice.cs</FileName>
</TypeIdentifier>
</Class>
<Interface Name="DTS.DASLib.Command.ICommandReport" Collapsed="true">
<Position X="7.75" Y="2.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="DTS.DASLib.Command.ICommand" Collapsed="true">
<Position X="6" Y="2.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AgAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Interface>
<Enum Name="DTS.DASLib.Command.CommandStatus" Collapsed="true">
<Position X="9.5" Y="3.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAgAAAAAAAAgAAAACAAAAAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Enum>
<Enum Name="DTS.DASLib.Command.CommandErrorReason" Collapsed="true">
<Position X="6" Y="3.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAIAgAAAAAAAAAAAAAAAAAEAAAACAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Enum>
<Enum Name="DTS.DASLib.Command.CommandReceiveAction" Collapsed="true">
<Position X="7.75" Y="3.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAACAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Enum>
<Delegate Name="DTS.DASLib.Command.CommandCallback" Collapsed="true">
<Position X="6" Y="4.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Delegate>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>

View File

@@ -0,0 +1,104 @@
using DTS.Common.Interface.DASFactory;
using System;
namespace DTS.DASLib.Command.Classes
{
public class UDPQATSEntry : IUDPQATSEntry
{
public string ResponseHostMac { get; private set; }
public string ResponseClientMacAddress { get; private set; }
public string SerialNumber { get; private set; }
public byte ArmState { get; private set; }
public byte ArmMode { get; private set; }
public byte Started { get; private set; }
public byte Triggered { get; private set; }
public byte FaultFlags { get; private set; }
public uint SampleRate { get; private set; }
public ulong TotalSamples { get; private set; }
public ulong CurrentSample { get; private set; }
public ushort EventNumber { get; private set; }
public ulong FaultSampleNumber { get; private set; }
public ushort LegacyFaultFlags { get; private set; }
public float InputVoltage { get; private set; }
public float BackupVoltage { get; private set; }
public float BatterySOC { get; private set; }
public ulong EstimateMaxSamples { get; private set; }
public short TiltSensorCh1 { get; private set; }
public short TiltSensorCh2 { get; private set; }
public short TiltSensorCh3 { get; private set; }
public float SysTempC { get; private set; }
public byte SyncClockEnable { get; private set; }
public byte ADCExtClockSyncEnable { get; private set; }
public byte SyncClockStatus { get; private set; }
public byte ADCExtClockSyncStatus { get; private set; }
public ulong EventTriggerSample { get; private set; }
public float[] ChannelOffsetMV { get; private set; } = new float[6];
public float[] ShuntDeviationPercent { get; private set; } = new float[6];
public DateTime Timestamp { get; private set; } = DateTime.Now;
public UDPQATSEntry(string responseHostMac,
string responseClientMacAddress,
string serialNumber,
byte armState,
byte armMode,
byte started,
byte triggered,
byte faultFlags,
uint sampleRate,
ulong totalSamples,
ulong currentSample,
ushort eventNumber,
ulong faultSampleNumber,
ushort legacyFaultFlags,
float inputVoltage,
float backupVoltage,
float batterySOC,
ulong estimateMaxSamples,
short tiltSensorCh1,
short tiltSensorCh2,
short tiltSensorCh3,
float sysTempC,
byte syncClockEnable,
byte adcExtClockSyncEnable,
byte syncClockStatus,
byte adcExtClockSyncStatus,
ulong eventTriggerSample,
float[] channelOffsetMV,
float[] channelShuntDeviationPercent,
DateTime timeStamp)
{
ResponseHostMac = responseHostMac;
ResponseClientMacAddress = responseClientMacAddress;
SerialNumber = serialNumber;
ArmState = armState;
ArmMode = armMode;
Started = started;
Triggered = triggered;
FaultFlags = faultFlags;
SampleRate = sampleRate;
TotalSamples = totalSamples;
CurrentSample = currentSample;
EventNumber = eventNumber;
FaultSampleNumber = faultSampleNumber;
LegacyFaultFlags = legacyFaultFlags;
InputVoltage = inputVoltage;
BackupVoltage = backupVoltage;
BatterySOC = batterySOC;
EstimateMaxSamples = estimateMaxSamples;
TiltSensorCh1 = tiltSensorCh1;
TiltSensorCh2 = tiltSensorCh2;
TiltSensorCh3 = tiltSensorCh3;
SysTempC = sysTempC;
SyncClockEnable = syncClockEnable;
ADCExtClockSyncEnable = adcExtClockSyncEnable;
SyncClockStatus = syncClockStatus;
ADCExtClockSyncStatus = adcExtClockSyncStatus;
EventTriggerSample = eventTriggerSample;
ChannelOffsetMV = channelOffsetMV;
ShuntDeviationPercent = channelShuntDeviationPercent;
Timestamp = timeStamp;
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{58E70872-8ACC-4957-BB8E-D3746BCC536D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DTS.DASLib.Command</RootNamespace>
<AssemblyName>ICommand</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkProfile />
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Prism">
<HintPath>..\..\Common\DTS.Common\lib\PrismLibrary\Prism.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AbstractCommandBase.cs" />
<Compile Include="Classes\DiscoveredDevice.cs" />
<Compile Include="Classes\UDPQATSEntry.cs" />
<Compile Include="CommandLogEntryBase.cs" />
<Compile Include="CommandPacketBase.cs" />
<Compile Include="CommandReport.cs" />
<Compile Include="ICommand.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SliceCommandBase.cs" />
<Compile Include="SliceCommandPacketBase.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Common\DTS.Common.DASResource\DTS.Common.DASResource.csproj">
<Project>{f621ce48-bb4b-4cfc-a325-9410b721cc44}</Project>
<Name>DTS.Common.DASResource</Name>
</ProjectReference>
<ProjectReference Include="..\..\Common\DTS.Common.ICommunication\DTS.Common.ICommunication.csproj">
<Project>{f57b954e-a49a-4110-b36c-b5abab3e230b}</Project>
<Name>DTS.Common.ICommunication</Name>
</ProjectReference>
<ProjectReference Include="..\..\Common\DTS.Common.Utilities\DTS.Common.Utilities.csproj">
<Project>{d6da1b74-c711-43c2-91b1-1908a8d04dbf}</Project>
<Name>DTS.Common.Utilities</Name>
</ProjectReference>
<ProjectReference Include="..\..\Common\DTS.Common\DTS.Common.csproj">
<Project>{f7a0804f-61a4-40ae-83d0-f1137622b592}</Project>
<Name>DTS.Common</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Design\ClassDiagram_ICommand.cd" />
<None Include="Design\Graph_ReferenceAssemblies.dgml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,833 @@
//#define LOG_COMM
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Diagnostics;
using DTS.Common.DASResource;
using DTS.Common.ICommunication;
using DTS.Common.Utilities;
using DTS.Common.Utilities.Logging;
using DTS.Common.Utils;
using DTS.Common.Enums.Communication;
using DTS.Common.Interface.Communication;
using DTS.Common.Enums.DASFactory;
using DTS.Common.Events;
// ReSharper disable InconsistentNaming
namespace DTS.DASLib.Command
{
/// <summary>
/// Ribeye, SliceCommand, SliceDBCommand all contained Command objects which
/// implemented ICommand
/// I extracted as many common things as I could into one common class and formed
/// an abstract base class.
/// In general slice commands seemed to contain the most up to date code, and
/// slice db commands and ribeye seemed to contain older code, so the majority of the code
/// is actually from slice commands.
/// 6/14/10 - dtm
/// </summary>
public abstract class AbstractCommandBase : ICommand
{
// this is the buffer we use to accumulate the data coming in until we have a full
// response package.
protected SecureQueue<byte> CommandDataBuffer;
protected DTS.Common.Interface.DASFactory.ICommunication recorder;
protected ManualResetEvent SyncEvent;
protected CommandCallback UserCallback { get; set; }
protected object UserCallbackData { get; set; }
protected bool IsSynchronous { get; set; }
protected CommandPacketBase baseCommand;
protected CommandPacketBase baseResponse;
protected ICommunicationReport ComReport;
protected DFConstantsAndEnums.CommandStatus _status;
protected Type ClassType;
protected object _debuglock;
protected int current_thread_id;
protected int MinimumProtocolVersion { get; set; }
protected DateTime ExecuteTime { get; set; }
protected bool ExecuteIsBusy = false;
protected object ExecuteBusyLock = new object();
/// <summary>
/// whether to log commands or not
/// </summary>
public bool LogCommands { get; set; }
/// <summary>
/// Log Command or response
/// </summary>
/// <param name="sending">if true logs command, otherwise logs response</param>
protected virtual void LogCommand(bool sending)
{
try
{
if (!LogCommands) { return; }
APILogger.LogString(GetFormattedLogEntry(sending));
}
catch (Exception ex)
{
LogString($"threw an exception in {(sending ? "CommandToString()" : "ResponseToString()")}");
APILogger.LogException(ex);
}
}
protected virtual string MakeLogString(string msg)
{
var dasName = "<unknown>";
if (null != recorder) { dasName = recorder.ToString(); }
var cmdName = "<unknown>";
try
{
cmdName = GetType().FullName;
}
catch
{
// we use unknown
}
var sequenceNumber = "<unknown>";
try
{
sequenceNumber = baseCommand.SequenceNumber.ToString();
}
catch { }
//17686 add additional debug information into log
if (null != baseResponse)
{
sequenceNumber = $"{sequenceNumber}\\{baseResponse.SequenceNumber}";
}
return string.Format(Strings.CmdAbstractCommandGeneralFailure, dasName, cmdName, msg, sequenceNumber);
}
protected virtual void LogString(string msg)
{
APILogger.LogString(MakeLogString(msg));
}
/// <summary>
/// <see cref="CommandPacketBase.CommandStatus" /> status of command
/// </summary>
public DFConstantsAndEnums.CommandStatus Status => _status;
protected void EnqueueData(byte[] data)
{
CommandDataBuffer.Enqueue(data);
}
protected byte[] DequeueData(bool bResetEvent)
{
return CommandDataBuffer.Dequeue(bResetEvent);
}
#if LOG_COMM
private static readonly object _COMM_LOCK_ = new object();
#endif
/**
* Knuth-Morris-Pratt Algorithm for Pattern Matching
*/
class KMPMatch
{
/**
* Finds the first occurrence of the pattern in the text.
*/
public int indexOf(byte[] data, byte[] pattern, int startAddress = 0)
{
int[] failure = computeFailure(pattern);
int j = 0;
if (data.Length == 0) return -1;
for (int i = startAddress; i < data.Length; i++)
{
while (j > 0 && pattern[j] != data[i])
{
j = failure[j - 1];
}
if (pattern[j] == data[i]) { j++; }
if (j == pattern.Length)
{
return i - pattern.Length + 1;
}
}
return -1;
}
/**
* Computes the failure function using a boot-strapping process,
* where the pattern is matched against itself.
*/
private int[] computeFailure(byte[] pattern)
{
int[] failure = new int[pattern.Length];
int j = 0;
for (int i = 1; i < pattern.Length; i++)
{
while (j > 0 && pattern[j] != pattern[i])
{
j = failure[j - 1];
}
if (pattern[j] == pattern[i])
{
j++;
}
failure[i] = j;
}
return failure;
}
}
private static readonly byte[] StreamSignature = { 0xFA, 0x04, 0x07, 0x00, 0x00, 0x00, 0x10, 0xF8 };
private static readonly byte[] EndStreamSignature = { 0xFA, 0x04, 0x08, 0x00 };
private const int STREAM_PACKET_SIZE = 63518;
protected virtual CommandReceiveAction ReceiveBlockOK(ICommunicationReport report)
{
lock (_debuglock)
{
if (-1 != current_thread_id)
{
}
current_thread_id = Thread.CurrentThread.ManagedThreadId;
}
// use the buffer to assemble a bigger chunk
EnqueueData(report.Data);
var tempBuffer = DequeueData(false);
if (DFConstantsAndEnums.ExtraCommunicationLogging)
{
APILogger.Log($"ReceivedBlock {recorder?.ConnectString ?? "N/A"}", tempBuffer);
}
if (baseCommand.GetCommandDescription() == "GetNextDownloadStreamDataSamples")
{
var match = new KMPMatch();
var index = match.indexOf(tempBuffer, StreamSignature, 1);
if (index > 0)
{
var length = tempBuffer.Length - index;
var remainder = new byte[length];
Array.Copy(tempBuffer, index, remainder, 0, length);
EnqueueData(remainder);
var tmp = new byte[index];
Array.Copy(tempBuffer, 0, tmp, 0, index);
tempBuffer = tmp;
}
else
{
index = match.indexOf(tempBuffer, EndStreamSignature);
if (index >= 0)
{
var tmp = new byte[index];
Array.Copy(tempBuffer, 0, tmp, 0, index);
tempBuffer = tmp;
}
else
{
EnqueueData(tempBuffer);
return CommandReceiveAction.ContinueReceiving;
}
}
}
//there could be multiple packets in here, we have to
// a debug test
if (null != tempBuffer && tempBuffer.Length > 0 && tempBuffer[0] != 0xFA)
{
}
#if LOG_COMM
lock (_COMM_LOCK_)
{
System.IO.File.AppendAllText(@"Logs\COMM.log",
$"{DateTime.Now.Ticks} [IN] {BitConverter.ToString(tempBuffer).Replace("-", string.Empty)}\r\n");
}
#endif
// what's the state of this packet?
// - note I think the command object should be intialized and stable, but
// just incase maybe it's safer to check it before using it
// 6/14/2010 - dtm
var pState = baseCommand?.VerifyPacket(tempBuffer) ?? GetCommandPacket().VerifyPacket(tempBuffer);
if (DFConstantsAndEnums.ExtraCommunicationLogging)
{
APILogger.Log($"VerifyPacket {recorder?.ConnectString ?? "N/A"} {pState.ToString()}");
}
switch (pState)
{
case CommandPacketBase.PacketState.OK:
// perfect, a good complete packet
baseResponse = GetCommandPacket(tempBuffer);
#if LOG_COMM
lock (_COMM_LOCK_)
{
System.IO.File.AppendAllText(@"Logs\COMM.log",
$"{DateTime.Now.Ticks} [IN] [OK] seq:{baseResponse.SequenceNumber} {baseCommand.GetCommandDescription()}\r\n");
#endif
if (baseCommand.GetCommandDescription() == "EndRealtimeMode")
{
//if (baseCommand.SequenceNumber != baseResponse.SequenceNumber)
{
//look for the response
KMPMatch match = new KMPMatch();
//look for the command header for end realtime (0x08, 0x02)
//if we find it we have a response to end realtime, if not we have
//other data and should keep waiting
var target = new byte[] { 0xFA, 0x08, 0x02 };
//baseCommand.ToBytes();
var index = match.indexOf(tempBuffer, target);
if (index < 0)
{
#if LOG_COMM
System.IO.File.AppendAllText(@"Logs\COMM.log",
$"{DateTime.Now.Ticks} - NOT COMPLETE YET\r\n");
#endif
//this suggests the response we have is a realtime packet and NOT the end packet
return DataTooShort(tempBuffer);
}
else
{
#if LOG_COMM
System.IO.File.AppendAllText(@"Logs\COMM.log", $"{DateTime.Now.Ticks} - COMPLETE\r\n");
#endif
}
}
}
#if LOG_COMM
}
#endif
WholePackage();
if (IsSynchronous)
{
lock (_debuglock) { current_thread_id = -1; }
SyncEvent.Set();
}
else
{
// we're not doing a SyncExecute so we must flag the command done
recorder.ExecuteIsBusy = false;
WholePackagePost();
lock (_debuglock) { current_thread_id = -1; }
}
return CommandReceiveAction.StopReceiving;
case CommandPacketBase.PacketState.TooShort:
// not enough data, keep going
lock (_debuglock) { current_thread_id = -1; }
return DataTooShort(tempBuffer);
case CommandPacketBase.PacketState.Unknown:
// not good
if (!IsSynchronous)
{
// we're not doing a SyncExecute so we must flag the command done
recorder.ExecuteIsBusy = false;
lock (_debuglock) { current_thread_id = -1; }
return DataUnknown(report);
}
SyncEvent.Set();
return CommandReceiveAction.StopReceiving;
default:
Debug.Assert(false, "CommandBase.ReceiveBlockOK: Unhandled case " + pState.ToString());
return CommandReceiveAction.StopReceiving;
}
}
protected virtual CommandReceiveAction DataTooShort(byte[] dataSoFar)
{
// we need more data
CommandDataBuffer.Enqueue(dataSoFar);
return CommandReceiveAction.ContinueReceiving;
}
protected virtual CommandReceiveAction DataUnknown(ICommunicationReport report)
{
// a bad one
var cbReport = new CommandReport(CommandStatus.Failure, UserCallbackData);
LogString("DataUnknown: reporting failure " + report);
UserCallback(cbReport);
return CommandReceiveAction.StopReceiving;
}
protected virtual CommandReceiveAction WholePackage()
{
return CommandReceiveAction.StopReceiving;
}
protected virtual CommandReceiveAction WholePackagePost()
{
// we have a whole package, do a default response
var stat = CommandStatus.Success;
if (baseResponse.Status != DFConstantsAndEnums.CommandStatus.StatusNoError)
{
var s = (int)baseResponse.Status;
LogString("WholePackagePost: reporting failure, status==" + CommandPacketBase.StatusLabels[s] + " (0x" + s.ToString("X") + ")");
stat = CommandStatus.Failure;
}
var acr = new CommandReport(stat, UserCallbackData);
return UserCallback(acr);
}
protected virtual CommandReceiveAction SendReceiveError(ICommunicationReport report)
{
if (IsSynchronous)
{
string result = "null";
if (null != report) { result = report.Result.ToString(); }
LogString("SendReceiveError: SyncEvent.Set(), result=" + result);
SyncEvent.Set();
}
else
{
if (UserCallback == null)
{
throw new ApplicationException(Strings.Slice_CommandBase_SendReceiveError_Err1);
}
LogString("SendReceiveError: reporting failure, report==" + report);
var cbReport = new CommandReport(CommandStatus.Failure, UserCallbackData);
UserCallback(cbReport);
}
return CommandReceiveAction.StopReceiving;
}
/// <summary>
/// Status of response packet
/// </summary>
public DFConstantsAndEnums.CommandStatus ResponseStatus
{
get { if (null == baseResponse) return DFConstantsAndEnums.CommandStatus.StatusNoResponse; return baseResponse.Status; }
}
/// <summary>
/// string description of status in hex?
/// </summary>
public string StatusString => CommandPacketBase.StatusLabels[(int)_status] + " (0x" + _status.ToString("X") + ")";
/// <summary>
/// default I/O timeout in ms?
/// </summary>
public const int Default_IO_Timeout = 120000; //System.Threading.Timeout.Infinite; //1000;
/// <summary>
/// timeout for specific commands in ms?
/// </summary>
public int IO_Timeout { get; set; }
/// <summary>
/// note, this was internal, it's not designed to be accessed by more than 1 level of inheritance
/// </summary>
/// <param name="sock"></param>
/// <param name="TimeoutMillisec"></param>
internal void SetupThis(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
{
ClassType = GetType();
CommandDataBuffer = new SecureQueue<byte>(SecureQueue<byte>.NullPolicy.SkipNull, "CommandBase.CommandDataBuffer");
recorder = sock;
SyncEvent = new ManualResetEvent(false);
UserCallback = null;
UserCallbackData = null;
IsSynchronous = false;
baseResponse = null;
ComReport = null;
LogCommands = true;
_status = DFConstantsAndEnums.CommandStatus.StatusUnimplemented;
IO_Timeout = TimeoutMillisec;
// The first protocol version was 1, so set that as the default here
MinimumProtocolVersion = 1;
}
protected AbstractCommandBase(DTS.Common.Interface.DASFactory.ICommunication sock)
{
_debuglock = new object();
lock (_debuglock)
{
current_thread_id = -1;
}
SetupThis(sock, Default_IO_Timeout);
}
protected AbstractCommandBase(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
{
_debuglock = new object();
lock (_debuglock)
{
current_thread_id = -1;
}
SetupThis(sock, TimeoutMillisec);
}
/// <summary>
/// Both Execute and SyncExecute uses this function as their callback (since
/// both calls recorder.Execute).
/// </summary>
/// <param name="report"></param>
/// <returns>true if recorder should wait for more data, false otherwise
/// </returns>
protected virtual bool ExecuteCallback(ICommunicationReport report)
{
// we should only handle ExecuteIsBusy if we're NOT run thry SyncExecute
ComReport = report;
switch (report.Result)
{
case CommunicationConstantsAndEnums.CommunicationResult.ReceiveOK:
// ReceiveBlockOK takes care of the ExecuteIsBusy flag
return ReceiveBlockOK(report) == CommandReceiveAction.ContinueReceiving;
case CommunicationConstantsAndEnums.CommunicationResult.SendTimeout:
case CommunicationConstantsAndEnums.CommunicationResult.SendFailed:
case CommunicationConstantsAndEnums.CommunicationResult.ReceiveTimeout:
case CommunicationConstantsAndEnums.CommunicationResult.ReceiveFailed:
// this will always result in termination
LogString("ExecuteCallback: " + report.Result);
if (!IsSynchronous)
{
recorder.ExecuteIsBusy = false;
}
SendReceiveError(report);
return false;
case CommunicationConstantsAndEnums.CommunicationResult.Canceled:
if (IsSynchronous)
{
SyncEvent.Set();
}
else
{
recorder.ExecuteIsBusy = false;
var cbReport = new CommandReport(CommandStatus.Canceled, UserCallbackData);
UserCallback(cbReport);
}
return false;
}
Debug.Assert(false, "CommandBase.ExecuteCallback: unhandled case " + report.Result);
return true;
}
private void SurfaceError(string msg)
{
try
{
PageErrorEvent.SurfaceApplicationError(msg);
}
catch (Exception ex)
{
APILogger.Log(ex);
}
}
private Random _random = new Random(DateTime.Now.Second);
protected void InternalSyncExecute()
{
// this is a try/finally to handle the ExecuteIsBusy
try
{
// there can be only one!
recorder.ExecuteIsBusy = true;
if (recorder.ProtocolVersion < MinimumProtocolVersion)
{
throw new Exception(Strings.Slice_CommandBase_SyncExecute_Err6);
}
if (recorder.IsCanceled())
{
throw new CanceledException();
}
if (baseCommand.AlreadyRun)
{
baseCommand.GetNextSequenceNumber();
}
baseCommand.AlreadyRun = true;
baseCommand.ComputeCRCs();
var CommandBytes = baseCommand.ToBytes();
baseCommand.OriginalBytes = CommandBytes;
#if LOG_COMM
lock (_COMM_LOCK_)
{
System.IO.File.AppendAllText(@"Logs\COMM.log",
$"{DateTime.Now.Ticks} [OUT] seq:{baseCommand.SequenceNumber} {baseCommand.GetCommandDescription()} - {BitConverter.ToString(CommandBytes).Replace("-", string.Empty)}\r\n");
}
#endif
if (LogCommands)
{
LogCommand(true);
}
UserCallback = null;
UserCallbackData = null;
IsSynchronous = true;
SyncEvent.Reset();
ExecuteTime = DateTime.Now;
recorder.Execute(CommandBytes, ExecuteCallback, null, IO_Timeout);
var syncExecTimeout = IO_Timeout;
if (syncExecTimeout != Timeout.Infinite)
{
syncExecTimeout *= 3;
}
try
{
if (!WaitWithCondition.Wait(SyncEvent, syncExecTimeout, recorder.CancelEvent))
{
// timeout
LogString("SyncExecute: timeout");
throw new TimeoutException(MakeLogString("SyncExecute: timeout"));
}
}
catch (WaitWithCondition.ConditionMetException)
{
throw new CanceledException();
}
// we didn't timeout, check the result
switch (ComReport.Result)
{
case CommunicationConstantsAndEnums.CommunicationResult.Canceled:
throw new CanceledException();
case CommunicationConstantsAndEnums.CommunicationResult.ReceiveOK:
if (baseResponse == null)
{
LogString("SyncExecute: ReceiveOK but response==null!");
LogCommand(false);
throw new Exception(MakeLogString("SyncExecute: ReceiveOK but response==null!"));
}
if (baseResponse.Status == DFConstantsAndEnums.CommandStatus.StatusSlicebusNoResponse)
{
SurfaceError($"Possible hardware issue detected on {recorder.SerialNumber} [SliceBusNoResponse]. Please contact DTS support");
}
if (baseResponse.Status != DFConstantsAndEnums.CommandStatus.StatusNoError)
{
// didn't go well
var msg = MakeLogString("SyncExecute: response.Status = " + baseResponse.Status);
LogCommand(false);
if (baseResponse.Status == DFConstantsAndEnums.CommandStatus.StatusInvalidModeForCommand ||
baseResponse.Status == DFConstantsAndEnums.CommandStatus.StatusInvalidCommand)
{
throw new CommandException(CommandErrorReason.InvalidMode, msg);
}
if (baseResponse.Status == DFConstantsAndEnums.CommandStatus.StatusUnimplemented ||
baseResponse.Status == DFConstantsAndEnums.CommandStatus.StatusInvalidCommand ||
baseResponse.Status == DFConstantsAndEnums.CommandStatus.StatusInvalidCommandType)
{
throw new NotImplementedException(msg);
}
var ex = new Exception(msg);
ex.Data.Add("Status", baseResponse.Status);
throw ex;
}
// everything is fine, let it exit
if (LogCommands)
{
LogCommand(false);
}
break;
case CommunicationConstantsAndEnums.CommunicationResult.ReceiveFailed:
{
var msg = MakeLogString("SyncExecute: ComReport.Result == " + ComReport.Result);
APILogger.LogString(msg);
LogCommand(false);
throw new CommandException(CommandErrorReason.ReceiveFailed, msg);
}
case CommunicationConstantsAndEnums.CommunicationResult.ReceiveTimeout:
{
var msg = MakeLogString("SyncExecute: ComReport.Result == " + ComReport.Result);
APILogger.LogString(msg);
LogCommand(false);
throw new CommandException(CommandErrorReason.ReceiveFailed, msg);
}
case CommunicationConstantsAndEnums.CommunicationResult.SendFailed:
case CommunicationConstantsAndEnums.CommunicationResult.SendTimeout:
{
var msg = MakeLogString("SyncExecute: ComReport.Result == " + ComReport.Result);
APILogger.LogString(msg);
LogCommand(false);
throw new CommandException(CommandErrorReason.SendFailed, msg);
}
default:
{
var msg = MakeLogString("SyncExecute: Unknown ComReport.Result == " + ComReport.Result);
APILogger.LogString(msg);
LogCommand(false);
throw new Exception(msg);
}
}
}
finally
{
recorder.ExecuteIsBusy = false;
}
}
public virtual void SyncExecute()
{
try
{
InternalSyncExecute();
// if we get here, everything is fine
return;
}
catch (TimeoutException te)
{
// and again
LogString("SyncExecute: timeout");
//the retry here was causing a lot of issues
//seems better to just accept the death of the command and re-issue as needed
throw te;
}
}
public virtual void Execute(CommandCallback cb, object cbData)
{
// this try/catch is to only handle ExecuteIsBusy
try
{
// there can be only one!
recorder.ExecuteIsBusy = true;
if (!recorder.Connected)
{
// "Slice.CommandBase.Execute: No recorder connected"
throw new System.Exception(Strings.Slice_CommandBase_Execute_Err1);
}
if (cb == null)
{
// "Slice.CommandBase.Execute: Callback can't be null"
throw new ArgumentException(Strings.Slice_CommandBase_Execute_Err2);
}
if (recorder.ProtocolVersion < MinimumProtocolVersion)
{
// "Slice.CommandBase.Execute: The recorder's protocol version does not support this command"
throw new System.Exception(Strings.Slice_CommandBase_Execute_Err3);
}
if (recorder.IsCanceled())
{
throw new CanceledException();
}
// this is the tail end of execute, do some bookeeping first
//Debug.Assert(false == command.AlreadyRun);
if (baseCommand.AlreadyRun)
{
baseCommand.GetNextSequenceNumber();
}
baseCommand.AlreadyRun = true;
baseCommand.ComputeCRCs();
var CommandBytes = baseCommand.ToBytes();
baseCommand.OriginalBytes = CommandBytes;
UserCallback = cb;
UserCallbackData = cbData;
IsSynchronous = false;
LogCommand(true);
ExecuteTime = DateTime.Now;
recorder.Execute(CommandBytes, ExecuteCallback, null, IO_Timeout);
}
catch (System.Exception ex)
{
APILogger.Log(ex);
// if an exception has happend the execute is actually started and execute is therefore not busy.
// After execute starts the only responses we get is thru ExecuteCallback
recorder.ExecuteIsBusy = false;
throw;
}
}
/// <summary>
/// returns a commandpacket object
/// this is necessary because commandpackets are specific to inheritted classes
/// and can contain different packing of bytes and different verification schemes
/// an example would be <see cref="SliceCommandPacketBase" />
/// </summary>
/// <param name="buffer"></param>
/// <returns></returns>
protected abstract CommandPacketBase GetCommandPacket(byte[] buffer);
protected abstract CommandPacketBase GetCommandPacket();
/// <summary>
/// allows inheriting classes to add their own log statements to entries
/// when overriding, be sure to call base class implementation
/// the first line of the two dimensional array is the header information
/// from the command (like sequence number, type of command, etc)
/// </summary>
/// <param name="lines"></param>
public virtual void CommandToString(ref List<List<string>> lines)
{
}
/// <summary>
/// allows inheriting classes to add their own log statements to log entries
/// when overriding, make sure to call the base class to pick up statements
/// added by parent classes
/// the base class will add a line if there is an error
/// </summary>
/// <param name="lines"></param>
public virtual void ResponseToString(ref List<List<string>> lines)
{
if (null == baseResponse || baseResponse.Status != DFConstantsAndEnums.CommandStatus.StatusNoError)
{
lines.Add(new List<string>()
{
$"XXXXX ERROR XXXXX {baseResponse.Status.ToString()}"
});
}
}
public const string RESPONSESTART_STRING = "<- ";
private const string SPACE_STRING = " ";
public const string COMMANDSTART_STRING = "-> ";
/// <summary>
/// outputs a two dimensional array of log information into a single string
/// using a two dimensional array means that subclasses don't need to care
/// about how much data was already put into the arrays, they can just add
/// whatever data they need to report
/// </summary>
/// <param name="lines">two dimensional array of log data</param>
/// <param name="bSending"></param>
/// <returns></returns>
private string FormatLogEntry(List<List<string>> lines, bool bSending)
{
StringBuilder sb = new StringBuilder(200);
for (var i = 0; i < lines.Count; i++)
{
if (0 == i)
{
sb.Append(bSending ? COMMANDSTART_STRING : RESPONSESTART_STRING);
}
else { sb.Append(SPACE_STRING); }
for (var j = 0; j < lines[i].Count; j++)
{
if (j > 0) { sb.Append(", "); }
sb.Append(lines[i][j]);
}
}
return sb.ToString();
}
/// <summary>
/// outputs a single string for logging
/// </summary>
/// <param name="bSending">log outgoing or ingoing command</param>
/// <returns></returns>
private string GetFormattedLogEntry(bool bSending)
{
var lines = new List<List<string>>();
if (bSending)
{
baseCommand.GetPacketLogHeader(ref lines);
CommandToString(ref lines);
}
else
{
if (null != baseResponse)
{
baseResponse.GetPacketLogHeader(baseCommand, ref lines, ExecuteTime);
ResponseToString(ref lines);
}
}
return FormatLogEntry(lines, bSending);
}
}
}

View File

@@ -0,0 +1,392 @@
using System;
using System.Collections.Generic;
using System.Text;
using DTS.Common.Enums.DASFactory;
using DTS.Common.Utilities.Logging;
using DTS.Common.Utils;
namespace DTS.DASLib.Command
{
/// <summary>
/// this is the base for all slice command packets
/// from here SliceDb and slice command packets will have different commands that can be
/// run and a different command type enum containing the command types, however
/// this class contains the common logic for addressing and packing the packet
/// </summary>
public abstract class SliceCommandPacketBase : CommandPacketBase
{
public const byte MAGIC_BYTE = 0xFA;
protected const int HEADER_SIZE_BYTES = 12;
protected const int DATA_CRC_SIZE_BYTES = 2;
// Packet format -- all are 8 bits, but ParameterLength, SequenceNumber and HeaderCRC
protected const int MagicBytePosition = 0;
protected const int TypePosition = 1;
protected const int CommandPosition = 2;
protected const int StatusPosition = 3;
protected const int DeviceGroupPosition = 4;
protected const int DeviceIDPosition = 5;
// Parameter length is 16 bits
protected const int ParameterLengthPosition = 6;
// Sequence number length is 16 bits
protected const int SequenceNumberPosition = 8;
// Header CRC is 16 bits
protected const int HeaderCRCPosition = 10;
public UInt16 ParameterLength;
public byte DeviceGroup;
public byte DeviceID;
public UInt16 HeaderCRC;
public byte[] Parameter;
public UInt16 ParameterCRC;
public SliceCommandPacketBase()
{
Parameter = new byte[0];
AlreadyRun = false;
ShouldLog = true;
GetNextSequenceNumber();
}
public SliceCommandPacketBase(byte[] Bytes)
{
OriginalBytes = Bytes;
ShouldLog = true;
if (HEADER_SIZE_BYTES <= Bytes.Length && MAGIC_BYTE == Bytes[0])
{
Type = ConvertByteToCommandType(Bytes[TypePosition]);//(CommandType)Bytes[TypePosition];
//Command = Bytes[CommandPosition];
SetCommand(Bytes[CommandPosition], Convert.ToString(Bytes[CommandPosition]));
Status = (DFConstantsAndEnums.CommandStatus)Bytes[StatusPosition];
DeviceGroup = Bytes[DeviceGroupPosition];
DeviceID = Bytes[DeviceIDPosition];
ParameterLength = (ushort)(Bytes[ParameterLengthPosition + 0] |
(Bytes[ParameterLengthPosition + 1] << 8));
SequenceNumber = (ushort)(Bytes[SequenceNumberPosition + 0] |
(Bytes[SequenceNumberPosition + 1] << 8));
HeaderCRC = (ushort)(Bytes[HeaderCRCPosition + 0] |
(Bytes[HeaderCRCPosition + 1] << 8));
Parameter = new byte[ParameterLength];
if (ParameterLength > 0 && Bytes.Length > HEADER_SIZE_BYTES)
{
try
{
Buffer.BlockCopy(Bytes, HEADER_SIZE_BYTES + DATA_CRC_SIZE_BYTES, Parameter, 0, ParameterLength);
ParameterCRC = (UInt16)(Bytes[HEADER_SIZE_BYTES + 0] |
Bytes[HEADER_SIZE_BYTES + 1] << 8);
}
catch (Exception ex)
{
APILogger.Log(ex);
}
}
}
}
public override PacketState VerifyPacket(byte[] Bytes)
{
if (Bytes == null)
return PacketState.Unknown;
if (Bytes.Length < HEADER_SIZE_BYTES)
return PacketState.TooShort;
if (Bytes[MagicBytePosition] != MAGIC_BYTE)
return PacketState.Unknown;
object type = ConvertByteToCommandType(Bytes[TypePosition]);
//CommandType type = (CommandType)Bytes[TypePosition];
byte command = Bytes[CommandPosition];
CommandStatus status = (CommandStatus)Bytes[StatusPosition];
byte deviceGroup = Bytes[DeviceGroupPosition];
byte deviceID = Bytes[DeviceIDPosition];
ushort parameterLength = (ushort)(Bytes[ParameterLengthPosition + 0] |
(Bytes[ParameterLengthPosition + 1] << 8));
// TODO: Why isn't this checking the CRCs?
//ushort headerCRC = (ushort)(Bytes[9] | (Bytes[8] << 8));
//ushort parameterCRC = (UInt16)(Bytes[10 + 1 + parameterLength] | Bytes[10 + 0 + parameterLength] << 8);
// Note that the second condition (parameterLength==0) is already caught above and does not need to
// be here.
if ((parameterLength > 0 && Bytes.Length < parameterLength + HEADER_SIZE_BYTES + DATA_CRC_SIZE_BYTES) ||
(0 == parameterLength && Bytes.Length < HEADER_SIZE_BYTES))
{
return PacketState.TooShort;
}
//if(Bytes.Length > parameterLength + 10 + 2)
// return PacketState.TooLong;
return PacketState.OK;
}
public override void ComputeCRCs()
{
HeaderCRC = 0xFFFF;
// Compute the CRC of the first 8 bytes in the CommandPacket
// This is a little more awkward than it should be but since the length field
// is really two bytes, but packed into the 16-bit variable, we need to mask it
// off and compute the CRC of the bytes in the correct order, etc.
//Utility.Utility.Crc16Ccitt crccalc = new Utility.Utility.Crc16Ccitt(Utility.Utility.InitialCrcValue.Zeros);
//crccalc.UpdateChecksum((ushort)0xFA);
//crccalc.UpdateChecksum((ushort)Type);
//crccalc.UpdateChecksum((ushort)Command);
//crccalc.UpdateChecksum((ushort)Status);
//crccalc.UpdateChecksum((ushort)DeviceGroup);
//crccalc.UpdateChecksum((ushort)DeviceID);
//crccalc.UpdateChecksum((ushort)(Parameter.Length & 0xFF));
//crccalc.UpdateChecksum((ushort)((Parameter.Length & 0xFF00) >> 8));
//HeaderCRC = crccalc.cur
HeaderCRC = Utils.Math_DoCRCCCITTStep(0xFA, HeaderCRC);
HeaderCRC = Utils.Math_DoCRCCCITTStep((ushort)((int)Type), HeaderCRC);
HeaderCRC = Utils.Math_DoCRCCCITTStep(GetCommand(), HeaderCRC);
HeaderCRC = Utils.Math_DoCRCCCITTStep((ushort)Status, HeaderCRC);
HeaderCRC = Utils.Math_DoCRCCCITTStep(DeviceGroup, HeaderCRC);
HeaderCRC = Utils.Math_DoCRCCCITTStep(DeviceID, HeaderCRC);
HeaderCRC = Utils.Math_DoCRCCCITTStep((ushort)(Parameter.Length & 0xFF), HeaderCRC);
HeaderCRC = Utils.Math_DoCRCCCITTStep((ushort)((Parameter.Length & 0xFF00) >> 8), HeaderCRC);
HeaderCRC = Utils.Math_DoCRCCCITTStep((ushort)(SequenceNumber & 0xFF), HeaderCRC);
HeaderCRC = Utils.Math_DoCRCCCITTStep((ushort)((SequenceNumber & 0xFF00) >> 8), HeaderCRC);
// Compute the Parameter CRC
ParameterCRC = 0xFFFF;
// If length > 0, continue the computation over the data bytes
if (Parameter.Length > 0)
{
for (int i = 0; i < Parameter.Length; i++)
{
ParameterCRC = Utils.Math_DoCRCCCITTStep(Parameter[i], ParameterCRC);
}
}
}
public void GetParameter(int Offset, out double Value)
{
ByteConvertor.Convert(Parameter, Offset, out Value);
}
public void GetParameter(int Offset, out UInt64 Value)
{
Value = 0 |
(ulong)Parameter[Offset + 7] << 0 |
(ulong)Parameter[Offset + 6] << 8 |
(ulong)Parameter[Offset + 5] << 16 |
(ulong)Parameter[Offset + 4] << 24 |
(ulong)Parameter[Offset + 3] << 32 |
(ulong)Parameter[Offset + 2] << 40 |
(ulong)Parameter[Offset + 1] << 48 |
(ulong)Parameter[Offset + 0] << 56;
}
public void GetParameter(int Offset, out Int64 Value)
{
Value = (long)Parameter[Offset + 7] << 0 |
(long)Parameter[Offset + 6] << 8 |
(long)Parameter[Offset + 5] << 16 |
(long)Parameter[Offset + 4] << 24 |
(long)Parameter[Offset + 3] << 32 |
(long)Parameter[Offset + 2] << 40 |
(long)Parameter[Offset + 1] << 48 |
(long)Parameter[Offset + 0] << 56;
}
public void GetParameter(int Offset, out Int32 Value)
{
Value = Parameter[Offset + 3] |
Parameter[Offset + 2] << 8 |
Parameter[Offset + 1] << 16 |
Parameter[Offset + 0] << 24;
}
public void GetParameter(int Offset, out UInt32 Value)
{
Value = (UInt32)(Parameter[Offset + 3] |
Parameter[Offset + 2] << 8 |
Parameter[Offset + 1] << 16 |
Parameter[Offset + 0] << 24);
}
public void GetParameter(int Offset, out Int16 Value)
{
Value = (Int16)(Parameter[Offset + 1] |
Parameter[Offset + 0] << 8);
}
public void GetParameter(int Offset, out UInt16 Value)
{
Value = (UInt16)(Parameter[Offset + 1] |
Parameter[Offset + 0] << 8);
}
public void GetParameter(int Offset, out byte Value)
{
Value = Parameter[Offset];
}
public void GetParameter(int Offset, out bool Value)
{
Value = (Parameter[Offset] == 0x01);
}
public void GetParameter(int Offset, out float Value)
{
Value = BitConverter.ToSingle(Parameter, Offset);
}
public void GetParameter(int Offset, out string Value)
{
StringBuilder sb = new StringBuilder();
int idx = Offset;
while (idx < Parameter.Length && 0 != Parameter[idx])
{
sb.Append((char)Parameter[idx++]);
}
Value = sb.ToString();
}
public void SetParameter(int Offset, double Value)
{
byte[] rv = ByteConvertor.ToByteArray(Value);
Buffer.BlockCopy(rv, 0, Parameter, Offset, rv.Length);
}
public void SetParameter(int Offset, Int64 Value)
{
Parameter[Offset + 7] = (byte)(((ulong)Value & 0x00000000000000FF) >> 0);
Parameter[Offset + 6] = (byte)(((ulong)Value & 0x000000000000FF00) >> 8);
Parameter[Offset + 5] = (byte)(((ulong)Value & 0x0000000000FF0000) >> 16);
Parameter[Offset + 4] = (byte)(((ulong)Value & 0x00000000FF000000) >> 24);
Parameter[Offset + 3] = (byte)(((ulong)Value & 0x000000FF00000000) >> 32);
Parameter[Offset + 2] = (byte)(((ulong)Value & 0x0000FF0000000000) >> 40);
Parameter[Offset + 1] = (byte)(((ulong)Value & 0x00FF000000000000) >> 48);
Parameter[Offset + 0] = (byte)(((ulong)Value & 0xFF00000000000000) >> 56);
}
public void SetParameter(int Offset, UInt64 Value)
{
Parameter[Offset + 7] = (byte)((Value & 0x00000000000000FF) >> 0);
Parameter[Offset + 6] = (byte)((Value & 0x000000000000FF00) >> 8);
Parameter[Offset + 5] = (byte)((Value & 0x0000000000FF0000) >> 16);
Parameter[Offset + 4] = (byte)((Value & 0x00000000FF000000) >> 24);
Parameter[Offset + 3] = (byte)((Value & 0x000000FF00000000) >> 32);
Parameter[Offset + 2] = (byte)((Value & 0x0000FF0000000000) >> 40);
Parameter[Offset + 1] = (byte)((Value & 0x00FF000000000000) >> 48);
Parameter[Offset + 0] = (byte)((Value & 0xFF00000000000000) >> 56);
}
public void SetParameter(int Offset, Int32 Value)
{
Parameter[Offset + 3] = (byte)((Value & 0x000000FF));
Parameter[Offset + 2] = (byte)((Value & 0x0000FF00) >> 8);
Parameter[Offset + 1] = (byte)((Value & 0x00FF0000) >> 16);
Parameter[Offset + 0] = (byte)((Value & 0xFF000000) >> 24);
}
public void SetParameter(int Offset, UInt32 Value)
{
Parameter[Offset + 3] = (byte)((Value & 0x000000FF));
Parameter[Offset + 2] = (byte)((Value & 0x0000FF00) >> 8);
Parameter[Offset + 1] = (byte)((Value & 0x00FF0000) >> 16);
Parameter[Offset + 0] = (byte)((Value & 0xFF000000) >> 24);
}
public void SetParameter(int Offset, Int16 Value)
{
Parameter[Offset + 1] = (byte)(Value & 0x00FF);
Parameter[Offset + 0] = (byte)((Value & 0xFF00) >> 8);
}
public void SetParameter(int Offset, UInt16 Value)
{
Parameter[Offset + 1] = (byte)(Value & 0x00FF);
Parameter[Offset + 0] = (byte)((Value & 0xFF00) >> 8);
}
public void SetParameter(int Offset, byte Value)
{
Parameter[Offset] = Value;
}
public void SetParameter(int Offset, bool Value)
{
Parameter[Offset] = (byte)(Value ? 0x01 : 0x00);
}
public void SetParameter(int Offset, byte[] Value)
{
Value.CopyTo(Parameter, Offset);
}
public void SetParameter(int Offset, string Value)
{
char[] original = Value.ToCharArray();
char[] withNullTermination = new char[original.Length + 1];
original.CopyTo(withNullTermination, 0);
withNullTermination[withNullTermination.Length - 1] = '\0';
SetParameter(Offset, withNullTermination);
}
public void SetParameter(int Offset, char[] Value)
{
for (int i = 0; i < Value.Length; i++)
{
Parameter[Offset + i] = (byte)Value[i];
}
Parameter[Parameter.Length - 1] = 0;
}
public void SetParameter(int Offset, char Value)
{
Parameter[Offset] = (byte)Value;
}
public void SetParameter(int Offset, float Value)
{
BitConverter.GetBytes(Value).CopyTo(Parameter, Offset);
}
public override byte[] ToBytes()
{
int Length;
byte[] CommandBytes;
Length = HEADER_SIZE_BYTES + Parameter.Length + (Parameter.Length > 0 ? DATA_CRC_SIZE_BYTES : 0);
CommandBytes = new byte[Length];
CommandBytes[MagicBytePosition] = MAGIC_BYTE;
CommandBytes[TypePosition] = (byte)((int)Type);
CommandBytes[CommandPosition] = GetCommand();
CommandBytes[StatusPosition] = (byte)Status;
CommandBytes[DeviceGroupPosition] = DeviceGroup;
CommandBytes[DeviceIDPosition] = DeviceID;
CommandBytes[ParameterLengthPosition + 0] = (byte)((Parameter.Length & 0xFF00) >> 8);
CommandBytes[ParameterLengthPosition + 1] = (byte)(Parameter.Length & 0x00FF);
CommandBytes[SequenceNumberPosition + 0] = (byte)((SequenceNumber & 0xFF00) >> 8);
CommandBytes[SequenceNumberPosition + 1] = (byte)(SequenceNumber & 0x00FF);
CommandBytes[HeaderCRCPosition + 0] = (byte)((HeaderCRC & 0xFF00) >> 8);
CommandBytes[HeaderCRCPosition + 1] = (byte)(HeaderCRC & 0x00FF);
for (int iIndex = 0; iIndex < Parameter.Length; iIndex++)
{
CommandBytes[iIndex + HEADER_SIZE_BYTES + DATA_CRC_SIZE_BYTES] = Parameter[iIndex];
}
if (Parameter.Length > 0)
{
CommandBytes[HEADER_SIZE_BYTES + 0] = (byte)((ParameterCRC & 0xFF00) >> 8);
CommandBytes[HEADER_SIZE_BYTES + 1] = (byte)(ParameterCRC & 0x00FF);
}
OriginalBytes = CommandBytes;
return CommandBytes;
}
}
}

View File

@@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="DTS.DASLib.Command.Classes.DiscoveredDevice" Collapsed="true">
<Position X="3.75" Y="3.75" Width="1.5" />
<NestedTypes>
<Class Name="DTS.DASLib.Command.Classes.DiscoveredDevice.DiscoveredChildrenSorter" Collapsed="true">
<TypeIdentifier>
<NewMemberFileName>Classes\DiscoveredDevice.cs</NewMemberFileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Enum Name="DTS.DASLib.Command.Classes.DiscoveredDevice.MultiCastDeviceClasses" Collapsed="true">
<TypeIdentifier>
<NewMemberFileName>Classes\DiscoveredDevice.cs</NewMemberFileName>
</TypeIdentifier>
</Enum>
</NestedTypes>
<TypeIdentifier>
<HashCode>ABEIQAAAAJAAQAQABAIAYgAkGBAQAICAAAACICQAIAA=</HashCode>
<FileName>Classes\DiscoveredDevice.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="DTS.DASLib.Command.Classes.ConnectedEthernetDevice" Collapsed="true">
<Position X="2" Y="3.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAACAEAAACAAAAAAAAAAAA=</HashCode>
<FileName>Classes\DiscoveredDevice.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.AbstractCommandBase" Collapsed="true">
<Position X="4.25" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>IkAKwgFVAAMAAUyAwIACIIBCACAAIAgEDAUQCWBTIEg=</HashCode>
<FileName>AbstractCommandBase.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="DTS.DASLib.Command.CommandLogEntryBase" Collapsed="true">
<Position X="8.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAGAAAAAAAEAAQAAAAAAAAAAAAQAAA=</HashCode>
<FileName>CommandLogEntryBase.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.CommandPacketBase" Collapsed="true">
<Position X="1.25" Y="0.5" Width="1.5" />
<Compartments>
<Compartment Name="Nested Types" Collapsed="false" />
</Compartments>
<NestedTypes>
<Enum Name="DTS.DASLib.Command.CommandPacketBase.CommandStatus" Collapsed="true">
<TypeIdentifier>
<NewMemberFileName>CommandPacketBase.cs</NewMemberFileName>
</TypeIdentifier>
</Enum>
<Enum Name="DTS.DASLib.Command.CommandPacketBase.PacketState" Collapsed="true">
<TypeIdentifier>
<NewMemberFileName>CommandPacketBase.cs</NewMemberFileName>
</TypeIdentifier>
</Enum>
</NestedTypes>
<TypeIdentifier>
<HashCode>EAAAAAGEAAAAAAAMAAiBABQAAAAAACAAAwkAAQBAAAA=</HashCode>
<FileName>CommandPacketBase.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.CommandReport" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="6.75" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAA=</HashCode>
<FileName>CommandReport.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" Collapsed="true" />
</Class>
<Class Name="DTS.DASLib.Command.CommandException" Collapsed="true">
<Position X="6.75" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.SliceCommandBase" Collapsed="true">
<Position X="4.25" Y="1.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AgAAAECAAIAAAQAAAAAAAABEAAQAAAAAAAAAEAAAAEA=</HashCode>
<FileName>SliceCommandBase.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.SliceCommandPacketBase" Collapsed="true">
<Position X="1.25" Y="1.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAQAQCAAIAwAgEoEQAABIAAEEgRAGAEAAAAEAAAAAA=</HashCode>
<FileName>SliceCommandPacketBase.cs</FileName>
</TypeIdentifier>
</Class>
<Interface Name="DTS.DASLib.Command.ICommandReport" Collapsed="true">
<Position X="8.5" Y="2.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="DTS.DASLib.Command.ICommand" Collapsed="true">
<Position X="6.75" Y="2.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AgAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Interface>
<Enum Name="DTS.DASLib.Command.CommandStatus" Collapsed="true">
<Position X="6.75" Y="4.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAgAAAAAAAAgAAAACAAAAAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Enum>
<Enum Name="DTS.DASLib.Command.CommandErrorReason" Collapsed="true">
<Position X="6.75" Y="3.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAIAgAAAAAAAAAAAAAAAAAEAAAACAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Enum>
<Enum Name="DTS.DASLib.Command.CommandReceiveAction" Collapsed="true">
<Position X="8.5" Y="3.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAACAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Enum>
<Delegate Name="DTS.DASLib.Command.CommandCallback" Collapsed="true">
<Position X="6.75" Y="5.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Delegate>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>

View File

@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ICommand")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ICommand")]
[assembly: AssemblyCopyright("Copyright © 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("14230b85-7fbb-40ce-973e-c0aecb2e8b44")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.06.0081")]
[assembly: AssemblyFileVersion("1.06.0081")]

BIN
DataPRO/ICommand/.svn/wc.db Normal file

Binary file not shown.

View File

View File

@@ -0,0 +1,833 @@
//#define LOG_COMM
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Diagnostics;
using DTS.Common.DASResource;
using DTS.Common.ICommunication;
using DTS.Common.Utilities;
using DTS.Common.Utilities.Logging;
using DTS.Common.Utils;
using DTS.Common.Enums.Communication;
using DTS.Common.Interface.Communication;
using DTS.Common.Enums.DASFactory;
using DTS.Common.Events;
// ReSharper disable InconsistentNaming
namespace DTS.DASLib.Command
{
/// <summary>
/// Ribeye, SliceCommand, SliceDBCommand all contained Command objects which
/// implemented ICommand
/// I extracted as many common things as I could into one common class and formed
/// an abstract base class.
/// In general slice commands seemed to contain the most up to date code, and
/// slice db commands and ribeye seemed to contain older code, so the majority of the code
/// is actually from slice commands.
/// 6/14/10 - dtm
/// </summary>
public abstract class AbstractCommandBase : ICommand
{
// this is the buffer we use to accumulate the data coming in until we have a full
// response package.
protected SecureQueue<byte> CommandDataBuffer;
protected DTS.Common.Interface.DASFactory.ICommunication recorder;
protected ManualResetEvent SyncEvent;
protected CommandCallback UserCallback { get; set; }
protected object UserCallbackData { get; set; }
protected bool IsSynchronous { get; set; }
protected CommandPacketBase baseCommand;
protected CommandPacketBase baseResponse;
protected ICommunicationReport ComReport;
protected DFConstantsAndEnums.CommandStatus _status;
protected Type ClassType;
protected object _debuglock;
protected int current_thread_id;
protected int MinimumProtocolVersion { get; set; }
protected DateTime ExecuteTime { get; set; }
protected bool ExecuteIsBusy = false;
protected object ExecuteBusyLock = new object();
/// <summary>
/// whether to log commands or not
/// </summary>
public bool LogCommands { get; set; }
/// <summary>
/// Log Command or response
/// </summary>
/// <param name="sending">if true logs command, otherwise logs response</param>
protected virtual void LogCommand(bool sending)
{
try
{
if (!LogCommands) { return; }
APILogger.LogString(GetFormattedLogEntry(sending));
}
catch (Exception ex)
{
LogString($"threw an exception in {(sending ? "CommandToString()" : "ResponseToString()")}");
APILogger.LogException(ex);
}
}
protected virtual string MakeLogString(string msg)
{
var dasName = "<unknown>";
if (null != recorder) { dasName = recorder.ToString(); }
var cmdName = "<unknown>";
try
{
cmdName = GetType().FullName;
}
catch
{
// we use unknown
}
var sequenceNumber = "<unknown>";
try
{
sequenceNumber = baseCommand.SequenceNumber.ToString();
}
catch { }
//17686 add additional debug information into log
if (null != baseResponse)
{
sequenceNumber = $"{sequenceNumber}\\{baseResponse.SequenceNumber}";
}
return string.Format(Strings.CmdAbstractCommandGeneralFailure, dasName, cmdName, msg, sequenceNumber);
}
protected virtual void LogString(string msg)
{
APILogger.LogString(MakeLogString(msg));
}
/// <summary>
/// <see cref="CommandPacketBase.CommandStatus" /> status of command
/// </summary>
public DFConstantsAndEnums.CommandStatus Status => _status;
protected void EnqueueData(byte[] data)
{
CommandDataBuffer.Enqueue(data);
}
protected byte[] DequeueData(bool bResetEvent)
{
return CommandDataBuffer.Dequeue(bResetEvent);
}
#if LOG_COMM
private static readonly object _COMM_LOCK_ = new object();
#endif
/**
* Knuth-Morris-Pratt Algorithm for Pattern Matching
*/
class KMPMatch
{
/**
* Finds the first occurrence of the pattern in the text.
*/
public int indexOf(byte[] data, byte[] pattern, int startAddress = 0)
{
int[] failure = computeFailure(pattern);
int j = 0;
if (data.Length == 0) return -1;
for (int i = startAddress; i < data.Length; i++)
{
while (j > 0 && pattern[j] != data[i])
{
j = failure[j - 1];
}
if (pattern[j] == data[i]) { j++; }
if (j == pattern.Length)
{
return i - pattern.Length + 1;
}
}
return -1;
}
/**
* Computes the failure function using a boot-strapping process,
* where the pattern is matched against itself.
*/
private int[] computeFailure(byte[] pattern)
{
int[] failure = new int[pattern.Length];
int j = 0;
for (int i = 1; i < pattern.Length; i++)
{
while (j > 0 && pattern[j] != pattern[i])
{
j = failure[j - 1];
}
if (pattern[j] == pattern[i])
{
j++;
}
failure[i] = j;
}
return failure;
}
}
private static readonly byte[] StreamSignature = { 0xFA, 0x04, 0x07, 0x00, 0x00, 0x00, 0x10, 0xF8 };
private static readonly byte[] EndStreamSignature = { 0xFA, 0x04, 0x08, 0x00 };
private const int STREAM_PACKET_SIZE = 63518;
protected virtual CommandReceiveAction ReceiveBlockOK(ICommunicationReport report)
{
lock (_debuglock)
{
if (-1 != current_thread_id)
{
}
current_thread_id = Thread.CurrentThread.ManagedThreadId;
}
// use the buffer to assemble a bigger chunk
EnqueueData(report.Data);
var tempBuffer = DequeueData(false);
if (DFConstantsAndEnums.ExtraCommunicationLogging)
{
APILogger.Log($"ReceivedBlock {recorder?.ConnectString ?? "N/A"}", tempBuffer);
}
if (baseCommand.GetCommandDescription() == "GetNextDownloadStreamDataSamples")
{
var match = new KMPMatch();
var index = match.indexOf(tempBuffer, StreamSignature, 1);
if (index > 0)
{
var length = tempBuffer.Length - index;
var remainder = new byte[length];
Array.Copy(tempBuffer, index, remainder, 0, length);
EnqueueData(remainder);
var tmp = new byte[index];
Array.Copy(tempBuffer, 0, tmp, 0, index);
tempBuffer = tmp;
}
else
{
index = match.indexOf(tempBuffer, EndStreamSignature);
if (index >= 0)
{
var tmp = new byte[index];
Array.Copy(tempBuffer, 0, tmp, 0, index);
tempBuffer = tmp;
}
else
{
EnqueueData(tempBuffer);
return CommandReceiveAction.ContinueReceiving;
}
}
}
//there could be multiple packets in here, we have to
// a debug test
if (null != tempBuffer && tempBuffer.Length > 0 && tempBuffer[0] != 0xFA)
{
}
#if LOG_COMM
lock (_COMM_LOCK_)
{
System.IO.File.AppendAllText(@"Logs\COMM.log",
$"{DateTime.Now.Ticks} [IN] {BitConverter.ToString(tempBuffer).Replace("-", string.Empty)}\r\n");
}
#endif
// what's the state of this packet?
// - note I think the command object should be intialized and stable, but
// just incase maybe it's safer to check it before using it
// 6/14/2010 - dtm
var pState = baseCommand?.VerifyPacket(tempBuffer) ?? GetCommandPacket().VerifyPacket(tempBuffer);
if (DFConstantsAndEnums.ExtraCommunicationLogging)
{
APILogger.Log($"VerifyPacket {recorder?.ConnectString ?? "N/A"} {pState.ToString()}");
}
switch (pState)
{
case CommandPacketBase.PacketState.OK:
// perfect, a good complete packet
baseResponse = GetCommandPacket(tempBuffer);
#if LOG_COMM
lock (_COMM_LOCK_)
{
System.IO.File.AppendAllText(@"Logs\COMM.log",
$"{DateTime.Now.Ticks} [IN] [OK] seq:{baseResponse.SequenceNumber} {baseCommand.GetCommandDescription()}\r\n");
#endif
if (baseCommand.GetCommandDescription() == "EndRealtimeMode")
{
//if (baseCommand.SequenceNumber != baseResponse.SequenceNumber)
{
//look for the response
KMPMatch match = new KMPMatch();
//look for the command header for end realtime (0x08, 0x02)
//if we find it we have a response to end realtime, if not we have
//other data and should keep waiting
var target = new byte[] { 0xFA, 0x08, 0x02 };
//baseCommand.ToBytes();
var index = match.indexOf(tempBuffer, target);
if (index < 0)
{
#if LOG_COMM
System.IO.File.AppendAllText(@"Logs\COMM.log",
$"{DateTime.Now.Ticks} - NOT COMPLETE YET\r\n");
#endif
//this suggests the response we have is a realtime packet and NOT the end packet
return DataTooShort(tempBuffer);
}
else
{
#if LOG_COMM
System.IO.File.AppendAllText(@"Logs\COMM.log", $"{DateTime.Now.Ticks} - COMPLETE\r\n");
#endif
}
}
}
#if LOG_COMM
}
#endif
WholePackage();
if (IsSynchronous)
{
lock (_debuglock) { current_thread_id = -1; }
SyncEvent.Set();
}
else
{
// we're not doing a SyncExecute so we must flag the command done
recorder.ExecuteIsBusy = false;
WholePackagePost();
lock (_debuglock) { current_thread_id = -1; }
}
return CommandReceiveAction.StopReceiving;
case CommandPacketBase.PacketState.TooShort:
// not enough data, keep going
lock (_debuglock) { current_thread_id = -1; }
return DataTooShort(tempBuffer);
case CommandPacketBase.PacketState.Unknown:
// not good
if (!IsSynchronous)
{
// we're not doing a SyncExecute so we must flag the command done
recorder.ExecuteIsBusy = false;
lock (_debuglock) { current_thread_id = -1; }
return DataUnknown(report);
}
SyncEvent.Set();
return CommandReceiveAction.StopReceiving;
default:
Debug.Assert(false, "CommandBase.ReceiveBlockOK: Unhandled case " + pState.ToString());
return CommandReceiveAction.StopReceiving;
}
}
protected virtual CommandReceiveAction DataTooShort(byte[] dataSoFar)
{
// we need more data
CommandDataBuffer.Enqueue(dataSoFar);
return CommandReceiveAction.ContinueReceiving;
}
protected virtual CommandReceiveAction DataUnknown(ICommunicationReport report)
{
// a bad one
var cbReport = new CommandReport(CommandStatus.Failure, UserCallbackData);
LogString("DataUnknown: reporting failure " + report);
UserCallback(cbReport);
return CommandReceiveAction.StopReceiving;
}
protected virtual CommandReceiveAction WholePackage()
{
return CommandReceiveAction.StopReceiving;
}
protected virtual CommandReceiveAction WholePackagePost()
{
// we have a whole package, do a default response
var stat = CommandStatus.Success;
if (baseResponse.Status != DFConstantsAndEnums.CommandStatus.StatusNoError)
{
var s = (int)baseResponse.Status;
LogString("WholePackagePost: reporting failure, status==" + CommandPacketBase.StatusLabels[s] + " (0x" + s.ToString("X") + ")");
stat = CommandStatus.Failure;
}
var acr = new CommandReport(stat, UserCallbackData);
return UserCallback(acr);
}
protected virtual CommandReceiveAction SendReceiveError(ICommunicationReport report)
{
if (IsSynchronous)
{
string result = "null";
if (null != report) { result = report.Result.ToString(); }
LogString("SendReceiveError: SyncEvent.Set(), result=" + result);
SyncEvent.Set();
}
else
{
if (UserCallback == null)
{
throw new ApplicationException(Strings.Slice_CommandBase_SendReceiveError_Err1);
}
LogString("SendReceiveError: reporting failure, report==" + report);
var cbReport = new CommandReport(CommandStatus.Failure, UserCallbackData);
UserCallback(cbReport);
}
return CommandReceiveAction.StopReceiving;
}
/// <summary>
/// Status of response packet
/// </summary>
public DFConstantsAndEnums.CommandStatus ResponseStatus
{
get { if (null == baseResponse) return DFConstantsAndEnums.CommandStatus.StatusNoResponse; return baseResponse.Status; }
}
/// <summary>
/// string description of status in hex?
/// </summary>
public string StatusString => CommandPacketBase.StatusLabels[(int)_status] + " (0x" + _status.ToString("X") + ")";
/// <summary>
/// default I/O timeout in ms?
/// </summary>
public const int Default_IO_Timeout = 120000; //System.Threading.Timeout.Infinite; //1000;
/// <summary>
/// timeout for specific commands in ms?
/// </summary>
public int IO_Timeout { get; set; }
/// <summary>
/// note, this was internal, it's not designed to be accessed by more than 1 level of inheritance
/// </summary>
/// <param name="sock"></param>
/// <param name="TimeoutMillisec"></param>
internal void SetupThis(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
{
ClassType = GetType();
CommandDataBuffer = new SecureQueue<byte>(SecureQueue<byte>.NullPolicy.SkipNull, "CommandBase.CommandDataBuffer");
recorder = sock;
SyncEvent = new ManualResetEvent(false);
UserCallback = null;
UserCallbackData = null;
IsSynchronous = false;
baseResponse = null;
ComReport = null;
LogCommands = true;
_status = DFConstantsAndEnums.CommandStatus.StatusUnimplemented;
IO_Timeout = TimeoutMillisec;
// The first protocol version was 1, so set that as the default here
MinimumProtocolVersion = 1;
}
protected AbstractCommandBase(DTS.Common.Interface.DASFactory.ICommunication sock)
{
_debuglock = new object();
lock (_debuglock)
{
current_thread_id = -1;
}
SetupThis(sock, Default_IO_Timeout);
}
protected AbstractCommandBase(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
{
_debuglock = new object();
lock (_debuglock)
{
current_thread_id = -1;
}
SetupThis(sock, TimeoutMillisec);
}
/// <summary>
/// Both Execute and SyncExecute uses this function as their callback (since
/// both calls recorder.Execute).
/// </summary>
/// <param name="report"></param>
/// <returns>true if recorder should wait for more data, false otherwise
/// </returns>
protected virtual bool ExecuteCallback(ICommunicationReport report)
{
// we should only handle ExecuteIsBusy if we're NOT run thry SyncExecute
ComReport = report;
switch (report.Result)
{
case CommunicationConstantsAndEnums.CommunicationResult.ReceiveOK:
// ReceiveBlockOK takes care of the ExecuteIsBusy flag
return ReceiveBlockOK(report) == CommandReceiveAction.ContinueReceiving;
case CommunicationConstantsAndEnums.CommunicationResult.SendTimeout:
case CommunicationConstantsAndEnums.CommunicationResult.SendFailed:
case CommunicationConstantsAndEnums.CommunicationResult.ReceiveTimeout:
case CommunicationConstantsAndEnums.CommunicationResult.ReceiveFailed:
// this will always result in termination
LogString("ExecuteCallback: " + report.Result);
if (!IsSynchronous)
{
recorder.ExecuteIsBusy = false;
}
SendReceiveError(report);
return false;
case CommunicationConstantsAndEnums.CommunicationResult.Canceled:
if (IsSynchronous)
{
SyncEvent.Set();
}
else
{
recorder.ExecuteIsBusy = false;
var cbReport = new CommandReport(CommandStatus.Canceled, UserCallbackData);
UserCallback(cbReport);
}
return false;
}
Debug.Assert(false, "CommandBase.ExecuteCallback: unhandled case " + report.Result);
return true;
}
private void SurfaceError(string msg)
{
try
{
PageErrorEvent.SurfaceApplicationError(msg);
}
catch (Exception ex)
{
APILogger.Log(ex);
}
}
private Random _random = new Random(DateTime.Now.Second);
protected void InternalSyncExecute()
{
// this is a try/finally to handle the ExecuteIsBusy
try
{
// there can be only one!
recorder.ExecuteIsBusy = true;
if (recorder.ProtocolVersion < MinimumProtocolVersion)
{
throw new Exception(Strings.Slice_CommandBase_SyncExecute_Err6);
}
if (recorder.IsCanceled())
{
throw new CanceledException();
}
if (baseCommand.AlreadyRun)
{
baseCommand.GetNextSequenceNumber();
}
baseCommand.AlreadyRun = true;
baseCommand.ComputeCRCs();
var CommandBytes = baseCommand.ToBytes();
baseCommand.OriginalBytes = CommandBytes;
#if LOG_COMM
lock (_COMM_LOCK_)
{
System.IO.File.AppendAllText(@"Logs\COMM.log",
$"{DateTime.Now.Ticks} [OUT] seq:{baseCommand.SequenceNumber} {baseCommand.GetCommandDescription()} - {BitConverter.ToString(CommandBytes).Replace("-", string.Empty)}\r\n");
}
#endif
if (LogCommands)
{
LogCommand(true);
}
UserCallback = null;
UserCallbackData = null;
IsSynchronous = true;
SyncEvent.Reset();
ExecuteTime = DateTime.Now;
recorder.Execute(CommandBytes, ExecuteCallback, null, IO_Timeout);
var syncExecTimeout = IO_Timeout;
if (syncExecTimeout != Timeout.Infinite)
{
syncExecTimeout *= 3;
}
try
{
if (!WaitWithCondition.Wait(SyncEvent, syncExecTimeout, recorder.CancelEvent))
{
// timeout
LogString("SyncExecute: timeout");
throw new TimeoutException(MakeLogString("SyncExecute: timeout"));
}
}
catch (WaitWithCondition.ConditionMetException)
{
throw new CanceledException();
}
// we didn't timeout, check the result
switch (ComReport.Result)
{
case CommunicationConstantsAndEnums.CommunicationResult.Canceled:
throw new CanceledException();
case CommunicationConstantsAndEnums.CommunicationResult.ReceiveOK:
if (baseResponse == null)
{
LogString("SyncExecute: ReceiveOK but response==null!");
LogCommand(false);
throw new Exception(MakeLogString("SyncExecute: ReceiveOK but response==null!"));
}
if (baseResponse.Status == DFConstantsAndEnums.CommandStatus.StatusSlicebusNoResponse)
{
SurfaceError($"Possible hardware issue detected on {recorder.SerialNumber} [SliceBusNoResponse]. Please contact DTS support");
}
if (baseResponse.Status != DFConstantsAndEnums.CommandStatus.StatusNoError)
{
// didn't go well
var msg = MakeLogString("SyncExecute: response.Status = " + baseResponse.Status);
LogCommand(false);
if (baseResponse.Status == DFConstantsAndEnums.CommandStatus.StatusInvalidModeForCommand ||
baseResponse.Status == DFConstantsAndEnums.CommandStatus.StatusInvalidCommand)
{
throw new CommandException(CommandErrorReason.InvalidMode, msg);
}
if (baseResponse.Status == DFConstantsAndEnums.CommandStatus.StatusUnimplemented ||
baseResponse.Status == DFConstantsAndEnums.CommandStatus.StatusInvalidCommand ||
baseResponse.Status == DFConstantsAndEnums.CommandStatus.StatusInvalidCommandType)
{
throw new NotImplementedException(msg);
}
var ex = new Exception(msg);
ex.Data.Add("Status", baseResponse.Status);
throw ex;
}
// everything is fine, let it exit
if (LogCommands)
{
LogCommand(false);
}
break;
case CommunicationConstantsAndEnums.CommunicationResult.ReceiveFailed:
{
var msg = MakeLogString("SyncExecute: ComReport.Result == " + ComReport.Result);
APILogger.LogString(msg);
LogCommand(false);
throw new CommandException(CommandErrorReason.ReceiveFailed, msg);
}
case CommunicationConstantsAndEnums.CommunicationResult.ReceiveTimeout:
{
var msg = MakeLogString("SyncExecute: ComReport.Result == " + ComReport.Result);
APILogger.LogString(msg);
LogCommand(false);
throw new CommandException(CommandErrorReason.ReceiveFailed, msg);
}
case CommunicationConstantsAndEnums.CommunicationResult.SendFailed:
case CommunicationConstantsAndEnums.CommunicationResult.SendTimeout:
{
var msg = MakeLogString("SyncExecute: ComReport.Result == " + ComReport.Result);
APILogger.LogString(msg);
LogCommand(false);
throw new CommandException(CommandErrorReason.SendFailed, msg);
}
default:
{
var msg = MakeLogString("SyncExecute: Unknown ComReport.Result == " + ComReport.Result);
APILogger.LogString(msg);
LogCommand(false);
throw new Exception(msg);
}
}
}
finally
{
recorder.ExecuteIsBusy = false;
}
}
public virtual void SyncExecute()
{
try
{
InternalSyncExecute();
// if we get here, everything is fine
return;
}
catch (TimeoutException te)
{
// and again
LogString("SyncExecute: timeout");
//the retry here was causing a lot of issues
//seems better to just accept the death of the command and re-issue as needed
throw te;
}
}
public virtual void Execute(CommandCallback cb, object cbData)
{
// this try/catch is to only handle ExecuteIsBusy
try
{
// there can be only one!
recorder.ExecuteIsBusy = true;
if (!recorder.Connected)
{
// "Slice.CommandBase.Execute: No recorder connected"
throw new System.Exception(Strings.Slice_CommandBase_Execute_Err1);
}
if (cb == null)
{
// "Slice.CommandBase.Execute: Callback can't be null"
throw new ArgumentException(Strings.Slice_CommandBase_Execute_Err2);
}
if (recorder.ProtocolVersion < MinimumProtocolVersion)
{
// "Slice.CommandBase.Execute: The recorder's protocol version does not support this command"
throw new System.Exception(Strings.Slice_CommandBase_Execute_Err3);
}
if (recorder.IsCanceled())
{
throw new CanceledException();
}
// this is the tail end of execute, do some bookeeping first
//Debug.Assert(false == command.AlreadyRun);
if (baseCommand.AlreadyRun)
{
baseCommand.GetNextSequenceNumber();
}
baseCommand.AlreadyRun = true;
baseCommand.ComputeCRCs();
var CommandBytes = baseCommand.ToBytes();
baseCommand.OriginalBytes = CommandBytes;
UserCallback = cb;
UserCallbackData = cbData;
IsSynchronous = false;
LogCommand(true);
ExecuteTime = DateTime.Now;
recorder.Execute(CommandBytes, ExecuteCallback, null, IO_Timeout);
}
catch (System.Exception ex)
{
APILogger.Log(ex);
// if an exception has happend the execute is actually started and execute is therefore not busy.
// After execute starts the only responses we get is thru ExecuteCallback
recorder.ExecuteIsBusy = false;
throw;
}
}
/// <summary>
/// returns a commandpacket object
/// this is necessary because commandpackets are specific to inheritted classes
/// and can contain different packing of bytes and different verification schemes
/// an example would be <see cref="SliceCommandPacketBase" />
/// </summary>
/// <param name="buffer"></param>
/// <returns></returns>
protected abstract CommandPacketBase GetCommandPacket(byte[] buffer);
protected abstract CommandPacketBase GetCommandPacket();
/// <summary>
/// allows inheriting classes to add their own log statements to entries
/// when overriding, be sure to call base class implementation
/// the first line of the two dimensional array is the header information
/// from the command (like sequence number, type of command, etc)
/// </summary>
/// <param name="lines"></param>
public virtual void CommandToString(ref List<List<string>> lines)
{
}
/// <summary>
/// allows inheriting classes to add their own log statements to log entries
/// when overriding, make sure to call the base class to pick up statements
/// added by parent classes
/// the base class will add a line if there is an error
/// </summary>
/// <param name="lines"></param>
public virtual void ResponseToString(ref List<List<string>> lines)
{
if (null == baseResponse || baseResponse.Status != DFConstantsAndEnums.CommandStatus.StatusNoError)
{
lines.Add(new List<string>()
{
$"XXXXX ERROR XXXXX {baseResponse.Status.ToString()}"
});
}
}
public const string RESPONSESTART_STRING = "<- ";
private const string SPACE_STRING = " ";
public const string COMMANDSTART_STRING = "-> ";
/// <summary>
/// outputs a two dimensional array of log information into a single string
/// using a two dimensional array means that subclasses don't need to care
/// about how much data was already put into the arrays, they can just add
/// whatever data they need to report
/// </summary>
/// <param name="lines">two dimensional array of log data</param>
/// <param name="bSending"></param>
/// <returns></returns>
private string FormatLogEntry(List<List<string>> lines, bool bSending)
{
StringBuilder sb = new StringBuilder(200);
for (var i = 0; i < lines.Count; i++)
{
if (0 == i)
{
sb.Append(bSending ? COMMANDSTART_STRING : RESPONSESTART_STRING);
}
else { sb.Append(SPACE_STRING); }
for (var j = 0; j < lines[i].Count; j++)
{
if (j > 0) { sb.Append(", "); }
sb.Append(lines[i][j]);
}
}
return sb.ToString();
}
/// <summary>
/// outputs a single string for logging
/// </summary>
/// <param name="bSending">log outgoing or ingoing command</param>
/// <returns></returns>
private string GetFormattedLogEntry(bool bSending)
{
var lines = new List<List<string>>();
if (bSending)
{
baseCommand.GetPacketLogHeader(ref lines);
CommandToString(ref lines);
}
else
{
if (null != baseResponse)
{
baseResponse.GetPacketLogHeader(baseCommand, ref lines, ExecuteTime);
ResponseToString(ref lines);
}
}
return FormatLogEntry(lines, bSending);
}
}
}

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram />

View File

@@ -0,0 +1,238 @@
using DTS.Common.Interface.DASFactory;
using System;
using System.Collections.Generic;
using System.Linq;
using static DTS.Common.Enums.DASFactory.DFConstantsAndEnums;
namespace DTS.DASLib.Command.Classes
{
/// <summary>
/// DiscoveredDevice class is used by the multicast autodiscovery mechanism to describe response payload from devices
/// </summary>
public class DiscoveredDevice : IDiscoveredDevice, IComparable<DiscoveredDevice>
{
//Addresses are strings so SortableBindingList can be used unmodified
#region UDP payload properties
/// <summary>
/// Device Serial Number
/// </summary>
public string Serial { get; set; }
/// <summary>
/// Device type
/// </summary>
public MultiCastDeviceClasses DevClass { get; set; }
/// <summary>
/// Device Mac
/// </summary>
public string Mac { get; set; }
public IDiscoveredDevice Parent { get; set; }
public bool IsParent(IDiscoveredDevice possibleChild)
{
if (null == Connections)
{
return false;
}
var matches = from connection in Connections where connection.MACAddress == possibleChild.Mac select connection;
var connectedEthernetDevices = matches as ConnectedEthernetDevice[] ?? matches.ToArray();
if (!connectedEthernetDevices.Any()) { return false; }
//if it matches it's our DIRECT uplink/parent if it contains all of our children and no other children ON THIS PORT.
var port = connectedEthernetDevices[0].Port;
var childrenOnPort = from connection in Connections where connection.Port == port select connection;
return childrenOnPort.Count() == 1 + possibleChild.Connections.Length;
}
public int GetPort(IDiscoveredDevice device)
{
var matches = from connection in Connections where connection.MACAddress == device.Mac select connection;
var connectedEthernetDevices = matches as ConnectedEthernetDevice[] ?? matches.ToArray();
if (!connectedEthernetDevices.Any()) { return -1; }
return connectedEthernetDevices[0].Port;
}
private List<IDiscoveredDevice> _orderedList = null;
public int GetSlot(IDiscoveredDevice child, Dictionary<string, IDiscoveredDevice> lookup)
{
if (null == _orderedList)
{
_orderedList = new List<IDiscoveredDevice>();
foreach (var macAddress in Connections.Select(x => x.MACAddress))
{
if (!lookup.ContainsKey(macAddress)) continue;
var device = lookup[macAddress];
if (null == device) continue;
_orderedList.Add(device);
_orderedList.Sort(new DiscoveredChildrenSorter());
}
}
var slot = _orderedList.IndexOf(child);
return slot <= 0 ? 1 : 1 + slot;
}
public int GetSlotOnPort(IDiscoveredDevice child, Dictionary<string, IDiscoveredDevice> lookup)
{
var matches = from device in _orderedList where device.Port == child.Port select device;
var slotOnPort = matches.ToList().IndexOf(child);
return slotOnPort <= 0 ? 1 : 1 + slotOnPort;
}
/// <summary>
/// so what we want here is first alphabetic by ultimate parent, then
/// by slot within each parent
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
public int CompareTo(DiscoveredDevice other)
{
var myUltimateParent = GetParent(this);
var otherUltimateParent = GetParent(other);
if (null == myUltimateParent && null == otherUltimateParent)
{
//both SLICE6dbs or both without a chain...
return String.Compare(Serial, other.Serial, StringComparison.Ordinal);
}
if (null == myUltimateParent)
{
if (otherUltimateParent == this)
{
return -1;
}
return string.Compare(Serial, otherUltimateParent.Serial, StringComparison.Ordinal);
}
if (null == otherUltimateParent)
{
if (myUltimateParent == other)
{
return 1;
}
return string.Compare(myUltimateParent.Serial, other.Serial, StringComparison.Ordinal);
}
//we both have parents, if they aren't the same, then use their serial numbers
if (myUltimateParent != otherUltimateParent)
{
return string.Compare(myUltimateParent.Serial, otherUltimateParent.Serial, StringComparison.Ordinal);
}
//same parent, first compare port
if (Port != other.Port) { return Port.CompareTo(other.Port); }
//on same port, then use slot
return PositionOnDistributor.CompareTo(other.PositionOnDistributor);
}
public static IDiscoveredDevice GetParent(IDiscoveredDevice device)
{
var target = device;
while (null != target.Parent) { target = target.Parent; }
return target != device ? target : null;
}
public class DiscoveredChildrenSorter : IComparer<IDiscoveredDevice>
{
int IComparer<IDiscoveredDevice>.Compare(IDiscoveredDevice x, IDiscoveredDevice y)
{
if (x == y) { return 0; }
if (null == x) { return -1; }
if (null == y) { return 1; }
return x.Port != y.Port ? x.Port.CompareTo(y.Port) : y.Connections.Length.CompareTo(x.Connections.Length);
}
}
public bool IsModule { get; set; }
/// <summary>
/// if I'm on a SLICE6DB, what port am I on
/// </summary>
public int Port { get; set; }
/// <summary>
/// starting at the first device in the chain on the first point, up until the last device on the last chain/port, where is this device
/// this is used to as we don't show SLICE6 devices when on a SLICE6Db, but we still need to know which devices is where for showing
/// the channels in the UI
/// </summary>
public int PositionOnDistributor { get; set; }
/// <summary>
/// where is this device in a chain of devices, only used for SLICE6 on a SLICE6Db right now
/// </summary>
public int PositionOnChain { get; set; }
/// <summary>
/// Is DHCP enabled
/// </summary>
public bool Dhcp { get; set; }
/// <summary>
/// Device IP
/// </summary>
public string Ip { get; set; }
/// <summary>
/// Device Subnet
/// </summary>
public string Subnet { get; set; }
/// <summary>
/// Device Gateway
/// </summary>
public string Gateway { get; set; }
/// <summary>
/// Device DNS Sever
/// </summary>
public string Dns { get; set; }
/// <summary>
/// Is Device connected to another host
/// </summary>
public bool Connected { get; set; }
/// <summary>
/// Host IP that device is connected to
/// </summary>
public string ConnectedIp { get; set; }
/// <summary>
/// Host Name Resolution that device is connected to
/// </summary>
public string ConnectedHost { get; set; }
/// <summary>
/// User entry for Distributor ID that device is connected to
/// </summary>
public ushort SystemId { get; set; }
/// <summary>
/// User entry for location of device
/// </summary>
public string Location { get; set; }
/// <summary>
/// Firmware version string
/// [Product Name]-[FW/BL]-[REL/DBG]-[Board #]-[FW Ver Name]
/// </summary>
public string FirmwareVersion { get; set; }
/// <summary>
/// Build Server number for the firmware
/// </summary>
public string BuildId { get; set; }
#endregion
public IConnectedEthernetDevice[] Connections { get; set; }
public DiscoveredDevice()
{
Connections = new IConnectedEthernetDevice[0];
}
}
public class ConnectedEthernetDevice : IConnectedEthernetDevice
{
public string MACAddress { get; }
public int Port { get; }
public ConnectedEthernetDevice(string macAddress, int port) { MACAddress = macAddress; Port = port; }
public string SerialNumber { get; set; }
}
}

View File

@@ -0,0 +1,104 @@
using DTS.Common.Interface.DASFactory;
using System;
namespace DTS.DASLib.Command.Classes
{
public class UDPQATSEntry : IUDPQATSEntry
{
public string ResponseHostMac { get; private set; }
public string ResponseClientMacAddress { get; private set; }
public string SerialNumber { get; private set; }
public byte ArmState { get; private set; }
public byte ArmMode { get; private set; }
public byte Started { get; private set; }
public byte Triggered { get; private set; }
public byte FaultFlags { get; private set; }
public uint SampleRate { get; private set; }
public ulong TotalSamples { get; private set; }
public ulong CurrentSample { get; private set; }
public ushort EventNumber { get; private set; }
public ulong FaultSampleNumber { get; private set; }
public ushort LegacyFaultFlags { get; private set; }
public float InputVoltage { get; private set; }
public float BackupVoltage { get; private set; }
public float BatterySOC { get; private set; }
public ulong EstimateMaxSamples { get; private set; }
public short TiltSensorCh1 { get; private set; }
public short TiltSensorCh2 { get; private set; }
public short TiltSensorCh3 { get; private set; }
public float SysTempC { get; private set; }
public byte SyncClockEnable { get; private set; }
public byte ADCExtClockSyncEnable { get; private set; }
public byte SyncClockStatus { get; private set; }
public byte ADCExtClockSyncStatus { get; private set; }
public ulong EventTriggerSample { get; private set; }
public float[] ChannelOffsetMV { get; private set; } = new float[6];
public float[] ShuntDeviationPercent { get; private set; } = new float[6];
public DateTime Timestamp { get; private set; } = DateTime.Now;
public UDPQATSEntry(string responseHostMac,
string responseClientMacAddress,
string serialNumber,
byte armState,
byte armMode,
byte started,
byte triggered,
byte faultFlags,
uint sampleRate,
ulong totalSamples,
ulong currentSample,
ushort eventNumber,
ulong faultSampleNumber,
ushort legacyFaultFlags,
float inputVoltage,
float backupVoltage,
float batterySOC,
ulong estimateMaxSamples,
short tiltSensorCh1,
short tiltSensorCh2,
short tiltSensorCh3,
float sysTempC,
byte syncClockEnable,
byte adcExtClockSyncEnable,
byte syncClockStatus,
byte adcExtClockSyncStatus,
ulong eventTriggerSample,
float[] channelOffsetMV,
float[] channelShuntDeviationPercent,
DateTime timeStamp)
{
ResponseHostMac = responseHostMac;
ResponseClientMacAddress = responseClientMacAddress;
SerialNumber = serialNumber;
ArmState = armState;
ArmMode = armMode;
Started = started;
Triggered = triggered;
FaultFlags = faultFlags;
SampleRate = sampleRate;
TotalSamples = totalSamples;
CurrentSample = currentSample;
EventNumber = eventNumber;
FaultSampleNumber = faultSampleNumber;
LegacyFaultFlags = legacyFaultFlags;
InputVoltage = inputVoltage;
BackupVoltage = backupVoltage;
BatterySOC = batterySOC;
EstimateMaxSamples = estimateMaxSamples;
TiltSensorCh1 = tiltSensorCh1;
TiltSensorCh2 = tiltSensorCh2;
TiltSensorCh3 = tiltSensorCh3;
SysTempC = sysTempC;
SyncClockEnable = syncClockEnable;
ADCExtClockSyncEnable = adcExtClockSyncEnable;
SyncClockStatus = syncClockStatus;
ADCExtClockSyncStatus = adcExtClockSyncStatus;
EventTriggerSample = eventTriggerSample;
ChannelOffsetMV = channelOffsetMV;
ShuntDeviationPercent = channelShuntDeviationPercent;
Timestamp = timeStamp;
}
}
}

View File

@@ -0,0 +1,60 @@
using System;
using System.Text;
// ReSharper disable InconsistentNaming
namespace DTS.DASLib.Command
{
/// <summary>
/// this is an abstraction of the LogEntryBase classes, I extracted the common
/// functionality and put it here
/// this class in turn is used by SliceCommandLogEntry and CommonLogEntry(ribeye)
/// the reason for the additional classes is the structure of the packets and how the log looks
/// differs slightly between ribeye and slice
/// I'm not sure these classes are in use?
/// 6/14/2010 - dtm
/// </summary>
public abstract class CommandLogEntryBase
{
protected StringBuilder sb;
protected CommandPacketBase command;
/// <summary>
/// construct a CommandLogEntryBase object
/// </summary>
/// <param name="_command">underlying command</param>
public CommandLogEntryBase(CommandPacketBase _command)
{
sb = new StringBuilder();
command = _command;
sb.AppendFormat("=== {0:08d} ==={1}", _command.SequenceNumber, Environment.NewLine);
}
/// <summary>
/// adds command data into log
/// </summary>
/// <param name="CommandName"></param>
public void TagCommonCommandData(string CommandName)
{
sb.AppendFormat("Log Entry Type:\t\t{0} command{1}", CommandName, Environment.NewLine);
}
/// <summary>
/// adds response data into log
/// </summary>
/// <param name="CommandName"></param>
public void TagCommonResponseData(string CommandName)
{
sb.AppendFormat("Response Status:\t\t{0}{1}", command.Status, Environment.NewLine);
sb.AppendFormat("Response Timestamp:\t{0} {1}{2}", DateTime.Now.ToShortDateString(),
DateTime.Now.ToLongTimeString(), Environment.NewLine);
}
/// <summary>
/// returns the log entry represented as a string
/// </summary>
/// <returns></returns>
public override string ToString()
{
return sb.ToString();
}
}
}

View File

@@ -0,0 +1,321 @@
using System;
using System.Collections.Generic;
using System.Text;
using DTS.Common.DASResource;
using DTS.Common.Enums.DASFactory;
namespace DTS.DASLib.Command
{
/// <summary>
/// this is an abstraction of the common functions and behaviors of the CommandPackets
/// 6/14/2010 - dtm
/// </summary>
public abstract class CommandPacketBase
{
/// <summary>
/// the state of command packet
/// </summary>
public enum PacketState
{
#pragma warning disable 1591
OK,
TooShort,
Unknown
#pragma warning restore 1591
};
/// <summary>
/// corresponding strings for CommandStatus enum
/// </summary>
public static String[] StatusLabels =
{
#pragma warning disable 1591
// 0x00
Strings.CmdStatusNoErr,
// 0x01
Strings.CmdStatusInvalidParam,
// 0x02
Strings.CmdStatusInvalidParamLen,
// 0x03
Strings.CmdStatusInvalidCmdType,
// 0x04
Strings.CmdStatusInvalidCmd,
// 0x05
Strings.CmdStatusInvalidCRC,
// 0x06
Strings.CmdStatusInvalidCmdMode,
// 0x07
Strings.CmdStatusUnimplemented,
// 0x08
Strings.CmdStatusInvalidRecCRC,
// 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
Strings.CmdStatusInvalidDevID,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0x10
Strings.CmdStatusFlashErase,
// 0x11
Strings.CmdStatusFlashWrite,
// 0x12
Strings.CmdStatusFlashBlockCRC,
// 0x13
Strings.CmdStatusFlashImageCRC,
// 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0x20
Strings.CmdStatusInvalidAttrib,
// 0x21
Strings.CmdStatusAttribSet,
// 0x22
Strings.CmdStatusAttribBackup,
// 0x23
Strings.CmdStatusAttribBuffer,
// 0x24 - 0x2F
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0x30 - 0x3F
Strings.CmdStatusSampleRate,
Strings.CmdStatusEventLen,
Strings.CmdStatusArmMode,
Strings.CmdStatusUnimplArmMode,
Strings.CmdStatusEventTooLarge,
Strings.CmdStatusMemFull,
Strings.CmdStatusInvalidSliceCount,
Strings.CmdStatusShortedStart,
Strings.CmdStatusShortedTrigger,
Strings.CmdStatusInvalidPreTrig,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0x40 - 0x4F
Strings.CmdStatusStartSDWrite,
Strings.CmdStatusFlushSDBlock,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0x50 - 0x5F
Strings.CmdStatusSwitchReq,
Strings.CmdStatusSwitchSetting,
Strings.CmdStatusSwitchChannel,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0x60 - 0x6F
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0x70 - 0x7F
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0x80 - 0x8F
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0x90 - 0x9F
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0xA0 - 0xAF
Strings.CmdStatusSlicebusInvalidHeaderCRC,
Strings.CmdStatusSlicebusInvalidDataCRC,
Strings.CmdStatusSlicebusNullDescriptor,
Strings.CmdStatusSlicebusNotImplemented,
Strings.CmdStatusSlicebusNoResponse,
Strings.CmdStatusSlicebusNullCommandBuffer,
Strings.CmdStatusSlicebusCommandBufferTooShort,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0xB0 - 0xBF
Strings.CmdStatusSetupRequestedSensorRangeTooSmall,
Strings.CmdStatusSetupInvalidStackChannel,
Strings.CmdStatusSetupInvalidChannelRequested,
Strings.CmdStatusSetupInconsistentChannelCountFound,
Strings.CmdStatusSetupNoShuntTargetsSet,
Strings.CmdStatusSetupNoBridgeResistancesSet,
Strings.CmdStatusSetupChannelDoesNotSupportShunt,
Strings.CmdStatusSetupShuntDACOutputExceeded,
Strings.CmdStatusSetupRequestedSensorRangeTooLarge,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0xC0 - 0xCF
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0xD0 - 0xDF
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0xE0 - 0xEF
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
// 0xF0 - 0xFF
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
Strings.CmdStatusUnknown, Strings.CmdStatusUnknown,
#pragma warning restore 1591
};
/// <summary>
/// the status of the packet
/// </summary>
public DFConstantsAndEnums.CommandStatus Status;
/// <summary>
/// the command, use SetCommand to assign
/// </summary>
private byte _Command;
/// <summary>
/// string description of the command, for logging
/// </summary>
private string _CommandDescription;
/// <summary>
/// assigns a command to the packet structure
/// </summary>
/// <param name="command">byte command information</param>
/// <param name="commandDescription">string describing command</param>
public void SetCommand(byte command, string commandDescription)
{
_Command = command;
_CommandDescription = commandDescription;
}
/// <summary>
/// returns command (byte) information
/// </summary>
/// <returns></returns>
public byte GetCommand() { return _Command; }
/// <summary>
/// returns a string description of command
/// </summary>
/// <returns></returns>
public string GetCommandDescription() { return _CommandDescription; }
/// <summary>
/// wether or not to log
/// </summary>
public bool ShouldLog;
public bool AlreadyRun { get; set; }
public byte[] OriginalBytes;
/// <summary>
/// the command put into byte array form, for executing to hardware
/// </summary>
/// <returns></returns>
public abstract byte[] ToBytes();
/// <summary>
/// this is an enum CommandType, inheritting classes implement CommandType themselves, so
/// the we don't know the possible values of the enum in the base class,
/// however we do know we'll need to store and use the enum value
/// </summary>
public object Type;
/// <summary>
/// produce a string representing the command
/// </summary>
/// <returns>formatted string</returns>
public override string ToString()
{
return GetCommand().ToString();
//return this.Command.ToString();
}
public UInt16 SequenceNumber;
/// <summary>
/// each CommandPacket can have it's own enum of commandtypes
/// so, we just let the inheritting classes define them on their own
/// and just request a method of getting the resulting object post
/// conversion back
/// </summary>
/// <param name="b">byte to be converted</param>
/// <returns>CommandType, an enum contained in inheritting classes</returns>
public abstract object ConvertByteToCommandType(byte b);
/// <summary>
/// verify if the packet is valid or not
/// </summary>
/// <param name="Bytes"></param>
/// <returns></returns>
public abstract PacketState VerifyPacket(byte[] Bytes);
/// <summary>
/// get the next sequence number.
/// note sliceDB, slice, and ribeye all have different counters for
/// packets, so they could all have a sequence #1 independently
/// </summary>
public abstract void GetNextSequenceNumber();
/// <summary>
/// triggers the packet's logic to compute a checksum or CRC
/// different packets may use different methods (slice-crc, ribeye-checksum)
/// </summary>
public abstract void ComputeCRCs();
/// <summary>
/// formats a header for the log entry for the response packet
/// incoming (response) packets may have less information, so the
/// associated outgoing packet is also passed in
/// </summary>
/// <param name="commandPacket">outgoing command packet</param>
/// <param name="lines">two dimensional array of string log data</param>
public void GetPacketLogHeader(CommandPacketBase commandPacket, ref List<List<string>> lines, DateTime executeTime)
{
lines.Add(new List<string>());
string type = null != Type ? Type.ToString() : "";
ushort sequence = SequenceNumber;
if (0 == sequence && null != commandPacket) { sequence = commandPacket.SequenceNumber; }
var sSequence = $"[{sequence.ToString("00000000")}]\\[{SequenceNumber.ToString("00000000")}]";
lines[0].Add(string.Format("{0} - {1} {2} - ({3}ms)", type, commandPacket.GetCommandDescription(), sSequence, DateTime.Now.Subtract(executeTime).TotalMilliseconds));
if (Status != DFConstantsAndEnums.CommandStatus.StatusNoError)
{
lines.Add(new List<string>() { Status.ToString() });
}
}
/// <summary>
/// returns a header for the log entry for a command packet
/// </summary>
/// <param name="lines">two dimensional array of string log data</param>
public void GetPacketLogHeader(ref List<List<string>> lines)
{
lines.Add(new List<string>());
lines[0].Add(string.Format("{0} - {1} [{2:00000000}]", Type.ToString(), GetCommandDescription(), SequenceNumber));
if (Status != DFConstantsAndEnums.CommandStatus.StatusNoError)
{
lines.Add(new List<string>() { Status.ToString() });
}
}
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace DTS.DASLib.Command
{
/// <summary>
/// class encapsulating the return status and value from a command
/// 6/14/2010 - dtm
/// </summary>
public class CommandReport : ICommandReport
{
public object CallbackObject { get; set; }
public CommandStatus Status { get; set; }
public CommandReport(CommandStatus _Status, object _CallbackObject)
{
Status = _Status;
CallbackObject = _CallbackObject;
}
}
}

View File

@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="DTS.DASLib.Command.AbstractCommandBase" Collapsed="true">
<Position X="3.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>IkAKwgFVAAMAAUyAwIACIIBCACAAIAgEDAUQCWBTIEg=</HashCode>
<FileName>AbstractCommandBase.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="DTS.DASLib.Command.CommandLogEntryBase" Collapsed="true">
<Position X="7.75" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAGAAAAAAAEAAQAAAAAAAAAAAAQAAA=</HashCode>
<FileName>CommandLogEntryBase.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.CommandPacketBase" Collapsed="true">
<Position X="0.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>EAAAAAGEAAAAAAAMAAiBABQAAAAAACAAAwkAAQBAAAA=</HashCode>
<FileName>CommandPacketBase.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.CommandReport" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="9.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAA=</HashCode>
<FileName>CommandReport.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" Collapsed="true" />
</Class>
<Class Name="DTS.DASLib.Command.CommandException" Collapsed="true">
<Position X="6" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.SliceCommandBase" Collapsed="true">
<Position X="3.5" Y="1.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AgAAAECAAIAAAQAAAAAAAABEAAQAAAAAAAAAEAAAAEA=</HashCode>
<FileName>SliceCommandBase.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.SliceCommandPacketBase" Collapsed="true">
<Position X="0.5" Y="1.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAQAQCAAIAwAgEoEQAABIAAEEgRAGAEAAAAEAAAAAA=</HashCode>
<FileName>SliceCommandPacketBase.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.Classes.DiscoveredDevice" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="7.75" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>ABEIQAAAAJAAQAQABAIAYgAkGBAQAICAAAACICQAIAA=</HashCode>
<FileName>Classes\DiscoveredDevice.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" Collapsed="true" />
</Class>
<Class Name="DTS.DASLib.Command.Classes.ConnectedEthernetDevice" Collapsed="true">
<Position X="6" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAACAEAAACAAAAAAAAAAAA=</HashCode>
<FileName>Classes\DiscoveredDevice.cs</FileName>
</TypeIdentifier>
</Class>
<Interface Name="DTS.DASLib.Command.ICommandReport" Collapsed="true">
<Position X="7.75" Y="2.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="DTS.DASLib.Command.ICommand" Collapsed="true">
<Position X="6" Y="2.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AgAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Interface>
<Enum Name="DTS.DASLib.Command.CommandStatus" Collapsed="true">
<Position X="9.5" Y="3.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAgAAAAAAAAgAAAACAAAAAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Enum>
<Enum Name="DTS.DASLib.Command.CommandErrorReason" Collapsed="true">
<Position X="6" Y="3.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAIAgAAAAAAAAAAAAAAAAAEAAAACAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Enum>
<Enum Name="DTS.DASLib.Command.CommandReceiveAction" Collapsed="true">
<Position X="7.75" Y="3.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAACAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Enum>
<Delegate Name="DTS.DASLib.Command.CommandCallback" Collapsed="true">
<Position X="6" Y="4.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Delegate>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>

View File

@@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="DTS.DASLib.Command.Classes.DiscoveredDevice" Collapsed="true">
<Position X="3.75" Y="3.75" Width="1.5" />
<NestedTypes>
<Class Name="DTS.DASLib.Command.Classes.DiscoveredDevice.DiscoveredChildrenSorter" Collapsed="true">
<TypeIdentifier>
<NewMemberFileName>Classes\DiscoveredDevice.cs</NewMemberFileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Enum Name="DTS.DASLib.Command.Classes.DiscoveredDevice.MultiCastDeviceClasses" Collapsed="true">
<TypeIdentifier>
<NewMemberFileName>Classes\DiscoveredDevice.cs</NewMemberFileName>
</TypeIdentifier>
</Enum>
</NestedTypes>
<TypeIdentifier>
<HashCode>ABEIQAAAAJAAQAQABAIAYgAkGBAQAICAAAACICQAIAA=</HashCode>
<FileName>Classes\DiscoveredDevice.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="DTS.DASLib.Command.Classes.ConnectedEthernetDevice" Collapsed="true">
<Position X="2" Y="3.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAACAEAAACAAAAAAAAAAAA=</HashCode>
<FileName>Classes\DiscoveredDevice.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.AbstractCommandBase" Collapsed="true">
<Position X="4.25" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>IkAKwgFVAAMAAUyAwIACIIBCACAAIAgEDAUQCWBTIEg=</HashCode>
<FileName>AbstractCommandBase.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="DTS.DASLib.Command.CommandLogEntryBase" Collapsed="true">
<Position X="8.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAGAAAAAAAEAAQAAAAAAAAAAAAQAAA=</HashCode>
<FileName>CommandLogEntryBase.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.CommandPacketBase" Collapsed="true">
<Position X="1.25" Y="0.5" Width="1.5" />
<Compartments>
<Compartment Name="Nested Types" Collapsed="false" />
</Compartments>
<NestedTypes>
<Enum Name="DTS.DASLib.Command.CommandPacketBase.CommandStatus" Collapsed="true">
<TypeIdentifier>
<NewMemberFileName>CommandPacketBase.cs</NewMemberFileName>
</TypeIdentifier>
</Enum>
<Enum Name="DTS.DASLib.Command.CommandPacketBase.PacketState" Collapsed="true">
<TypeIdentifier>
<NewMemberFileName>CommandPacketBase.cs</NewMemberFileName>
</TypeIdentifier>
</Enum>
</NestedTypes>
<TypeIdentifier>
<HashCode>EAAAAAGEAAAAAAAMAAiBABQAAAAAACAAAwkAAQBAAAA=</HashCode>
<FileName>CommandPacketBase.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.CommandReport" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="6.75" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAA=</HashCode>
<FileName>CommandReport.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" Collapsed="true" />
</Class>
<Class Name="DTS.DASLib.Command.CommandException" Collapsed="true">
<Position X="6.75" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.SliceCommandBase" Collapsed="true">
<Position X="4.25" Y="1.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AgAAAECAAIAAAQAAAAAAAABEAAQAAAAAAAAAEAAAAEA=</HashCode>
<FileName>SliceCommandBase.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DTS.DASLib.Command.SliceCommandPacketBase" Collapsed="true">
<Position X="1.25" Y="1.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAQAQCAAIAwAgEoEQAABIAAEEgRAGAEAAAAEAAAAAA=</HashCode>
<FileName>SliceCommandPacketBase.cs</FileName>
</TypeIdentifier>
</Class>
<Interface Name="DTS.DASLib.Command.ICommandReport" Collapsed="true">
<Position X="8.5" Y="2.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="DTS.DASLib.Command.ICommand" Collapsed="true">
<Position X="6.75" Y="2.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AgAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Interface>
<Enum Name="DTS.DASLib.Command.CommandStatus" Collapsed="true">
<Position X="6.75" Y="4.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAgAAAAAAAAgAAAACAAAAAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Enum>
<Enum Name="DTS.DASLib.Command.CommandErrorReason" Collapsed="true">
<Position X="6.75" Y="3.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAIAgAAAAAAAAAAAAAAAAAEAAAACAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Enum>
<Enum Name="DTS.DASLib.Command.CommandReceiveAction" Collapsed="true">
<Position X="8.5" Y="3.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAACAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Enum>
<Delegate Name="DTS.DASLib.Command.CommandCallback" Collapsed="true">
<Position X="6.75" Y="5.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>ICommand.cs</FileName>
</TypeIdentifier>
</Delegate>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>

View File

@@ -0,0 +1,440 @@
<?xml version="1.0" encoding="utf-8"?>
<DirectedGraph DataVirtualized="True" Layout="Sugiyama" ZoomLevel="-1" xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="@10" Category="CodeSchema_Assembly" AssemblyTimestamp="12/14/2018 20:59:11" Bounds="-177.494798819339,45.3125833333333,174.97,25" CodeSchemaProperty_StrongName="SliceDBCommands, Version=1.6.81.0, Culture=neutral, PublicKeyToken=null" DelayedChildNodesState="NotFetched" DelayedCrossGroupLinksState="Fetched" FilePath="$(dea48a0b-999e-48e8-8601-cb05b6b765de.OutputPath)" Group="Collapsed" Label="SliceDBCommands.dll">
<Category Ref="FileSystem.Category.FileOfType.dll" />
</Node>
<Node Id="@12" Category="CodeSchema_Assembly" AssemblyTimestamp="12/14/2018 20:59:12" Bounds="-371.881565486005,45.3125,164.386666666667,25" CodeSchemaProperty_StrongName="SLICECommands, Version=1.6.81.0, Culture=neutral, PublicKeyToken=null" DelayedChildNodesState="NotFetched" DelayedCrossGroupLinksState="Fetched" FilePath="$(d015f93d-9507-4484-977b-4cf1bdc0b30e.OutputPath)" Group="Collapsed" Label="SLICECommands.dll">
<Category Ref="FileSystem.Category.FileOfType.dll" />
</Node>
<Node Id="@14" Category="CodeSchema_Assembly" AssemblyTimestamp="12/14/2018 20:59:11" Bounds="231.928734513995,45.3125,164.19,25" CodeSchemaProperty_StrongName="TDASCommands, Version=1.6.81.0, Culture=neutral, PublicKeyToken=null" DelayedChildNodesState="NotFetched" DelayedCrossGroupLinksState="Fetched" FilePath="$(14b4a79f-a4b5-4c4c-a041-0105eed82782.OutputPath)" Group="Collapsed" Label="TDASCommands.dll">
<Category Ref="FileSystem.Category.FileOfType.dll" />
</Node>
<Node Id="@16" Category="CodeSchema_Assembly" AssemblyTimestamp="12/14/2018 20:59:14" Bounds="-44.2683500953703,-64.6876166666667,135.89,25" CodeSchemaProperty_StrongName="DASFactory, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DelayedChildNodesState="NotFetched" DelayedCrossGroupLinksState="Fetched" FilePath="$(02eeba8c-7b22-4bc3-bf3a-8de23eaf2e61.OutputPath)" Group="Collapsed" Label="DASFactory.dll">
<Category Ref="FileSystem.Category.FileOfType.dll" />
</Node>
<Node Id="@2" Category="CodeSchema_Assembly" AssemblyTimestamp="12/14/2018 21:00:10" Bounds="117.812507273767,-139.687716666667,129.18,25" CodeSchemaProperty_StrongName="DataPRO, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DelayedChildNodesState="NotFetched" DelayedCrossGroupLinksState="Fetched" FilePath="$(8baa9433-8034-4fde-822c-537c59d3a7ec.OutputPath)" Group="Collapsed" Label="DataPRO.exe" UseManualLocation="True">
<Category Ref="CodeMap_WpfProject" />
<Category Ref="FileSystem.Category.FileOfType.exe" />
</Node>
<Node Id="@4" Category="CodeSchema_Assembly" AssemblyTimestamp="12/14/2018 20:59:11" Bounds="-12.2683288605816,100.312683333333,133.77,25" CodeSchemaProperty_StrongName="ICommand, Version=1.6.81.0, Culture=neutral, PublicKeyToken=null" DelayedChildNodesState="NotFetched" DelayedCrossGroupLinksState="Fetched" FilePath="$(58e70872-8acc-4957-bb8e-d3746bcc536d.OutputPath)" Group="Collapsed" Label="ICommand.dll" />
<Node Id="@6" Category="CodeSchema_Assembly" AssemblyTimestamp="12/14/2018 20:59:13" Bounds="4.74883362620589,-9.68751666666668,115.97,25" CodeSchemaProperty_StrongName="IService, Version=1.6.81.0, Culture=neutral, PublicKeyToken=null" DelayedChildNodesState="NotFetched" DelayedCrossGroupLinksState="Fetched" FilePath="$(c9c45b72-05a3-4962-bc13-a78b1f4b1925.OutputPath)" Group="Collapsed" Label="IService.dll">
<Category Ref="FileSystem.Category.FileOfType.dll" />
</Node>
<Node Id="@8" Category="CodeSchema_Assembly" AssemblyTimestamp="12/14/2018 20:59:11" Bounds="27.4753011806614,45.3125833333333,174.453333333333,25" CodeSchemaProperty_StrongName="Ribeye Commands, Version=1.6.81.0, Culture=neutral, PublicKeyToken=null" DelayedChildNodesState="NotFetched" DelayedCrossGroupLinksState="Fetched" FilePath="$(53abd0f3-7d8d-43cd-99d7-06c45246d93e.OutputPath)" Group="Collapsed" Label="Ribeye Commands.dll">
<Category Ref="FileSystem.Category.FileOfType.dll" />
</Node>
</Nodes>
<Links>
<Link Source="@10" Target="@4" Category="InheritsFrom" Bounds="-57.1402063188802,70.3125833333333,70.4750449869209,26.8010034600893" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="375">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_FieldRead" />
<Category Ref="CodeSchema_FieldWrite" />
<Category Ref="CodeSchema_ReturnTypeLink" />
</Link>
<Link Source="@12" Target="@4" Category="References" Bounds="-211.76899818276,70.2595262042781,191.629938440522,30.6114773435068" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="1719">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_FieldRead" />
<Category Ref="CodeSchema_FieldWrite" />
<Category Ref="CodeSchema_FunctionPointer" />
<Category Ref="CodeSchema_ReturnTypeLink" />
<Category Ref="Implements" />
<Category Ref="InheritsFrom" />
</Link>
<Link Source="@14" Target="@4" Category="References" Bounds="122.376908548554,70.3125,132.690871718339,28.133475535438" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="442">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_FieldRead" />
<Category Ref="CodeSchema_FieldWrite" />
<Category Ref="CodeSchema_FunctionPointer" />
<Category Ref="CodeSchema_ReturnTypeLink" />
<Category Ref="InheritsFrom" />
</Link>
<Link Source="@16" Target="@10" Category="CodeSchema_Calls" Bounds="-70.6229498301613,-39.6876166666667,81.3807085959602,78.741963727204" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="7">
<Category Ref="CodeMap_ProjectReference" />
</Link>
<Link Source="@16" Target="@12" Category="References" Bounds="-245.586626840792,-39.6876166666667,233.653668824858,82.0191805207747" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="159">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
</Link>
<Link Source="@16" Target="@14" Category="CodeSchema_Calls" Bounds="56.6706017984722,-39.6876166666667,215.94293941237,81.8115620505097" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="30">
<Category Ref="CodeMap_ProjectReference" />
</Link>
<Link Source="@16" Target="@4" Category="References" Bounds="-2.4352719783783,-39.6876182556152,43.8318822383881,132.490077972412" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="94">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
</Link>
<Link Source="@16" Target="@6" Category="References" Bounds="32.5532664293215,-39.6876166666667,16.0930225012287,22.6621011176714" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="531">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_FieldWrite" />
<Category Ref="CodeSchema_ReturnTypeLink" />
</Link>
<Link Source="@16" Target="@8" Category="CodeSchema_Calls" Bounds="65.0691528320313,-39.6876182556152,61.6118392944336,76.1888618469238" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="6">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_FieldRead" />
</Link>
<Link Source="@2" Target="@14" Category="References" Bounds="191.295823023052,-114.687716666667,108.617156935812,152.666845524603" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="11">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
</Link>
<Link Source="@2" Target="@16" Category="References" Bounds="58.2682468002986,-114.687716666667,97.6799861843111,46.155105748047" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="62">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
</Link>
<Link Source="@2" Target="@4" Category="References" Bounds="124.239486694336,-114.687713623047,81.4401245117188,213.188179016113" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="110">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_ReturnTypeLink" />
</Link>
<Link Source="@2" Target="@6" Category="References" Bounds="80.3358170747098,-114.687716666667,90.560104666154,98.3785593988733" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="7433">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_FieldWrite" />
<Category Ref="CodeSchema_ReturnTypeLink" />
</Link>
<Link Source="@6" Target="@10" Category="CodeSchema_Calls" Bounds="-46.827632277619,15.3124833333333,74.8470671014717,26.9510166111526" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="50">
<Category Ref="CodeMap_ProjectReference" />
</Link>
<Link Source="@6" Target="@12" Category="References" Bounds="-202.126942242109,11.8252217236356,207.110104607883,32.3222076917732" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="2084">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_FieldRead" />
<Category Ref="CodeSchema_FieldWrite" />
<Category Ref="CodeSchema_ReturnTypeLink" />
<Category Ref="InheritsFrom" />
</Link>
<Link Source="@6" Target="@14" Category="References" Bounds="117.790990419989,14.8628861970343,130.329541871057,28.5253285139701" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="675">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_ReturnTypeLink" />
</Link>
<Link Source="@6" Target="@4" Category="References" Bounds="17.34108543396,15.3124837875366,27.8616542816162,77.5488519668579" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="923">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_FieldRead" />
<Category Ref="CodeSchema_ReturnTypeLink" />
</Link>
<Link Source="@6" Target="@8" Category="References" Bounds="74.5447517475189,15.3124833333333,22.1652030067121,23.4583827216558" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="39">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_FieldRead" />
</Link>
<Link Source="@8" Target="@4" Category="References" Bounds="74.9110788046124,70.3125833333333,26.1351646195079,23.9232681928351" IsSourceVirtualized="True" IsTargetVirtualized="True" Weight="93">
<Category Ref="CodeMap_ProjectReference" />
<Category Ref="CodeSchema_Calls" />
<Category Ref="CodeSchema_FieldRead" />
<Category Ref="CodeSchema_FieldWrite" />
<Category Ref="CodeSchema_ReturnTypeLink" />
<Category Ref="Implements" />
<Category Ref="InheritsFrom" />
</Link>
</Links>
<Categories>
<Category Id="CodeMap_ProjectReference" Label="Project Reference" CanBeDataDriven="True" CanLinkedNodesBeDataDriven="True" IncomingActionLabel="Referenced By" OutgoingActionLabel="References" />
<Category Id="CodeMap_WpfProject" Label="WPF Project" CanBeDataDriven="True" IsProviderRoot="False" NavigationActionLabel="WPF Projects" />
<Category Id="CodeSchema_Assembly" Label="Assembly" BasedOn="File" CanBeDataDriven="True" DefaultAction="Microsoft.Contains" Icon="CodeSchema_Assembly" NavigationActionLabel="Assemblies" />
<Category Id="CodeSchema_Calls" Label="Calls" CanBeDataDriven="True" CanLinkedNodesBeDataDriven="True" IncomingActionLabel="Called By" OutgoingActionLabel="Calls" />
<Category Id="CodeSchema_FieldRead" Label="Field Read" BasedOn="CodeSchema_FieldReference" CanBeDataDriven="True" CanLinkedNodesBeDataDriven="True" IncomingActionLabel="Read By" OutgoingActionLabel="Reads Fields" />
<Category Id="CodeSchema_FieldReference" Label="Field Reference" CanBeDataDriven="True" CanLinkedNodesBeDataDriven="True" IncomingActionLabel="Referenced By" OutgoingActionLabel="References Fields" />
<Category Id="CodeSchema_FieldWrite" Label="Field Write" BasedOn="CodeSchema_FieldReference" CanBeDataDriven="True" CanLinkedNodesBeDataDriven="True" IncomingActionLabel="Written By" OutgoingActionLabel="Writes Fields" />
<Category Id="CodeSchema_FunctionPointer" Label="Function Pointer" CanBeDataDriven="True" CanLinkedNodesBeDataDriven="True" IncomingActionLabel="Function Pointers" OutgoingActionLabel="Function Pointers" />
<Category Id="CodeSchema_ReturnTypeLink" Label="Return" CanBeDataDriven="True" CanLinkedNodesBeDataDriven="True" IncomingActionLabel="Return types" OutgoingActionLabel="Return types" />
<Category Id="File" Label="File" CanBeDataDriven="True" DefaultAction="Microsoft.Contains" Icon="File" NavigationActionLabel="Files" />
<Category Id="FileSystem.Category.FileOfType.dll" BasedOn="CodeSchema_Assembly" CanBeDataDriven="True" IsProviderRoot="False" />
<Category Id="FileSystem.Category.FileOfType.exe" BasedOn="CodeSchema_Assembly" CanBeDataDriven="True" IsProviderRoot="False" />
<Category Id="Implements" Label="Implements" />
<Category Id="InheritsFrom" Label="Inherits From" />
<Category Id="References" Label="References" CanBeDataDriven="True" CanLinkedNodesBeDataDriven="True" IncomingActionLabel="Referenced By" OutgoingActionLabel="References" />
</Categories>
<Properties>
<Property Id="AssemblyTimestamp" DataType="System.DateTime" />
<Property Id="Bounds" DataType="System.Windows.Rect" />
<Property Id="CanBeDataDriven" Label="CanBeDataDriven" Description="CanBeDataDriven" DataType="System.Boolean" />
<Property Id="CanLinkedNodesBeDataDriven" Label="CanLinkedNodesBeDataDriven" Description="CanLinkedNodesBeDataDriven" DataType="System.Boolean" />
<Property Id="CodeSchemaProperty_StrongName" Label="StrongName" Description="StrongName" DataType="System.String" />
<Property Id="DataVirtualized" Label="Data Virtualized" Description="If true, the graph can contain nodes and links that represent data for virtualized nodes/links (i.e. not actually created in the graph)." DataType="System.Boolean" />
<Property Id="DefaultAction" Label="DefaultAction" Description="DefaultAction" DataType="System.String" />
<Property Id="DelayedChildNodesState" Label="Delayed Child Nodes State" Description="Unspecified if the delayed child nodes state is not specified. NotFetched if the group contains child nodes that are not fetched into the graph yet. Fetched if the group has all its delayed child nodes already fetched." DataType="Microsoft.VisualStudio.GraphModel.DelayedDataState" />
<Property Id="DelayedCrossGroupLinksState" Label="Delayed Cross-Group Links State" Description="Unspecified if the delayed cross-group links state is not specified. NotFetched if delayed cross-group links on this node are not fetched into the graph yet. Fetched if all delayed cross-group links have already fetched." DataType="Microsoft.VisualStudio.GraphModel.DelayedDataState" />
<Property Id="Expression" DataType="System.String" />
<Property Id="FilePath" Label="File Path" Description="File Path" DataType="System.String" />
<Property Id="Group" Label="Group" Description="Display the node as a group" DataType="Microsoft.VisualStudio.GraphModel.GraphGroupStyle" />
<Property Id="GroupLabel" DataType="System.String" />
<Property Id="Icon" Label="Icon" Description="Icon" DataType="System.String" />
<Property Id="IncomingActionLabel" Label="IncomingActionLabel" Description="IncomingActionLabel" DataType="System.String" />
<Property Id="IsEnabled" DataType="System.Boolean" />
<Property Id="IsProviderRoot" Label="IsProviderRoot" Description="IsProviderRoot" DataType="System.Boolean" />
<Property Id="IsSourceVirtualized" Label="Link Source Virtualized" Description="If true, the link source end contains data for virtualized nodes/links (i.e. not actually created in the graph)." DataType="System.Boolean" />
<Property Id="IsTargetVirtualized" Label="Link Target Virtualized" Description="If true, the link target end contains data for virtualized nodes/links (i.e. not actually created in the graph)." DataType="System.Boolean" />
<Property Id="Label" Label="Label" Description="Displayable label of an Annotatable object" DataType="System.String" />
<Property Id="Layout" DataType="System.String" />
<Property Id="NavigationActionLabel" Label="NavigationActionLabel" Description="NavigationActionLabel" DataType="System.String" />
<Property Id="OutgoingActionLabel" Label="OutgoingActionLabel" Description="OutgoingActionLabel" DataType="System.String" />
<Property Id="TargetType" DataType="System.Type" />
<Property Id="UseManualLocation" DataType="System.Boolean" />
<Property Id="Value" DataType="System.String" />
<Property Id="ValueLabel" DataType="System.String" />
<Property Id="Visibility" Label="Visibility" Description="Defines whether a node in the graph is visible or not" DataType="System.Windows.Visibility" />
<Property Id="Weight" Label="Weight" Description="Weight" DataType="System.Double" />
<Property Id="ZoomLevel" DataType="System.String" />
</Properties>
<QualifiedNames>
<Name Id="Assembly" Label="Assembly" ValueType="Uri" />
</QualifiedNames>
<IdentifierAliases>
<Alias n="1" Uri="Assembly=$(8baa9433-8034-4fde-822c-537c59d3a7ec.OutputPathUri)" />
<Alias n="2" Id="(@1)" />
<Alias n="3" Uri="Assembly=$(58e70872-8acc-4957-bb8e-d3746bcc536d.OutputPathUri)" />
<Alias n="4" Id="(@3)" />
<Alias n="5" Uri="Assembly=$(c9c45b72-05a3-4962-bc13-a78b1f4b1925.OutputPathUri)" />
<Alias n="6" Id="(@5)" />
<Alias n="7" Uri="Assembly=$(53abd0f3-7d8d-43cd-99d7-06c45246d93e.OutputPathUri)" />
<Alias n="8" Id="(@7)" />
<Alias n="9" Uri="Assembly=$(dea48a0b-999e-48e8-8601-cb05b6b765de.OutputPathUri)" />
<Alias n="10" Id="(@9)" />
<Alias n="11" Uri="Assembly=$(d015f93d-9507-4484-977b-4cf1bdc0b30e.OutputPathUri)" />
<Alias n="12" Id="(@11)" />
<Alias n="13" Uri="Assembly=$(14b4a79f-a4b5-4c4c-a041-0105eed82782.OutputPathUri)" />
<Alias n="14" Id="(@13)" />
<Alias n="15" Uri="Assembly=$(02eeba8c-7b22-4bc3-bf3a-8de23eaf2e61.OutputPathUri)" />
<Alias n="16" Id="(@15)" />
</IdentifierAliases>
<Styles>
<Style TargetType="Node" GroupLabel="Results" ValueLabel="True">
<Condition Expression="HasCategory('QueryResult')" />
<Setter Property="Background" Value="#FFBCFFBE" />
</Style>
<Style TargetType="Node" GroupLabel="Test Project" ValueLabel="Test Project">
<Condition Expression="HasCategory('CodeMap_TestProject')" />
<Setter Property="Icon" Value="CodeMap_TestProject" />
<Setter Property="Background" Value="#FF307A69" />
</Style>
<Style TargetType="Node" GroupLabel="Web Project" ValueLabel="Web Project">
<Condition Expression="HasCategory('CodeMap_WebProject')" />
<Setter Property="Icon" Value="CodeMap_WebProject" />
</Style>
<Style TargetType="Node" GroupLabel="Windows Store Project" ValueLabel="Windows Store Project">
<Condition Expression="HasCategory('CodeMap_WindowsStoreProject')" />
<Setter Property="Icon" Value="CodeMap_WindowsStoreProject" />
</Style>
<Style TargetType="Node" GroupLabel="Phone Project" ValueLabel="Phone Project">
<Condition Expression="HasCategory('CodeMap_PhoneProject')" />
<Setter Property="Icon" Value="CodeMap_PhoneProject" />
</Style>
<Style TargetType="Node" GroupLabel="Portable Library" ValueLabel="Portable Library">
<Condition Expression="HasCategory('CodeMap_PortableLibraryProject')" />
<Setter Property="Icon" Value="CodeMap_PortableLibraryProject" />
</Style>
<Style TargetType="Node" GroupLabel="WPF Project" ValueLabel="WPF Project">
<Condition Expression="HasCategory('CodeMap_WpfProject')" />
<Setter Property="Icon" Value="CodeMap_WpfProject" />
</Style>
<Style TargetType="Node" GroupLabel="VSIX Project" ValueLabel="VSIX Project">
<Condition Expression="HasCategory('CodeMap_VsixProject')" />
<Setter Property="Icon" Value="CodeMap_VsixProject" />
</Style>
<Style TargetType="Node" GroupLabel="Modeling Project" ValueLabel="Modeling Project">
<Condition Expression="HasCategory('CodeMap_ModelingProject')" />
<Setter Property="Icon" Value="CodeMap_ModelingProject" />
</Style>
<Style TargetType="Node" GroupLabel="Assembly" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Assembly')" />
<Setter Property="Background" Value="#FF094167" />
<Setter Property="Stroke" Value="#FF094167" />
<Setter Property="Icon" Value="CodeSchema_Assembly" />
</Style>
<Style TargetType="Node" GroupLabel="Namespace" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Namespace')" />
<Setter Property="Background" Value="#FF0E619A" />
<Setter Property="Stroke" Value="#FF0E619A" />
<Setter Property="Icon" Value="CodeSchema_Namespace" />
</Style>
<Style TargetType="Node" GroupLabel="Interface" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Interface')" />
<Setter Property="Background" Value="#FF1382CE" />
<Setter Property="Stroke" Value="#FF1382CE" />
<Setter Property="Icon" Value="CodeSchema_Interface" />
</Style>
<Style TargetType="Node" GroupLabel="Struct" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Struct')" />
<Setter Property="Background" Value="#FF1382CE" />
<Setter Property="Stroke" Value="#FF1382CE" />
<Setter Property="Icon" Value="CodeSchema_Struct" />
</Style>
<Style TargetType="Node" GroupLabel="Enumeration" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Enum')" />
<Setter Property="Background" Value="#FF1382CE" />
<Setter Property="Stroke" Value="#FF1382CE" />
<Setter Property="Icon" Value="CodeSchema_Enum" />
<Setter Property="LayoutSettings" Value="List" />
</Style>
<Style TargetType="Node" GroupLabel="Delegate" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Delegate')" />
<Setter Property="Background" Value="#FF1382CE" />
<Setter Property="Stroke" Value="#FF1382CE" />
<Setter Property="Icon" Value="CodeSchema_Delegate" />
</Style>
<Style TargetType="Node" GroupLabel="Class" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Type')" />
<Setter Property="Background" Value="#FF0E70C0" />
<Setter Property="Stroke" Value="#FF0E70C0" />
<Setter Property="Icon" Value="CodeSchema_Class" />
</Style>
<Style TargetType="Node" GroupLabel="Property" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Property')" />
<Setter Property="Background" Value="#FFE0E0E0" />
<Setter Property="Stroke" Value="#FFE0E0E0" />
<Setter Property="Icon" Value="CodeSchema_Property" />
</Style>
<Style TargetType="Node" GroupLabel="Method" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Method') Or HasCategory('CodeSchema_CallStackUnresolvedMethod')" />
<Setter Property="Background" Value="#FFE0E0E0" />
<Setter Property="Stroke" Value="#FFE0E0E0" />
<Setter Property="Icon" Value="CodeSchema_Method" />
<Setter Property="LayoutSettings" Value="List" />
</Style>
<Style TargetType="Node" GroupLabel="Event" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Event')" />
<Setter Property="Background" Value="#FFE0E0E0" />
<Setter Property="Stroke" Value="#FFE0E0E0" />
<Setter Property="Icon" Value="CodeSchema_Event" />
</Style>
<Style TargetType="Node" GroupLabel="Field" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Field')" />
<Setter Property="Background" Value="#FFE0E0E0" />
<Setter Property="Stroke" Value="#FFE0E0E0" />
<Setter Property="Icon" Value="CodeSchema_Field" />
</Style>
<Style TargetType="Node" GroupLabel="Out Parameter" ValueLabel="Has category">
<Condition Expression="CodeSchemaProperty_IsOut = 'True'" />
<Setter Property="Icon" Value="CodeSchema_OutParameter" />
</Style>
<Style TargetType="Node" GroupLabel="Parameter" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_Parameter')" />
<Setter Property="Icon" Value="CodeSchema_Parameter" />
</Style>
<Style TargetType="Node" GroupLabel="Local Variable" ValueLabel="Has category">
<Condition Expression="HasCategory('CodeSchema_LocalExpression')" />
<Setter Property="Icon" Value="CodeSchema_LocalExpression" />
</Style>
<Style TargetType="Node" GroupLabel="Externals" ValueLabel="Has category">
<Condition Expression="HasCategory('Externals')" />
<Setter Property="Background" Value="#FF424242" />
<Setter Property="Stroke" Value="#FF424242" />
</Style>
<Style TargetType="Link" GroupLabel="Inherits From" ValueLabel="True">
<Condition Expression="HasCategory('InheritsFrom')" />
<Setter Property="Stroke" Value="#FF00A600" />
<Setter Property="StrokeDashArray" Value="2 0" />
<Setter Property="DrawArrow" Value="true" />
</Style>
<Style TargetType="Link" GroupLabel="Implements" ValueLabel="True">
<Condition Expression="HasCategory('Implements')" />
<Setter Property="Stroke" Value="#8000A600" />
<Setter Property="StrokeDashArray" Value="2 2" />
<Setter Property="DrawArrow" Value="true" />
</Style>
<Style TargetType="Link" GroupLabel="Calls" ValueLabel="True">
<Condition Expression="HasCategory('CodeSchema_Calls')" />
<Setter Property="Stroke" Value="#FFFF00FF" />
<Setter Property="StrokeDashArray" Value="2 0" />
<Setter Property="DrawArrow" Value="true" />
</Style>
<Style TargetType="Link" GroupLabel="Function Pointer" ValueLabel="True">
<Condition Expression="HasCategory('CodeSchema_FunctionPointer')" />
<Setter Property="Stroke" Value="#FFFF00FF" />
<Setter Property="StrokeDashArray" Value="2 2" />
<Setter Property="DrawArrow" Value="true" />
</Style>
<Style TargetType="Link" GroupLabel="Field Read" ValueLabel="True">
<Condition Expression="HasCategory('CodeSchema_FieldRead')" />
<Setter Property="Stroke" Value="#FF00AEEF" />
<Setter Property="StrokeDashArray" Value="2 2" />
<Setter Property="DrawArrow" Value="true" />
</Style>
<Style TargetType="Link" GroupLabel="Field Write" ValueLabel="True">
<Condition Expression="HasCategory('CodeSchema_FieldWrite')" />
<Setter Property="Stroke" Value="#FF00AEEF" />
<Setter Property="DrawArrow" Value="true" />
<Setter Property="IsHidden" Value="false" />
</Style>
<Style TargetType="Link" GroupLabel="Inherits From" ValueLabel="True" Visibility="Hidden">
<Condition Expression="HasCategory('InheritsFrom') And Target.HasCategory('CodeSchema_Class')" />
<Setter Property="TargetDecorator" Value="OpenArrow" />
</Style>
<Style TargetType="Link" GroupLabel="Implements" ValueLabel="True" Visibility="Hidden">
<Condition Expression="HasCategory('Implements') And Target.HasCategory('CodeSchema_Interface')" />
<Setter Property="TargetDecorator" Value="OpenArrow" />
</Style>
<Style TargetType="Link" GroupLabel="Comment Link" ValueLabel="True" Visibility="Hidden">
<Condition Expression="Source.HasCategory('Comment')" />
<Setter Property="Stroke" Value="#FFE5C365" />
</Style>
<Style TargetType="Node" GroupLabel="Cursor Location Changed" ValueLabel="True" Visibility="Hidden">
<Condition Expression="IsCursorLocation" />
<Setter Property="IndicatorWest" Value="WestIndicator" />
</Style>
<Style TargetType="Node" GroupLabel="Disabled Breakpoint Location Changed" ValueLabel="True" Visibility="Hidden">
<Condition Expression="DisabledBreakpointCount" />
<Setter Property="IndicatorWest" Value="WestIndicator" />
</Style>
<Style TargetType="Node" GroupLabel="Enabled Breakpoint Location Changed" ValueLabel="True" Visibility="Hidden">
<Condition Expression="EnabledBreakpointCount" />
<Setter Property="IndicatorWest" Value="WestIndicator" />
</Style>
<Style TargetType="Node" GroupLabel="Instruction Pointer Location Changed" ValueLabel="True" Visibility="Hidden">
<Condition Expression="IsInstructionPointerLocation" />
<Setter Property="IndicatorWest" Value="WestIndicator" />
</Style>
<Style TargetType="Node" GroupLabel="Current Callstack Changed" ValueLabel="True" Visibility="Hidden">
<Condition Expression="IsCurrentCallstackFrame" />
<Setter Property="IndicatorWest" Value="WestIndicator" />
</Style>
<Style TargetType="Link" GroupLabel="Return" ValueLabel="True" Visibility="Hidden">
<Condition Expression="HasCategory('CodeSchema_ReturnTypeLink')" />
</Style>
<Style TargetType="Link" GroupLabel="References" ValueLabel="True" Visibility="Hidden">
<Condition Expression="HasCategory('References')" />
</Style>
<Style TargetType="Link" GroupLabel="Uses Attribute" ValueLabel="True" Visibility="Hidden">
<Condition Expression="HasCategory('CodeSchema_AttributeUse')" />
</Style>
<Style TargetType="Node" GroupLabel="Solution Folder" ValueLabel="True" Visibility="Hidden">
<Condition Expression="HasCategory('CodeMap_SolutionFolder')" />
<Setter Property="Background" Value="#FFDEBA83" />
</Style>
<Style TargetType="Link" GroupLabel="Project Reference" ValueLabel="Project Reference">
<Condition Expression="HasCategory('CodeMap_ProjectReference')" />
<Setter Property="Stroke" Value="#9A9A9A" />
<Setter Property="StrokeDashArray" Value="2 2" />
<Setter Property="DrawArrow" Value="true" />
</Style>
<Style TargetType="Link" GroupLabel="External Reference" ValueLabel="External Reference">
<Condition Expression="HasCategory('CodeMap_ExternalReference')" />
<Setter Property="Stroke" Value="#9A9A9A" />
<Setter Property="StrokeDashArray" Value="2 2" />
<Setter Property="DrawArrow" Value="true" />
</Style>
</Styles>
<Paths>
<Path Id="02eeba8c-7b22-4bc3-bf3a-8de23eaf2e61.OutputPath" Value="C:\Users\robert.nelsen\Desktop\DataPro\SourceCode\DataPro_Diagraming\DataPRO\DASFactory\bin\Debug\DASFactory.dll" />
<Path Id="02eeba8c-7b22-4bc3-bf3a-8de23eaf2e61.OutputPathUri" Value="file:///C:/Users/robert.nelsen/Desktop/DataPro/SourceCode/DataPro_Diagraming/DataPRO/DASFactory/bin/Debug/DASFactory.dll" />
<Path Id="14b4a79f-a4b5-4c4c-a041-0105eed82782.OutputPath" Value="C:\Users\robert.nelsen\Desktop\DataPro\SourceCode\DataPro_Diagraming\DataPRO\TDASCommands\bin\Debug\TDASCommands.dll" />
<Path Id="14b4a79f-a4b5-4c4c-a041-0105eed82782.OutputPathUri" Value="file:///C:/Users/robert.nelsen/Desktop/DataPro/SourceCode/DataPro_Diagraming/DataPRO/TDASCommands/bin/Debug/TDASCommands.dll" />
<Path Id="53abd0f3-7d8d-43cd-99d7-06c45246d93e.OutputPath" Value="C:\Users\robert.nelsen\Desktop\DataPro\SourceCode\DataPro_Diagraming\DataPRO\RibeyeCommands\bin\Debug\Ribeye Commands.dll" />
<Path Id="53abd0f3-7d8d-43cd-99d7-06c45246d93e.OutputPathUri" Value="file:///C:/Users/robert.nelsen/Desktop/DataPro/SourceCode/DataPro_Diagraming/DataPRO/RibeyeCommands/bin/Debug/Ribeye Commands.dll" />
<Path Id="58e70872-8acc-4957-bb8e-d3746bcc536d.OutputPath" Value="C:\Users\robert.nelsen\Desktop\DataPro\SourceCode\DataPro_Diagraming\DataPRO\ICommand\bin\Debug\ICommand.dll" />
<Path Id="58e70872-8acc-4957-bb8e-d3746bcc536d.OutputPathUri" Value="file:///C:/Users/robert.nelsen/Desktop/DataPro/SourceCode/DataPro_Diagraming/DataPRO/ICommand/bin/Debug/ICommand.dll" />
<Path Id="8baa9433-8034-4fde-822c-537c59d3a7ec.OutputPath" Value="C:\Users\robert.nelsen\Desktop\DataPro\SourceCode\DataPro_Diagraming\DataPRO\DataPRO\bin\Debug\DataPRO.exe" />
<Path Id="8baa9433-8034-4fde-822c-537c59d3a7ec.OutputPathUri" Value="file:///C:/Users/robert.nelsen/Desktop/DataPro/SourceCode/DataPro_Diagraming/DataPRO/DataPRO/bin/Debug/DataPRO.exe" />
<Path Id="c9c45b72-05a3-4962-bc13-a78b1f4b1925.OutputPath" Value="C:\Users\robert.nelsen\Desktop\DataPro\SourceCode\DataPro_Diagraming\DataPRO\IService\bin\Debug\IService.dll" />
<Path Id="c9c45b72-05a3-4962-bc13-a78b1f4b1925.OutputPathUri" Value="file:///C:/Users/robert.nelsen/Desktop/DataPro/SourceCode/DataPro_Diagraming/DataPRO/IService/bin/Debug/IService.dll" />
<Path Id="d015f93d-9507-4484-977b-4cf1bdc0b30e.OutputPath" Value="C:\Users\robert.nelsen\Desktop\DataPro\SourceCode\DataPro_Diagraming\DataPRO\SLICECommands\bin\Debug\SLICECommands.dll" />
<Path Id="d015f93d-9507-4484-977b-4cf1bdc0b30e.OutputPathUri" Value="file:///C:/Users/robert.nelsen/Desktop/DataPro/SourceCode/DataPro_Diagraming/DataPRO/SLICECommands/bin/Debug/SLICECommands.dll" />
<Path Id="dea48a0b-999e-48e8-8601-cb05b6b765de.OutputPath" Value="C:\Users\robert.nelsen\Desktop\DataPro\SourceCode\DataPro_Diagraming\DataPRO\SLICEDBCommands\bin\Debug\SliceDBCommands.dll" />
<Path Id="dea48a0b-999e-48e8-8601-cb05b6b765de.OutputPathUri" Value="file:///C:/Users/robert.nelsen/Desktop/DataPro/SourceCode/DataPro_Diagraming/DataPRO/SLICEDBCommands/bin/Debug/SliceDBCommands.dll" />
</Paths>
</DirectedGraph>

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace DTS.DASLib.Command
{
public enum CommandStatus
{
Success,
Failure,
Canceled
}
public enum CommandErrorReason
{
SendFailed,
ReceiveFailed,
InvalidMode,
Canceled
}
public class CommandException : ApplicationException
{
public CommandErrorReason Error { get; set; }
public CommandException(CommandErrorReason _err)
{
Error = _err;
}
public CommandException(CommandErrorReason _err, string msg)
: base(msg)
{
Error = _err;
}
}
public enum CommandReceiveAction
{
StopReceiving,
ContinueReceiving
}
public interface ICommandReport
{
object CallbackObject { get; set; }
CommandStatus Status { get; set; }
}
public delegate CommandReceiveAction CommandCallback(ICommandReport report);
public interface ICommand
{
void Execute(CommandCallback Callback,
object CallbackObject);
void SyncExecute();
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{58E70872-8ACC-4957-BB8E-D3746BCC536D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DTS.DASLib.Command</RootNamespace>
<AssemblyName>ICommand</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkProfile />
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Prism">
<HintPath>..\..\Common\DTS.Common\lib\PrismLibrary\Prism.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AbstractCommandBase.cs" />
<Compile Include="Classes\DiscoveredDevice.cs" />
<Compile Include="Classes\UDPQATSEntry.cs" />
<Compile Include="CommandLogEntryBase.cs" />
<Compile Include="CommandPacketBase.cs" />
<Compile Include="CommandReport.cs" />
<Compile Include="ICommand.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SliceCommandBase.cs" />
<Compile Include="SliceCommandPacketBase.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Common\DTS.Common.DASResource\DTS.Common.DASResource.csproj">
<Project>{f621ce48-bb4b-4cfc-a325-9410b721cc44}</Project>
<Name>DTS.Common.DASResource</Name>
</ProjectReference>
<ProjectReference Include="..\..\Common\DTS.Common.ICommunication\DTS.Common.ICommunication.csproj">
<Project>{f57b954e-a49a-4110-b36c-b5abab3e230b}</Project>
<Name>DTS.Common.ICommunication</Name>
</ProjectReference>
<ProjectReference Include="..\..\Common\DTS.Common.Utilities\DTS.Common.Utilities.csproj">
<Project>{d6da1b74-c711-43c2-91b1-1908a8d04dbf}</Project>
<Name>DTS.Common.Utilities</Name>
</ProjectReference>
<ProjectReference Include="..\..\Common\DTS.Common\DTS.Common.csproj">
<Project>{f7a0804f-61a4-40ae-83d0-f1137622b592}</Project>
<Name>DTS.Common</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Design\ClassDiagram_ICommand.cd" />
<None Include="Design\Graph_ReferenceAssemblies.dgml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ICommand")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ICommand")]
[assembly: AssemblyCopyright("Copyright © 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("14230b85-7fbb-40ce-973e-c0aecb2e8b44")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.06.0081")]
[assembly: AssemblyFileVersion("1.06.0081")]

View File

@@ -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));
//}
}
}
}
}

View File

@@ -0,0 +1,392 @@
using System;
using System.Collections.Generic;
using System.Text;
using DTS.Common.Enums.DASFactory;
using DTS.Common.Utilities.Logging;
using DTS.Common.Utils;
namespace DTS.DASLib.Command
{
/// <summary>
/// this is the base for all slice command packets
/// from here SliceDb and slice command packets will have different commands that can be
/// run and a different command type enum containing the command types, however
/// this class contains the common logic for addressing and packing the packet
/// </summary>
public abstract class SliceCommandPacketBase : CommandPacketBase
{
public const byte MAGIC_BYTE = 0xFA;
protected const int HEADER_SIZE_BYTES = 12;
protected const int DATA_CRC_SIZE_BYTES = 2;
// Packet format -- all are 8 bits, but ParameterLength, SequenceNumber and HeaderCRC
protected const int MagicBytePosition = 0;
protected const int TypePosition = 1;
protected const int CommandPosition = 2;
protected const int StatusPosition = 3;
protected const int DeviceGroupPosition = 4;
protected const int DeviceIDPosition = 5;
// Parameter length is 16 bits
protected const int ParameterLengthPosition = 6;
// Sequence number length is 16 bits
protected const int SequenceNumberPosition = 8;
// Header CRC is 16 bits
protected const int HeaderCRCPosition = 10;
public UInt16 ParameterLength;
public byte DeviceGroup;
public byte DeviceID;
public UInt16 HeaderCRC;
public byte[] Parameter;
public UInt16 ParameterCRC;
public SliceCommandPacketBase()
{
Parameter = new byte[0];
AlreadyRun = false;
ShouldLog = true;
GetNextSequenceNumber();
}
public SliceCommandPacketBase(byte[] Bytes)
{
OriginalBytes = Bytes;
ShouldLog = true;
if (HEADER_SIZE_BYTES <= Bytes.Length && MAGIC_BYTE == Bytes[0])
{
Type = ConvertByteToCommandType(Bytes[TypePosition]);//(CommandType)Bytes[TypePosition];
//Command = Bytes[CommandPosition];
SetCommand(Bytes[CommandPosition], Convert.ToString(Bytes[CommandPosition]));
Status = (DFConstantsAndEnums.CommandStatus)Bytes[StatusPosition];
DeviceGroup = Bytes[DeviceGroupPosition];
DeviceID = Bytes[DeviceIDPosition];
ParameterLength = (ushort)(Bytes[ParameterLengthPosition + 0] |
(Bytes[ParameterLengthPosition + 1] << 8));
SequenceNumber = (ushort)(Bytes[SequenceNumberPosition + 0] |
(Bytes[SequenceNumberPosition + 1] << 8));
HeaderCRC = (ushort)(Bytes[HeaderCRCPosition + 0] |
(Bytes[HeaderCRCPosition + 1] << 8));
Parameter = new byte[ParameterLength];
if (ParameterLength > 0 && Bytes.Length > HEADER_SIZE_BYTES)
{
try
{
Buffer.BlockCopy(Bytes, HEADER_SIZE_BYTES + DATA_CRC_SIZE_BYTES, Parameter, 0, ParameterLength);
ParameterCRC = (UInt16)(Bytes[HEADER_SIZE_BYTES + 0] |
Bytes[HEADER_SIZE_BYTES + 1] << 8);
}
catch (Exception ex)
{
APILogger.Log(ex);
}
}
}
}
public override PacketState VerifyPacket(byte[] Bytes)
{
if (Bytes == null)
return PacketState.Unknown;
if (Bytes.Length < HEADER_SIZE_BYTES)
return PacketState.TooShort;
if (Bytes[MagicBytePosition] != MAGIC_BYTE)
return PacketState.Unknown;
object type = ConvertByteToCommandType(Bytes[TypePosition]);
//CommandType type = (CommandType)Bytes[TypePosition];
byte command = Bytes[CommandPosition];
CommandStatus status = (CommandStatus)Bytes[StatusPosition];
byte deviceGroup = Bytes[DeviceGroupPosition];
byte deviceID = Bytes[DeviceIDPosition];
ushort parameterLength = (ushort)(Bytes[ParameterLengthPosition + 0] |
(Bytes[ParameterLengthPosition + 1] << 8));
// TODO: Why isn't this checking the CRCs?
//ushort headerCRC = (ushort)(Bytes[9] | (Bytes[8] << 8));
//ushort parameterCRC = (UInt16)(Bytes[10 + 1 + parameterLength] | Bytes[10 + 0 + parameterLength] << 8);
// Note that the second condition (parameterLength==0) is already caught above and does not need to
// be here.
if ((parameterLength > 0 && Bytes.Length < parameterLength + HEADER_SIZE_BYTES + DATA_CRC_SIZE_BYTES) ||
(0 == parameterLength && Bytes.Length < HEADER_SIZE_BYTES))
{
return PacketState.TooShort;
}
//if(Bytes.Length > parameterLength + 10 + 2)
// return PacketState.TooLong;
return PacketState.OK;
}
public override void ComputeCRCs()
{
HeaderCRC = 0xFFFF;
// Compute the CRC of the first 8 bytes in the CommandPacket
// This is a little more awkward than it should be but since the length field
// is really two bytes, but packed into the 16-bit variable, we need to mask it
// off and compute the CRC of the bytes in the correct order, etc.
//Utility.Utility.Crc16Ccitt crccalc = new Utility.Utility.Crc16Ccitt(Utility.Utility.InitialCrcValue.Zeros);
//crccalc.UpdateChecksum((ushort)0xFA);
//crccalc.UpdateChecksum((ushort)Type);
//crccalc.UpdateChecksum((ushort)Command);
//crccalc.UpdateChecksum((ushort)Status);
//crccalc.UpdateChecksum((ushort)DeviceGroup);
//crccalc.UpdateChecksum((ushort)DeviceID);
//crccalc.UpdateChecksum((ushort)(Parameter.Length & 0xFF));
//crccalc.UpdateChecksum((ushort)((Parameter.Length & 0xFF00) >> 8));
//HeaderCRC = crccalc.cur
HeaderCRC = Utils.Math_DoCRCCCITTStep(0xFA, HeaderCRC);
HeaderCRC = Utils.Math_DoCRCCCITTStep((ushort)((int)Type), HeaderCRC);
HeaderCRC = Utils.Math_DoCRCCCITTStep(GetCommand(), HeaderCRC);
HeaderCRC = Utils.Math_DoCRCCCITTStep((ushort)Status, HeaderCRC);
HeaderCRC = Utils.Math_DoCRCCCITTStep(DeviceGroup, HeaderCRC);
HeaderCRC = Utils.Math_DoCRCCCITTStep(DeviceID, HeaderCRC);
HeaderCRC = Utils.Math_DoCRCCCITTStep((ushort)(Parameter.Length & 0xFF), HeaderCRC);
HeaderCRC = Utils.Math_DoCRCCCITTStep((ushort)((Parameter.Length & 0xFF00) >> 8), HeaderCRC);
HeaderCRC = Utils.Math_DoCRCCCITTStep((ushort)(SequenceNumber & 0xFF), HeaderCRC);
HeaderCRC = Utils.Math_DoCRCCCITTStep((ushort)((SequenceNumber & 0xFF00) >> 8), HeaderCRC);
// Compute the Parameter CRC
ParameterCRC = 0xFFFF;
// If length > 0, continue the computation over the data bytes
if (Parameter.Length > 0)
{
for (int i = 0; i < Parameter.Length; i++)
{
ParameterCRC = Utils.Math_DoCRCCCITTStep(Parameter[i], ParameterCRC);
}
}
}
public void GetParameter(int Offset, out double Value)
{
ByteConvertor.Convert(Parameter, Offset, out Value);
}
public void GetParameter(int Offset, out UInt64 Value)
{
Value = 0 |
(ulong)Parameter[Offset + 7] << 0 |
(ulong)Parameter[Offset + 6] << 8 |
(ulong)Parameter[Offset + 5] << 16 |
(ulong)Parameter[Offset + 4] << 24 |
(ulong)Parameter[Offset + 3] << 32 |
(ulong)Parameter[Offset + 2] << 40 |
(ulong)Parameter[Offset + 1] << 48 |
(ulong)Parameter[Offset + 0] << 56;
}
public void GetParameter(int Offset, out Int64 Value)
{
Value = (long)Parameter[Offset + 7] << 0 |
(long)Parameter[Offset + 6] << 8 |
(long)Parameter[Offset + 5] << 16 |
(long)Parameter[Offset + 4] << 24 |
(long)Parameter[Offset + 3] << 32 |
(long)Parameter[Offset + 2] << 40 |
(long)Parameter[Offset + 1] << 48 |
(long)Parameter[Offset + 0] << 56;
}
public void GetParameter(int Offset, out Int32 Value)
{
Value = Parameter[Offset + 3] |
Parameter[Offset + 2] << 8 |
Parameter[Offset + 1] << 16 |
Parameter[Offset + 0] << 24;
}
public void GetParameter(int Offset, out UInt32 Value)
{
Value = (UInt32)(Parameter[Offset + 3] |
Parameter[Offset + 2] << 8 |
Parameter[Offset + 1] << 16 |
Parameter[Offset + 0] << 24);
}
public void GetParameter(int Offset, out Int16 Value)
{
Value = (Int16)(Parameter[Offset + 1] |
Parameter[Offset + 0] << 8);
}
public void GetParameter(int Offset, out UInt16 Value)
{
Value = (UInt16)(Parameter[Offset + 1] |
Parameter[Offset + 0] << 8);
}
public void GetParameter(int Offset, out byte Value)
{
Value = Parameter[Offset];
}
public void GetParameter(int Offset, out bool Value)
{
Value = (Parameter[Offset] == 0x01);
}
public void GetParameter(int Offset, out float Value)
{
Value = BitConverter.ToSingle(Parameter, Offset);
}
public void GetParameter(int Offset, out string Value)
{
StringBuilder sb = new StringBuilder();
int idx = Offset;
while (idx < Parameter.Length && 0 != Parameter[idx])
{
sb.Append((char)Parameter[idx++]);
}
Value = sb.ToString();
}
public void SetParameter(int Offset, double Value)
{
byte[] rv = ByteConvertor.ToByteArray(Value);
Buffer.BlockCopy(rv, 0, Parameter, Offset, rv.Length);
}
public void SetParameter(int Offset, Int64 Value)
{
Parameter[Offset + 7] = (byte)(((ulong)Value & 0x00000000000000FF) >> 0);
Parameter[Offset + 6] = (byte)(((ulong)Value & 0x000000000000FF00) >> 8);
Parameter[Offset + 5] = (byte)(((ulong)Value & 0x0000000000FF0000) >> 16);
Parameter[Offset + 4] = (byte)(((ulong)Value & 0x00000000FF000000) >> 24);
Parameter[Offset + 3] = (byte)(((ulong)Value & 0x000000FF00000000) >> 32);
Parameter[Offset + 2] = (byte)(((ulong)Value & 0x0000FF0000000000) >> 40);
Parameter[Offset + 1] = (byte)(((ulong)Value & 0x00FF000000000000) >> 48);
Parameter[Offset + 0] = (byte)(((ulong)Value & 0xFF00000000000000) >> 56);
}
public void SetParameter(int Offset, UInt64 Value)
{
Parameter[Offset + 7] = (byte)((Value & 0x00000000000000FF) >> 0);
Parameter[Offset + 6] = (byte)((Value & 0x000000000000FF00) >> 8);
Parameter[Offset + 5] = (byte)((Value & 0x0000000000FF0000) >> 16);
Parameter[Offset + 4] = (byte)((Value & 0x00000000FF000000) >> 24);
Parameter[Offset + 3] = (byte)((Value & 0x000000FF00000000) >> 32);
Parameter[Offset + 2] = (byte)((Value & 0x0000FF0000000000) >> 40);
Parameter[Offset + 1] = (byte)((Value & 0x00FF000000000000) >> 48);
Parameter[Offset + 0] = (byte)((Value & 0xFF00000000000000) >> 56);
}
public void SetParameter(int Offset, Int32 Value)
{
Parameter[Offset + 3] = (byte)((Value & 0x000000FF));
Parameter[Offset + 2] = (byte)((Value & 0x0000FF00) >> 8);
Parameter[Offset + 1] = (byte)((Value & 0x00FF0000) >> 16);
Parameter[Offset + 0] = (byte)((Value & 0xFF000000) >> 24);
}
public void SetParameter(int Offset, UInt32 Value)
{
Parameter[Offset + 3] = (byte)((Value & 0x000000FF));
Parameter[Offset + 2] = (byte)((Value & 0x0000FF00) >> 8);
Parameter[Offset + 1] = (byte)((Value & 0x00FF0000) >> 16);
Parameter[Offset + 0] = (byte)((Value & 0xFF000000) >> 24);
}
public void SetParameter(int Offset, Int16 Value)
{
Parameter[Offset + 1] = (byte)(Value & 0x00FF);
Parameter[Offset + 0] = (byte)((Value & 0xFF00) >> 8);
}
public void SetParameter(int Offset, UInt16 Value)
{
Parameter[Offset + 1] = (byte)(Value & 0x00FF);
Parameter[Offset + 0] = (byte)((Value & 0xFF00) >> 8);
}
public void SetParameter(int Offset, byte Value)
{
Parameter[Offset] = Value;
}
public void SetParameter(int Offset, bool Value)
{
Parameter[Offset] = (byte)(Value ? 0x01 : 0x00);
}
public void SetParameter(int Offset, byte[] Value)
{
Value.CopyTo(Parameter, Offset);
}
public void SetParameter(int Offset, string Value)
{
char[] original = Value.ToCharArray();
char[] withNullTermination = new char[original.Length + 1];
original.CopyTo(withNullTermination, 0);
withNullTermination[withNullTermination.Length - 1] = '\0';
SetParameter(Offset, withNullTermination);
}
public void SetParameter(int Offset, char[] Value)
{
for (int i = 0; i < Value.Length; i++)
{
Parameter[Offset + i] = (byte)Value[i];
}
Parameter[Parameter.Length - 1] = 0;
}
public void SetParameter(int Offset, char Value)
{
Parameter[Offset] = (byte)Value;
}
public void SetParameter(int Offset, float Value)
{
BitConverter.GetBytes(Value).CopyTo(Parameter, Offset);
}
public override byte[] ToBytes()
{
int Length;
byte[] CommandBytes;
Length = HEADER_SIZE_BYTES + Parameter.Length + (Parameter.Length > 0 ? DATA_CRC_SIZE_BYTES : 0);
CommandBytes = new byte[Length];
CommandBytes[MagicBytePosition] = MAGIC_BYTE;
CommandBytes[TypePosition] = (byte)((int)Type);
CommandBytes[CommandPosition] = GetCommand();
CommandBytes[StatusPosition] = (byte)Status;
CommandBytes[DeviceGroupPosition] = DeviceGroup;
CommandBytes[DeviceIDPosition] = DeviceID;
CommandBytes[ParameterLengthPosition + 0] = (byte)((Parameter.Length & 0xFF00) >> 8);
CommandBytes[ParameterLengthPosition + 1] = (byte)(Parameter.Length & 0x00FF);
CommandBytes[SequenceNumberPosition + 0] = (byte)((SequenceNumber & 0xFF00) >> 8);
CommandBytes[SequenceNumberPosition + 1] = (byte)(SequenceNumber & 0x00FF);
CommandBytes[HeaderCRCPosition + 0] = (byte)((HeaderCRC & 0xFF00) >> 8);
CommandBytes[HeaderCRCPosition + 1] = (byte)(HeaderCRC & 0x00FF);
for (int iIndex = 0; iIndex < Parameter.Length; iIndex++)
{
CommandBytes[iIndex + HEADER_SIZE_BYTES + DATA_CRC_SIZE_BYTES] = Parameter[iIndex];
}
if (Parameter.Length > 0)
{
CommandBytes[HEADER_SIZE_BYTES + 0] = (byte)((ParameterCRC & 0xFF00) >> 8);
CommandBytes[HEADER_SIZE_BYTES + 1] = (byte)(ParameterCRC & 0x00FF);
}
OriginalBytes = CommandBytes;
return CommandBytes;
}
}
}

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = "")]

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]