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 ...@@ -6,7 +6,7 @@ from UtilitiesRei.IPFinder import IPFinder
class controlInterface: class controlInterface:
def __init__(self): def __init__(self):
self.__listIp = ['192.168.0.150'] self.__listIp = ['192.168.0.150', '192.168.0.151']
self.__listUsedIp = [] self.__listUsedIp = []
self.__nhr9410 = [] self.__nhr9410 = []
self.__nhr9430 = [] self.__nhr9430 = []
......
...@@ -548,11 +548,10 @@ class NHR9400(): ...@@ -548,11 +548,10 @@ class NHR9400():
#Fetch the average current of all channels #Fetch the average current of all channels
def getCurrent(self): def getCurrent(self):
self.__s.send("FECT:CURR?\n".encode()) self.__s.send("CURR?\n".encode())
value = self.__s.recv(1024) value = self.__s.recv(1024)
print(value.decode())
print(value)
return self.receiveFloat(value) return self.receiveFloat(value)
#fetch individual value of current of one channel #fetch individual value of current of one channel
def getCurrentA(self): def getCurrentA(self):
self.__s.send("FETC:CURR:APHase?\n".encode()) self.__s.send("FETC:CURR:APHase?\n".encode())
......
...@@ -65,6 +65,11 @@ class NHR9430(NHR9400): ...@@ -65,6 +65,11 @@ class NHR9430(NHR9400):
value = self.__s.recv(1024) value = self.__s.recv(1024)
return self.receiveArray(value) return self.receiveArray(value)
def getCurrent(self):
self.__s.send("CURR?\n".encode())
value = self.__s.recv(1024)
return self.receiveFloat(value)
###################### Instrument Capabilities ################# ###################### 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. #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") ...@@ -38,7 +38,7 @@ interface.newNhr("9430")
NHRs = { NHRs = {
"9410" : interface.getNhr9410()[0], "9410" : interface.getNhr9410()[0],
# "9430" : interface.getNhr9430()[0], "9430" : interface.getNhr9430()[0],
} }
def on_connect(client, userdata, flags, rc): def on_connect(client, userdata, flags, rc):
...@@ -134,14 +134,14 @@ def connect_mqtt(): ...@@ -134,14 +134,14 @@ def connect_mqtt():
def publish(client): def publish(client):
while not FLAG_EXIT: while not FLAG_EXIT:
for nhr_id, nhr_instance in NHRs.items(): voltage = NHRs["9410"].getVoltage()
voltage = nhr_instance.getVoltage() freq = NHRs["9410"].getFreq()
freq = nhr_instance.getFreq() curr = NHRs["9430"].getCurrent()
data = [ data = [
{ {
"measurement": "mqtt_consumer", "measurement": "mqtt_consumer",
"tags": { "tags": {
"nhr": nhr_id, "nhr": "9410",
"method": "Voltage" "method": "Voltage"
}, },
"time": datetime.datetime.utcnow().isoformat(), "time": datetime.datetime.utcnow().isoformat(),
...@@ -152,13 +152,24 @@ def publish(client): ...@@ -152,13 +152,24 @@ def publish(client):
{ {
"measurement": "mqtt_consumer", "measurement": "mqtt_consumer",
"tags": { "tags": {
"nhr": nhr_id, "nhr": "9410",
"method": "Freq" "method": "Freq"
}, },
"time": datetime.datetime.utcnow().isoformat(), "time": datetime.datetime.utcnow().isoformat(),
"fields": { "fields": {
"value": str(freq) "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) client_influxdb.write_points(data)
......
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