root/experimental/components/image_display/trunk/image_display/image_display.py @ 3875

Revision 3875, 4.7 KB (checked in by DrewCormier, 6 years ago)

not using output port for this component

Line 
1'''
2/****************************************************************************
3
4Copyright 2007 Virginia Polytechnic Institute and State University
5
6This file is part of the OSSIE image_display.
7
8OSSIE image_display is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 2 of the License, or
11(at your option) any later version.
12
13OSSIE image_display is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with OSSIE image_display; if not, write to the Free Software
20Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
22****************************************************************************/
23
24'''
25
26#! /bin/env python
27from omniORB import CORBA
28from omniORB import URI
29import CosNaming
30import CF, CF__POA
31import standardInterfaces__POA
32import customInterfaces__POA
33import sys
34
35import WorkModule
36import threading
37import time
38
39#-------------------------------------------------------------
40# image_display_i class definition (main component class)
41#-------------------------------------------------------------
42class _image_display__i(CF__POA.Resource):
43    def __init__(self, uuid, label, poa):
44        CF._objref_Resource.__init__(self._this())
45        print "image_display_i __init__: " + label
46        self.naming_service_name = label
47        self.poa = poa
48
49        self.inPort0_servant = dataIn_complexShort_i(self, "image_in")
50        self.inPort0_var = self.inPort0_servant._this()
51
52
53        self.propertySet = []
54        self.work_mod = None
55       
56    def start(self):
57        print "image_display start called"
58       
59    def stop(self):
60        print "image_display stop called"
61       
62    def getPort(self, id):
63        if str(id) == "image_in":
64            return self.inPort0_var
65       
66        return None  #port not found in available ports list
67       
68    def initialize(self):
69        print "image_display initialize called"
70   
71    def configure(self, props):
72        print "image_display configure called"
73        buffer_size = 0
74        self.work_mod = WorkModule.WorkClass(self, buffer_size)
75
76    def query(self, props):
77        return None
78 
79    def releaseObject(self):
80        # release the main work module
81        self.work_mod.Release()
82       
83        # release the main process threads for the ports
84               
85        # deactivate the ports
86        iid0 = self.poa.reference_to_id(self.inPort0_var)
87
88        self.poa.deactivate_object(iid0)
89       
90#------------------------------------------------------------------
91# dataIn_complexShort_i class definition
92#------------------------------------------------------------------
93class dataIn_complexShort_i(standardInterfaces__POA.complexShort):
94    def __init__(self, parent, name):
95        self.parent = parent
96        self.name = name
97       
98    def pushPacket(self, I, Q):
99        self.parent.work_mod.AddData(I, Q)
100        if (self.parent.outPort1_active):
101            self.parent.outPort1_servant.send_timing_message(self.parent.naming_service_name, self.name, "pushPacket", "end", len(I))
102
103               
104#-------------------------------------------------------------------
105# ORB_Init class definition
106#-------------------------------------------------------------------
107class ORB_Init:
108    """Takes care of initializing the ORB and bind the object"""
109   
110    def __init__(self, uuid, label):
111        # initialize the orb
112        self.orb = CORBA.ORB_init()
113       
114        # get the POA
115        obj_poa = self.orb.resolve_initial_references("RootPOA")
116        poaManager = obj_poa._get_the_POAManager()
117        poaManager.activate()
118       
119        ns_obj = self.orb.resolve_initial_references("NameService")
120        rootContext = ns_obj._narrow(CosNaming.NamingContext)
121       
122        # create the main component object
123        self.image_display_Obj = image_display_i(uuid, label, obj_poa)
124        image_display_var = self.image_display_Obj._this()
125       
126        name = URI.stringToName(label)
127        rootContext.rebind(name, image_display_var)
128       
129        self.orb.run()
130       
131#-------------------------------------------------------------------
132# Code run when this file is executed
133#-------------------------------------------------------------------
134if __name__ == "__main__":
135    if len(sys.argv) != 3:
136        print sys.argv[0] + " <id> <usage name> "
137   
138    uuid = str(sys.argv[1])
139    label = str(sys.argv[2])
140   
141    print "Identifier - " + uuid + "  Label - " + label
142   
143    orb = ORB_Init(uuid, label)
144   
145
Note: See TracBrowser for help on using the browser.