def __init__(self): Sink.__init__(self) self.curImage=0 self.image=Image() self.loadingImage = Image(self.baseURL() + "images/blanksearching.gif") self.nextButton = Image(self.baseURL() + "rembrandt/forward.gif") self.prevButton = Image(self.baseURL() + "rembrandt/back.gif") self.sImages=["rembrandt/JohannesElison.jpg", "rembrandt/LaMarcheNocturne.jpg", "rembrandt/SelfPortrait1628.jpg", "rembrandt/SelfPortrait1640.jpg", "rembrandt/TheArtistInHisStudio.jpg", "rembrandt/TheReturnOfTheProdigalSon.jpg"] for i in range(len(self.sImages)): self.sImages[i]=self.baseURL() + self.sImages[i] self.image.addLoadListener(self) self.prevButton.addClickListener(self) self.nextButton.addClickListener(self) topPanel = DockPanel() topPanel.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) topPanel.add(self.prevButton, DockPanel.WEST) topPanel.add(self.nextButton, DockPanel.EAST) topPanel.add(self.loadingImage, DockPanel.CENTER) panel = VerticalPanel() panel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) panel.add(HTML("<h2>A Bit of Rembrandt</h2>", True)) panel.add(topPanel) panel.add(self.image) panel.setWidth("100%") self.initWidget(panel) self.image.setStyleName("ks-images-Image") self.nextButton.setStyleName("ks-images-Button") self.prevButton.setStyleName("ks-images-Button") self.loadImage(0)
def __init__(self): Sink.__init__(self) self.vp = VerticalPanel() self.initWidget(self.vp) self.loaded = False
def __init__(self): Sink.__init__(self) self.fTabs = TabPanel() self.fTabs.addTabListener(self) self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/JohannesElison.jpg"), "1634") self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/SelfPortrait1640.jpg"), "1640") self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"), "1642") self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/TheReturnOfTheProdigalSon.jpg"), "1662") self.fTabs.add( self.createImage(self.baseURL() + "rembrandt/TheReturnOfTheProdigalSon.jpg"), "1662 (disabled)") self.fTabs.selectTab(0) self.fTabs.setWidth("100%") self.fTabs.setHeight("100%") self.initWidget(self.fTabs)
def main(): # sleep so rabbit can get all set up, # and we don't get mad throwing errors all around the place time.sleep(15) initialize_log() sink = Sink() sink.run()
def __init__(self): Sink.__init__(self) colour_grid = ColourGridCanvas() rotated = RotatedCanvas() spheres = SpheresCanvas() pattern = PatternCanvas() spiro = SpiroCanvas() self.solar = SolarCanvas() row0 = HorizontalPanel() row0.setSpacing(8) row0.add(colour_grid) row0.add(rotated) row0.add(spheres) row0.add(pattern) row1 = HorizontalPanel() row1.setSpacing(8) row1.add(self.solar) row1.add(spiro) panel = VerticalPanel() panel.add(row0) panel.add(row1) self.setWidget(panel)
def __init__(self): Sink.__init__(self) self.frame=Frame(self.baseURL() + "rembrandt/LaMarcheNocturne.html") self.frame.setWidth("100%") self.frame.setHeight("48em") self.initWidget(self.frame)
def __init__(self): Sink.__init__(self) colour_grid = ColourGridCanvas() rotated = RotatedCanvas() spheres = SpheresCanvas() #pattern = PatternCanvas() spiro = SpiroCanvas() self.solar = SolarCanvas() row0 = HorizontalPanel() row0.setSpacing(8) row0.add(colour_grid) row0.add(rotated) row0.add(spheres) #row0.add(pattern) row1 = HorizontalPanel() row1.setSpacing(8) row1.add(self.solar) row1.add(spiro) panel = VerticalPanel() panel.add(row0) panel.add(row1) self.setWidget(panel)
def __init__(self, parent=None): Sink.__init__(self, parent) text=""" <div class='infoProse'> This is the AstroData Control Center Engineering Interface. <p> The "astrodata control center" is an application which acts as a common point of contact for the "reduce" command which executes "recipes", providing coordinated sevices such as calibration search, image display, stacking-list maintainance, and image quality statics. </p> <p> It is written in Pyjamas which is a system that compiles python programs into HTML+Javascript. It is entirely separate from the "adcc" application, except that the adcc HTTP interface will serve the HTML which is required for the interface to make use of HTTPRequest. </p> <p> When invoked from the command line, "reduce", if there is no adcc running, reduce will start one. This mode could be considered the baseline, or normal case. The reduce instance communicates with the adcc using XMLRPC, and the adcc essentially acts as a library which happens to have its own process. This interface is only useful when adcc is started ahead of time, since otherwise when reduce is finished running, the adcc will shut down as well. </p> </div>""" self.initWidget(HTML(text, True))
def __init__(self, parent=None): Sink.__init__(self, parent) self.frame = Frame("/summary", Size=("100%",rccutil.getHeight())) self.initWidget(self.frame) Window.addWindowResizeListener(self)
def __init__(self): Sink.__init__(self) self.fPasswordText = PasswordTextBox() self.fTextArea = TextArea() self.fTextBox = TextBox() panel = VerticalPanel() panel.setSpacing(8) panel.add(HTML("Normal text box:")) panel.add(self.createTextThing(self.fTextBox)) panel.add(HTML("Password text box:")) panel.add(self.createTextThing(self.fPasswordText)) panel.add(HTML("Text area:")) panel.add(self.createTextThing(self.fTextArea)) panel.add( HTML("""Textarea below demos oninput event. oninput allows to detect when the content of an element has changed. This is different from examples above, where changes are detected only if they are made with keyboard. oninput occurs when the content is changed through any user interface(keyboard, mouse, etc.). For example, at first type few chars, but then paste some text to the text areas above and below by selecting 'Paste' command from context menu or by dragging&dropping and see the difference. oninput is similar to onchange event, but onchange event fires only when a text-entry widget loses focus.""")) vp = VerticalPanel() self.echo = HTML() textArea = TextArea() vp.add(textArea) vp.add(self.echo) textArea.addInputListener(self) panel.add(vp) self.initWidget(panel)
def __init__(self): Sink.__init__(self) self.menu = MenuBar() subMenu = MenuBar(True) subMenu.addItem("<code>Code</code>", True, self) subMenu.addItem("<strike>Strikethrough</strike>", True, self) subMenu.addItem("<u>Underlined</u>", True, self) menu0 = MenuBar(True) menu0.addItem("<b>Bold</b>", True, self) menu0.addItem("<i>Italicized</i>", True, self) menu0.addItem("More »", True, subMenu) menu1 = MenuBar(True) menu1.addItem("<font color='#FF0000'><b>Apple</b></font>", True, self) menu1.addItem("<font color='#FFFF00'><b>Banana</b></font>", True, self) menu1.addItem("<font color='#FFFFFF'><b>Coconut</b></font>", True, self) menu1.addItem("<font color='#8B4513'><b>Donut</b></font>", True, self) menu2 = MenuBar(True) menu2.addItem("Bling", self) menu2.addItem("Ginormous", self) menu2.addItem("<code>w00t!</code>", True, self) self.menu.addItem(MenuItem("Style", menu0)) self.menu.addItem(MenuItem("Fruit", menu1)) self.menu.addItem(MenuItem("Term", menu2)) self.menu.setWidth("100%") self.initWidget(self.menu)
def __init__(self): Sink.__init__(self) self.frame = Frame(self.baseURL() + "rembrandt/LaMarcheNocturne.html") self.frame.setWidth("100%") self.frame.setHeight("48em") self.initWidget(self.frame)
def __init__(self): Sink.__init__(self) self.fPasswordText = PasswordTextBox() self.fTextArea = TextArea() self.fTextBox = TextBox() panel = VerticalPanel() panel.setSpacing(8) panel.add(HTML("Normal text box:")) panel.add(self.createTextThing(self.fTextBox)) panel.add(HTML("Password text box:")) panel.add(self.createTextThing(self.fPasswordText)) panel.add(HTML("Text area:")) panel.add(self.createTextThing(self.fTextArea)) panel.add(HTML("""Textarea below demos oninput event. oninput allows to detect when the content of an element has changed. This is different from examples above, where changes are detected only if they are made with keyboard. oninput occurs when the content is changed through any user interface(keyboard, mouse, etc.). For example, at first type few chars, but then paste some text to the text areas above and below by selecting 'Paste' command from context menu or by dragging&dropping and see the difference. oninput is similar to onchange event, but onchange event fires only when a text-entry widget loses focus.""")) vp = VerticalPanel() self.echo = HTML() textArea = TextArea() vp.add(textArea) vp.add(self.echo) textArea.addInputListener(self) panel.add(vp) self.initWidget(panel)
def __init__(self): Sink.__init__(self) text="<div class='infoProse'>This is the Kitchen Sink sample. " self.vp = VerticalPanel() self.initWidget(self.vp) self.loaded = False
def __init__(self): Sink.__init__(self) text = "<div class='infoProse'>This is the Kitchen Sink sample. " self.vp = VerticalPanel() self.initWidget(self.vp) self.loaded = False
def __init__(self, parent=None): Sink.__init__(self, parent) self.RVDock = HorizontalPanel(Spacing=5) self.RList = ListBox() self.RList.addClickListener(getattr(self, "onRecipeSelected")) self.RView = HTML() HTTPRequest().asyncGet("recipes.xml", RecipeListLoader(self)) self.RVDock.add(self.RList) self.RVDock.add(self.RView) self.initWidget(self.RVDock)
def define_sink_route(self, sink_route, speed_sink): if len(sink_route) < 2: raise Exception( 'Esperado, ao menos, lista com duas listas contendo posição inicial e destino' ) init_sink_position = sink_route[0] del sink_route[0] target_sink_position = (sink_route[0]) del sink_route[0] self.sink = Sink(init_sink_position, speed_sink, target_sink_position) self.sink_route = sink_route
def __init__(self): Sink.__init__(self) self.fTabs = TabPanel() self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/JohannesElison.jpg"), "1634") self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/SelfPortrait1640.jpg"), "1640") self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"), "1642") self.fTabs.add(self.createImage(self.baseURL() + "rembrandt/TheReturnOfTheProdigalSon.jpg"), "1662") self.fTabs.selectTab(0) self.fTabs.setWidth("100%") self.fTabs.setHeight("100%") self.initWidget(self.fTabs)
def __init__(self): colours = ['Azure', 'Red', 'Rust', 'Green', 'Beige', 'Brass', 'Brown', 'Bronze', 'Blue', 'Black', 'Burgundy', 'Pink', 'Gold', 'Gray', 'Purple', 'Yellow', 'White'] Sink.__init__(self) self.colour_input = AutoCompleteTextBox() self.colour_input.setCompletionItems(colours) panel = HorizontalPanel() panel.add(HTML("Enter a colour: ")) panel.add(self.colour_input) panel.setSpacing(8) self.setWidget(panel)
def __init__(self): Sink.__init__(self) text="<div class='infoProse'>This is the Kitchen Sink sample. " text+="It demonstrates many of the widgets in the Google Web Toolkit." text+="<p>This sample also demonstrates something else really useful in GWT: " text+="history support. " text+="When you click on a link at the left, the location bar will be " text+="updated with the current <i>history token</i>, which keeps the app " text+="in a bookmarkable state. The back and forward buttons work properly " text+="as well. Finally, notice that you can right-click a link and 'open " text+="in new window' (or middle-click for a new tab in Firefox).</p></div>" self.initWidget(HTML(text, True))
def __init__(self): Sink.__init__(self) self.fPasswordText = PasswordTextBox() self.fTextArea = TextArea() self.fTextBox = TextBox() panel = VerticalPanel() panel.setSpacing(8) panel.add(HTML("Normal text box:")) panel.add(self.createTextThing(self.fTextBox)) panel.add(HTML("Password text box:")) panel.add(self.createTextThing(self.fPasswordText)) panel.add(HTML("Text area:")) panel.add(self.createTextThing(self.fTextArea)) self.initWidget(panel)
def main(): rospy.init_node('mission_planner') sm = smach.StateMachine( outcomes=['mission_complete', 'mission_failed', 'aborted']) with sm: Sink(sm, 5, 'DEPTH') #state detectGate() depthTask = Depth(100, 'HEADING') depthTask.addDepthAction(sm) headingTask = Heading(200, 'DEPTH+HEADING') headingTask.addHeadingAction(sm) depthHeadingTask = DepthHeading(350, 350, 'mission_complete') depthHeadingTask.addDepthHeading(sm) sis = IntrospectionServer('ALPHEUS_MISSION_PLANNER', sm, '/START_ALPHEUS') sis.start() outcome = sm.execute() rospy.spin() sis.stop()
def __init__(self): colours = [ 'Azure', 'Red', 'Rust', 'Green', 'Beige', 'Brass', 'Brown', 'Bronze', 'Blue', 'Black', 'Burgundy', 'Pink', 'Gold', 'Gray', 'Purple', 'Yellow', 'White' ] Sink.__init__(self) self.colour_input = AutoCompleteTextBox() self.colour_input.setCompletionItems(colours) panel = HorizontalPanel() panel.add(HTML("Enter a colour: ")) panel.add(self.colour_input) panel.setSpacing(8) self.setWidget(panel)
def __init__(self): Sink.__init__(self) self.fDialogButton = Button("Show Dialog", self) self.fPopupButton = Button("Show Popup", self) panel = VerticalPanel() panel.add(self.fPopupButton) panel.add(self.fDialogButton) list = ListBox() list.setVisibleItemCount(5) for i in range(10): list.addItem("list item %d" % i) panel.add(list) panel.setSpacing(8) self.initWidget(panel)
def define_sink_route(self, sink_route, speed_sink): if len(sink_route) < 2: raise Exception('Esperado, ao menos, lista com duas listas contendo posição inicial e destino') init_sink_position = sink_route[0] del sink_route[0] target_sink_position = (sink_route[0]) del sink_route[0] self.sink = Sink(init_sink_position, speed_sink, target_sink_position) self.sink_route = sink_route
def __init__(self): Sink.__init__(self) inner = Grid(10, 5, Width="100%", BorderWidth="1") outer = FlexTable(Width="100%", BorderWidth="1") outer.setWidget(0, 0, Image(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg")) outer.getFlexCellFormatter().setColSpan(0, 0, 2) outer.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER) outer.setHTML(1, 0, "Look to the right...<br>That's a nested table component ->") outer.setWidget(1, 1, inner) outer.getCellFormatter().setColSpan(1, 1, 2) for i in range(10): for j in range(5): inner.setText(i, j, "%d" % i + ",%d" % j) self.initWidget(outer)
def __init__(self, parent = None): Sink.__init__(self, parent) self.reduceFiles = [] if True: HTTPRequest().asyncGet("datadir.xml", DirDictLoader(self), ) dock = DockPanel(HorizontalAlignment=HasAlignment.ALIGN_LEFT, Spacing=10, Size=("100%","100%")) self.dock = dock self.fProto = [] self.fTree = Tree() self.treePanel = ScrollPanel() self.treePanel.setSize("100%", str( int( Window.getClientHeight()*.75 ) )+"px") Window.addWindowResizeListener(self) self.treePanel.add(self.fTree) dock.add(self.treePanel, DockPanel.WEST) #self.treePanel.setBorderWidth(1) #self.treePanel.setWidth("100%") prPanel = self.createRightPanel() dock.add(prPanel,DockPanel.EAST) dock.setCellWidth(self.treePanel, "50%") dock.setCellWidth(prPanel, "50%") for i in range(len(self.fProto)): self.createItem(self.fProto[i]) self.fTree.addItem(self.fProto[i].item) self.fTree.addTreeListener(self) self.initWidget(self.dock) if False: #self.parent.filexml != None: DirDictLoader(self).onCompletion(self.parent.filexml)
def on_new_pa_sink(self, index, struct, props): if not self.pa_sinks.has_key(index): self.__print("new sink:", index, struct.name) # create new self.pa_sinks[index] = Sink(index, struct, props) else: self.__print("changed sink:", index, struct.name) # update old self.pa_sinks[index].update(struct, props) self.update()
def __init__(self): Sink.__init__(self) inner = Grid(10, 5, Width="100%", BorderWidth="1") outer = FlexTable(Width="100%", BorderWidth="1") outer.setWidget( 0, 0, Image(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg")) outer.getFlexCellFormatter().setColSpan(0, 0, 2) outer.getFlexCellFormatter().setHorizontalAlignment( 0, 0, HasHorizontalAlignment.ALIGN_CENTER) outer.setHTML( 1, 0, "Look to the right...<br>That's a nested table component ->") outer.setWidget(1, 1, inner) outer.getCellFormatter().setColSpan(1, 1, 2) for i in range(10): for j in range(5): inner.setText(i, j, "%d" % i + ",%d" % j) self.initWidget(outer)
def __init__(self): Sink.__init__(self) self.curImage = 0 self.image = Image() self.loadingImage = Image(self.baseURL() + "images/blanksearching.gif") self.nextButton = Image(self.baseURL() + "rembrandt/forward.gif") self.prevButton = Image(self.baseURL() + "rembrandt/back.gif") self.sImages = [ "rembrandt/JohannesElison.jpg", "rembrandt/LaMarcheNocturne.jpg", "rembrandt/SelfPortrait1628.jpg", "rembrandt/SelfPortrait1640.jpg", "rembrandt/TheArtistInHisStudio.jpg", "rembrandt/TheReturnOfTheProdigalSon.jpg" ] for i in range(len(self.sImages)): self.sImages[i] = self.baseURL() + self.sImages[i] self.image.addLoadListener(self) self.prevButton.addClickListener(self) self.nextButton.addClickListener(self) topPanel = DockPanel() topPanel.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) topPanel.add(self.prevButton, DockPanel.WEST) topPanel.add(self.nextButton, DockPanel.EAST) topPanel.add(self.loadingImage, DockPanel.CENTER) panel = VerticalPanel() panel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) panel.add(HTML("<h2>A Bit of Rembrandt</h2>", True)) panel.add(topPanel) panel.add(self.image) panel.setWidth("100%") self.initWidget(panel) self.image.setStyleName("ks-images-Image") self.nextButton.setStyleName("ks-images-Button") self.prevButton.setStyleName("ks-images-Button") self.loadImage(0)
def __init__(self): Sink.__init__(self) disabledButton = Button("Disabled Button") disabledCheck = CheckBox("Disabled Check") normalButton = Button("Normal Button") normalCheck = CheckBox("Normal Check") panel = VerticalPanel() radio0 = RadioButton("group0", "Choice 0") radio1 = RadioButton("group0", "Choice 1") radio2 = RadioButton("group0", "Choice 2 (Disabled)") radio3 = RadioButton("group0", "Choice 3") hp = HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(normalButton) hp.add(disabledButton) hp = HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(normalCheck) hp.add(disabledCheck) hp = HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(radio0) hp.add(radio1) hp.add(radio2) hp.add(radio3) disabledButton.setEnabled(False) disabledCheck.setEnabled(False) radio2.setEnabled(False) panel.setSpacing(8) self.initWidget(panel)
def __init__(self): Sink.__init__(self) self.menu = MenuBar() subMenu = MenuBar(True) subMenu.addItem("<code>Code</code>", True, self) subMenu.addItem("<strike>Strikethrough</strike>", True, self) subMenu.addItem("<u>Underlined</u>", True, self) menu0 = MenuBar(True) menu0.addItem("<b>Bold</b>", True, self) menu0.addItem("<i>Italicized</i>", True, self) menu0.addItem("More »", True, subMenu) menu1 = MenuBar(True) menu1.addItem("<font color='#FF0000'><b>Apple</b></font>", True, self) menu1.addItem("<font color='#FFFF00'><b>Banana</b></font>", True, self) menu1.addItem("<font color='#FFFFFF'><b>Coconut</b></font>", True, self) menu1.addItem("<font color='#8B4513'><b>Donut</b></font>", True, self) menu2 = MenuBar(True) menu2.addItem("Bling", self) menu2.addItem("Ginormous", self) menu2.addItem("<code>w00t!</code>", True, self) self.menu.addItem(MenuItem("Style", menu0)) self.menu.addItem(MenuItem("Fruit", menu1)) self.menu.addItem(MenuItem("Term", menu2)) self.menu.setWidth("100%") self.panel = VerticalPanel() self.context = HTML("""Right-Click me<br/>to show a context menu.<br /> Left-click me<br />to do absolutely nothing.""") self.panel.add(self.menu) self.panel.add(self.context) self.initWidget(self.panel) self.context.setContextMenu(self)
def __init__(self): Sink.__init__(self) disabledButton = Button("Disabled Button") disabledCheck = CheckBox("Disabled Check") normalButton = Button("Normal Button") normalCheck = CheckBox("Normal Check") panel = VerticalPanel() radio0 = RadioButton("group0", "Choice 0") radio1 = RadioButton("group0", "Choice 1") radio2 = RadioButton("group0", "Choice 2 (Disabled)") radio3 = RadioButton("group0", "Choice 3") hp=HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(normalButton) hp.add(disabledButton) hp=HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(normalCheck) hp.add(disabledCheck) hp=HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(radio0) hp.add(radio1) hp.add(radio2) hp.add(radio3) disabledButton.setEnabled(False) disabledCheck.setEnabled(False) radio2.setEnabled(False) panel.setSpacing(8) self.initWidget(panel)
def __init__(self): Sink.__init__(self) img = Image("images/num1.png") img.addMouseListener(TooltipListener("An image: " + img.getUrl())) img2 = Image("images/num2.png") img2.addMouseListener(TooltipListener("An image: " + img2.getUrl())) html = HTML("Some <i>HTML</i> text.") html.addMouseListener(TooltipListener("An HTML component.")) panel_h = HorizontalPanel() panel_h.add(img) panel_h.add(img2) panel_h.setSpacing(8) panel = VerticalPanel() panel.add(panel_h) panel.add(html) panel.setSpacing(8) self.setWidget(panel)
def __init__(self): Sink.__init__(self) self.sStrings=[["foo0", "bar0", "baz0", "toto0", "tintin0"], ["foo1", "bar1", "baz1", "toto1", "tintin1"], ["foo2", "bar2", "baz2", "toto2", "tintin2"], ["foo3", "bar3", "baz3", "toto3", "tintin3"], ["foo4", "bar4", "baz4", "toto4", "tintin4"]] self.combo=ListBox(VisibleItemCount=1) self.list=ListBox(MultipleSelect=True, VisibleItemCount=10) self.echo=Label() self.combo.addChangeListener(self) for i in range(len(self.sStrings)): txt = "List %d" % i self.combo.addItem(txt) # test setItemText self.combo.setItemText(i, txt + " using set text") self.combo.setSelectedIndex(0) self.fillList(0) self.list.setItemSelected(0, False) self.list.setItemSelected(1, True) self.list.addChangeListener(self) horz = HorizontalPanel(VerticalAlignment=HasAlignment.ALIGN_TOP, Spacing=8) horz.add(self.combo) horz.add(self.list) panel = VerticalPanel(HorizontalAlignment=HasAlignment.ALIGN_LEFT) panel.add(horz) panel.add(self.echo) self.initWidget(panel) self.echoSelection()
def __init__(self, wsnsize, theta, emax, cachelen, dataSize, net_file_name): self.sink = Sink(net_file_name) self.sink.buildGroup() self.sink.refineGroups() self.sink.refineGroups() self.skf = [] self.slist = [] self.dataSize = dataSize self.est_mean = 0.0 self.wsnSize = wsnsize self.totalVar = 0 self.outputlen = 0 self.TotalAgrData = 0 self.totalaggregationOutput = [] self.prevList = [] for i in range(0, wsnsize): skl = SinkKalmanFilter(i + 1) sn = SensorSimulator(theta, emax, cachelen) sn.getSensorReadings(i + 1, dataSize) self.slist.append((sn)) self.skf.append((skl))
def __init__(self): Sink.__init__(self) self.sStrings = [["foo0", "bar0", "baz0", "toto0", "tintin0"], ["foo1", "bar1", "baz1", "toto1", "tintin1"], ["foo2", "bar2", "baz2", "toto2", "tintin2"], ["foo3", "bar3", "baz3", "toto3", "tintin3"], ["foo4", "bar4", "baz4", "toto4", "tintin4"]] self.combo = ListBox() self.list = ListBox() self.echo = Label() self.combo.setVisibleItemCount(1) self.combo.addChangeListener(self) self.list.setVisibleItemCount(10) self.list.setMultipleSelect(True) for i in range(len(self.sStrings)): self.combo.addItem("List %d" % i) self.combo.setSelectedIndex(0) self.fillList(0) self.list.addChangeListener(self) horz = HorizontalPanel() horz.setVerticalAlignment(HasAlignment.ALIGN_TOP) horz.setSpacing(8) horz.add(self.combo) horz.add(self.list) panel = VerticalPanel() panel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT) panel.add(horz) panel.add(self.echo) self.initWidget(panel) self.echoSelection()
def main(): rospy.init_node('mission_planner') sm = smach.StateMachine( outcomes=['mission_complete', 'mission_failed', 'aborted']) theta = 0 with sm: Sink(sm, 'DEPTH1', 545, 'mission_complete') sis = IntrospectionServer('ZARNA_MISSION_PLANNER', sm, '/START_ZARNA') sis.start() outcome = sm.execute() rospy.spin() sis.stop()
def main(): rospy.init_node('mission_planner') sm = smach.StateMachine( outcomes=['mission_complete', 'mission_failed', 'aborted']) theta = 0 with sm: Sink(sm, 'SINK1', 525, 'HEADING1') Heading(sm, 'HEADING1', 90, 'mission_complete') #Forward(sm, 'FORWARD1', 12, 'mission_complete') sis = IntrospectionServer('ZARNA_MISSION_PLANNER', sm, '/START_ZARNA') sis.start() outcome = sm.execute() rospy.spin() sis.stop()
def main(): rospy.init_node('mission_planner') sm = smach.StateMachine(outcomes=['mission_complete', 'mission_failed', 'aborted']) theta = 0 with sm: Sink (sm, 'SINK1', 547, 'HEADING1') Heading(sm, 'HEADING1', 90, 'mission_complete') #it = ImageTask() # Image Task should return User data which should be # further mapped to Heading etc states #it.init(sm) sis = IntrospectionServer('ZARNA_MISSION_PLANNER', sm, '/START_ZARNA') # start introspection server by - rosrun smach_viewer smach_viewer.py sis.start() outcome = sm.execute() rospy.spin() sis.stop()
def main(): sm = smach.StateMachine( outcomes=['mission_complete', 'mission_failed', 'aborted']) theta = 0 with sm: # smach.StateMachine.add('TORPEDO', Torpedo(), transitions={'torpedo_success':'mission_complete'}) # smach.StateMachine.add('DETECTBUOY', DetectBuoy(), transitions={'buoy_success':'mission_complete', 'buoy_retry': 'DETECTBUOY'}) Sink(sm, 'SINK1', 515, 'HEADING1') Heading(sm, 'HEADING1', 75, 'FORWARD1') Forward(sm, 'FORWARD1', 6, 'FORWARD2') Forward(sm, 'FORWARD2', 12, 'mission_complete') #Heading(sm, 'HEADING2', 90, 'FORWARD2') #Forward(sm, 'FORWARD2', 10, 'HEADING3') #Heading(sm, 'HEADING3', 90, 'FORWARD3') #Forward(sm, 'FORWARD3', 15, 'mission_complete') #DetectBuoy(sm, 'DETECTBUOY', 'FORWARD2') #Forward(sm, 'FORWARD2', 14, 'HEADING2') #Heading(sm, 'HEADING2', theta + 45, 'FORWARD3') #Forward(sm, 'FORWARD3', 14, 'SWAY1') #torpedo fire #Sway(sm, 'SWAY1', -5, 'FORWARD4') #Forward(sm, 'FORWARD4', 10, 'SINK2') #Sink (sm, 'SINK2', 525, 'mission_complete') #resurface #it = ImageTask() # Image Task should return User data which should be # further mapped to Heading etc states #it.init(sm) sis = IntrospectionServer('ZARNA_MISSION_PLANNER', sm, '/START_ZARNA') # start introspection server by - rosrun smach_viewer smach_viewer.py sis.start() outcome = sm.execute() boolean = 1 sis.stop() rospy.loginfo("Mission Complete")
class Environment: NEAR = 'near' ENERGY = 'energy' DUTY_CICLE = 'duty_cicle' def __init__(self, number_of_nodes, transmission_range, speed_sink, size_area, sink_route, strategy, duty_cycle): """ :type number_of_nodes: a integer number :type transmission_range: a number, given in meters :type speed_sink: a number, speed given in meters per second :type size_area: a list of two numbers, the values in meters :type sink_route: a list of list of two numbers referring to the each target position :type strategy: a string, use static variable on class Environment :type duty_cycle: a boolean, enable duty-cicle on nodes """ self.sink = None self.define_sink_route(sink_route, speed_sink) self.transmission_range = transmission_range self.size_x = size_area[0] self.size_y = size_area[1] self.sink_route = sink_route self.strategy = strategy self.duty_cicle = duty_cycle self.nodes = [] Node.is_run = True for i in range(number_of_nodes): x_pos = randint(0, self.size_x) y_pos = randint(0, self.size_y) pos = (x_pos, y_pos) node = Node(pos, duty_cycle) node.start() self.nodes.append(node) def define_sink_route(self, sink_route, speed_sink): if len(sink_route) < 2: raise Exception('Esperado, ao menos, lista com duas listas contendo posição inicial e destino') init_sink_position = sink_route[0] del sink_route[0] target_sink_position = (sink_route[0]) del sink_route[0] self.sink = Sink(init_sink_position, speed_sink, target_sink_position) self.sink_route = sink_route def check_nodes_in_sink_radius(self, clock): packets_transmitted = 0 packets_lost = 0 nodes_founds = [] nodes_lost = [] more_energy = [0, None] more_close = [self.transmission_range + 1, None] for node in self.nodes: node_on = node.wait_beacon(clock) if self.strategy == Environment.DUTY_CICLE: if not node_on: continue x = node.position[0] - self.sink.position[0] y = node.position[1] - self.sink.position[1] distance = sqrt(x ** 2 + y ** 2) if distance <= self.transmission_range: nodes_founds.append(node.id) if node.energy < Node.cost_send_package: nodes_lost.append(node.id) else: if more_energy[0] < node.energy: more_energy[0] = node.energy more_energy[1] = node if more_close[0] > distance: more_close[0] = distance more_close[1] = node if self.strategy == Environment.ENERGY: if more_energy[0] >= Node.cost_send_package: if more_energy[1].package_transmission(): packets_transmitted += 1 packets_lost = len(nodes_founds) - len(nodes_lost) - 1 else: # self.strategy == Environment.NEAR: if more_close[0] <= self.transmission_range: if more_close[1].package_transmission(): packets_transmitted += 1 packets_lost = len(nodes_founds) - len(nodes_lost) - 1 def check_environment(self): packets_lost = 0 sink_pos = self.sink.position nodes_founds = [] Node.sink_position = self.sink.position # atualiza posição do sink Node.environment.append(Node.BEACON) nodes_in_radius = 0 for node in Node.environment: if type(node) == Node: x = node.position[0] - sink_pos[0] y = node.position[1] - sink_pos[1] distance = sqrt(x ** 2 + y ** 2) if distance <= self.transmission_range: nodes_founds.append(node.id) nodes_in_radius += 1 debug('Nó ' + str(node.id) + ' encontrado pelo Sink') if nodes_in_radius > 1: packets_transmitted = 0 packets_lost = nodes_in_radius else: packets_transmitted = nodes_in_radius Node.environment.remove(Node.BEACON) self.sink.reached_target() # movimentação do sink if self.sink.in_target and len(self.sink_route): self.sink.update_target(self.sink_route[0]) del self.sink_route[0] return packets_transmitted, packets_lost, nodes_founds, Node.nodes_discharged def end_sink_turn(self): if len(self.sink_route) == 0 and self.sink.in_target: return True else: return False def energy_network_level(self): energy = 0 for node in self.nodes: energy += node.energy return energy def nodes_lost(self): return len(Node.nodes_discharged) def finalize(self): Node.is_run = False sleep(0.01)
distAfter = np.sqrt(((sinkX + sdeltaX)**2) + ((sinkY + sdeltaY)**2)) self.deltaDist = distAfter - distBefore return self.deltaDist if __name__ == "__main__": Hrz = 10 Res = Hrz + 1 testNode = MPCnode(1, 20, 20, 0.05, Hrz, Res) testNode.CHstatus = 1 testNode1 = MPCnode(2, 20, 60, 0.05, Hrz, Res) testNode1.CHstatus = 1 testNode2 = Sink(100, 100) testNode.connect(testNode2) testNode1.connect(testNode2) #print('x: {0}, y: {1}'.format(testNode2.xPos,testNode2.yPos)) testNode2.move(-30, 40) #print('x: {0}, y: {1}'.format(testNode2.xPos,testNode2.yPos)) #print('Distance to sink: {0}'.format(testNode.getDistance(testNode2))) #print("Segment: {0}, PR: {1}, PS: {2}".format(0,testNode.PA, testNode.getPS())) #print(testNode.data.value) #testNode.sendMsg(testNode2) #testNode.plot() #testNode.controlPR(0,0) #testNode.m.time[Hrz-1] = testNode.m.time[Hrz]-0.0000000000001 testNode.setDesData(20)
def __init__(self): text="<div class='infoProse'>Welcome to the Addons Gallery. " text+="This app shows off the addon components for Pyjamas.</div>" Sink.__init__(self) self.setWidget(HTML(text, True))
class Environment: NEAR = 'near' ENERGY = 'energy' DUTY_CICLE = 'duty_cicle' def __init__(self, number_of_nodes, transmission_range, speed_sink, size_area, sink_route, strategy, duty_cycle): """ :type number_of_nodes: a integer number :type transmission_range: a number, given in meters :type speed_sink: a number, speed given in meters per second :type size_area: a list of two numbers, the values in meters :type sink_route: a list of list of two numbers referring to the each target position :type strategy: a string, use static variable on class Environment :type duty_cycle: a boolean, enable duty-cicle on nodes """ self.sink = None self.define_sink_route(sink_route, speed_sink) self.transmission_range = transmission_range self.size_x = size_area[0] self.size_y = size_area[1] self.sink_route = sink_route self.strategy = strategy self.duty_cicle = duty_cycle self.nodes = [] Node.is_run = True for i in range(number_of_nodes): x_pos = randint(0, self.size_x) y_pos = randint(0, self.size_y) pos = (x_pos, y_pos) node = Node(pos, duty_cycle) node.start() self.nodes.append(node) def define_sink_route(self, sink_route, speed_sink): if len(sink_route) < 2: raise Exception( 'Esperado, ao menos, lista com duas listas contendo posição inicial e destino' ) init_sink_position = sink_route[0] del sink_route[0] target_sink_position = (sink_route[0]) del sink_route[0] self.sink = Sink(init_sink_position, speed_sink, target_sink_position) self.sink_route = sink_route def check_nodes_in_sink_radius(self, clock): packets_transmitted = 0 packets_lost = 0 nodes_founds = [] nodes_lost = [] more_energy = [0, None] more_close = [self.transmission_range + 1, None] for node in self.nodes: node_on = node.wait_beacon(clock) if self.strategy == Environment.DUTY_CICLE: if not node_on: continue x = node.position[0] - self.sink.position[0] y = node.position[1] - self.sink.position[1] distance = sqrt(x**2 + y**2) if distance <= self.transmission_range: nodes_founds.append(node.id) if node.energy < Node.cost_send_package: nodes_lost.append(node.id) else: if more_energy[0] < node.energy: more_energy[0] = node.energy more_energy[1] = node if more_close[0] > distance: more_close[0] = distance more_close[1] = node if self.strategy == Environment.ENERGY: if more_energy[0] >= Node.cost_send_package: if more_energy[1].package_transmission(): packets_transmitted += 1 packets_lost = len(nodes_founds) - len(nodes_lost) - 1 else: # self.strategy == Environment.NEAR: if more_close[0] <= self.transmission_range: if more_close[1].package_transmission(): packets_transmitted += 1 packets_lost = len(nodes_founds) - len(nodes_lost) - 1 def check_environment(self): packets_lost = 0 sink_pos = self.sink.position nodes_founds = [] Node.sink_position = self.sink.position # atualiza posição do sink Node.environment.append(Node.BEACON) nodes_in_radius = 0 for node in Node.environment: if type(node) == Node: x = node.position[0] - sink_pos[0] y = node.position[1] - sink_pos[1] distance = sqrt(x**2 + y**2) if distance <= self.transmission_range: nodes_founds.append(node.id) nodes_in_radius += 1 debug('Nó ' + str(node.id) + ' encontrado pelo Sink') if nodes_in_radius > 1: packets_transmitted = 0 packets_lost = nodes_in_radius else: packets_transmitted = nodes_in_radius Node.environment.remove(Node.BEACON) self.sink.reached_target() # movimentação do sink if self.sink.in_target and len(self.sink_route): self.sink.update_target(self.sink_route[0]) del self.sink_route[0] return packets_transmitted, packets_lost, nodes_founds, Node.nodes_discharged def end_sink_turn(self): if len(self.sink_route) == 0 and self.sink.in_target: return True else: return False def energy_network_level(self): energy = 0 for node in self.nodes: energy += node.energy return energy def nodes_lost(self): return len(Node.nodes_discharged) def finalize(self): Node.is_run = False sleep(0.01)
def __init__(self): Sink.__init__(self) self.fProto = [ Proto("Beethoven", [ Proto("Concertos", [ Proto("No. 1 - C"), Proto("No. 2 - B-Flat Major"), Proto("No. 3 - C Minor"), Proto("No. 4 - G Major"), Proto("No. 5 - E-Flat Major") ]), Proto("Quartets", [ Proto("Six String Quartets"), Proto("Three String Quartets"), Proto("Grosse Fugue for String Quartets") ]), Proto("Sonatas", [ Proto("Sonata in A Minor"), Proto("Sonata in F Major") ]), Proto("Symphonies", [ Proto("No. 1 - C Major"), Proto("No. 2 - D Major"), Proto("No. 3 - E-Flat Major"), Proto("No. 4 - B-Flat Major"), Proto("No. 5 - C Minor"), Proto("No. 6 - F Major"), Proto("No. 7 - A Major"), Proto("No. 8 - F Major"), Proto("No. 9 - D Minor") ]) ]), Proto("Brahms", [ Proto("Concertos", [ Proto("Violin Concerto"), Proto("Double Concerto - A Minor"), Proto("Piano Concerto No. 1 - D Minor"), Proto("Piano Concerto No. 2 - B-Flat Major") ]), Proto("Quartets", [ Proto("Piano Quartet No. 1 - G Minor"), Proto("Piano Quartet No. 2 - A Major"), Proto("Piano Quartet No. 3 - C Minor"), Proto("String Quartet No. 3 - B-Flat Minor") ]), Proto("Sonatas", [ Proto("Two Sonatas for Clarinet - F Minor"), Proto("Two Sonatas for Clarinet - E-Flat Major") ]), Proto("Symphonies", [ Proto("No. 1 - C Minor"), Proto("No. 2 - D Minor"), Proto("No. 3 - F Major"), Proto("No. 4 - E Minor") ]) ]), Proto("Mozart", [ Proto("Concertos", [ Proto("Piano Concerto No. 12"), Proto("Piano Concerto No. 17"), Proto("Clarinet Concerto"), Proto("Violin Concerto No. 5"), Proto("Violin Concerto No. 4") ]), ]) ] self.fTree = Tree() for i in range(len(self.fProto)): self.createItem(self.fProto[i]) self.fTree.addItem(self.fProto[i].item) self.fTree.addTreeListener(self) self.initWidget(self.fTree)
class myApproach: def __init__(self, wsnsize, theta, emax, cachelen, dataSize, net_file_name): self.sink = Sink(net_file_name) self.sink.buildGroup() self.sink.refineGroups() self.sink.refineGroups() self.skf = [] self.slist = [] self.dataSize = dataSize self.est_mean = 0.0 self.wsnSize = wsnsize self.totalVar = 0 self.outputlen = 0 self.TotalAgrData = 0 self.totalaggregationOutput = [] self.prevList = [] for i in range(0, wsnsize): skl = SinkKalmanFilter(i + 1) sn = SensorSimulator(theta, emax, cachelen) sn.getSensorReadings(i + 1, dataSize) self.slist.append((sn)) self.skf.append((skl)) def aggregate(self, rno, th): lls = self.sink.lls temp = lls.head sum = 0.0 counter = 0 agList = [] tlist = [] sum_2 = 0 while (temp is not None): node_id = temp.getNodeId() sensorh = self.slist[node_id - 1] valh = sensorh.RDR(sensorh.readings[rno]) counter += 1 if valh is None: #my code valh = self.skf[node_id - 1].run(None) tlist.append(valh) sum += self.skf[node_id - 1].run(None) else: sum += valh tlist.append(valh) self.skf[node_id - 1].run(sensorh.readings[rno]) for el in temp.getNeighbors(): sensor = self.slist[el - 1] val = sensor.RDR(sensor.readings[rno]) if val is None: val = self.skf[el - 1].run(None) tlist.append(val) sum += self.skf[el - 1].run(None) else: tlist.append(val) sum += val self.skf[el - 1].run(sensor.readings[rno]) counter += 1 sum_2 = (max(tlist) + min(tlist)) / 2 #print((max(tlist)+min(tlist))/2, " ", tlist) tlist = [] #print("valh",valh) #print("val",val) agList.append(sum_2) #agList.append((sum/counter)) #here is my code counter = 0 sum = 0.0 self.outputlen = len(agList) temp = temp.next sum = 0 templist_1 = agList templist_2 = [] """if len(self.prevList)==0: self.prevList=agList templist_2=agList else: for i in range(len(self.prevList)): if abs(round(self.prevList[i])-round(agList[i]))>th: templist_2.append(agList[i]) else: templist_2.append(0)""" #print("aggregation list ", agList) self.TotalAgrData += len(agList) #print(len(agList),"###########") for d in agList: sum += d self.est_mean += (sum / len(agList)) #print((sum/len(agList))) self.totalVar += np.var(agList) #print("estimated",self.est_mean) #print(templist_2) self.prevList = agList self.totalaggregationOutput.append(agList) def findTemporalRedundancy(self, th): counter = 0 unsimilardata = 0 totaldata = 0 sum = 0 for k in range(0, len(self.totalaggregationOutput[0])): for i in range(0, self.dataSize - 1): if abs(self.totalaggregationOutput[i][k] - self.totalaggregationOutput[i + 1][k]) > th: counter += self.totalaggregationOutput[i][k] #here is my code unsimilardata += self.totalaggregationOutput[i][k] #sum+=counter/self.dataSize sum = 0 counter = 0 print("Temporal Redundancy", sum / len(self.totalaggregationOutput[0]) * 100) def findSpatialRedundancy(self, th): tspred = 0 counter = 1 spatial_sum = 0 spatial_sum1 = 0 tReadings = [] for n in self.totalaggregationOutput: # print("appppppppppppppp",n) for k in range(0, len(n) - 1): if round(n[k]) not in tReadings: tReadings.append(round(n[k])) for l in range(k + 1, len(n)): if abs(round(n[k]) - round(n[l])) <= th: counter += 1 if counter > 1: spatial_sum += (round(n[k]) * counter) / len(n) #print(n[k]," ",(n[k] * counter) ) counter = 1 spatial_sum1 += 1 - len(tReadings) / len(n) tReadings = [] spatial_sum = 0 counter = 1 # counter=counter # tspred += (counter / len(n)) print("Spatial Redundancy:", spatial_sum1 / self.dataSize * 100) """tspred = 0 counter = 1 spatial_sum=0 spatial_sum1=0 tReadings = [] for n in self.totalaggregationOutput: #print("appppppppppppppp",n) for k in range(0, len(n) - 1): if n[k]==0: continue if n[k] not in tReadings: tReadings.append(n[k]) for l in range(k + 1, len(n)): if abs(n[k] - n[l]) < th: counter +=1 if counter>1: spatial_sum+=(n[k]*counter)#/len(n) counter=1 tReadings=[] spatial_sum1+=spatial_sum/sum(n) spatial_sum=0 counter=1 #counter=counter # tspred += (counter / len(n)) print("Spatial Redundancy:",spatial_sum1/self.dataSize*100) """ """tspred = 0 counter = 1 spatial_sum = 0 spatial_sum1 = 0 tReadings = [] for n in self.totalaggregationOutput: #print("appppppppppppppp",n) for k in range(0, len(n) - 1): if n[k] == 0: continue if round(n[k]) not in tReadings: tReadings.append(round(n[k])) for l in range(k + 1, len(n)): if abs(round(n[k]) - round(n[l])) <= th: counter += 1 if counter > 1: spatial_sum += ( counter) / len(n) # print(n[k]," ",(n[k] * counter) ) counter = 1 tReadings = [] spatial_sum1 += spatial_sum / len(n) spatial_sum = 0 counter = 1 # counter=counter # tspred += (counter / len(n)) print("Spatial Redundancy:", spatial_sum1 / self.dataSize * 100) """ def findAggregationRate(self): agRate = (self.TotalAgrData / (self.wsnSize * self.dataSize)) * 100 #print(self.TotalAgrData, " ", self.wsnSize," ", self.dataSize) print(" Aggregation Rate:", agRate) def findAccuracy(self): sum = 00.0 actual_mean = 0.0 for i in range(0, self.dataSize): for s in self.slist: sum += s.readings[i] #print(s.readings[i]) actual_mean += (sum / self.wsnSize) #print((sum/self.wsnSize)) sum = 0 #actual_mean=actual_mean/self.dataSize #self.est_mean=self.est_mean/self.dataSize #print(actual_mean, " ", self.est_mean) acc = (abs(actual_mean - self.est_mean) / actual_mean) * 100 print("Accuracy:", acc) print("estemated mean", self.est_mean, "\n actual mean", actual_mean) def findEnergyConsumption(self): lls = self.sink.lls temp = lls.head sum = 0.0 TotalTrans = 0 while (temp is not None): node_id = temp.getNodeId() sum += 3.6 - self.slist[node_id - 1].batCap TotalTrans += self.slist[node_id - 1].totaltrans for el in temp.getNeighbors(): sum += 3.6 - self.slist[el - 1].batCap TotalTrans += self.slist[el - 1].totaltrans temp = temp.next #print("Total:", TotalTrans) return sum def findEnergyEfficiency(self): sum = 0 for s in self.slist: sum += s.findEnergyEfficiency() print("Energy Efficiency:", sum)
def __init__(self, parent = None): Sink.__init__(self, parent) self.reduceFiles = [] if True: HTTPRequest().asyncGet("datadir.xml", DirDictLoader(self), ) dock = DockPanel(HorizontalAlignment=HasAlignment.ALIGN_LEFT, Spacing=10, Size=("100%","100%")) self.dock = dock self.fProto = [] self.fTree = Tree() self.prPanel = VerticalPanel(Size=("50%", "")) self.treePanel = HorizontalPanel(Size=("50%", "100%")) self.treePanel.add(self.fTree) dock.add(self.treePanel, DockPanel.WEST) self.treePanel.setBorderWidth(1) self.treePanel.setWidth("100%") self.prPanel.setBorderWidth(1) self.prPanel.setWidth("100%") # prepare panel self.prepareReduce = HTML("<tt> .. none yet .. </tt>", True, ) self.recipeList = ListBox() self.recipeList.addChangeListener(getattr(self, "onRecipeSelected")) self.recipeList.addItem("None") HTTPRequest().asyncGet("recipes.xml", RecipeListLoader(self)) #EO prepare panel self.reduceCLPanel = DockPanel(Spacing = 5) self.reduceCLPanel.add(HTML("<i>Reduce Command Line</i>:"), DockPanel.NORTH) self.reduceCLPanel.add(self.prepareReduce, DockPanel.NORTH) self.reduceFilesPanel = DockPanel(Spacing = 5) self.reduceFilesPanel.add(HTML("<b>Datasets</b>:"), DockPanel.WEST) self.reduceFiles = ListBox() self.reduceFiles.setVisibleItemCount(5) self.reduceFilesPanel.add(self.reduceFiles, DockPanel.WEST) self.clearReduceFilesButton = Button("<b>Clear List</b>", listener = getattr(self, "onClearReduceFiles")) self.reduceFilesPanel.add(self.clearReduceFilesButton, DockPanel.SOUTH) self.recipeListPanel = DockPanel(Spacing = 5) self.recipeListPanel.add(HTML("<b>Recipes List</b>:"),DockPanel.WEST) self.recipeListPanel.add(self.recipeList, DockPanel.WEST) self.runReduceButton = Button("<b>RUN REDUCE</b>", listener = getattr(self, "onRunReduce")) self.adInfo = HTML("file info...") # major sub panels self.prPanel.add(self.reduceCLPanel) self.prPanel.add(self.reduceFilesPanel) self.prPanel.add(self.recipeListPanel) self.prPanel.add(self.runReduceButton) self.prPanel.add(self.adInfo) dock.add(self.prPanel,DockPanel.EAST) dock.setCellWidth(self.treePanel, "50%") dock.setCellWidth(self.prPanel, "50%") for i in range(len(self.fProto)): self.createItem(self.fProto[i]) self.fTree.addItem(self.fProto[i].item) self.fTree.addTreeListener(self) self.initWidget(self.dock) if False: #self.parent.filexml != None: DirDictLoader(self).onCompletion(self.parent.filexml)
def run(file_name, datasize): #lls=uploadData(file_name) s = Sink(file_name) global test_mean global actual_mean global aglist global energy_con #s.buildGroup() #s.refineGroups() lls = s.lls actual_mean = 0 test_mean = 0 counter = 0 wsnNet = [] sum_1 = 0 temp = lls.head templist = [] while temp is not None: ch = ClusterHead(datasize, temp.getNodeId(), temp.getNeighbors()) wsnNet.append(ch) temp = temp.next sum_2 = 0 counter_2 = 0 for i in range(0, datasize): for ch in wsnNet: sum_2 += ch.readings[i] counter_2 += 1 for s in ch.wsn: sum_2 += s.readings[i] counter_2 += 1 actual_mean = actual_mean + sum_2 / counter_2 #print(sum_2/counter_2) sum_2 = 0 counter_2 = 0 for i in range(0, datasize): for ch in wsnNet: #charge = ch.Itx * (0.426 + 15) / 32768 charge = 17.4 / 32768 Etx = ch.V * charge l = ch.aggregate(i) ch.batCap = ch.batCap - Etx * len(l) sum_1 += sum(l) / len(l) #/len(ch.aggregate(i)) counter += 1 for val in l: templist.append(val) #print(counter, " ",len(templist)) aglist.append(templist) #print( sum(templist)/len(templist)) test_mean += sum(templist) / len(templist) #print(sum(templist)/len(templist)) templist = [] counter = 0 sum_1 = 0 total = 0 for ch in wsnNet: energy_con += 3.6 - ch.batCap total += ch.ChTotalTrans for s in ch.wsn: total += s.totaltrans energy_con += 3.6 - s.batCap print("Energy Efficiency:", total / (energy_con))
def __init__(self): Sink.__init__(self) text = """This is a <code>ScrollPanel</code> contained at the center of a <code>DockPanel</code>. By putting some fairly large contents in the middle and setting its size explicitly, it becomes a scrollable area within the page, but without requiring the use of an IFRAME. Here's quite a bit more meaningless text that will serve primarily to make this thing scroll off the bottom of its visible area. Otherwise, you might have to make it really, really small in order to see the nifty scroll bars!""" contents = HTML(text) scroller = ScrollPanel(contents, StyleName="ks-layouts-Scroller") dock = DockPanel(HorizontalAlignment=HasAlignment.ALIGN_CENTER, Spacing=10) north0 = HTML("This is the <i>first</i> north component", True) east = HTML("<center>This<br>is<br>the<br>east<br>component</center>", True) south = HTML("This is the south component") west = HTML("<center>This<br>is<br>the<br>west<br>component</center>", True) north1 = HTML("This is the <b>second</b> north component", True) dock.add(north0, DockPanel.NORTH) dock.add(east, DockPanel.EAST) dock.add(south, DockPanel.SOUTH) dock.add(west, DockPanel.WEST) dock.add(north1, DockPanel.NORTH) dock.add(scroller, DockPanel.CENTER) #Logger.write("Layouts", "TODO: flowpanel") flow = FlowPanel() for i in range(8): flow.add(CheckBox("Flow %d" % i)) horz = HorizontalPanel(VerticalAlignment=HasAlignment.ALIGN_MIDDLE) horz.add(Button("Button")) horz.add(HTML("<center>This is a<br>very<br>tall thing</center>", True)) horz.add(Button("Button")) vert = VerticalPanel(HorizontalAlignment=HasAlignment.ALIGN_CENTER) vert.add(Button("Small")) vert.add(Button("--- BigBigBigBig ---")) vert.add(Button("tiny")) menu = MenuBar() menu0 = MenuBar(True) menu1 = MenuBar(True) menu.addItem("menu0", menu0) menu.addItem("menu1", menu1) menu0.addItem("child00") menu0.addItem("child01") menu0.addItem("child02") menu1.addItem("child10") menu1.addItem("child11") menu1.addItem("child12") #Logger.write("Layouts", "TODO: htmlpanel") id = HTMLPanel.createUniqueId() text = """This is an <code>HTMLPanel</code>. It allows you to add components inside existing HTML, like this: <span id='%s' /> Notice how the menu just fits snugly in there? Cute.""" % id html = HTMLPanel(text) DOM.setStyleAttribute(menu.getElement(), "display", "inline") html.add(menu, id) disclose = DisclosurePanel("Click to disclose") disclose.add( HTML("""<b>Ta-daaaaa!</b><br />Ok - it could have been<br />more of a surprise.""")) panel = VerticalPanel(Spacing=8, HorizontalAlignment=HasAlignment.ALIGN_CENTER) panel.add(self.makeLabel("Dock Panel")) panel.add(dock) panel.add(self.makeLabel("Flow Panel")) panel.add(flow) panel.add(self.makeLabel("Horizontal Panel")) panel.add(horz) panel.add(self.makeLabel("Vertical Panel")) panel.add(vert) panel.add(self.makeLabel("HTML Panel")) panel.add(html) panel.add(self.makeLabel("Disclosure Panel")) panel.add(disclose) self.initWidget(panel) self.setStyleName("ks-layouts")
def __init__(self): Sink.__init__(self) text="""This is a <code>ScrollPanel</code> contained at the center of a <code>DockPanel</code>. By putting some fairly large contents in the middle and setting its size explicitly, it becomes a scrollable area within the page, but without requiring the use of an IFRAME. Here's quite a bit more meaningless text that will serve primarily to make this thing scroll off the bottom of its visible area. Otherwise, you might have to make it really, really small in order to see the nifty scroll bars!""" contents = HTML(text) scroller = ScrollPanel(contents, StyleName="ks-layouts-Scroller") dock = DockPanel(HorizontalAlignment=HasAlignment.ALIGN_CENTER, Spacing=10) north0 = HTML("This is the <i>first</i> north component", True) east = HTML("<center>This<br>is<br>the<br>east<br>component</center>", True) south = HTML("This is the south component") west = HTML("<center>This<br>is<br>the<br>west<br>component</center>", True) north1 = HTML("This is the <b>second</b> north component", True) dock.add(north0, DockPanel.NORTH) dock.add(east, DockPanel.EAST) dock.add(south, DockPanel.SOUTH) dock.add(west, DockPanel.WEST) dock.add(north1, DockPanel.NORTH) dock.add(scroller, DockPanel.CENTER) #Logger.write("Layouts", "TODO: flowpanel") flow = FlowPanel() for i in range(8): flow.add(CheckBox("Flow %d" % i)) horz = HorizontalPanel(VerticalAlignment=HasAlignment.ALIGN_MIDDLE) horz.add(Button("Button")) horz.add(HTML("<center>This is a<br>very<br>tall thing</center>", True)) horz.add(Button("Button")) vert = VerticalPanel(HorizontalAlignment=HasAlignment.ALIGN_CENTER) vert.add(Button("Small")) vert.add(Button("--- BigBigBigBig ---")) vert.add(Button("tiny")) menu = MenuBar() menu0 = MenuBar(True) menu1 = MenuBar(True) menu.addItem("menu0", menu0) menu.addItem("menu1", menu1) menu0.addItem("child00") menu0.addItem("child01") menu0.addItem("child02") menu1.addItem("child10") menu1.addItem("child11") menu1.addItem("child12") #Logger.write("Layouts", "TODO: htmlpanel") id = HTMLPanel.createUniqueId() text="""This is an <code>HTMLPanel</code>. It allows you to add components inside existing HTML, like this: <span id='%s' /> Notice how the menu just fits snugly in there? Cute.""" % id html = HTMLPanel(text) DOM.setStyleAttribute(menu.getElement(), "display", "inline") html.add(menu, id) disclose = DisclosurePanel("Click to disclose") disclose.add(HTML("""<b>Ta-daaaaa!</b><br />Ok - it could have been<br />more of a surprise.""")) panel = VerticalPanel(Spacing=8, HorizontalAlignment=HasAlignment.ALIGN_CENTER) panel.add(self.makeLabel("Dock Panel")) panel.add(dock) panel.add(self.makeLabel("Flow Panel")) panel.add(flow) panel.add(self.makeLabel("Horizontal Panel")) panel.add(horz) panel.add(self.makeLabel("Vertical Panel")) panel.add(vert) panel.add(self.makeLabel("HTML Panel")) panel.add(html) panel.add(self.makeLabel("Disclosure Panel")) panel.add(disclose) self.initWidget(panel) self.setStyleName("ks-layouts")