Moves modbus functions to M1 driver
This commit is contained in:
@@ -159,28 +159,28 @@
|
||||
<div class="gauge-box">
|
||||
<div data-labelheight="10"
|
||||
style="height: 170px; background: transparent; margin: 0 auto;"
|
||||
id="gauge-t_amb"
|
||||
id="gauge-t_amb_f"
|
||||
data-chart="solidgauge"
|
||||
data-nodename="prostarsolar.t_amb"
|
||||
data-units="deg C"
|
||||
data-min="0"
|
||||
data-max="50"
|
||||
data-nodename="prostarsolar.t_amb_f"
|
||||
data-units="deg F"
|
||||
data-min="-25"
|
||||
data-max="125"
|
||||
data-decimalplaces="2"
|
||||
data-colors="0.1:#DF5353,0.5:#DDDF0D,0.9:#55BF3B"
|
||||
data-valuefontsize="18px">
|
||||
</div>
|
||||
<div class- "timestamp-box">
|
||||
<a href="#" data-channelId="<%= channels['prostarsolar.t_amb'].channelId %>" class="data-table" title="Download Channel History">
|
||||
<a href="#" data-channelId="<%= channels['prostarsolar.t_amb_f'].channelId %>" class="data-table" title="Download Channel History">
|
||||
<i class="fa fa-download"></i>
|
||||
</a>
|
||||
</div>
|
||||
<span data-timeupdate="t_amb">
|
||||
<%= channels["prostarsolar.t_amb"].timestamp %>
|
||||
<span data-timeupdate="t_amb_f">
|
||||
<%= channels["prostarsolar.t_amb_f"].timestamp %>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class='col-xs-8'>
|
||||
<div style="height:300px" id="chart-t_amb" data-chart="chart" data-nodename1="prostarsolar.t_amb" data-datalabel1="Ambient Temp" data-daysofhistory="2" data-chartlabel="Ambient Temp" data-ylabel="" data-xlabel="Date" data-units=" deg C"></div>
|
||||
<div style="height:300px" id="chart-t_amb_f" data-chart="chart" data-nodename1="prostarsolar.t_amb_f" data-datalabel1="Ambient Temp" data-daysofhistory="2" data-chartlabel="Ambient Temp" data-ylabel="" data-xlabel="Date" data-units=" deg F"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
"file3": "persistence.py",
|
||||
"file2": "utilities.py",
|
||||
"file1": "prostarsolar.py",
|
||||
"file5": "Maps.py",
|
||||
"file4": "Channel.py"
|
||||
"file4": "modbusMap.p"
|
||||
},
|
||||
"deviceName": "prostarsolar",
|
||||
"driverId": "0170",
|
||||
"releaseVersion": "1",
|
||||
"releaseVersion": "2",
|
||||
"driverFileName": "prostarsolar.py"
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "prostarsolar",
|
||||
"driverFilename": "prostarsolar.py",
|
||||
"driverId": "0000",
|
||||
"name": "prostarsolar",
|
||||
"driverFilename": "prostarsolar.py",
|
||||
"driverId": "0000",
|
||||
"additionalDriverFiles": [
|
||||
"utilities.py",
|
||||
"persistence.py",
|
||||
"Channel.py"
|
||||
],
|
||||
"version": 1,
|
||||
"persistence.py",
|
||||
"modbusMap.p"
|
||||
],
|
||||
"version": 2,
|
||||
"s3BucketName": "prostarsolar"
|
||||
}
|
||||
}
|
||||
1414
python-driver/modbusMap.p
Normal file
1414
python-driver/modbusMap.p
Normal file
File diff suppressed because it is too large
Load Diff
@@ -4,13 +4,8 @@ import threading
|
||||
from device_base import deviceBase
|
||||
import persistence
|
||||
from utilities import get_public_ip_address
|
||||
import prostarsolar_utils
|
||||
import time
|
||||
import minimalmodbus
|
||||
import minimalmodbusM1
|
||||
|
||||
minimalmodbusM1.CLOSE_PORT_AFTER_EACH_CALL = True
|
||||
minimalmodbusM1.STOPBITS = 2
|
||||
|
||||
_ = None
|
||||
|
||||
@@ -18,7 +13,6 @@ _ = None
|
||||
# GLOBAL VARIABLES
|
||||
WATCHDOG_SEND_PERIOD = 3600 # Seconds, the longest amount of time before sending the watchdog status
|
||||
PLC_IP_ADDRESS = "192.168.1.10"
|
||||
CHANNELS = prostarsolar_utils.CHANNELS # Load the channels from the utils program
|
||||
|
||||
# PERSISTENCE FILE
|
||||
persist = persistence.load()
|
||||
@@ -58,8 +52,6 @@ class start(threading.Thread, deviceBase):
|
||||
public_ip_address = get_public_ip_address()
|
||||
self.sendtodbDev(1, 'public_ip_address', public_ip_address, 0, 'prostarsolar')
|
||||
|
||||
instrument_485 = self.connect_to_485(prostarsolar_utils.BAUDRATE, prostarsolar_utils.NODEADDRESS)
|
||||
|
||||
send_loops = 0
|
||||
watchdog_loops = 0
|
||||
watchdog_check_after = 5000
|
||||
@@ -67,19 +59,6 @@ class start(threading.Thread, deviceBase):
|
||||
if self.forceSend:
|
||||
print "FORCE SEND: TRUE"
|
||||
|
||||
for chan in CHANNELS:
|
||||
try:
|
||||
val = chan.read(instrument_485.read_registers(chan.register_number, chan.channel_size, functioncode=4))
|
||||
if chan.check(val, self.forceSend):
|
||||
self.sendtodbDev(1, chan.mesh_name, chan.value, 0, 'prostarsolar')
|
||||
time.sleep(0.1)
|
||||
except IOError as e:
|
||||
print("prostarsolar IO Error: {}".format(e))
|
||||
print("Attempting to reconnect to rs485 device")
|
||||
instrument_485 = self.connect_to_485(prostarsolar_utils.BAUDRATE, prostarsolar_utils.NODEADDRESS)
|
||||
except Exception as e:
|
||||
print("prostarsolar Non-IO Error: {}".format(e))
|
||||
|
||||
print("prostarsolar driver still alive...")
|
||||
if self.forceSend:
|
||||
if send_loops > 2:
|
||||
@@ -98,17 +77,6 @@ class start(threading.Thread, deviceBase):
|
||||
watchdog_loops = 0
|
||||
time.sleep(10)
|
||||
|
||||
def connect_to_485(self, baudrate, nodeaddress):
|
||||
"""Connect to the RS485 device."""
|
||||
connected_to_485 = False
|
||||
while connected_to_485 is False:
|
||||
connected_to_485 = self.mcu.set485Baud(baudrate)
|
||||
|
||||
serial_485 = self.mcu.rs485
|
||||
instrument_485 = minimalmodbusM1.Instrument(nodeaddress, serial_485)
|
||||
instrument_485.address = nodeaddress
|
||||
return instrument_485
|
||||
|
||||
def prostarsolar_sync(self, name, value):
|
||||
"""Sync all data from the driver."""
|
||||
self.forceSend = True
|
||||
|
||||
Reference in New Issue
Block a user