wolfhece 2.0.16__py3-none-any.whl → 2.0.18__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wolfhece/CpGrid.py +10 -13
- wolfhece/PyCrosssections.py +18 -13
- wolfhece/PyHydrographs.py +2 -2
- wolfhece/PyParams.py +15 -27
- wolfhece/PyPictures.py +48 -45
- wolfhece/PyVertexvectors.py +14 -19
- wolfhece/apps/curvedigitizer.py +4 -1
- wolfhece/apps/wolfcompare2Darrays.py +11 -7
- wolfhece/clientserver/clientserver.py +62 -0
- wolfhece/friction_law.py +39 -34
- wolfhece/ftp/downloader.py +8 -7
- wolfhece/gpuview.py +14 -13
- wolfhece/hydrology/Catchment.py +2 -2
- wolfhece/hydrology/PyWatershed.py +2 -2
- wolfhece/hydrology/SubBasin.py +13 -11
- wolfhece/hydrometry/kiwis_gui.py +9 -9
- wolfhece/irm_qdf.py +12 -10
- wolfhece/mar/Interface_MAR_WOLF_objet.py +260 -161
- wolfhece/opengl/py3d.py +231 -16
- wolfhece/pyshields.py +4 -4
- wolfhece/pythonfortran/example_makendarray.py +46 -41
- wolfhece/pythonfortran/example_numpy_memory.py +87 -83
- wolfhece/pythonfortran/tools.py +1 -1
- wolfhece/scenario/imposebc_void.py +2 -3
- wolfhece/scenario/update_void.py +6 -6
- wolfhece/wolf_array.py +17 -16
- wolfhece/wolfresults_2D.py +2 -4
- {wolfhece-2.0.16.dist-info → wolfhece-2.0.18.dist-info}/METADATA +7 -1
- {wolfhece-2.0.16.dist-info → wolfhece-2.0.18.dist-info}/RECORD +33 -38
- wolfhece/apps/wolfBernoulli.py +0 -18
- wolfhece/bernoulli/ModelJockgrim.py +0 -226
- wolfhece/bernoulli/NetworkOpenGL.py +0 -6461
- wolfhece/bernoulli/ReadNeupotzData.py +0 -223
- wolfhece/bernoulli/opti_results_interactive_plot.py +0 -212
- wolfhece/debug.py +0 -8
- /wolfhece/{bernoulli → clientserver}/__init__.py +0 -0
- {wolfhece-2.0.16.dist-info → wolfhece-2.0.18.dist-info}/WHEEL +0 -0
- {wolfhece-2.0.16.dist-info → wolfhece-2.0.18.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.0.16.dist-info → wolfhece-2.0.18.dist-info}/top_level.txt +0 -0
@@ -1,226 +0,0 @@
|
|
1
|
-
from tb_device_mqtt import TBDeviceMqttClient
|
2
|
-
from time import sleep
|
3
|
-
import paho.mqtt.client as mqtt
|
4
|
-
import time
|
5
|
-
import requests
|
6
|
-
import time
|
7
|
-
import pandas as pd
|
8
|
-
from datetime import datetime
|
9
|
-
from datetime import timedelta
|
10
|
-
from datetime import date
|
11
|
-
# Importing models and REST client class from Community Edition version
|
12
|
-
from tb_rest_client.rest_client_ce import *
|
13
|
-
from tb_rest_client.rest import ApiException
|
14
|
-
|
15
|
-
try:
|
16
|
-
from ..libs import wolfpy
|
17
|
-
except:
|
18
|
-
msg=_('Error importing wolfpy.pyd')
|
19
|
-
msg+=_(' Python version : ' + sys.version)
|
20
|
-
msg+=_(' If your Python version is not 3.7.x or 3.9.x, you need to compile an adapted library with compile_wcython.py in wolfhece library path')
|
21
|
-
msg+=_(' See comments in compile_wcython.py or launch *python compile_wcython.py build_ext --inplace* in :')
|
22
|
-
msg+=' ' + dirname(__file__)
|
23
|
-
|
24
|
-
raise Exception(msg)
|
25
|
-
|
26
|
-
|
27
|
-
#Global variables
|
28
|
-
topic = "v1/devices/me/telemetry"
|
29
|
-
headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
|
30
|
-
#url = 'http://iot4h2o.mv.uni-kl.de:8080/api/auth/login'
|
31
|
-
url = 'http://iot4h2o.mv.uni-kl.de:8080'
|
32
|
-
broker = 'iot4h2o.mv.uni-kl.de'
|
33
|
-
#logging.basicConfig(level=logging.DEBUG)
|
34
|
-
|
35
|
-
def callback(client, result):
|
36
|
-
print(client, result)
|
37
|
-
Test=1
|
38
|
-
def on_publish(client, userdata, result):
|
39
|
-
# log.debug("Data published to ThingsBoard!")
|
40
|
-
client.request_attributes(["sensorModel", "attribute_2"], callback=on_attributes_change)
|
41
|
-
v=1
|
42
|
-
pass
|
43
|
-
def on_attributes_change(client, result, exception):
|
44
|
-
client.stop()
|
45
|
-
sleep(3)
|
46
|
-
if exception is not None:
|
47
|
-
print("Exception: " + str(exception))
|
48
|
-
else:
|
49
|
-
print(result)
|
50
|
-
#function for getting the token for the curl-command
|
51
|
-
def getCurlToken():
|
52
|
-
url = 'http://iot4h2o.mv.uni-kl.de:8080/api/auth/login'
|
53
|
-
headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
|
54
|
-
loginJSON = {'username': username, 'password': password}
|
55
|
-
tokenAuthResp = requests.post(url, headers=headers, json=loginJSON).json()
|
56
|
-
token = tokenAuthResp['token']
|
57
|
-
return token
|
58
|
-
|
59
|
-
#function for getting telemetry data
|
60
|
-
def GetTelemetryData(CurlToken,DeviceToken):
|
61
|
-
url = 'http://iot4h2o.mv.uni-kl.de:8080/api/plugins/telemetry/DEVICE/'+DeviceToken+'/values/timeseries'
|
62
|
-
headers = {'Content-Type': 'application/json', 'X-Authorization': 'Bearer '+CurlToken}
|
63
|
-
telemetryDataResp = requests.get(url, headers=headers).json()
|
64
|
-
#telemetryDataResp = requests.get(url).json()
|
65
|
-
return telemetryDataResp
|
66
|
-
|
67
|
-
#insert the following information
|
68
|
-
username2 = "t.pirard@uliege.be"
|
69
|
-
username = "t.pirard@zwgs.de"
|
70
|
-
password = "111122"
|
71
|
-
#Example network
|
72
|
-
DeviceID = "698e65a0-21c0-11ec-a052-af580412d5c6"
|
73
|
-
DeviceToken = "guCnZNPPCPP6oA9NeE2Q"
|
74
|
-
DeviceID = "50e87610-c9dd-11ec-abdc-49029c7e8f07"
|
75
|
-
DeviceToken = "5CTiU24QD1ldH3AOU6vP"
|
76
|
-
EntryExample = ["Head","Discharge"]
|
77
|
-
BarWaterColumn=10.197442889221
|
78
|
-
#Time data
|
79
|
-
TimeStamp = time()
|
80
|
-
PreviousDate = date.fromtimestamp(TimeStamp)
|
81
|
-
CurrentDate = PreviousDate
|
82
|
-
#Definition of different usefull device token and usefull entries
|
83
|
-
#Production unit
|
84
|
-
DeviceKuhardt = "5124b960-7da1-11eb-81e7-7bf4b1b85926" #Wasserwerk Kuhardt : MengeL1 + MengeL2 +MengeLeimersheim
|
85
|
-
TokenKuhardt = "uRdOU74bNrwob2wJt6aR"
|
86
|
-
EntryKuhardt =['MengeL1','MengeL2','MengeLeimersheim']
|
87
|
-
RevFactorKuhardt=[10*3600,10*3600,100*3600]
|
88
|
-
DeviceJockgrim = "47a69c00-7da1-11eb-81e7-7bf4b1b85926" #Wasserwerk Jockgrim : Menge + Druck
|
89
|
-
TokenJockgrim = "VaHJOZvERK3iebpkilwT"
|
90
|
-
EntryJockgrim = ['Menge','Druck']
|
91
|
-
RevFactorJockgrim=[3600,100/BarWaterColumn]
|
92
|
-
#Water towers : Wasserturm
|
93
|
-
NameTowers=['Hatz',"Rulz","Wor"]
|
94
|
-
DevicesWT=["39805350-7da1-11eb-81e7-7bf4b1b85926","308325c0-7da1-11eb-81e7-7bf4b1b85926","260db010-7da1-11eb-81e7-7bf4b1b85926"]
|
95
|
-
TokensWT=["n9IqRbv633DvwV8j6Zqb","8s7KqLd4jzIeGbblEauO","aKhhW6x92cFFEXybMFfa"]
|
96
|
-
EntryWT = ['Ablauf','Menge','Niveau']
|
97
|
-
RevFactorWT=[10*3600,10*3600,100]
|
98
|
-
#Booster system
|
99
|
-
DeviceKnittel = "5d4e7e30-f423-11eb-88d0-df9159a9b3d4" #Druckerhoehungsanlage - DEA Knittelsheim
|
100
|
-
TokenKnittel = "XoQ3yRVkWCmsDRqIyhuE"
|
101
|
-
EntryKnittel = ['Menge','Druck']
|
102
|
-
RevFactorKnittel = [100*3600,100/BarWaterColumn]
|
103
|
-
|
104
|
-
#Vector for devices
|
105
|
-
DevicesID=[DeviceKuhardt,DeviceJockgrim,DevicesWT[0],DevicesWT[1],DevicesWT[2],DeviceKnittel]
|
106
|
-
#Vector for token
|
107
|
-
TokensID=[TokenKuhardt,TokenJockgrim,TokensWT[0],TokensWT[1],TokensWT[2],TokenKnittel]
|
108
|
-
#Vector for keys
|
109
|
-
Keys=[EntryKuhardt,EntryJockgrim,EntryWT,EntryWT,EntryWT,EntryKnittel]
|
110
|
-
#Vector for correction factors
|
111
|
-
RevFactors=[RevFactorKuhardt,RevFactorJockgrim,RevFactorWT,RevFactorWT,RevFactorWT,RevFactorKnittel]
|
112
|
-
#Dictionnary for Elements
|
113
|
-
Entities={}
|
114
|
-
Ent=["Kuhardt","Jockgrim","Hatz","Rulz","Wor","Knittel"]
|
115
|
-
for Val in Ent:
|
116
|
-
Entities[Val]={}
|
117
|
-
Test=1
|
118
|
-
for El in Entities:
|
119
|
-
Entities[El]["Keys"]={}
|
120
|
-
#Entities[El]["Keys"]["Name"]={}
|
121
|
-
cpt=0
|
122
|
-
#Definition of TokenID, DeviceID, Keys and Directory
|
123
|
-
Basic_Directory='E:\\Network_Thomas\\Jockgrim_Data\\'
|
124
|
-
file={}
|
125
|
-
#Entrées
|
126
|
-
for El in Entities:
|
127
|
-
Entities[El]["TokenID"]=TokensID[cpt]
|
128
|
-
Entities[El]["DeviceID"]=DevicesID[cpt]
|
129
|
-
Entities[El]["Directory"]=Basic_Directory+El+'\\'
|
130
|
-
file[El]={}
|
131
|
-
for LocKey in Keys[cpt]:
|
132
|
-
Entities[El]["Keys"][LocKey]={}
|
133
|
-
file[El][LocKey]={}
|
134
|
-
cpt_key=0
|
135
|
-
for IdKey in Entities[El]["Keys"]:
|
136
|
-
Entities[El]["Keys"][IdKey]={}
|
137
|
-
Entities[El]["Keys"][IdKey]["TimeStamp"]=TimeStamp
|
138
|
-
Entities[El]["Keys"][IdKey]["Value"]=0
|
139
|
-
Entities[El]["Keys"][IdKey]["RevFactor"]=RevFactors[cpt][cpt_key]
|
140
|
-
Entities[El]["Keys"][IdKey]["Filename"]=Entities[El]["Directory"]+IdKey+'_'+str(CurrentDate.year)+'_'+str(CurrentDate.month)+'.bin'
|
141
|
-
#file[El][IdKey]=open(Entities[El]["Keys"][IdKey]["Filename"], 'a')
|
142
|
-
Test=1
|
143
|
-
cpt_key+=1
|
144
|
-
cpt+=1
|
145
|
-
#Sorties
|
146
|
-
Entities_Out=['Hatz','Rulz','Wor']
|
147
|
-
File_Out=[]
|
148
|
-
for El in Entities_Out:
|
149
|
-
File_Out.append(Entities[El]['Directory'])
|
150
|
-
#Part related to the time
|
151
|
-
Time={}
|
152
|
-
Time['Directory']=Basic_Directory+'Delta_Measurements.txt'
|
153
|
-
#Function to read the data in the file corresponding to the new_day
|
154
|
-
|
155
|
-
#for Elem in Entities:
|
156
|
-
|
157
|
-
client= TBDeviceMqttClient(broker, DeviceToken)
|
158
|
-
client.connect()
|
159
|
-
|
160
|
-
next_reading = time()
|
161
|
-
PreviousTimeStamp = time()
|
162
|
-
INTERVAL=5*60
|
163
|
-
NewTimeStamp=True
|
164
|
-
|
165
|
-
#Parameters for the potential simulatio of the network
|
166
|
-
Simulation_Instant=True
|
167
|
-
network_directory="D:\\ProgThomas\\wolf_oo\\Sources-Thomas3\\Solutions\\Unit_Tests\\to_debug\\Compar_Model_Sensib_Extr_500"
|
168
|
-
new_initiation=1
|
169
|
-
while CurrentDate.year==2022:
|
170
|
-
|
171
|
-
next_reading += INTERVAL
|
172
|
-
sleep_time = next_reading-time()
|
173
|
-
#Every device is read to access to its own information
|
174
|
-
for Elem in Entities:
|
175
|
-
telemetryData=GetTelemetryData(getCurlToken(),Entities[Elem]["DeviceID"])
|
176
|
-
for Key in Entities[Elem]["Keys"]:
|
177
|
-
TimeUsed=float(telemetryData[Key][0]['ts']/1000)
|
178
|
-
if(Entities[Elem]["Keys"][Key]['TimeStamp']!=TimeUsed):
|
179
|
-
Loc_Data=telemetryData[Key][0]['value']
|
180
|
-
Loc_Data=float(Loc_Data)/float(Entities[Elem]["Keys"][Key]["RevFactor"])
|
181
|
-
Loc_Data=str(Loc_Data)
|
182
|
-
CurrentDate=pd.Timestamp(TimeUsed, unit='s',tz='Europe/Vatican')
|
183
|
-
|
184
|
-
if(PreviousDate.month!=CurrentDate.month):
|
185
|
-
#The previous file with the previous day is closed and the new file with the current day is opened
|
186
|
-
Entities[Elem]["Filename"]=Entities[Elem]["Directory"]+Key+'_'+str(CurrentDate.year)+'_'+str(CurrentDate.month)+'.bin'
|
187
|
-
file[Elem][Key].close()
|
188
|
-
file[Elem][Key] = open(Entities[Elem]["Filename"], 'a')
|
189
|
-
file[Elem][Key]=open(Entities[Elem]["Keys"][Key]["Filename"], 'a')
|
190
|
-
file[Elem][Key].write(Loc_Data)
|
191
|
-
file[Elem][Key].write('\n')
|
192
|
-
Entities[Elem]["Keys"][Key]['TimeStamp']=TimeUsed
|
193
|
-
file[Elem][Key].close()
|
194
|
-
Test=1
|
195
|
-
if(NewTimeStamp):
|
196
|
-
#Export of the current time of the measure : we consider a unique timestamp for each source of information
|
197
|
-
f_time=open(Time['Directory'],'a')
|
198
|
-
#We transform based on delta
|
199
|
-
Delta=CurrentDate.day*86400+CurrentDate.hour*3600+CurrentDate.minute*60+CurrentDate.second
|
200
|
-
f_time.write(str(Delta))
|
201
|
-
f_time.write('\n')
|
202
|
-
f_time.close()
|
203
|
-
NewTimeStamp=False
|
204
|
-
NewTimeStamp=True
|
205
|
-
#print(value)
|
206
|
-
if sleep_time > 0:
|
207
|
-
if(Simulation_Instant):
|
208
|
-
Results_Reservoirs=wolfpy.jockgrim_application(Basic_Directory,network_directory,CurrentDate.year,CurrentDate.month,new_initiation)
|
209
|
-
new_initiation=0
|
210
|
-
telemetry = {"Hatzenbühl": Results_Reservoirs[0], "Rülzheim": Results_Reservoirs[1], "Wörth": Results_Reservoirs[2]}
|
211
|
-
# Sending volume data to ThingsBoard
|
212
|
-
client.send_telemetry(telemetry,1)
|
213
|
-
#Sending results to the txt files to obtain also it on the machine
|
214
|
-
cpt_elem=0
|
215
|
-
for El in File_Out:
|
216
|
-
El=El+'Results_'+str(CurrentDate.year)+'_'+str(CurrentDate.month)+'.txt'
|
217
|
-
file_out = open(El, 'a')
|
218
|
-
file_out.write(str(Results_Reservoirs[cpt_elem]))
|
219
|
-
file_out.write('\n')
|
220
|
-
cpt_elem+=1
|
221
|
-
file_out.close()
|
222
|
-
sleep(sleep_time)
|
223
|
-
|
224
|
-
#client.disconnect()
|
225
|
-
f.close()
|
226
|
-
Test=1
|