def __init__(self, name, core_services):

        self.__name = name
        self.__core = core_services
     
        self.__stopevent = threading.Event()
		
        from core.tracing import get_tracer
        self.__tracer = get_tracer(name)
        
        # Configuration Settings:

        # server: The IP address or hostname to connect to.
        # port: The TCP port number to connect to.
        # interval: How often (in seconds) to emit CSV data 
        #    (default: 60 seconds).
        # channels: A list of channels to include in the data set. If this 
        #    setting is not given, all channels will be included.
        settings_list = [
                Setting(name="server", type=str, required=True),
                Setting(name="port", type=int, required=True),
                Setting(name='interval', type=int, required=False, default_value=60),
                Setting(name="channels", type=list, required=False, default_value=[]),
        ]
                                                 
        PresentationBase.__init__(self, name=name, settings_list=settings_list)

        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
Exemple #2
0
    def __init__(self, name, core_services):

        self.__name = name
        self.__core = core_services

        self.__stopevent = threading.Event()

        from core.tracing import get_tracer
        self.__tracer = get_tracer(name)

        # Configuration Settings:

        # server: The IP address or hostname to connect to.
        # port: The TCP port number to connect to.
        # interval: How often (in seconds) to emit CSV data
        #    (default: 60 seconds).
        # channels: A list of channels to include in the data set. If this
        #    setting is not given, all channels will be included.
        settings_list = [
            Setting(name="server", type=str, required=True),
            Setting(name="port", type=int, required=True),
            Setting(name='interval',
                    type=int,
                    required=False,
                    default_value=60),
            Setting(name="channels",
                    type=list,
                    required=False,
                    default_value=[]),
        ]

        PresentationBase.__init__(self, name=name, settings_list=settings_list)

        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
Exemple #3
0
    def __init__(self, name, core_services):
        """Initialize XMLRPC presentation"""
        
        self.__name = name
        self.__core = core_services

        self.__digiweb_cb_handle = None
        self.__digiweb_xmlrpc = None

        settings_list = [
            Setting(
              name='port', type=int, required=False, default_value=80),
            Setting(
              name='use_default_httpserver', type=bool, required=False,
              default_value=True),
        ]


        ## Initialize settings:
        PresentationBase.__init__(self, name=name,
                                  settings_list=settings_list)

        ## Thread initialization:
        self.__stopevent = threading.Event()
        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
    def __init__(self, name, core_services):

        self.__name = name
        self.__core = core_services
        
        # Settings:
        #
        # type: must be set to either "tcp" or "serial" (default value: "tcp")
        # port: if type is set to "tcp", 'port' is an integer which specifies 
        #     the TCP port number that the console will start upon (default 
        #     value: 4146).
        # device: if type is set to "serial", this is the serial port device 
        #     name that will be used. (default value: "/com/0").
        # baudrate: if type is set to "serial", this is the baud rate that will
        #     be used. (default value: 115200).
        
        settings_list = [
            Setting(
                name='type', type=str, required=False, default_value="tcp"),
            Setting(
                name='port', type=int, required=False, default_value=4146),
            Setting(
                name='device', type=str, required=False, default_value="/com/0"),
            Setting(
                name='baudrate', type=int, required=False, default_value=115200),
        ]

        ## Initialize settings:
        PresentationBase.__init__(self, name=name,
                                    settings_list=settings_list)

        ## Thread initialization:
        self.__stopevent = threading.Event()
        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
    def __init__(self, name, core_services):
	self.__name = name
	self.__core = core_services

	settings_list = [
	    Setting(
		name='interval', type=int, required=False, default_value=60),
	    Setting(
		name='sample_threshold', type=int, required=False, default_value=10),
	    Setting(
		name='collection', type=str, required=False, default_value=""),
	    Setting(
		name="channels", type=list, required=False, default_value=[]),
	    Setting(
		name='file_count', type=int, required=False, default_value=20),
	    Setting(
		name='filename', type=str, required=False, default_value="sample"),
	    Setting(
		name='secure', type=bool, required=False, default_value=True),
		Setting(
		name='compact_xml', type=bool, required=False, default_value=False),
	]

	PresentationBase.__init__(self, name=name,
                                  settings_list=settings_list)
	self.__stopevent = threading.Event()
	threading.Thread.__init__(self, name=name)
	threading.Thread.setDaemon(self, True)
    def __init__(self, name, core_services):
        """ Create the SMTPHandler presentation service """
        self.__name = name
        self.__core = core_services
        self.LastNotify = time.clock()

        self.queue = Queue()
        self.started_flag = False
        self.monitored_channel = None

        settings_list = [Setting(name="to_address", type=str, required=True),
                             Setting(name="from_address", type=str, required=False,
                                             default_value="*****@*****.**"),
                             Setting(name="subject", type=str, required=False,
                                             default_value="iDigi Dia Alert"),
                             Setting(name="server_address", type=str, required=True),
                             Setting(name="port", type=int, required=False,
                                             default_value=25),
                             Setting(name="username", type=str, required=False,
                                             default_value=""),
                             Setting(name="password", type=str, required=False,
                                             default_value=""),
                             Setting(name="monitored_channel", type=str, required=True),
                             Setting(name="notify_cooldown_time", type=int, required=False,
                                             default_value=360),]

        PresentationBase.__init__(self, name=name, settings_list=settings_list)

        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
    def __init__(self, name, core_services):

       self.__name = name
       self.__core = core_services
       self.__event_timer = None
       self.__stopevent = core_services
       
       self.__xbee_manager = None

        # Settings
        #
        # interval: is the maximum interval in seconds that this module waits 
        #     before sending data to the iDigi Manager Database.
        # sample_threshold: is the mininum number of samples required before
        #     sending data to the iDigi Manager Database.
        # collection: is the collection on the database where the data will
        #     be stored.
        # file_count: the number of unique files we will keep on iDigi.
        # filename: the name of the xml file we will push to iDigi, with
        #     a number appended to the end (cycling from 1 to file_count)
        # channels: is the list of channels the module is subscribed to.
        #     If no channels are listed, all channels are subscribed to.
        # compact_xml: (when set to True) will produce output XML with the 
        #     information stored as attributes to the sample node instead of
        #     separately tagged, resulting in smaller XML output.
  
       settings_list = [
          Setting(
                name='xbee_device_manager', type=str, required=False, default_value="xbee_device_manager"),
          Setting(
             name='interval', type=int, required=False,
            default_value=60),
          Setting(
             name='sample_threshold', type=int, required=False,
            default_value=10),
          Setting(
             name='collection', type=str, required=False,
             default_value=""),
          Setting(
             name="channels", type=list, required=False,
             default_value=[]),
          Setting(
             name='file_count', type=int, required=False,
             default_value=20),
          Setting(
             name='filename', type=str, required=False,
             default_value="sample"),
          Setting(
             name='secure', type=bool, required=False,
             default_value=True),
          Setting(
             name='compact_xml', type=bool, required=False,
             default_value=False),
       ]

       PresentationBase.__init__(self, name=name,
                                  settings_list=settings_list)
       self.__stopevent = threading.Event()
       threading.Thread.__init__(self, name=name)
       threading.Thread.setDaemon(self, True)
