Updates to use common channel objects, adds flow totals today and yesterday, public IP

This commit is contained in:
Patrick McDonagh
2018-03-01 14:51:13 -06:00
parent 8d3ecb3d7c
commit 134ce5f01f
17 changed files with 731 additions and 11625 deletions

287
POCloud_Driver/Channel.py Normal file
View File

@@ -0,0 +1,287 @@
"""Define Meshify channel class."""
from pycomm.ab_comm.clx import Driver as ClxDriver
from pycomm.cip.cip_base import CommError, DataError
import time
def binarray(intval):
"""Split an integer into its bits."""
bin_string = '{0:08b}'.format(intval)
bin_arr = [i for i in bin_string]
bin_arr.reverse()
return bin_arr
def read_tag(addr, tag, plc_type="CLX"):
"""Read a tag from the PLC."""
direct = plc_type == "Micro800"
c = ClxDriver()
try:
if c.open(addr, direct_connection=direct):
try:
v = c.read_tag(tag)
return v
except DataError as e:
c.close()
print("Data Error during readTag({}, {}): {}".format(addr, tag, e))
except CommError:
# err = c.get_status()
c.close()
print("Could not connect during readTag({}, {})".format(addr, tag))
# print err
except AttributeError as e:
c.close()
print("AttributeError during readTag({}, {}): \n{}".format(addr, tag, e))
c.close()
return False
def read_array(addr, tag, start, end, plc_type="CLX"):
"""Read an array from the PLC."""
direct = plc_type == "Micro800"
c = ClxDriver()
if c.open(addr, direct_connection=direct):
arr_vals = []
try:
for i in range(start, end):
tag_w_index = tag + "[{}]".format(i)
v = c.read_tag(tag_w_index)
# print('{} - {}'.format(tag_w_index, v))
arr_vals.append(round(v[0], 4))
# print(v)
if len(arr_vals) > 0:
return arr_vals
else:
print("No length for {}".format(addr))
return False
except Exception:
print("Error during readArray({}, {}, {}, {})".format(addr, tag, start, end))
err = c.get_status()
c.close()
print err
pass
c.close()
def write_tag(addr, tag, val, plc_type="CLX"):
"""Write a tag value to the PLC."""
direct = plc_type == "Micro800"
c = ClxDriver()
if c.open(addr, direct_connection=direct):
try:
cv = c.read_tag(tag)
print(cv)
wt = c.write_tag(tag, val, cv[1])
return wt
except Exception:
print("Error during writeTag({}, {}, {})".format(addr, tag, val))
err = c.get_status()
c.close()
print err
c.close()
class Channel(object):
"""Holds the configuration for a Meshify channel."""
def __init__(self, mesh_name, data_type, chg_threshold, guarantee_sec, map_=False, write_enabled=False):
"""Initialize the channel."""
self.mesh_name = mesh_name
self.data_type = data_type
self.last_value = None
self.value = None
self.last_send_time = 0
self.chg_threshold = chg_threshold
self.guarantee_sec = guarantee_sec
self.map_ = map_
self.write_enabled = write_enabled
def __str__(self):
"""Create a string for the channel."""
return "{}\nvalue: {}, last_send_time: {}".format(self.mesh_name, self.value, self.last_send_time)
def check(self, new_value, force_send=False):
"""Check to see if the new_value needs to be stored."""
send_needed = False
send_reason = ""
if self.data_type == 'BOOL' or self.data_type == 'STRING':
if self.last_send_time == 0:
send_needed = True
send_reason = "no send time"
elif self.value is None:
send_needed = True
send_reason = "no value"
elif not (self.value == new_value):
if self.map_:
if not self.value == self.map_[new_value]:
send_needed = True
send_reason = "value change"
else:
send_needed = True
send_reason = "value change"
elif (time.time() - self.last_send_time) > self.guarantee_sec:
send_needed = True
send_reason = "guarantee sec"
elif force_send:
send_needed = True
send_reason = "forced"
else:
if self.last_send_time == 0:
send_needed = True
send_reason = "no send time"
elif self.value is None:
send_needed = True
send_reason = "no value"
elif abs(self.value - new_value) > self.chg_threshold:
send_needed = True
send_reason = "change threshold"
elif (time.time() - self.last_send_time) > self.guarantee_sec:
send_needed = True
send_reason = "guarantee sec"
elif force_send:
send_needed = True
send_reason = "forced"
if send_needed:
self.last_value = self.value
if self.map_:
try:
self.value = self.map_[new_value]
except KeyError:
print("Cannot find a map value for {} in {} for {}".format(new_value, self.map_, self.mesh_name))
self.value = new_value
else:
self.value = new_value
self.last_send_time = time.time()
print("Sending {} for {} - {}".format(self.value, self.mesh_name, send_reason))
return send_needed
def read(self):
"""Read the value."""
pass
def identity(sent):
"""Return exactly what was sent to it."""
return sent
class ModbusChannel(Channel):
"""Modbus channel object."""
def __init__(self, mesh_name, register_number, data_type, chg_threshold, guarantee_sec, channel_size=1, map_=False, write_enabled=False, transformFn=identity):
"""Initialize the channel."""
super(ModbusChannel, self).__init__(mesh_name, data_type, chg_threshold, guarantee_sec, map_, write_enabled)
self.mesh_name = mesh_name
self.register_number = register_number
self.channel_size = channel_size
self.data_type = data_type
self.last_value = None
self.value = None
self.last_send_time = 0
self.chg_threshold = chg_threshold
self.guarantee_sec = guarantee_sec
self.map_ = map_
self.write_enabled = write_enabled
self.transformFn = transformFn
def read(self, mbsvalue):
"""Return the transformed read value."""
return self.transformFn(mbsvalue)
class PLCChannel(Channel):
"""PLC Channel Object."""
def __init__(self, ip, mesh_name, plc_tag, data_type, chg_threshold, guarantee_sec, map_=False, write_enabled=False, plc_type='CLX'):
"""Initialize the channel."""
super(PLCChannel, self).__init__(mesh_name, data_type, chg_threshold, guarantee_sec, map_, write_enabled)
self.plc_ip = ip
self.mesh_name = mesh_name
self.plc_tag = plc_tag
self.data_type = data_type
self.last_value = None
self.value = None
self.last_send_time = 0
self.chg_threshold = chg_threshold
self.guarantee_sec = guarantee_sec
self.map_ = map_
self.write_enabled = write_enabled
self.plc_type = plc_type
def read(self):
"""Read the value."""
plc_value = None
if self.plc_tag and self.plc_ip:
read_value = read_tag(self.plc_ip, self.plc_tag, plc_type=self.plc_type)
if read_value:
plc_value = read_value[0]
return plc_value
class BoolArrayChannels(Channel):
"""Hold the configuration for a set of boolean array channels."""
def __init__(self, ip, mesh_name, plc_tag, data_type, chg_threshold, guarantee_sec, map_=False, write_enabled=False):
"""Initialize the channel."""
self.plc_ip = ip
self.mesh_name = mesh_name
self.plc_tag = plc_tag
self.data_type = data_type
self.last_value = None
self.value = None
self.last_send_time = 0
self.chg_threshold = chg_threshold
self.guarantee_sec = guarantee_sec
self.map_ = map_
self.write_enabled = write_enabled
def compare_values(self, new_val_dict):
"""Compare new values to old values to see if the values need storing."""
send = False
for idx in new_val_dict:
try:
if new_val_dict[idx] != self.last_value[idx]:
send = True
except KeyError:
print("Key Error in self.compare_values for index {}".format(idx))
send = True
return send
def read(self, force_send=False):
"""Read the value and check to see if needs to be stored."""
send_needed = False
send_reason = ""
if self.plc_tag:
v = read_tag(self.plc_ip, self.plc_tag)
if v:
bool_arr = binarray(v[0])
new_val = {}
for idx in self.map_:
try:
new_val[self.map_[idx]] = bool_arr[idx]
except KeyError:
print("Not able to get value for index {}".format(idx))
if self.last_send_time == 0:
send_needed = True
send_reason = "no send time"
elif self.value is None:
send_needed = True
send_reason = "no value"
elif self.compare_values(new_val):
send_needed = True
send_reason = "value change"
elif (time.time() - self.last_send_time) > self.guarantee_sec:
send_needed = True
send_reason = "guarantee sec"
elif force_send:
send_needed = True
send_reason = "forced"
if send_needed:
self.value = new_val
self.last_value = self.value
self.last_send_time = time.time()
print("Sending {} for {} - {}".format(self.value, self.mesh_name, send_reason))
return send_needed

File diff suppressed because one or more lines are too long

View File

@@ -1,12 +1,12 @@
{
"driverFileName":"ipp.py",
"deviceName":"ipp",
"driverId":"0090",
"releaseVersion":"8",
"files": {
"file1":"ipp.py",
"file2":"micro800.py"
}
"files": {
"file3": "Channel.py",
"file2": "utilities.py",
"file1": "ipp.py",
"file4": "maps.py"
},
"deviceName": "ipp",
"driverId": "0090",
"releaseVersion": "9",
"driverFileName": "ipp.py"
}

View File

@@ -0,0 +1,12 @@
{
"name": "ipp",
"driverFilename": "ipp.py",
"driverId": "0090",
"additionalDriverFiles": [
"utilities.py",
"Channel.py",
"maps.py"
],
"version": 9,
"s3BucketName": "ipp"
}

View File

@@ -1,20 +0,0 @@
import pickle
with open('testPickle.p', 'rb') as ch_f:
channels = pickle.load(ch_f)
out = []
for x in channels.keys():
chName = x
dType = channels[x]['data_type']
if dType == 'REAL':
dType = "float"
elif dType[-3:] == "INT":
dType = "integer"
elif dType == "BOOL":
dType = "boolean"
else:
print dType
out.append("{0} - {1}".format(chName, dType))
for a in sorted(out):
print a

View File

