Skip to content

Commit

Permalink
Merge pull request #47 from hylasoft-usa/da-write-err
Browse files Browse the repository at this point in the history
style cop
  • Loading branch information
jmbeach authored Mar 13, 2017
2 parents 6a937ac + 9e6da3c commit 19dc3ee
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
17 changes: 9 additions & 8 deletions h-opc-cli/Repl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,34 +99,35 @@ private void Write(IList<string> args)
var tag = args[0];
var val = args[1];
var type = _client.GetDataType(GenerateRelativeTag(tag));
switch(type.Name) {
switch (type.Name)
{
case "Int32":
var val32 = Convert.ToInt32(val);
_client.Write<int>(GenerateRelativeTag(tag), val32);
break;
case "Int16":
var val16 = Convert.ToInt16(val);
_client.Write<Int16>(GenerateRelativeTag(tag), val16);
_client.Write<short>(GenerateRelativeTag(tag), val16);
break;
case "UInt16":
var valuint16 = Convert.ToUInt16(val);
_client.Write<UInt16>(GenerateRelativeTag(tag), valuint16);
_client.Write<ushort>(GenerateRelativeTag(tag), valuint16);
break;
case "UInt32":
var valuint32 = Convert.ToUInt32(val);
_client.Write<UInt32>(GenerateRelativeTag(tag), valuint32);
_client.Write<uint>(GenerateRelativeTag(tag), valuint32);
break;
case "Boolean":
var valBool = Convert.ToBoolean(val);
_client.Write<Boolean>(GenerateRelativeTag(tag), valBool);
_client.Write<bool>(GenerateRelativeTag(tag), valBool);
break;
case "Int64":
var val64 = Convert.ToInt64(val);
_client.Write<Int64>(GenerateRelativeTag(tag), val64);
_client.Write<long>(GenerateRelativeTag(tag), val64);
break;
case "UInt64":
var valuint64 = Convert.ToUInt64(val);
_client.Write<UInt64>(GenerateRelativeTag(tag), valuint64);
_client.Write<ulong>(GenerateRelativeTag(tag), valuint64);
break;
default:
_client.Write<object>(GenerateRelativeTag(tag), val);
Expand Down Expand Up @@ -179,7 +180,7 @@ private void ShowSubnodes()
if (nodes == null || !nodes.Any())
Console.WriteLine("no subnodes");
else foreach (var node in nodes)
Console.WriteLine(node.Name);
Console.WriteLine(node.Name);
}
#endregion

Expand Down
2 changes: 1 addition & 1 deletion h-opc/Common/IClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public interface IClient<out TNode> : IDisposable
/// Gets the datatype of an OPC tag
/// </summary>
/// <param name="tag">Tag to get datatype of</param>
/// <returns>System.Type</returns>
/// <returns>System Type</returns>
System.Type GetDataType(string tag);

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions h-opc/Da/DaClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ public DaClient(Uri serverUrl)
/// Gets the datatype of an OPC tag
/// </summary>
/// <param name="tag">Tag to get datatype of</param>
/// <returns>System.Type</returns>
/// <returns>System Type</returns>
public System.Type GetDataType(string tag)
{
var item = new OpcDa.Item { ItemName = tag };
OpcDa.ItemProperty result;
try
{
var propertyCollection = _server.GetProperties(new [] {item}, new [] {new OpcDa.PropertyID(1)}, false)[0];
var propertyCollection = _server.GetProperties(new[] { item }, new[] { new OpcDa.PropertyID(1) }, false)[0];
result = propertyCollection[0];
}
catch (NullReferenceException)
Expand Down
10 changes: 5 additions & 5 deletions h-opc/Ua/UaClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void Connect()
/// Gets the datatype of an OPC tag
/// </summary>
/// <param name="tag">Tag to get datatype of</param>
/// <returns>System.Type</returns>
/// <returns>System Type</returns>
public System.Type GetDataType(string tag)
{
var nodesToRead = BuildReadValueIdCollection(tag, Attributes.Value);
Expand Down Expand Up @@ -487,10 +487,10 @@ private Session InitializeSession(Uri url)
CertificateValidator = certificateValidator,
ServerConfiguration = new ServerConfiguration
{
MaxSubscriptionCount = _options.MaxSubscriptionCount,
MaxMessageQueueSize = _options.MaxMessageQueueSize,
MaxNotificationQueueSize = _options.MaxNotificationQueueSize,
MaxPublishRequestCount = _options.MaxPublishRequestCount
MaxSubscriptionCount = _options.MaxSubscriptionCount,
MaxMessageQueueSize = _options.MaxMessageQueueSize,
MaxNotificationQueueSize = _options.MaxNotificationQueueSize,
MaxPublishRequestCount = _options.MaxPublishRequestCount
},
SecurityConfiguration = new SecurityConfiguration
{
Expand Down
2 changes: 1 addition & 1 deletion tests/DaTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void DaExploreFolder()
public void DaGetDataType()
{
var type = _client.GetDataType(TestRegister);
Assert.AreEqual(typeof(Int16), type);
Assert.AreEqual(typeof(short), type);
}
}
}
4 changes: 2 additions & 2 deletions tests/UaTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ public void DisposeWithoutException()
public void UaGetDataType()
{
var type = _client.GetDataType("Data.Dynamic.Scalar.Int32Value");
Assert.AreEqual(typeof(Int32), type);
Assert.AreEqual(typeof(short), type);
type = _client.GetDataType("Data.Dynamic.Scalar.Int16Value");
Assert.AreEqual(typeof(Int16), type);
Assert.AreEqual(typeof(short), type);
}
}
}

0 comments on commit 19dc3ee

Please sign in to comment.