@mokouliszt/mel-device 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.ja.md CHANGED
@@ -97,13 +97,26 @@ analyzeDevice(" u1¥g0 ", {
97
97
  - ワードデバイスのビット指定: `D0.A`
98
98
  - タイマ/カウンタの接点・コイル・現在値: `TS0`, `TC0`, `TN0`, `LCS0` など
99
99
  - ユニットアクセス: `U1\G0`
100
- - CPUバッファメモリアクセス: `U3E0\G0`
100
+ - CPUバッファメモリアクセス: `U3E0\G0`, `U3E0\HG0`
101
101
  - リンクダイレクト: `J1\X0`, `J1\W0`
102
102
  - 桁指定: `K4M100`
103
103
  - 間接指定: `@D10`, `@D10.8`
104
104
  - インデックス修飾: `D10Z2.0`, `D10.8Z2`, `D0LZ0`
105
105
  - ローカルデバイス: `#M0`(対応シリーズ/デバイスのみ)
106
106
 
107
+ ### ユニットアクセス/CPUバッファメモリアクセスの範囲
108
+
109
+ 先頭入出力番号、CPU指定、アドレスをそれぞれマニュアル記載の範囲で判定します。バッファメモリ領域 `G` と定周期通信エリア `HG` は上限が別で、`HG` はMX-R/MX-Fのマニュアルには記載がありません。
110
+
111
+ | シリーズ | `Un\G` 先頭入出力番号 | `U3En\G` | `U3En\HG` |
112
+ | --- | --- | --- | --- |
113
+ | iQ-R | `U00`〜`UFF` | `U3E0`〜`U3E3`、アドレス `0`〜`268435455` | `U3E0`〜`U3E3`、アドレス `0`〜`12287` |
114
+ | iQ-F | マニュアルに記載なし(判定しない) | 非対応 | 非対応 |
115
+ | MX-R | `U00`〜`UFF` | `U3E0`、アドレス `0`〜`524287` | マニュアルに記載なし |
116
+ | MX-F | `U01`〜`UFE` | `U3E0`、アドレス `0`〜`16809983` | マニュアルに記載なし |
117
+
118
+ CR800は独自の固定テーブルで判定します(下記参照)。
119
+
107
120
  ## MELFA CR800
108
121
 
109
122
  推奨表記は、親シリーズとコントローラ種別を分ける方法です。
package/README.md CHANGED
@@ -97,13 +97,26 @@ analyzeDevice(" u1¥g0 ", {
97
97
  - Bit specification for word devices: `D0.A`
98
98
  - Timer/counter contacts, coils, and current values: `TS0`, `TC0`, `TN0`, `LCS0`, etc.
99
99
  - Module access: `U1\G0`
100
- - CPU buffer memory access: `U3E0\G0`
100
+ - CPU buffer memory access: `U3E0\G0`, `U3E0\HG0`
101
101
  - Link direct devices: `J1\X0`, `J1\W0`
102
102
  - Digit specification: `K4M100`
103
103
  - Indirect specification: `@D10`, `@D10.8`
104
104
  - Index modification: `D10Z2.0`, `D10.8Z2`, `D0LZ0`
105
105
  - Local devices: `#M0` (supported series/devices only)
106
106
 
107
+ ### Module and CPU buffer access limits
108
+
109
+ The head I/O number, the CPU selector, and the address are all validated against the ranges printed in the manuals. The `G` buffer-memory area and the `HG` cyclic-transmission area have separate limits, and the `HG` area is not listed for MX-R or MX-F at all.
110
+
111
+ | Series | `Un\G` head I/O number | `U3En\G` | `U3En\HG` |
112
+ | --- | --- | --- | --- |
113
+ | iQ-R | `U00`-`UFF` | `U3E0`-`U3E3`, address `0`-`268435455` | `U3E0`-`U3E3`, address `0`-`12287` |
114
+ | iQ-F | not stated in the manual (unchecked) | not supported | not supported |
115
+ | MX-R | `U00`-`UFF` | `U3E0`, address `0`-`524287` | not listed in the manual |
116
+ | MX-F | `U01`-`UFE` | `U3E0`, address `0`-`16809983` | not listed in the manual |
117
+
118
+ CR800 uses its own fixed table; see the section below.
119
+
107
120
  ## MELFA CR800
108
121
 
109
122
  The recommended notation separates the parent series from the controller type.
package/dist/index.cjs CHANGED
@@ -112,6 +112,28 @@ const SOURCES = {
112
112
  CR800: { manual: "BFP-A3477-AB", pages: [489, 490, 491, 618, 619, 654, 655, 656, 657] }
113
113
  };
114
114
 
115
+ // CPU buffer memory access devices (U3En\G, U3En\HG).
116
+ // iQ-R SH-082487-J p.433 lists CPU No.1-4 as 3E0-3E3 and separates the G area
117
+ // (0-268435455) from the HG cyclic-transmission area (max 12288 points, p.408).
118
+ // MX-R SH-082640-D p.377/378 and MX-F SH-082633-E p.442/443 only document the
119
+ // 3E0 CPU function part, and neither manual mentions the HG area at all.
120
+ const CPU_BUFFER_RULES = {
121
+ "iQ-R": { units: [0, 1, 2, 3], G: 268435455, HG: 12287 },
122
+ "MX-R": { units: [0], G: 524287 },
123
+ "MX-F": { units: [0], G: 16809983 }
124
+ };
125
+
126
+ // Unit access devices (Un\G). unitMin/unitMax are the documented head I/O
127
+ // number ranges: iQ-R p.432 and MX-R p.376 give 00H-FFH, MX-F p.441 gives
128
+ // 01H-FEH. The iQ-F manual (p.68) does not state a unit-number range, so the
129
+ // unit number is left unchecked for that series.
130
+ const UNIT_ACCESS_RULES = {
131
+ "iQ-R": { unitMin: 0x00, unitMax: 0xff, address: 268435455 },
132
+ "MX-R": { unitMin: 0x00, unitMax: 0xff, address: 268435455 },
133
+ "MX-F": { unitMin: 0x01, unitMax: 0xfe, address: 268435455 },
134
+ "iQ-F": { unitMin: null, unitMax: null, address: 268435455 }
135
+ };
136
+
115
137
  const CR800_RULES = {
116
138
  "CR800-R": {
117
139
  direct: { X: [0, 0xfff], Y: [0, 0xfff], M: [0, 18431], D: [0, 5119], SM: [0, 4095], SD: [0, 4095] },
@@ -615,12 +637,32 @@ function analyzeDevice(value, options = {}) {
615
637
  return { valid: true, input: value, normalized, series, model, mode, code: "VALID", message: "Valid link-direct device notation; the actual range depends on the configured network.", configurationDependent: true, parsed, source: SOURCES[series] };
616
638
  }
617
639
 
618
- if (parsed.kind === "unit" || parsed.kind === "cpu-buffer") {
619
- const maxAddress = parsed.kind === "cpu-buffer"
620
- ? series === "MX-R" ? 524287 : series === "MX-F" ? 16809983 : 268435455
621
- : 268435455;
622
- if (parsed.address > maxAddress) return invalid(value, series, model, mode, "ADDRESS_OUT_OF_RANGE", `Buffer-memory address must be 0-${maxAddress}.`, { normalized, parsed });
623
- return { valid: true, input: value, normalized, series, model, mode, code: "VALID", message: "Valid access-device notation; existence and actual range depend on the installed unit or CPU buffer.", configurationDependent: true, parsed, source: SOURCES[series] };
640
+ if (parsed.kind === "cpu-buffer") {
641
+ const rule = CPU_BUFFER_RULES[series];
642
+ const maxAddress = rule[parsed.prefix];
643
+ if (maxAddress === undefined) {
644
+ return invalid(value, series, model, mode, "DEVICE_NOT_SUPPORTED", `U3En\\${parsed.prefix} is not listed as a ${series} device in the attached manual.`, { normalized, parsed });
645
+ }
646
+ if (!rule.units.includes(parsed.cpu)) {
647
+ return invalid(value, series, model, mode, "CPU_NUMBER_OUT_OF_RANGE", `U3E${parsed.cpu.toString(16).toUpperCase()} is not a documented CPU selector for ${series}.`, { normalized, parsed });
648
+ }
649
+ if (parsed.address > maxAddress) {
650
+ return invalid(value, series, model, mode, "ADDRESS_OUT_OF_RANGE", `U3En\\${parsed.prefix} address must be 0-${maxAddress}.`, { normalized, parsed });
651
+ }
652
+ return { valid: true, input: value, normalized, series, model, mode, code: "VALID", message: "Valid CPU-buffer access notation; the actual usable range depends on the refresh and multiple-CPU configuration.", configurationDependent: true, parsed, source: SOURCES[series] };
653
+ }
654
+
655
+ if (parsed.kind === "unit") {
656
+ const rule = UNIT_ACCESS_RULES[series];
657
+ if (rule.unitMin !== null && (parsed.unit < rule.unitMin || parsed.unit > rule.unitMax)) {
658
+ return invalid(value, series, model, mode, "UNIT_NUMBER_OUT_OF_RANGE",
659
+ `U${parsed.unit.toString(16).toUpperCase()} is outside the documented ${series} head I/O number range ${rule.unitMin.toString(16).toUpperCase().padStart(2, "0")}H-${rule.unitMax.toString(16).toUpperCase()}H.`,
660
+ { normalized, parsed });
661
+ }
662
+ if (parsed.address > rule.address) {
663
+ return invalid(value, series, model, mode, "ADDRESS_OUT_OF_RANGE", `Buffer-memory address must be 0-${rule.address}.`, { normalized, parsed });
664
+ }
665
+ return { valid: true, input: value, normalized, series, model, mode, code: "VALID", message: "Valid access-device notation; existence and actual range depend on the installed unit.", configurationDependent: true, parsed, source: SOURCES[series] };
624
666
  }
625
667
 
626
668
  if (mode === "syntax") {
@@ -6,10 +6,10 @@
6
6
 
7
7
  | シリーズ | マニュアル | 文書番号・版 | 主な参照ページ |
8
8
  | --- | --- | --- | --- |
9
- | iQ-R | MELSEC iQ-R シーケンサCPUユニットユーザーズマニュアル | SH-082487-J | 65(機種別デフォルト点数)、408(デバイス一覧)、409-410(点数設定・最大使用範囲)、435-436(インデックス修飾) |
10
- | iQ-F | MELSEC iQ-F FX5ユーザーズマニュアル(応用編) | JY997D54301AF | 57(デバイス一覧)、69-70(インデックス)、76(割込みポインタ)、89(機種別使用範囲) |
11
- | MX-R | MELSEC MXコントローラ MX-Rモデルユーザーズマニュアル | SH-082640-D | 350(デバイス一覧・デフォルト点数)、351-352(点数設定・最大使用範囲)、380-381(インデックス修飾) |
12
- | MX-F | MELSEC MXコントローラ MX-Fモデルユーザーズマニュアル | SH-082633-E | 277(性能・デフォルト点数)、416(デバイス一覧)、417-418(点数設定・最大使用範囲) |
9
+ | iQ-R | MELSEC iQ-R シーケンサCPUユニットユーザーズマニュアル | SH-082487-J | 65(機種別デフォルト点数)、408(デバイス一覧)、409-410(点数設定・最大使用範囲)、432-433(ユニット/CPUバッファアクセス指定方法)、435-436(インデックス修飾) |
10
+ | iQ-F | MELSEC iQ-F FX5ユーザーズマニュアル(応用編) | JY997D54301AF | 57(デバイス一覧)、68(ユニットアクセス)、69-70(インデックス)、76(割込みポインタ)、89(機種別使用範囲) |
11
+ | MX-R | MELSEC MXコントローラ MX-Rモデルユーザーズマニュアル | SH-082640-D | 221(性能仕様)、350(デバイス一覧・デフォルト点数)、351-352(点数設定・最大使用範囲)、376-378(ユニット/CPUバッファアクセス指定方法)、380-381(インデックス修飾) |
12
+ | MX-F | MELSEC MXコントローラ MX-Fモデルユーザーズマニュアル | SH-082633-E | 277(性能・デフォルト点数)、416(デバイス一覧)、417-418(点数設定・最大使用範囲)、441-443(ユニット/CPUバッファアクセス指定方法) |
13
13
  | CR800 | CR800シリーズコントローラ 機能と操作の詳細解説 | BFP-A3477-AB | 5-489~5-491(CPUバッファ対応)、6-618~6-619(シーケンサリンク)、6-654(対応デバイス一覧)、6-655~6-657(デバイス割付) |
14
14
 
15
15
  ## 基数
@@ -80,6 +80,25 @@ B=8K、F=2K、SB=2K、V=2K、W=8K、SW=2K、L=8Kは共通です。S/ST/LST/R/ZR/
80
80
 
81
81
  両マニュアルとも、実際の最大値はグローバルラベル使用量で変化すると注記しています。
82
82
 
83
+ ## ユニットアクセス/CPUバッファメモリアクセス
84
+
85
+ 先頭入出力番号(`Un`)、CPU指定(`U3En`)、アドレスの根拠は下記のとおりです。
86
+
87
+ | シリーズ | `Un` の範囲 | `Un¥G` アドレス | `U3En` の範囲 | `U3En¥G` アドレス | `U3En¥HG` アドレス | 参照 |
88
+ | --- | --- | ---: | --- | ---: | ---: | --- |
89
+ | iQ-R | 00H~FFH | 0-268435455 | 3E0~3E3 | 0-268435455 | 0-12287 | 本文432・433ページ、408ページ |
90
+ | iQ-F | 記載なし | 0-268435455 | 非対応 | - | - | 本文68ページ、57ページ注記 |
91
+ | MX-R | 00H~FFH | 0-268435455 | 3E0のみ | 0-524287 | 記載なし | 本文376・377・378ページ、221ページ |
92
+ | MX-F | 01H~FEH | 0-268435455 | 3E0のみ | 0-16809983 | 記載なし | 本文441・442・443ページ、277ページ |
93
+
94
+ iQ-R本文433ページの表は`U3En`のnを1号機=3E0、2号機=3E1、3号機=3E2、4号機=3E3と明記し、CPUバッファメモリ(`G`)と定周期通信エリア(`HG`)を別領域として区別しています。`G`は408ページで最大268435456点(変更不可)、`HG`は同ページで最大12288点です。
95
+
96
+ MX-R本文377ページ、MX-F本文442ページのバッファメモリ指定例では、CPU機能部の先頭入出力番号として3E0のみが示されます。MX-F本文443ページは「U3E0¥Gnで指定します」と明記しています。また両マニュアルとも`HG`表記は一度も現れず、MX-Rは本文221ページ、MX-Fは本文277ページの性能仕様でCPUバッファメモリアクセスデバイス点数を`U3E¥G`としてのみ規定しています。このため本パッケージは、MX-R/MX-Fの`U3E1`以降と`HG`表記を無効として扱います。
97
+
98
+ iQ-F本文68ページはユニット番号の範囲を明示していないため、`Un`のnは判定しません(`U¥G`自体がFX5S非対応である点のみ判定します)。
99
+
100
+ MX-F本文441ページのユニットアクセスデバイスは`Gn`を0~4294967295としていますが、同277ページの性能仕様は最大268435456点としています。本パッケージは厳しいほうの性能仕様値を採用しています。
101
+
83
102
  ## 修飾表記
84
103
 
85
104
  iQ-R本文436ページ、MX-R本文381ページ、MX-Fの同等節では、次の例が明示されています。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mokouliszt/mel-device",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Model-aware Mitsubishi MELSEC and MELFA device notation validator.",
5
5
  "license": "MIT",
6
6
  "author": "mokouliszt",