Exemple #8
0
    def __init__(self, name, core_services):

        self.__name = name
        self.__core = core_services

        from core.tracing import get_tracer
        self.__tracer = get_tracer(name)

        # Settings:
        #
        # page: The path location to access this presentation.
        # exclude: List of strings. Channels matching the strings will not be
        #    displayed.

        settings_list = [
            Setting(name='page',
                    type=str,
                    required=False,
                    default_value='/idigi_dia'),
            Setting(name='exclude',
                    type=list,
                    required=False,
                    default_value=[]),
        ]

        ## Initialize settings:
        PresentationBase.__init__(self, name=name, settings_list=settings_list)
Exemple #9
0
    def __init__(self, name, core_services):

        self.__name = name
        self.__core = core_services

        self.__digiweb_cb_handle = None
        self.__digiweb_xmlrpc = None

        from core.tracing import get_tracer
        self.__tracer = get_tracer(name)

        settings_list = [
            Setting(name='port', type=int, required=False, default_value=80),
            Setting(name='use_default_httpserver',
                    type=bool,
                    required=False,
                    default_value=True),
        ]

        ## Initialize settings:
        PresentationBase.__init__(self, name=name, settings_list=settings_list)

        ## Thread initialization:
        self.__stopevent = threading.Event()
        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
    def __init__(self, name, core_services, settings=None):
        """
        Create an instance of the RCIHandler.

        If the target_name is not specified, it will default to 'idigi_dia'.
        """

        self._name = name
        self._core = core_services
        self._handle = None
        self._tracer = get_tracer(name)

        settings_list = [
            Setting(name='target_name',
                    type=str,
                    required=False,
                    default_value='idigi_dia'),
        ]

        if settings is not None:
            settings.extend(settings_list)
        else:
            settings = settings_list

        ## Initialize settings:
        PresentationBase.__init__(self, name=name, settings_list=settings)
Exemple #11
0
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services

        ## Settings Table Definition:
        settings_list = [
            Setting(
                name='page', type=str, required=False, default_value='index'),
            Setting(
                name='port', type=int, required=False, default_value=8001),
            Setting(
                name='polling', type=int, required=False, default_value=0),
            Setting(
                name='use_default_httpserver', type=bool, required=False, default_value=True),
            Setting(
                name='title', type=str, required=False, 
                        default_value='Dia Web Presentation'),
        ]
        ## Initialize settings:
        PresentationBase.__init__(self, name=name,
                        settings_list=settings_list)

        ## Thread initialization:
        self.__stopevent = threading.Event()
        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
    def __init__(self, name, core_services):
        """
        Create an instance of the RCIHandler.

        If the target_name is not specified, it will default to 'idigi_dia'.
        """

        self.__name = name
        self.__core = core_services
        self.__thread = None
        
        
        self.websocketCom = False
        self.retrying = False
        self.pingy = 0
        self.reconnecting = 0
        self.started = False
        self.ping_loop = False

        from core.tracing import get_tracer
        self.__tracer = get_tracer(name)

        settings_list = [
                         Setting(
                                 name='target_name', type=str,
                                 required=False, default_value='idigi_dia'),
                        ]

        ## Initialize settings:
        PresentationBase.__init__(self, name=name,
                                  settings_list=settings_list)
Exemple #13
0
    def __init__(self, name, core_services):

        self.__name = name
        self.__core = core_services
		
        from core.tracing import get_tracer
        self.__tracer = get_tracer(name)

        # Settings:
        #
        # page: The path location to access this presentation.
        # exclude: List of strings. Channels matching the strings will not be
        #    displayed.  
        
        settings_list = [
            Setting(
                name='page', type=str, required=False,
                default_value='/idigi_dia'),
            Setting(
                name='exclude', type=list, required=False, default_value=[]),
        ]

        ## Initialize settings:
        PresentationBase.__init__(self, name=name,
                                    settings_list=settings_list)
    def __init__(self, name, core_services):
        """Performs startup initializations.  It verifies and loads the settings list."""

        self.logger = init_module_logger(name)

        self.__name = name
        self.__core = core_services

        self.gateway_id = None
        self.server_conn_handle = None
        self.keep_alive_timer = 0
        self.waiting_for_reply = False
        self.ao_msg_size_on_7_bits = True
        self.write_channel_name = None
        self.write_channe = None
        self.read_channel_name = None

        # watchdogs
        self.mainloop_made_a_pause = None
        self.mainloop_made_one_loop = None

        settings_list = [
            Setting(name='write_channel', type=str, required=True),
            Setting(name='read_channel', type=str, required=True),
            Setting(name='server_port',
                    type=int,
                    required=True,
                    default_value=9990),
            Setting(name='server_address',
                    type=str,
                    required=True,
                    default_value="localhost"),
            Setting(name='keep_alive_interval',
                    type=int,
                    required=False,
                    default_value=10),
            Setting(name='gateway_id', type=str, required=True),
            Setting(name='ao_msg_size_on_7_bits',
                    type=bool,
                    required=False,
                    default_value=False),
            Setting(name='activate_tcp_keepalive',
                    type=bool,
                    required=False,
                    default_value=True),
            Setting(name='log_level',
                    type=str,
                    required=False,
                    default_value='DEBUG',
                    verify_function=check_debug_level_setting),
        ]

        ## Initialize settings:
        PresentationBase.__init__(self, name=name, settings_list=settings_list)

        ## Thread initialization:
        self.__stopevent = threading.Event()
        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services

        # Declare the settings list for the presentation
        settings_list = [
            Setting(name="xbib_board", type=str, required=True)]

        PresentationBase.__init__(self, name=name, 
                                  settings_list=settings_list)
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services

        from core.tracing import get_tracer
        self.__tracer = get_tracer(name)

        settings_list = [
            Setting(name="SMS",
                    type=dict,
                    required=False,
                    default_value={},
                    verify_function=self.__verify_SMS),
            Setting(name="Iridium",
                    type=dict,
                    required=False,
                    default_value={},
                    verify_function=self.__verify_iridium),
            Setting(name="clients",
                    type=dict,
                    required=False,
                    default_value={},
                    verify_function=self.__verify_clients),
            Setting(name="updates",
                    type=dict,
                    required=False,
                    default_value={},
                    verify_function=self.__verify_updates),
            Setting(name="alarms",
                    type=dict,
                    required=False,
                    default_value={},
                    verify_function=self.__verify_alarms),
        ]

        PresentationBase.__init__(self, name=name, settings_list=settings_list)

        # Our dictionary of Transport Managers.
        self.__transport_managers = {}

        # Our cached list of clients.
        self.client_list = []

        # The list of DIA channels that have matched our filters and so we have
        # subscribed to getting channel updates from DIA as they come in.
        self.__channels_being_watched = []

        # The following list will contain a list of messages that should
        # be sent out at the next interval time.

        self.__coalesce_list = []

        self.__stopevent = threading.Event()
        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
Exemple #17
0
    def __init__(self, name, core_services):

        self.__name = name
        self.__core = core_services

        self.__stopevent = threading.Event()

        from core.tracing import get_tracer
        self.__tracer = get_tracer(name)

        self.use_proxy = None
        self.proxy_host = None
        self.proxy_port = None

        # Configuration Settings:

        settings_list = [
            Setting(name="cosm_host",
                    type=str,
                    required=False,
                    default_value="api.cosm.com"),
            Setting(name="cosm_key", type=str, required=True),
            Setting(name="cosm_feed_id0", type=str, required=True),
            Setting(name="channel0", type=str, required=True),
            Setting(name="cosm_datastream0", type=str, required=True),
            Setting(name="use_proxy",
                    type=bool,
                    required=False,
                    default_value=False),
            Setting(name="proxy_host", type=str, required=False),
            Setting(name="proxy_port",
                    type=int,
                    required=False,
                    default_value=3128),
        ]

        PresentationBase.__init__(self, name=name, settings_list=settings_list)

        self.use_proxy = SettingsBase.get_setting(self, "use_proxy")
        if self.use_proxy:
            self.proxy_host = SettingsBase.get_setting(self, "proxy_host")
            self.proxy_port = SettingsBase.get_setting(self, "proxy_port")
            if not self.proxy_host:
                self.__tracer.warning(
                    "proxy_host configuration parameter not set. Will ignore use_proxy to false"
                )
                self.use_proxy = False

        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)

        return
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services
        self.__xbee_display = None

        #Declare the settings list
        settings_list = [
            Setting(name="channels", type=list, required=True),
            Setting(name="update_rate", type=int, required=False, 
                    default_value=5)
        ]
                             
        PresentationBase.__init__(self, name=name, settings_list=settings_list)
 def __init__(self, name, core_services):
     """Create an instance of the RCIHandler"""
 
     self.__name = name
     self.__core = core_services
 
     settings_list = [
                      Setting(
                              name='target_name', type=str, 
                              required=False, default_value='idigi_dia'),
                     ]
 
     ## Initialize settings:
     PresentationBase.__init__(self, name=name,
                               settings_list=settings_list)
Exemple #20
0
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services
        self.web_cb_handle = None

        settings_list = [
            Setting(
                name='log_url', type=str, required=False, default_value='logging'),
            Setting(
                name='refresh_rate', type=int, required=False, default_value=10),
        ]

        ## Initialize settings:
        PresentationBase.__init__(self, name=name,
                                    settings_list=settings_list)
Exemple #21
0
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services
        
        settings_list = [
            Setting(
                name='page', type=str, required=False,
                default_value='/idigi_dia'),
            Setting(
                name='exclude', type=list, required=False, default_value=[]),
        ]

        ## Initialize settings:
        PresentationBase.__init__(self, name=name,
                                    settings_list=settings_list)
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services

        # local variables
        self.__current_file_number = 1
        self.clear_statistics()
        self.__cache = string_file.string_flash_cache()

        settings_list = [
            Setting(
                name='interval', type=int, required=False, default_value=60),
            Setting(
                name='sample_threshold', type=int, required=False, default_value=10),
            Setting(
                name='collection', type=str, required=False, default_value=""),
            Setting(
                name="channels", type=list, required=False, default_value=[]),
            Setting(
                name='file_count', type=int, required=False, default_value=20),
            Setting(
                name='filename', type=str, required=False, default_value="sample"),
            Setting(
                name='secure', type=bool, required=False, default_value=True),
            Setting(
                name='compact_xml', type=bool, required=False, default_value=False),
            Setting(
                name='cache', type=int, required=False, default_value=0),
            Setting(
                name='cache_size', type=int, required=False, default_value=50000),
            Setting(
                name='clean_minute_interval', type=int, required=True,
                default_value=15,
                verify_function=self.__verify_clean_minutes),
            Setting(
                name='clean_minute_skew_secs', type=int, required=False,
                default_value=0),
            Setting(
                name='filename_format', type=str, required=False,
                default_value="%s%i.xml"),
            ]

        PresentationBase.__init__(self, name=name,
                                  settings_list=settings_list)
        self.__stopevent = threading.Event()
        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services
		
        from core.tracing import get_tracer
        self.__tracer = get_tracer(name)

        settings_list = [
            Setting(
                name = "SMS", type = dict, required = False,
                default_value = {}, verify_function = self.__verify_SMS),
            Setting(
                name = "Iridium", type = dict, required = False,
                default_value = {}, verify_function = self.__verify_iridium),
            Setting(
                name = "clients", type = dict, required = False,
                default_value = {}, verify_function = self.__verify_clients),
            Setting(
                name = "updates", type = dict, required = False,
                default_value = {}, verify_function = self.__verify_updates),
            Setting(
                name = "alarms", type = dict, required = False,
                default_value = {}, verify_function = self.__verify_alarms),
  ]

        PresentationBase.__init__(self, name = name,
                                  settings_list = settings_list)

        # Our dictionary of Transport Managers.
        self.__transport_managers = {}

        # Our cached list of clients.
        self.client_list = []

        # The list of Dia channels that have matched our filters and so we have
        # subscribed to getting channel updates from Dia as they come in.
        self.__channels_being_watched = []

        # The following list will contain a list of messages that should
        # be sent out at the next interval time.

        self.__coalesce_list = []

        self.__stopevent = threading.Event()
        threading.Thread.__init__(self, name = name)
        threading.Thread.setDaemon(self, True)
Exemple #24
0
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services
     
        self.__stopevent = threading.Event()
        
        settings_list = [
                Setting(name="server", type=str, required=True),
                Setting(name="port", type=int, required=True),
                Setting(name='interval', type=int, required=False, default_value=60),
                Setting(name="channels", type=list, required=False, default_value=[]),
        ]
                                                 
        PresentationBase.__init__(self, name=name, settings_list=settings_list)

        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services

        self.__tracer = get_tracer(name)

        # Settings
        # output: the message to output to stdout

        settings_list = [
            Setting(name='output',
                    type=str,
                    required=False,
                    default_value="Hello, World!"),
        ]

        PresentationBase.__init__(self, name=name, settings_list=settings_list)
        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
Exemple #26
0
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services

        import core.tracing as tracing
        self.__tracer = tracing.get_tracer(name)

        # Settings:
        #
        # page: name of presented web page
        # port: port to use.  digiweb ignores this and uses port 80.
        # polling: how frequently to request an update from the server
        #     (passed to javascript in the browser)
        # use_default_httpserver: use digiweb on the ConnectPort,
        #     BaseHTTPServer on other platforms.  If false, always use
        #     BaseHTTPServer.
        # title: set the title of the web page

        ## Settings Table Definition:
        settings_list = [
            Setting(name='page',
                    type=str,
                    required=False,
                    default_value='index'),
            Setting(name='port', type=int, required=False, default_value=8001),
            Setting(name='polling', type=int, required=False, default_value=0),
            Setting(name='use_default_httpserver',
                    type=bool,
                    required=False,
                    default_value=True),
            Setting(name='title',
                    type=str,
                    required=False,
                    default_value='DIA Web Presentation'),
        ]
        ## Initialize settings:
        PresentationBase.__init__(self, name=name, settings_list=settings_list)

        ## Thread initialization:
        self.__stopevent = threading.Event()
        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
Exemple #27
0
    def __init__(self, name, core_services):

        self.__name = name
        self.__core = core_services

        self.queue = Queue()
        self.started_flag = False
        self.monitored_channel = None

        from core.tracing import get_tracer
        self.__tracer = get_tracer(name)

        # Configuration Settings:

        #     to_address: The email address to send the email to
        #     from_address: The from address of the email, defaults to:
        #         [email protected]
        #     subject: The subject of the email, defaults to: iDigi Dia Alert
        #     server_address: The address of the SMTP server
        #     port: The port of the SMTP server, defaults to: 25
        #     monitored_channel: The Channel whose samples are monitored
        #          to determine queueing of the email message.

        settings_list = [
            Setting(name="to_address", type=str, required=True),
            Setting(name="from_address",
                    type=str,
                    required=False,
                    default_value="*****@*****.**"),
            Setting(name="subject",
                    type=str,
                    required=False,
                    default_value="iDigi Dia Alert"),
            Setting(name="server_address", type=str, required=True),
            Setting(name="port", type=int, required=False, default_value=25),
            Setting(name="monitored_channel", type=str, required=True)
        ]

        PresentationBase.__init__(self, name=name, settings_list=settings_list)

        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
Exemple #28
0
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services

        import core.tracing as tracing
        self.__tracer = tracing.get_tracer(name)

        # Settings:
        #
        # page: name of presented web page
        # port: port to use.  digiweb ignores this and uses port 80.
        # polling: how frequently to request an update from the server
        #     (passed to javascript in the browser)
        # use_default_httpserver: use digiweb on the ConnectPort,
        #     BaseHTTPServer on other platforms.  If false, always use
        #     BaseHTTPServer.
        # title: set the title of the web page

        ## Settings Table Definition:
        settings_list = [
            Setting(
                name='page', type=str, required=False, default_value='index'),
            Setting(
                name='port', type=int, required=False, default_value=8001),
            Setting(
                name='polling', type=int, required=False, default_value=0),
            Setting(
                name='use_default_httpserver',
                type=bool, required=False, default_value=True),
            Setting(
                name='title', type=str, required=False,
                        default_value='Dia Web Presentation'),
        ]
        ## Initialize settings:
        PresentationBase.__init__(self, name=name,
                        settings_list=settings_list)

        ## Thread initialization:
        self.__stopevent = threading.Event()
        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
