Commit 10fe7b30 authored by joao-santos's avatar joao-santos

[Updated] Add 9430 to NHR project

parent 3b3c8ed8
......@@ -6,7 +6,7 @@ from UtilitiesRei.IPFinder import IPFinder
class controlInterface:
def __init__(self):
self.__listIp = ['192.168.0.150']
self.__listIp = ['192.168.0.150', '192.168.0.151']
self.__listUsedIp = []
self.__nhr9410 = []
self.__nhr9430 = []
......
{
"__inputs": [],
"__requires": [
{
"type": "panel",
"id": "geeksrus-mqtt-panel",
"name": "MQTT panel",
"version": "1.0.7"
},
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "7.5.3"
},
{
"type": "panel",
"id": "timeseries",
"name": "Time series",
"version": ""
}
],
"annotations": {
"list": [
{
......@@ -16,7 +37,7 @@
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": 1,
"id": null,
"links": [],
"panels": [
{
......@@ -27,7 +48,7 @@
},
"gridPos": {
"h": 3,
"w": 3,
"w": 4,
"x": 0,
"y": 0
},
......@@ -90,7 +111,88 @@
],
"timeFrom": null,
"timeShift": null,
"title": "NHR Enable",
"title": "NHR Enable 9410",
"type": "geeksrus-mqtt-panel",
"value": "1",
"viewModel": {
"maxValue": "100",
"minValue": "0",
"step": "1",
"text": "Enable"
}
},
{
"datasource": null,
"fieldConfig": {
"defaults": {},
"overrides": []
},
"gridPos": {
"h": 3,
"w": 4,
"x": 4,
"y": 0
},
"id": 14,
"mode": "Button",
"model": {
"maxValue": 100,
"minValue": 0,
"offValue": "false",
"onValue": "true",
"step": 1,
"text": "Enable"
},
"mqttAuth": "None",
"mqttPassword": "",
"mqttProtocol": "wss",
"mqttServer": "broker.hivemq.com",
"mqttServerPort": "8884/mqtt",
"mqttTopicPublish": "labrei-nhr-sub/9430/enableOutput",
"mqttTopicQuery": "",
"mqttTopicSubscribe": "labrei-nhr-pub",
"mqttUser": "",
"pluginVersion": "7.5.3",
"targets": [
{
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"value"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"timeFrom": null,
"timeShift": null,
"title": "NHR Enable 9430",
"type": "geeksrus-mqtt-panel",
"value": "1",
"viewModel": {
......@@ -108,8 +210,8 @@
},
"gridPos": {
"h": 3,
"w": 3,
"x": 3,
"w": 4,
"x": 8,
"y": 0
},
"id": 8,
......@@ -171,7 +273,7 @@
],
"timeFrom": null,
"timeShift": null,
"title": "NHR Disable",
"title": "NHR Disable 9410",
"type": "geeksrus-mqtt-panel",
"value": "0",
"viewModel": {
......@@ -189,10 +291,91 @@
},
"gridPos": {
"h": 3,
"w": 7,
"x": 6,
"w": 4,
"x": 12,
"y": 0
},
"id": 15,
"mode": "Button",
"model": {
"maxValue": 100,
"minValue": 0,
"offValue": "false",
"onValue": "true",
"step": 1,
"text": "Disable"
},
"mqttAuth": "None",
"mqttPassword": "",
"mqttProtocol": "wss",
"mqttServer": "broker.hivemq.com",
"mqttServerPort": "8884/mqtt",
"mqttTopicPublish": "labrei-nhr-sub/9430/enableOutput",
"mqttTopicQuery": "",
"mqttTopicSubscribe": "labrei-nhr-pub",
"mqttUser": "",
"pluginVersion": "7.5.3",
"targets": [
{
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"value"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"timeFrom": null,
"timeShift": null,
"title": "NHR Disable 9430",
"type": "geeksrus-mqtt-panel",
"value": "0",
"viewModel": {
"maxValue": "100",
"minValue": "0",
"step": "1",
"text": "Disable"
}
},
{
"datasource": null,
"fieldConfig": {
"defaults": {},
"overrides": []
},
"gridPos": {
"h": 3,
"w": 7,
"x": 0,
"y": 3
},
"id": 9,
"mode": "Text",
"model": {
......@@ -252,16 +435,16 @@
],
"timeFrom": null,
"timeShift": null,
"title": "NHR Set Voltage",
"title": "NHR Set Voltage 9410",
"type": "geeksrus-mqtt-panel",
"value": {
"type": "Buffer",
"data": [
110,
117,
108,
108
],
"type": "Buffer"
]
},
"viewModel": {
"maxValue": "100",
......@@ -279,8 +462,97 @@
"gridPos": {
"h": 3,
"w": 7,
"x": 13,
"y": 0
"x": 7,
"y": 3
},
"id": 16,
"mode": "Text",
"model": {
"maxValue": 100,
"minValue": 0,
"offValue": "false",
"onValue": "true",
"step": 1,
"text": "Send"
},
"mqttAuth": "None",
"mqttPassword": "",
"mqttProtocol": "wss",
"mqttServer": "broker.hivemq.com",
"mqttServerPort": "8884/mqtt",
"mqttTopicPublish": "labrei-nhr-sub/9430/setCurrent",
"mqttTopicQuery": "",
"mqttTopicSubscribe": "labrei-nhr-pub",
"mqttUser": "",
"pluginVersion": "7.5.3",
"targets": [
{
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"value"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": []
}
],
"timeFrom": null,
"timeShift": null,
"title": "NHR Set Current 9430",
"type": "geeksrus-mqtt-panel",
"value": {
"type": "Buffer",
"data": [
110,
117,
108,
108
]
},
"viewModel": {
"maxValue": "100",
"minValue": "0",
"step": "1",
"text": "Send"
}
},
{
"datasource": null,
"fieldConfig": {
"defaults": {},
"overrides": []
},
"gridPos": {
"h": 3,
"w": 7,
"x": 14,
"y": 3
},
"id": 10,
"mode": "Text",
......@@ -341,16 +613,16 @@
],
"timeFrom": null,
"timeShift": null,
"title": "NHR Set Frequency",
"title": "NHR Set Frequency 9410",
"type": "geeksrus-mqtt-panel",
"value": {
"type": "Buffer",
"data": [
110,
117,
108,
108
],
"type": "Buffer"
]
},
"viewModel": {
"maxValue": "100",
......@@ -406,12 +678,12 @@
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"h": 7,
"w": 10,
"x": 0,
"y": 3
"y": 6
},
"id": 12,
"id": 17,
"options": {
"graph": {},
"legend": {
......@@ -464,13 +736,19 @@
"key": "method",
"operator": "=",
"value": "Voltage"
},
{
"condition": "AND",
"key": "nhr",
"operator": "=",
"value": "9410"
}
]
}
],
"timeFrom": null,
"timeShift": null,
"title": "Voltage",
"title": "Voltage 9410",
"type": "timeseries"
},
{
......@@ -515,15 +793,15 @@
}
]
},
"unit": "rothz"
"unit": "amp"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 3
"h": 7,
"w": 10,
"x": 10,
"y": 6
},
"id": 13,
"options": {
......@@ -577,20 +855,140 @@
{
"key": "nhr",
"operator": "=",
"value": "9410"
"value": "9430"
},
{
"condition": "AND",
"key": "method",
"operator": "=",
"value": "Curr"
}
]
}
],
"timeFrom": null,
"timeShift": null,
"title": "Current 9430",
"type": "timeseries"
},
{
"datasource": null,
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"graph": false,
"legend": false,
"tooltip": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": true
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "rothz"
},
"overrides": []
},
"gridPos": {
"h": 7,
"w": 10,
"x": 0,
"y": 13
},
"id": 12,
"options": {
"graph": {},
"legend": {
"calcs": [],
"displayMode": "hidden",
"placement": "bottom"
},
"tooltipOptions": {
"mode": "single"
}
},
"pluginVersion": "7.5.3",
"targets": [
{
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "mqtt_consumer",
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"value"
],
"type": "field"
},
{
"params": [],
"type": "last"
}
]
],
"tags": [
{
"key": "method",
"operator": "=",
"value": "Freq"
},
{
"condition": "AND",
"key": "nhr",
"operator": "=",
"value": "9410"
}
]
}
],
"timeFrom": null,
"timeShift": null,
"title": "Frequency ",
"title": "Frequency 9410",
"type": "timeseries"
}
],
......@@ -609,5 +1007,5 @@
"timezone": "",
"title": "LabREI",
"uid": "-SKl6PX4k",
"version": 4
"version": 6
}
\ No newline at end of file
......@@ -548,11 +548,10 @@ class NHR9400():
#Fetch the average current of all channels
def getCurrent(self):
self.__s.send("FECT:CURR?\n".encode())
self.__s.send("CURR?\n".encode())
value = self.__s.recv(1024)
print(value.decode())
print(value)
return self.receiveFloat(value)
#fetch individual value of current of one channel
def getCurrentA(self):
self.__s.send("FETC:CURR:APHase?\n".encode())
......
......@@ -65,6 +65,11 @@ class NHR9430(NHR9400):
value = self.__s.recv(1024)
return self.receiveArray(value)
def getCurrent(self):
self.__s.send("CURR?\n".encode())
value = self.__s.recv(1024)
return self.receiveFloat(value)
###################### Instrument Capabilities #################
#Query returns the minimum and maximum allowable set value for crest factor in NORMal loading mode Refer to CONFigure:LOAD:MODE for information about setting the 9430 in NORmal loading mode.
......
......@@ -38,7 +38,7 @@ interface.newNhr("9430")
NHRs = {
"9410" : interface.getNhr9410()[0],
# "9430" : interface.getNhr9430()[0],
"9430" : interface.getNhr9430()[0],
}
def on_connect(client, userdata, flags, rc):
......@@ -134,14 +134,14 @@ def connect_mqtt():
def publish(client):
while not FLAG_EXIT:
for nhr_id, nhr_instance in NHRs.items():
voltage = nhr_instance.getVoltage()
freq = nhr_instance.getFreq()
data = [
voltage = NHRs["9410"].getVoltage()
freq = NHRs["9410"].getFreq()
curr = NHRs["9430"].getCurrent()
data = [
{
"measurement": "mqtt_consumer",
"tags": {
"nhr": nhr_id,
"nhr": "9410",
"method": "Voltage"
},
"time": datetime.datetime.utcnow().isoformat(),
......@@ -152,17 +152,28 @@ def publish(client):
{
"measurement": "mqtt_consumer",
"tags": {
"nhr": nhr_id,
"nhr": "9410",
"method": "Freq"
},
"time": datetime.datetime.utcnow().isoformat(),
"fields": {
"value": str(freq)
}
},
{
"measurement": "mqtt_consumer",
"tags": {
"nhr": "9430",
"method": "Curr"
},
"time": datetime.datetime.utcnow().isoformat(),
"fields": {
"value": str(curr)
}
}
]
client_influxdb.write_points(data)
time.sleep(1)
]
client_influxdb.write_points(data)
time.sleep(1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment