# VirtualPLC

Local Mitsubishi MC protocol PLC simulator for client tests; Python 3.10+, stdlib only.
Install: pip install virtual-plc
Client: pip install pymcprotocol
  from pymcprotocol import Type3E
  c = Type3E(plctype="Q"); c.connect("127.0.0.1", 5000); c.close()
Start here: virtual-plc guide
Quick start: virtual-plc --port 5000; `virtual-plc guide options` lists flags/defaults.
Topics: run options client profiles ethernet embed faults memory troubleshoot divergences
Machine-readable: virtual-plc guide options --json; virtual-plc guide profiles --json; virtual-plc guide ethernet --json
Equivalent entry point: python -m virtual_plc guide

Rules:
- Safety: use localhost; never connect to equipment or production networks. See [README](https://raw.githubusercontent.com/greatgc-flow/VirtualPLC/main/README.md).
- Client plctype and server profile must agree for iQ-R.
- Optional 1E commands 00H/01H/02H/03H, 04H/05H, 13H/14H, 15H/16H; contract, errors and simulator policies: [BEHAVIOR](https://raw.githubusercontent.com/greatgc-flow/VirtualPLC/main/docs/BEHAVIOR.md).
- CPU names have NUL fill by default; --text-pad 0x20 gives space fill.
- Seed direct Memory before start; snapshot after stop; use clients for live writes.
- Ethernet model and research-only references: `virtual-plc guide ethernet --json`.
- Fault schema and after-dispatch behavior: [FAULTS](https://raw.githubusercontent.com/greatgc-flow/VirtualPLC/main/docs/FAULTS.md).
- The pinned client's single recv(4096) limits reads; keep batches under ~1000 words.
- PLC ordering, capacities and control policies remain partly unverified.

Docs:
- [README](https://raw.githubusercontent.com/greatgc-flow/VirtualPLC/main/README.md)
- [Behavior](https://raw.githubusercontent.com/greatgc-flow/VirtualPLC/main/docs/BEHAVIOR.md)
- [Faults](https://raw.githubusercontent.com/greatgc-flow/VirtualPLC/main/docs/FAULTS.md)
- [Design](https://raw.githubusercontent.com/greatgc-flow/VirtualPLC/main/docs/DESIGN.md)
- [Repository workflow](https://raw.githubusercontent.com/greatgc-flow/VirtualPLC/main/AGENTS.md)
