Skip to content

Commit 02b5cee

Browse files
Updating
1 parent 10faacc commit 02b5cee

116 files changed

Lines changed: 12110 additions & 18 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

MTConnect.NET.sln

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Templates", "Templates", "{
117117
EndProject
118118
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Agent", "templates\mtconnect.net-agent\content\MTConnect.NET-Embedded-Agent\Agent.csproj", "{FF3FACB1-C470-4C7F-9A4B-F364BE1E32B3}"
119119
EndProject
120+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MTConnect.NET-XML-2", "libraries\MTConnect.NET-XML-2\MTConnect.NET-XML-2.csproj", "{A0B626A0-5AD5-4110-9BF6-147E304D1FE6}"
121+
EndProject
120122
Global
121123
GlobalSection(SolutionConfigurationPlatforms) = preSolution
122124
Debug|Any CPU = Debug|Any CPU
@@ -413,6 +415,14 @@ Global
413415
{FF3FACB1-C470-4C7F-9A4B-F364BE1E32B3}.Package|Any CPU.Build.0 = Debug|Any CPU
414416
{FF3FACB1-C470-4C7F-9A4B-F364BE1E32B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
415417
{FF3FACB1-C470-4C7F-9A4B-F364BE1E32B3}.Release|Any CPU.Build.0 = Release|Any CPU
418+
{A0B626A0-5AD5-4110-9BF6-147E304D1FE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
419+
{A0B626A0-5AD5-4110-9BF6-147E304D1FE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
420+
{A0B626A0-5AD5-4110-9BF6-147E304D1FE6}.Docker|Any CPU.ActiveCfg = Debug|Any CPU
421+
{A0B626A0-5AD5-4110-9BF6-147E304D1FE6}.Docker|Any CPU.Build.0 = Debug|Any CPU
422+
{A0B626A0-5AD5-4110-9BF6-147E304D1FE6}.Package|Any CPU.ActiveCfg = Package|Any CPU
423+
{A0B626A0-5AD5-4110-9BF6-147E304D1FE6}.Package|Any CPU.Build.0 = Package|Any CPU
424+
{A0B626A0-5AD5-4110-9BF6-147E304D1FE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
425+
{A0B626A0-5AD5-4110-9BF6-147E304D1FE6}.Release|Any CPU.Build.0 = Release|Any CPU
416426
EndGlobalSection
417427
GlobalSection(SolutionProperties) = preSolution
418428
HideSolutionNode = FALSE
@@ -457,6 +467,7 @@ Global
457467
{A9DF36FC-4EF7-4BFB-B47D-F1C10227631A} = {FFF032D3-7446-4CAF-A3E3-CF9C4E1A5DCC}
458468
{24C98CF3-CC93-4696-A036-8FD1E16F2E7E} = {FFF032D3-7446-4CAF-A3E3-CF9C4E1A5DCC}
459469
{FF3FACB1-C470-4C7F-9A4B-F364BE1E32B3} = {D7873DF2-16DB-4B19-A100-C0089DF37488}
470+
{A0B626A0-5AD5-4110-9BF6-147E304D1FE6} = {B7CCD58C-A3F3-43BE-BBF8-2B20D118C39D}
460471
EndGlobalSection
461472
GlobalSection(ExtensibilityGlobals) = postSolution
462473
SolutionGuid = {CC13D3AD-18BF-4695-AB2A-087EF0885B20}

agent/MTConnect.NET-Agent/MTConnect.NET-Agent.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
<None Update="devices\okuma.xml">
6060
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
6161
</None>
62+
<None Update="devices\sodick.xml">
63+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
64+
</None>
6265
<None Update="README.md">
6366
<PackagePath>\</PackagePath>
6467
<Pack>True</Pack>

agent/MTConnect.NET-Agent/agent.config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# - Device Configuration -
2-
devices: devices
2+
devices: devices/sodick.xml
33

44
# - Processors -
55
processors:
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Device id="Sodick_VN600Q_1" name="Sodick_VN600Q" uuid="Sodick_VN600Q">
2+
<Components>
3+
<Systems id="systems_56" name="systems">
4+
<Components>
5+
<x:Wire id="wire_88" name="wire">
6+
<DataItems>
7+
<DataItem category="SAMPLE" id="wire_89" name="wire_speed" nativeUnits="MILLIMETER/SECOND" type="VELOCITY" units="MILLIMETER/SECOND"/>
8+
<DataItem category="SAMPLE" id="wire_90" name="wire_tension_com" nativeUnits="x:GRAM" subType="COMMANDED" type="x:TENSION" units="x:GRAM"/>
9+
<DataItem category="SAMPLE" id="wire_91" name="wire_tension_act" nativeUnits="x:GRAM" subType="ACTUAL" type="x:TENSION" units="x:GRAM"/>
10+
<DataItem category="SAMPLE" id="wire_92" name="radius" nativeUnits="MILLIMETER" type="x:RADIUS" units="MILLIMETER"/>
11+
<DataItem category="EVENT" id="wire_93" name="wire_run" type="x:WIRE_MOTION_STATE"/>
12+
<DataItem category="EVENT" id="wire_94" name="discharging" type="x:DISCHARGING"/>
13+
<DataItem category="EVENT" id="wire_95" name="contact" type="x:CONTACT"/>
14+
<DataItem category="EVENT" id="wire_96" name="connected" type="x:CONNECTED"/>
15+
<DataItem category="SAMPLE" id="wire_97" name="upper_power_feed" nativeUnits="SECOND" subType="x:UPPER_POWER_FEED_CONTACT" type="ACCUMULATED_TIME" units="SECOND"/>
16+
<DataItem category="SAMPLE" id="wire_98" name="lower_power_feed" nativeUnits="SECOND" subType="x:LOWER_POWER_FEED_CONTACT" type="ACCUMULATED_TIME" units="SECOND"/>
17+
<DataItem category="CONDITION" id="wire_99" name="tension" type="x:TENSION"/>
18+
<DataItem category="CONDITION" id="wire_100" name="winding" type="x:WINDING"/>
19+
<DataItem category="SAMPLE" id="wire_101" name="cutting_speed" nativeUnits="MILLIMETER/MINUTE" type="VELOCITY" units="MILLIMETER/MINUTE"/>
20+
</DataItems>
21+
</x:Wire>
22+
</Components>
23+
</Systems>
24+
</Components>
25+
</Device>

agent/MTConnect.NET-Applications-Agents/MTConnect.NET-Applications-Agents.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<ProjectReference Include="..\..\libraries\MTConnect.NET-JSON-cppagent\MTConnect.NET-JSON-cppagent.csproj" />
6565
<ProjectReference Include="..\..\libraries\MTConnect.NET-JSON\MTConnect.NET-JSON.csproj" />
6666
<ProjectReference Include="..\..\libraries\MTConnect.NET-Services\MTConnect.NET-Services.csproj" />
67-
<ProjectReference Include="..\..\libraries\MTConnect.NET-XML\MTConnect.NET-XML.csproj" />
67+
<ProjectReference Include="..\..\libraries\MTConnect.NET-XML-2\MTConnect.NET-XML-2.csproj" />
6868
<ProjectReference Include="..\Modules\MTConnect.NET-AgentModule-HttpAdapter\MTConnect.NET-AgentModule-HttpAdapter.csproj" />
6969
<ProjectReference Include="..\Modules\MTConnect.NET-AgentModule-HttpServer\MTConnect.NET-AgentModule-HttpServer.csproj" />
7070
<ProjectReference Include="..\Modules\MTConnect.NET-AgentModule-MqttAdapter\MTConnect.NET-AgentModule-MqttAdapter.csproj" />

examples/MTConnect.NET-Client-HTTP/MTConnect.NET-Client-HTTP.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99

1010
<ItemGroup>
1111
<ProjectReference Include="..\..\libraries\MTConnect.NET-HTTP\MTConnect.NET-HTTP.csproj" />
12-
<ProjectReference Include="..\..\libraries\MTConnect.NET-JSON-cppagent\MTConnect.NET-JSON-cppagent.csproj" />
13-
<ProjectReference Include="..\..\libraries\MTConnect.NET-JSON\MTConnect.NET-JSON.csproj" />
14-
<ProjectReference Include="..\..\libraries\MTConnect.NET-XML\MTConnect.NET-XML.csproj" />
12+
<ProjectReference Include="..\..\libraries\MTConnect.NET-XML-2\MTConnect.NET-XML-2.csproj" />
1513
</ItemGroup>
1614

1715
</Project>

examples/MTConnect.NET-Client-HTTP/Program.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,22 @@ static void DocumentClient()
2525

2626
client.ProbeReceived += (s, response) =>
2727
{
28-
foreach (var device in response.Devices) Console.WriteLine($"Device Received : {device.Uuid} : {device.Name}");
28+
var formatOptions = new List<KeyValuePair<string, string>>();
29+
formatOptions.Add(new KeyValuePair<string, string>("indentOutput", "true"));
30+
31+
var inputStream = ResponseDocumentFormatter.Format("XML", response, formatOptions).Content;
32+
if (inputStream != null)
33+
{
34+
inputStream.Seek(0, SeekOrigin.Begin);
35+
36+
var outputStream = new MemoryStream();
37+
inputStream.CopyTo(outputStream);
38+
var outputBytes = outputStream.ToArray();
39+
Console.WriteLine(System.Text.Encoding.UTF8.GetString(outputBytes));
40+
}
41+
42+
//foreach (var device in response.Devices) EntityFo;
43+
//foreach (var device in response.Devices) Console.WriteLine($"Device Received : {device.Uuid} : {device.Name}");
2944
};
3045

3146
client.CurrentReceived += (s, response) =>

libraries/MTConnect.NET-Common/Configurations/DeviceConfiguration.cs

Lines changed: 75 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,20 @@ public static IEnumerable<DeviceConfiguration> FromFile(string filePath, string
9393

9494
return devices;
9595
}
96-
else
97-
{
98-
if (contents.Position > 0) contents.Seek(0, SeekOrigin.Begin);
96+
}
97+
}
9998

100-
// Read Single Entity Format
101-
var device = Formatters.EntityFormatter.CreateDevice(documentFormatterId, contents).Content;
102-
if (device != null)
103-
{
104-
return new List<DeviceConfiguration> { new DeviceConfiguration(device, rootPath) };
105-
}
99+
using (var contents = File.OpenRead(rootPath))
100+
{
101+
if (contents != null)
102+
{
103+
if (contents.Position > 0) contents.Seek(0, SeekOrigin.Begin);
104+
105+
// Read Single Entity Format
106+
var device = Formatters.EntityFormatter.CreateDevice(documentFormatterId, contents).Content;
107+
if (device != null)
108+
{
109+
return new List<DeviceConfiguration> { new DeviceConfiguration(device, rootPath) };
106110
}
107111
}
108112
}
@@ -114,6 +118,68 @@ public static IEnumerable<DeviceConfiguration> FromFile(string filePath, string
114118
return null;
115119
}
116120

121+
///// <summary>
122+
///// Gets a list of Devices from the specified file (ex. devices.xml)
123+
///// </summary>
124+
///// <param name="filePath">The path to the Device Configuration file</param>
125+
//public static IEnumerable<DeviceConfiguration> FromFile(string filePath, string documentFormatterId)
126+
//{
127+
// // Set the Filename
128+
// var path = !string.IsNullOrEmpty(filePath) ? filePath : DefaultFilename;
129+
130+
// // Add Working directory (if path is not rooted)
131+
// var rootPath = path;
132+
// if (!System.IO.Path.IsPathRooted(rootPath))
133+
// {
134+
// rootPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path);
135+
// }
136+
137+
// if (!string.IsNullOrEmpty(rootPath))
138+
// {
139+
// try
140+
// {
141+
// if (File.Exists(rootPath))
142+
// {
143+
// using (var contents = File.OpenRead(rootPath))
144+
// {
145+
// if (contents != null)
146+
// {
147+
// if (contents.Position > 0) contents.Seek(0, SeekOrigin.Begin);
148+
149+
// // Read ResponseDocument Format
150+
// var devicesDocument = Formatters.ResponseDocumentFormatter.CreateDevicesResponseDocument(documentFormatterId, contents).Content;
151+
// if (devicesDocument != null && devicesDocument.Devices != null && devicesDocument.Devices.Count() > 0)
152+
// {
153+
// var devices = new List<DeviceConfiguration>();
154+
155+
// foreach (var device in devicesDocument.Devices)
156+
// {
157+
// devices.Add(new DeviceConfiguration(device, rootPath));
158+
// }
159+
160+
// return devices;
161+
// }
162+
// else
163+
// {
164+
// if (contents.Position > 0) contents.Seek(0, SeekOrigin.Begin);
165+
166+
// // Read Single Entity Format
167+
// var device = Formatters.EntityFormatter.CreateDevice(documentFormatterId, contents).Content;
168+
// if (device != null)
169+
// {
170+
// return new List<DeviceConfiguration> { new DeviceConfiguration(device, rootPath) };
171+
// }
172+
// }
173+
// }
174+
// }
175+
// }
176+
// }
177+
// catch { }
178+
// }
179+
180+
// return null;
181+
//}
182+
117183
#if NETCOREAPP1_0_OR_GREATER
118184

119185
/// <summary>

libraries/MTConnect.NET-HTTP/Clients/MTConnectHttpClient.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ private async Task Worker()
650650
{
651651
// Run Probe Request
652652
var probe = await GetProbeAsync(_stop.Token);
653-
if (probe != null)
653+
if (probe != null && probe.Header != null)
654654
{
655655
_lastResponse = UnixDateTime.Now;
656656
ResponseReceived?.Invoke(this, new EventArgs());
@@ -958,7 +958,7 @@ private void ProcessSampleDocument(IStreamsResponseDocument document, Cancellati
958958
private static IDevice ProcessDevice(IMTConnectDevicesHeader header, IDevice inputDevice)
959959
{
960960
var outputDevice = (Device)inputDevice;
961-
outputDevice.InstanceId = header.InstanceId;
961+
if (header != null) outputDevice.InstanceId = header.InstanceId;
962962

963963
// Add DataItems
964964
if (!inputDevice.DataItems.IsNullOrEmpty())
@@ -999,7 +999,7 @@ private static IDevice ProcessDevice(IMTConnectDevicesHeader header, IDevice inp
999999
private static IComponent ProcessComponent(IMTConnectDevicesHeader header, IComponent inputComponent)
10001000
{
10011001
var outputComponent = (Component)inputComponent;
1002-
outputComponent.InstanceId = header.InstanceId;
1002+
if (header != null) outputComponent.InstanceId = header.InstanceId;
10031003

10041004
// Add DataItems
10051005
if (!inputComponent.DataItems.IsNullOrEmpty())
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
2+
// TrakHound Inc. licenses this file to you under the MIT license.
3+
4+
using MTConnect.Assets.Xml;
5+
using System.Collections.Generic;
6+
using System.Xml;
7+
using System.Xml.Serialization;
8+
9+
namespace MTConnect.Assets.ComponentConfigurationParameters
10+
{
11+
[XmlRoot("ComponentConfigurationParameters")]
12+
public class XmlComponentConfigurationParametersAsset : XmlAsset
13+
{
14+
[XmlArray("ParameterSets")]
15+
[XmlArrayItem("ParameterSet")]
16+
public List<XmlParameterSet> ParameterSets { get; set; }
17+
18+
19+
public override IAsset ToAsset()
20+
{
21+
var asset = new ComponentConfigurationParametersAsset();
22+
23+
asset.AssetId = AssetId;
24+
asset.Timestamp = Timestamp;
25+
asset.DeviceUuid = DeviceUuid;
26+
asset.Removed = Removed;
27+
28+
//if (Description != null) asset.Description = Description.ToDescription();
29+
30+
if (!ParameterSets.IsNullOrEmpty())
31+
{
32+
var parameterSets = new List<IParameterSet>();
33+
foreach (var parameterSet in ParameterSets)
34+
{
35+
parameterSets.Add(parameterSet.ToParameterSet());
36+
}
37+
asset.ParameterSets = parameterSets;
38+
}
39+
40+
return asset;
41+
}
42+
43+
public static void WriteXml(XmlWriter writer, IAsset asset)
44+
{
45+
if (asset != null)
46+
{
47+
var componentConfigurationParametersAsset = (IComponentConfigurationParametersAsset)asset;
48+
49+
writer.WriteStartElement("ComponentConfigurationParameters");
50+
51+
WriteCommonXml(writer, asset);
52+
53+
// ParameterSets
54+
if (!componentConfigurationParametersAsset.ParameterSets.IsNullOrEmpty())
55+
{
56+
XmlParameterSet.WriteXml(writer, componentConfigurationParametersAsset.ParameterSets);
57+
}
58+
59+
writer.WriteEndElement();
60+
}
61+
}
62+
}
63+
}

0 commit comments

Comments
 (0)