diff --git a/Modbus Map Clean.pdf b/Modbus Map Clean.pdf index 0c7640f..baef09c 100644 Binary files a/Modbus Map Clean.pdf and b/Modbus Map Clean.pdf differ diff --git a/Modbus Map.xlsx b/Modbus Map.xlsx index 050a131..d591b10 100644 Binary files a/Modbus Map.xlsx and b/Modbus Map.xlsx differ diff --git a/db_coils.csv b/db_coils.csv new file mode 100644 index 0000000..e69de29 diff --git a/db_discrete_inputs.csv b/db_discrete_inputs.csv new file mode 100644 index 0000000..e69de29 diff --git a/db_holding_registers.csv b/db_holding_registers.csv new file mode 100644 index 0000000..e69de29 diff --git a/db_input_registers.csv b/db_input_registers.csv new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yml b/docker-compose.yml index abc91c4..3b0f10d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,19 +1,23 @@ version : '2' services: mongodb: - image: docker.henrypump.cloud/poc_modbus/mongodb + # image: docker.henrypump.cloud/poc_modbus/mongodb + image: 860246592755.dkr.ecr.us-east-1.amazonaws.com/mongodb ports: - "27017:27017" restart: on-failure scraper: - image: docker.henrypump.cloud/poc_modbus/scraper + # image: docker.henrypump.cloud/poc_modbus/scraper + image: 860246592755.dkr.ecr.us-east-1.amazonaws.com/poc-modbus/poc-scraper depends_on: - modbus_server restart: on-failure environment: - - PLC_IP_ADDRESS=192.168.1.10 + # - PLC_IP_ADDRESS=192.168.1.10 + - PLC_IP_ADDRESS=1609.denise.henryres.cloudcnx.net modbus_server: - image: docker.henrypump.cloud/poc_modbus/modbus_server + # image: docker.henrypump.cloud/poc_modbus/modbus_server + image: 860246592755.dkr.ecr.us-east-1.amazonaws.com/poc-modbus/poc-modbus-server depends_on: - mongodb links: diff --git a/getAllValues.py b/getAllValues.py index 2a86c38..ad91e5f 100644 --- a/getAllValues.py +++ b/getAllValues.py @@ -23,7 +23,7 @@ log.setLevel(logging.INFO) # ---------------------------------------------------------------------------# # Modbus Client Setup # ---------------------------------------------------------------------------# -modbus_client = ModbusClient('localhost', port=502) +modbus_client = ModbusClient('modbus.theta.poconsole.net', port=502) # ---------------------------------------------------------------------------# # Mongo DB Setup diff --git a/resources/preparemongo b/resources/preparemongo new file mode 100755 index 0000000..332dd7d --- /dev/null +++ b/resources/preparemongo @@ -0,0 +1,22 @@ +#! /bin/bash + +if [[ $(uname -m) == "x86_64" ]] +then + wget --backups=0 "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-3.2.7.tgz" + tar -zxf ./mongodb-linux-x86_64-ubuntu1604-3.2.7.tgz --strip-components=1 +else + IFS=" " read -a links <<< $(apt-get -y --print-uris install mongodb | egrep -o "https?://[^']+") + for link in ${links[@]} + do + wget --backups=0 ${link} + done + + IFS=" " read -a deb_pkgs <<< $(ls ./ | egrep "\.deb") + for pkg in ${deb_pkgs[@]} + do + echo "Extracting ${pkg}..." + dpkg-deb -R ${pkg} ./ + done + + mv usr/bin bin +fi diff --git a/resources/preparescraper b/resources/preparescraper new file mode 100644 index 0000000..f62f966 --- /dev/null +++ b/resources/preparescraper @@ -0,0 +1,5 @@ +#!/bin/bash + +pip install requests pymongo pymodbus cryptography pyasn1 +pip install git+https://github.com/Henry-Pump/Pycomm-Helper.git +pip install git+https://github.com/ruscito/pycomm.git diff --git a/resources/startmongo b/resources/startmongo new file mode 100755 index 0000000..8dc61c4 --- /dev/null +++ b/resources/startmongo @@ -0,0 +1,2 @@ +env LC_ALL=C mongod --bind_ip 127.0.0.1 --pidfilepath $SNAP_COMMON/mongod.pid --smallfiles --journal --dbpath=$SNAP_COMMON --replSet rs0 + diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 0000000..c12aaea --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,48 @@ +name: poc-modbus +version: '0.1' +summary: Modbus TCP Server for Henry POC +description: Serves POC data from the Henry POC over Modbus TCP +assumes: [snapd2.21] +grade: devel +confinement: devmode + +apps: + poc-mongo: + command: startmongo + daemon: simple + plugs: [network, network-bind] + mongo: + command: env LC_ALL=C mongo + plugs: [network] + poc-scraper: + command: pocscraper + daemon: simple + plugs: [network, network-bind] + +parts: + mongodb: + build-packages: + - wget + source: ./ + prepare: ./resources/preparemongo + plugin: dump + stage-packages: + - libssl1.0.0 + prime: + - usr + - bin + - lib + poc-scraper: + source: ./ + prepare: ./resources/preparescraper + plugin: python + python-version: python2 + source: poc_scraper/poc_scraper + scripts: + plugin: dump + source: resources/ + organize: + startmongo: bin/startmongo + startscraper: bin/startscraper + prime: + - bin diff --git a/test.py b/test.py index 2c1a325..98b2a8b 100644 --- a/test.py +++ b/test.py @@ -23,7 +23,7 @@ log.setLevel(logging.INFO) # ---------------------------------------------------------------------------# # Modbus Client Setup # ---------------------------------------------------------------------------# -modbus_client = ModbusClient('localhost', port=502) +modbus_client = ModbusClient('modbus.theta.poconsole.net', port=502) # ---------------------------------------------------------------------------# # Mongo DB Setup