본문으로 건너뛰기

FATEK FBs 드라이버

개요

FATEK FACON FBs 시리즈 PLC 의 ASCII 통신. FBs Series Communication Protocol Manual 의 공개 스펙 기반 자체 구현. 외부 라이브러리 / 깃허브 코드 의존성 없음.

항목
opc_typeFATEK
구현 클래스plantpulse.driver.protocol.fatek.FatekDriver
라이브러리(없음 — 자체 구현. FATEK FBs 매뉴얼)
read양호 (cmd 44 / 46)
write양호 (cmd 45 / 47)
디폴트 포트500
보안없음

클래스 / 구조

FatekDriver (BaseProtocolDriver)
├── Socket / InputStream / OutputStream
├── station — 0~255 (디폴트 1)
├── synchronized read/write
├── Addr (device, index, bit)
├── parseAddress(raw) — R/D/M/X/Y/T/C/WX/WY/WM
├── formatBitItem / formatWordItem
└── sendAndReceive(cmd, body) — STX/ETX/LRC 검증

connect() 직후 cmd 41 (status) 를 헬로로 호출하지만 실패해도 연결은 유지 (PLC 가 미지원일 수 있음).


wire 포맷 요약

Request : STX <station 2hex> <cmd 2hex> <data ASCII> <LRC 2hex> ETX
Response: STX <station 2hex> <cmd 2hex> <error 1자> <data> <LRC 2hex> ETX
STX = 0x02, ETX = 0x03
LRC : STX 다음부터 LRC 직전까지 XOR (ASCII char 단위) → 2자리 hex 대문자

주요 명령

cmd동작
40Read system status
41Get PLC run/stop/error/break status (헬로용)
42Run/Stop PLC
44Read data from registers (연속 워드)
45Write data to registers (연속 워드)
46Read individual data (단일 비트 / 혼재)
47Write individual data

sendAndReceive() 에서 응답 error code 가 '0' 이 아니면 IOException (예: '2' illegal value, '4' illegal command, '5' checksum, '6' illegal address, 'A' PLC password locked).


OPC 등록 옵션 (options)

의미디폴트
stationPLC station ID (0~255)1
connect-timeoutms3000
read-timeoutms3000

태그 주소 형식

표기의미bit/word
R0 / R100General registerword
D100Data registerword
WX10 / WY0 / WM10Input/Output/Internal wordword
M100Internal relaybit
X0 / Y0 / S0Input / Output / Stepbit
T0 / C0Timer / Counter 현재값word (cmd 44 의 RT/RC 표기)

formatWordItem() :

  • R/D → <dev>+5자 index (총 6자)
  • WX/WY/WM → <dev>+4자 (총 6자)
  • T → RT + 4자, C → RC + 4자

데이터 인코딩 / 디코딩

wordCountFor(dt, fmt) 가 1/2/4 워드 결정. decodeWords() 가 변환 — FATEK FB 멀티-워드는 little-endian word order (low word 가 먼저).

format / data_type워드 수비고
W / WORD / UI / UW1signed/unsigned 16
B / BYTE1(16-bit 응답 그대로)
DW / DWORD / Int322signed 32
UDW / UInt322unsigned 32
REAL / FLOAT / Float2IEEE 32-bit
LREAL / DOUBLE / Double4IEEE 64-bit
LW / LWORD / Int644signed 64

지원 / 미지원

  • ✅ cmd 44 / 45 (워드 N개 연속 read/write)
  • ✅ cmd 46 / 47 (단일 비트 read/write)
  • ✅ STX/ETX/LRC 프레임 검증 + station/cmd echo 검증
  • ✅ 32 / 64-bit 멀티-워드, Float, Double
  • ❌ 다수 비트 동시 read/write (cmd 46/47 의 mixed 항목)
  • ❌ Run/Stop PLC (cmd 42)
  • ❌ Timer/Counter contact bit 분리 (현재 word 만)

테스트 커버리지

test/java/plantpulse/driver/protocol/fatek/

클래스테스트 수
FatekDriverTest48

총 48 테스트 — LRC, buildRequest, 주소 파서, 워드 인/디코드, error code.


참고

  • FATEK FBs Series Communication Protocol Manual (벤더 공개)
  • 코드: src/plantpulse/driver/protocol/fatek/FatekDriver.java