68 lines
2.4 KiB
Plaintext
68 lines
2.4 KiB
Plaintext
def getStatusColor():
|
|
# Check PLC statuses:
|
|
devices = system.device.listDevices()
|
|
for device in range(devices.getRowCount()):
|
|
if devices.getValueAt(device, "Enabled") and devices.getValueAt(device, "State") <> "Connected":
|
|
return "#F00"
|
|
# Check Database statuses:
|
|
databases = system.db.getConnections()
|
|
for database in range(databases.getRowCount()):
|
|
if databases.getValueAt(database, "Status") <> "Valid":
|
|
return "#00F"
|
|
# Everything is okay:
|
|
return "#0F0"
|
|
|
|
|
|
def getStatusTooltip():
|
|
tooltip = ["Connection Status", ""]
|
|
# Check PLC statuses:
|
|
devices = system.device.listDevices()
|
|
devices = system.dataset.sort(devices, "Name")
|
|
for device in range(devices.getRowCount()):
|
|
name = devices.getValueAt(device, "Name")
|
|
status = devices.getValueAt(device, "State")
|
|
tooltip.append(name+": "+status)
|
|
# Check Database statuses:
|
|
databases = system.db.getConnections()
|
|
databases = system.dataset.sort(databases, "Name")
|
|
for database in range(databases.getRowCount()):
|
|
name = databases.getValueAt(database, "Name")
|
|
status = databases.getValueAt(database, "Status")
|
|
if status == "Valid":
|
|
status = "Connected"
|
|
tooltip.append(name+": "+status)
|
|
# Return tooltip:
|
|
return "<br>".join(tooltip)
|
|
|
|
def getFireAlarm():
|
|
# Check PLC:
|
|
paths = []
|
|
devices = system.device.listDevices()
|
|
for device in range(devices.getRowCount()):
|
|
if devices.getValueAt(device, "Enabled") and devices.getValueAt(device, "State") == "Connected":
|
|
path = devices.getValueAt(device, "Name")
|
|
paths.append(path + "/" + path + "/Alarms/FireAlarm")
|
|
# Read values:
|
|
return max(v.value for v in system.tag.readBlocking(paths) if v.quality.isGood())
|
|
|
|
def getPowerSaveMin():
|
|
# Check PLC:
|
|
paths = []
|
|
devices = system.device.listDevices()
|
|
for device in range(devices.getRowCount()):
|
|
if devices.getValueAt(device, "Enabled") and devices.getValueAt(device, "State") == "Connected":
|
|
path = devices.getValueAt(device, "Name")
|
|
paths.append(path + "/" + path + "/PowerSaveMin")
|
|
# Read values:
|
|
return min(v.value for v in system.tag.readBlocking(paths) if v.quality.isGood())
|
|
|
|
def setPowerSaveMin(value):
|
|
# Check PLC:
|
|
paths = []
|
|
devices = system.device.listDevices()
|
|
for device in range(devices.getRowCount()):
|
|
if devices.getValueAt(device, "Enabled") and devices.getValueAt(device, "State") == "Connected":
|
|
path = devices.getValueAt(device, "Name")
|
|
paths.append(path + "/" + path + "/PowerSaveMin")
|
|
# Write values:
|
|
system.tag.writeBlocking(paths, [value]*len(paths)) |