Dreamine.PLC.Omron.CxComponent 1.0.1
Dreamine.PLC.Omron.CxComponent 산업 자동화 및 I/O 기능을 제공합니다.
로딩중...
검색중...
일치하는것 없음
OmronCxAddressNameFormatter.cs
이 파일의 문서화 페이지로 가기
1using System.Globalization;
2using Dreamine.PLC.Abstractions.Devices;
3
5
14public static class OmronCxAddressNameFormatter
15{
48 public static string Format(PlcAddress address)
49 {
50 var prefix = address.DeviceType switch
51 {
52 PlcDeviceType.D => "D",
53 PlcDeviceType.M => "W",
54 PlcDeviceType.X => "CIO",
55 PlcDeviceType.Y => "CIO",
56 PlcDeviceType.W => "W",
57 PlcDeviceType.R => "H",
58 _ => throw new NotSupportedException($"Unsupported CX-Compolet device type: {address.DeviceType}")
59 };
60
61 var offset = address.Offset.ToString(CultureInfo.InvariantCulture);
62 return address.BitOffset.HasValue
63 ? $"{prefix}{offset}.{address.BitOffset.Value}"
64 : $"{prefix}{offset}";
65 }
66
107 public static string FormatOffset(PlcAddress address, int delta)
108 {
109 return Format(address with { Offset = address.Offset + delta });
110 }
111}