-
Notifications
You must be signed in to change notification settings - Fork 2
/
CcdTemp.py
executable file
·64 lines (53 loc) · 1.7 KB
/
CcdTemp.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
#!/usr/bin/env python
import sys, traceback, Ice, os
Ice.loadSlice("/home/utsumi/bin/HinOTORI.ice")
import HinOTORI
from optparse import OptionParser
sys.path.append("/home/utsumi/bin")
import config
class CameraClient(Ice.Application):
def run(self,args):
self.shutdownOnInterrupt()
self.parseoptions(args)
if self.options.setp is not None:
self.SetTemperature()
else:
self.GetTemperature()
def SetTemperature(self):
"""
A class method to communicate with the cameras
"""
for i in range(len(config.camera)):
obj = self.communicator().stringToProxy("ApogeeCam%d:default -h %s -p %d" \
% ( config.camera[i]['uid'], \
config.nodesetting['camera']['ip'], \
config.nodesetting['camera']['port'] ))
ptr = HinOTORI.CameraPrx.checkedCast(obj)
setp =float(self.options.setp)
print("self.options.setp %lf" % setp)
ptr.SetTemperature(setp)
def GetTemperature(self):
"""
A class method to communicate with the cameras
"""
for i in range(len(config.camera)):
obj = self.communicator().stringToProxy("ApogeeCam%d:default -h %s -p %d" \
% ( config.camera[i]['uid'], \
config.nodesetting['camera']['ip'], \
config.nodesetting['camera']['port'] ))
ptr = HinOTORI.CameraPrx.checkedCast(obj)
print("CCD temperature is %lf" % ptr.GetTemperature())
def parseoptions(self,args):
"""
A class method to parse the argument
"""
parser = OptionParser()
parser.add_option("-t", "--temp", dest="setp",
help="set target temperature", metavar="FILE",default=None)
(options, myargs) = parser.parse_args(args)
self.options = options
if __name__ == "__main__":
status = 0
app = CameraClient()
status = app.main(sys.argv)
sys.exit(status)