Exemple #29
0
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services

        settings_list = [
            Setting(
                name='type', type=str, required=False, default_value="tcp"),
            Setting(
                name='port', type=int, required=False, default_value=4146),
            Setting(
                name='device', type=str, required=False, default_value="/com/0"),
            Setting(
                name='baudrate', type=int, required=False, default_value=115200),
        ]

        ## Initialize settings:
        PresentationBase.__init__(self, name=name,
                                    settings_list=settings_list)

        ## Thread initialization:
        self.__stopevent = threading.Event()
        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
Exemple #30
0
    def __init__(self, name, core_services):
        """ Create the SMTPHandler presentation service """
        self.__name = name
        self.__core = core_services
             
        self.queue = Queue()
        self.started_flag = False
        self.monitored_channel = None
        
        settings_list = [Setting(name="to_address", type=str, required=True),
                             Setting(name="from_address", type=str, required=False, 
                                             default_value="*****@*****.**"),
                             Setting(name="subject", type=str, required=False, 
                                             default_value=" "),
                             Setting(name="server_address", type=str, required=True, default_value="smtp.gmail.com"),
                             Setting(name="port", type=int, required=False, 
                                             default_value=465),
                             Setting(name="monitored_channel", type=str, required=True)]

        PresentationBase.__init__(self, name=name, settings_list=settings_list)
        
        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
