Commit 0d275ffa authored by Roberto Borghes's avatar Roberto Borghes
Browse files

First basic version just for exporting Image

parent 100c4dcb
NAME = arinaxbzoom-srv
MAIN = ArinaxBzoom.py
DIRNAME = $(NAME:-srv=)
MODNAME = $(MAIN:.py=)
default: bin
@cp src/*.py bin/${DIRNAME}
@echo "#!/usr/bin/env python\nimport sys\nsys.path.append(sys.path[0]+'/${DIRNAME}')\nfrom ${MODNAME} import main\nif __name__ == '__main__':\n main()\n" > bin/${NAME}
@chmod +x bin/${NAME} bin/${DIRNAME}/${MAIN}
bin:
@test -d $@ || mkdir -p $@/${DIRNAME}
clean:
@rm -fr bin/ src/*~ src/*.pyc
.PHONY: clean
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# ############################################################################
# license :
# ============================================================================
#
# File : ArinaxBzoom.py
#
# Project : Arinax B-zoom
#
# This file is part of Tango device class.
#
# Tango is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Tango is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Tango. If not, see <http://www.gnu.org/licenses/>.
#
#
# $Author : sci.comp$
#
# $Revision : $
#
# $Date : $
#
# $HeadUrl : $
# ============================================================================
# This file is generated by POGO
# (Program Obviously used to Generate tango Object)
# ############################################################################
__all__ = ["ArinaxBzoom", "ArinaxBzoomClass", "main"]
__docformat__ = 'restructuredtext'
import PyTango
import sys
# Add additional import
#----- PROTECTED REGION ID(ArinaxBzoom.additionnal_import) ENABLED START -----#
import traceback
import struct
from PIL import Image
import numpy
class TangoTestClient():
attributes = {'camera_name': None,
'camera_[*]_pixelsize': None,
'image_[*]_width': None,
'image_[*]_height': None,
'video_[*]_exposure': [2000, 50000, 22200],
'video_[*]_exposure_range': None,
'video_[*]_gain': [0.1, 0.2, 0.5],
'video_[*]_gain_range': None,
'video_[*]_scale': None,
'num_zoom_levels': None,
'video_zoom_idx': 5,
'video_zoom_percent': 0.6,
'video_predefined_zoom_list': None,
'video_zoom_list': None,
'video_[*]_mode': ['RGB8Packed', 'BayerBG8', 'BayerRG8'],
'video_[*]_white_balance': ['Continuous', 'Auto', 'Off'],
'video_[*]_white_balance_red': [0.1, 0.15, 0.5],
'video_[*]_white_balance_blue': [0.5, 0.2, 0.1],
'width_magnification_ratio': None,
'height_magnification_ratio': None,
'width_optic_center_offset': None,
'height_optic_center_offset': None,
'video_live': None,
'video_[*]_last_image_counter': None,
'video_[*]_fps': None,
'endianness': None}
# ------------------
header_format = '>IHHqiiHHHH'
header_size = struct.calcsize(header_format)
hybrid = 'bzoom'
first = 'acA2500-x5'
second = 'acA2440-x30'
#----- PROTECTED REGION END -----# // ArinaxBzoom.additionnal_import
# Device States Description
# No states for this device
class ArinaxBzoom (PyTango.Device_4Impl):
"""Arinax B-zoom"""
# -------- Add you global variables here --------------------------
#----- PROTECTED REGION ID(ArinaxBzoom.global_variables) ENABLED START -----#
#----- PROTECTED REGION END -----# // ArinaxBzoom.global_variables
def __init__(self, cl, name):
PyTango.Device_4Impl.__init__(self,cl,name)
self.debug_stream("In __init__()")
ArinaxBzoom.init_device(self)
#----- PROTECTED REGION ID(ArinaxBzoom.__init__) ENABLED START -----#
#----- PROTECTED REGION END -----# // ArinaxBzoom.__init__
def delete_device(self):
self.debug_stream("In delete_device()")
#----- PROTECTED REGION ID(ArinaxBzoom.delete_device) ENABLED START -----#
#----- PROTECTED REGION END -----# // ArinaxBzoom.delete_device
def init_device(self):
self.debug_stream("In init_device()")
self.get_device_properties(self.get_device_class())
self.attr_Image_read = [[0]]
#----- PROTECTED REGION ID(ArinaxBzoom.init_device) ENABLED START -----#
try:
self.__device = PyTango.DeviceProxy(self.bzoom_tango_url)
self.__device.ping()
self.set_state(PyTango.DevState.ON)
except:
traceback.print_exc()
self.set_state(PyTango.DevState.FAULT)
#----- PROTECTED REGION END -----# // ArinaxBzoom.init_device
def always_executed_hook(self):
self.debug_stream("In always_excuted_hook()")
#----- PROTECTED REGION ID(ArinaxBzoom.always_executed_hook) ENABLED START -----#
#----- PROTECTED REGION END -----# // ArinaxBzoom.always_executed_hook
# -------------------------------------------------------------------------
# ArinaxBzoom read/write attribute methods
# -------------------------------------------------------------------------
def read_Image(self, attr):
self.debug_stream("In read_Image()")
#----- PROTECTED REGION ID(ArinaxBzoom.Image_read) ENABLED START -----#
img_data = self.__device.video_last_image
_, _, _, frame_number, width, height, _, _, _, _ = \
struct.unpack(TangoTestClient.header_format, img_data[1][:TangoTestClient.header_size])
raw = img_data[1][TangoTestClient.header_size:]
img = Image.frombytes(mode='RGB', size=(width, height), data=raw)
#self.attr_Image_read = numpy.array(img.getdata()).reshape(width, height, 3)
self.attr_Image_read = numpy.array(img.convert("P"))
attr.set_value(self.attr_Image_read)
#----- PROTECTED REGION END -----# // ArinaxBzoom.Image_read
def read_attr_hardware(self, data):
self.debug_stream("In read_attr_hardware()")
#----- PROTECTED REGION ID(ArinaxBzoom.read_attr_hardware) ENABLED START -----#
#----- PROTECTED REGION END -----# // ArinaxBzoom.read_attr_hardware
# -------------------------------------------------------------------------
# ArinaxBzoom command methods
# -------------------------------------------------------------------------
#----- PROTECTED REGION ID(ArinaxBzoom.programmer_methods) ENABLED START -----#
#----- PROTECTED REGION END -----# // ArinaxBzoom.programmer_methods
class ArinaxBzoomClass(PyTango.DeviceClass):
# -------- Add you global class variables here --------------------------
#----- PROTECTED REGION ID(ArinaxBzoom.global_class_variables) ENABLED START -----#
#----- PROTECTED REGION END -----# // ArinaxBzoom.global_class_variables
# Class Properties
class_property_list = {
}
# Device Properties
device_property_list = {
'bzoom_tango_url':
[PyTango.DevString,
"Arinax Tango server complete URL",
[] ],
}
# Command definitions
cmd_list = {
}
# Attribute definitions
attr_list = {
'Image':
[[PyTango.DevLong,
PyTango.IMAGE,
PyTango.READ, 3000, 3000]],
}
def main():
try:
py = PyTango.Util(sys.argv)
py.add_class(ArinaxBzoomClass, ArinaxBzoom, 'ArinaxBzoom')
#----- PROTECTED REGION ID(ArinaxBzoom.add_classes) ENABLED START -----#
#----- PROTECTED REGION END -----# // ArinaxBzoom.add_classes
U = PyTango.Util.instance()
U.server_init()
U.server_run()
except PyTango.DevFailed as e:
print ('-------> Received a DevFailed exception:', e)
except Exception as e:
print ('-------> An unforeseen exception occured....', e)
if __name__ == '__main__':
main()
<?xml version="1.0" encoding="ASCII"?>
<pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl">
<classes name="ArinaxBzoom" pogoRevision="9.4">
<description description="Arinax B-zoom" title="Arinax B-zoom" sourcePath="/mnt/xrd1-control-01" language="Python" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="true" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
<inheritances classname="Device_Impl" sourcePath=""/>
<identification contact="at elettra..eu - sci.comp" author="sci.comp" emailDomain="elettra..eu" classFamily="OtherInstruments" siteSpecific="" platform="All Platforms" bus="Ethernet" manufacturer="Arinax" reference="B-Zoom"/>
</description>
<deviceProperties name="bzoom_tango_url" mandatory="true" description="Arinax Tango server complete URL">
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0">
<argin description="none">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="Device state">
<type xsi:type="pogoDsl:StateType"/>
</argout>
<status abstract="true" inherited="true" concrete="true"/>
</commands>
<commands name="Status" description="This command gets the device status (stored in its device_status data member) and returns it to the caller." execMethod="dev_status" displayLevel="OPERATOR" polledPeriod="0">
<argin description="none">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="Device status">
<type xsi:type="pogoDsl:ConstStringType"/>
</argout>
<status abstract="true" inherited="true" concrete="true"/>
</commands>
<attributes name="Image" attType="Image" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="3000" maxY="3000" allocReadMember="true" isDynamic="false">
<dataType xsi:type="pogoDsl:IntType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<preferences docHome="./doc_html" makefileHome="/usr/share/pogo/preferences"/>
</classes>
</pogoDsl:PogoSystem>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment