Beremiz_service.py
changeset 396 d1083f580ca1
parent 381 5c0f34a9ab00
child 409 63249a965feb
equal deleted inserted replaced
395:433fd448dd31 396:d1083f580ca1
   524                                              tags.h1["PLC IS NOW STARTED"],
   524                                              tags.h1["PLC IS NOW STARTED"],
   525                                              ])
   525                                              ])
   526         
   526         
   527     class PLCStoppedHMI(PLCHMI):
   527     class PLCStoppedHMI(PLCHMI):
   528         docFactory = loaders.stan(tags.div(render=tags.directive('liveElement'))[
   528         docFactory = loaders.stan(tags.div(render=tags.directive('liveElement'))[
   529                                              tags.h1["PLC IS STOPPED"]
   529                                              tags.h1["PLC IS STOPPED"],
   530                                              ])
   530                                              ])
   531         
   531     
   532     class MainPage(athena.LiveElement):
   532     class MainPage(athena.LiveElement):
   533         jsClass = u"WebInterface.PLC"
   533         jsClass = u"WebInterface.PLC"
   534         docFactory = loaders.stan(tags.div(render=tags.directive('liveElement'))[
   534         docFactory = loaders.stan(tags.div(render=tags.directive('liveElement'))[
   535                                                         tags.div(id='content')[                         
   535                                                         tags.div(id='content')[                         
   536                                                         tags.div(render = tags.directive('PLCElement')),
   536                                                         tags.div(render = tags.directive('PLCElement')),
   580         athena.expose(getPLCElement)
   580         athena.expose(getPLCElement)
   581 
   581 
   582         def detachFragmentChildren(self):
   582         def detachFragmentChildren(self):
   583             for child in self.liveFragmentChildren[:]:
   583             for child in self.liveFragmentChildren[:]:
   584                 child.detach()
   584                 child.detach()
   585         
   585     
   586     class WebInterface(athena.LivePage):
   586     class WebInterface(athena.LivePage):
   587 
   587 
   588         docFactory = loaders.stan([tags.raw(xhtml_header),
   588         docFactory = loaders.stan([tags.raw(xhtml_header),
   589                                    tags.html(xmlns="http://www.w3.org/1999/xhtml")[
   589                                    tags.html(xmlns="http://www.w3.org/1999/xhtml")[
   590                                        tags.head(render=tags.directive('liveglue')),
   590                                        tags.head(render=tags.directive('liveglue')),
   592                                            tags.div[
   592                                            tags.div[
   593                                                    tags.div( render = tags.directive( "MainPage" ))
   593                                                    tags.div( render = tags.directive( "MainPage" ))
   594                                                    ]]]])
   594                                                    ]]]])
   595         MainPage = MainPage()
   595         MainPage = MainPage()
   596         PLCHMI = PLCHMI
   596         PLCHMI = PLCHMI
   597 
   597         
   598         def __init__(self, plcState=False, *a, **kw):
   598         def __init__(self, plcState=False, *a, **kw):
   599             super(WebInterface, self).__init__(*a, **kw)
   599             super(WebInterface, self).__init__(*a, **kw)
   600             self.jsModules.mapping[u'WebInterface'] = util.sibpath(__file__, 'webinterface.js')
   600             self.jsModules.mapping[u'WebInterface'] = util.sibpath(__file__, 'webinterface.js')
   601             self.plcState = plcState
   601             self.plcState = plcState
   602             self.MainPage.setPLCState(plcState)
   602             self.MainPage.setPLCState(plcState)
   643         
   643         
   644         def disconnected(self, reason):
   644         def disconnected(self, reason):
   645             self.MainPage.resetHMI()
   645             self.MainPage.resetHMI()
   646             #print reason
   646             #print reason
   647             #print "We will be called back when the client disconnects"
   647             #print "We will be called back when the client disconnects"
   648     
   648         
   649     if havewx:
   649     if havewx:
   650         reactor.registerWxApp(app)
   650         reactor.registerWxApp(app)
   651     res = WebInterface()
   651     res = WebInterface()
   652     site = appserver.NevowSite(res)
   652     site = appserver.NevowSite(res)
   653     reactor.listenTCP(8009, site)
   653     reactor.listenTCP(8009, site)