-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprogram.py
266 lines (211 loc) · 7.01 KB
/
program.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#-*- coding:utf-8 -*-
## Modules
#Module for GUI
from Tkinter import *
#Module fot communication with device
import visa
#Module sys
import sys
#Extra modules
import message
import connection
import currentValues
import changingSignal
import changingValues
#Тк function for opening the second (help) window
def noviProzor():
oprogramu = Toplevel(root)
oprogramu.title("Telecommunication measurements")
oprogramu.resizable(width=False, height=False)
sirina=150
visina=150
w = oprogramu.winfo_screenwidth()/2-sirina/2
h = oprogramu.winfo_screenheight()/2-visina/2
oprogramu.geometry("%dx%d" % (sirina,visina))
oprogramu.geometry("+%d+%d" % (w, h))
verzija=Label(oprogramu,text="Version: 1.0")
verzija.place(x=40,y=50)
#Showing message
message.welcome()
#Connection with device
rm=visa.ResourceManager('C:\\Program Files (x86)\\IVI Foundation\\VISA\\WinNT\\agvisa\\agbin\\visa32.dll')
uredjaj1adrese=["TCPIP0::169.254.2.20::inst0::INSTR","GPIB0::10::INSTR"] # <- here you should add addresses of device
#Showing message
message.findingDevices()
#tipUredjaja=None
brojac=0 #brojac=counter
if brojac==0:
print ">>> LAN"
try:
instrument=rm.open_resource(uredjaj1adrese[0])
instrument.write("*IDN?")
tipUredjaja=instrument.read()
model=tipUredjaja.split(',')
instrument.write("*CLS")
brojac=1
interfejs="LAN"
except:
message.notConnected()
brojac=0
if brojac==0:
print ">>> GPIB"
try:
instrument=rm.open_resource(uredjaj1adrese[1])
instrument.write("*IDN?")
tipUredjaja=instrument.read()
model=tipUredjaja.split(',')
instrument.write("*CLS")
brojac=1
interfejs="GPIB"
except:
message.notConnected()
brojac=0
if brojac==0:
print u"Уређај није повезан."
quit()
##Creating main window
root=Tk()
sirina=540
visina=270
w = root.winfo_screenwidth()/2-sirina/2
h = root.winfo_screenheight()/2-visina/2
root.geometry("%dx%d" % (sirina,visina))
root.geometry("+%d+%d" % (w, h))
root.title("Телекомуникациона мерења")
root.resizable(width=False, height=False)
##......
##Creating menu
meni = Menu(root)
datoteka = Menu(meni, tearoff=0)
datoteka.add_command(label="Изађи", command=lambda: connection.egzit(root,instrument))
meni.add_cascade(label="Програм", menu=datoteka)
pomoc = Menu(meni, tearoff=0)
pomoc.add_command(label="О програму", command=noviProzor)
meni.add_cascade(label="Помоћ", menu=pomoc)
##......
## Showing menu
root.config(menu=meni)
##......
##Making frames (okvir)
okvir1=Frame(root,width=270, height=135, borderwidth=1, relief=SUNKEN)
okvir2=Frame(root,width=270, height=135,borderwidth=1, relief=SUNKEN)
okvir3=Frame(root,width=270, height=135,borderwidth=1, relief=SUNKEN)
okvir4=Frame(root,width=270, height=135,borderwidth=1, relief=SUNKEN)
okvir1.grid(row=0, column=0)
okvir2.grid(row=0, column=1)
okvir3.grid(row=1, column=0)
okvir4.grid(row=1, column=1)
##......
#######################################################################################################################################
########1. FRAME########
###Опште информације###
naslov=Label(okvir1,text="Телекомуникациона мерења", foreground="#283593")
naslov.place(x=45,y=5)
profesor=Label(okvir1,text="Професор: др Ненад Јевтић")
profesor.place(x=5,y=35)
student=Label(okvir1,text="Студент: Никола Ђорђевић ТС130211")
student.place(x=5,y=55)
linija=Label(okvir1,text="-------")
linija.place(x=5,y=75)
oUredjaju=Label(okvir1,text=model[0]+" "+model[1]+" >>> "+interfejs)
oUredjaju.place(x=5,y=90)
#######################################################################################################################################
########2. FRAME########
###Current values###
##Text
naslov=Label(okvir2,text="Current values", foreground="#283593")
naslov.place(x=80,y=5)
##......
##Values
signal=Label(okvir2,text="Type of signal:")
signal.place(x=5,y=35)
f=Label(okvir2,text="f =")
f.place(x=5,y=55)
vpp=Label(okvir2,text="Vpp =")
vpp.place(x=5,y=75)
##......
##Text
obavestenje2=Label(okvir2,text=" ")
obavestenje2.place(x=5,y=105)
##......
##Button
azuriraj=Button(okvir2,text="Ажурирај",command=lambda: currentValues.updatingValues(instrument,signal,f,obavestenje2,vpp))
azuriraj.place(x=200,y=102)
##......
#######################################################################################################################################
########3. FRAME########
###Changing type of signal###
##Тext
naslov=Label(okvir3,text="Промена типа сигнала", foreground="#283593")
naslov.place(x=60,y=5)
##......
##List meny
var=StringVar(okvir3)
var.set("-")
tipovi=[u"синусоидални","правоугаони","троугаони", "импулсни","шум"]
odabir=OptionMenu(okvir3, var, *tipovi)
odabir.place(x=5,y=40)
##......
##Text
info=Label(okvir3,text=" ")
info.place(x=5,y=90)
##......
##Text
obavestenje3=Label(okvir3,text=" ")
obavestenje3.place(x=5,y=110)
##......
##Button
primeni=Button(okvir3,text="Примени", command=lambda: changingSignal.set(instrument,obavestenje3,var))
primeni.place(x=155,y=41)
##......
#######################################################################################################################################
########4. FRAME########
###Промена вредности###
##Text
naslov=Label(okvir4,text="Промена параметара", foreground="#283593")
naslov.place(x=75,y=5)
##......
##Text
naslov=Label(okvir4,text="Фреквенција:")
naslov.place(x=5,y=35)
##......
##Text
naslov=Label(okvir4,text="Амплитуда:")
naslov.place(x=5,y=67)
##......
##Entry
polje1=Entry(okvir4, width=8)
polje1.place(x=85,y=38)
##......
##Entry
polje2=Entry(okvir4, width=8)
polje2.place(x=85,y=70)
##......
##List meny
var1=StringVar(okvir4)
var1.set("-")
tipovi1=["Hz","kHz","MHz"]
odabir1=OptionMenu(okvir4, var1, *tipovi1)
odabir1.place(x=137,y=35)
##......
##List meny
var2=StringVar(okvir4)
var2.set("-")
tipovi2=["mV","V"]
odabir2=OptionMenu(okvir4, var2, *tipovi2)
odabir2.place(x=137,y=67)
##......
##Text
obavestenje4=Label(okvir4,text=" ")
obavestenje4.place(x=5,y=110)
##......
##Button
primeniF=Button(okvir4,text="Примени", command=lambda: changingValues.set_frekvencija(instrument,polje1,obavestenje4,var1))
primeniF.place(x=205,y=37)
##......
##Button
primeniV=Button(okvir4,text="Примени", command=lambda: changingValues.set_napon(instrument,polje2,obavestenje4,var2))
primeniV.place(x=205,y=69)
##......
#######################################################################################################################################
root.mainloop()