source: trunk/src/testing/dim/sageGate.py @ 4

Revision 4, 5.2 KB checked in by ajaworski, 13 years ago (diff)

Added modified SAGE sources

Line 
1############################################################################
2#
3# DIM - A Direct Interaction Manager for SAGE
4# Copyright (C) 2007 Electronic Visualization Laboratory,
5# University of Illinois at Chicago
6#
7# All rights reserved.
8#
9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions are met:
11#
12#  * Redistributions of source code must retain the above copyright
13#    notice, this list of conditions and the following disclaimer.
14#  * Redistributions in binary form must reproduce the above
15#    copyright notice, this list of conditions and the following disclaimer
16#    in the documentation and/or other materials provided with the distribution.
17#  * Neither the name of the University of Illinois at Chicago nor
18#    the names of its contributors may be used to endorse or promote
19#    products derived from this software without specific prior written permission.
20#
21# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32#
33# Direct questions, comments etc about SAGE UI to www.evl.uic.edu/cavern/forum
34#
35# Author: Ratko Jagodic
36#       
37############################################################################
38
39
40
41import sageGateBase as sgb
42from globals import *
43
44
45
46####################################################################
47#
48# DESCRIPTION: This class provides the main communication interface
49#              with SAGE. It subclasses the SageGateBase in order
50#              to customize some parameters.
51#
52# DATE: Aug, 2007
53#
54####################################################################
55
56class SageGate(sgb.SageGateBase):
57    """ this class provides the main communication interface with SAGE
58        subclasses the SageGateBase in order to customize some parameters
59    """
60   
61    def __init__(self):
62        sgb.SageGateBase.__init__(self,
63                                  sageServerHost=getSAGEServer(),
64                                  useAppLauncher=True,
65                                  #forceAppLauncher=getAppLauncher(),
66                                  onDisconnect=self.showConnectionClosedDialog,
67                                  verbose=True)
68       
69
70    def showConnectionClosedDialog(self):
71        """ informs the user when the connection breaks """
72        print "Connection to SAGE closed"
73        exitApp()
74
75
76##     def executeApp(self, appName, configName="default", pos=False, size=False, optionalArgs="", useBridge=False, sageIP=None, sagePort=None):
77##         """ overridden in order to figure out the correct port and host for the target machine
78##             The reason is that SageGateBase doesn't have access to all the machine info (ie usersData)
79##         """
80
81##         # figure out the correct system ports for data streaming (if not overridden by the user)
82##         sageIP, sagePort = self.__getMachineInfo(sageIP, sagePort)
83       
84##         return sgb.SageGateBase.executeApp(self, appName, configName, pos, size,
85##                                            optionalArgs, useBridge, sageIP, sagePort)
86
87
88##     def executeRemoteApp(self, launcherId, appName, configName="default", pos=False, size=False, optionalArgs="", useBridge=False, sageIP=None, sagePort=None):
89##         """ overridden in order to figure out the correct port and host for the target machine
90##             The reason is that SageGateBase doesn't have access to all the machine info (ie usersData)
91##         """
92
93##         # figure out the correct system ports for data streaming (if not overridden by the user)
94##         sageIP, sagePort = self.__getMachineInfo(sageIP, sagePort)
95       
96##         return sgb.SageGateBase.executeRemoteApp(self, launcherId, appName, configName, pos, size,
97##                                                  optionalArgs, useBridge, sageIP, sagePort)
98       
99
100    def onMessage(self, code, data):
101        """ handles the incoming messages """
102        if code in self.hashCallbackFunction:
103            self.hashCallbackFunction[ code ](data)
104
105           
106##     def __getMachineInfo(self, sageIP, sagePort):
107##         if not sageIP:
108##             machine = getUsersData().FindMachineByIP(self.sageHost)
109##             if machine:
110##                 sageIP = machine.GetSystemIP()     # the machine told the server what to use for streaming
111##                 if not sagePort: sagePort = machine.GetSystemPort()
112##             else:
113##                 sageIP = self.sageHost    # use the default ip and port
114##                 if not sagePort: sagePort = self.sagePort+1
115##         return (sageIP, sagePort)
116
117
118   
Note: See TracBrowser for help on using the repository browser.