Exemple #31
0
    def __init__(self, name, core_services):

        self.__name = name
        self.__core = core_services

        # Settings:
        #
        # type: must be set to either "tcp" or "serial" (default value: "tcp")
        # port: if type is set to "tcp", 'port' is an integer which specifies
        #     the TCP port number that the console will start upon (default
        #     value: 4146).
        # device: if type is set to "serial", this is the serial port device
        #     name that will be used. (default value: "/com/0").
        # baudrate: if type is set to "serial", this is the baud rate that will
        #     be used. (default value: 115200).

        settings_list = [
            Setting(name='type', type=str, required=False,
                    default_value="tcp"),
            Setting(name='port', type=int, required=False, default_value=4146),
            Setting(name='device',
                    type=str,
                    required=False,
                    default_value="/com/0"),
            Setting(name='baudrate',
                    type=int,
                    required=False,
                    default_value=115200),
        ]

        ## Initialize settings:
        PresentationBase.__init__(self, name=name, settings_list=settings_list)

        ## Thread initialization:
        self.__stopevent = threading.Event()
        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
    def __init__(self, name, core_services):
        
        self.__name = name
        self.__core = core_services
             
        self.queue = Queue()
        self.started_flag = False
        self.monitored_channel = None
		
        from core.tracing import get_tracer
        self.__tracer = get_tracer(name)
        
        # Configuration Settings:

        #     to_address: The email address to send the email to
        #     from_address: The from address of the email, defaults to: 
        #         [email protected]
        #     subject: The subject of the email, defaults to: iDigi Dia Alert
        #     server_address: The address of the SMTP server
        #     port: The port of the SMTP server, defaults to: 25
        #     monitored_channel: The Channel whose samples are monitored
        #          to determine queueing of the email message.
        
        settings_list = [Setting(name="to_address", type=str, required=True),
                             Setting(name="from_address", type=str, required=False, 
                                             default_value="*****@*****.**"),
                             Setting(name="subject", type=str, required=False, 
                                             default_value="iDigi Dia Alert"),
                             Setting(name="server_address", type=str, required=True),
                             Setting(name="port", type=int, required=False, 
                                             default_value=25),
                             Setting(name="monitored_channel", type=str, required=True)]

        PresentationBase.__init__(self, name=name, settings_list=settings_list)
        
        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
    def __init__(self, name, core_services):
        """
        Create an instance of the RCIHandler.

        If the target_name is not specified, it will default to 'idigi_dia'.
        """

        self.__name = name
        self.__core = core_services
        self.__handle = None
        self.addedXML = None

        from core.tracing import get_tracer
        self.__tracer = get_tracer(name)

        settings_list = [
                         Setting(
                                 name='target_name', type=str,
                                 required=False, default_value='idigi_dia'),
                        ]

        ## Initialize settings:
        PresentationBase.__init__(self, name=name,
                                  settings_list=settings_list)
 def __init__(self, name, core_services):
     self.__name = name
     self.__core = core_services
     ## Settings Table Definition:
     self.queue = Queue.Queue()
     settings_list = [
         Setting(
             name='server_ip', type=str, required=False,
             default_value="192.168.33.106"),
         Setting(
             name='server_port', type=int, required=False,
             default_value="8081"),
         Setting(
             name='tx_interval', type=int, required=False,
             default_value=30),
     ]
     
     ## Channel Properties Definition:
     property_list = [ ]
                                         
     ## Initialize the DeviceBase interface:
     PresentationBase.__init__(self, self.__name, settings_list)
     ## Thread initialization:
     self.__stopevent = threading.Event()
     threading.Thread.__init__(self, name=name)
     threading.Thread.setDaemon(self, True)
     
     ## HealthValut functions:
     http_path = "/hv/"
     
     APP_ADDR_PORT = 'http://' + SettingsBase.get_setting(self, "server_ip") + ':' + str(SettingsBase.get_setting(self, "server_port"))
     APP_ACTION_URL = APP_ADDR_PORT + http_path + 'back'
     html_path = APP_ADDR_PORT + http_path
     
     self.hvconn = None
     self.subscribed_channels = []
     self.tx_started = False
     self.hv_ccr_pump_runing = False
     self.hv_ccr_pump_stoped = False
     self.hv_ccr_pump_restart = False
     
     html_header = '\
             <!DOCTYPE html>\
             <html>\
             <head>\
                 <title>Digi HV Presentation</title>\
                 <style type="text/css">\
                     body {\
                         background: url("http://thecodelesscode.com/images/circuits-back.jpg") 0% 0% repeat;\
                         font-size:2.5em;\
                         margin: 0;\
                         padding: 0;\
                         text-align: center;\
                     }\
                     a:link {color:black; text-decoration:none;}\
                     a:visited {color:black; text-decoration:none;}\
                     a:hover {color:red; text-decoration:underline;}\
                     a:active {color:red; text-decoration:underline;}\
                     .centered {margin: 0 auto; text-align: left; display: table;}\
                 </style>\
             </head>\
             <body><div class="centered">'
     html_footer = '</div></body></html>'
     
     @get('')
     @get('index')
     @get(http_path)
     @get(http_path + 'index')
     def IndexPage(request):
         html = html_header + '\
             <a href="' + html_path + 'create" target="_self">Create new App</a>\
             <br><br>\
             <a href="' + html_path + 'login" target="_self">Login new User</a>\
             <br><br>\
             <a href="' + html_path + 'user_list" target="_self">List of Users</a>\
             <br><br>\
             <a href="' + html_path + 'selected" target="_self">Selected User</a>\
             <br><br>'
         if not self.tx_started:
             #html += '<a href="' + html_path + 'tx_start" target="_self">Start HV Data Tx</a>'
             html += '<a href="' + html_path + 'tx_control" target="_self">Start HV Data Tx</a>'
         else:
             #html += '<a href="' + html_path + 'tx_stop" target="_self">Stop HV Data Tx</a>'
             html += '<a href="' + html_path + 'tx_control" target="_self">Stop HV Data Tx</a>'
         html += '\
             <br><br>\
             <a href="' + html_path + 'channels" target="_self">Channel Explorer</a>'
         html += html_footer
         
         return Response(html, content_type='text/html')
     
     @get(http_path + 'create')
     def CreateAppInstance(request):
         self.hvconn = HealthVaultConn(path)
         
         d = {}
         d['appid'] = HV_APPID
         d['appCreationToken'] = self.hvconn.instance_creation_token
         d['instancename'] = 'iDigi Dia MS_HV presentation'
         d['redirect'] = APP_ACTION_URL
         
         targetqs = urlencode(d)
         url = "%s/redirect.aspx?%s" % (HV_SHELL_URL, urlencode({'target': "CREATEAPPLICATION", 'targetqs': targetqs}))
         raise Redirect(url)
     
     @get(http_path + 'login')
     def LoginNewUser(request):
         if(self.hvconn == None):
             raise Redirect(html_path + 'create')
         
         d = {}
         d['appid'] = self.hvconn.instance_app_id
         d['redirect'] = APP_ACTION_URL
         
         targetqs = urlencode(d)
         url = "%s/redirect.aspx?%s" % (HV_SHELL_URL, urlencode({'target': "APPAUTH", 'targetqs': targetqs}))
             
         raise Redirect(url)
     
     @get(http_path + 'back')
     def ShellRedirectionPoint(request):
         if(self.hvconn == None):
             raise Redirect(html_path + 'create')
         self.hvconn.createAuthenticatedSessionToken()
         html = html_header + '\
             Success\
             <br><br>\
             <a href="' + html_path + 'index" target="_self">Back to Index Page</a>'
         html += html_footer
         return Response(html, content_type='text/html')
     
     @get(http_path + 'user_list')
     def AuthorizedPeopleList(request):
         if(self.hvconn == None):
             raise Redirect(html_path + 'create')
         self.hvconn.getAuthorizedPeople()
         #users = ''
         html = html_header
         for i in self.hvconn.user_dict:
             name = self.hvconn.user_dict[i]["name"]
             html += '\
             <a href="' + html_path + 'select/' + name.replace(' ', '_') + '" target="_self">' + name + '</a>\
             <br><br>'
         html += '\
             <a href="' + html_path + 'index" target="_self">Back to Index Page</a>'
         html += html_footer
         return Response(html, content_type='text/html')
         
     @get(http_path + 'select/(?P<name>\w+)')
     def SelectUser(request, name=None):
         if(self.hvconn == None):
             raise Redirect(html_path + 'create')
         name = name.replace('_', ' ')
         if name == self.hvconn.selected_user:
             message = 'User already selected.'
         else:
             message = 'User not found.'
             for i in self.hvconn.user_dict:
                 if name == self.hvconn.user_dict[i]["name"]:
                     found = 1
                     self.hvconn.userSelect(name)
                     self.hv_ccr_pump_reset()
                     message = 'User selected.'
         html = html_header +'\
             ' + message + '\
             <br><br>\
             <a href="' + html_path + 'index" target="_self">Back to Index Page</a>'
         html += html_footer
         return Response(html, content_type='text/html')
     
     @get(http_path + 'selected')
     def SelectedUser(request):
         if(self.hvconn == None):
             raise Redirect(html_path + 'create')
         user = self.hvconn.selected_user#.replace(' ', '_')
         html = html_header + '\
             Selected User: '******'\
             <br><br>\
             <a href="' + html_path + 'index" target="_self">Back to Index Page</a>'
         html += html_footer
         return Response(html, content_type='text/html')
     
     @get(http_path + 'tx_control')
     def TxControl(request):
         if(self.hvconn == None):
             raise Redirect(APP_ADDR_PORT + '/create')
         
         if not self.tx_started:
             self.tx_started = True
             self.hv_ccr_pump_start()
             html = html_header +'\
                 Auto Data Tx Started!\
                 <br><br>\
                 <a href="' + html_path + 'index" target="_self">Back to Index Page</a>'
         else:
             self.tx_started = False
             self.hv_ccr_pump_stop()
             html = html_header +'\
                 Auto Data Tx Stopped!\
                 <br><br>\
                 <a href="' + html_path + 'index" target="_self">Back to Index Page</a>'
         html += html_footer
             
         return Response(html, content_type='text/html')
     
     
     @get(http_path + 'tx_start')
     def TxStart(request):
         if(self.hvconn == None):
             raise Redirect(APP_ADDR_PORT + '/create')
         if not self.tx_started:
             self.tx_started = True
         self.hv_ccr_pump_start()
         html = html_header +'\
             Auto Data Tx Started!\
             <br><br>\
             <a href="' + html_path + 'index" target="_self">Back to Index Page</a>'
         html += html_footer
         return Response(html, content_type='text/html')
     
     @get(http_path + 'tx_stop')
     def TxStop(request):
         if(self.hvconn == None):
             raise Redirect(html_path + 'create')
         if self.tx_started:
             self.tx_started = False
         self.hv_ccr_pump_stop()
         html = html_header +'\
             Auto Data Tx Stopped!\
             <br><br>\
             <a href="' + html_path + 'index" target="_self">Back to Index Page</a>'
         html += html_footer
         return Response(html, content_type='text/html')
     
     @get(http_path + 'channels')
     def ChannelExplorer(request):
         if(self.hvconn == None):
             raise Redirect(html_path + 'create')
         
         cm = self.__core.get_service("channel_manager")
         cd = cm.channel_database_get()
         channel_list = cd.channel_list()
         
         html = html_header +'\
             Existing Channels:\
             <br><br>'
         for channel_name in channel_list:
             if channel_name in self.subscribed_channels:
                 html += '<a href="' + html_path + 'subscriber/' + channel_name + '" target="_self">Unsubscribe from: '+channel_name+'</a>'
             else:
                 html += '<a href="' + html_path + 'subscriber/' + channel_name + '" target="_self">Subscribe to: '+channel_name+'</a>'
             html += '<br><br>'
         html += '\
             <a href="' + html_path + 'index" target="_self">Back to Index Page</a>'
         html += html_footer
         return Response(html, content_type='text/html')
     
     @get(http_path + 'subscriber/(?P<channel_name>[\w\-._%]+)')
     def ChannelSubscriber(request, channel_name=None):
         if(self.hvconn == None):
             raise Redirect(html_path + 'create')
         channel_name=channel_name.replace('%20', ' ')
         if channel_name in self.subscribed_channels:
             #unsubscribe:
             self.unsubscriber(channel_name)
             self.subscribed_channels.remove(channel_name)
         else:
             #subscribe:
             self.subscriber(channel_name)
             self.subscribed_channels.append(channel_name)
         raise Redirect(html_path + 'channels')
     
     @get(http_path + 'get')
     def GetThing(request):
         if(self.hvconn == None):
             raise Redirect(APP_ADDR_PORT + '/create')
         try:
             personaldemographic = "92ba621e-66b3-4a01-bd73-74844aed4f5b"
             
             response_str = self.hvconn.getBasicThing(personaldemographic)
             return Response(response_str, content_type='text/xml')
             
         except:
             traceback.print_exc()
             
         return Response(response_str, content_type='text/xml')
     ##############################################################################
     @get(http_path + 'put_ccr')
     def PutThing_CCR(request):
         if(self.hvconn == None):
             raise Redirect(APP_ADDR_PORT + '/create')
         
         try:
             personaldemographic = "92ba621e-66b3-4a01-bd73-74844aed4f5b"
             ccr = "1e1ccbfc-a55d-4d91-8940-fa2fbf73c195"
             
             response_str = self.hvconn.getBasicThing(personaldemographic)
             
             dom = minidom.parseString(response_str)
             
             node = dom.getElementsByTagName("first")
             first_name = node.pop().firstChild.nodeValue    
             
             node = dom.getElementsByTagName("last")
             family_name = node.pop().firstChild.nodeValue    
             
             node = dom.getElementsByTagName("y")
             year = node.pop().firstChild.nodeValue
             
             node = dom.getElementsByTagName("m")
             month = node.pop().firstChild.nodeValue
             
             node = dom.getElementsByTagName("d")
             day = node.pop().firstChild.nodeValue
             
             date_of_birth = year + '-' + month + '-' + day
     
         except:
             traceback.print_exc()
             
         ccr_xml = self.Channels_to_CCR(first_name, family_name, date_of_birth)
         response_str = self.hvconn.putBasicThing(ccr, ccr_xml)
         
         return Response(response_str, content_type='text/xml')
