본문으로 건너뛰기

Panasonic MEWTOCOL 드라이버

개요

Panasonic FP 시리즈 (FP0R / FP-X / FPΣ / FP7) 의 ASCII 통신 프로토콜 MEWTOCOL-COM. Panasonic 공개 사용자 매뉴얼 (ARCT1F320, ARCT1F313 등) 의 프레임 / 명령 / 디바이스 코드 / BCC 알고리즘만으로 직접 구현. 외부 GitHub 코드 차용 없음.

항목
opc_typeMEWTOCOL
구현 클래스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-timeoutms3000
read-timeoutms3000

normalizeStation() 이 1자리 입력 ("1") 을 "01" 로 자동 보정.


태그 주소 형식

표기의미
DT0Data Register 0 (16-bit)
LD100Link Data 100
FL10File Register 10
WX0 / WY0 / WR0I/O / Internal word
R0.5Internal Relay word 0 의 bit 5
R00054자 = 워드3+비트1 (= R0.5)
X0.0 / Y0.5Input/Output bit
T0 / C0Timer / Counter (단일 비트로 취급)

데이터 인코딩 / 디코딩

wordCountFor(dt, fmt) 가 16/32/64-bit 결정 (1/2/4 워드). decodeWords(words, dt, fmt) 가 멀티-워드 → 값 변환:

format / data_type워드 수변환
DW / Int322(words[1]<<16) | words[0] (low word first), signed
UDW / UInt322unsigned 32
REAL / Float2Float.intBitsToFloat(...)
LREAL / Double4Double.longBitsToDouble(...)
LW / Int644signed 64
(디폴트)1signed 16

에러 코드 매핑

decodeError(code) 가 매뉴얼의 대표 에러를 한글로 변환 (일부):

code설명
20Relay/register 번호 오류
21Memory 영역 초과
22Latch 에러
40BCC 오류 (수신측)
41Format 오류
42Not supported 명령
60Parameter 오류
66Address 오류

지원 / 미지원

  • ✅ 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/

클래스테스트 수
MEWTOCOLDriverTest39

총 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