diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2015-04-02 11:44:48 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2015-04-02 11:44:48 (GMT) |
commit | 81aa1c79dd158aa7bc76876552e4b1d05ecea656 (patch) | |
tree | 4b590410d4042c156cfd3d4e874f3a329390a72b /src/bindings/swig/php/test.php | |
parent | ff86d690dc02d7dd495000331d378e7d8eb688ac (diff) | |
download | uscxml-81aa1c79dd158aa7bc76876552e4b1d05ecea656.zip uscxml-81aa1c79dd158aa7bc76876552e4b1d05ecea656.tar.gz uscxml-81aa1c79dd158aa7bc76876552e4b1d05ecea656.tar.bz2 |
Reactivated PHP bindings and some work on PROMELA
Diffstat (limited to 'src/bindings/swig/php/test.php')
-rw-r--r-- | src/bindings/swig/php/test.php | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/bindings/swig/php/test.php b/src/bindings/swig/php/test.php new file mode 100644 index 0000000..739c6a1 --- /dev/null +++ b/src/bindings/swig/php/test.php @@ -0,0 +1,85 @@ +<?php + +require_once('uscxmlNativePHP.php'); + +// $exts = get_loaded_extensions(); +// foreach ($exts as $e) +// { +// echo "Name: ".$e." --"; +// print_r(get_extension_funcs($e)); +// } + +class MyMonitor extends InterpreterMonitor { + function beforeExitingStates($interpreter,$statesToExit) { + print "MyMonitor.beforeExitingStates()\n"; + } + function afterExitingStates($interpreter) { + print "MyMonitor.afterExitingStates()\n"; + } + function beforeEnteringStates($interpreter,$statesToEnter) { + print "MyMonitor.beforeEnteringStates()\n"; + } + function afterEnteringStates($interpreter) { + print "MyMonitor.afterEnteringStates()\n"; + } + function onStableConfiguration($interpreter) { + print "MyMonitor.onStableConfiguration()\n"; + } + function beforeCompletion($interpreter) { + print "MyMonitor.beforeCompletion()\n"; + } + function afterCompletion($interpreter) { + print "MyMonitor.afterCompletion()\n"; + } + function beforeMicroStep($interpreter) { + print "MyMonitor.beforeMicroStep()\n"; + } + function afterMicroStep($interpreter) { + print "MyMonitor.afterMicroStep()\n"; + } + function beforeTakingTransitions($interpreter,$transitions) { + print "MyMonitor.beforeTakingTransitions()\n"; + } +} + +$monitor = new MyMonitor(); + +// run interpreter in blocking mode +$interpreter = Interpreter::fromURL('https://raw.githubusercontent.com/tklab-tud/uscxml/master/test/uscxml/test-invoked.scxml'); +$interpreter->addMonitor($monitor); +$interpreter->interpret(); + +// interleave interpreter execution with this thread +$interpreter = Interpreter::fromURL('https://raw.githubusercontent.com/tklab-tud/uscxml/master/test/uscxml/test-invoked.scxml'); +$parentQueue = new ParentQueue(); +$interpreter->setParentQueue($parentQueue); + +while($interpreter->step() > 0) { + $event = $parentQueue->pop(); + print("Name: " . $event->getName() . "\n"); + print("Type: " . $event->getType() . "\n"); + print("Origin: " . $event->getOrigin() . "\n"); + print("OriginType: " . $event->getOriginType() . "\n"); + print("Content " . strlen($event->getContent()) . " bytes: \n'" . $event->getContent() . "'\n"); + + $namelist = $event->getNameList(); + print("Namelist ".$namelist->size()." elements: \n"); + $keys = $event->getNameListKeys(); + for ($i = 0; $i < $keys->size(); $i++) { + print($keys->get($i) . "\t" . Data::toJSON($namelist->get($keys->get($i))) . "\n"); + } + + $params = $event->getParamMap(); + print("Params ". $params->size() ." elements: \n"); + $keys = $event->getParamMapKeys(); + for ($i = 0; $i < $keys->size(); $i++) { + print($keys->get($i)."\n"); + $paramList = $params->get($keys->get($i)); + for ($j = 0; $j < $paramList->size(); $j++) { + print("\t" . Data::toJSON($paramList->get($i)) . "\n"); + } + } + +} + +?>
\ No newline at end of file |