Exemple #35
0
    def __init__(self, name, core_services):
        """Performs startup initializations.  It verifies and loads the settings list."""
        
        self.logger = init_module_logger(name)
               
        self.__name = name
        self.__core = core_services        
        
        self.destinations = []
        self.request_channel_to_wp0_dd = None

        self.server_conn_handle = None
        self.keep_alive_timer = 0
        self.waiting_for_reply = False
        self.gateway_v1_backward_compatibility = False
        self.msg_size_on_7_bits = True
        self.radio_responses = Queue.Queue(8)
        
        # watchdogs
        self.mainloop_made_a_pause = None
        self.mainloop_made_one_loop = None
        
 
        #initialisation of the modem handler
        self.m10_handler = m10_sc_api.m10_sc_api(self.logger)
        
        settings_list = [
            Setting(
                name='destinations', type=list, required=False, default_value=[{'value':0, 'device_driver_name':'waveport'}]),
            Setting(
                name='gateway_v1_backward_compatibility', type=bool, required=False, default_value=True),
            Setting(
                name='msg_size_on_7_bits', type=bool, required=False, default_value=True),
            Setting(
                name='do_waveport_initialization', type=bool, required=False, default_value=False),
            Setting(
                name='port_num', type=int, required=True),
            Setting(
                name='baudrate', type=int, required=False, default_value=4800,
                    verify_function=lambda x: x > 0),
            Setting(
                name='log_level', type=str, required=False, default_value='DEBUG',
                 verify_function=check_debug_level_setting),
                         
            Setting(
                name='desired_gateway', type=str, required=False, default_value='GATEWAY_EUROPE',
                 verify_function=lambda key: verify_if_configuration_command_value_is_valid(m10_sc_api.DESIRED_GATEWAY_VALUES, key)),
            Setting(
                name='def_polled', type=str, required=False, default_value='SC_POLL_MODE_IMMEDIATE',
                 verify_function=lambda key: verify_if_configuration_command_value_is_valid(m10_sc_api.SC_POLL_MODE_VALUES, key)),
            Setting(
                name='def_ack_level', type=str, required=False, default_value='ACK_LEVEL_DELIVERY_ORBCOMM',
                 verify_function=lambda key: verify_if_configuration_command_value_is_valid(m10_sc_api.ACK_LEVEL_VALUES, key)),
                         
            Setting(
                name='def_rep_or_ind', type=str, required=False, default_value=m10_sc_api.DEFAULT_OR_IND_REPORTS),
            Setting(
                name='def_msg_or_ind', type=str, required=False, default_value=m10_sc_api.DEFAULT_OR_IND_MES),
                         
            Setting(
                name='def_priority', type=str, required=False, default_value='PRIORITY_LVL_NORMAL',
                 verify_function=lambda key: verify_if_configuration_command_value_is_valid(m10_sc_api.PRIORITY_LVL, key)),
            Setting(
                name='def_msg_body_type', type=str, required=False, default_value='MSG_BODY_TYPE_ASCII',
                 verify_function=lambda key: verify_if_configuration_command_value_is_valid(m10_sc_api.MSG_BODY_TYPE_VALUES, key)),
            Setting(
                name='def_serv_type', type=str, required=False, default_value='REPORTS_SERVICE_TYPE_NORMAL_PRIORITY_DELIVERY_ORBCOMM',
                 verify_function=lambda key: verify_if_configuration_command_value_is_valid(m10_sc_api.REPORTS_SERVICE_TYPE_VALUES, key)),
            Setting(
                name='gwy_search_mode', type=str, required=False, default_value='GWY_SEARCH_MODE_0',
                 verify_function=lambda key: verify_if_configuration_command_value_is_valid(m10_sc_api.GWY_SEARCH_MODE_VALUES, key))       
        ]

        ## Initialize settings:
        PresentationBase.__init__(self, name=name,
                                    settings_list=settings_list)
        ## Thread initialization:
        self.__stopevent = threading.Event()
        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)
