def __init__(self): # Catch CNTRL-C signel signal.signal(signal.SIGINT, self.signal_cntrl_c) self.shutdown = False args = self.parse_commandline_arguments() self.init_logging(args.logfilename, args.verbose) logging.info(" Serving on: ZMQ") logging.info("Connection ID: %s", args.connection) logging.info(" Device ID: %s", args.device_id) logging.info(" Device Name: %s", args.device_name) self.device = dashio.dashDevice(args.connection, args.device_id, args.device_name) time.sleep(1) self.zmq_con = dashio.zmqConnection(pub_port=args.pub_port, sub_port=args.sub_port) time.sleep(1) self.zmq_con.add_device(self.device) self.connection = args.connection self.page_name = "TestZMQ: " + platform.node() self.page_test = dashio.Page("TestZMQ", self.page_name, 1) self.up_btn = dashio.Button("UP_BTN", control_position=dashio.ControlPosition( 0.02, 0.01, 0.22, 0.12)) self.up_btn.btn_state = dashio.ButtonState.OFF self.up_btn.icon_name = dashio.Icon.UP self.up_btn.on_color = dashio.Color.GREEN self.up_btn.text = "" self.up_btn.text_color = dashio.Color.WHITE self.up_btn.title = "Up" self.up_btn.message_rx_event += self.up_btn_event_handler self.page_test.add_control(self.up_btn) self.down_btn = dashio.Button("DOWN_BTN", control_position=dashio.ControlPosition( 0.02, 0.78, 0.22, 0.12)) self.down_btn.btn_state = dashio.ButtonState.OFF self.down_btn.icon_name = dashio.Icon.DOWN self.down_btn.on_color = dashio.Color.GREEN self.down_btn.text = "" self.down_btn.text_color = dashio.Color.WHITE self.down_btn.title = "Down" self.down_btn.message_rx_event += self.down_btn_event_handler self.page_test.add_control(self.down_btn) self.sldr_cntrl = dashio.SliderSingleBar( "SLDR", control_position=dashio.ControlPosition(0.02, 0.13, 0.22, 0.65)) self.sldr_cntrl.title = "Slider" self.sldr_cntrl.max = 10 self.sldr_cntrl.slider_enabled = True self.sldr_cntrl.red_value self.sldr_cntrl.message_rx_event += self.slider_event_handler self.page_test.add_control(self.sldr_cntrl) self.sldr_dbl_cntrl = dashio.SliderDoubleBar( "SLDR_DBL", control_position=dashio.ControlPosition(0.78, 0.01, 0.2, 0.89)) self.sldr_dbl_cntrl.title = "Slider Double" self.sldr_dbl_cntrl.max = 5 self.sldr_dbl_cntrl.slider_enabled = True self.sldr_dbl_cntrl.red_value self.sldr_dbl_cntrl.message_rx_event += self.slider_dbl_event_handler self.page_test.add_control(self.sldr_dbl_cntrl) self.knb_control = dashio.Knob("KNB", control_position=dashio.ControlPosition( 0.24, 0.14, 0.54, 0.21)) self.knb_control.title = "A Knob" self.knb_control.max = 10 self.knb_control.red_value = 10 self.knb_control.message_rx_event += self.knob_event_handler self.page_test.add_control(self.knb_control) self.dl_control = dashio.Dial("DIAL1", control_position=dashio.ControlPosition( 0.24, 0.57, 0.54, 0.21)) self.dl_control.title = "A Dial" self.dl_control.max = 10 self.page_test.add_control(self.dl_control) self.text_cntrl = dashio.TextBox( "TXT1", control_position=dashio.ControlPosition(0.24, 0.78, 0.54, 0.12)) self.text_cntrl.text = "Hello" self.text_cntrl.title = "A text control" self.text_cntrl.keyboard_type = dashio.Keyboard.ALL_CHARS self.text_cntrl.close_key_board_on_send = True self.text_cntrl.message_rx_event += self.text_cntrl_message_handler self.page_test.add_control(self.text_cntrl) self.alarm_ctrl = dashio.Alarm("TestingAlarms", "Test Alarms", "Hello", "Test of Shared Alarms") self.device.add_control(self.alarm_ctrl) self.comp_control = dashio.Compass( "COMP1", control_position=dashio.ControlPosition(0.24, 0.35, 0.54, 0.22)) self.comp_control.title = "A compass" self.page_test.add_control(self.comp_control) self.selector_ctrl = dashio.Selector( "TestSelector", "A Selector", control_position=dashio.ControlPosition(0.24, 0.01, 0.54, 0.13)) self.selector_ctrl.message_rx_event += self.selector_ctrl_handler self.selector_ctrl.add_selection("First") self.selector_ctrl.add_selection("Second") self.selector_ctrl.add_selection("Third") self.selector_ctrl.add_selection("Forth") self.selector_ctrl.add_selection("Fifth") self.page_test.add_control(self.selector_ctrl) self.label_ctrl = dashio.Label( "LabelID", "A label", style=dashio.LabelStyle.GROUP, color=dashio.Color.BLUE, control_position=dashio.ControlPosition(0.0, 0.0, 1.0, 0.93), ) self.page_test.add_control(self.label_ctrl) self.device.add_control(self.label_ctrl) self.device.add_control(self.page_test) self.device.add_control(self.selector_ctrl) self.device.add_control(self.comp_control) self.device.add_control(self.text_cntrl) self.device.add_control(self.dl_control) self.device.add_control(self.knb_control) self.device.add_control(self.sldr_dbl_cntrl) self.device.add_control(self.sldr_cntrl) self.device.add_control(self.down_btn) self.device.add_control(self.up_btn) while not self.shutdown: time.sleep(5) self.comp_control.direction_value = random.random() * 360 self.device.send_popup_message("TestControls", "Shutting down", "Goodbye") time.sleep(1) self.device.close() self.zmq_con.close()
def __init__(self): # Catch CNTRL-C signel signal.signal(signal.SIGINT, self.signal_cntrl_c) self.shutdown = False args = self.parse_commandline_arguments() self.init_logging(args.logfilename, args.verbose) logging.info("Connecting to server: %s", args.server) logging.info(" Connection ID: %s", args.connection) logging.info(" Control topic: %s/%s/%s/control", args.username, args.connection, args.device_id) logging.info(" Data topic: %s/%s/%s/data", args.username, args.connection, args.device_id) device = dashio.dashDevice(args.connection, args.device_id, args.device_name) dash_conn = dashio.dashConnection(args.username, args.password) dash_conn.add_device(device) self.page_test = dashio.Page("TestPage", "Testing Pages", 1) self.up_btn = dashio.Button("UP_BTN") self.up_btn.btn_state = dashio.ButtonState.OFF self.up_btn.icon_name = dashio.Icon.UP self.up_btn.on_color = dashio.Color.GREEN self.up_btn.text = "" self.up_btn.text_color = dashio.Color.WHITE self.up_btn.title = "Up" self.up_btn.message_rx_event += self.up_btn_event_handler device.add_control(self.up_btn) self.page_test.add_control(self.up_btn) self.down_btn = dashio.Button("DOWN_BTN") self.down_btn.btn_state = dashio.ButtonState.OFF self.down_btn.icon_name = dashio.Icon.DOWN self.down_btn.on_color = dashio.Color.GREEN self.down_btn.text = "" self.down_btn.text_color = dashio.Color.WHITE self.down_btn.title = "Down" self.down_btn.message_rx_event += self.down_btn_event_handler device.add_control(self.down_btn) self.page_test.add_control(self.down_btn) self.sldr_cntrl = dashio.SliderSingleBar("SLDR") self.sldr_cntrl.title = "Slider" self.sldr_cntrl.max = 10 self.sldr_cntrl.slider_enabled = True self.sldr_cntrl.red_value self.sldr_cntrl.message_rx_event += self.slider_event_handler device.add_control(self.sldr_cntrl) self.page_test.add_control(self.sldr_cntrl) self.sldr_dbl_cntrl = dashio.SliderDoubleBar("SLDR_DBL") self.sldr_dbl_cntrl.title = "Slider Double" self.sldr_dbl_cntrl.max = 5 self.sldr_dbl_cntrl.slider_enabled = True self.sldr_dbl_cntrl.red_value self.sldr_dbl_cntrl.message_rx_event += self.slider_dbl_event_handler device.add_control(self.sldr_dbl_cntrl) self.page_test.add_control(self.sldr_dbl_cntrl) self.knb_control = dashio.Knob("KNB") self.knb_control.title = "A Knob" self.knb_control.max = 10 self.knb_control.red_value = 10 self.knb_control.message_rx_event += self.knob_event_handler device.add_control(self.knb_control) self.page_test.add_control(self.knb_control) self.dl_control = dashio.Dial("DIAL1") self.dl_control.title = "A Dial" self.dl_control.max = 10 device.add_control(self.dl_control) self.page_test.add_control(self.dl_control) self.text_cntrl = dashio.TextBox("TXT1") self.text_cntrl.text = "Hello" self.text_cntrl.title = "A text control" self.text_cntrl.keyboard_type = dashio.Keyboard.ALL_CHARS self.text_cntrl.close_key_board_on_send = True self.text_cntrl.message_rx_event += self.text_cntrl_message_handler device.add_control(self.text_cntrl) self.page_test.add_control(self.text_cntrl) self.alarm_ctrl = dashio.Alarm("TestingAlarms", "Test Alarms", "Hello", "Test of Shared Alarms") device.add_control(self.alarm_ctrl) self.comp_control = dashio.Compass("COMP1") self.comp_control.title = "A compass" device.add_control(self.comp_control) self.page_test.add_control(self.comp_control) self.selector_ctrl = dashio.Selector("TestSelector", "A Selector") self.selector_ctrl.message_rx_event += self.selector_ctrl_handler self.selector_ctrl.add_selection("First") self.selector_ctrl.add_selection("Second") self.selector_ctrl.add_selection("Third") self.selector_ctrl.add_selection("Forth") self.selector_ctrl.add_selection("Fifth") device.add_control(self.selector_ctrl) self.page_test.add_control(self.selector_ctrl) self.label_ctrl = dashio.Label("LabelID", "A label", color=dashio.Color.BLUE) device.add_control(self.label_ctrl) self.page_test.add_control(self.label_ctrl) device.add_control(self.page_test) while not self.shutdown: time.sleep(5) self.comp_control.direction_value = random.random() * 360 device.send_popup_message("TestControls", "Shutting down", "Goodbye") device.close()
def __init__(self): # Catch CNTRL-C signel signal.signal(signal.SIGINT, self.signal_cntrl_c) self.shutdown = False args = self.parse_commandline_arguments() self.init_logging(args.logfilename, args.verbose) logging.info(" Serving on: %s:%s", args.url, str(args.port)) logging.info(" Device ID: %s", args.device_id) logging.info(" Device Name: %s", args.device_name) self.tcp_con = dashio.TCPConnection() self.device = dashio.Device("ControlTest", args.device_id, args.device_name) self.tcp_con.add_device(self.device) self.page_name = "TestTCP: " + platform.node() self.page_test = dashio.DeviceView("TestTCP", self.page_name) self.up_btn = dashio.Button("UP_BTN", control_position=dashio.ControlPosition(0.02, 0.01, 0.22, 0.12)) self.up_btn.btn_state = dashio.ButtonState.OFF self.up_btn.icon_name = dashio.Icon.UP self.up_btn.on_color = dashio.Color.GREEN self.up_btn.text = "" self.up_btn.title = "Up" self.up_btn.message_rx_event = self.up_btn_event_handler self.page_test.add_control(self.up_btn) self.down_btn = dashio.Button( "DOWN_BTN", control_position=dashio.ControlPosition(0.02, 0.86, 0.22, 0.12) ) self.down_btn.btn_state = dashio.ButtonState.OFF self.down_btn.icon_name = dashio.Icon.DOWN self.down_btn.on_color = dashio.Color.GREEN self.down_btn.text = "" self.down_btn.title = "Down" self.down_btn.message_rx_event = self.down_btn_event_handler self.page_test.add_control(self.down_btn) self.sldr_cntrl = dashio.SliderSingleBar( "SLDR", control_position=dashio.ControlPosition(0.02, 0.13, 0.22, 0.73) ) self.sldr_cntrl.title = "Slider" self.sldr_cntrl.bar_max = 10 self.sldr_cntrl.slider_enabled = True self.sldr_cntrl.red_value = 10 self.sldr_cntrl.message_rx_event += self.slider_event_handler self.page_test.add_control(self.sldr_cntrl) self.sldr_dbl_cntrl = dashio.SliderDoubleBar( "SLDR_DBL", control_position=dashio.ControlPosition(0.78, 0.01, 0.2, 0.98) ) self.sldr_dbl_cntrl.title = "Slider Double" self.sldr_dbl_cntrl.bar_max = 5 self.sldr_dbl_cntrl.slider_enabled = True self.sldr_dbl_cntrl.red_value = 5 self.sldr_dbl_cntrl.message_rx_event += self.slider_dbl_event_handler self.page_test.add_control(self.sldr_dbl_cntrl) self.knb_control = dashio.Knob("KNB", control_position=dashio.ControlPosition(0.24, 0.14, 0.54, 0.21)) self.knb_control.title = "A Knob" self.knb_control.dial_max = 10 self.knb_control.red_value = 10 self.knb_control.message_rx_event += self.knob_event_handler self.page_test.add_control(self.knb_control) self.dl_control = dashio.Dial( "DIAL1", style=DialStyle.BAR, units="m/s", number_position=DialNumberPosition.CENTER, precision=Precision.TWO, control_position=dashio.ControlPosition(0.24, 0.63, 0.54, 0.21) ) self.dl_control.title = "A Dial" self.dl_control.dial_max = 10 self.page_test.add_control(self.dl_control) self.text_cntrl = dashio.TextBox( "TXT1", control_position=dashio.ControlPosition(0.24, 0.84, 0.54, 0.12) ) self.text_cntrl.text = "Hello" self.text_cntrl.title = "A text control" self.text_cntrl.keyboard_type = dashio.Keyboard.ALL_CHARS self.text_cntrl.close_keyboard_on_send = True self.text_cntrl.message_rx_event += self.text_cntrl_message_handler self.page_test.add_control(self.text_cntrl) self.alarm_ctrl = dashio.Alarm("TestingAlarms", "Test Alarms") self.device.add_control(self.alarm_ctrl) self.comp_control = dashio.Direction( "COMP1", style=DirectionStyle.DEGPS, units="nm", precision=Precision.TWO, control_position=dashio.ControlPosition(0.24, 0.38, 0.54, 0.22) ) self.comp_control.title = "A Direction control" self.comp_control.direction_text = "00" self.page_test.add_control(self.comp_control) self.selector_ctrl = dashio.Selector( "TestSelector", "A Selector", control_position=dashio.ControlPosition(0.24, 0.01, 0.54, 0.13) ) self.selector_ctrl.message_rx_event += self.selector_ctrl_handler self.selector_ctrl.add_selection("First") self.selector_ctrl.add_selection("Second") self.selector_ctrl.add_selection("Third") self.selector_ctrl.add_selection("Forth") self.selector_ctrl.add_selection("Fifth") self.page_test.add_control(self.selector_ctrl) self.label_ctrl = dashio.Label( "LabelID", "A label", style=dashio.LabelStyle.GROUP, color=dashio.Color.BLUE, control_position=dashio.ControlPosition(0.0, 0.0, 1.0, 1.0), ) self.page_test.add_control(self.label_ctrl) self.device.add_control(self.label_ctrl) self.device.add_control(self.page_test) self.device.add_control(self.selector_ctrl) self.device.add_control(self.comp_control) self.device.add_control(self.text_cntrl) self.device.add_control(self.dl_control) self.device.add_control(self.knb_control) self.device.add_control(self.sldr_dbl_cntrl) self.device.add_control(self.sldr_cntrl) self.device.add_control(self.down_btn) self.device.add_control(self.up_btn) while not self.shutdown: time.sleep(5) self.comp_control.direction_value = random.random() * 360 self.device.send_popup_message("TestControls", "Shutting down", "Goodbye") self.tcp_con.close() self.device.close()
def __init__(self): self.shutdown = False signal.signal(signal.SIGINT, self.signal_cntrl_c) args = self.parse_commandline_arguments() self.init_logging(args.logfilename, args.verbose) logging.info("Connecting to server: %s", args.server) logging.info(" Connection ID: %s", args.connection) logging.info(" Control topic: %s/%s/%s/control", args.username, args.connection, args.device_id) logging.info(" Data topic: %s/%s/%s/data", args.username, args.connection, args.device_id) device = dashio.dashDevice(args.connection, args.device_id, args.device_name) dash_conn = dashio.dashConnection(args.username, args.password) dash_conn.add_device(device) self.tapage = dashio.Page("testAlarm", "Test Alarm") self.alarm_btn1 = dashio.Button("ALARM_BTN1") self.tapage.add_control(self.alarm_btn1) self.alarm_btn1.title = "A1" self.alarm_btn1.btn_state = dashio.ButtonState.OFF self.alarm_btn1.icon_name = dashio.Icon.BELL self.alarm_btn1.on_color = dashio.Color.RED self.alarm_btn1.text_color = dashio.Color.BLUE self.alarm_btn1.message_rx_event += self.alarm_btn1_handler device.add_control(self.alarm_btn1) self.alarm_btn2 = dashio.Button("ALARM_BTN2") self.alarm_btn2.title = "A2" self.alarm_btn2.btn_state = dashio.ButtonState.OFF self.alarm_btn2.icon_name = dashio.Icon.BELL self.alarm_btn2.on_color = dashio.Color.RED self.alarm_btn2.text_color = dashio.Color.BLUE self.alarm_btn2.message_rx_event += self.alarm_btn2_handler device.add_control(self.alarm_btn2) self.tapage.add_control(self.alarm_btn2) self.alarm_btn3 = dashio.Button("ALARM_BTN3") self.alarm_btn3.title = "A3" self.alarm_btn3.btn_state = dashio.ButtonState.OFF self.alarm_btn3.icon_name = dashio.Icon.BELL self.alarm_btn3.on_color = dashio.Color.RED self.alarm_btn3.text_color = dashio.Color.BLUE self.alarm_btn3.message_rx_event += self.alarm_btn3_handler device.add_control(self.alarm_btn3) self.tapage.add_control(self.alarm_btn3) self.alarm1_ctrl = dashio.Alarm("TestingAlarms1", "Alarm1", "Hello from Alarm1", "Alarm1") self.alarm2_ctrl = dashio.Alarm("TestingAlarms2", "Alarm2", "Hello from Alarm2", "Alarm2") self.alarm3_ctrl = dashio.Alarm("TestingAlarms3", "Alarm3", "Hello from Alarm3", "Alarm3") device.add_control(self.alarm1_ctrl) device.add_control(self.alarm2_ctrl) device.add_control(self.alarm3_ctrl) self.tapage.add_control(self.alarm1_ctrl) self.tapage.add_control(self.alarm2_ctrl) self.tapage.add_control(self.alarm3_ctrl) device.add_control(self.tapage) while not self.shutdown: time.sleep(1) device.close()
def __init__(self): self.shutdown = False signal.signal(signal.SIGINT, self.signal_cntrl_c) args = self.parse_commandline_arguments() self.init_logging(args.logfilename, args.verbose) logging.info("Connecting to server: %s", args.server) logging.info(" Device ID: %s", args.device_id) logging.info(" Control topic: %s/%s/control", args.username, args.device_id) logging.info(" Data topic: %s/%s/data", args.username, args.device_id) device = dashio.Device(args.device_type, args.device_id, args.device_name) dash_conn = dashio.DashConnection(args.username, args.password) dash_conn.add_device(device) self.tadevice_view = dashio.DeviceView("testAlarm", "Test Alarm") self.alarm_btn1 = dashio.Button("ALARM_BTN1") self.tadevice_view.add_control(self.alarm_btn1) self.alarm_btn1.title = "A1" self.alarm_btn1.btn_state = dashio.ButtonState.OFF self.alarm_btn1.icon_name = dashio.Icon.BELL self.alarm_btn1.on_color = dashio.Color.RED self.alarm_btn1.message_rx_event += self.alarm_btn1_handler device.add_control(self.alarm_btn1) self.alarm_btn2 = dashio.Button("ALARM_BTN2") self.alarm_btn2.title = "A2" self.alarm_btn2.btn_state = dashio.ButtonState.OFF self.alarm_btn2.icon_name = dashio.Icon.BELL self.alarm_btn2.on_color = dashio.Color.RED self.alarm_btn2.message_rx_event += self.alarm_btn2_handler device.add_control(self.alarm_btn2) self.tadevice_view.add_control(self.alarm_btn2) self.alarm_btn3 = dashio.Button("ALARM_BTN3") self.alarm_btn3.title = "A3" self.alarm_btn3.btn_state = dashio.ButtonState.OFF self.alarm_btn3.icon_name = dashio.Icon.BELL self.alarm_btn3.on_color = dashio.Color.RED self.alarm_btn3.message_rx_event += self.alarm_btn3_handler device.add_control(self.alarm_btn3) self.tadevice_view.add_control(self.alarm_btn3) self.alarm1_ctrl = dashio.Alarm("TestingAlarms1", "A plop form Alarm1", SoundName.PLOP) self.alarm2_ctrl = dashio.Alarm("TestingAlarms2", "Squeaky from Alarm2", SoundName.SQUEAKY) self.alarm3_ctrl = dashio.Alarm("TestingAlarms3", "Whoosh from Alarm3", SoundName.WHOOSH) device.add_control(self.alarm1_ctrl) device.add_control(self.alarm2_ctrl) device.add_control(self.alarm3_ctrl) self.tadevice_view.add_control(self.alarm1_ctrl) self.tadevice_view.add_control(self.alarm2_ctrl) self.tadevice_view.add_control(self.alarm3_ctrl) device.add_control(self.tadevice_view) while not self.shutdown: time.sleep(1) device.close()