Panasonic MEWTOCOL 드라이버
개요
Panasonic FP 시리즈 (FP0R / FP-X / FPΣ / FP7) 의 ASCII 통신 프로토콜 MEWTOCOL-COM. Panasonic 공개 사용자 매뉴얼 (ARCT1F320, ARCT1F313 등) 의 프레임 / 명령 / 디바이스 코드 / BCC 알고리즘만으로 직접 구현. 외부 GitHub 코드 차용 없음.
| 항목 | 값 |
|---|---|
opc_type | MEWTOCOL |
| 구현 클래스 | plantpulse.driver.protocol.mewtocol.MEWTOCOLDriver |
| 라이브러리 | (없음 — 자체 구현. ARCT1F320) |
| read | 양호 (RD / RC) |
| write | 양호 (WD / WC) |
| 디폴트 포트 | 9094 (FP-X / FP7 TCP) |
| 보안 | 없음 |
클래스 / 구조
MEWTOCOLDriver (BaseProtocolDriver)
├── Socket / InputStream / OutputStream
├── station — "01" 디폴트, 옵션 station 으로 변경
├── ioLock — synchronized exchange()
├── ParsedAddress.parse() — 디바이스/wordIndex/bitIndex 분해
├── computeBcc(byte[]) — '%' ~ ETX 위치 직전 XOR → 2자리 hex
└── decodeRdResponseHex / encodeWords — 16/32/64-bit
wire 포맷 요약
요청 : '%' <station 2> '#' <cmd 2> <data> <BCC 2hex> CR
응답 : '%' <station 2> '$' <cmd 2> <data> <BCC 2hex> CR (정상)
'%' <station 2> '!' <에러 2hex> <BCC 2hex> CR (에러)
BCC : '%' 부터 BCC 직전 (= ETX 위치) 까지 XOR
CR : 0x0D (LF 는 무시)
지원 명령
| cmd | 동작 | 형식 (data 부) |
|---|---|---|
RD | 워드 read (DT/LD/FL/WX/WY/WR) | <dev1자><start5자리><end5자리> |
RC | 비트 read (단일, X/Y/R/L/T/C) | RCS<dev1자><wordAddr4><bit1자hex> |
WD | 워드 write | <dev><start5><end5><word1 hex 4>... |
WC | 비트 write (단일) | WCS<dev><wordAddr4><bit1><val1> |
워드 hex 는 매뉴얼 규정대로 LSB byte 가 먼저 (예: 0x1234 워드 → 응답 hex 3412).
OPC 등록 옵션 (options)
| 키 | 의미 | 디폴트 |
|---|---|---|
station | 스테이션 번호 (2-자리) | 01 |
connect-timeout | ms | 3000 |
read-timeout | ms | 3000 |
normalizeStation() 이 1자리 입력 ("1") 을 "01" 로 자동 보정.
태그 주소 형식
| 표기 | 의미 |
|---|---|
DT0 | Data Register 0 (16-bit) |
LD100 | Link Data 100 |
FL10 | File Register 10 |
WX0 / WY0 / WR0 | I/O / Internal word |
R0.5 | Internal Relay word 0 의 bit 5 |
R0005 | 4자 = 워드3+비트1 (= R0.5) |
X0.0 / Y0.5 | Input/Output bit |
T0 / C0 | Timer / Counter (단일 비트로 취급) |
데이터 인코딩 / 디코딩
wordCountFor(dt, fmt) 가 16/32/64-bit 결정 (1/2/4 워드).
decodeWords(words, dt, fmt) 가 멀티-워드 → 값 변환:
| format / data_type | 워드 수 | 변환 |
|---|---|---|
DW / Int32 | 2 | (words[1]<<16) | words[0] (low word first), signed |
UDW / UInt32 | 2 | unsigned 32 |
REAL / Float | 2 | Float.intBitsToFloat(...) |
LREAL / Double | 4 | Double.longBitsToDouble(...) |
LW / Int64 | 4 | signed 64 |
| (디폴트) | 1 | signed 16 |
에러 코드 매핑
decodeError(code) 가 매뉴얼의 대표 에러를 한글로 변환 (일부):
| code | 설명 |
|---|---|
20 | Relay/register 번호 오류 |
21 | Memory 영역 초과 |
22 | Latch 에러 |
40 | BCC 오류 (수신측) |
41 | Format 오류 |
42 | Not supported 명령 |
60 | Parameter 오류 |
66 | Address 오류 |
지원 / 미지원
- ✅ RD / WD (워드 N개 연속)
- ✅ RC / WC (비트 단일)
- ✅ 32 / 64-bit 멀티-워드, Float, Double
- ❌ RC 다중 (RCP — Preset multi)
- ❌ RT / WT (Timer / Counter EV/SV 분리 read)
- ❌ MEWTOCOL-7 / MEWTOCOL-DAT 확장
테스트 커버리지
test/java/plantpulse/driver/protocol/mewtocol/
| 클래스 | 테스트 수 |
|---|---|
MEWTOCOLDriverTest | 39 |
총 39 테스트 — BCC, 프레임 빌더, 주소 파서, RD 응답 디코드, WC bit, 에러 매핑.
참고
- Panasonic ARCT1F320 FP-X User Manual MEWTOCOL-COM
- Panasonic ARCT1F313 FP Series Programming Manual
- 코드:
src/plantpulse/driver/protocol/mewtocol/MEWTOCOLDriver.java