Dreamine.PLC.Mitsubishi.MxComponent 1.0.1
Dreamine.PLC.Mitsubishi.MxComponent 산업 자동화 및 I/O 기능을 제공합니다.
로딩중...
검색중...
일치하는것 없음
MitsubishiMxDeviceNameFormatter.cs
이 파일의 문서화 페이지로 가기
1using System.Globalization;
2using Dreamine.PLC.Abstractions.Devices;
3
5
15{
48 public static string Format(PlcAddress address)
49 {
50 var prefix = address.DeviceType switch
51 {
52 PlcDeviceType.D => "D",
53 PlcDeviceType.M => "M",
54 PlcDeviceType.X => "X",
55 PlcDeviceType.Y => "Y",
56 PlcDeviceType.B => "B",
57 PlcDeviceType.W => "W",
58 PlcDeviceType.R => "R",
59 PlcDeviceType.ZR => "ZR",
60 _ => throw new NotSupportedException($"Unsupported MX Component device type: {address.DeviceType}")
61 };
62
63 var offset = address.DeviceType is PlcDeviceType.X or PlcDeviceType.Y or PlcDeviceType.B or PlcDeviceType.W
64 ? address.Offset.ToString("X", CultureInfo.InvariantCulture)
65 : address.Offset.ToString(CultureInfo.InvariantCulture);
66
67 return address.BitOffset.HasValue
68 ? $"{prefix}{offset}.{address.BitOffset.Value}"
69 : $"{prefix}{offset}";
70 }
71
112 public static string FormatOffset(PlcAddress address, int delta)
113 {
114 return Format(address with { Offset = address.Offset + delta });
115 }
116}