@@ -1,538 +1,316 @@
#!/usr/bin/python
"""Driver for ipp"""
import threading
import traceback
import time
import json
import socket
import os
import sys
from device_base import deviceBase
import micro800 as u800
from Channel import PLCChannel
from utilities import get_public_ip_address
from maps import *
import time
import logging
addr = '10.20.4.5'
channels = {}
version = "8"
_ = None
# LOGGING SETUP
from logging.handlers import RotatingFileHandler
e300_current = {
0: 'None',
1: 'Overload',
2: 'Phase Loss',
4: 'Ground Fault',
8: 'Stall',
16: 'Jam',
32: 'Underload',
64: 'Current Imbalance',
128: 'L1 Undercurrent',
256: 'L2 Undercurrent',
512: 'L3 Undercurrent',
1024: 'L1 Overcurrent',
2048: 'L2 Overcurrent',
4096: 'L3 Overcurrent',
8192: 'L1 Line Loss',
16384: 'L2 Line Loss',
32768: 'L3 Line Loss'
}
log_formatter = logging.Formatter('%(asctime)s %(levelname)s %(funcName)s(%(lineno)d) %(message)s')
logFile = './ipp.log'
my_handler = RotatingFileHandler(logFile, mode='a', maxBytes=500*1024, backupCount=2, encoding=None, delay=0)
my_handler.setFormatter(log_formatter)
my_handler.setLevel(logging.INFO)
logger = logging.getLogger('ipp')
logger.setLevel(logging.INFO)
logger.addHandler(my_handler)
e300_voltage = {
0: 'None',
1: 'Undervoltage',
2: 'Overvoltage',
4: 'Voltage Unbalance',
8: 'Phase Rotation',
16: 'Overfrequency'
}
console_out = logging.StreamHandler(sys.stdout)
console_out.setFormatter(log_formatter)
logger.addHandler(console_out)
e300_control = {
0: 'None',
1: 'Test Trip',
2: 'DLX Trip',
4: 'PTC Trip',
8: 'Operator Station Trip',
16: 'Remote Trip',
32: 'Blocked Start Trip',
64: 'Hardware Fault Trip',
128: 'Config Trip',
256: 'Option Match Trip',
512: 'DLX FB Timeout Trip',
1024: 'Expansion Bus Trip',
2048: 'Reserved',
4096: 'Reserved',
8192: 'NVS Trip',
16384: 'Test Mode Trip'
}
logger.info("ipp startup")
e300_power = {
0: 'None',
1: 'Under kW',
2: 'Over kW',
4: 'Under kVAR Consumed',
8: 'Over kVAR Consumed',
16: 'Under kVAR Generated',
32: 'Over kVAR Generated',
64: 'Under kVA',
128: 'Over kVA',
256: 'Under PF Lag',
512: 'Over PF Lag',
1024: 'Under PF Lead',
2048: 'Over PF Lead'
}
device_status = {
1: "Startup",
2: "Not ready to start",
3: "Ready to start",
4: "Lost run permissive",
5: "Not able to restart - Overload Limit",
6: "Not able to restart - Trip Limit",
7: "Waiting to attempt restart",
8: "Waiting to attempt restart (Overload)",
9: "Running",
10: "User stopped",
11: "Waiting to start (Timer Mode)"
}
class Channel():
def read(self):
valData = u800.readMicroTag(self.device_addr, self.tag)
if valData:
nowVal = valData[0]
if self.map_obj:
nowVal = self.map_obj[nowVal]
self.data_type = valData[1]
if (self.data_type == "BOOL") or (type(nowVal) is str) or (type(nowVal) is str):
if self.last_value == "":
self.sendFn(self.name, nowVal, 0)
self.last_time_uploaded = time.time()
self.last_value = nowVal
elif (not (self.last_value == nowVal)) or ((time.time() - self.last_time_uploaded) > self.max_time_between_uploads):
self.sendFn(self.name, nowVal, 0)
self.last_time_uploaded = time.time()
self.last_value = nowVal
elif (self.data_type == "REAL") or (self.data_type[-3:] == "INT"):
if self.last_value == "":
self.sendFn(self.name, nowVal, 0)
self.last_time_uploaded = time.time()
self.last_value = nowVal
elif (abs(self.last_value - nowVal) > self.change_threshold) or ((time.time() - self.last_time_uploaded) > self.max_time_between_uploads):
self.sendFn(self.name, nowVal, 0)
self.last_time_uploaded = time.time()
self.last_value = nowVal
return True
return False
def __init__(self, name, tag, max_time_between_uploads, sendFn, change_threshold=0.0, e300_param=False, writeable=False, map_obj=None):
global addr
self.name = name
self.tag = tag
self.data_type = ''
self.last_value = ''
self.last_time_uploaded = 0
self.change_threshold = change_threshold
self.max_time_between_uploads = int(max_time_between_uploads)
self.sendFn = sendFn
self.device_addr = addr
self.writeable = bool(writeable)
self.map_obj = map_obj
self.e300_param = e300_param
self.read()
def write(self, val, handshake=None, handshake_val=None):
if self.writeable:
if not self.e300_param:
if handshake is None:
if u800.writeMicroTag(self.device_addr, self.tag, val):
self.sendFn(self.name, val, time.time())
self.last_value = val
return True
else:
return False
else:
return u800.writeMicroTag(self.device_addr, self.tag, val, handshake=handshake, handshake_val=handshake_val)
else:
if u800.writeMicroTag(self.device_addr, self.tag, val):
if u800.writeMicroTag(self.device_addr, "write_E300", 1):
self.sendFn(self.name, val, time.time())
self.last_value = val
return True
return False
else:
print("NOT ALLOWED TO WRITE TO {}".format(self.name))
return False
# GLOBAL VARIABLES
WATCHDOG_SEND_PERIOD = 3600 # Seconds, the longest amount of time before sending the watchdog status
PLC_IP_ADDRESS = "10.20.4.5"
CHANNELS = [
PLCChannel(PLC_IP_ADDRESS, 'alarmdhpressure', 'alarm_DHPressure', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'alarmdhtemperature', 'alarm_DHTemperature', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'alarme300', 'alarm_E300', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'alarmtubingpressure', 'alarm_TubingPressure', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'automode', 'Auto_Mode', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'cfgcflasetting', 'cfg_C_FLASetting', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgcleartripcountafter', 'cfg_ClearTripCountAfter', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgdhsensordisttointake', 'cfg_DHSensorDistToIntake', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfggfgroundfaultinhibittime', 'cfg_GF_GroundFaultInhibitTime', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfggfgroundfaulttripdelay', 'cfg_GF_GroundFaultTripDelay', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfggfgroundfaulttriplevel', 'cfg_GF_GroundFaultTripLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfggfgroundfaultwarningdelay', 'cfg_GF_GroundFaultWarningDelay', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfggfgroundfaultwarninglevel', 'cfg_GF_GroundFaultWarningLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgictprimary', 'cfg_I_CTPrimary', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgictsecondary', 'cfg_I_CTSecondary', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgicurrentimbalanceinhibittim', 'cfg_I_CurrentImbalanceInhibitTime', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgicurrentimbalancetripdelay', 'cfg_I_CurrentImbalanceTripDelay', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgicurrentimbalancetriplevel', 'cfg_I_CurrentImbalanceTripLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgicurrentimbalancewarninglev', 'cfg_I_CurrentImbalanceWarningLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgijaminhibittime', 'cfg_I_JamInhibitTime', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgijamtripdelay', 'cfg_I_JamTripDelay', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgijamtriplevel', 'cfg_I_JamTripLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgijamwarninglevel', 'cfg_I_JamWarningLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgilinelossinhibittime', 'cfg_I_LineLossInhibitTime', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgilinelosstripdelay', 'cfg_I_LineLossTripDelay', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgiovercurrentinhibittime', 'cfg_I_OvercurrentInhibitTime', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgiovercurrenttripdelay', 'cfg_I_OvercurrentTripDelay', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgiovercurrenttriplevel', 'cfg_I_OvercurrentTripLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgiovercurrentwarninglevel', 'cfg_I_OvercurrentWarningLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgistallenabledtime', 'cfg_I_StallEnabledTime', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgistalltriplevel', 'cfg_I_StallTripLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgiundercurrentinhibittime', 'cfg_I_UndercurrentInhibitTime', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgiundercurrenttripdelay', 'cfg_I_UndercurrentTripDelay', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgiundercurrenttriplevel', 'cfg_I_UndercurrentTripLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgiundercurrentwarninglevel', 'cfg_I_UndercurrentWarningLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgiunderloadinhibittime', 'cfg_I_UnderloadInhibitTime', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgiunderloadtripdelay', 'cfg_I_UnderloadTripDelay', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgiunderloadtriplevel', 'cfg_I_UnderloadTripLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgiunderloadwarninglevel', 'cfg_I_UnderloadWarningLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgoverloadtripcountlimit', 'cfg_OverloadTripCountLimit', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgplphaselossinhibittime', 'cfg_PL_PhaseLossInhibitTime', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgplphaselosstripdelay', 'cfg_PL_PhaseLossTripDelay', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgread', 'cfg_READ', 'REAL', 0.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgspecificgravity', 'cfg_SpecificGravity', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgtcuolresetlevel', 'cfg_TCU_OLResetLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgtcuolwarninglevel', 'cfg_TCU_OLWarningLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgtcutripclass', 'cfg_TCU_TripClass', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgtimermodeenabled', 'cfg_TimerModeEnabled', 'REAL', 0.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgtimerruntime', 'cfg_TimerRunTime', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgtimerwaittime', 'cfg_TimerWaitTime', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgtripcountlimit', 'cfg_TripCountLimit', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvoverfrequencyinhibittime', 'cfg_V_OverfrequencyInhibitTime', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvoverfrequencytripdelay', 'cfg_V_OverfrequencyTripDelay', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvoverfrequencytriplevel', 'cfg_V_OverfrequencyTripLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvoverfrequencywarninglevel', 'cfg_V_OverfrequencyWarningLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvovervoltageinhibittime', 'cfg_V_OvervoltageInhibitTime', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvovervoltagetripdelay', 'cfg_V_OvervoltageTripDelay', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvovervoltagetriplevel', 'cfg_V_OvervoltageTripLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvovervoltagewarninglevel', 'cfg_V_OvervoltageWarningLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvphaserotationinhibittime', 'cfg_V_PhaseRotationInhibitTime', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvphaserotationtriptype', 'cfg_V_PhaseRotationTripType', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvptprimary', 'cfg_V_PTPrimary', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvptsecondary', 'cfg_V_PTSecondary', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvunderfrequencyinhibittime', 'cfg_V_UnderfrequencyInhibitTime', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvunderfrequencytripdelay', 'cfg_V_UnderfrequencyTripDelay', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvunderfrequencytriplevel', 'cfg_V_UnderfrequencyTripLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvunderfrequencywarninglevel', 'cfg_V_UnderfrequencyWarningLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvundervoltageinhibittime', 'cfg_V_UndervoltageInhibitTime', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvundervoltagetripdelay', 'cfg_V_UndervoltageTripDelay', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvundervoltagetriplevel', 'cfg_V_UndervoltageTripLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvundervoltagewarninglevel', 'cfg_V_UndervoltageWarningLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvvoltageimbalanceinhibittim', 'cfg_V_VoltageImbalanceInhibitTime', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvvoltageimbalancetripdelay', 'cfg_V_VoltageImbalanceTripDelay', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvvoltageimbalancetriplevel', 'cfg_V_VoltageImbalanceTripLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvvoltageimbalancewarninglev', 'cfg_V_VoltageImbalanceWarningLevel', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgvvoltagemode', 'cfg_V_VoltageMode', 'REAL', 1.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'cfgwrite', 'cfg_WRITE', 'REAL', 0.0, 86400, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'contactorstatus', 'Contactor_Status', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'devicestatus', 'Device_Status_INT', 'STRING', 0.0, 3600, plc_type='Micro800', map_=map_device_status),
PLCChannel(PLC_IP_ADDRESS, 'dhdownholestatusint', 'DH_DownholeStatus_INT', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'dhfluidlevel', 'DH_Fluid_Level', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'dhintakepressure', 'DH_IntakePressure', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'dhintaketemperature', 'DH_IntakeTemperature', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'dhmaxintakepressureforever', 'DH_MaxIntakePressure_Forever', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'dhmaxintakepressurestartup', 'DH_MaxIntakePressure_Startup', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'dhmaxintaketemperatureforever', 'DH_MaxIntakeTemperature_Forever', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'dhmaxintaketemperaturestartup', 'DH_MaxIntakeTemperature_Startup', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'dhnumchannels', 'DH_NumChannels', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'dhpsirating', 'DH_PSIRating', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'dhtooltype', 'DH_ToolType', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'dhtoolvoltage', 'DH_ToolVoltage', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'downholetoolenabled', 'Downhole_Tool_Enabled', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'downtimetimeparameter', 'Downtime_Time_Parameter', 'REAL', 1.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'downtimetimeparameterol', 'Downtime_Time_Parameter_OL', 'REAL', 1.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'e300averagecurrent', 'E300_AverageCurrent', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300averagellvoltage', 'E300_AverageLLVoltage', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300averagelnvoltage', 'E300_AverageLNVoltage', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300kwh', 'E300_kWh', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300kwhregen', 'E300_kWh_Regen', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l1apparentpower', 'E300_L1ApparentPower', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l1current', 'E300_L1Current', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l1l2voltage', 'E300_L1L2Voltage', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l1nvoltage', 'E300_L1NVoltage', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l1reactivepower', 'E300_L1ReactivePower', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l1realpower', 'E300_L1RealPower', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l1truepowerfactor', 'E300_L1TruePowerFactor', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l2apparentpower', 'E300_L2ApparentPower', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l2current', 'E300_L2Current', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l2l3voltage', 'E300_L2L3Voltage', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l2nvoltage', 'E300_L2NVoltage', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l2reactivepower', 'E300_L2ReactivePower', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l2realpower', 'E300_L2RealPower', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l2truepowerfactor', 'E300_L2TruePowerFactor', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l3apparentpower', 'E300_L3ApparentPower', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l3current', 'E300_L3Current', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l3l1voltage', 'E300_L3L1Voltage', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l3nvoltage', 'E300_L3NVoltage', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l3reactivepower', 'E300_L3ReactivePower', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l3realpower', 'E300_L3RealPower', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300l3truepowerfactor', 'E300_L3TruePowerFactor', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300linefrequency', 'E300_LineFrequency', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300percentcurrentunbalance', 'E300_PercentCurrentUnbalance', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300percentvoltageunbalance', 'E300_PercentVoltageUnbalance', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300threephasetruepowerfactor', 'E300_ThreePhaseTruePowerFactor', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300totalapparentpower', 'E300_TotalApparentPower', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300totalreactivepower', 'E300_TotalReactivePower', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'e300totalrealpower', 'E300_TotalRealPower', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'flowrate', 'Flowrate', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'flowtoday', 'Flow_Today', 'REAL', 100.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'flowyesterday', 'Flow_Yesterday', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'handmode', 'Hand_Mode', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'overloadtrip', 'OverloadTrip', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'pressurealarmdelay', 'Pressure_Alarm_Delay', 'REAL', 1.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'pressurealarmstartupdelay', 'Pressure_Alarm_Startup_Delay', 'REAL', 1.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'pressureeumax', 'Pressure_EU_Max', 'REAL', 1.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'pressureeumin', 'Pressure_EU_Min', 'REAL', 1.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'pressurehi', 'Pressure_Hi', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'pressurehisp', 'Pressure_Hi_SP', 'REAL', 1.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'pressurein', 'Pressure_In', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'pressurelo', 'Pressure_Lo', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'pressurelosp', 'Pressure_Lo_SP', 'REAL', 1.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'pressureok', 'Pressure_OK', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'pressureshutdown', 'Pressure_Shutdown', 'REAL', 1.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'pressureshutdownenabled', 'Pressure_Shutdown_Enabled', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'pressurestartup', 'Pressure_Startup', 'REAL', 1.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'pressurestartupenabled', 'Pressure_Startup_Enabled', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'pressureswitchenabled', 'Pressure_Switch_Enabled', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'pressuretransducerenabled', 'Pressure_Transducer_Enabled', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'rpmode', 'RP_Mode', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'rppressure', 'RP_Pressure', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'rptemperature', 'RP_Temperature', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'rptrip', 'RP_Trip', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'rptubingpressure', 'RP_TubingPressure', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'runpermissive', 'Run_Permissive', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'spmode', 'SP_Mode', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'sppressure', 'SP_Pressure', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'sptemperature', 'SP_Temperature', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'sptrip', 'SP_Trip', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'spvoltage', 'SP_Voltage', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'startbutton', 'Start_Button', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'startcommand', 'Start_Command', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'startpermissive', 'Start_Permissive', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'stopcommand', 'Stop_Command', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tempshutdown', 'Temp_Shutdown', 'REAL', 1.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tempshutdownenabled', 'Temp_Shutdown_Enabled', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tempstartup', 'Temp_Startup', 'REAL', 1.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tempstartupenabled', 'Temp_Startup_Enabled', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'testmode', 'Test_Mode', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'tripenabledicurrentimbalance', 'TripEnabled_I_CurrentImbalance', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tripenabledigroundfault', 'TripEnabled_I_GroundFault', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tripenabledijam', 'TripEnabled_I_Jam', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tripenabledilineloss', 'TripEnabled_I_LineLoss', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tripenablediovercurrent', 'TripEnabled_I_Overcurrent', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tripenabledioverload', 'TripEnabled_I_Overload', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tripenablediphaseloss', 'TripEnabled_I_PhaseLoss', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tripenabledistall', 'TripEnabled_I_Stall', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tripenablediundercurrent', 'TripEnabled_I_Undercurrent', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tripenablediunderload', 'TripEnabled_I_Underload', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tripenablevoverfrequency', 'TripEnable_V_Overfrequency', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tripenablevovervoltage', 'TripEnable_V_Overvoltage', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tripenablevphaserotation', 'TripEnable_V_PhaseRotation', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tripenablevunderfrequency', 'TripEnable_V_Underfrequency', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tripenablevundervoltage', 'TripEnable_V_Undervoltage', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tripenablevvoltageunbalance', 'TripEnable_V_VoltageUnbalance', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tripresetcmd', 'TripResetCmd', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'tripstatus', 'TripStatus', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'tripstatuscontrolint', 'TripStatusControl_INT', 'STRING', 1.0, 3600, plc_type='Micro800', map_=map_e300_control),
PLCChannel(PLC_IP_ADDRESS, 'tripstatuscurrentint', 'TripStatusCurrent_INT', 'STRING', 1.0, 3600, plc_type='Micro800', map_=map_e300_current),
PLCChannel(PLC_IP_ADDRESS, 'tripstatuspowerint', 'TripStatusPower_INT', 'STRING', 1.0, 3600, plc_type='Micro800', map_=map_e300_power),
PLCChannel(PLC_IP_ADDRESS, 'tripstatusvoltageint', 'TripStatusVoltage_INT', 'STRING', 1.0, 3600, plc_type='Micro800', map_=map_e300_voltage),
PLCChannel(PLC_IP_ADDRESS, 'valoverloadtripcount', 'val_OverloadTripCount', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'valtripcount', 'val_TripCount', 'REAL', 1.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'voltageok', 'VoltageOK', 'REAL', 0.0, 3600, plc_type='Micro800'),
PLCChannel(PLC_IP_ADDRESS, 'warningenabledicurrentimbalanc', 'WarningEnabled_I_CurrentImbalance', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningenabledigroundfault', 'WarningEnabled_I_GroundFault', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningenabledijam', 'WarningEnabled_I_Jam', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningenabledilineloss', 'WarningEnabled_I_LineLoss', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningenablediovercurrent', 'WarningEnabled_I_Overcurrent', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningenabledioverload', 'WarningEnabled_I_Overload', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningenablediphaseloss', 'WarningEnabled_I_PhaseLoss', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningenabledistall', 'WarningEnabled_I_Stall', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningenablediundercurrent', 'WarningEnabled_I_Undercurrent', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningenablediunderload', 'WarningEnabled_I_Underload', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningenablevoverfrequency', 'WarningEnable_V_Overfrequency', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningenablevovervoltage', 'WarningEnable_V_Overvoltage', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningenablevphaserotation', 'WarningEnable_V_PhaseRotation', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningenablevunderfrequency', 'WarningEnable_V_Underfrequency', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningenablevundervoltage', 'WarningEnable_V_Undervoltage', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningenablevvoltageunbalance', 'WarningEnable_V_VoltageUnbalance', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningstatus', 'WarningStatus', 'BOOL', 0.0, 3600, plc_type='Micro800', write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningstatuscontrolint', 'WarningStatusControl_INT', 'STRING', 1.0, 3600, plc_type='Micro800', map_=map_e300_control, write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningstatuscurrentint', 'WarningStatusCurrent_INT', 'STRING', 1.0, 3600, plc_type='Micro800', map_=map_e300_current, write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningstatuspowerint', 'WarningStatusPower_INT', 'STRING', 1.0, 3600, plc_type='Micro800', map_=map_e300_power, write_enabled=True),
PLCChannel(PLC_IP_ADDRESS, 'warningstatusvoltageint', 'WarningStatusVoltage_INT', 'STRING', 1.0, 3600, plc_type='Micro800', map_=map_e300_voltage, write_enabled=True)
]
class start(threading.Thread, deviceBase):
def writeTag_WriteE300(self, addr, tag, val):
write_tag = u800.writeMicroTag(addr, tag, val)
write_e300 = u800.writeMicroTag(addr, "write_E300", 1)
return write_tag and write_e300
"""Start class required by Meshify."""
def updateGPS(self):
gps = self.mcu.gps
print("GPS found me at {0}".format(gps))
self.sendtodb("gps", gps, 0)
def __init__(self, name=None, number=None, mac=None, Q=None, mcu=None, companyId=None, offset=None, mqtt=None, Nodes=None):
"""Initialize the driver."""
threading.Thread.__init__(self)
deviceBase.__init__(self, name=name, number=number, mac=mac, Q=Q, mcu=mcu, companyId=companyId, offset=offset, mqtt=mqtt, Nodes=Nodes)
def setupChannels(self):
global channels
channels = {
'automode': Channel('automode', 'Auto_Mode', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'alarmdhpressure': Channel('alarmdhpressure', 'alarm_DHPressure', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'alarmdhtemperature': Channel('alarmdhtemperature', 'alarm_DHTemperature', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'alarme300': Channel('alarme300', 'alarm_E300', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'alarmtubingpressure': Channel('alarmtubingpressure', 'alarm_TubingPressure', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'cfgcflasetting': Channel('cfgcflasetting', 'cfg_C_FLASetting', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgcleartripcountafter': Channel('cfgcleartripcountafter', 'cfg_ClearTripCountAfter', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'cfgdhsensordisttointake': Channel('cfgdhsensordisttointake', 'cfg_DHSensorDistToIntake', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'cfggfgroundfaultinhibittime': Channel('cfggfgroundfaultinhibittime', 'cfg_GF_GroundFaultInhibitTime', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfggfgroundfaulttripdelay': Channel('cfggfgroundfaulttripdelay', 'cfg_GF_GroundFaultTripDelay', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfggfgroundfaulttriplevel': Channel('cfggfgroundfaulttriplevel', 'cfg_GF_GroundFaultTripLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfggfgroundfaultwarningdelay': Channel('cfggfgroundfaultwarningdelay', 'cfg_GF_GroundFaultWarningDelay', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfggfgroundfaultwarninglevel': Channel('cfggfgroundfaultwarninglevel', 'cfg_GF_GroundFaultWarningLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgictprimary': Channel('cfgictprimary', 'cfg_I_CTPrimary', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgictsecondary': Channel('cfgictsecondary', 'cfg_I_CTSecondary', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgicurrentimbalanceinhibittim': Channel('cfgicurrentimbalanceinhibittim', 'cfg_I_CurrentImbalanceInhibitTime', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgicurrentimbalancetripdelay': Channel('cfgicurrentimbalancetripdelay', 'cfg_I_CurrentImbalanceTripDelay', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgicurrentimbalancetriplevel': Channel('cfgicurrentimbalancetriplevel', 'cfg_I_CurrentImbalanceTripLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgicurrentimbalancewarninglev': Channel('cfgicurrentimbalancewarninglev', 'cfg_I_CurrentImbalanceWarningLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgijaminhibittime': Channel('cfgijaminhibittime', 'cfg_I_JamInhibitTime', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgijamtripdelay': Channel('cfgijamtripdelay', 'cfg_I_JamTripDelay', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgijamtriplevel': Channel('cfgijamtriplevel', 'cfg_I_JamTripLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgijamwarninglevel': Channel('cfgijamwarninglevel', 'cfg_I_JamWarningLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgilinelossinhibittime': Channel('cfgilinelossinhibittime', 'cfg_I_LineLossInhibitTime', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgilinelosstripdelay': Channel('cfgilinelosstripdelay', 'cfg_I_LineLossTripDelay', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgiovercurrentinhibittime': Channel('cfgiovercurrentinhibittime', 'cfg_I_OvercurrentInhibitTime', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgiovercurrenttripdelay': Channel('cfgiovercurrenttripdelay', 'cfg_I_OvercurrentTripDelay', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgiovercurrenttriplevel': Channel('cfgiovercurrenttriplevel', 'cfg_I_OvercurrentTripLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgiovercurrentwarninglevel': Channel('cfgiovercurrentwarninglevel', 'cfg_I_OvercurrentWarningLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgistallenabledtime': Channel('cfgistallenabledtime', 'cfg_I_StallEnabledTime', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgistalltriplevel': Channel('cfgistalltriplevel', 'cfg_I_StallTripLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgiundercurrentinhibittime': Channel('cfgiundercurrentinhibittime', 'cfg_I_UndercurrentInhibitTime', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgiundercurrenttripdelay': Channel('cfgiundercurrenttripdelay', 'cfg_I_UndercurrentTripDelay', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgiundercurrenttriplevel': Channel('cfgiundercurrenttriplevel', 'cfg_I_UndercurrentTripLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgiundercurrentwarninglevel': Channel('cfgiundercurrentwarninglevel', 'cfg_I_UndercurrentWarningLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgiunderloadinhibittime': Channel('cfgiunderloadinhibittime', 'cfg_I_UnderloadInhibitTime', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgiunderloadtripdelay': Channel('cfgiunderloadtripdelay', 'cfg_I_UnderloadTripDelay', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgiunderloadtriplevel': Channel('cfgiunderloadtriplevel', 'cfg_I_UnderloadTripLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgiunderloadwarninglevel': Channel('cfgiunderloadwarninglevel', 'cfg_I_UnderloadWarningLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgoverloadtripcountlimit': Channel('cfgoverloadtripcountlimit', 'cfg_OverloadTripCountLimit', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'cfgplphaselossinhibittime': Channel('cfgplphaselossinhibittime', 'cfg_PL_PhaseLossInhibitTime', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgplphaselosstripdelay': Channel('cfgplphaselosstripdelay', 'cfg_PL_PhaseLossTripDelay', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgread': Channel('cfgread', 'cfg_READ', 86400, self.sendtodbJSON, writeable=True, e300_param=False),
'cfgspecificgravity': Channel('cfgspecificgravity', 'cfg_SpecificGravity', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'cfgtcuolresetlevel': Channel('cfgtcuolresetlevel', 'cfg_TCU_OLResetLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgtcuolwarninglevel': Channel('cfgtcuolwarninglevel', 'cfg_TCU_OLWarningLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgtcutripclass': Channel('cfgtcutripclass', 'cfg_TCU_TripClass', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgtimermodeenabled': Channel('cfgtimermodeenabled', 'cfg_TimerModeEnabled', 86400, self.sendtodbJSON, writeable=True, e300_param=False),
'cfgtimerruntime': Channel('cfgtimerruntime', 'cfg_TimerRunTime', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'cfgtimerwaittime': Channel('cfgtimerwaittime', 'cfg_TimerWaitTime', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'cfgtripcountlimit': Channel('cfgtripcountlimit', 'cfg_TripCountLimit', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'cfgvoverfrequencyinhibittime': Channel('cfgvoverfrequencyinhibittime', 'cfg_V_OverfrequencyInhibitTime', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvoverfrequencytripdelay': Channel('cfgvoverfrequencytripdelay', 'cfg_V_OverfrequencyTripDelay', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvoverfrequencytriplevel': Channel('cfgvoverfrequencytriplevel', 'cfg_V_OverfrequencyTripLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvoverfrequencywarninglevel': Channel('cfgvoverfrequencywarninglevel', 'cfg_V_OverfrequencyWarningLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvovervoltageinhibittime': Channel('cfgvovervoltageinhibittime', 'cfg_V_OvervoltageInhibitTime', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvovervoltagetripdelay': Channel('cfgvovervoltagetripdelay', 'cfg_V_OvervoltageTripDelay', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvovervoltagetriplevel': Channel('cfgvovervoltagetriplevel', 'cfg_V_OvervoltageTripLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvovervoltagewarninglevel': Channel('cfgvovervoltagewarninglevel', 'cfg_V_OvervoltageWarningLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvphaserotationinhibittime': Channel('cfgvphaserotationinhibittime', 'cfg_V_PhaseRotationInhibitTime', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvphaserotationtriptype': Channel('cfgvphaserotationtriptype', 'cfg_V_PhaseRotationTripType', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvptprimary': Channel('cfgvptprimary', 'cfg_V_PTPrimary', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvptsecondary': Channel('cfgvptsecondary', 'cfg_V_PTSecondary', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvunderfrequencyinhibittime': Channel('cfgvunderfrequencyinhibittime', 'cfg_V_UnderfrequencyInhibitTime', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvunderfrequencytripdelay': Channel('cfgvunderfrequencytripdelay', 'cfg_V_UnderfrequencyTripDelay', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvunderfrequencytriplevel': Channel('cfgvunderfrequencytriplevel', 'cfg_V_UnderfrequencyTripLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvunderfrequencywarninglevel': Channel('cfgvunderfrequencywarninglevel', 'cfg_V_UnderfrequencyWarningLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvundervoltageinhibittime': Channel('cfgvundervoltageinhibittime', 'cfg_V_UndervoltageInhibitTime', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvundervoltagetripdelay': Channel('cfgvundervoltagetripdelay', 'cfg_V_UndervoltageTripDelay', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvundervoltagetriplevel': Channel('cfgvundervoltagetriplevel', 'cfg_V_UndervoltageTripLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvundervoltagewarninglevel': Channel('cfgvundervoltagewarninglevel', 'cfg_V_UndervoltageWarningLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvvoltageimbalanceinhibittim': Channel('cfgvvoltageimbalanceinhibittim', 'cfg_V_VoltageImbalanceInhibitTime', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvvoltageimbalancetripdelay': Channel('cfgvvoltageimbalancetripdelay', 'cfg_V_VoltageImbalanceTripDelay', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvvoltageimbalancetriplevel': Channel('cfgvvoltageimbalancetriplevel', 'cfg_V_VoltageImbalanceTripLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvvoltageimbalancewarninglev': Channel('cfgvvoltageimbalancewarninglev', 'cfg_V_VoltageImbalanceWarningLevel', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgvvoltagemode': Channel('cfgvvoltagemode', 'cfg_V_VoltageMode', 86400, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=True),
'cfgwrite': Channel('cfgwrite', 'cfg_WRITE', 86400, self.sendtodbJSON, writeable=True, e300_param=False),
'contactorstatus': Channel('contactorstatus', 'Contactor_Status', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'devicestatus': Channel('devicestatus', 'Device_Status_INT', 3600, self.sendtodb, writeable=False, e300_param=False, map_obj=device_status),
'dhdownholestatusint': Channel('dhdownholestatusint', 'DH_DownholeStatus_INT', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'dhfluidlevel': Channel('dhfluidlevel', 'DH_Fluid_Level', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'dhintakepressure': Channel('dhintakepressure', 'DH_IntakePressure', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'dhintaketemperature': Channel('dhintaketemperature', 'DH_IntakeTemperature', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'dhmaxintakepressureforever': Channel('dhmaxintakepressureforever', 'DH_MaxIntakePressure_Forever', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'dhmaxintakepressurestartup': Channel('dhmaxintakepressurestartup', 'DH_MaxIntakePressure_Startup', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'dhmaxintaketemperatureforever': Channel('dhmaxintaketemperatureforever', 'DH_MaxIntakeTemperature_Forever', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'dhmaxintaketemperaturestartup': Channel('dhmaxintaketemperaturestartup', 'DH_MaxIntakeTemperature_Startup', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'dhnumchannels': Channel('dhnumchannels', 'DH_NumChannels', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'dhpsirating': Channel('dhpsirating', 'DH_PSIRating', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'dhtooltype': Channel('dhtooltype', 'DH_ToolType', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'dhtoolvoltage': Channel('dhtoolvoltage', 'DH_ToolVoltage', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'downholetoolenabled': Channel('downholetoolenabled', 'Downhole_Tool_Enabled', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'downtimetimeparameter': Channel('downtimetimeparameter', 'Downtime_Time_Parameter', 3600, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'downtimetimeparameterol': Channel('downtimetimeparameterol', 'Downtime_Time_Parameter_OL', 3600, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'e300averagecurrent': Channel('e300averagecurrent', 'E300_AverageCurrent', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300averagellvoltage': Channel('e300averagellvoltage', 'E300_AverageLLVoltage', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300averagelnvoltage': Channel('e300averagelnvoltage', 'E300_AverageLNVoltage', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300kwh': Channel('e300kwh', 'E300_kWh', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300kwhregen': Channel('e300kwhregen', 'E300_kWh_Regen', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l1apparentpower': Channel('e300l1apparentpower', 'E300_L1ApparentPower', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l1current': Channel('e300l1current', 'E300_L1Current', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l1l2voltage': Channel('e300l1l2voltage', 'E300_L1L2Voltage', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l1nvoltage': Channel('e300l1nvoltage', 'E300_L1NVoltage', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l1reactivepower': Channel('e300l1reactivepower', 'E300_L1ReactivePower', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l1realpower': Channel('e300l1realpower', 'E300_L1RealPower', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l1truepowerfactor': Channel('e300l1truepowerfactor', 'E300_L1TruePowerFactor', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l2apparentpower': Channel('e300l2apparentpower', 'E300_L2ApparentPower', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l2current': Channel('e300l2current', 'E300_L2Current', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l2l3voltage': Channel('e300l2l3voltage', 'E300_L2L3Voltage', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l2nvoltage': Channel('e300l2nvoltage', 'E300_L2NVoltage', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l2reactivepower': Channel('e300l2reactivepower', 'E300_L2ReactivePower', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l2realpower': Channel('e300l2realpower', 'E300_L2RealPower', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l2truepowerfactor': Channel('e300l2truepowerfactor', 'E300_L2TruePowerFactor', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l3apparentpower': Channel('e300l3apparentpower', 'E300_L3ApparentPower', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l3current': Channel('e300l3current', 'E300_L3Current', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l3l1voltage': Channel('e300l3l1voltage', 'E300_L3L1Voltage', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l3nvoltage': Channel('e300l3nvoltage', 'E300_L3NVoltage', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l3reactivepower': Channel('e300l3reactivepower', 'E300_L3ReactivePower', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l3realpower': Channel('e300l3realpower', 'E300_L3RealPower', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300l3truepowerfactor': Channel('e300l3truepowerfactor', 'E300_L3TruePowerFactor', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300linefrequency': Channel('e300linefrequency', 'E300_LineFrequency', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300percentcurrentunbalance': Channel('e300percentcurrentunbalance', 'E300_PercentCurrentUnbalance', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300percentvoltageunbalance': Channel('e300percentvoltageunbalance', 'E300_PercentVoltageUnbalance', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300threephasetruepowerfactor': Channel('e300threephasetruepowerfactor', 'E300_ThreePhaseTruePowerFactor', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300totalapparentpower': Channel('e300totalapparentpower', 'E300_TotalApparentPower', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300totalreactivepower': Channel('e300totalreactivepower', 'E300_TotalReactivePower', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'e300totalrealpower': Channel('e300totalrealpower', 'E300_TotalRealPower', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'flowrate': Channel('flowrate', 'Flowrate', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'handmode': Channel('handmode', 'Hand_Mode', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'overloadtrip': Channel('overloadtrip', 'OverloadTrip', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'pressurealarmdelay': Channel('pressurealarmdelay', 'Pressure_Alarm_Delay', 3600, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'pressurealarmstartupdelay': Channel('pressurealarmstartupdelay', 'Pressure_Alarm_Startup_Delay', 3600, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'pressureeumax': Channel('pressureeumax', 'Pressure_EU_Max', 3600, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'pressureeumin': Channel('pressureeumin', 'Pressure_EU_Min', 3600, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'pressurehi': Channel('pressurehi', 'Pressure_Hi', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'pressurehisp': Channel('pressurehisp', 'Pressure_Hi_SP', 3600, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'pressurein': Channel('pressurein', 'Pressure_In', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'pressurelo': Channel('pressurelo', 'Pressure_Lo', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'pressurelosp': Channel('pressurelosp', 'Pressure_Lo_SP', 3600, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'pressureok': Channel('pressureok', 'Pressure_OK', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'pressureshutdown': Channel('pressureshutdown', 'Pressure_Shutdown', 3600, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'pressureshutdownenabled': Channel('pressureshutdownenabled', 'Pressure_Shutdown_Enabled', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'pressurestartup': Channel('pressurestartup', 'Pressure_Startup', 3600, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'pressurestartupenabled': Channel('pressurestartupenabled', 'Pressure_Startup_Enabled', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'pressureswitchenabled': Channel('pressureswitchenabled', 'Pressure_Switch_Enabled', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'pressuretransducerenabled': Channel('pressuretransducerenabled', 'Pressure_Transducer_Enabled', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'rpmode': Channel('rpmode', 'RP_Mode', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'rppressure': Channel('rppressure', 'RP_Pressure', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'rptemperature': Channel('rptemperature', 'RP_Temperature', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'rptrip': Channel('rptrip', 'RP_Trip', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'rptubingpressure': Channel('rptubingpressure', 'RP_TubingPressure', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'runpermissive': Channel('runpermissive', 'Run_Permissive', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'spmode': Channel('spmode', 'SP_Mode', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'sppressure': Channel('sppressure', 'SP_Pressure', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'sptemperature': Channel('sptemperature', 'SP_Temperature', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'sptrip': Channel('sptrip', 'SP_Trip', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'spvoltage': Channel('spvoltage', 'SP_Voltage', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'startbutton': Channel('startbutton', 'Start_Button', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'startcommand': Channel('startcommand', 'Start_Command', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'startpermissive': Channel('startpermissive', 'Start_Permissive', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'stopcommand': Channel('stopcommand', 'Stop_Command', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tempshutdown': Channel('tempshutdown', 'Temp_Shutdown', 3600, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'tempshutdownenabled': Channel('tempshutdownenabled', 'Temp_Shutdown_Enabled', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tempstartup': Channel('tempstartup', 'Temp_Startup', 3600, self.sendtodbJSON, writeable=True, change_threshold=1.0, e300_param=False),
'tempstartupenabled': Channel('tempstartupenabled', 'Temp_Startup_Enabled', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'testmode': Channel('testmode', 'Test_Mode', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'tripenabledicurrentimbalance': Channel('tripenabledicurrentimbalance', 'TripEnabled_I_CurrentImbalance', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tripenabledigroundfault': Channel('tripenabledigroundfault', 'TripEnabled_I_GroundFault', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tripenabledijam': Channel('tripenabledijam', 'TripEnabled_I_Jam', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tripenabledilineloss': Channel('tripenabledilineloss', 'TripEnabled_I_LineLoss', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tripenablediovercurrent': Channel('tripenablediovercurrent', 'TripEnabled_I_Overcurrent', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tripenabledioverload': Channel('tripenabledioverload', 'TripEnabled_I_Overload', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tripenablediphaseloss': Channel('tripenablediphaseloss', 'TripEnabled_I_PhaseLoss', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tripenabledistall': Channel('tripenabledistall', 'TripEnabled_I_Stall', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tripenablediundercurrent': Channel('tripenablediundercurrent', 'TripEnabled_I_Undercurrent', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tripenablediunderload': Channel('tripenablediunderload', 'TripEnabled_I_Underload', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tripenablevoverfrequency': Channel('tripenablevoverfrequency', 'TripEnable_V_Overfrequency', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tripenablevovervoltage': Channel('tripenablevovervoltage', 'TripEnable_V_Overvoltage', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tripenablevphaserotation': Channel('tripenablevphaserotation', 'TripEnable_V_PhaseRotation', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tripenablevunderfrequency': Channel('tripenablevunderfrequency', 'TripEnable_V_Underfrequency', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tripenablevundervoltage': Channel('tripenablevundervoltage', 'TripEnable_V_Undervoltage', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tripenablevvoltageunbalance': Channel('tripenablevvoltageunbalance', 'TripEnable_V_VoltageUnbalance', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tripresetcmd': Channel('tripresetcmd', 'TripResetCmd', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'tripstatus': Channel('tripstatus', 'TripStatus', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'tripstatuscontrolint': Channel('tripstatuscontrolint', 'TripStatusControl_INT', 3600, self.sendtodb, writeable=False, change_threshold=1.0, e300_param=False, map_obj=e300_control),
'tripstatuscurrentint': Channel('tripstatuscurrentint', 'TripStatusCurrent_INT', 3600, self.sendtodb, writeable=False, change_threshold=1.0, e300_param=False, map_obj=e300_current),
'tripstatuspowerint': Channel('tripstatuspowerint', 'TripStatusPower_INT', 3600, self.sendtodb, writeable=False, change_threshold=1.0, e300_param=False, map_obj=e300_power),
'tripstatusvoltageint': Channel('tripstatusvoltageint', 'TripStatusVoltage_INT', 3600, self.sendtodb, writeable=False, change_threshold=1.0, e300_param=False, map_obj=e300_voltage),
'valoverloadtripcount': Channel('valoverloadtripcount', 'val_OverloadTripCount', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'valtripcount': Channel('valtripcount', 'val_TripCount', 3600, self.sendtodbJSON, writeable=False, change_threshold=1.0, e300_param=False),
'voltageok': Channel('voltageok', 'VoltageOK', 3600, self.sendtodbJSON, writeable=False, e300_param=False),
'warningenabledicurrentimbalanc': Channel('warningenabledicurrentimbalanc', 'WarningEnabled_I_CurrentImbalance', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'warningenabledigroundfault': Channel('warningenabledigroundfault', 'WarningEnabled_I_GroundFault', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'warningenabledijam': Channel('warningenabledijam', 'WarningEnabled_I_Jam', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'warningenabledilineloss': Channel('warningenabledilineloss', 'WarningEnabled_I_LineLoss', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'warningenablediovercurrent': Channel('warningenablediovercurrent', 'WarningEnabled_I_Overcurrent', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'warningenabledioverload': Channel('warningenabledioverload', 'WarningEnabled_I_Overload', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'warningenablediphaseloss': Channel('warningenablediphaseloss', 'WarningEnabled_I_PhaseLoss', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'warningenabledistall': Channel('warningenabledistall', 'WarningEnabled_I_Stall', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'warningenablediundercurrent': Channel('warningenablediundercurrent', 'WarningEnabled_I_Undercurrent', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'warningenablediunderload': Channel('warningenablediunderload', 'WarningEnabled_I_Underload', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'warningenablevoverfrequency': Channel('warningenablevoverfrequency', 'WarningEnable_V_Overfrequency', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'warningenablevovervoltage': Channel('warningenablevovervoltage', 'WarningEnable_V_Overvoltage', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'warningenablevphaserotation': Channel('warningenablevphaserotation', 'WarningEnable_V_PhaseRotation', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'warningenablevunderfrequency': Channel('warningenablevunderfrequency', 'WarningEnable_V_Underfrequency', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'warningenablevundervoltage': Channel('warningenablevundervoltage', 'WarningEnable_V_Undervoltage', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'warningenablevvoltageunbalance': Channel('warningenablevvoltageunbalance', 'WarningEnable_V_VoltageUnbalance', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'warningstatus': Channel('warningstatus', 'WarningStatus', 3600, self.sendtodbJSON, writeable=True, e300_param=False),
'warningstatuscontrolint': Channel('warningstatuscontrolint', 'WarningStatusControl_INT', 3600, self.sendtodb, writeable=True, change_threshold=1.0, e300_param=False, map_obj=e300_control),
'warningstatuscurrentint': Channel('warningstatuscurrentint', 'WarningStatusCurrent_INT', 3600, self.sendtodb, writeable=True, change_threshold=1.0, e300_param=False, map_obj=e300_current),
'warningstatuspowerint': Channel('warningstatuspowerint', 'WarningStatusPower_INT', 3600, self.sendtodb, writeable=True, change_threshold=1.0, e300_param=False, map_obj=e300_power),
'warningstatusvoltageint': Channel('warningstatusvoltageint', 'WarningStatusVoltage_INT', 3600, self.sendtodb, writeable=True, change_threshold=1.0, e300_param=False, map_obj=e300_voltage),
}
self.daemon = True
self.version = "9"
self.finished = threading.Event()
self.forceSend = False
threading.Thread.start(self)
def __init__(self, name=None, number=None, mac=None, Q=None, mcu=None, companyId=None, offset=None, mqtt=None, Nodes=None):
global addr, version
threading.Thread.__init__(self)
deviceBase.__init__(self, name=name, number=number, mac=mac, Q=Q, mcu=mcu, companyId=companyId, offset=offset, mqtt=mqtt, Nodes=Nodes)
# this is a required function for all drivers, its goal is to upload some piece of data
# about your device so it can be seen on the web
def register(self):
"""Register the driver."""
pass
self.daemon = True
self.version = version
self.device_address = addr
if os.path.exists('./plcaddr.json'):
with open('plcaddr.json', "rb") as addr_file:
data = json.loads(addr_file.read())
if data['plc_address']:
try:
socket.inet_aton(data['plc_address'])
addr = data['plc_address']
self.device_address = addr
print("USING {} AS PLC IP ADDRESS (FROM JSON)".format(addr))
except:
print("plc_address exists in plcaddr.json, but it's not a valid ip address")
else:
print("no plc_address in plcaddr.json")
else:
print("No stored plcaddr.json file. Let's create one...'")
with open("plcaddr.json", "wb") as addr_file:
json.dump({"plc_address": addr}, addr_file)
def run(self):
"""Actually run the driver."""
wait_sec = 30
for i in range(0, wait_sec):
print("ipp driver will start in {} seconds".format(wait_sec - i))
time.sleep(1)
logger.info("BOOM! Starting ipp driver...")
self.finished = threading.Event()
threading.Thread.start(self)
self.sendtodbJSON("plcipaddress", self.device_address, 0)
try:
self.setupChannels()
except:
print("Unable to initialize channels...")
traceback.print_exc()
self.e300_warning = ""
self.e300_trip = ""
# self.updateGPS()
public_ip_address = get_public_ip_address()
self.sendtodb('public_ip_address', public_ip_address, 0)
# this is a required function for all drivers, its goal is to upload some piece of data
# about your device so it can be seen on the web
def register(self):
self.channels["status"]["last_value"] = ""
send_loops = 0
watchdog_loops = 0
watchdog_check_after = 5000
while True:
if self.forceSend:
logger.warning("FORCE SEND: TRUE")
def run(self):
global channels
print("****************\n*************\nEXECUTING RUN\n********************\n****************")
self.runLoopStatus = ""
last_OK_state = 0
while True:
if len(channels) > 0:
try:
for i in channels:
channels[i].read()
runLoopStatus = i
time.sleep(0.25)
for c in CHANNELS:
v = c.read()
if c.check(v, self.forceSend):
self.sendtodb(c.mesh_name, c.value, 0)
if not (channels['tripstatuscurrentint'].last_value == "None"):
if not (self.e300_trip == channels['tripstatuscurrentint'].last_value):
self.e300_trip = channels['tripstatuscurrentint'].last_value
self.sendtodb("e300tripstatus", self.e300_trip, time.time())
elif not (channels['tripstatusvoltageint'].last_value == "None"):
if not (self.e300_trip == channels['tripstatusvoltageint'].last_value):
self.e300_trip = channels['tripstatusvoltageint'].last_value
self.sendtodb("e300tripstatus", self.e300_trip, time.time())
elif not (channels['tripstatuscontrolint'].last_value == "None"):
if not (self.e300_trip == channels['tripstatuscontrolint'].last_value):
self.e300_trip = channels['tripstatuscontrolint'].last_value
self.sendtodb("e300tripstatus", self.e300_trip, time.time())
elif not (channels['tripstatuspowerint'].last_value == "None"):
if not (self.e300_trip == channels['tripstatuspowerint'].last_value):
self.e300_trip = channels['tripstatuspowerint'].last_value
self.sendtodb("e300tripstatus", self.e300_trip, time.time())
else:
if not (self.e300_trip == "None"):
self.e300_trip = "None"
# self.sendtodb("e300tripstatus", self.e300_trip, time.time())
if self.forceSend:
if send_loops > 2:
logger.warning("Turning off forceSend")
self.forceSend = False
send_loops = 0
else:
send_loops += 1
if not (channels['warningstatuscurrentint'].last_value == "None"):
if not (self.e300_warning == channels['warningstatuscurrentint'].last_value):
self.e300_warning = channels['warningstatuscurrentint'].last_value
self.sendtodb("e300warningstatus", self.e300_warning, time.time())
elif not (channels['warningstatusvoltageint'].last_value == "None"):
if not (self.e300_warning == channels['warningstatusvoltageint'].last_value):
self.e300_warning = channels['warningstatusvoltageint'].last_value
self.sendtodb("e300warningstatus", self.e300_warning, time.time())
elif not (channels['warningstatuscontrolint'].last_value == "None"):
if not (self.e300_warning == channels['warningstatuscontrolint'].last_value):
self.e300_warning = channels['warningstatuscontrolint'].last_value
self.sendtodb("e300warningstatus", self.e300_warning, time.time())
elif not (channels['warningstatuspowerint'].last_value == "None"):
if not (self.e300_warning == channels['warningstatuspowerint'].last_value):
self.e300_warning = channels['warningstatuspowerint'].last_value
self.sendtodb("e300warningstatus", self.e300_warning, time.time())
else:
if not (self.e300_warning == "None"):
self.e300_warning = "None"
# self.sendtodb("e300warningstatus", self.e300_warning, time.time())
watchdog_loops += 1
if (watchdog_loops >= watchdog_check_after):
test_public_ip = get_public_ip_address()
if not test_public_ip == public_ip_address:
self.sendtodb('public_ip_address', test_public_ip, 0)
public_ip_address = test_public_ip
watchdog_loops = 0
time.sleep(10)
runLoopStatus = "Complete"
OK_state = 1
if not OK_state == last_OK_state:
self.sendtodbJSON("driver_ok", OK_state, 0)
last_OK_state = OK_state
time.sleep(10)
except Exception, e:
OK_state = 0
if not OK_state == last_OK_state:
self.sendtodbJSON("driver_ok", OK_state, 0)
last_OK_state = OK_state
sleep_timer = 30
print "Error during {0} of run loop: {1}\nWill try again in {2} seconds...".format(runLoopStatus, e, sleep_timer)
time.sleep(sleep_timer)
else:
print("Apparently no channels... length shows {0}".format(len(channels)))
self.setupChannels()
time.sleep(30)
def ipp_sync(self, name, value):
self.sendtodb("connected", "true", 0)
return True
def genericSet(self, name, value, id):
global channels
try:
print("Trying to set {} to {}".format(channels[name].tag, value))
return channels[name].write(value)
except Exception, e:
print("Exception during genericSet: {}".format(e))
def ipp_plcipaddress(self, name, value):
global addr
value_ascii = value.encode('ascii', 'ignore')
try:
socket.inet_aton(value_ascii)
addr = value_ascii
self.device_address = addr
with open("plcaddr.json", "wb") as addr_file:
json.dump({"plc_address": addr}, addr_file)
print("Set PLC IP Address to {}".format(addr))
self.sendtodb("plcipaddress", addr, 0)
return True
except Exception, e:
r = "Unable to set PLC IP address to {}: {}".format(value_ascii, e)
print(r)
return r
def ipp_sync(self, name, value):
"""Sync all data from the driver."""
self.sendtodb("connected", "true", 0)
return True

77
POCloud_Driver/maps.py Normal file
View File

@@ -0,0 +1,77 @@
map_e300_current = {
0: 'None',
1: 'Overload',
2: 'Phase Loss',
4: 'Ground Fault',
8: 'Stall',
16: 'Jam',
32: 'Underload',
64: 'Current Imbalance',
128: 'L1 Undercurrent',
256: 'L2 Undercurrent',
512: 'L3 Undercurrent',
1024: 'L1 Overcurrent',
2048: 'L2 Overcurrent',
4096: 'L3 Overcurrent',
8192: 'L1 Line Loss',
16384: 'L2 Line Loss',
32768: 'L3 Line Loss'
}
map_e300_voltage = {
0: 'None',
1: 'Undervoltage',
2: 'Overvoltage',
4: 'Voltage Unbalance',
8: 'Phase Rotation',
16: 'Overfrequency'
}
map_e300_control = {
0: 'None',
1: 'Test Trip',
2: 'DLX Trip',
4: 'PTC Trip',
8: 'Operator Station Trip',
16: 'Remote Trip',
32: 'Blocked Start Trip',
64: 'Hardware Fault Trip',
128: 'Config Trip',
256: 'Option Match Trip',
512: 'DLX FB Timeout Trip',
1024: 'Expansion Bus Trip',
2048: 'Reserved',
4096: 'Reserved',
8192: 'NVS Trip',
16384: 'Test Mode Trip'
}
map_e300_power = {
0: 'None',
1: 'Under kW',
2: 'Over kW',
4: 'Under kVAR Consumed',
8: 'Over kVAR Consumed',
16: 'Under kVAR Generated',
32: 'Over kVAR Generated',
64: 'Under kVA',
128: 'Over kVA',
256: 'Under PF Lag',
512: 'Over PF Lag',
1024: 'Under PF Lead',
2048: 'Over PF Lead'
}
map_device_status = {
1: "Startup",
2: "Not ready to start",
3: "Ready to start",
4: "Lost run permissive",
5: "Not able to restart - Overload Limit",
6: "Not able to restart - Trip Limit",
7: "Waiting to attempt restart",
8: "Waiting to attempt restart (Overload)",
9: "Running",
10: "User stopped",
11: "Waiting to start (Timer Mode)"
}

View File

@@ -1,119 +0,0 @@
from pycomm.ab_comm.clx import Driver as plcDriver
import sys
def readMicroTag(addr, tag):
addr = str(addr)
tag = str(tag)
c = plcDriver()
if c.open(addr, True):
try:
v = c.read_tag(tag)
# print(v)
return v
except Exception:
err = c.get_status()
c.close()
print "{} on reading {} from {}".format(err, tag, addr)
pass
c.close()
def getTagType(addr, tag):
addr = str(addr)
tag = str(tag)
c = plcDriver()
if c.open(addr, True):
try:
return c.read_tag(tag)[1]
except Exception:
err = c.get_status()
c.close()
print err
pass
c.close()
def write(addr, tag, val, t):
addr = str(addr)
tag = str(tag)
c = plcDriver()
if c.open(addr, True):
try:
wt = c.write_tag(tag, val, t)
return wt
except Exception:
err = c.get_status()
c.close()
print("Write Error: {} setting {} at {} to {} type {}".format(err, tag, addr, val, t))
return False
c.close()
def closeEnough(a, b):
return abs(a - b) <= 0.001
def writeMicroTag(addr, tag, val, handshake=None, handshake_val=None):
addr = str(addr)
tag = str(tag)
print("handshake: {}, handshake_val: {}".format(handshake, handshake_val))
chk_tag = tag
if not(handshake is None) and not(handshake == "None"):
chk_tag = str(handshake)
print("Handshake tag passed, using {}".format(chk_tag))
chk_val = val
if not (handshake_val is None) and not(handshake_val == "None"):
chk_val = handshake_val
print("Handshake value passed, using {}".format(chk_val))
attempts_allowed = 5
attempts = 1
while attempts <= attempts_allowed:
try:
attempts = attempts + 1
cv = readMicroTag(addr, tag)
print("Val Before Write: {}".format(cv))
if cv:
if cv[1] == "REAL":
val = float(val)
chk_val = float(chk_val)
else:
val = int(val)
chk_val = int(chk_val)
wt = write(addr, tag, val, cv[1])
if wt:
print("write: {}".format(wt))
chk = readMicroTag(addr, chk_tag)
if chk:
print("chk: {}, chk_val: {}".format(chk, chk_val))
if closeEnough(chk[0], chk_val):
return True
except Exception as e:
print e
return False
def readMicroTagList(addr, tList):
addr = str(addr)
c = plcDriver()
if c.open(addr, True):
vals = []
try:
for t in tList:
v = c.read_tag(t)
vals.append({"tag": t, "val": v[0], "type": v[1]})
# print(v)
# print("{0} - {1}".format(t, v))
except Exception:
err = c.get_status()
c.close()
print err
pass
c.close()
return vals
if __name__ == '__main__':
if len(sys.argv) > 2:
print(readMicroTag(sys.argv[1], sys.argv[2]))
else:
print ("Did not pass a target and tag name.")

View File

@@ -1,405 +0,0 @@
{"ID":null,"name":"Doe","first-name":"John","age":25,"hobbies":["reading","cinema",{"sports":["volley-ball","badminton"]}],"address":{}}
{
"1":{
"c":"ETHERNET/IP",
"b":"10.20.158.3",
"addresses":{
"300":{
"2-2":{
"bytary":null,
"vm":null,
"ct":"number",
"le":"16",
"grp":"3600",
"la":"",
"chn":"cfgspmtarget",
"un":"1",
"dn":"henryhyd",
"da":"300",
"lrt":1471892551.0022135,
"r":"0-20",
"a":"cfg_SPMTarget",
"c":"0",
"misc_u":"SPM",
"f":"1",
"mrt":"15",
"m":"none",
"m1ch":"2-2",
"s":"On",
"mv":"0",
"t":"int"
},
"2-3":{
"bytary":null,
"vm":{
},
"ct":"number",
"le":"16",
"grp":"3600",
"la":0,
"chn":"",
"un":"",
"dn":"M1",
"da":"300",
"lrt":1471974386.0297532,
"r":"0-1",
"a":"cmd_Run",
"c":"0",
"misc_u":"",
"f":"1",
"mrt":"1",
"m":"none",
"m1ch":"2-3",
"s":"On",
"mv":"0",
"t":"int"
},
"2-1":{
"bytary":null,
"vm":null,
"ct":"number",
"le":"16",
"grp":"3600",
"la":"",
"chn":"stsenginerunning",
"un":"1",
"dn":"henryhyd",
"da":"300",
"lrt":1468878718.76403,
"r":"0-1",
"a":"sts_EngineRunning",
"c":"0",
"misc_u":"",
"f":"1",
"mrt":"1",
"m":"none",
"m1ch":"2-1",
"s":"On",
"mv":"0",
"t":"int"
},
"2-6":{
"bytary":null,
"vm":null,
"ct":"number",
"le":"16",
"grp":"3600",
"la":"",
"chn":"",
"un":"",
"dn":"M1",
"da":"300",
"lrt":1471892533.1567128,
"r":"0-1",
"a":"cmd_EngineStart",
"c":"0",
"misc_u":"",
"f":"1",
"mrt":"1",
"m":"none",
"m1ch":"2-6",
"s":"On",
"mv":"0",
"t":"int"
},
"2-7":{
"bytary":null,
"vm":null,
"ct":"number",
"le":"16",
"grp":"3600",
"la":"",
"chn":"",
"un":"",
"dn":"M1",
"da":"300",
"lrt":1471892513.008441,
"r":"0-1",
"a":"cmd_EngineStop",
"c":"0",
"misc_u":"",
"f":"1",
"mrt":"1",
"m":"none",
"m1ch":"2-7",
"s":"On",
"mv":"0",
"t":"int"
},
"2-4":{
"bytary":null,
"vm":null,
"ct":"number",
"le":"16",
"grp":"3600",
"la":"",
"chn":"",
"un":"",
"dn":"M1",
"da":"300",
"lrt":1471892514.166909,
"r":"0-150",
"a":"val_EngineOilPressure",
"c":"0",
"misc_u":" PSI",
"f":"1",
"mrt":"10",
"m":"none",
"m1ch":"2-4",
"s":"On",
"mv":"0",
"t":"int"
},
"2-5":{
"bytary":null,
"vm":null,
"ct":"number",
"le":"16",
"grp":"3600",
"la":"",
"chn":"",
"un":"",
"dn":"M1",
"da":"300",
"lrt":1471892558.0009384,
"r":"0-500",
"a":"time_EngineHourMeter",
"c":"0",
"misc_u":"Hours",
"f":"1",
"mrt":"60",
"m":"none",
"m1ch":"2-5",
"s":"On",
"mv":"0",
"t":"int"
},
"2-8":{
"bytary":null,
"vm":null,
"ct":"number",
"le":"16",
"grp":"3600",
"la":"",
"chn":"",
"un":"",
"dn":"M1",
"da":"300",
"lrt":1471892537.8492658,
"r":"0-1",
"a":"cmd_Start",
"c":"0",
"misc_u":"",
"f":"1",
"mrt":"1",
"m":"none",
"m1ch":"2-8",
"s":"On",
"mv":"0",
"t":"int"
},
"2-9":{
"bytary":null,
"vm":null,
"ct":"number",
"le":"16",
"grp":"3600",
"la":"",
"chn":"",
"un":"",
"dn":"M1",
"da":"300",
"lrt":1471892538.997888,
"r":"0-1",
"a":"cmd_Stop",
"c":"0",
"misc_u":"",
"f":"1",
"mrt":"1",
"m":"none",
"m1ch":"2-9",
"s":"On",
"mv":"0",
"t":"int"
},
"2-14":{
"bytary":null,
"vm":{
"1":"Starting",
"0":"Stopped",
"3":"Stopping",
"2":"Running"
},
"ct":"number",
"le":"16",
"grp":"3600",
"la":"",
"chn":"stsengineint",
"un":"1",
"dn":"henryhyd",
"da":"300",
"lrt":1471892540.141906,
"r":"0-5",
"a":"sts_EngineINT",
"c":"0",
"misc_u":"",
"f":"1",
"mrt":"10",
"m":"none",
"m1ch":"2-14",
"s":"On",
"mv":"0",
"t":"int"
},
"2-10":{
"bytary":null,
"vm":null,
"ct":"number",
"le":"16",
"grp":"3500",
"la":0,
"chn":"automode",
"un":"1",
"dn":"ipp",
"da":"300",
"lrt":1471974396.231401,
"r":"0-1",
"a":"Auto_Mode",
"c":"0",
"misc_u":"",
"f":"1",
"mrt":"60",
"m":"none",
"m1ch":"2-10",
"s":"On",
"mv":"0",
"t":"int"
},
"2-11":{
"bytary":null,
"vm":null,
"ct":"number",
"le":"16",
"grp":"86400",
"la":0.0,
"chn":"cfgcflasetting",
"un":"1",
"dn":"ipp",
"da":"300",
"lrt":1471974397.360571,
"r":"0-200",
"a":"cfg_C_FLASetting",
"c":"0",
"misc_u":"A",
"f":"1",
"mrt":"60",
"m":"none",
"m1ch":"2-11",
"s":"On",
"mv":"0",
"t":"int"
},
"2-12":{
"bytary":null,
"vm":null,
"ct":"number",
"le":"16",
"grp":"86400",
"la":60,
"chn":"cfgcleartripcountafter",
"un":"1",
"dn":"ipp",
"da":"300",
"lrt":1471974398.501199,
"r":"0-3600",
"a":"cfg_ClearTripCountAfter",
"c":"0",
"misc_u":"sec",
"f":"1",
"mrt":"60",
"m":"none",
"m1ch":"2-12",
"s":"On",
"mv":"0",
"t":"int"
},
"2-13":{
"bytary":null,
"vm":null,
"ct":"number",
"le":"16",
"grp":"86400",
"la":0,
"chn":"cfggfgroundfaultinhibittime",
"un":"1",
"dn":"ipp",
"da":"300",
"lrt":1471974399.6202452,
"r":"0-100",
"a":"cfg_GF_GroundFaultInhibitTime",
"c":"0",
"misc_u":"sec",
"f":"1",
"mrt":"60",
"m":"none",
"m1ch":"2-13",
"s":"On",
"mv":"0",
"t":"int"
}
}
},
"f":"Off",
"p":"",
"s":"1"
},
"2":{
"c":"ETHERNET/IP",
"b":"10.20.158.3",
"addresses":{
"300":{
"4-1":{
"bytary":null,
"vm":{
"11":"Waiting to start (Timer Mode)",
"10":"User stopped",
"1":"Startup",
"3":"Ready to start",
"2":"Not ready to start",
"5":"Not able to restart - Overload Limit",
"4":"Lost run permissive",
"7":"Waiting to attempt restart",
"6":"Not able to restart - Trip Limit",
"9":"Running",
"8":"Waiting to attempt restart (Overload)"
},
"ct":"number",
"le":"16",
"grp":"3600",
"la":0,
"chn":"devicestatus",
"un":"1",
"dn":"M1",
"da":"300",
"lrt":1471974334.856273,
"r":"",
"a":"Device_Status_INT",
"c":"0",
"misc_u":"",
"f":"1",
"mrt":"5",
"m":"none",
"m1ch":"4-1",
"s":"On",
"mv":"0",
"t":"int"
}
}
},
"f":"Off",
"p":"",
"s":"1"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,115 +0,0 @@
modbusMap = {
'1': {
'c': u'ETHERNET/IP',
'b': u'10.20.4.5',
'addresses': {
u'300': {
u'2-3': {
u'bytary': None,
u'vm': None,
u'ct': u'number',
u'le': u'16',
u'grp': u'3600',
u'la': 0,
u'chn':
u'automode',
u'un': u'1',
u'dn': u'M1',
u'da': u'300',
u'lrt': 1468595216.996952,
u'r': u'0-1',
u'a': u'Auto_Mode',
u'c': u'0.5',
u'misc_u': u'',
u'f': u'1',
u'mrt': u'60',
u'm': u'none',
'm1ch': u'2-3',
u's': u'On',
u'mv': u'0',
u't': u'int'
}, u'2-1': {
u'bytary': None,
u'vm': None,
u'ct': u'number',
u'le': u'16',
u'grp': u'86400',
u'la': None,
u'chn': u'cfggfgroundfaultinhibittime',
u'un': u'1',
u'dn': u'M1',
u'da': u'300',
u'lrt': u'0',
u'r': u'0-100',
u'a': u'cfg_GF_GroundFaultInhibitTime',
u'c': u'0',
u'misc_u': u'sec',
u'f': u'1',
u'mrt': u'60',
u'm': u'none',
'm1ch': u'2-1',
u's': u'On',
u'mv': u'0',
u't': u'int'
}, u'2-4': {
u'bytary': None,
u'vm': None,
u'ct': u'number',
u'le': u'16',
u'grp': u'86400',
u'la': 10.0,
u'chn': u'cfgcflasetting',
u'un': u'1',
u'dn': u'M1',
u'da': u'300',
u'lrt': 1468595218.131659,
u'r': u'0-200',
u'a': u'cfg_C_FLASetting',
u'c': u'0.5',
u'misc_u': u'A',
u'f': u'1',
u'mrt': u'60',
u'm': u'none',
'm1ch': u'2-4',
u's': u'On',
u'mv': u'0',
u't': u'int'
}, u'2-5': {
u'bytary': None,
u'vm': None,
u'ct': u'number',
u'le': u'16',
u'grp': u'86400',
u'la': 60,
u'chn': u'cfgcleartripcountafter',
u'un': u'1',
u'dn': u'M1',
u'da': u'300',
u'lrt': 1468595210.837538,
u'r': u'0-86400',
u'a': u'cfg_ClearTripCountAfter',
u'c': u'0',
u'misc_u': u'sec',
u'f': u'1',
u'mrt': u'60',
u'm': u'none',
'm1ch': u'2-5',
u's': u'On',
u'mv': u'0',
u't': u'int'
}
}
},
'f': u'Off',
'p': u'',
's': u'1'
},
'2': {
'c': u'none',
'b': u'9600',
'addresses': {},
'f': u'Off',
'p': u'none',
's': u'1'
}
}

View File

@@ -1,348 +0,0 @@
import xml.etree.ElementTree as ET
tree = ET.parse('tags.xml')
root = tree.getroot()
channels = {}
unreadable_channels = {}
ignored_channels = {}
writeable_channels = {}
ignore_tags = [
"cmd_Run",
"cmd_TimerRun",
"DH_DischargePressure",
"DH_DischargeTemperature",
"DH_VibrationX",
"DH_VibrationY",
"DH_WindingTemperature",
"DigitalInput_Status_0",
"DigitalInput_Status_1",
"DigitalInput_Status_2",
"DigitalInput_Status_3",
"DigitalInput_Status_4",
"DigitalInput_Status_5",
"E300_Config_Buffer",
"E300_OUTPUT_NUMBER",
"E300_OUTPUT_SET_CORRECTLY",
"E300_Output_Enable",
"E300_Output_Toggled",
"E300_SCAN_RATE",
"Enable_IO_Read",
"Pressure_OOT_Scans",
"Pressure_OOT_Seconds",
"Restart_Allowed",
"Restart_Command",
"Run_Time",
"Shutdown_Time"
"Start_Button",
"Start_Time",
"Start_Time_Set",
"sts_TimerRunTimeSet",
"sts_TimerCycleActive",
"sts_TimerWaitTimeSet",
"sts_TripCountIncreased",
"time_CurrentTime",
"time_TimerRunTime",
"time_TimerWaitTime",
"Time_Until_Startup",
"timer_RunTimeLeft",
"timer_WaitTimeLeft",
"TripResetWriteStatus",
"cfg_I_L1LossTripDelay", # Individual Line tags handled by generic Line tags
"cfg_I_L1_OvercurrentTripDelay",
"cfg_I_L1_OvercurrentTripLevel",
"cfg_I_L1_OvercurrentWarningLevel",
"cfg_I_L1_UndercurrentTripDelay",
"cfg_I_L1_UndercurrentTripLevel",
"cfg_I_L1_UndercurrentWarningLevel",
"cfg_I_L2LossTripDelay",
"cfg_I_L2_OvercurrentTripDelay",
"cfg_I_L2_OvercurrentTripLevel",
"cfg_I_L2_OvercurrentWarningLevel",
"cfg_I_L2_UndercurrentTripDelay",
"cfg_I_L2_UndercurrentTripLevel",
"cfg_I_L2_UndercurrentWarningLevel",
"cfg_I_L3LossTripDelay",
"cfg_I_L3_OvercurrentTripDelay",
"cfg_I_L3_OvercurrentTripLevel",
"cfg_I_L3_OvercurrentWarningLevel",
"cfg_I_L3_UndercurrentTripDelay",
"cfg_I_L3_UndercurrentTripLevel",
"cfg_I_L3_UndercurrentWarningLevel",
"cfg_I_TripEnableCurrent", # Enables get build by the enable bits
"cfg_I_WarningEnableCurrent",
"cfg_P_OverApparentPowerInhibitTime", # We're not going to worry about the power configuration for this panel
"cfg_P_OverApparentPowerTripDelay",
"cfg_P_OverApparentPowerTripLevel",
"cfg_P_OverApparentPowerWarningLevel",
"cfg_P_OverPowerFactorLagInhibitTime",
"cfg_P_OverPowerFactorLagTripDelay",
"cfg_P_OverPowerFactorLagTripLevel",
"cfg_P_OverPowerFactorLagWarningLevel",
"cfg_P_OverPowerFactorLeadInhibitTime",
"cfg_P_OverPowerFactorLeadTripDelay",
"cfg_P_OverPowerFactorLeadTripLevel",
"cfg_P_OverPowerFactorLeadWarningLevel",
"cfg_P_OverReactiveConsumedInhibitTime",
"cfg_P_OverReactiveConsumedTripDelay",
"cfg_P_OverReactiveConsumedTripLevel",
"cfg_P_OverReactiveConsumedWarningLevel",
"cfg_P_OverReactiveGeneratedInhibitTime",
"cfg_P_OverReactiveGeneratedTripDelay",
"cfg_P_OverReactiveGeneratedTripLevel",
"cfg_P_OverReactiveGeneratedWarningLevel",
"cfg_P_OverRealPowerInhibitTime",
"cfg_P_OverRealPowerTripDelay",
"cfg_P_OverRealPowerTripLevel",
"cfg_P_OverRealPowerWarningLevel",
"cfg_P_TripEnablePower",
"cfg_P_UnderApparentPowerInhibitTime",
"cfg_P_UnderApparentPowerTripDelay",
"cfg_P_UnderApparentPowerTripLevel",
"cfg_P_UnderApparentPowerWarningLevel",
"cfg_P_UnderPowerFactorLagInhibitTime",
"cfg_P_UnderPowerFactorLagTripDelay",
"cfg_P_UnderPowerFactorLagTripLevel",
"cfg_P_UnderPowerFactorLagWarningLevel",
"cfg_P_UnderPowerFactorLeadInhibitTime",
"cfg_P_UnderPowerFactorLeadTripDelay",
"cfg_P_UnderPowerFactorLeadTripLevel",
"cfg_P_UnderPowerFactorLeadWarningLevel",
"cfg_P_UnderReactiveConsumedInhibitTime",
"cfg_P_UnderReactiveConsumedTripDelay",
"cfg_P_UnderReactiveConsumedTripLevel",
"cfg_P_UnderReactiveConsumedWarningLevel",
"cfg_P_UnderReactiveGeneratedInhibitTime",
"cfg_P_UnderReactiveGeneratedTripDelay",
"cfg_P_UnderReactiveGeneratedTripLevel",
"cfg_P_UnderReactiveGeneratedWarningLevel",
"cfg_P_UnderRealPowerInhibitTime",
"cfg_P_UnderRealPowerTripDelay",
"cfg_P_UnderRealPowerTripLevel",
"cfg_P_UnderRealPowerWarningLevel",
"cfg_P_WarningEnablePower",
"cfg_V_TripEnableVoltage",
"cfg_V_WarningEnableVoltage"
]
writeable_tags = [
"cfg_C_FLASetting",
"cfg_C_TripEnableControl",
"cfg_C_WarningEnableControl",
"cfg_ClearTripCountAfter",
"cfg_GF_GroundFaultInhibitTime",
"cfg_GF_GroundFaultTripDelay",
"cfg_GF_GroundFaultTripLevel",
"cfg_GF_GroundFaultWarningDelay",
"cfg_GF_GroundFaultWarningLevel",
"cfg_I_CTPrimary",
"cfg_I_CTSecondary",
"cfg_I_CurrentImbalanceInhibitTime",
"cfg_I_CurrentImbalanceTripDelay",
"cfg_I_CurrentImbalanceTripLevel",
"cfg_I_CurrentImbalanceWarningLevel",
"cfg_I_JamInhibitTime",
"cfg_I_JamTripDelay",
"cfg_I_JamWarningLevel",
"cfg_I_LineLossInhibitTime",
"cfg_I_LineLossTripDelay",
"cfg_I_OvercurrentInhibitTime",
"cfg_I_OvercurrentTripDelay",
"cfg_I_OvercurrentTripLevel",
"cfg_I_OvercurrentWarningLevel",
"cfg_I_StallEnabledTime",
"cfg_I_StallTripLevel",
"cfg_I_UndercurrentInhibitTime",
"cfg_I_UndercurrentTripDelay",
"cfg_I_UndercurrentTripLevel",
"cfg_I_UndercurrentWarningLevel",
"cfg_I_UnderloadInhibitTime",
"cfg_I_UnderloadTripDelay",
"cfg_I_UnderloadTripLevel",
"cfg_I_UnderloadWarningLevel",
"cfg_OverloadTripCountLimit",
"cfg_PL_PhaseLossInhibitTime",
"cfg_PL_PhaseLossTripDelay",
"cfg_READ",
"cfg_SpecificGravity",
"cfg_TCU_TripClass",
"cfg_TimerModeEnabled",
"cfg_TimerRunTime",
"cfg_TimerWaitTime",
"cfg_TripCountLimit",
"cfg_V_OverfrequencyInhibitTime",
"cfg_V_OverfrequencyTripDelay",
"cfg_V_OverfrequencyTripLevel",
"cfg_V_OverfrequencyWarningLevel",
"cfg_V_OvervoltageInhibitTime",
"cfg_V_OvervoltageTripDelay",
"cfg_V_OvervoltageTripLevel",
"cfg_V_OvervoltageWarningLevel",
"cfg_V_PTPrimary",
"cfg_V_PTSecondary",
"cfg_V_PhaseRotationInhibitTime",
"cfg_V_PhaseRotationTripType",
"cfg_V_UnderfrequencyInhibitTime",
"cfg_V_UnderfrequencyTripDelay",
"cfg_V_UnderfrequencyTripLevel",
"cfg_V_UnderfrequencyWarningLevel",
"cfg_V_UndervoltageInhibitTime",
"cfg_V_UndervoltageTripDelay",
"cfg_V_UndervoltageTripLevel",
"cfg_V_UndervoltageWarningLevel",
"cfg_V_VoltageImbalanceInhibitTime",
"cfg_V_VoltageImbalanceTripDelay",
"cfg_V_VoltageImbalanceTripLevel",
"cfg_V_VoltageImbalanceWarningLevel",
"cfg_V_VoltageMode",
"cfg_WRITE",
"Downtime_Time_Parameter",
"Downtime_Time_Parameter_OL",
"Downhole_Tool_Enabled",
"Pressure_Alarm_Delay",
"Pressure_Alarm_Startup_Delay",
"Pressure_EU_Max",
"Pressure_EU_Min",
"Pressure_Hi_SP",
"Pressure_Lo_SP",
"Pressure_Shutdown",
"Pressure_Shutdown_Enabled",
"Pressure_Startup",
"Pressure_Startup_Enabled",
"Pressure_Switch_Enabled",
"Pressure_Transducer_Enabled",
"Start_Command",
"Stop_Command",
"Temp_Shutdown",
"Temp_Shutdown_Enabled",
"Temp_Startup",
"Temp_Startup_Enabled",
"TripEnable_V_Overfrequency",
"TripEnable_V_Overvoltage",
"TripEnable_V_PhaseRotation",
"TripEnable_V_Underfrequency",
"TripEnable_V_Undervoltage",
"TripEnable_V_VoltageUnbalance",
"TripEnabled_I_CurrentImbalance",
"TripEnabled_I_GroundFault",
"TripEnabled_I_Jam",
"TripEnabled_I_LineLoss",
"TripEnabled_I_Overcurrent",
"TripEnabled_I_Overload",
"TripEnabled_I_PhaseLoss",
"TripEnabled_I_Stall",
"TripEnabled_I_Undercurrent",
"TripEnabled_I_Underload",
"TripResetCmd",
"WarningEnable_V_Overfrequency",
"WarningEnable_V_Overvoltage",
"WarningEnable_V_PhaseRotation",
"WarningEnable_V_Underfrequency",
"WarningEnable_V_Undervoltage",
"WarningEnable_V_VoltageUnbalance",
"WarningEnabled_I_CurrentImbalance",
"WarningEnabled_I_GroundFault",
"WarningEnabled_I_Jam",
"WarningEnabled_I_LineLoss",
"WarningEnabled_I_Overcurrent",
"WarningEnabled_I_Overload",
"WarningEnabled_I_PhaseLoss",
"WarningEnabled_I_Stall",
"WarningEnabled_I_Undercurrent",
"WarningEnabled_I_Underload",
]
for child in root:
try:
tagName = child[1].text
tagType = child[2].text
struct = {
'tag': tagName,
"last_value": "",
"data_type": tagType,
"change_amount": .5,
"last_time_uploaded": 0,
"max_time_between_uploads": 3600
}
if tagName in writeable_tags:
struct['read_only'] = False
else:
struct['read_only'] = True
if tagName[0:3] == "cfg":
struct['max_time_between_uploads'] = 86400
chName = tagName.replace("_", "") # Channel names cannot have underscores
chName = chName.lower() # Channel names should all start wth a lowercase letter
if len(chName) > 30:
chName = chName[0:30]
if tagName not in ignore_tags:
if tagType == "BOOL":
struct['change_amount'] = None
channels[chName] = struct
elif tagType == "REAL" or tagType[-3:] == "INT":
channels[chName] = struct
else:
unreadable_channels[chName] = struct
else:
ignored_channels[chName] = struct
if struct['read_only'] is False:
writeable_channels[chName] = struct
except Exception, e:
print "oops: {}".format(e)
with open('ipp_channels_setup.py', 'wb') as txtFile:
txtFile.write("import pickle\r\r")
txtFile.write("channels = {\r")
for x in sorted(channels):
c = channels[x]
txtFile.write("\t'{}': {{\r".format(x))
txtFile.write("\t\t'data_type': '{}',\r".format(c['data_type']))
txtFile.write("\t\t'change_amount': {},\r".format(c['change_amount']))
txtFile.write("\t\t'max_time_between_uploads': {},\r".format(c['max_time_between_uploads']))
txtFile.write("\t\t'tag': '{}',\r".format(c['tag']))
txtFile.write("\t\t'last_time_uploaded': {},\r".format(c['last_time_uploaded']))
txtFile.write("\t\t'last_value': '{}',\r".format(c['last_value']))
txtFile.write("\t},\r")
txtFile.write("}\r")
txtFile.write("\rwith open('ipp_channels.p', 'wb') as ch_f:\r")
txtFile.write("\tpickle.dump(channels, ch_f)\r\r")
with open('channels.txt', 'wb') as ch_txt:
for x in sorted(channels):
c = channels[x]
rw = 'read only'
if c['read_only'] is False:
rw = "WRITEABLE"
ch_txt.write('[] - {} - {} - {}\r'.format(x, c['data_type'], rw))
print("UNREADABLE CHANNELS: ")
for y in sorted(unreadable_channels):
print("{} - {}".format(unreadable_channels[y]['data_type'], y))
print("")
print("")
print("")
print("IGNORED CHANNELS: ")
for z in sorted(ignored_channels):
print("{} - {}".format(z, ignored_channels[z]['data_type']))
with open('writeFunctions.txt', 'wb') as wftxt:
for a in sorted(writeable_channels):
c = writeable_channels[a]
wftxt.write("def ipp_{0}(self, name, value):\r".format(a.replace("_", "").lower()))
wftxt.write("\tprint('trying to set {0} to {{}}'.format(value))\r".format(c['tag']))
if c['data_type'] == 'REAL':
wftxt.write("\treturn u800.writeMicroTag(addr, '{0}', float(value))\r".format(c['tag']))
elif (c['data_type'] == 'BOOL') or (c['data_type'][-3:] == "INT"):
wftxt.write("\treturn u800.writeMicroTag(addr, '{0}', int(value))\r".format(c['tag']))
else:
print("!!!! DIDNT WORK FOR {0}".format(c))
wftxt.write("\r")

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +0,0 @@
import pickle
import json
modbus_map = pickle.load(open('modbusMap.p', 'rb'))
with open('modbusMap.json', 'w') as fp:
json.dump(modbus_map, fp)

View File

@@ -0,0 +1,51 @@
"""Utility functions for the driver."""
import socket
import struct
def get_public_ip_address():
"""Find the public IP Address of the host device."""
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
ip = s.getsockname()[0]
s.close()
return ip
def int_to_float16(int_to_convert):
"""Convert integer into float16 representation."""
bin_rep = ('0' * 16 + '{0:b}'.format(int_to_convert))[-16:]
sign = 1.0
if int(bin_rep[0]) == 1:
sign = -1.0
exponent = float(int(bin_rep[1:6], 2))
fraction = float(int(bin_rep[6:17], 2))
if exponent == float(0b00000):
return sign * 2 ** -14 * fraction / (2.0 ** 10.0)
elif exponent == float(0b11111):
if fraction == 0:
return sign * float("inf")
else:
return float("NaN")
else:
frac_part = 1.0 + fraction / (2.0 ** 10.0)
return sign * (2 ** (exponent - 15)) * frac_part
def ints_to_float(int1, int2):
"""Convert 2 registers into a floating point number."""
mypack = struct.pack('>HH', int1, int2)
f = struct.unpack('>f', mypack)
print("[{}, {}] >> {}".format(int1, int2, f[0]))
return f[0]
def degf_to_degc(temp_f):
"""Convert deg F to deg C."""
return (temp_f - 32.0) * (5.0/9.0)
def degc_to_degf(temp_c):
"""Convert deg C to deg F."""
return temp_c * 1.8 + 32.0

File diff suppressed because one or more lines are too long