This commit is contained in:
luosheng
2023-07-16 08:17:03 +08:00
parent 6d655b24d1
commit 2055c10c59
127 changed files with 7414 additions and 7470 deletions

View File

@@ -40,11 +40,11 @@ namespace Modbus.Net
{
Array.Reverse(data, pos, 4);
byte temp;
temp = data[pos]; data[pos] = data[pos+2]; data[pos+2] = temp;
temp = data[pos+1]; data[pos+1] = data[pos+3]; data[pos+3] = temp;
temp = data[pos]; data[pos] = data[pos + 2]; data[pos + 2] = temp;
temp = data[pos + 1]; data[pos + 1] = data[pos + 3]; data[pos + 3] = temp;
var t = BitConverter.ToSingle(data, pos);
temp = data[pos]; data[pos] = data[pos+2]; data[pos+2] = temp;
temp = data[pos+1]; data[pos+1] = data[pos+3]; data[pos+3] = temp;
temp = data[pos]; data[pos] = data[pos + 2]; data[pos + 2] = temp;
temp = data[pos + 1]; data[pos + 1] = data[pos + 3]; data[pos + 3] = temp;
Array.Reverse(data, pos, 4);
pos += 4;
return t;

View File

@@ -21,7 +21,7 @@ namespace Modbus.Net.Modbus
/// <param name="masterAddress">主站号</param>
/// <param name="endian">端格式</param>
public ModbusMachine(TKey id, ModbusType connectionType, string connectionString,
IEnumerable<AddressUnit<TUnitKey, int ,int>> getAddresses, bool keepConnect, byte slaveAddress, byte masterAddress,
IEnumerable<AddressUnit<TUnitKey, int, int>> getAddresses, bool keepConnect, byte slaveAddress, byte masterAddress,
Endian endian)
: base(id, getAddresses, keepConnect, slaveAddress, masterAddress)
{

View File

@@ -136,7 +136,7 @@ namespace Modbus.Net
else if (length == 0) return null;
else
{
duplicatedMessages = new List<(byte[],bool)>();
duplicatedMessages = new List<(byte[], bool)>();
var skipLength = 0;
while (receiveMessageCopy.Length >= length)
{

View File

@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Modbus.Net
{

View File

@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Modbus.Net
{

View File

@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Modbus.Net
namespace Modbus.Net
{
#if NET462
#pragma warning disable 1591

View File

@@ -313,7 +313,7 @@ namespace Modbus.Net
}
foreach (var assembly in AssemblyHelper.GetAllLibraryAssemblies())
{
var valueHelper = assembly.GetType("Modbus.Net."+endian.ToString() + "ValueHelper")?.GetProperty("Instance")?.GetValue(null, null) as ValueHelper;
var valueHelper = assembly.GetType("Modbus.Net." + endian.ToString() + "ValueHelper")?.GetProperty("Instance")?.GetValue(null, null) as ValueHelper;
if (valueHelper != null)
{
EndianInstanceCache[endian.ToString()] = valueHelper;

View File

@@ -1,8 +1,6 @@
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

View File

@@ -1,5 +1,4 @@
using Microsoft.Extensions.Logging;
using Quartz.Logging;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@@ -3,9 +3,9 @@ using Microsoft.AspNetCore.Mvc;
using Modbus.Net;
using Modbus.Net.Modbus;
using System.Diagnostics;
using AddressUnit = Modbus.Net.AddressUnit<string, int, int>;
using MachineJobSchedulerCreator = Modbus.Net.MachineJobSchedulerCreator<Modbus.Net.IMachineMethodDatas, string, double>;
using ModbusMachine = Modbus.Net.Modbus.ModbusMachine<string, string>;
using AddressUnit = Modbus.Net.AddressUnit<string, int, int>;
namespace AnyType.Controllers
{

View File

@@ -1,5 +1,4 @@
using Quartz.Logging;
using System.Configuration;
namespace MachineJob
{

View File

@@ -24,10 +24,9 @@
using System;
using System.Collections;
using System.Runtime.InteropServices;
using Technosoftware.DaAeHdaClient.Ae;
using Technosoftware.OpcRcw.Comn;
using Technosoftware.OpcRcw.Ae;
using Technosoftware.OpcRcw.Comn;
#endregion
#pragma warning disable 0618
@@ -189,7 +188,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
try
{
((IOPCEventServer)server_).CreateEventSubscription(
(state.Active)?1:0,
(state.Active) ? 1 : 0,
state.BufferTime,
state.MaxSize,
++m_handles,
@@ -544,18 +543,18 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
var ppszNodeNames = IntPtr.Zero;
var ppCLSIDs = IntPtr.Zero;
var count = (attributeIDs != null)?attributeIDs.Length:0;
var count = (attributeIDs != null) ? attributeIDs.Length : 0;
// call server.
try
{
((IOPCEventServer)server_).TranslateToItemIDs(
(sourceName != null)?sourceName:"",
(sourceName != null) ? sourceName : "",
eventCategory,
(conditionName != null)?conditionName:"",
(subConditionName != null)?subConditionName:"",
(conditionName != null) ? conditionName : "",
(subConditionName != null) ? subConditionName : "",
count,
(count > 0)?attributeIDs:new int[0],
(count > 0) ? attributeIDs : new int[0],
out ppszAttrItemIDs,
out ppszNodeNames,
out ppCLSIDs);
@@ -616,10 +615,10 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
try
{
((IOPCEventServer)server_).GetConditionState(
(sourceName != null)?sourceName:"",
(conditionName != null)?conditionName:"",
(attributeIDs != null)?attributeIDs.Length:0,
(attributeIDs != null)?attributeIDs:new int[0],
(sourceName != null) ? sourceName : "",
(conditionName != null) ? conditionName : "",
(attributeIDs != null) ? attributeIDs.Length : 0,
(attributeIDs != null) ? attributeIDs : new int[0],
out ppConditionState);
}
catch (Exception e)
@@ -1125,7 +1124,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
var pftActiveTime = new OpcRcw.Ae.FILETIME[count];
var pdwCookie = new int[count];
for (var ii = 0; ii < count; ii ++)
for (var ii = 0; ii < count; ii++)
{
pszSource[ii] = conditions[ii].SourceName;
pszConditionName[ii] = conditions[ii].ConditionName;
@@ -1333,7 +1332,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
// verify object.
if (unknown == null)
{
throw new OpcResultException(new OpcResult( (int)OpcResult.E_FAIL.Code, OpcResult.FuncCallType.SysFuncCall, null ),"The response from the server was invalid or incomplete");
throw new OpcResultException(new OpcResult((int)OpcResult.E_FAIL.Code, OpcResult.FuncCallType.SysFuncCall, null), "The response from the server was invalid or incomplete");
}
// save object.
@@ -1345,7 +1344,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
/// </summary>
private void ChangeBrowsePosition(string areaID)
{
var targetID = (areaID != null)?areaID:"";
var targetID = (areaID != null) ? areaID : "";
// invoke COM method.
try
@@ -1374,7 +1373,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
{
((IOPCEventAreaBrowser)m_browser).BrowseOPCAreas(
dwBrowseFilterType,
(browseFilter != null)?browseFilter:"",
(browseFilter != null) ? browseFilter : "",
out enumerator);
}
catch (Exception e)
@@ -1385,7 +1384,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
// verify object.
if (enumerator == null)
{
throw new OpcResultException(new OpcResult( (int)OpcResult.E_FAIL.Code, OpcResult.FuncCallType.SysFuncCall, null ),"The response from the server was invalid or incomplete");
throw new OpcResultException(new OpcResult((int)OpcResult.E_FAIL.Code, OpcResult.FuncCallType.SysFuncCall, null), "The response from the server was invalid or incomplete");
}
// return result.
@@ -1438,7 +1437,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
var buffer = new string[1];
// re-calculate buffer length.
var bufferLength = (maxElements > 0 && maxElements-elements.Count < buffer.Length)?maxElements-elements.Count:buffer.Length;
var bufferLength = (maxElements > 0 && maxElements - elements.Count < buffer.Length) ? maxElements - elements.Count : buffer.Length;
// fetch first batch of names.
var pFetched = Marshal.AllocCoTaskMem(sizeof(int));
@@ -1470,7 +1469,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
}
// re-calculate buffer length.
bufferLength = (maxElements > 0 && maxElements-elements.Count < buffer.Length)?maxElements-elements.Count:buffer.Length;
bufferLength = (maxElements > 0 && maxElements - elements.Count < buffer.Length) ? maxElements - elements.Count : buffer.Length;
// fetch next block.
result = enumerator.Next(bufferLength, buffer, pFetched);
@@ -1514,7 +1513,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
string browseFilter,
System.Runtime.InteropServices.ComTypes.IEnumString enumerator)
:
base (areaID, browseType, browseFilter)
base(areaID, browseType, browseFilter)
{
m_enumerator = enumerator;
}

View File

@@ -23,11 +23,9 @@
#region Using Directives
using System;
using System.Runtime.InteropServices;
using Technosoftware.DaAeHdaClient.Ae;
using Technosoftware.OpcRcw.Ae;
using Technosoftware.DaAeHdaClient.Utilities;
using Technosoftware.OpcRcw.Ae;
#endregion
@@ -333,7 +331,9 @@ namespace Technosoftware.DaAeHdaClient.Com.Ae
// build results.
var filters = new TsCAeSubscriptionFilters
{
EventTypes = pdwEventType, LowSeverity = pdwLowSeverity, HighSeverity = pdwHighSeverity
EventTypes = pdwEventType,
LowSeverity = pdwLowSeverity,
HighSeverity = pdwHighSeverity
};

View File

@@ -22,12 +22,11 @@
#region Using Directives
using System;
using System.Reflection;
using System.Net;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Globalization;
using System.Net;
using System.Reflection;
using System.Runtime.InteropServices;
using Technosoftware.DaAeHdaClient.Utilities;
#endregion
@@ -39,7 +38,7 @@ namespace Technosoftware.DaAeHdaClient.Com
internal class ComUtils
{
#region NetApi Function Declarations
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
private struct SERVER_INFO_100
{
public uint sv100_platform_id;
@@ -154,13 +153,13 @@ namespace Technosoftware.DaAeHdaClient.Com
/// <summary>
/// WIN32 GUID struct declaration.
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
private struct GUID
{
public int Data1;
public short Data2;
public short Data3;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=8)]
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] Data4;
}
@@ -195,7 +194,7 @@ namespace Technosoftware.DaAeHdaClient.Com
private const int VARIANT_NOVALUEPROP = 0x01;
private const int VARIANT_ALPHABOOL = 0x02; // For VT_BOOL to VT_BSTR conversions convert to "True"/"False" instead of
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
private struct SOLE_AUTHENTICATION_SERVICE
{
public uint dwAuthnSvc;
@@ -303,7 +302,7 @@ namespace Technosoftware.DaAeHdaClient.Com
COINIT_SPEED_OVER_MEMORY = 0x8, //Trade memory for speed
}
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
private struct COSERVERINFO
{
public uint dwReserved1;
@@ -313,7 +312,7 @@ namespace Technosoftware.DaAeHdaClient.Com
public uint dwReserved2;
};
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
private struct COAUTHINFO
{
public uint dwAuthnSvc;
@@ -325,7 +324,7 @@ namespace Technosoftware.DaAeHdaClient.Com
public uint dwCapabilities;
}
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
private struct COAUTHIDENTITY
{
public IntPtr User;
@@ -337,7 +336,7 @@ namespace Technosoftware.DaAeHdaClient.Com
public uint Flags;
}
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
private struct MULTI_QI
{
public IntPtr iid;
@@ -369,7 +368,7 @@ namespace Technosoftware.DaAeHdaClient.Com
[In, Out]
MULTI_QI[] pResults);
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
private struct LICINFO
{
public int cbLicInfo;
@@ -415,7 +414,7 @@ namespace Technosoftware.DaAeHdaClient.Com
bool fLock);
void GetLicInfo(
[In,Out] ref LICINFO pLicInfo);
[In, Out] ref LICINFO pLicInfo);
void RequestLicKey(
int dwReserved,
@@ -455,7 +454,7 @@ namespace Technosoftware.DaAeHdaClient.Com
private const int SECURITY_IMPERSONATION = 2;
private const int SECURITY_DELEGATION = 3;
[DllImport("advapi32.dll", SetLastError=true)]
[DllImport("advapi32.dll", SetLastError = true)]
private static extern bool LogonUser(
string lpszUsername,
string lpszDomain,
@@ -464,10 +463,10 @@ namespace Technosoftware.DaAeHdaClient.Com
int dwLogonProvider,
ref IntPtr phToken);
[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
private extern static bool CloseHandle(IntPtr handle);
[DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError=true)]
[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private extern static bool DuplicateToken(
IntPtr ExistingTokenHandle,
int SECURITY_IMPERSONATION_LEVEL,
@@ -510,11 +509,11 @@ namespace Technosoftware.DaAeHdaClient.Com
var authIdentity = new COAUTHIDENTITY();
authIdentity.User = m_hUserName.AddrOfPinnedObject();
authIdentity.UserLength = (uint)((identity.Username != null)?identity.Username.Length:0);
authIdentity.UserLength = (uint)((identity.Username != null) ? identity.Username.Length : 0);
authIdentity.Password = m_hPassword.AddrOfPinnedObject();
authIdentity.PasswordLength = (uint)((identity.Password != null)?identity.Password.Length:0);
authIdentity.PasswordLength = (uint)((identity.Password != null) ? identity.Password.Length : 0);
authIdentity.Domain = m_hDomain.AddrOfPinnedObject();
authIdentity.DomainLength = (uint)((identity.Domain != null)?identity.Domain.Length:0);
authIdentity.DomainLength = (uint)((identity.Domain != null) ? identity.Domain.Length : 0);
authIdentity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
m_hIdentity = GCHandle.Alloc(authIdentity, GCHandleType.Pinned);
@@ -697,7 +696,7 @@ namespace Technosoftware.DaAeHdaClient.Com
// COM impersonation is a nice feature but variations between behavoirs on different
// windows platforms make it virtually impossible to support. This code is left here
// in case it becomes a critical requirement in the future.
#if COM_IMPERSONATION_SUPPORT
#if COM_IMPERSONATION_SUPPORT
/// <summary>
/// Returns the WindowsIdentity associated with a UserIdentity.
/// </summary>
@@ -937,7 +936,7 @@ namespace Technosoftware.DaAeHdaClient.Com
return instance;
}
#endif
#endif
#endregion
@@ -2622,7 +2621,7 @@ namespace Technosoftware.DaAeHdaClient.Com
error,
langId,
buffer,
MAX_MESSAGE_LENGTH-1,
MAX_MESSAGE_LENGTH - 1,
IntPtr.Zero);
if (result > 0)

View File

@@ -23,9 +23,8 @@
#region Using Directives
using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Runtime.InteropServices;
using Technosoftware.DaAeHdaClient.Da;
#endregion

View File

@@ -22,16 +22,13 @@
#region Using Directives
using System;
using System.Threading;
using System.Collections;
using System.Globalization;
using System.Runtime.InteropServices;
using Technosoftware.DaAeHdaClient.Da;
using Technosoftware.DaAeHdaClient.Utilities;
using Technosoftware.OpcRcw.Da;
using System.Threading;
using Technosoftware.DaAeHdaClient.Com.Utilities;
using Technosoftware.DaAeHdaClient.Da;
using Technosoftware.OpcRcw.Da;
#endregion

View File

@@ -23,14 +23,12 @@
using System;
using System.Collections;
using System.Runtime.InteropServices;
using Technosoftware.DaAeHdaClient.Da;
using Technosoftware.DaAeHdaClient.Com.Da;
using Technosoftware.DaAeHdaClient.Utilities;
using Technosoftware.OpcRcw.Da;
using Technosoftware.OpcRcw.Comn;
using Technosoftware.DaAeHdaClient.Com.Utilities;
using Technosoftware.DaAeHdaClient.Da;
using Technosoftware.DaAeHdaClient.Utilities;
using Technosoftware.OpcRcw.Comn;
using Technosoftware.OpcRcw.Da;
#endregion

View File

@@ -23,13 +23,10 @@
#region Using Directives
using System;
using System.Collections;
using Technosoftware.DaAeHdaClient.Da;
using Technosoftware.DaAeHdaClient.Com.Da;
using Technosoftware.DaAeHdaClient.Utilities;
using Technosoftware.OpcRcw.Da;
using Technosoftware.DaAeHdaClient.Com.Utilities;
using Technosoftware.DaAeHdaClient.Da;
using Technosoftware.OpcRcw.Da;
#endregion
namespace Technosoftware.DaAeHdaClient.Com.Da20

View File

@@ -66,7 +66,7 @@ namespace Technosoftware.DaAeHdaClient.Com
try
{
// create buffer.
var buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(IntPtr))*count);
var buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(IntPtr)) * count);
try
{

View File

@@ -22,14 +22,9 @@
#region Using Directives
using System;
using System.Xml;
using System.Net;
using System.Text;
using System.Collections;
using System.Globalization;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
#endregion

View File

@@ -23,10 +23,9 @@
#region Using Directives
using System;
using System.Collections;
using Technosoftware.DaAeHdaClient.Hda;
using Technosoftware.OpcRcw.Hda;
using Technosoftware.OpcRcw.Comn;
using Technosoftware.OpcRcw.Hda;
#endregion
namespace Technosoftware.DaAeHdaClient.Com.Hda
@@ -141,7 +140,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
lock (this)
{
var branchPath = (itemID != null && itemID.ItemName != null)?itemID.ItemName:"";
var branchPath = (itemID != null && itemID.ItemName != null) ? itemID.ItemName : "";
// move to the correct position in the server's address space.
try
@@ -171,7 +170,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
// browse for items
enumerator = GetEnumerator(false);
var items = FetchElements(enumerator, maxElements-elements.Count, false);
var items = FetchElements(enumerator, maxElements - elements.Count, false);
if (items != null)
{
@@ -252,7 +251,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
}
// fetch next set of items.
var items = FetchElements(pos.Enumerator, maxElements-elements.Count, false);
var items = FetchElements(pos.Enumerator, maxElements - elements.Count, false);
if (items != null)
{
@@ -282,7 +281,7 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
{
try
{
var browseType = (isBranch)?OPCHDA_BROWSETYPE.OPCHDA_BRANCH:OPCHDA_BROWSETYPE.OPCHDA_LEAF;
var browseType = (isBranch) ? OPCHDA_BROWSETYPE.OPCHDA_BRANCH : OPCHDA_BROWSETYPE.OPCHDA_LEAF;
IEnumString pEnumerator = null;
m_browser.GetEnum(browseType, out pEnumerator);

View File

@@ -39,15 +39,15 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
/// <summary>
/// Initializes the object with the containing subscription object.
/// </summary>
public DataCallback() {}
public DataCallback() { }
/// <summary>
/// Fired when an exception occurs during callback processing.
/// </summary>
public event TsCHdaCallbackExceptionEventHandler CallbackExceptionEvent
{
add {lock (this) { _callbackExceptionEvent += value; }}
remove {lock (this) { _callbackExceptionEvent -= value; }}
add { lock (this) { _callbackExceptionEvent += value; } }
remove { lock (this) { _callbackExceptionEvent -= value; } }
}
/// <summary>

View File

@@ -66,8 +66,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
{
var output = new OpcRcw.Hda.OPCHDA_FILETIME();
output.dwHighDateTime = (int)((((ulong)(input*10000000)) & 0xFFFFFFFF00000000)>>32);
output.dwLowDateTime = (int)((((ulong)(input*10000000)) & 0x00000000FFFFFFFF));
output.dwHighDateTime = (int)((((ulong)(input * 10000000)) & 0xFFFFFFFF00000000) >> 32);
output.dwLowDateTime = (int)((((ulong)(input * 10000000)) & 0x00000000FFFFFFFF));
return output;
}
@@ -102,8 +102,8 @@ namespace Technosoftware.DaAeHdaClient.Com.Hda
if (input != null)
{
output.ftTime = Convert(Technosoftware.DaAeHdaClient.Com.Interop.GetFILETIME(input.AbsoluteTime));
output.szTime = (input.IsRelative)?input.ToString():"";
output.bString = (input.IsRelative)?1:0;
output.szTime = (input.IsRelative) ? input.ToString() : "";
output.bString = (input.IsRelative) ? 1 : 0;
}
// create a null value for a time structure.

View File

@@ -22,12 +22,11 @@
#region Using Directives
using System;
using System.Net;
using System.Globalization;
using System.Net;
using System.Runtime.InteropServices;
using Technosoftware.DaAeHdaClient.Da;
using Technosoftware.DaAeHdaClient.Com.Utilities;
using Technosoftware.DaAeHdaClient.Da;
#endregion
#pragma warning disable 0618
@@ -859,7 +858,8 @@ namespace Technosoftware.DaAeHdaClient.Com
/// <summary>
/// This flag suppresses the conversion to local time done during marshalling.
/// </summary>
public static bool PreserveUtc {
public static bool PreserveUtc
{
get { lock (typeof(Interop)) { return DaAeHdaClient.ApplicationInstance.TimeAsUtc; } }
set { lock (typeof(Interop)) { DaAeHdaClient.ApplicationInstance.TimeAsUtc = value; } }
}

View File

@@ -23,12 +23,11 @@
#region Using Directives
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Net;
using System.Globalization;
using System.Net;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
using Technosoftware.DaAeHdaClient.Utilities;
#endregion

View File

@@ -22,14 +22,12 @@
#region Using Directives
using System;
using System.Net;
using System.Collections;
using System.Runtime.InteropServices;
using Technosoftware.OpcRcw.Comn;
using Technosoftware.DaAeHdaClient.Ae;
using Technosoftware.DaAeHdaClient.Da;
using Technosoftware.DaAeHdaClient.Hda;
using Technosoftware.OpcRcw.Comn;
#endregion
namespace Technosoftware.DaAeHdaClient.Com
@@ -45,7 +43,7 @@ namespace Technosoftware.DaAeHdaClient.Com
/// <summary>
/// Frees all unmanaged resources
/// </summary>
public void Dispose() {}
public void Dispose() { }
//======================================================================
// IDiscovery
@@ -73,7 +71,7 @@ namespace Technosoftware.DaAeHdaClient.Com
{
lock (this)
{
var credentials = (connectData != null)?connectData.GetCredential(null, null):null;
var credentials = (connectData != null) ? connectData.GetCredential(null, null) : null;
// connect to the server.
m_server = (IOPCServerList2)Interop.CreateInstance(CLSID, host, credentials, connectData?.UseConnectSecurity ?? false);
@@ -160,7 +158,7 @@ namespace Technosoftware.DaAeHdaClient.Com
{
lock (this)
{
var credentials = (connectData != null)?connectData.GetCredential(null, null):null;
var credentials = (connectData != null) ? connectData.GetCredential(null, null) : null;
// connect to the server.
m_server = (IOPCServerList2)Interop.CreateInstance(CLSID, host, credentials, connectData?.UseConnectSecurity ?? false);
@@ -223,7 +221,7 @@ namespace Technosoftware.DaAeHdaClient.Com
var count = 10;
// create buffer.
var buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Guid))*count);
var buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Guid)) * count);
try
{

View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Technosoftware.DaAeHdaClient.Utilities;

View File

@@ -22,10 +22,9 @@
#region Using Directives
using System;
using System.Net;
using System.Globalization;
using System.Net;
using System.Runtime.InteropServices;
using Technosoftware.DaAeHdaClient.Da;
#pragma warning disable 618
#endregion

View File

@@ -85,11 +85,11 @@ namespace Technosoftware.DaAeHdaClient.Ae
protected virtual void Dispose(bool disposing)
{
// Check to see if Dispose has already been called.
if(!disposed_)
if (!disposed_)
{
// If disposing equals true, dispose all managed
// and unmanaged resources.
if(disposing)
if (disposing)
{
}
// Release unmanaged resources. If disposing is false,

View File

@@ -40,12 +40,12 @@ namespace Technosoftware.DaAeHdaClient.Ae
/// <summary>
/// Initializes the object with default values.
/// </summary>
public TsCAeItemUrl() {}
public TsCAeItemUrl() { }
/// <summary>
/// Initializes the object with an ItemIdentifier object.
/// </summary>
public TsCAeItemUrl(OpcItem item) : base(item) {}
public TsCAeItemUrl(OpcItem item) : base(item) { }
/// <summary>
/// Initializes the object with an ItemIdentifier object and url.

View File

@@ -23,7 +23,6 @@
#region Using Directives
using System;
using System.Collections;
using System.Runtime.Serialization;
#endregion

View File

@@ -268,11 +268,11 @@ namespace Technosoftware.DaAeHdaClient.Ae
protected virtual void Dispose(bool disposing)
{
// Check to see if Dispose has already been called.
if(!disposed_)
if (!disposed_)
{
// If disposing equals true, dispose all managed
// and unmanaged resources.
if(disposing)
if (disposing)
{
if (subscription_ != null)
{

View File

@@ -21,7 +21,6 @@
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
#region Using Directives
using System;
using Technosoftware.DaAeHdaClient.Utilities;
#endregion

View File

@@ -23,9 +23,8 @@
#region Using Directives
using System;
using System.Collections;
using System.Xml;
using System.IO;
using System.Xml;
using Technosoftware.DaAeHdaClient.Da;
#endregion

View File

@@ -22,8 +22,8 @@
#region Using Directives
using System;
using System.Xml;
using System.Runtime.Serialization;
using System.Xml;
#endregion
namespace Technosoftware.DaAeHdaClient.Da

View File

@@ -55,13 +55,13 @@ namespace Technosoftware.DaAeHdaClient.Da
/// <summary>A device failure has been detected.</summary>
BadDeviceFailure = 0x0000000c,
/// <summary>
/// A sensor failure had been detected (the Limits field can provide additional
/// A sensor failure had been detected (the Limits?field can provide additional
/// diagnostic information in some situations).
/// </summary>
BadSensorFailure = 0x00000010,
/// <summary>
/// Communications have failed. However, the last known value is available. Note that
/// the age of the value may be determined from the time stamp in the item state.
/// the age?of the value may be determined from the time stamp in the item state.
/// </summary>
BadLastKnownValue = 0x00000014,
/// <summary>Communications have failed. There is no last known value is available.</summary>
@@ -83,16 +83,16 @@ namespace Technosoftware.DaAeHdaClient.Da
Uncertain = 0x00000040,
/// <summary>
/// Whatever was writing this value has stopped doing so. The returned value should
/// be regarded as stale. Note that this differs from a BAD value with sub-status
/// be regarded as stale? Note that this differs from a BAD value with sub-status
/// badLastKnownValue (Last Known Value). That status is associated specifically with a
/// detectable communications error on a fetched value. This error is associated with the
/// failure of some external source to put something into the value within an acceptable
/// period of time. Note that the age of the value can be determined from the time stamp
/// detectable communications error on a fetched?value. This error is associated with the
/// failure of some external source to put?something into the value within an acceptable
/// period of time. Note that the age?of the value can be determined from the time stamp
/// in the item state.
/// </summary>
UncertainLastUsableValue = 0x00000044,
/// <summary>
/// Either the value has pegged at one of the sensor limits (in which case the
/// Either the value has pegged?at one of the sensor limits (in which case the
/// limit field should be set to low or high) or the sensor is otherwise known to be out of
/// calibration via some form of internal diagnostics (in which case the limit field should
/// be none).
@@ -100,7 +100,7 @@ namespace Technosoftware.DaAeHdaClient.Da
UncertainSensorNotAccurate = 0x00000050,
/// <summary>
/// The returned value is outside the limits defined for this parameter. Note that in
/// this case (per the Field-bus Specification) the Limits field indicates which limit has
/// this case (per the Field-bus Specification) the Limits?field indicates which limit has
/// been exceeded but does NOT necessarily imply that the value cannot move farther out of
/// range.
/// </summary>

View File

@@ -22,8 +22,8 @@
#region Using Directives
using System;
using System.Runtime.Serialization;
using System.Collections.Generic;
using System.Runtime.Serialization;
#endregion
namespace Technosoftware.DaAeHdaClient.Da

View File

@@ -210,8 +210,10 @@ namespace Technosoftware.DaAeHdaClient.Da
/// <summary>
/// The items belonging to the subscription.
/// </summary>
public TsCDaItem[] Items {
get {
public TsCDaItem[] Items
{
get
{
if (daItems_ == null) return new TsCDaItem[0];
var items = new TsCDaItem[daItems_.Length];
for (var ii = 0; ii < daItems_.Length; ii++) items[ii] = (TsCDaItem)daItems_[ii].Clone();
@@ -562,7 +564,8 @@ namespace Technosoftware.DaAeHdaClient.Da
/// <summary>
/// An event to receive data change updates.
/// </summary>
public event TsCDaDataChangedEventHandler DataChangedEvent {
public event TsCDaDataChangedEventHandler DataChangedEvent
{
add => Subscription.DataChangedEvent += value;
remove => Subscription.DataChangedEvent -= value;
}

View File

@@ -22,8 +22,6 @@
#region Using Directives
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
#pragma warning disable 618
#endregion

View File

@@ -22,8 +22,8 @@
#region Using Directives
using System;
using System.Text;
using System.Collections;
using System.Text;
#endregion
namespace Technosoftware.DaAeHdaClient.Hda

View File

@@ -22,8 +22,6 @@
#region Using Directives
using System;
using System.Linq;
using static System.String;
using System.Diagnostics;
using Technosoftware.DaAeHdaClient.Utilities;
#endregion

View File

@@ -22,9 +22,9 @@
#region Using Directives
using System;
using System.Xml;
using System.Collections;
using System.Text;
using System.Xml;
#endregion
namespace Technosoftware.DaAeHdaClient
@@ -161,7 +161,7 @@ namespace Technosoftware.DaAeHdaClient
// convert scalar value to an array type.
if (!type.IsArray && newType.IsArray)
{
var array = new ArrayList(1) {ChangeType(source, newType.GetElementType())};
var array = new ArrayList(1) { ChangeType(source, newType.GetElementType()) };
return array.ToArray(newType.GetElementType() ?? throw new InvalidOperationException());
}

View File

@@ -22,9 +22,9 @@
#region Using Directives
using System;
using System.Xml;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Xml;
#endregion
namespace Technosoftware.DaAeHdaClient

View File

@@ -24,8 +24,8 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Resources;
using System.Reflection;
using System.Resources;
using System.Runtime.Serialization;
#endregion

View File

@@ -22,8 +22,8 @@
#region Using Directives
using System;
using System.Text;
using System.Security.Cryptography;
using System.Text;
#endregion
namespace Technosoftware.DaAeHdaClient

View File

@@ -22,9 +22,6 @@
#region Using Directives
using System;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.IO;
// ReSharper disable UnusedMember.Global

View File

@@ -50,7 +50,7 @@ namespace Technosoftware.DaAeHdaClient.Utilities
return DateTime.UtcNow;
}
var ticks = (counter - s_Default.m_baseline)*s_Default.m_ratio;
var ticks = (counter - s_Default.m_baseline) * s_Default.m_ratio;
return new DateTime((long)ticks + s_Default.m_offset);
}
@@ -83,7 +83,7 @@ namespace Technosoftware.DaAeHdaClient.Utilities
m_baseline = m_offset;
}
m_ratio = ((decimal)TimeSpan.TicksPerSecond)/m_frequency;
m_ratio = ((decimal)TimeSpan.TicksPerSecond) / m_frequency;
}
/// <summary>

View File

@@ -22,10 +22,10 @@
#region Using Directives
using System;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
// ReSharper disable UnusedMember.Global
#endregion

View File

@@ -11,8 +11,6 @@
#region Using Directives
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
#endregion
@@ -24,7 +22,7 @@ namespace Technosoftware.OpcRcw.Ae
[ComImport]
[GuidAttribute("58E13251-AC87-11d1-84D5-00608CB8A7E9")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface CATID_OPCAEServer10 {}
public interface CATID_OPCAEServer10 { }
/// <exclude />
public enum OPCAEBROWSEDIRECTION
@@ -61,7 +59,7 @@ namespace Technosoftware.OpcRcw.Ae
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ONEVENTSTRUCT
{
[MarshalAs(UnmanagedType.I2)]
@@ -100,7 +98,7 @@ namespace Technosoftware.OpcRcw.Ae
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCEVENTSERVERSTATUS
{
public FILETIME ftStartTime;
@@ -120,7 +118,7 @@ namespace Technosoftware.OpcRcw.Ae
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCCONDITIONSTATE
{
[MarshalAs(UnmanagedType.I2)]

View File

@@ -11,8 +11,6 @@
#region Using Directives
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
/* Unmerged change from project 'Technosoftware.OpcRcw (net472)'

View File

@@ -11,8 +11,6 @@
#region Using Directives
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
#endregion
@@ -24,25 +22,25 @@ namespace Technosoftware.OpcRcw.Da
[ComImport]
[GuidAttribute("63D5F430-CFE4-11d1-B2C8-0060083BA1FB")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface CATID_OPCDAServer10 {}
public interface CATID_OPCDAServer10 { }
/// <exclude />
[ComImport]
[GuidAttribute("63D5F432-CFE4-11d1-B2C8-0060083BA1FB")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface CATID_OPCDAServer20 {}
public interface CATID_OPCDAServer20 { }
/// <exclude />
[ComImport]
[GuidAttribute("CC603642-66D7-48f1-B69A-B625E73652D7")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface CATID_OPCDAServer30 {}
public interface CATID_OPCDAServer30 { }
/// <exclude />
[ComImport]
[GuidAttribute("3098EDA4-A006-48b2-A27F-247453959408")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface CATID_XMLDAServer10 {}
public interface CATID_XMLDAServer10 { }
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
@@ -113,7 +111,7 @@ namespace Technosoftware.OpcRcw.Da
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCGROUPHEADER
{
[MarshalAs(UnmanagedType.I4)]
@@ -129,7 +127,7 @@ namespace Technosoftware.OpcRcw.Da
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCITEMHEADER1
{
[MarshalAs(UnmanagedType.I4)]
@@ -144,7 +142,7 @@ namespace Technosoftware.OpcRcw.Da
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCITEMHEADER2
{
[MarshalAs(UnmanagedType.I4)]
@@ -158,7 +156,7 @@ namespace Technosoftware.OpcRcw.Da
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCGROUPHEADERWRITE
{
[MarshalAs(UnmanagedType.I4)]
@@ -172,7 +170,7 @@ namespace Technosoftware.OpcRcw.Da
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCITEMHEADERWRITE
{
[MarshalAs(UnmanagedType.I4)]
@@ -182,7 +180,7 @@ namespace Technosoftware.OpcRcw.Da
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCITEMSTATE
{
[MarshalAs(UnmanagedType.I4)]
@@ -197,7 +195,7 @@ namespace Technosoftware.OpcRcw.Da
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCSERVERSTATUS
{
public FILETIME ftStartTime;
@@ -221,7 +219,7 @@ namespace Technosoftware.OpcRcw.Da
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCITEMDEF
{
[MarshalAs(UnmanagedType.LPWStr)]
@@ -242,7 +240,7 @@ namespace Technosoftware.OpcRcw.Da
};
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCITEMATTRIBUTES
{
[MarshalAs(UnmanagedType.LPWStr)]
@@ -270,7 +268,7 @@ namespace Technosoftware.OpcRcw.Da
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCITEMRESULT
{
[MarshalAs(UnmanagedType.I4)]
@@ -287,7 +285,7 @@ namespace Technosoftware.OpcRcw.Da
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCITEMPROPERTY
{
[MarshalAs(UnmanagedType.I2)]
@@ -309,7 +307,7 @@ namespace Technosoftware.OpcRcw.Da
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCITEMPROPERTIES
{
[MarshalAs(UnmanagedType.I4)]
@@ -322,7 +320,7 @@ namespace Technosoftware.OpcRcw.Da
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCBROWSEELEMENT
{
[MarshalAs(UnmanagedType.LPWStr)]
@@ -337,7 +335,7 @@ namespace Technosoftware.OpcRcw.Da
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCITEMVQT
{
[MarshalAs(UnmanagedType.Struct)]

View File

@@ -11,8 +11,6 @@
#region Using Directives
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
#endregion
@@ -25,7 +23,7 @@ namespace Technosoftware.OpcRcw.Hda
[ComImport]
[GuidAttribute("7DE5B060-E089-11d2-A5E6-000086339399")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface CATID_OPCHDAServer10 {}
public interface CATID_OPCHDAServer10 { }
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
@@ -128,7 +126,7 @@ namespace Technosoftware.OpcRcw.Hda
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCHDA_ANNOTATION
{
[MarshalAs(UnmanagedType.I4)]
@@ -142,7 +140,7 @@ namespace Technosoftware.OpcRcw.Hda
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCHDA_MODIFIEDITEM
{
[MarshalAs(UnmanagedType.I4)]
@@ -158,7 +156,7 @@ namespace Technosoftware.OpcRcw.Hda
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCHDA_ATTRIBUTE
{
[MarshalAs(UnmanagedType.I4)]
@@ -172,7 +170,7 @@ namespace Technosoftware.OpcRcw.Hda
};
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCHDA_TIME
{
[MarshalAs(UnmanagedType.I4)]
@@ -183,7 +181,7 @@ namespace Technosoftware.OpcRcw.Hda
}
/// <exclude />
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OPCHDA_ITEM
{
[MarshalAs(UnmanagedType.I4)]
@@ -886,7 +884,7 @@ namespace Technosoftware.OpcRcw.Hda
[MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.I4, SizeParamIndex=2)]
int[] phrErrors);
void OnInsertAnnotations (
void OnInsertAnnotations(
[MarshalAs(UnmanagedType.I4)]
int dwTransactionID,
[MarshalAs(UnmanagedType.I4)]
@@ -898,7 +896,7 @@ namespace Technosoftware.OpcRcw.Hda
[MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.I4, SizeParamIndex=2)]
int[] phrErrors);
void OnPlayback (
void OnPlayback(
[MarshalAs(UnmanagedType.I4)]
int dwTransactionID,
[MarshalAs(UnmanagedType.I4)]
@@ -909,7 +907,7 @@ namespace Technosoftware.OpcRcw.Hda
[MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.I4, SizeParamIndex=2)]
int[] phrErrors);
void OnUpdateComplete (
void OnUpdateComplete(
[MarshalAs(UnmanagedType.I4)]
int dwTransactionID,
[MarshalAs(UnmanagedType.I4)]