Skip to content

Commit

Permalink
Finished the sensorsPLCSimu_readme.md file.
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuYuancheng committed Jul 26, 2023
1 parent eb30448 commit 4e1c87d
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 8 deletions.
12 changes: 6 additions & 6 deletions doc/metroEmuUI_readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ The program user interface design detail is shown below:



##### Program module files List
##### Program module files list

| Idx | Program File | Execution Env | Description |
| ---- | -------------------------------- | ------------- | ------------------------------------------------------------ |
Expand All @@ -67,12 +67,12 @@ The program user interface design detail is shown below:
| 3 | configFiles/TrainLocation/*.json | | All the preset scenario config file. |
| 4 | img/*.png, *.jpg, *.icon | | All the UI picture materials file. |
| 5 | MetroEmuRun.py | python 3 | Main UI application program. |
| 6 | metroEmuGobal.py | python 3 | System needs global file, the system config file's contents will be saved in the global paramters. |
| 6 | metroEmuGobal.py | python 3 | System needs global file, the system config file's contents will be saved in the global parameters. |
| 7 | railwayAgent.py | python 3 | Components agents module to initialize all the different items shown on the map. |
| 8 | railwayMgr.py | python3 | UI data controller, System auto controller |
| 9 | railwayPanel.py | python3 | All the control panels |
| 10 | railwayPanelMap.py | python3 | Real-world display panel |
| 11 | dataMgr.py | python3 | PLC data controller |
| 8 | railwayMgr.py | python 3 | UI data controller, System auto controller |
| 9 | railwayPanel.py | python 3 | All the control panels |
| 10 | railwayPanelMap.py | python 3 | Real-world display panel |
| 11 | dataMgr.py | python 3 | PLC data controller |
| | | | |

Libraries required code base: https://github.com/LiuYuancheng/Metro_emulator/tree/main/src/lib
Expand Down
111 changes: 111 additions & 0 deletions doc/sensorsPLCSimu_readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,114 @@ You can also check the excel file `ladderConnectionMap.xlsx` to see the mapping



##### Program module files list

| Idx | Program File | Execution Env | Description |
| ---- | ---------------------------------- | ------------- | ------------------------------------------------------------ |
| 1 | signalPlcEmu/plcConfig.txt | | System config file. |
| 2 | signalPlcEmu/plcSimGlobalSignal.py | python 3 | System needs global file, the system config file's contents will be saved in the global parameters. |
| 3 | signalPlcEmu/plcSimulatorSignal.py | python 3 | Main PLC simulation program. |
| | | | |

Libraries required code base: https://github.com/LiuYuancheng/Metro_emulator/tree/main/src/lib



------

### Program Setup

###### Development Environment : python 3.7.4

###### Additional Lib/Software Need

1. **pyModbusTCP** : https://github.com/sourceperl/pyModbusTCP

```
pip install pyModbusTCP
```

###### Hardware Needed : None

###### Execution environment

```
OS : ubuntu 20.04 server
Display mode:
- Display output: No
VM Deploy Config:
- NIC number: 2
- SSH: enable
- NIC 1: IP address: 10.0.10.11, gateway: 10.0.10.1
- NIC 2: IP address: 192.168.100.11, gateway: 192.168.100.1
```



------

### Program Usage



##### Edit Configuration File

Open config file `plcConfig.txt`

```
# This is the config file template for the module <monitorApp.py>
# Setup the paramter with below format (every line follow <key>:<val> format, the
# key can not be changed):
# Set the master PLC's name
PLC_NAME:PLC-01
# Define the ip addresses allowed to read PLC state:
# json list fomat: ["masterIP", "slave1IP", ...]
ALLOW_R_L:["127.0.0.1", "192.168.0.10"]
# Define the ip addresses allowed to change PLC state:
# json list fomat: ["masterIP", "slave1IP", ...]
ALLOW_W_L:["127.0.0.1"]
# Define Realworld emulator ip
RW_IP:127.0.0.1
# Define Realworld emulator connection port
RW_PORT:3001
# Define PLC clock interval
CLK_INT:0.6
# Define modbus TCP host IP, use 0.0.0.0 or localhost
MD_BUS_IP:localhost
# Define modbus TCP host Port, normally use 502
MD_BUS_PORT:502
```



##### Program Execution

After follow the instruction in the file `metroConfig.txt` to setup all the parameters, you can run the program:

```
python plcSimulatorSignal.py
```

or double click the file `runSignalPlcCtrlEmu_win.bat`



------

#### Problem and Solution

Refer to `doc/ProblemAndSolution.md`



------

> last edit by LiuYuancheng ([email protected]) by 26/07/2023 if you have any problem, please send me a message.
4 changes: 2 additions & 2 deletions src/plcCtrl/signalPlcEmu/plcSimulatorSignal.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def initCoilState(self):
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
def main():
#gv.gDebugPrint("Start Init the PLC: %s" %str(gv.PLC_NAME), logType=gv.LOG_INFO)
#gv.gDebugPrint("Start Init the PLC: %s" %str(gv.PLC_NAME), logType=gv.LOG_INFO)``
gv.iLadderLogic = tFlipFlopLadderLogic(None, ladderName='T_flipflop_logic_set')
addressInfoDict = {
'hostaddress': gv.gModBusIP,
Expand All @@ -159,4 +159,4 @@ def main():
plc.run()

if __name__ == "__main__":
main()
main()
21 changes: 21 additions & 0 deletions src/plcCtrl/signalPlcEmu/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Railway Sensor-Signal System Control PLC Simulator

### Introduction

**Please refer to the Railway Sensor-Signal System Control PLC Simulator Readme file in the document fold with the below section: **

- Introduction
- Program design
- Program Setup steps
- Execute the program
- Problem and solution

**Click below link to jump to the readme file:**

[ Railway Sensor-Signal System Control PLC Simulator Readme file ](../../doc/sensorsPLCSimu_readme.md)



------

> last edit by LiuYuancheng ([email protected]) by 25/07/2023 if you have any problem, please send me a message.

0 comments on commit 4e1c87d

Please sign in to comment.