runtime/NevowServer.py
branchpython3
changeset 3750 f62625418bff
parent 3703 4b75f1506ea1
child 3800 a5a6ee271e65
equal deleted inserted replaced
3749:fda6c1a37662 3750:f62625418bff
    21 # You should have received a copy of the GNU Lesser General Public
    21 # You should have received a copy of the GNU Lesser General Public
    22 # License along with this library; if not, write to the Free Software
    22 # License along with this library; if not, write to the Free Software
    23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
    23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
    24 
    24 
    25 
    25 
    26 from __future__ import absolute_import
    26 
    27 from __future__ import print_function
    27 
    28 import os
    28 import os
    29 import collections
    29 import collections
    30 import shutil
    30 import shutil
    31 import platform as platform_module
    31 import platform as platform_module
    32 from zope.interface import implements
    32 from zope.interface import implements
    76             tags.h1["PLC IS STOPPED"],
    76             tags.h1["PLC IS STOPPED"],
    77         ])
    77         ])
    78 
    78 
    79 
    79 
    80 class MainPage(athena.LiveElement):
    80 class MainPage(athena.LiveElement):
    81     jsClass = u"WebInterface.PLC"
    81     jsClass = "WebInterface.PLC"
    82     docFactory = loaders.stan(
    82     docFactory = loaders.stan(
    83         tags.invisible[
    83         tags.invisible[
    84             tags.div(render=tags.directive('liveElement'))[
    84             tags.div(render=tags.directive('liveElement'))[
    85                 tags.div(id='content')[
    85                 tags.div(id='content')[
    86                     tags.div(render=tags.directive('PLCElement'))]
    86                     tags.div(render=tags.directive('PLCElement'))]
   354     def child_settings(self, context):
   354     def child_settings(self, context):
   355         return SettingsPage()
   355         return SettingsPage()
   356 
   356 
   357     def __init__(self, plcState=False, *a, **kw):
   357     def __init__(self, plcState=False, *a, **kw):
   358         super(WebInterface, self).__init__(*a, **kw)
   358         super(WebInterface, self).__init__(*a, **kw)
   359         self.jsModules.mapping[u'WebInterface'] = paths.AbsNeighbourFile(
   359         self.jsModules.mapping['WebInterface'] = paths.AbsNeighbourFile(
   360             __file__, 'webinterface.js')
   360             __file__, 'webinterface.js')
   361         self.plcState = plcState
   361         self.plcState = plcState
   362         self.MainPage.setPLCState(plcState)
   362         self.MainPage.setPLCState(plcState)
   363 
   363 
   364     def getHMI(self):
   364     def getHMI(self):
   365         return self.MainPage.getHMI()
   365         return self.MainPage.getHMI()
   366 
   366 
   367     def LoadHMI(self, hmi, jsmodules):
   367     def LoadHMI(self, hmi, jsmodules):
   368         for name, path in jsmodules.iteritems():
   368         for name, path in jsmodules.items():
   369             self.jsModules.mapping[name] = os.path.join(WorkingDir, path)
   369             self.jsModules.mapping[name] = os.path.join(WorkingDir, path)
   370         self.MainPage.setPLCStartedHMI(hmi)
   370         self.MainPage.setPLCStartedHMI(hmi)
   371 
   371 
   372     def UnLoadHMI(self):
   372     def UnLoadHMI(self):
   373         self.MainPage.resetPLCStartedHMI()
   373         self.MainPage.resetPLCStartedHMI()