-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSiemens_Logo_Snap7.py
More file actions
67 lines (47 loc) · 1.33 KB
/
Siemens_Logo_Snap7.py
File metadata and controls
67 lines (47 loc) · 1.33 KB
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
import snap7
import time as clock
import logging
logging.basicConfig(level=logging.INFO)
Logo7=True
plc = snap7.logo.Logo()
logger = logging.getLogger(__name__)
try:
plc.connect("xxx.xxx.xxx.xxx",0x0300,0x0200) #Fill in IP address
print("¤¤ Connected ¤¤")
except:
print("¤¤ Connection failed at init ¤¤")
logger.info("Connection failed at init")
#Digital Variables
Switch_Manual_Auto = "V528.1"
Switch_Stairs_West_East_North = "V529.0"
Switch_Ramp_West = "V529.1"
Switch_Ramp_East = "V529.2"
OK_Signal_Stairs_West = "V528.2"
OK_Signal_Stairs_Easst = "V528.3"
OK_Signal_Stairs_North = "V528.4"
OK_Signal_Ramp_West = "V528.5"
OK_Signal_Ramp_East = "V528.6"
#Analogue Variables
Temp_Outside_Air = "VW101"
Humidity_Outside_Air = "VW102"
Temp_Ground_1 = "VW103"
Power_Stairs_West = "VW104"
Power_Ramp_West = "VW105"
Power_Ramp_East = "VW106"
Power_Stairs_North = "VW107"
Power_Ramp_East = "VW108"
if plc.get_connected():
logger.info("Connected")
plc.read(Temp_Outside_Air)
plc.write(Switch_Manual_Auto, 1)
clock.sleep(5)
plc.write(Switch_Manual_Auto, 0)
else:
print("¤¤ Could not connect to PLC ¤¤")
logger.info("Could not connect to PLC")
plc.disconnect()
if plc.get_connected():
logger.info("Disconnection failed")
else:
logger.info("Disconnected from PLC")
plc.destroy()