Browse Source

Merge branch 'master' of https://msdl.uantwerpen.be/git/bentley/AToMPM

Bentley James Oakes 6 years ago
parent
commit
80600da0d7
5 changed files with 25 additions and 54 deletions
  1. 1 1
      client/constants.js
  2. 2 0
      mt/main.py
  3. 0 21
      mt/ptcal/accurate_time.py
  4. 1 4
      mt/ptcal/motifcontext.py
  5. 21 28
      mt/ptcal/ptcal.py

+ 1 - 1
client/constants.js

@@ -6,7 +6,7 @@
 /****************************** GLOBAL CONSTANTS ******************************/
 var __WEBPAGE__ = 'https://atompm.github.io/',
 	__RELEASE_LOC__ = "https://api.github.com/repos/AToMPM/atompm/releases/latest",
-	__DOC_WEBPAGE__ = "https://msdl.uantwerpen.be/documentation/AToMPM/index.html",
+	__DOC_WEBPAGE__ = "https://atompm.readthedocs.io/en/latest/",
     __VERSION__ = '0.8.5',
     __DEFAULT_SAVEAS		 	= '.autosave.model',
 	 __TITLE						= 'AToMPM',

+ 2 - 0
mt/main.py

@@ -11,6 +11,8 @@ from httpd import HTTPServerThread
 '''
 def main() :
 	logging.basicConfig(format='%(levelname)s - %(message)s', level=logging.INFO)
+
+	print("Starting Model Transformation Server... ")
 	httpd = HTTPServerThread()
 	httpd.start()
 

+ 0 - 21
mt/ptcal/accurate_time.py

@@ -1,21 +0,0 @@
-'''This file is part of AToMPM - A Tool for Multi-Paradigm Modelling
-Copyright 2011 by the AToMPM team and licensed under the LGPL
-See COPYING.lesser and README.md in the root of this project for full details'''
-
-import time as t
-import os
-
-global start_time
-def set_start_time():
-    global start_time
-    if os.name == 'posix':
-        start_time = t.time()
-    elif os.name == 'nt':
-        start_time = t.clock()
-
-if os.name == 'posix':
-    def time():
-        return int((t.time() - start_time) * 1000)
-elif os.name == 'nt':
-    def time():
-        return int((t.clock() - start_time) * 1000)

+ 1 - 4
mt/ptcal/motifcontext.py

@@ -8,11 +8,8 @@ Author: Huseyin Ergin (hergin)
 Purpose: MoTif integration to AtomPM
 '''
 
-import random
 import collections
-import datetime
 from time import *
-import timeit
 from .tconstants import TConstants as TC
 from .utils import Utilities as utils
 from .tcontext import TransformationContext
@@ -327,7 +324,7 @@ class MotifContext(TransformationContext) :
 			
 			'''
 	def nextStep(self) :
-		timeNextStep = clock()
+		#timeNextStep = clock()
 		if self._expired == True :
 			raise RuntimeError('can not step in expired mtContext')
 		elif self._lastStep == {} :

+ 21 - 28
mt/ptcal/ptcal.py

@@ -2,7 +2,7 @@
 Copyright 2011 by the AToMPM team and licensed under the LGPL
 See COPYING.lesser and README.md in the root of this project for full details'''
 
-import re, json, uuid, threading, itertools, traceback, logging, sys
+import re, json, uuid, threading, itertools, traceback, logging, sys, time, os
 
 if sys.version_info[0] < 3:
     import cPickle as pickle
@@ -14,7 +14,7 @@ else:
     import io as StringIO
     from queue import *
 
-from random import Random
+#from random import Random
 from .utils import Utilities as utils
 from .tcontext import ModelTransformationContext, ExhaustContext
 from .tconstants import TConstants as TC
@@ -22,11 +22,8 @@ from .compiler import ModelAndRuleCompiler
 from .pytcore.core.himesis import HConstants as HC
 from .pytcore.rules.ndarule import NDARule
 from .pytcore.tcore.messages import Packet
-from .accurate_time import time as clock
-from .accurate_time import set_start_time
-set_start_time()
 
