forked from mxcube/HardwareObjects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MicrodiffCamera.py
34 lines (28 loc) · 933 Bytes
/
MicrodiffCamera.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
"""Class for cameras connected to framegrabbers run by Taco Device Servers
"""
from HardwareRepository import BaseHardwareObjects
import logging
import os
import PyTango
#try:
# import Image
#except ImportError:
# logging.getLogger("HWR").warning("PIL not available: cannot take snapshots")
# canTakeSnapshots=False
#else:
# canTakeSnapshots=True
class MicrodiffCamera(BaseHardwareObjects.Device):
def _init(self):
try:
self.device = PyTango.DeviceProxy(self.tangoname)
except PyTango.DevFailed, traceback:
last_error = traceback[-1]
logging.getLogger('HWR').error("%s: %s", str(self.name()), last_error['desc'])
self.device = BaseHardwareObjects.Null()
else:
self.setIsReady(True)
def takeSnapshot(self, *args):
jpeg_data=self.device.GrabImage()
f = open(*(args + ("w",)))
f.write("".join(map(chr, jpeg_data)))
f.close()