PLCControler.py
changeset 385 373635372b93
parent 384 ed27a676d5c9
child 389 6a72016d721a
equal deleted inserted replaced
384:ed27a676d5c9 385:373635372b93
    24 
    24 
    25 from xml.dom import minidom
    25 from xml.dom import minidom
    26 from types import StringType, UnicodeType
    26 from types import StringType, UnicodeType
    27 import cPickle
    27 import cPickle
    28 import os,sys,re
    28 import os,sys,re
       
    29 import datetime
    29 from time import localtime
    30 from time import localtime
    30 from datetime import *
       
    31 
    31 
    32 from plcopen import plcopen
    32 from plcopen import plcopen
    33 from plcopen.structures import *
    33 from plcopen.structures import *
    34 from graphics.GraphicCommons import *
    34 from graphics.GraphicCommons import *
    35 from PLCGenerator import *
    35 from PLCGenerator import *
   209 
   209 
   210     # Create a new project by replacing the current one
   210     # Create a new project by replacing the current one
   211     def CreateNewProject(self, properties):
   211     def CreateNewProject(self, properties):
   212         # Create the project
   212         # Create the project
   213         self.Project = plcopen.project()
   213         self.Project = plcopen.project()
   214         properties["creationDateTime"] = datetime(*localtime()[:6])
   214         properties["creationDateTime"] = datetime.datetime(*localtime()[:6])
   215         self.Project.setfileHeader(properties)
   215         self.Project.setfileHeader(properties)
   216         self.Project.setcontentHeader(properties)
   216         self.Project.setcontentHeader(properties)
   217         self.SetFilePath("")
   217         self.SetFilePath("")
   218         # Initialize the project buffer
   218         # Initialize the project buffer
   219         self.CreateProjectBuffer(False)
   219         self.CreateProjectBuffer(False)
  2434                             values.append(int(value))
  2434                             values.append(int(value))
  2435                         else:
  2435                         else:
  2436                             values.append(0)
  2436                             values.append(0)
  2437                     if result[-1] is not None:
  2437                     if result[-1] is not None:
  2438                         values.append(int(float(result[-1]) * 1000))
  2438                         values.append(int(float(result[-1]) * 1000))
  2439                     new_task.setinterval(time(*values))
  2439                     new_task.setinterval(datetime.time(*values))
  2440                 new_task.setpriority(int(task["Priority"]))
  2440                 new_task.setpriority(int(task["Priority"]))
  2441                 if task["Name"] != "":
  2441                 if task["Name"] != "":
  2442                     task_list[task["Name"]] = new_task
  2442                     task_list[task["Name"]] = new_task
  2443                 resource.appendtask(new_task)
  2443                 resource.appendtask(new_task)
  2444             for instance in instances:
  2444             for instance in instances:
  2524     def SaveXMLFile(self, filepath = None):
  2524     def SaveXMLFile(self, filepath = None):
  2525         if not filepath and self.FilePath == "":
  2525         if not filepath and self.FilePath == "":
  2526             return False
  2526             return False
  2527         else:
  2527         else:
  2528             contentheader = self.Project.getcontentHeader()
  2528             contentheader = self.Project.getcontentHeader()
  2529             contentheader["modificationDateTime"] = datetime(*localtime()[:6])
  2529             contentheader["modificationDateTime"] = datetime.datetime(*localtime()[:6])
  2530             self.Project.setcontentHeader(contentheader)
  2530             self.Project.setcontentHeader(contentheader)
  2531             
  2531             
  2532             text = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
  2532             text = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
  2533             extras = {"xmlns" : "http://www.plcopen.org/xml/tc6.xsd",
  2533             extras = {"xmlns" : "http://www.plcopen.org/xml/tc6.xsd",
  2534                       "xmlns:xhtml" : "http://www.w3.org/1999/xhtml",
  2534                       "xmlns:xhtml" : "http://www.w3.org/1999/xhtml",