Exemple #36
0
    def __init__(self, name, core_services):

        self.__name = name
        self.__core = core_services

        self._logger = init_module_logger(name)
        self._published_ip_address = None

        # Configuration Settings:

        settings_list = [
            Setting(name="hostname", type=str, required=True),
            Setting(name="domainname",
                    type=str,
                    required=False,
                    default_value="dtdns.net"),
            Setting(name="dtdns_server_host",
                    type=str,
                    required=False,
                    default_value="www.dtdns.com"),
            Setting(name="dtdns_server_port",
                    type=int,
                    required=False,
                    default_value=80),
            Setting(name="dtdns_password", type=str, required=True),
            Setting(name="use_proxy",
                    type=bool,
                    required=False,
                    default_value=False),
            Setting(name="proxy_host",
                    type=str,
                    required=False,
                    default_value="proxy"),
            Setting(name="proxy_port",
                    type=int,
                    required=False,
                    default_value=8080),
            Setting(name="address_update_rate",
                    type=int,
                    required=False,
                    default_value=600),
            Setting(name="check_for_valid_address_rate",
                    type=int,
                    required=False,
                    default_value=30),
            Setting(name="interface",
                    type=str,
                    required=False,
                    default_value='mobile0'),
            Setting(name="no_digicli",
                    type=bool,
                    required=False,
                    default_value=False),
            Setting(name='log_level',
                    type=str,
                    required=False,
                    default_value='DEBUG',
                    verify_function=check_debug_level_setting),
        ]

        PresentationBase.__init__(self, name=name, settings_list=settings_list)

        self.__stopevent = threading.Event()

        return
Exemple #37
0
    def __init__(self, name, core_services):

        self.__name = name
        self.__core = core_services
        self.__stopevent = core_services

        self.__tracer = get_tracer(name)

        # Settings
        # initial_upload: is the number of seconds before the first initial
        #     upload.  If it is not specified, initial upload is disabled.
        # interval: is the maximum interval in seconds that this module waits
        #     before sending data to the Device Cloud Manager Database.  If it is
        #     equal to 0, the feature is disabled.
        # sample_threshold: is the mininum number of samples required before
        #     sending data to the Device Cloud Manager Database.  If it is equal to
        #     0, the feature is disabled.
        # collection: is the collection on the database where the data will
        #     be stored.
        # file_count: the number of unique files we will keep on Device Cloud.
        # filename: the name of the xml file we will push to Device Cloud, with
        #     a number appended to the end (cycling from 1 to file_count)
        # channels: is the list of channels the module is subscribed to.
        #     If no channels are listed, all channels are subscribed to.
        # compact_xml: (when set to True) will produce output XML with the
        #     information stored as attributes to the sample node instead of
        #     separately tagged, resulting in smaller XML output.

        settings_list = [
            Setting(name='initial_upload',
                    type=int,
                    required=False,
                    default_value=None),
            Setting(name='interval',
                    type=int,
                    required=False,
                    default_value=60),
            Setting(name='sample_threshold',
                    type=int,
                    required=False,
                    default_value=10),
            Setting(name='collection',
                    type=str,
                    required=False,
                    default_value=""),
            Setting(name="channels",
                    type=list,
                    required=False,
                    default_value=[]),
            Setting(name='file_count',
                    type=int,
                    required=False,
                    default_value=20),
            Setting(name='filename',
                    type=str,
                    required=False,
                    default_value="sample"),
            Setting(name='secure',
                    type=bool,
                    required=False,
                    default_value=True),
            Setting(name='compact_xml',
                    type=bool,
                    required=False,
                    default_value=False),
        ]

        PresentationBase.__init__(self, name=name, settings_list=settings_list)
        self.__stopevent = threading.Event()
        threading.Thread.__init__(self, name=name)
        threading.Thread.setDaemon(self, True)