def __init__(self, name, core_services):

        ## These will be created by XBeeSerial
        # self._name = name
        # self._core = core_services
        # self._tracer = get_tracer(name)
        # self._xbee_manager = None
        # self._extended_address = None

        ## Local State Variables:
        self.__request_events = []
        self.__request_retry_events = []
        self._loopback_data = ""
        self._loopback_attempts = 0
        self._loopback_passes = 0
        self._loopback_fails = 0
        self._loopback_total_bytes_sent = 0
        self._loopback_total_bytes_received = 0

        ## Settings Table Definition:
        settings_list = [
            Setting(
                name='loop_rate_sec', type=int, required=False,
                default_value=5,
                verify_function=lambda x: x >= 0),
            Setting(
                name='packet_size', type=int, required=False,
                default_value=5,
                verify_function=lambda x: x <= 10),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(name="attempts", type=int,
                initial=Sample(timestamp=0, value=0),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="total_bytes_sent", type=int,
                initial=Sample(timestamp=0, value=0),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="total_bytes_received", type=int,
                initial=Sample(timestamp=0, value=0),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="passes", type=int,
                initial=Sample(timestamp=0, value=0),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="fails", type=int,
                initial=Sample(timestamp=0, value=0),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
        ]

        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, name, core_services,
                                settings_list, property_list)

        self._tracer.calls("XBeeLoopBack.__init__()")
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services

        ## Local State Variables:
        self.__xbee_manager = None
        self.__response_buffer = ""
        self.__request_events = []
        self.__request_retry_events = []

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

        ## Settings Table Definition:
        settings_list = [
            Setting(
                name='poll_rate_sec', type=int, required=False,
                default_value=5,
                verify_function=lambda x: x >= 0),
            Setting(
                name='bus_id', type=int, required=False,
                default_value=0,
                verify_function=lambda x: x >= 0),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(name="strength", type=int,
                initial=Sample(timestamp=0, value=0, unit="%"),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),

            ChannelSourceDeviceProperty(name="target_detected", type=Boolean,
                initial=Sample(timestamp=0,
                    value=Boolean(False, style=STYLE_YESNO)),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),

            ChannelSourceDeviceProperty(name="error_flag", type=Boolean,
                initial=Sample(timestamp=0,
                    value=Boolean(False, style=STYLE_YESNO)),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),

            ChannelSourceDeviceProperty(name="range", type=int,
                initial=Sample(timestamp=0, value=0, unit="in"),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),

            ChannelSourceDeviceProperty(name="temperature", type=float,
                initial=Sample(timestamp=0, value=0.0, unit="C"),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
        ]

        ## Initialize the DeviceBase interface:
        XBeeSerial.__init__(self, self.__name, self.__core,
                                settings_list, property_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)

        ## Local State Variables:
        self.__xbee_manager = None

        ## Settings Table Definition:
        settings_list = []

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(
                name="read",
                type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET,
                options=DPROP_OPT_AUTOTIMESTAMP,
            ),
            ChannelSourceDeviceProperty(
                name="write",
                type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET | DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=self.serial_write,
            ),
        ]

        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, self.__name, self.__core, settings_list, property_list)
Esempio n. 4
0
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services
        self.__event_timer2 = None
        self.local = 0
        self.hour_timer = 0
        self.source2 = None 
        self.source1 = None
        self.ud_once = 0
        self.sched = 0
        self.w_retry = 0
        self.timer_c = 0
        self.main_addr = "mainMistaway_" + gw_extended_address()
        self.last_temp = 0
        


        ## Local State Variables:
        self._count = 0
        self.__xbee_manager = None
        self.update_timer = None
        self.modes = {"O":0, "H":1, "C":2, "A":3}
        self.count = 0
        

        ## Settings Table Definition:
        settings_list = [
            Setting(
                name='xbee_device_manager', type=str, required=True),
            Setting(
                name='compact_xml', type=bool, required=False, default_value=False),
            Setting(
                name="channels", type=list, required=False, default_value=[]),
            Setting(
                name='extended_address', type=str, required=True),
            Setting(
                name='sample_rate_sec', type=int, required=False,
                default_value=300,
                verify_function=lambda x: x >= 10 and x < 0xffff),
        ]

        ## Channel Properties Definition
       
        
        
        
        property_list = [
                         
            ChannelSourceDeviceProperty(name="SS", type=str,
                initial=Sample(timestamp=0, unit="", value="System is Idle"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="ST", type=str,
                initial=Sample(timestamp=0, unit="R,W,I", value="0"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="med", type=str,
                initial=Sample(timestamp=0, unit="med", value="0"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="w_t", type=str,
                initial=Sample(timestamp=0, unit="degF", value="60"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="w_h", type=str,
                initial=Sample(timestamp=0, unit="percent", value="O"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
          
            
            ChannelSourceDeviceProperty(name="sch", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("sch", x)),
            
            ChannelSourceDeviceProperty(name="err", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("err", x)),
            
            ChannelSourceDeviceProperty(name="hour", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_hour("hour", x)),
            
            
            
            ChannelSourceDeviceProperty(name="heat_4", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="heat_5", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="heat_7", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
                   
            ChannelSourceDeviceProperty(name="heat_6", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            
            
            
           
            
            
            # setable channesls
            
            
            
            ChannelSourceDeviceProperty(name="f_count", type=int,
                initial=Sample(timestamp=0, unit="failed", value=0),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.send_failed("f_count", x)),
            
            ChannelSourceDeviceProperty(name="hd1_on1", type=str,
                initial=Sample(timestamp=0, unit="degF", value="4"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("hd1_on1", x)),
            
            ChannelSourceDeviceProperty(name="hd1_off1", type=str,
                initial=Sample(timestamp=0, unit="degF", value="4"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("hd1_off1", x)),
            
            ChannelSourceDeviceProperty(name="ot_on1", type=str,
                initial=Sample(timestamp=0, unit="degF", value="0"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("ot_on1", x)),
            
            ChannelSourceDeviceProperty(name="mode1", type=str,
                initial=Sample(timestamp=0, unit="o/h/c/a", value="O"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("mode1", x)),
                      
            ChannelSourceDeviceProperty(name="dev_h1", type=str,
                initial=Sample(timestamp=0, unit="dev", value="3"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("dev_h1", x)),
            
            ChannelSourceDeviceProperty(name="dev_l1", type=str,
                initial=Sample(timestamp=0, unit="dev", value="3"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("dev_l1", x)),         
                   
            ChannelSourceDeviceProperty(name="splt1", type=str,
                initial=Sample(timestamp=0, unit="degF", value="65"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("splt1", x)),
            
            ChannelSourceDeviceProperty(name="hd1_on2", type=str,
                initial=Sample(timestamp=0, unit="degF", value="4"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("hd1_on2", x)),
            
            ChannelSourceDeviceProperty(name="hd1_off2", type=str,
                initial=Sample(timestamp=0, unit="degF", value="4"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("hd1_off2", x)),
            
            ChannelSourceDeviceProperty(name="ot_on2", type=str,
                initial=Sample(timestamp=0, unit="degF", value="0"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("ot_on2", x)),
            
            ChannelSourceDeviceProperty(name="mode2", type=str,
                initial=Sample(timestamp=0, unit="o/h/c/a", value="O"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("mode2", x)),
                      
            ChannelSourceDeviceProperty(name="dev_h2", type=str,
                initial=Sample(timestamp=0, unit="dev", value="3"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("dev_h2", x)),
            
            ChannelSourceDeviceProperty(name="dev_l2", type=str,
                initial=Sample(timestamp=0, unit="dev", value="3"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("dev_l2", x)),         
                   
            ChannelSourceDeviceProperty(name="splt2", type=str,
                initial=Sample(timestamp=0, unit="degF", value="65"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("splt2", x)),
            
            
            ChannelSourceDeviceProperty(name="ot_on", type=str,
                initial=Sample(timestamp=0, unit="degF", value="0"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("ot_on", x)),
            
            
            ChannelSourceDeviceProperty(name="dev_h", type=str,
                initial=Sample(timestamp=0, unit="dev", value="3"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("dev_h", x)),
            
            ChannelSourceDeviceProperty(name="dev_l", type=str,
                initial=Sample(timestamp=0, unit="dev", value="3"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("dev_l", x)),         
                   
            
            ChannelSourceDeviceProperty(name="zip", type=str,
                initial=Sample(timestamp=0, unit="zip", value="10001"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_name("zip", x)),
            
            
            
            
            # gettable properties
            ChannelSourceDeviceProperty(name="serialReceive", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="serialSend", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=self.serial_send),
            ChannelSourceDeviceProperty(name="current_temp", type=int,
                initial=Sample(timestamp=0, unit="degF", value=0),
                perms_mask=(DPROP_PERM_GET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="spt", type=int,
                initial=Sample(timestamp=0, unit="fF", value=75),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_sp(x.value)),
            ChannelSourceDeviceProperty(name="spht", type=int,
                initial=Sample(timestamp=0, unit="fF", value=80),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_sph(x.value)),
            ChannelSourceDeviceProperty(name="splt", type=int,
                initial=Sample(timestamp=0, unit="fF", value=65),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_spc(x.value)),
            ChannelSourceDeviceProperty(name="mode", type=str,
                initial=Sample(timestamp=0, unit="o/h/c/a", value="Off"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_mode(x.value)),
            ChannelSourceDeviceProperty(name="fan", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(True, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_fan(x.value)),
            ChannelSourceDeviceProperty(name="ac_1", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),                
                options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="ac_2", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="heat_1", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="heat_2", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="heat_3", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="read", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="set_current_temp", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_temp(x.value)),
            
            ChannelSourceDeviceProperty(name="outside_temp", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_outside(x.value)),
            
            ChannelSourceDeviceProperty(name="lock", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_lock(x.value)),
            
            ChannelSourceDeviceProperty(name="hd1_off", type=str,
                initial=Sample(timestamp=0, unit="", value="4"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_hd1_off(x.value)),
            
            ChannelSourceDeviceProperty(name="hd1_on", type=str,
                initial=Sample(timestamp=0, unit="", value="4"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_hd1_on(x.value)),
            
            ChannelSourceDeviceProperty(name="mrt", type=str,
                initial=Sample(timestamp=0, unit="", value="4"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_mrt(x.value)),
            
            ChannelSourceDeviceProperty(name="mot", type=str,
                initial=Sample(timestamp=0, unit="", value="4"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.set_mot(x.value)),
            
            ChannelSourceDeviceProperty(name="write", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=self.serial_write),
        ]

        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, self.__name, self.__core,    
                                settings_list, property_list)
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services
        self.__event_timer2 = None


        ## Local State Variables:
        self._count = 0
        self.__xbee_manager = None
        self.update_timer = None
        self.modes = {"O":0, "H":1, "C":2, "A":3}
        self.count = 0
        

        ## Settings Table Definition:
        settings_list = [
            Setting(
                name='xbee_device_manager', type=str, required=True),
            Setting(
                name='compact_xml', type=bool, required=False, default_value=False),
            Setting(
                name="channels", type=list, required=False, default_value=[]),
            Setting(
                name='extended_address', type=str, required=True),
            Setting(
                name='sample_rate_sec', type=int, required=False,
                default_value=300),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(name="signal", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="mist_cycle", type=str,
                initial=Sample(timestamp=0, unit="F", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="pm", type=str,
                initial=Sample(timestamp=0, unit="F", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="status", type=str,
                initial=Sample(timestamp=0, unit="F", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="serialReceive", type=str,
                initial=Sample(timestamp=0, unit="F", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="serialSend", type=str,
                initial=Sample(timestamp=0, unit="F", value=" "),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=self.serial_write),
            ChannelSourceDeviceProperty(name="r", type=str,
                initial=Sample(timestamp=0, unit="F", value="not_set"),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.new_update("r", x)),
            ChannelSourceDeviceProperty(name="cartridge_remaining_volume", type=int,
                initial=Sample(timestamp=0, unit="F", value=1),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
           #     set_cb=lambda x: self.set_sph("cartridge_remaining_volume", x)),
            ChannelSourceDeviceProperty(name="cartridge_full_volume", type=int,
                initial=Sample(timestamp=0, unit="F", value=1),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
        #        set_cb=lambda x: self.set_sph("cartridge_full_volume", x)),
            ChannelSourceDeviceProperty(name="crc", type=int,
                initial=Sample(timestamp=0, unit="F", value=1),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
        #        set_cb=lambda x: self.set_sph("crc", x)),
                
            
        ]

        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, self.__name, self.__core,    
                                settings_list, property_list)
    def __init__(self, name, core_services):

        ## These will be created by XBeeSerial
        # self._name = name
        # self._core = core_services
        # self._tracer = get_tracer(name)
        # self._xbee_manager = None
        # self._extended_address = None

        # local variables used for packing of multiple rcv packets
        self.rcv_buffer = ''
        self.__chr_timer = None

        # create a resource semaphore for receiving and timeout
        self.__rcv_lock = threading.Lock()

        # local variables used for append/strip EOLN
        self.__eoln_save = None
        self._eoln = None

        ## Settings Table Definition:
        settings_list = [
            # if True, then data is converted from hexadecimal to binary
            # if False, then data is assumed ASCII (or raw)
            Setting(
                name='hexadecimal', type=bool, required=False,
                default_value=self.DEF_HEXDEC),

            # add/strip an end-of-line sequence
            # set to None to disable
            # else likely set to '\r', '\n', or '\r\n'
            # other escapes need to be of the form '\xXX', which XX is
            # exactly 2 hexadecimal bytes. Example: '\x0D' is '\r'
            Setting(
                name='eoln', type=str, required=False,
                default_value=self.DEF_EOLN),

            # character timeout to 'pack' data into a single receive
            Setting(
                name='char_timeout', type=float, required=False,
                default_value=self.DEF_CHARTOUT,
                verify_function=lambda x: x == 0.0 or x >= 0.25),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(name="read", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="write", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=self.serial_write),
        ]

        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, name, core_services,
                                settings_list, property_list)

        self._tracer.calls("XBeeSerialTerminal.__init__()")
Esempio n. 7
0
    def __init__(self, name, core_services):

        ## These will be created by XBeeSerial
        # self._name = name
        # self._core = core_services
        # self._tracer = get_tracer(name)
        # self._xbee_manager = None
        # self._extended_address = None

        ## Local State Variables:
        self.__request_events = []
        self.__request_retry_events = []
        self._loopback_data = ""
        self._loopback_attempts = 0
        self._loopback_passes = 0
        self._loopback_fails = 0
        self._loopback_total_bytes_sent = 0
        self._loopback_total_bytes_received = 0

        ## Settings Table Definition:
        settings_list = [
            Setting(name='loop_rate_sec',
                    type=int,
                    required=False,
                    default_value=5,
                    verify_function=lambda x: x >= 0),
            Setting(name='packet_size',
                    type=int,
                    required=False,
                    default_value=5,
                    verify_function=lambda x: x <= 10),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(name="attempts",
                                        type=int,
                                        initial=Sample(timestamp=0, value=0),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="total_bytes_sent",
                                        type=int,
                                        initial=Sample(timestamp=0, value=0),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="total_bytes_received",
                                        type=int,
                                        initial=Sample(timestamp=0, value=0),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="passes",
                                        type=int,
                                        initial=Sample(timestamp=0, value=0),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="fails",
                                        type=int,
                                        initial=Sample(timestamp=0, value=0),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
        ]

        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, name, core_services, settings_list,
                            property_list)

        self._tracer.calls("XBeeLoopBack.__init__()")
Esempio n. 8
0
    def __init__(self, name, core_services):

            ## These will be created by XBeeSerial
        # self._name = name
        # self._core = core_services
        # self._tracer = get_tracer(name)
        # self._xbee_manager = None
        # self._extended_address = None

        ## Local State Variables:
        self.__response_buffer = ""
        self.__request_event = None
        self.__mode = self.MODE_IDLE
        self.__req_cnt = 0
        self.__rsp_cnt = 0
        self.__sensor = None

        ## Over-ride our parent's settings
        self.DEF_BAUDRATE = 19200
        self.DEF_PARITY = 'none'
        self.DEF_STOPBITS = 1
        self.DEF_HWFLOW = '485'

        ## Settings Table Definition:
        settings_list = [
            Setting(
                name='poll_rate_sec', type=int, required=False,
                default_value=5,
                verify_function=lambda x: x >= 1),
            Setting(
                name='bus_id', type=int, required=False,
                default_value=1,
                verify_function=lambda x: x >= 0),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(name="strength", type=int,
                initial=Sample(timestamp=0, value=0, unit="%"),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),

            ChannelSourceDeviceProperty(name="target_detected", type=Boolean,
                initial=Sample(timestamp=0,
                    value=Boolean(False, style=STYLE_YESNO)),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),

            ChannelSourceDeviceProperty(name="error_flag", type=Boolean,
                initial=Sample(timestamp=0,
                    value=Boolean(False, style=STYLE_YESNO)),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),

            ChannelSourceDeviceProperty(name="range", type=float,
                initial=Sample(timestamp=0, value=0.0, unit="in"),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),

            ChannelSourceDeviceProperty(name="temperature", type=float,
                initial=Sample(timestamp=0, value=0.0, unit="C"),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),

            ChannelSourceDeviceProperty(name="availability", type=float,
                initial=Sample(timestamp=0, value=0.0, unit="prc"),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
        ]

        ## Initialize the DeviceBase interface:
        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, name, core_services,
                                settings_list, property_list)

        self._tracer.calls("MassaM300.__init__()")
Esempio n. 9
0
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services
        self.radio_requests_from_presentation_queue = Queue.Queue(8)
        self.radio_message_from_waveport_queue = Queue.Queue(1024)

        self.init_module_logger()

        ## Settings Table Definition:
        settings_list = [
            Setting(name='log_level',
                    type=str,
                    required=False,
                    default_value='DEBUG',
                    verify_function=self.check_debug_level_setting),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(name="response",
                                        type=str,
                                        initial=Sample(timestamp=0,
                                                       value="stres"),
                                        perms_mask=DPROP_PERM_GET
                                        | DPROP_PERM_SET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),

            # settable properties
            ChannelSourceDeviceProperty(name="request",
                                        type=str,
                                        initial=Sample(timestamp=0,
                                                       value="streq"),
                                        perms_mask=DPROP_PERM_GET
                                        | DPROP_PERM_SET,
                                        options=DPROP_OPT_AUTOTIMESTAMP,
                                        set_cb=self.request_channel_cb),
        ]

        ## Local State Variables:
        self.__xbee_manager = None

        ## Initialize the XBeeSerial interface:
        self.logger.debug("Initialize XBeeSerial")
        XBeeSerial.__init__(self, self.__name, self.__core, settings_list,
                            property_list)

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

        # Arm watchdogs
        if (on_digi_board()):
            self.mainloop_made_one_loop = digiwdog.Watchdog(
                MAIN_LOOP_STILL_LOOPING_WATCHOG_DELAY,
                "AO Presentation main loop no more looping. Force reset")
            self.mainloop_made_a_pause = digiwdog.Watchdog(
                MAIN_LOOP_IS_NOT_INSTANTANEOUS_WATCHDOG_DELAY,
                "AO Presentation main loop no more looping. Force reset")
        else:
            self.mainloop_made_one_loop = None
            self.mainloop_made_a_pause = None
Esempio n. 10
0
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services
        self.__event_timer2 = None
        self.string = ""


        ## Local State Variables:
        self._count = 0
        self.__xbee_manager = None
        self.update_timer = None
        self.modes = {"O":0, "H":1, "C":2, "A":3}
        self.count = 0
        

        ## Settings Table Definition:
        settings_list = [
            Setting(
                name='xbee_device_manager', type=str, required=True),
            Setting(
                name='compact_xml', type=bool, required=False, default_value=False),
            Setting(
                name="channels", type=list, required=False, default_value=[]),
            Setting(
                name='extended_address', type=str, required=True),
            Setting(
                name='sample_rate_sec', type=int, required=False,
                default_value=30,
                verify_function=lambda x: x >= 10 and x < 0xffff),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
			            
			
            ChannelSourceDeviceProperty(name="hd1_on", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("hd1_on", x)),
            
            ChannelSourceDeviceProperty(name="cd1_on", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("cd1_on", x)),
            
            ChannelSourceDeviceProperty(name="hd1_off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("hd1_off", x)),
            
            ChannelSourceDeviceProperty(name="cd1_off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("cd1_off", x)),
                  
            ChannelSourceDeviceProperty(name="hd2_on", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("hd2_on", x)), 
            
            ChannelSourceDeviceProperty(name="hd2_off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("hd2_off", x)),
            
            ChannelSourceDeviceProperty(name="hd3_on", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("hd3_on", x)),
            
            ChannelSourceDeviceProperty(name="hd3_off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("hd3_off", x)),
            
            ChannelSourceDeviceProperty(name="cd2_on", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("cd2_on", x)),
                  
            
            ChannelSourceDeviceProperty(name="cd2_off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("cd2_off", x)),
            
            ChannelSourceDeviceProperty(name="tm", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("tm", x)),
            
            ChannelSourceDeviceProperty(name="mont", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("mont", x)),
            
            ChannelSourceDeviceProperty(name="mofft", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("mofft", x)),
            
            ChannelSourceDeviceProperty(name="cs", type=str,
			      initial=Sample(timestamp=0, unit="", value="O"),
			      perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
			      options=DPROP_OPT_AUTOTIMESTAMP,
			      set_cb=lambda x: self.update("cs", x)),
			
            ChannelSourceDeviceProperty(name="ht1on", type=str,
			      initial=Sample(timestamp=0, unit="", value="O"),
			      perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
			      options=DPROP_OPT_AUTOTIMESTAMP,
			      set_cb=lambda x: self.update("ht1on", x)),
			
            ChannelSourceDeviceProperty(name="ht2on", type=str,
			      initial=Sample(timestamp=0, unit="", value="O"),
			      perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
			      options=DPROP_OPT_AUTOTIMESTAMP,
			      set_cb=lambda x: self.update("ht2on", x)),
			
            ChannelSourceDeviceProperty(name="ht3on", type=str,
			      initial=Sample(timestamp=0, unit="", value="O"),
			      perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
			      options=DPROP_OPT_AUTOTIMESTAMP,
			      set_cb=lambda x: self.update("ht3on", x)),
			      
			ChannelSourceDeviceProperty(name="ht1off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("ht1off", x)),
            
            ChannelSourceDeviceProperty(name="ht2off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("ht2off", x)),
            
            ChannelSourceDeviceProperty(name="ht3off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("ht3off", x)),
            
            ChannelSourceDeviceProperty(name="ct1on", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("ct1on", x)),
            
            ChannelSourceDeviceProperty(name="ct2on", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("ct2on", x)),
            
            
            ChannelSourceDeviceProperty(name="ct1off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("ct1off", x)),
            
            ChannelSourceDeviceProperty(name="ct2off", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("ct2off", x)),
            
            ChannelSourceDeviceProperty(name="t", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("t", x)),
            
            ChannelSourceDeviceProperty(name="d", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("d", x)),
            
            
            
            
            
            
            ChannelSourceDeviceProperty(name="serialReceive", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="serialSend", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=self.serial_send),
            
            ChannelSourceDeviceProperty(name="current_temp", type=float,
                initial=Sample(timestamp=0, unit="F", value=0.0),
                perms_mask=(DPROP_PERM_GET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            
            ChannelSourceDeviceProperty(name="splt", type=str,
                  initial=Sample(timestamp=0, unit="", value="65"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("splt", x)),
            
            
            ChannelSourceDeviceProperty(name="mode", type=str,
                  initial=Sample(timestamp=0, unit="", value="O"),
                  perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                  options=DPROP_OPT_AUTOTIMESTAMP,
                  set_cb=lambda x: self.update("mode", x)),
            
            
            ChannelSourceDeviceProperty(name="cot", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_bool("cot", x)),
            
            
            ChannelSourceDeviceProperty(name="hp", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_bool("hp", x)),
            
            ChannelSourceDeviceProperty(name="tfoh", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_bool("tfoh", x)),
            
            ChannelSourceDeviceProperty(name="essh", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_bool("essh", x)),
            
            ChannelSourceDeviceProperty(name="eahp", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_bool("eahp", x)),
            
            ChannelSourceDeviceProperty(name="essc", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_bool("essc", x)),
            
            ChannelSourceDeviceProperty(name="tsm", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_bool("tsm", x)),
            
            
            ChannelSourceDeviceProperty(name="fan", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.update_bool("fan", x)),
            
            ChannelSourceDeviceProperty(name="ac_1", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),                
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="ac_2", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="heat_1", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="heat_2", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            ChannelSourceDeviceProperty(name="heat_3", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP),
            
            
            
            
            
            ChannelSourceDeviceProperty(name="read", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="write", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=self.serial_write),
        ]

        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, self.__name, self.__core,    
                                settings_list, property_list)
Esempio n. 11
0
    def __init__(self, name, core_services):
        self.__name = name
        self.__core = core_services
        self.string = ""
        self.signals = 0
        self.include_unit = "F"
        self.sleeping = 0

        ## Local State Variables:
        self.__xbee_manager = None

        ## Settings Table Definition:
        settings_list = [
            Setting(
                name='sleep', type=bool, required=False,
                default_value=False),
            Setting(
                name='sample_rate_ms', type=int, required=False,
                default_value=5000),
            # These settings are provided for advanced users, they
            # are not required:
            Setting(
                name='awake_time_ms', type=int, required=False,
                default_value=700,
                verify_function=lambda x: x >= 0 and x <= 0xffff),
            Setting(
                name='sample_predelay', type=int, required=False,
                default_value=0,
                verify_function=lambda x: x >= 0 and x <= 0xffff)

        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
             ChannelSourceDeviceProperty(name="excl", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(False, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.exclude("excl", x)),
             ChannelSourceDeviceProperty(name="signal", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
             ChannelSourceDeviceProperty(name="volts", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
             ChannelSourceDeviceProperty(name="get_signal", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(True, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
               set_cb=lambda x: self.set_sig_update()),
             ChannelSourceDeviceProperty(name="incl", type=Boolean,
                initial=Sample(timestamp=0,
                value=Boolean(True, style=STYLE_ONOFF)),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=lambda x: self.include("incl", x)),
            ChannelSourceDeviceProperty(name="temperature", type=str,
                initial=Sample(timestamp=0, value="0.0", unit="fF"),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="low_battery", type=bool,
                initial=Sample(timestamp=0, value=False),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="read", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="write", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=self.serial_write),
        ]

        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, self.__name, self.__core,    
                                settings_list, property_list)
Esempio n. 12
0
    def __init__(self, name, core_services):

        ## These will be created by XBeeSerial
        # self._name = name
        # self._core = core_services
        # self._tracer = get_tracer(name)
        # self._xbee_manager = None
        # self._extended_address = None

        ## Local State Variables:
        self.__response_buffer = ""
        self.__request_event = None
        self.__mode = self.MODE_IDLE
        self.__req_cnt = 0
        self.__rsp_cnt = 0
        self.__sensor = None

        ## Over-ride our parent's settings
        self.DEF_BAUDRATE = 19200
        self.DEF_PARITY = 'none'
        self.DEF_STOPBITS = 1
        self.DEF_HWFLOW = '485'

        ## Settings Table Definition:
        settings_list = [
            Setting(name='poll_rate_sec',
                    type=int,
                    required=False,
                    default_value=5,
                    verify_function=lambda x: x >= 1),
            Setting(name='bus_id',
                    type=int,
                    required=False,
                    default_value=1,
                    verify_function=lambda x: x >= 0),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(name="strength",
                                        type=int,
                                        initial=Sample(timestamp=0,
                                                       value=0,
                                                       unit="%"),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="target_detected",
                                        type=Boolean,
                                        initial=Sample(timestamp=0,
                                                       value=Boolean(
                                                           False,
                                                           style=STYLE_YESNO)),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="error_flag",
                                        type=Boolean,
                                        initial=Sample(timestamp=0,
                                                       value=Boolean(
                                                           False,
                                                           style=STYLE_YESNO)),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="range",
                                        type=float,
                                        initial=Sample(timestamp=0,
                                                       value=0.0,
                                                       unit="in"),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="temperature",
                                        type=float,
                                        initial=Sample(timestamp=0,
                                                       value=0.0,
                                                       unit="C"),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="availability",
                                        type=float,
                                        initial=Sample(timestamp=0,
                                                       value=0.0,
                                                       unit="prc"),
                                        perms_mask=DPROP_PERM_GET,
                                        options=DPROP_OPT_AUTOTIMESTAMP),
        ]

        ## Initialize the DeviceBase interface:
        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, name, core_services, settings_list,
                            property_list)

        self._tracer.calls("MassaM300.__init__()")
Esempio n. 13
0
    def __init__(self, name, core_services):

        ## These will be created by XBeeSerial
        # self._name = name
        # self._core = core_services
        # self._tracer = get_tracer(name)
        # self._xbee_manager = None
        # self._extended_address = None

        # local variables used for packing of multiple rcv packets
        self.rcv_buffer = ''
        self.__chr_timer = None

        # create a resource semaphore for receiving and timeout
        self.__rcv_lock = threading.Lock()

        # local variables used for append/strip EOLN
        self.__eoln_save = None
        self._eoln = None

        ## Settings Table Definition:
        settings_list = [
            # if True, then data is converted from hexadecimal to binary
            # if False, then data is assumed ASCII (or raw)
            Setting(
                name='hexadecimal', type=bool, required=False,
                default_value=self.DEF_HEXDEC),

            # add/strip an end-of-line sequence
            # set to None to disable
            # else likely set to '\r', '\n', or '\r\n'
            # other escapes need to be of the form '\xXX', which XX is
            # exactly 2 hexadecimal bytes. Example: '\x0D' is '\r'
            Setting(
                name='eoln', type=str, required=False,
                default_value=self.DEF_EOLN),

            # character timeout to 'pack' data into a single receive
            Setting(
                name='char_timeout', type=float, required=False,
                default_value=self.DEF_CHARTOUT,
                verify_function=lambda x: x == 0.0 or x >= 0.25),
        ]

        ## Channel Properties Definition:
        property_list = [
            # gettable properties
            ChannelSourceDeviceProperty(name="read", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=DPROP_PERM_GET, options=DPROP_OPT_AUTOTIMESTAMP),
            ChannelSourceDeviceProperty(name="write", type=str,
                initial=Sample(timestamp=0, unit="", value=""),
                perms_mask=(DPROP_PERM_GET|DPROP_PERM_SET),
                options=DPROP_OPT_AUTOTIMESTAMP,
                set_cb=self.serial_write),
        ]

        ## Initialize the XBeeSerial interface:
        XBeeSerial.__init__(self, name, core_services,
                                settings_list, property_list)

        self._tracer.calls("XBeeSerialTerminal.__init__()")