-import cProfile, pstats
+#import cProfile, pstats
 
 ''' hergin :: motif-integration start '''
 from .motifcontext import MotifContext
@@ -36,19 +33,16 @@ from .pytcore.tcore.messages import Pivots
 
 import igraph as ig
 #import pydot
-import datetime
+#import datetime
 from random import *
-from threading import *
+#from threading import *
 
-from .barrier import *
+#from .barrier import *
 from .synchgraph import *
-from itertools import *
 #from petrinet import *
 
-from pprint import isreadable
-from math import *
-
-import os
+#from pprint import isreadable
+#from math import *
 
 ''' 
     py-t-core abstraction layer 
@@ -103,6 +97,8 @@ class PyTCoreAbstractionLayer :
         self.defaultDCL                 = TC.PYTHON
         self._mtwid                 = mtwid
 
+        self.start_time = time.time()
+        self.clock = None
 
         ''' Used only in COMP 522 and comp 621
         Petri Net Modules, docomposition of disconnected
@@ -717,7 +713,7 @@ class PyTCoreAbstractionLayer :
                 seconds '''
     def play(self) :
 
-        self.start_time = clock()
+        self.start_time = time.time()
         if self._execmode == 'STOPPED':
             self._randomGen = Random(0)
         if self._execmode != 'PLAY' :
@@ -979,8 +975,7 @@ class PyTCoreAbstractionLayer :
         NOTE: this function assumes that feedback for the last step has already
                 been received '''
     def step(self) :
-        if not hasattr(self, 'start_time'):
-            self.start_time = clock()
+        self.start_time = time.time()
         if self._execmode == 'PLAY' :
             pass
         else :
@@ -1005,27 +1000,22 @@ class PyTCoreAbstractionLayer :
             else:
                 ar = NDARule(r['cr']['lhs'],r['cr']['rhs'],rng=self._randomGen,sendAndApplyDeltaFunc=self.sendAndApplyDelta)
 
+            startTime = time.time()
             if mtc.nextInput == "packetIn":
-                startTime=clock()
-
                 self.packet = ar.packet_in(self.packet)
-
-                mtc.setLastStepExecTime(clock()-startTime)
+                mtc.setLastStepExecTime(time.time()-startTime)
 
             elif mtc.nextInput == "nextIn":
-                startTime=clock()
                 self.packet = ar.next_in(self.packet)
-                mtc.setLastStepExecTime(clock()-startTime)
+                mtc.setLastStepExecTime(time.time()-startTime)
 
             elif mtc.nextInput == "cancelIn":
-                startTime=clock()
                 self.packet = ar.cancelIn(self.packet)
-                mtc.setLastStepExecTime(clock()-startTime)
+                mtc.setLastStepExecTime(time.time()-startTime)
 
             elif mtc.nextInput == "successIn":
-                startTime=clock()
                 self.packet = ar.success_in(self.packet)
-                mtc.setLastStepExecTime(clock()-startTime)
+                mtc.setLastStepExecTime(time.time()-startTime)
 
             ''' hergin :: motif-integration end '''
 
@@ -1043,6 +1033,7 @@ class PyTCoreAbstractionLayer :
         try :
             nr = self._nextRule()
         except Exception :
+            print(traceback.format_exc())
             nr = {'$err':traceback.format_exc()}
 
         ''' hergin :: motif-integration start TRAFO RESULT: in case of a CRule_end, pop it from context and continue the rest '''
@@ -1060,7 +1051,9 @@ class PyTCoreAbstractionLayer :
                         return
                     self._handleChangelogs()
 
-                self._aswPrintReq(TC.TRANSFORMATION_DONE+nr['trafoResult']+" in "+str(self._mtContexts[-1].totalExecutionTime/1000.0)+" seconds, in total "+str((clock()-self.start_time)/1000.0))
+                exec_time = self._mtContexts[-1].totalExecutionTime/1000.0
+                total_time = (time.time()-self.start_time)/1000.0
+                self._aswPrintReq(TC.TRANSFORMATION_DONE+nr['trafoResult']+" in "+str(exec_time)+" seconds, in total "+str(total_time))
                 self.stop()
                 return
             else: