-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalue.py
executable file
·129 lines (95 loc) · 2.42 KB
/
value.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
# -*- coding:utf-8 -*-
import pickle
# 기본 셋팅 값
def set_value():
global Setvalue
global Laser
global Chuck
global Chuck_scale
global Coordination
global Frame
# 파일 가져와서 저장하기, 만약에 파일이 없으면 생성하기 None 으로 지정하고.
Setvalue = read_file()
print 'set value len > ', Setvalue.__len__()
if Setvalue.__len__() == 5:
print 'Set value len is 4'
# 레이저 사이의 거리.
Laser = Setvalue[0]
# 척 기본값 [ y, z ].
Chuck = Setvalue[1]
# 척 보정값 [ y, z ].
Chuck_scale = Setvalue[2]
# 좌표계 보정값 [ y, z ].
Coordination = Setvalue[3]
# 프레임 길이.
Frame = Setvalue[4]
def get_value():
return Setvalue[:]
def get_chuck():
return Chuck[:]
def get_chuck_scale():
return Chuck_scale[:]
def get_laser():
return Laser[:]
def get_coor():
return Coordination[:]
def get_frame():
return Frame
def read_file():
f = None
try:
f = open('value.txt', 'rb')
except Exception as e:
print 'read_file error > ', e
f = open('value.txt', 'wb')
temp = [
[83, 43, -3, -37],
[],
[0, 0],
[6, -23],
1674
]
pickle.dump(temp, f)
f.close()
f = open('value.txt', 'rb')
finally:
Setvalue = pickle.load(f)
f.close()
return Setvalue
def save_value():
Setvalue[0] = Laser
Setvalue[1] = Chuck
Setvalue[2] = Chuck_scale
Setvalue[3] = Coordination
Setvalue[4] = Frame
try:
f = open('value.txt', 'wb')
pickle.dump(Setvalue, f)
f.close()
except Exception as e:
print 'error > ', e, '파일 저장에 오류가 있습니다.'
def set_laser(laser):
if type(laser) == list:
global Laser
Laser = laser
save_value()
def set_chuck(chuck):
if type(chuck) == list:
global Chuck
Chuck = chuck
save_value()
def set_chuck_scale(scale):
if type(scale) == list:
global Chuck_scale
Chuck_scale = scale
save_value()
def set_coordination(coor):
if type(coor) == list:
global Coordination
Coordination = coor
save_value()
def set_frame(frame):
if type(frame) == int:
global Frame
Frame = frame
save_value()