Initial commit

This commit is contained in:
Yentl Van Tendeloo 2016-08-04 17:38:43 +02:00
commit 66a6860316
407 changed files with 1254365 additions and 0 deletions

1
test/.cache/v/cache/lastfailed vendored Normal file
View file

@ -0,0 +1 @@
{}

25
test/CMakeLists.txt Normal file
View file

@ -0,0 +1,25 @@
add_custom_target(basic_tests
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${PYTHON_EXECUTABLE} "test_basic.py")
add_custom_target(mpi_tests
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${PYTHON_EXECUTABLE} "test_mpi.py")
add_custom_target(realtime_tests
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${PYTHON_EXECUTABLE} "test_realtime.py")
SET(DART_TESTING_TIMEOUT 1000)
add_test(NAME Basics
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${PYTHON_EXECUTABLE} "test_basic.py")
add_test(NAME MPI
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${PYTHON_EXECUTABLE} "test_mpi.py")
add_test(NAME Realtime
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${PYTHON_EXECUTABLE} "test_realtime.py")
set_tests_properties(Basics PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED")
set_tests_properties(MPI PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED")
set_tests_properties(Realtime PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED")

15
test/__init__.py Normal file
View file

@ -0,0 +1,15 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

741
test/activity-log Normal file
View file

@ -0,0 +1,741 @@
2 0
2 0
2 0
2 0
2 0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
81.5 0.000102500974035 5.95315102419e-06 7.65162742942e-05
238.5 0.0001028657749 5.59415248846e-06 7.20182001985e-05
378.5 0.000106811523438 5.86250955744e-06 7.56710998772e-05
546.5 0.000102061580345 6.19427593434e-06 7.12076822917e-05
726.0 0.000112041046745 5.93693632829e-06 7.41654320767e-05
867.0 0.00010317839109 5.50930316632e-06 7.43902646578e-05
1083.0 0.000101365000996 5.84914984293e-06 6.85595518706e-05
1389.0 0.000100553420282 6.05275554042e-06 6.78939204062e-05
1692.0 0.000100950937013 6.06275893546e-06 6.8682271081e-05
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
74.5 0.000113141616719 6.17168093688e-06 7.56698966826e-05
210.5 0.000101013881404 5.74918297248e-06 7.4136547926e-05
349.5 0.0001045796179 6.13581749701e-06 7.32667984501e-05
589.5 0.000104393592248 6.02428729718e-06 6.58761537992e-05
784.0 0.000137247145176 6.03869557381e-06 4.38801944256e-05
862.0 0.000135439893474 6.43211862315e-06 4.24929287123e-05
948.5 0.000130014655031 6.69926772883e-06 4.23089957532e-05
1015.0 0.000124087700477 6.69406010554e-06 4.59230863131e-05
1236.0 9.88104404547e-05 6.00692553398e-06 6.46737905649e-05
1686.5 0.000101012959639 6.29219756901e-06 6.33082977713e-05
inf 0.0 0.0 0.0
57.0 0.000150900138052 0.0 3.21321320115e-05
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
152.0 0.000191749710786 9.53595889242e-06 0.000136069561306
463.0 0.000191104487053 9.25558917927e-06 0.000133018073796
807.0 0.000189539548513 9.29574708681e-06 0.000132929956591
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
150.5 0.00019376856148 9.08446074324e-06 0.000137980990236
460.0 0.000187588187883 8.96768749885e-06 0.000132952096327
802.5 0.000192140038722 9.41785869546e-06 0.000133948365089
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
152.0 0.00019040468492 8.97912602676e-06 0.000137120485306
463.0 0.000189131910696 8.82373665864e-06 0.000132044156392
807.0 0.000189497664168 9.30799020303e-06 0.000132230165842
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
147.0 0.000191999130509 9.25453341737e-06 0.000138486323713
453.0 0.000187472727314 9.464018e-06 0.000130878304535
797.0 0.000189664557173 9.44137573242e-06 0.000130749393154
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
148.5 0.000196373422539 9.35451751606e-06 0.000135490789959
454.5 0.00019311526465 9.49889894516e-06 0.000131842446706
792.5 0.000195638624915 9.49909812526e-06 0.000133472796622
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
152.5 0.000193619337238 8.89418555088e-06 0.00013650831629
465.5 0.000191851197002 9.18245761194e-06 0.000131064857649
809.5 0.000193078771274 9.18853510303e-06 0.000132652979131
144.5 0.000191446819107 9.54664289745e-06 0.000136310254001
443.5 0.000191719400844 9.82608609987e-06 0.000132691898778
775.5 0.000190095498528 9.82888987367e-06 0.00013648825632
1112.0 0.000204614873202 9.90786642398e-06 0.00014492175864
1443.5 0.000194536430248 9.494587995e-06 0.000137397517329
1778.0 0.000202189257115 9.50657291177e-06 0.000140145972923
inf 0.0 0.0 0.0
142.5 0.000198868701332 9.55096462317e-06 0.000139473195662
437.5 0.000188828296349 1.02215125913e-05 0.000133406529661
766.0 0.000194827941331 9.78058034723e-06 0.000132024288177
1100.0 0.00024184697791 9.61822799489e-06 0.000140514554857
1428.5 0.000196572273008 9.61225403369e-06 0.000136613845825
1758.0 0.000209794104474 9.24809173968e-06 0.00014022386299
144.5 0.00019263643707 9.62749072012e-06 0.000137531221119
444.0 0.000187068600808 9.78592903383e-06 0.00012909904603
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
167.5 0.000165331541602 8.73679545388e-06 0.000112813266356
498.0 0.000174662086861 5.56407530615e-06 0.000118495496504
858.0 0.000173413814022 8.32347095315e-06 0.000120184748306
808.5 0.000179900961407 9.19245057187e-06 0.000120723853677
1114.5 0.000191368139129 7.20445289973e-06 0.000130917371636
1460.5 0.000183731714884 9.44010416667e-06 0.00012086613973
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
148.5 0.000190479586823 8.64167004723e-06 0.000135078173294
454.5 0.000186097432697 8.99708460248e-06 0.000129322021727
792.5 0.000191143014755 9.35446192353e-06 0.000128318068063
757.5 0.000190913472389 9.03204953957e-06 0.000130663213042
1058.0 0.000202746545115 9.64364697856e-06 0.000135667093339
1387.5 0.000194701219357 9.62896811586e-06 0.000131810633706
1727.5 0.000223126656339 9.97900602681e-06 0.000135043596573
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
144.0 0.000190608203411 9.30329163869e-06 0.000134344730112
444.0 0.000185750233821 9.43052463042e-06 0.000129455939317
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
147.5 0.000186079639499 9.15446523893e-06 0.000133973461086
450.0 0.000187248568381 8.92916033345e-06 0.000128482234093
782.5 0.000191873228046 9.0565479977e-06 0.000132253808035
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
153.5 0.000180878934332 8.07905041822e-06 0.000131348445283
472.0 0.000177231701938 8.75935410008e-06 0.000122078259786
827.5 0.000183977167125 1.28470693673e-05 0.00013046189556
786.5 0.000197049367388 8.57350020903e-06 0.000129600831099
1099.0 0.000197067582534 8.86975621885e-06 0.000131785503926
1443.0 0.0001948400097 9.40436157732e-06 0.000133683668316
1794.0 0.000204281245961 8.29416162827e-06 0.000134014382082
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
154.5 0.000184528264413 9.26668975731e-06 0.000131702731728
474.5 0.00018201421755 8.13792479362e-06 0.000124797360054
703.5 0.000245835837417 9.82584915762e-06 7.35061375175e-05
832.0 0.000245648164016 7.97418447641e-06 7.14998978835e-05
961.5 0.000242144562477 9.93041105049e-06 7.35567521679e-05
1183.0 0.000200200232731 8.50638006903e-06 0.000137569798026
1510.5 0.000194841815579 8.56698782912e-06 0.000134475769535
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
152.5 0.000189380958432 8.84493843454e-06 0.000134661158577
460.0 0.000189156686106 8.61921618062e-06 0.000128334568393
805.5 0.000181863314211 9.23825061227e-06 0.000126832426377
763.0 0.000197737603574 8.72241484152e-06 0.000133484601974
1074.0 0.000203134823431 9.1893541301e-06 0.000129792587889
1421.5 0.000187472599309 9.65821387645e-06 0.00012845527835
1775.0 0.000200864831371 9.0133508987e-06 0.000135909876174
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
153.5 0.000182327307785 8.74072022081e-06 0.000130071702143
467.5 0.000180015682803 9.48326609959e-06 0.000128517269717
818.0 0.000181528141624 1.28670742637e-05 0.000126048138267
779.0 0.000197423214944 8.92727580292e-06 0.000128641033804
1092.0 0.000201406302275 9.82078505151e-06 0.000133360609596
1436.5 0.000196874958195 8.77249730776e-06 0.000131387579931
1789.5 0.000203120743424 9.43815952872e-06 0.000136765566739
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
153.5 0.000185161926071 8.70033661783e-06 0.000132677997751
467.0 0.000181886553764 8.84681940079e-06 0.000127840787172
815.5 0.000190525535563 9.49184205235e-06 0.000129524529455
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
150.0 0.000196075439453 9.36110814412e-06 0.000138252576192
457.0 0.000192628544607 9.20113484571e-06 0.000132212972945
794.0 0.000194292598301 9.15394888984e-06 0.000132026937273
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
146.5 0.000193150783968 9.28693257094e-06 0.000137982514938
450.0 0.000194102335887 9.28389798304e-06 0.000132599454017
663.5 0.00025431666754 9.30887407961e-06 7.75303460855e-05
777.5 0.000253722978675 9.48905944824e-06 7.49981921652e-05
894.5 0.000263043812343 8.98176882447e-06 7.57089182108e-05
1014.5 0.000258307811642 8.99882355997e-06 7.55570151589e-05
1230.5 0.000202247950808 9.29219163116e-06 0.000138151683991
1545.5 0.00020738978371 9.21162691983e-06 0.000139706560811
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
151.0 0.000181429433507 8.38649193972e-06 0.00012685131553
456.0 0.000191724145567 7.98082970954e-06 0.000128645401496
788.0 0.000200795993376 8.98154933801e-06 0.000131528698996
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
149.0 0.000197436985554 9.07590725278e-06 0.000135036922941
456.0 0.000186170958265 9.32246823854e-06 0.000129852113844
674.0 0.000248579184214 9.61422920227e-06 7.08599885305e-05
792.0 0.00025474203044 9.60867980431e-06 7.08945866289e-05
908.5 0.000255195503561 9.24534267849e-06 7.39668169592e-05
1027.0 0.000254855553309 9.66389973958e-06 7.204413414e-05
1238.0 0.000210632551585 9.08753729814e-06 0.000138863822482
1549.0 0.000207013636827 9.17613506317e-06 0.000138025730848
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
144.5 0.000200485275691 9.71163845392e-06 0.000137198755073
444.5 0.000188384408736 9.30829063489e-06 0.000129642210589
778.5 0.000195024394188 9.48665522728e-06 0.000131865509418
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
147.0 0.00019494205916 8.79715900032e-06 0.000134751099308
450.5 0.000189908396322 9.40420376226e-06 0.000130726506535
668.5 0.000250959784035 9.88371003934e-06 7.25044467585e-05
788.5 0.000259303639078 9.28406022553e-06 7.40992717254e-05
911.5 0.000239364860594 9.09871833269e-06 6.59070273702e-05
1038.0 0.000258432280633 9.22333809637e-06 7.36482681767e-05
1252.0 0.000210871821956 9.20185917302e-06 0.000141174385422
1564.5 0.000211989768198 9.18171487493e-06 0.000138648945223
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
144.5 0.000195387737974 9.08878022824e-06 0.000136782141293
443.5 0.000195663723745 9.41020385347e-06 0.000131285306319
776.5 0.000197785909102 9.46060950015e-06 0.000130560551705
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
149.0 0.000187344999121 8.79588543169e-06 0.000133957638837
457.5 0.000185334944052 8.99712493801e-06 0.000128142138634
805.5 0.000184172344461 8.98528162301e-06 0.00012521528755
1149.0 0.000200398506657 8.7276581795e-06 0.000157877706712
1466.5 0.000191444983849 8.81121708797e-06 0.000152314259456
1783.0 0.000203008001501 8.94998575186e-06 0.000156525667612
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
147.0 0.000193050118531 9.2448020468e-06 0.000139563262057
417.0 0.000177219631226 9.19752973851e-06 0.000237246839012
715.5 0.000187481910075 9.4837612576e-06 0.000145778357134
1044.5 0.000232062044672 1.09936593022e-05 0.000157478189624
1373.0 0.000186852727618 1.02281570435e-05 0.000146989822388
1700.5 0.000205133782058 1.03770709429e-05 0.00015848191058
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
144.0 0.000194965137376 9.45809814665e-06 0.000133927497599
441.0 0.000192583775988 9.06769746269e-06 0.000131085028056
773.0 0.000197876765075 9.24238279545e-06 0.000130949073664
737.0 0.000194202769886 9.62010630361e-06 0.000132794980403
1035.5 0.000195589862836 9.32592287708e-06 0.000135575843394
1364.5 0.000195500486522 9.48589885613e-06 0.000136029823369
1699.5 0.000204918185255 9.32194500147e-06 0.000137833987965
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
146.5 0.00019367888519 9.51802771246e-06 0.000138664408349
447.5 0.000189112228097 9.57840854682e-06 0.000133512089553
780.0 0.000194132328033 9.51129398989e-06 0.000133205665631
744.5 0.000199754614579 9.56016674376e-06 0.000136420601293
1039.0 0.000206562249284 9.37439893421e-06 0.000137097741428
1361.0 0.000197611836826 9.19804853552e-06 0.000136721134186
1689.0 0.000214893606645 9.66274285618e-06 0.0001403930821
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
146.5 0.000193943342658 9.48222423983e-06 0.000138086670495
448.0 0.000190992509165 9.37446471184e-06 0.00013060492854
781.5 0.000198639407545 9.63291200269e-06 0.000131639111944
743.0 0.000203924519675 9.67809132167e-06 0.000149425438472
1036.0 0.000201935861625 9.85463460286e-06 0.000144994336795
1362.0 0.000199489510817 9.5629278635e-06 0.000145890809208
1694.0 0.000214286570279 9.72043043413e-06 0.00014879418619
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
149.5 0.000198252623695 9.42191950055e-06 0.000136524538531
456.0 0.000190588319378 9.25808195855e-06 0.000129821194205
794.0 0.000199524737195 9.18701867372e-06 0.000129743175612
760.5 0.000201874264216 9.53755136264e-06 0.000142890315945
1067.0 0.000206105364194 9.50150519797e-06 0.000146956563746
1403.0 0.000200037228859 9.81624517064e-06 0.00014599703126
1746.0 0.000209197940597 9.59491155234e-06 0.00015123134636
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
156.5 0.000175572812748 7.67357433185e-06 0.000122834318362
472.5 0.000183333423818 8.11669520076e-06 0.000125959001738
696.0 0.00026011094451 8.32602381706e-06 7.48354941607e-05
822.5 0.000253940582275 9.37652587891e-06 7.32936859131e-05
949.5 0.000244332838428 9.03403112131e-06 7.07622646361e-05
1176.5 0.000189105547391 8.83395855243e-06 0.000129944727971
1510.0 0.000194003707484 9.00134705661e-06 0.000132797754299
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
2 0
2 0
2 0
2 0
2 0
2 0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
149.5 0.000194066344296 8.9841542834e-06 0.000134589281369
457.5 0.000186541103038 9.02154844266e-06 0.000128089441486
765.5 0.000196185797752 9.04953998068e-06 0.000131398937774
1073.0 0.000199681595911 8.93767875961e-06 0.000135696386989
1410.0 0.000198428191286 9.188438927e-06 0.000133617630218
1758.0 0.000209872539227 9.21156279434e-06 0.000138523310599
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
1381.0 0.000200162728628 9.02652740479e-06 0.000132053693136
1696.5 0.000211995894095 9.00300247792e-06 0.00013647338775
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
1381.5 0.00020024150709 9.27297775928e-06 0.000132804693178
1694.5 0.000211540368887 9.24550569974e-06 0.000139130812425
1380.5 0.00019864015356 9.03518702274e-06 0.000134646693201
1693.5 0.000210371221607 9.09563233728e-06 0.000137924783456
inf 0.0 0.0 0.0
151.5 0.000190203732783 9.25189984514e-06 0.000131363129065
465.5 0.00018196619474 9.31593088003e-06 0.000122516338642
824.0 0.000179689149467 9.17181676748e-06 0.00012467406234
776.0 0.000195452490368 9.12273252333e-06 0.00013065660322
1080.0 0.000203559031853 9.20509680724e-06 0.000136193556663
1413.0 0.000198467303131 9.08819295592e-06 0.000134328664359
1755.5 0.000206114662378 9.44814653195e-06 0.000138210025799
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
147.5 0.000194498644037 9.39530841375e-06 0.000133327710426
153.5 0.000196095009968 9.20901469377e-06 0.000132346386242
467.5 0.000185762981759 9.60061854663e-06 0.000127195197845
814.5 0.000191072995797 9.25485953569e-06 0.000128241071113
1169.0 0.000203963546526 9.50835999988e-06 0.000136870713461
1515.5 0.000198372271882 9.3023316199e-06 0.000133625265597
inf 0.0 0.0 0.0
1486.5 0.000203760172611 9.48650781128e-06 0.000134224078328
1799.5 0.000215989004946 9.46966515404e-06 0.00013604368274
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
153.0 0.000191291952445 9.22508489073e-06 0.000131578227274
467.5 0.000184360303377 9.34999424607e-06 0.000127055696659
814.0 0.000190894668167 9.40400200921e-06 0.000129795718837
777.5 0.000193504372028 8.92424021506e-06 0.000130453495064
1079.0 0.0002034294839 9.78684892841e-06 0.000137092241275
1405.5 0.00019645828335 9.55941697706e-06 0.000136501850931
1739.5 0.000211449055657 9.7454522629e-06 0.000140271825582
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
152.5 0.000189097201238 8.81914232598e-06 0.000135528845865
151.0 0.000190949597896 9.21306231164e-06 0.000135537804357
462.0 0.000180646777153 9.65595245361e-06 0.000127884745598
793.5 0.000197842239291 9.14540304734e-06 0.000133634656233
1132.5 0.000201008924797 9.34173811727e-06 0.000136668646514
1473.0 0.000200795300434 9.89643824583e-06 0.000136166638722
1811.5 0.000200447359114 9.76723846712e-06 0.000136509402641
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
150.5 0.000192171711462 9.2206999313e-06 0.00013450689094
461.5 0.000185649342997 9.19211319302e-06 0.000127969129806
792.5 0.000199648641771 9.31300725406e-06 0.000137201851764
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
152.0 0.000197805856404 8.93442254317e-06 0.000133177167491
462.5 0.000189165211626 9.38406502035e-06 0.000127154569897
793.0 0.000200907851374 9.27891842155e-06 0.000135902748551
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
768.5 0.000194888195749 8.88614331262e-06 0.000134273302757
1073.5 0.000201911018008 9.1484614781e-06 0.000136695589338
1401.0 0.000201955963584 8.89862284941e-06 0.000137496695799
1380.5 0.000198294885182 9.35493903017e-06 0.000147455113389
1695.5 0.000207705800267 9.24430224831e-06 0.000148088910428
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
154.0 0.000181300299508 8.39651405037e-06 0.000126242637634
467.0 0.000193994000273 8.67603709863e-06 0.000129339080187
687.0 0.000249516768534 8.26648024262e-06 7.53324539935e-05
805.5 0.000253774808801 8.74685204547e-06 7.58544258449e-05
924.0 0.000243851395904 8.67101012683e-06 6.9583048586e-05
1046.0 0.00025294061567 9.70480871982e-06 7.31378305154e-05
1260.5 0.000210187334191 8.94496805893e-06 0.000139785511874
1587.5 0.000186608916401 9.66041850769e-06 0.00012873091684
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
151.5 0.000190458675422 9.38015802465e-06 0.000133982585995
464.0 0.000191708529218 9.3146140531e-06 0.000127021570383
796.0 0.000196051179317 9.67965488545e-06 0.000135351342765
776.0 0.000194745347989 9.31490336033e-06 0.000130662854934
1086.5 0.000198480851224 9.00310408733e-06 0.000133640713826
1415.5 0.000203363311678 8.9923892401e-06 0.000135313444785
1753.0 0.000208585035233 9.29832458496e-06 0.000134816481954
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
151.5 0.000199360422569 9.13387084558e-06 0.00013278970624
464.0 0.000189626439018 9.20873251021e-06 0.000126638767882
682.5 0.000252143196438 9.16356625764e-06 7.38040260647e-05
803.0 0.000256328355698 9.63324592227e-06 7.23051646399e-05
929.0 0.000247115180606 9.15451655312e-06 7.14858373006e-05
1054.5 0.000257724761963 9.0446472168e-06 7.15599060059e-05
1270.5 0.000210186557583 9.73167170919e-06 0.000139239556626
1591.0 0.000203113356036 9.79871806984e-06 0.000136118449137
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
2 0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
234.5 0.000126669910162 7.38487569e-06 9.62031675554e-05
716.0 0.000137387017007 7.49377586581e-06 9.673664927e-05
1220.5 0.000143685850125 7.29607146921e-06 9.94844344056e-05
1724.5 0.000147454878863 7.26765599744e-06 0.000102257873659
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
239.0 0.000126253112091 7.52614631812e-06 9.46831004889e-05
720.0 0.00014772198417 7.50673703911e-06 9.83466786787e-05
1059.5 0.000168904280051 7.50835125263e-06 5.34974611723e-05
1387.5 0.000148538395019 7.42459245462e-06 0.000102055564103
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
2 0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
239.5 0.000123176793714 7.08536215764e-06 9.41857913342e-05
723.0 0.000144140642197 7.26052972137e-06 9.78722924092e-05
1226.0 0.000140723114308 7.21883589697e-06 9.9017813399e-05
1734.0 0.000146881164796 7.37038960897e-06 0.000101308746031
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
231.0 0.00013032052424 7.40129710276e-06 9.57472499831e-05
695.0 0.000147495146985 7.45748757293e-06 9.98288265114e-05
1022.5 0.000178861870337 7.49946271301e-06 5.3846016132e-05
1337.5 0.000158902468865 7.46179870467e-06 0.000103753169918
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0
inf 0.0 0.0 0.0

512
test/devstrace.vcd Normal file
View file

@ -0,0 +1,512 @@
$date
2016-04-25
$end
$version
PyDEVS VCD export
$end
$comment
Generated from DEVS-code
$end
$timescale 1ns $end
$scope Binary.CoupledGenerator.Generator Binary.CoupledGenerator.Generator $end
$var wire 1 0 outport $end
$var wire 1 1 inport $end
$upscope $end
$scope Binary.CoupledProcessor_2.Processor0 Binary.CoupledProcessor_2.Processor0 $end
$var wire 1 2 inport $end
$var wire 1 3 outport $end
$upscope $end
$scope Binary.CoupledProcessor_2.Processor1 Binary.CoupledProcessor_2.Processor1 $end
$var wire 1 4 inport $end
$var wire 1 5 outport $end
$upscope $end
$scope Binary.CoupledProcessor_3.Processor0 Binary.CoupledProcessor_3.Processor0 $end
$var wire 1 6 inport $end
$var wire 1 7 outport $end
$upscope $end
$scope Binary.CoupledProcessor_3.Processor1 Binary.CoupledProcessor_3.Processor1 $end
$var wire 1 8 inport $end
$var wire 1 9 outport $end
$upscope $end
$scope Binary.CoupledProcessor_3.Processor2 Binary.CoupledProcessor_3.Processor2 $end
$var wire 1 10 inport $end
$var wire 1 11 outport $end
$upscope $end
$enddefinitions $end
$dumpvars
bz 0
bz 1
bz 2
bz 3
bz 4
bz 5
bz 6
bz 7
bz 8
bz 9
bz 10
bz 11
$end
b1 0
#10
b1 2
b1 3
b1 4
b1 0
#20
b1 2
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#30
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#40
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#50
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#60
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#70
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#80
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#90
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#100
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#110
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#120
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#130
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#140
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#150
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#160
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#170
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#180
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#190
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#200
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#210
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#220
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#230
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#240
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#250
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#260
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#270
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#280
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#290
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#300
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#310
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#320
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#330
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#340
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#350
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#360
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#370
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#380
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#390
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#400
b1 2

4704
test/devstrace.xml Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,53 @@
digraph G {
subgraph "clusterChain" {
label = "Chain"
color=black
subgraph "clusterChain.CoupledGenerator" {
label = "CoupledGenerator"
color=black
"Chain.CoupledGenerator.Generator" [
label = "Generator\nState: 1.0"
color="green"
style=filled
]
}
subgraph "clusterChain.CoupledProcessor_2" {
label = "CoupledProcessor_2"
color=black
"Chain.CoupledProcessor_2.Processor0" [
label = "Processor0\nState: inf"
color="blue"
style=filled
]
"Chain.CoupledProcessor_2.Processor1" [
label = "Processor1\nState: inf"
color="blue"
style=filled
]
}
subgraph "clusterChain.CoupledProcessor_3" {
label = "CoupledProcessor_3"
color=black
"Chain.CoupledProcessor_3.Processor0" [
label = "Processor0\nState: inf"
color="red"
style=filled
]
"Chain.CoupledProcessor_3.Processor1" [
label = "Processor1\nState: inf"
color="red"
style=filled
]
"Chain.CoupledProcessor_3.Processor2" [
label = "Processor2\nState: inf"
color="red"
style=filled
]
}
}
"Chain.CoupledGenerator.Generator" -> "Chain.CoupledProcessor_2.Processor0" [label="outport -> inport"];
"Chain.CoupledProcessor_2.Processor0" -> "Chain.CoupledProcessor_2.Processor1" [label="outport -> inport"];
"Chain.CoupledProcessor_2.Processor1" -> "Chain.CoupledProcessor_3.Processor0" [label="outport -> inport"];
"Chain.CoupledProcessor_3.Processor0" -> "Chain.CoupledProcessor_3.Processor1" [label="outport -> inport"];
"Chain.CoupledProcessor_3.Processor1" -> "Chain.CoupledProcessor_3.Processor2" [label="outport -> inport"];
}

529867
test/expected/allocate Normal file

File diff suppressed because it is too large Load diff

448
test/expected/atomic Normal file
View file

@ -0,0 +1,448 @@
__ Current Time: 0.00 __________________________________________
INITIAL CONDITIONS in model <Generator>
Initial State: 1.0
Next scheduled internal transition at time 1.00
__ Current Time: 1.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 2.00
__ Current Time: 2.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 3.00
__ Current Time: 3.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 4.00
__ Current Time: 4.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 5.00
__ Current Time: 5.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 6.00
__ Current Time: 6.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 7.00
__ Current Time: 7.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 8.00
__ Current Time: 8.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 9.00
__ Current Time: 9.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 10.00
__ Current Time: 10.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 11.00
__ Current Time: 11.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 12.00
__ Current Time: 12.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 13.00
__ Current Time: 13.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 14.00
__ Current Time: 14.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 15.00
__ Current Time: 15.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 16.00
__ Current Time: 16.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 17.00
__ Current Time: 17.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 18.00
__ Current Time: 18.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 19.00
__ Current Time: 19.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 20.00
__ Current Time: 20.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 21.00
__ Current Time: 21.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 22.00
__ Current Time: 22.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 23.00
__ Current Time: 23.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 24.00
__ Current Time: 24.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 25.00
__ Current Time: 25.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 26.00
__ Current Time: 26.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 27.00
__ Current Time: 27.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 28.00
__ Current Time: 28.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 29.00
__ Current Time: 29.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 30.00
__ Current Time: 30.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 31.00
__ Current Time: 31.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 32.00
__ Current Time: 32.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 33.00
__ Current Time: 33.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 34.00
__ Current Time: 34.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 35.00
__ Current Time: 35.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 36.00
__ Current Time: 36.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 37.00
__ Current Time: 37.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 38.00
__ Current Time: 38.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 39.00
__ Current Time: 39.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 40.00
__ Current Time: 40.00 __________________________________________
INTERNAL TRANSITION in model <Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 41.00

4107
test/expected/auto_allocate Normal file

File diff suppressed because it is too large Load diff

25273
test/expected/autodist Normal file

File diff suppressed because it is too large Load diff

211803
test/expected/checkpoint Normal file

File diff suppressed because it is too large Load diff

14987
test/expected/classicDEVS Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,169 @@
__ Current Time: 0.00 __________________________________________
INITIAL CONDITIONS in model <Root.Coupled.P1>
Initial State: None
Next scheduled internal transition at time inf
INITIAL CONDITIONS in model <Root.Coupled.P1>
Initial State: None
Next scheduled internal transition at time inf
INITIAL CONDITIONS in model <Root.Gen>
Initial State: True
Next scheduled internal transition at time 1.00
INITIAL CONDITIONS in model <Root.P1>
Initial State: None
Next scheduled internal transition at time inf
INITIAL CONDITIONS in model <Root.P2>
Initial State: (None, None)
Next scheduled internal transition at time inf
INITIAL CONDITIONS in model <Root.PO2>
Initial State: None
Next scheduled internal transition at time inf
__ Current Time: 1.00 __________________________________________
EXTERNAL TRANSITION in model <Root.Coupled.P1>
Input Port Configuration:
port <inport>:
3
New State: 3
Next scheduled internal transition at time 2.00
EXTERNAL TRANSITION in model <Root.Coupled.P1>
Input Port Configuration:
port <inport>:
3
New State: 3
Next scheduled internal transition at time 2.00
INTERNAL TRANSITION in model <Root.Gen>
New State: False
Output Port Configuration:
port <outport>:
3
Next scheduled internal transition at time inf
__ Current Time: 2.00 __________________________________________
EXTERNAL TRANSITION in model <Root.P1>
Input Port Configuration:
port <inport>:
3
New State: 3
Next scheduled internal transition at time 3.00
EXTERNAL TRANSITION in model <Root.P2>
Input Port Configuration:
port <inport1>:
3
port <inport2>:
3
New State: (3, 3)
Next scheduled internal transition at time 3.00
INTERNAL TRANSITION in model <Root.Coupled.P1>
New State: None
Output Port Configuration:
port <outport>:
3
Next scheduled internal transition at time inf
__ Current Time: 2.00 __________________________________________
EXTERNAL TRANSITION in model <Root.P1>
Input Port Configuration:
port <inport>:
3
New State: 3
Next scheduled internal transition at time 3.00
EXTERNAL TRANSITION in model <Root.P2>
Input Port Configuration:
port <inport1>:
3
port <inport2>:
3
New State: (3, 3)
Next scheduled internal transition at time 3.00
INTERNAL TRANSITION in model <Root.Coupled.P1>
New State: None
Output Port Configuration:
port <outport>:
3
Next scheduled internal transition at time inf
__ Current Time: 3.00 __________________________________________
EXTERNAL TRANSITION in model <Root.PO2>
Input Port Configuration:
port <inport>:
3
New State: 3
Next scheduled internal transition at time 4.00
INTERNAL TRANSITION in model <Root.P1>
New State: None
Output Port Configuration:
port <outport>:
3
Next scheduled internal transition at time inf
__ Current Time: 3.00 __________________________________________
EXTERNAL TRANSITION in model <Root.PO2>
Input Port Configuration:
port <inport>:
(3, 3)
New State: (3, 3)
Next scheduled internal transition at time 4.00
INTERNAL TRANSITION in model <Root.P2>
New State: (None, None)
Output Port Configuration:
port <outport>:
(3, 3)
Next scheduled internal transition at time inf
__ Current Time: 4.00 __________________________________________
INTERNAL TRANSITION in model <Root.PO2>
New State: None
Output Port Configuration:
port <outport1>:
(3, 3)
port <outport2>:
(3, 3)
Next scheduled internal transition at time inf

3453
test/expected/confluent Normal file

File diff suppressed because it is too large Load diff

1242
test/expected/doublelayer Normal file

File diff suppressed because it is too large Load diff

4107
test/expected/draw Normal file

File diff suppressed because it is too large Load diff

4183
test/expected/dual Normal file

File diff suppressed because it is too large Load diff

3195
test/expected/dual_mp Normal file

File diff suppressed because it is too large Load diff

2664
test/expected/dualdepth Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,495 @@
__ Current Time: 0.00 __________________________________________
INITIAL CONDITIONS in model <Root.GEN>
Initial State: 1.0
Next scheduled internal transition at time 0.50
INITIAL CONDITIONS in model <Root.Processor>
Initial State: inf
Next scheduled internal transition at time inf
INITIAL CONDITIONS in model <Root.Processor>
Initial State: inf
Next scheduled internal transition at time inf
__ Current Time: 0.50 __________________________________________
INITIAL CONDITIONS in model <Root.ElapsedNothing>
Initial State: 1
Next scheduled internal transition at time 1.20
EXTERNAL TRANSITION in model <Root.Processor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 1.50
EXTERNAL TRANSITION in model <Root.Processor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 1.50
INITIAL CONDITIONS in model <Root.CoupledProcessor_3.Processor0>
Initial State: inf
Next scheduled internal transition at time inf
INITIAL CONDITIONS in model <Root.CoupledProcessor_3.Processor1>
Initial State: inf
Next scheduled internal transition at time inf
INITIAL CONDITIONS in model <Root.CoupledProcessor_3.Processor2>
Initial State: inf
Next scheduled internal transition at time inf
INITIAL CONDITIONS in model <Root.Processor>
Initial State: inf
Next scheduled internal transition at time inf
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 1.50
__ Current Time: 1.20 __________________________________________
INTERNAL TRANSITION in model <Root.ElapsedNothing>
New State: 0
Output Port Configuration:
Next scheduled internal transition at time inf
__ Current Time: 1.50 __________________________________________
EXTERNAL TRANSITION in model <Root.CoupledProcessor_3.Processor0>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 0.2
Next scheduled internal transition at time 1.70
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 2.50
INTERNAL TRANSITION in model <Root.Processor>
New State: inf
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time inf
__ Current Time: 1.70 __________________________________________
EXTERNAL TRANSITION in model <Root.CoupledProcessor_3.Processor1>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 0.2
Next scheduled internal transition at time 1.90
INTERNAL TRANSITION in model <Root.CoupledProcessor_3.Processor0>
New State: inf
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time inf
__ Current Time: 1.90 __________________________________________
EXTERNAL TRANSITION in model <Root.CoupledProcessor_3.Processor2>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 0.2
Next scheduled internal transition at time 2.10
INTERNAL TRANSITION in model <Root.CoupledProcessor_3.Processor1>
New State: inf
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time inf
__ Current Time: 2.10 __________________________________________
INTERNAL TRANSITION in model <Root.CoupledProcessor_3.Processor2>
New State: inf
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time inf
__ Current Time: 2.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 3.50
__ Current Time: 3.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 4.50
__ Current Time: 4.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 5.50
__ Current Time: 5.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 6.50
__ Current Time: 6.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 7.50
__ Current Time: 7.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 8.50
__ Current Time: 8.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 9.50
__ Current Time: 9.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 10.50
__ Current Time: 10.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 11.50
__ Current Time: 11.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 12.50
__ Current Time: 12.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 13.50
__ Current Time: 13.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 14.50
__ Current Time: 14.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 15.50
__ Current Time: 15.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 16.50
__ Current Time: 16.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 17.50
__ Current Time: 17.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 18.50
__ Current Time: 18.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 19.50
__ Current Time: 19.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 20.50
__ Current Time: 20.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 21.50
__ Current Time: 21.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 22.50
__ Current Time: 22.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 23.50
__ Current Time: 23.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 24.50
__ Current Time: 24.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 25.50
__ Current Time: 25.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 26.50
__ Current Time: 26.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 27.50
__ Current Time: 27.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 28.50
__ Current Time: 28.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 29.50
__ Current Time: 29.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 30.50
__ Current Time: 30.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 31.50
__ Current Time: 31.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 32.50
__ Current Time: 32.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 33.50
__ Current Time: 33.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 34.50
__ Current Time: 34.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 35.50
__ Current Time: 35.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 36.50
__ Current Time: 36.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 37.50
__ Current Time: 37.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 38.50
__ Current Time: 38.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 39.50
__ Current Time: 39.50 __________________________________________
INTERNAL TRANSITION in model <Root.GEN>
New State: 1.0
Output Port Configuration:
Next scheduled internal transition at time 40.50

View file

@ -0,0 +1 @@
dynamicstructure

6
test/expected/fetch Normal file
View file

@ -0,0 +1,6 @@
Generator: 1.0
Processor1.Processor1: 0.66
Processor1.Processor2: 0.66
Processor2.Processor1: inf
Processor2.Processor2: inf
Processor2.Processor3: 0.3

2548
test/expected/local Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,53 @@
digraph G {
subgraph "clusterChain" {
label = "Chain"
color=black
subgraph "clusterChain.CoupledGenerator" {
label = "CoupledGenerator"
color=black
"Chain.CoupledGenerator.Generator" [
label = "Generator\nState: 1.0"
color="red"
style=filled
]
}
subgraph "clusterChain.CoupledProcessor_2" {
label = "CoupledProcessor_2"
color=black
"Chain.CoupledProcessor_2.Processor0" [
label = "Processor0\nState: inf"
color="red"
style=filled
]
"Chain.CoupledProcessor_2.Processor1" [
label = "Processor1\nState: inf"
color="red"
style=filled
]
}
subgraph "clusterChain.CoupledProcessor_3" {
label = "CoupledProcessor_3"
color=black
"Chain.CoupledProcessor_3.Processor0" [
label = "Processor0\nState: inf"
color="red"
style=filled
]
"Chain.CoupledProcessor_3.Processor1" [
label = "Processor1\nState: inf"
color="red"
style=filled
]
"Chain.CoupledProcessor_3.Processor2" [
label = "Processor2\nState: inf"
color="red"
style=filled
]
}
}
"Chain.CoupledGenerator.Generator" -> "Chain.CoupledProcessor_2.Processor0" [label="outport -> inport"];
"Chain.CoupledProcessor_2.Processor0" -> "Chain.CoupledProcessor_2.Processor1" [label="outport -> inport"];
"Chain.CoupledProcessor_2.Processor1" -> "Chain.CoupledProcessor_3.Processor0" [label="outport -> inport"];
"Chain.CoupledProcessor_3.Processor0" -> "Chain.CoupledProcessor_3.Processor1" [label="outport -> inport"];
"Chain.CoupledProcessor_3.Processor1" -> "Chain.CoupledProcessor_3.Processor2" [label="outport -> inport"];
}

21067
test/expected/longtime Normal file

File diff suppressed because it is too large Load diff

4020
test/expected/multi Normal file

File diff suppressed because it is too large Load diff

5437
test/expected/multiinputs Normal file

File diff suppressed because it is too large Load diff

268
test/expected/multinested Normal file
View file

@ -0,0 +1,268 @@
__ Current Time: 0.00 __________________________________________
INITIAL CONDITIONS in model <MultiNested.Generator>
Initial State: 1
Next scheduled internal transition at time 1.00
INITIAL CONDITIONS in model <MultiNested.NProcessor1>
Initial State: inf
Next scheduled internal transition at time 1.00
INITIAL CONDITIONS in model <MultiNested.NProcessor2>
Initial State: inf
Next scheduled internal transition at time 1.00
__ Current Time: 1.00 __________________________________________
CONFLUENT TRANSITION in model <MultiNested.NProcessor1>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 5
Next scheduled internal transition at time 2.00
CONFLUENT TRANSITION in model <MultiNested.NProcessor2>
Input Port Configuration:
port <inport>:
Eventsize = 5
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 5
Next scheduled internal transition at time 2.00
INTERNAL TRANSITION in model <MultiNested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 2.00
__ Current Time: 2.00 __________________________________________
CONFLUENT TRANSITION in model <MultiNested.NProcessor1>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 4.00
CONFLUENT TRANSITION in model <MultiNested.NProcessor2>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 5
Next scheduled internal transition at time 4.00
INTERNAL TRANSITION in model <MultiNested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 3.00
__ Current Time: 3.00 __________________________________________
EXTERNAL TRANSITION in model <MultiNested.NProcessor1>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 6.00
INTERNAL TRANSITION in model <MultiNested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 4.00
__ Current Time: 4.00 __________________________________________
EXTERNAL TRANSITION in model <MultiNested.NProcessor1>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 8.00
INTERNAL TRANSITION in model <MultiNested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 5.00
INTERNAL TRANSITION in model <MultiNested.NProcessor2>
New State: -1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 6.00
__ Current Time: 5.00 __________________________________________
EXTERNAL TRANSITION in model <MultiNested.NProcessor1>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 10.00
INTERNAL TRANSITION in model <MultiNested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 6.00
__ Current Time: 6.00 __________________________________________
EXTERNAL TRANSITION in model <MultiNested.NProcessor1>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 12.00
INTERNAL TRANSITION in model <MultiNested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 7.00
INTERNAL TRANSITION in model <MultiNested.NProcessor2>
New State: -3
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 8.00
__ Current Time: 7.00 __________________________________________
EXTERNAL TRANSITION in model <MultiNested.NProcessor1>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 14.00
INTERNAL TRANSITION in model <MultiNested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 8.00
__ Current Time: 8.00 __________________________________________
EXTERNAL TRANSITION in model <MultiNested.NProcessor1>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 16.00
INTERNAL TRANSITION in model <MultiNested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 9.00
INTERNAL TRANSITION in model <MultiNested.NProcessor2>
New State: -5
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 10.00
__ Current Time: 9.00 __________________________________________
EXTERNAL TRANSITION in model <MultiNested.NProcessor1>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 18.00
INTERNAL TRANSITION in model <MultiNested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 10.00
__ Current Time: 10.00 __________________________________________
EXTERNAL TRANSITION in model <MultiNested.NProcessor1>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 20.00
INTERNAL TRANSITION in model <MultiNested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 11.00
INTERNAL TRANSITION in model <MultiNested.NProcessor2>
New State: -7
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 12.00

399
test/expected/nested Normal file
View file

@ -0,0 +1,399 @@
__ Current Time: 0.00 __________________________________________
INITIAL CONDITIONS in model <Nested.Generator>
Initial State: 1
Next scheduled internal transition at time 1.00
INITIAL CONDITIONS in model <Nested.NProcessor>
Initial State: inf
Next scheduled internal transition at time 1.00
__ Current Time: 1.00 __________________________________________
CONFLUENT TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 5
Next scheduled internal transition at time 2.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 2.00
__ Current Time: 2.00 __________________________________________
CONFLUENT TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 4.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 3.00
__ Current Time: 3.00 __________________________________________
EXTERNAL TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 6.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 4.00
__ Current Time: 4.00 __________________________________________
EXTERNAL TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 8.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 5.00
__ Current Time: 5.00 __________________________________________
EXTERNAL TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 10.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 6.00
__ Current Time: 6.00 __________________________________________
EXTERNAL TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 12.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 7.00
__ Current Time: 7.00 __________________________________________
EXTERNAL TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 14.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 8.00
__ Current Time: 8.00 __________________________________________
EXTERNAL TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 16.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 9.00
__ Current Time: 9.00 __________________________________________
EXTERNAL TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 18.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 10.00
__ Current Time: 10.00 __________________________________________
EXTERNAL TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 20.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 11.00
__ Current Time: 11.00 __________________________________________
EXTERNAL TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 22.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 12.00
__ Current Time: 12.00 __________________________________________
EXTERNAL TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 24.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 13.00
__ Current Time: 13.00 __________________________________________
EXTERNAL TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 26.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 14.00
__ Current Time: 14.00 __________________________________________
EXTERNAL TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 28.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 15.00
__ Current Time: 15.00 __________________________________________
EXTERNAL TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 30.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 16.00
__ Current Time: 16.00 __________________________________________
EXTERNAL TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 32.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 17.00
__ Current Time: 17.00 __________________________________________
EXTERNAL TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 34.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 18.00
__ Current Time: 18.00 __________________________________________
EXTERNAL TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 36.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 19.00
__ Current Time: 19.00 __________________________________________
EXTERNAL TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 38.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 20.00
__ Current Time: 20.00 __________________________________________
EXTERNAL TRANSITION in model <Nested.NProcessor>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 1
Next scheduled internal transition at time 40.00
INTERNAL TRANSITION in model <Nested.Generator>
New State: 1
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 21.00

View file

@ -0,0 +1 @@
nested

4107
test/expected/normal Normal file

File diff suppressed because it is too large Load diff

1912
test/expected/random Normal file

File diff suppressed because it is too large Load diff

134
test/expected/realtime Normal file
View file

@ -0,0 +1,134 @@
__ Current Time: 0.00 __________________________________________
INITIAL CONDITIONS in model <trafficSystem.policeman>
Initial State: idle
Next scheduled internal transition at time 200.00
INITIAL CONDITIONS in model <trafficSystem.trafficLight>
Initial State: red
Next scheduled internal transition at time 3.00
__ Current Time: 3.00 __________________________________________
INTERNAL TRANSITION in model <trafficSystem.trafficLight>
New State: green
Output Port Configuration:
port <OBSERVED>:
grey
Next scheduled internal transition at time 5.00
__ Current Time: 5.00 __________________________________________
INTERNAL TRANSITION in model <trafficSystem.trafficLight>
New State: yellow
Output Port Configuration:
port <OBSERVED>:
yellow
Next scheduled internal transition at time 6.00
__ Current Time: 6.00 __________________________________________
INTERNAL TRANSITION in model <trafficSystem.trafficLight>
New State: red
Output Port Configuration:
port <OBSERVED>:
grey
Next scheduled internal transition at time 9.00
__ Current Time: 9.00 __________________________________________
INTERNAL TRANSITION in model <trafficSystem.trafficLight>
New State: green
Output Port Configuration:
port <OBSERVED>:
grey
Next scheduled internal transition at time 11.00
__ Current Time: 10.00 __________________________________________
EXTERNAL TRANSITION in model <trafficSystem.trafficLight>
Input Port Configuration:
port <INTERRUPT>:
toManual
New State: manual
Next scheduled internal transition at time inf
__ Current Time: 20.00 __________________________________________
EXTERNAL TRANSITION in model <trafficSystem.trafficLight>
Input Port Configuration:
port <INTERRUPT>:
toAutonomous
New State: red
Next scheduled internal transition at time 23.00
__ Current Time: 23.00 __________________________________________
INTERNAL TRANSITION in model <trafficSystem.trafficLight>
New State: green
Output Port Configuration:
port <OBSERVED>:
grey
Next scheduled internal transition at time 25.00
__ Current Time: 25.00 __________________________________________
INTERNAL TRANSITION in model <trafficSystem.trafficLight>
New State: yellow
Output Port Configuration:
port <OBSERVED>:
yellow
Next scheduled internal transition at time 26.00
__ Current Time: 26.00 __________________________________________
INTERNAL TRANSITION in model <trafficSystem.trafficLight>
New State: red
Output Port Configuration:
port <OBSERVED>:
grey
Next scheduled internal transition at time 29.00
__ Current Time: 29.00 __________________________________________
INTERNAL TRANSITION in model <trafficSystem.trafficLight>
New State: green
Output Port Configuration:
port <OBSERVED>:
grey
Next scheduled internal transition at time 31.00
__ Current Time: 30.00 __________________________________________
EXTERNAL TRANSITION in model <trafficSystem.trafficLight>
Input Port Configuration:
port <INTERRUPT>:
toManual
New State: manual
Next scheduled internal transition at time inf

View file

@ -0,0 +1,134 @@
__ Current Time: 0.00 __________________________________________
INITIAL CONDITIONS in model <trafficSystem.policeman>
Initial State: idle
Next scheduled internal transition at time 200.00
INITIAL CONDITIONS in model <trafficSystem.trafficLight>
Initial State: red
Next scheduled internal transition at time 3.00
__ Current Time: 3.00 __________________________________________
INTERNAL TRANSITION in model <trafficSystem.trafficLight>
New State: green
Output Port Configuration:
port <OBSERVED>:
grey
Next scheduled internal transition at time 5.00
__ Current Time: 5.00 __________________________________________
INTERNAL TRANSITION in model <trafficSystem.trafficLight>
New State: yellow
Output Port Configuration:
port <OBSERVED>:
yellow
Next scheduled internal transition at time 6.00
__ Current Time: 6.00 __________________________________________
INTERNAL TRANSITION in model <trafficSystem.trafficLight>
New State: red
Output Port Configuration:
port <OBSERVED>:
grey
Next scheduled internal transition at time 9.00
__ Current Time: 9.00 __________________________________________
INTERNAL TRANSITION in model <trafficSystem.trafficLight>
New State: green
Output Port Configuration:
port <OBSERVED>:
grey
Next scheduled internal transition at time 11.00
__ Current Time: 10.00 __________________________________________
EXTERNAL TRANSITION in model <trafficSystem.trafficLight>
Input Port Configuration:
port <INTERRUPT>:
toManual
New State: manual
Next scheduled internal transition at time inf
__ Current Time: 20.00 __________________________________________
EXTERNAL TRANSITION in model <trafficSystem.trafficLight>
Input Port Configuration:
port <INTERRUPT>:
toAutonomous
New State: red
Next scheduled internal transition at time 23.00
__ Current Time: 23.00 __________________________________________
INTERNAL TRANSITION in model <trafficSystem.trafficLight>
New State: green
Output Port Configuration:
port <OBSERVED>:
grey
Next scheduled internal transition at time 25.00
__ Current Time: 25.00 __________________________________________
INTERNAL TRANSITION in model <trafficSystem.trafficLight>
New State: yellow
Output Port Configuration:
port <OBSERVED>:
yellow
Next scheduled internal transition at time 26.00
__ Current Time: 26.00 __________________________________________
INTERNAL TRANSITION in model <trafficSystem.trafficLight>
New State: red
Output Port Configuration:
port <OBSERVED>:
grey
Next scheduled internal transition at time 29.00
__ Current Time: 29.00 __________________________________________
INTERNAL TRANSITION in model <trafficSystem.trafficLight>
New State: green
Output Port Configuration:
port <OBSERVED>:
grey
Next scheduled internal transition at time 31.00
__ Current Time: 30.00 __________________________________________
EXTERNAL TRANSITION in model <trafficSystem.trafficLight>
Input Port Configuration:
port <INTERRUPT>:
toManual
New State: manual
Next scheduled internal transition at time inf

25273
test/expected/reinit1 Normal file

File diff suppressed because it is too large Load diff

25273
test/expected/reinit2 Normal file

File diff suppressed because it is too large Load diff

25273
test/expected/reinit3 Normal file

File diff suppressed because it is too large Load diff

211867
test/expected/relocation Normal file

File diff suppressed because it is too large Load diff

3079
test/expected/remotedc Normal file

File diff suppressed because it is too large Load diff

15719
test/expected/remotedc_long Normal file

File diff suppressed because it is too large Load diff

21071
test/expected/run1 Normal file

File diff suppressed because it is too large Load diff

10600
test/expected/run2 Normal file

File diff suppressed because it is too large Load diff

109
test/expected/stateStop Normal file
View file

@ -0,0 +1,109 @@
__ Current Time: 0.00 __________________________________________
INITIAL CONDITIONS in model <Chain.CoupledGenerator.Generator>
Initial State: 1.0
Next scheduled internal transition at time 1.00
INITIAL CONDITIONS in model <Chain.CoupledProcessor_2.Processor0>
Initial State: inf
Next scheduled internal transition at time inf
INITIAL CONDITIONS in model <Chain.CoupledProcessor_2.Processor1>
Initial State: inf
Next scheduled internal transition at time inf
INITIAL CONDITIONS in model <Chain.CoupledProcessor_3.Processor0>
Initial State: inf
Next scheduled internal transition at time inf
INITIAL CONDITIONS in model <Chain.CoupledProcessor_3.Processor1>
Initial State: inf
Next scheduled internal transition at time inf
INITIAL CONDITIONS in model <Chain.CoupledProcessor_3.Processor2>
Initial State: inf
Next scheduled internal transition at time inf
__ Current Time: 1.00 __________________________________________
EXTERNAL TRANSITION in model <Chain.CoupledProcessor_2.Processor0>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 0.66
Next scheduled internal transition at time 1.66
INTERNAL TRANSITION in model <Chain.CoupledGenerator.Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 2.00
__ Current Time: 1.66 __________________________________________
EXTERNAL TRANSITION in model <Chain.CoupledProcessor_2.Processor1>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 0.66
Next scheduled internal transition at time 2.32
INTERNAL TRANSITION in model <Chain.CoupledProcessor_2.Processor0>
New State: inf
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time inf
__ Current Time: 2.00 __________________________________________
EXTERNAL TRANSITION in model <Chain.CoupledProcessor_2.Processor0>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 0.66
Next scheduled internal transition at time 2.66
INTERNAL TRANSITION in model <Chain.CoupledGenerator.Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 3.00
__ Current Time: 2.32 __________________________________________
EXTERNAL TRANSITION in model <Chain.CoupledProcessor_3.Processor0>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 0.3
Next scheduled internal transition at time 2.62
INTERNAL TRANSITION in model <Chain.CoupledProcessor_2.Processor1>
New State: inf
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time inf

View file

@ -0,0 +1,147 @@
__ Current Time: 0.00 __________________________________________
INITIAL CONDITIONS in model <Chain.CoupledGenerator.Generator>
Initial State: 1.0
Next scheduled internal transition at time 1.00
INITIAL CONDITIONS in model <Chain.CoupledProcessor_2.Processor0>
Initial State: inf
Next scheduled internal transition at time inf
INITIAL CONDITIONS in model <Chain.CoupledProcessor_2.Processor1>
Initial State: inf
Next scheduled internal transition at time inf
INITIAL CONDITIONS in model <Chain.CoupledProcessor_3.Processor0>
Initial State: inf
Next scheduled internal transition at time inf
INITIAL CONDITIONS in model <Chain.CoupledProcessor_3.Processor1>
Initial State: inf
Next scheduled internal transition at time inf
INITIAL CONDITIONS in model <Chain.CoupledProcessor_3.Processor2>
Initial State: inf
Next scheduled internal transition at time inf
__ Current Time: 1.00 __________________________________________
EXTERNAL TRANSITION in model <Chain.CoupledProcessor_2.Processor0>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 0.66
Next scheduled internal transition at time 1.66
INTERNAL TRANSITION in model <Chain.CoupledGenerator.Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 2.00
__ Current Time: 1.66 __________________________________________
EXTERNAL TRANSITION in model <Chain.CoupledProcessor_2.Processor1>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 0.66
Next scheduled internal transition at time 2.32
INTERNAL TRANSITION in model <Chain.CoupledProcessor_2.Processor0>
New State: inf
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time inf
__ Current Time: 2.00 __________________________________________
EXTERNAL TRANSITION in model <Chain.CoupledProcessor_2.Processor0>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 0.66
Next scheduled internal transition at time 2.66
INTERNAL TRANSITION in model <Chain.CoupledGenerator.Generator>
New State: 1.0
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time 3.00
__ Current Time: 2.32 __________________________________________
EXTERNAL TRANSITION in model <Chain.CoupledProcessor_3.Processor0>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 0.3
Next scheduled internal transition at time 2.62
INTERNAL TRANSITION in model <Chain.CoupledProcessor_2.Processor1>
New State: inf
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time inf
__ Current Time: 2.62 __________________________________________
EXTERNAL TRANSITION in model <Chain.CoupledProcessor_3.Processor1>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 0.3
Next scheduled internal transition at time 2.92
INTERNAL TRANSITION in model <Chain.CoupledProcessor_3.Processor0>
New State: inf
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time inf
__ Current Time: 2.66 __________________________________________
EXTERNAL TRANSITION in model <Chain.CoupledProcessor_2.Processor1>
Input Port Configuration:
port <inport>:
Eventsize = 1
New State: 0.66
Next scheduled internal transition at time 3.32
INTERNAL TRANSITION in model <Chain.CoupledProcessor_2.Processor0>
New State: inf
Output Port Configuration:
port <outport>:
Eventsize = 1
Next scheduled internal transition at time inf

4107
test/expected/trace Normal file

File diff suppressed because it is too large Load diff

512
test/expected/trace.vcd Normal file
View file

@ -0,0 +1,512 @@
$date
2013-08-31
$end
$version
PyDEVS VCD export
$end
$comment
Generated from DEVS-code
$end
$timescale 1ns $end
$scope Binary.CoupledGenerator.Generator Binary.CoupledGenerator.Generator $end
$var wire 1 0 outport $end
$var wire 1 1 inport $end
$upscope $end
$scope Binary.CoupledProcessor_2.Processor0 Binary.CoupledProcessor_2.Processor0 $end
$var wire 1 2 inport $end
$var wire 1 3 outport $end
$upscope $end
$scope Binary.CoupledProcessor_2.Processor1 Binary.CoupledProcessor_2.Processor1 $end
$var wire 1 4 inport $end
$var wire 1 5 outport $end
$upscope $end
$scope Binary.CoupledProcessor_3.Processor0 Binary.CoupledProcessor_3.Processor0 $end
$var wire 1 6 inport $end
$var wire 1 7 outport $end
$upscope $end
$scope Binary.CoupledProcessor_3.Processor1 Binary.CoupledProcessor_3.Processor1 $end
$var wire 1 8 inport $end
$var wire 1 9 outport $end
$upscope $end
$scope Binary.CoupledProcessor_3.Processor2 Binary.CoupledProcessor_3.Processor2 $end
$var wire 1 10 inport $end
$var wire 1 11 outport $end
$upscope $end
$enddefinitions $end
$dumpvars
bz 0
bz 1
bz 2
bz 3
bz 4
bz 5
bz 6
bz 7
bz 8
bz 9
bz 10
bz 11
$end
b1 0
#10
b1 2
b1 3
b1 4
b1 0
#20
b1 2
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#30
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#40
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#50
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#60
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#70
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#80
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#90
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#100
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#110
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#120
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#130
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#140
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#150
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#160
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#170
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#180
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#190
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#200
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#210
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#220
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#230
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#240
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#250
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#260
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#270
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#280
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#290
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#300
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#310
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#320
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#330
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#340
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#350
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#360
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#370
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#380
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#390
b1 2
b1 11
b1 5
b1 6
b1 7
b1 8
b1 3
b1 4
b1 9
b1 10
b1 0
#400
b1 2

4704
test/expected/trace.xml Normal file

File diff suppressed because it is too large Load diff

3852
test/expected/z Normal file

File diff suppressed because it is too large Load diff

4224
test/expected/zeroLookahead Normal file

File diff suppressed because it is too large Load diff

6
test/locationsave.txt Normal file
View file

@ -0,0 +1,6 @@
0 1 Chain.CoupledGenerator.Generator
1 2 Chain.CoupledProcessor_2.Processor0
2 2 Chain.CoupledProcessor_2.Processor1
3 0 Chain.CoupledProcessor_3.Processor0
4 0 Chain.CoupledProcessor_3.Processor1
5 0 Chain.CoupledProcessor_3.Processor2

0
test/output/.keep Normal file
View file

197
test/testActions.py Normal file
View file

@ -0,0 +1,197 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from testutils import *
from pypdevs.util import DEVSException
class TestActions(unittest.TestCase):
# Tests the externalInput function, which takes messages of the form:
# [[time, age], content, anti-message, UUID, color]
def setUp(self):
self.sim = basicSim()
def tearDown(self):
self.sim.run_gvt = False
def test_actions_delayed_action_normal(self):
self.sim.gvt = 0
plist = []
plist.append([(1, 1), "model1", "ABC"])
plist.append([(2, 1), "model3", "ABC"])
plist.append([(3, 1), "model1", "ABE"])
plist.append([(2, 6), "model1", "DBC"])
plist.append([(0, 1), "model2", "ABZ"])
plist.append([(7, 1), "model1", "A5C"])
# Messages should not be sorted in the actions list
for i in plist:
self.sim.delayedAction(i[0], i[1], i[2])
self.assertTrue(self.sim.actions == plist)
def test_actions_text_revertion(self):
self.sim.gvt = 1
plist = []
plist.append([(1, 1), "model1", "ABC"])
plist.append([(2, 1), "model3", "ABC"])
plist.append([(3, 1), "model1", "ABE"])
plist.append([(2, 6), "model1", "DBC"])
# This one should be filtered out
plist.append([(0, 1), "model2", "ABZ"])
plist.append([(7, 1), "model1", "A5C"])
# Messages should not be sorted in the toPrint list
rlist = []
for i in plist:
if i[0][0] < self.sim.gvt:
try:
self.sim.delayedAction(i[0], i[1], i[2])
# Should throw an exception
self.fail() #pragma: nocover
except DEVSException:
# OK
pass
else:
# This one should work fine
self.sim.delayedAction(i[0], i[1], i[2])
rlist.append(i)
self.assertTrue(self.sim.actions == rlist)
def test_actions_perform(self):
self.sim.gvt = 0
plist = []
# Should not need to be added in correct order!
# Those that should not be executed contain faulty code
# (a division by zero)
plist.append([(0, 0), "model1", "pass"])
plist.append([(3, 1), "model2", "pass"])
plist.append([(2, 1), "model3", "pass"])
plist.append([(2, 1), "model1", "pass"])
plist.append([(6, 4), "model2", "1/0"])
plist.append([(4, 3), "model1", "pass"])
plist.append([(8, 2), "model1", "1/0"])
plist.append([(9, 9), "model3", "1/0"])
plist2 = []
# Should be in this exact order, otherwise this part was sorted too
plist2.append(plist[4])
plist2.append(plist[6])
plist2.append(plist[7])
self.sim.actions = list(plist)
# Perform all actions up to time 5
try:
self.sim.performActions(5)
except ZeroDivisionError: #pragma: nocover
# executed a bad piece of code!
self.fail("Executed too much code")
self.assertTrue(self.sim.actions == plist2)
# Now execute a command that should crash, to make sure that
# this code is executed and not just deleted
try:
self.sim.performActions(7)
self.fail("Didn't execute desired code") #pragma: nocover
except ZeroDivisionError:
pass
def test_actions_remove_revert(self):
self.sim.gvt = 5
plist = []
# Should not need to be added in correct order!
plist.append([(0, 0), "model1", "ABC"])
plist.append([(3, 1), "model2", "ABC"])
plist.append([(2, 1), "model3", "ABC"])
plist.append([(2, 1), "model1", "ABC"])
plist.append([(8, 4), "model2", "ABC"])
plist.append([(4, 3), "model1", "ABC"])
plist.append([(8, 2), "model1", "ABC"])
plist.append([(9, 9), "model3", "ABC"])
# Make a copy...
self.sim.actions = list(plist)
self.sim.removeActions("model1", (9, 1))
# No messages from this time on
self.assertTrue(self.sim.actions == plist)
try:
self.sim.removeActions("model1", (4, 3))
# Revertion from before the GVT, should be denied!
self.fail() #pragma: nocover
except DEVSException:
pass
# Nothing should have happend to the print list
self.assertTrue(self.sim.actions == plist)
self.sim.removeActions("model2", (5,1))
# One message from model2 should be removed, as it is just at the GVT
clist = []
clist.append([(0, 0), "model1", "ABC"])
clist.append([(3, 1), "model2", "ABC"])
clist.append([(2, 1), "model3", "ABC"])
clist.append([(2, 1), "model1", "ABC"])
clist.append([(4, 3), "model1", "ABC"])
clist.append([(8, 2), "model1", "ABC"])
clist.append([(9, 9), "model3", "ABC"])
try:
self.sim.removeActions("QDFQF", (0,0))
# Should still cause an error, even if there is nothing < GVT
self.fail() #pragma: nocover
except DEVSException:
pass
self.assertTrue(self.sim.actions == clist)
def test_actions_remove_normal(self):
self.sim.gvt = 0
plist = []
# Should not need to be added in correct order!
plist.append([(0, 0), "model1", "ABC"])
plist.append([(3, 1), "model2", "ABC"])
plist.append([(2, 1), "model3", "ABC"])
plist.append([(2, 1), "model1", "ABC"])
plist.append([(8, 4), "model2", "ABC"])
plist.append([(4, 3), "model1", "ABC"])
plist.append([(8, 2), "model1", "ABC"])
plist.append([(9, 9), "model3", "ABC"])
# Make a copy...
self.sim.actions = list(plist)
self.sim.removeActions("model1", (9, 1))
# No messages from this time on
self.assertTrue(self.sim.actions == plist)
self.sim.removeActions("model1", (4, 3))
# The message at [4,3] itself should also be removed
clist = []
clist.append([(0, 0), "model1", "ABC"])
clist.append([(3, 1), "model2", "ABC"])
clist.append([(2, 1), "model3", "ABC"])
clist.append([(2, 1), "model1", "ABC"])
clist.append([(8, 4), "model2", "ABC"])
clist.append([(9, 9), "model3", "ABC"])
self.assertTrue(self.sim.actions == clist)
self.sim.removeActions("model2", (0,0))
# All messages from model2 should be removed
clist = []
clist.append([(0, 0), "model1", "ABC"])
clist.append([(2, 1), "model3", "ABC"])
clist.append([(2, 1), "model1", "ABC"])
clist.append([(9, 9), "model3", "ABC"])
self.assertTrue(self.sim.actions == clist)
self.sim.removeActions("QDFQF", (0,0))
# Shouldn't make a difference as the model does not exist
self.assertTrue(self.sim.actions == clist)

47
test/testExceptions.py Normal file
View file

@ -0,0 +1,47 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from testutils import *
from pypdevs.util import DEVSException
from pypdevs.DEVS import BaseDEVS, AtomicDEVS, CoupledDEVS
class TestExceptions(unittest.TestCase):
# Tests the externalInput function, which takes messages of the form:
# [[time, age], content, anti-message, UUID, color]
def setUp(self):
self.sim = basicSim()
def tearDown(self):
self.sim.run_gvt = False
def test_DEVS_model_exceptions(self):
try:
# Shouldn't allow instantiation of the base model
junk = BaseDEVS("junk")
self.fail() #pragma: nocover
except DEVSException:
pass
try:
# Shouldn't allow instantiation of the base model
junk = AtomicDEVS("junk")
self.fail() #pragma: nocover
except DEVSException:
pass
try:
# Shouldn't allow instantiation of the base model
junk = CoupledDEVS("junk")
self.fail() #pragma: nocover
except DEVSException:
pass

68
test/testExternalInput.py Normal file
View file

@ -0,0 +1,68 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from testutils import *
from pypdevs.util import DEVSException
class TestExternalInput(unittest.TestCase):
def setUp(self):
self.sim = basicSim()
self.msg = basicMsg()
def tearDown(self):
self.sim.run_gvt = False
def test_externalInput_antimsg_unpresent(self):
# Send a non-present anti message
self.sim.externalInput(self.msg)
self.assertTrue(self.sim.outputQueue == [])
self.assertTrue(self.sim.prevtime == (0,1))
def test_externalInput_antimsg_unpresent_other(self):
# Send a non-present anti message
self.sim.filtered = [self.msg.uuid]
msg2 = NetworkMessage(self.msg.timestamp, self.msg.content, self.msg.uuid, self.msg.color, self.msg.destination)
msg2.uuid = 11111
self.sim.externalInput(msg2)
self.assertTrue(self.sim.outputQueue == [])
self.assertTrue(self.sim.prevtime == (0,1))
def test_externalInput_antimsg_unpresent_multi(self):
# Send a non-present anti message
self.sim.filtered = [self.msg.uuid, self.msg.uuid]
self.sim.externalInput(self.msg)
# This message should now get filtered
self.assertTrue(self.sim.outputQueue == [])
self.assertTrue(self.sim.prevtime == (0,1))
def test_externalInput_normal(self):
self.msg.timestamp = (1, 2)
self.sim.prevtime = (1, 1)
self.sim.externalInput(self.msg)
self.assertTrue(self.sim.outputQueue == [])
self.assertTrue(self.sim.prevtime == (1, 1))
def test_externalInput_revert(self):
self.msg.timestamp = (1, 1)
self.sim.prevtime = (10, 1)
self.sim.model = Generator()
self.sim.model.local_model_ids = set([0, 1])
self.sim.model.rootsim = self.sim
self.sim.externalInput(self.msg)
self.assertTrue(self.sim.reverted)

139
test/testGVT.py Normal file
View file

@ -0,0 +1,139 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from testutils import *
from pypdevs.basesimulator import BaseSimulator
from pypdevs.util import DEVSException
from pypdevs.DEVS import RootDEVS
class StubBaseSimulator(BaseSimulator):
def __init__(self, name):
BaseSimulator.__init__(self, name, None)
self.reverted = False
def receiveControl(self, msg):
thrd = threading.Thread(target=BaseSimulator.receiveControl, args=[self, msg])
thrd.start()
class StubRootDEVS(RootDEVS):
def __init__(self, models, num):
scheduler = "heapset"
models[num].model_id = num
RootDEVS.__init__(self, [models[num]], models, scheduler)
class TestGVT(unittest.TestCase):
def setUp(self):
self.sim = basicSim()
def tearDown(self):
self.sim.run_gvt = False
def test_GVT_notify_receive(self):
self.assertTrue(self.sim.V == [{}, {}, {}, {}])
self.sim.notifyReceive(0)
self.assertTrue(self.sim.V == [{0: -1}, {}, {}, {}])
self.sim.notifyReceive(0)
self.sim.notifyReceive(0)
self.sim.notifyReceive(0)
self.sim.notifyReceive(0)
self.assertTrue(self.sim.V == [{0: -5}, {}, {}, {}])
self.sim.notifyReceive(1)
self.assertTrue(self.sim.V == [{0: -5}, {0: -1}, {}, {}])
self.sim.notifyReceive(1)
self.sim.notifyReceive(1)
self.sim.notifyReceive(1)
self.assertTrue(self.sim.V == [{0: -5}, {0:-4}, {}, {}])
self.sim.notifyReceive(0)
self.sim.notifyReceive(1)
self.sim.notifyReceive(3)
self.sim.notifyReceive(2)
self.sim.notifyReceive(3)
self.sim.notifyReceive(3)
self.sim.notifyReceive(0)
self.assertTrue(self.sim.V == [{0: -7}, {0: -5}, {0: -1}, {0: -3}])
self.sim.V = [{0: 10, 1: 5}, {}, {}, {}]
self.sim.notifyReceive(0)
self.assertTrue(self.sim.V == [{0: 9, 1: 5}, {}, {}, {}])
def test_GVT_notify_send(self):
self.assertTrue(self.sim.V == [{}, {}, {}, {}])
self.assertTrue(self.sim.Tmin == float('inf'))
self.sim.notifySend(1, 1, 0)
self.assertTrue(self.sim.V == [{1: 1}, {}, {}, {}])
self.assertTrue(self.sim.Tmin == float('inf'))
self.sim.notifySend(1, 1, 0)
self.assertTrue(self.sim.V == [{1: 2}, {}, {}, {}])
self.assertTrue(self.sim.Tmin == float('inf'))
self.sim.notifySend(2, 1, 0)
self.assertTrue(self.sim.V == [{1: 2, 2: 1}, {}, {}, {}])
self.assertTrue(self.sim.Tmin == float('inf'))
self.sim.notifySend(2, 3, 0)
self.sim.notifySend(1, 2, 0)
self.sim.notifySend(2, 1, 0)
self.assertTrue(self.sim.V == [{1: 3, 2: 3}, {}, {}, {}])
self.assertTrue(self.sim.Tmin == float('inf'))
self.sim.notifySend(1, 9, 1)
self.assertTrue(self.sim.V == [{1: 3, 2: 3}, {1: 1}, {}, {}])
self.assertTrue(self.sim.Tmin == 9)
self.sim.notifySend(1, 6, 1)
self.assertTrue(self.sim.V == [{1: 3, 2: 3}, {1: 2}, {}, {}])
self.assertTrue(self.sim.Tmin == 6)
self.sim.notifySend(2, 5, 1)
self.assertTrue(self.sim.V == [{1: 3, 2: 3}, {1: 2, 2: 1}, {}, {}])
self.assertTrue(self.sim.Tmin == 5)
self.sim.notifySend(1, 8, 1)
self.assertTrue(self.sim.V == [{1: 3, 2: 3}, {1: 3, 2: 1}, {}, {}])
self.assertTrue(self.sim.Tmin == 5)
self.sim.notifySend(2, 5, 1)
self.sim.notifySend(2, 1, 0)
self.sim.notifySend(2, 1, 0)
self.sim.notifySend(2, 6, 1)
self.assertTrue(self.sim.V == [{1: 3, 2: 5}, {1: 3, 2: 3}, {}, {}])
self.assertTrue(self.sim.Tmin == 5)
def test_setGVT(self):
self.sim.gvt = 0
models = [Generator()]
from pypdevs.statesavers import CopyState
models[0].old_states = [CopyState((0, 1), (2, 1), None, 0, {}, 0), CopyState((2, 1), (6, 1), None, 0, {}, 0)]
self.sim.model = StubRootDEVS(models, 0)
# Prevent a loop
self.sim.next_LP = self.sim
self.assertTrue(self.sim.gvt == 0)
self.sim.setGVT(5, [], False)
self.assertTrue(self.sim.gvt == 5)
# Try to set to a time before the current GVT
try:
self.sim.setGVT(1, [], False)
self.fail()
except DEVSException:
pass
# GVT shouldn't have changed
self.assertTrue(self.sim.gvt == 5)

94
test/testHelpers.py Normal file
View file

@ -0,0 +1,94 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from testutils import *
from pypdevs.util import *
class TestHelpers(unittest.TestCase):
# Tests the externalInput function, which takes messages of the form:
# [[time, age], content, anti-message, UUID, color]
def setUp(self):
setLogger('None', ('localhost', 514), logging.WARN)
def test_helper_add_dict(self):
a = {"a": 3, "b": 6, "c": 2}
b = {"a": 4, "b": 1, "c": 7}
addDict(a, b)
self.assertTrue(a == {"a": 7, "b": 7, "c": 9})
b = {"a": 4, "b": 1, "c": 7}
addDict(a, b)
self.assertTrue(a == {"a": 11, "b": 8, "c": 16})
b = {"c": 1}
addDict(a, b)
self.assertTrue(a == {"a": 11, "b": 8, "c": 17})
b = {"a": -21}
addDict(a, b)
self.assertTrue(a == {"a": -10, "b": 8, "c": 17})
b = {"a": 0, "d": 9}
addDict(a, b)
self.assertTrue(a == {"a": -10, "b": 8, "c": 17, "d": 9})
b = {}
addDict(a, b)
self.assertTrue(a == {"a": -10, "b": 8, "c": 17, "d": 9})
b = {"a": 10, "b": -8, "c": -17, "d": -9, "def": 3}
addDict(a, b)
self.assertTrue(a == {"a": 0, "b": 0, "c": 0, "d": 0, "def": 3})
b = {"d": -9, "def": 2}
addDict(a, b)
self.assertTrue(a == {"a": 0, "b": 0, "c": 0, "d": -9, "def": 5})
def test_helper_all_zero_dict(self):
a = {"a": 0}
self.assertTrue(allZeroDict(a))
a = {}
self.assertTrue(allZeroDict(a))
a = {"a": 0, "b": 0, "c": 0}
self.assertTrue(allZeroDict(a))
a = {"a": 1, "b": 0}
self.assertFalse(allZeroDict(a))
a = {"a": 1, "b": -1}
self.assertFalse(allZeroDict(a))
a = {"a": 0, "b": 1}
self.assertFalse(allZeroDict(a))
a = {"a": -1}
self.assertFalse(allZeroDict(a))
def test_toStr(self):
self.assertTrue(toStr("abc") == "'abc'")
self.assertTrue(toStr("'abc") == "''abc'")
self.assertTrue(toStr(5) == "'5'")
self.assertTrue(toStr([1, 2, 3]) == "'[1, 2, 3]'")
def test_DEVSException(self):
self.assertTrue(str(DEVSException("ABC")) == "DEVS Exception: ABC")
def test_easyCommand(self):
self.assertTrue(easyCommand("abc", []) == "abc()")
self.assertTrue(easyCommand("abc", ["1", "def"]) == "abc(1, def)")
self.assertTrue(easyCommand("abc", ["'def'"]) == "abc('def')")

168
test/testLocal.py Normal file
View file

@ -0,0 +1,168 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from testutils import *
import subprocess
import filecmp
import datetime
class TestLocal(unittest.TestCase):
def setUp(self):
setLogger('None', ('localhost', 514), logging.WARN)
def tearDown(self):
pass
def test_local_normal(self):
self.assertTrue(runLocal("normal"))
def test_local_Z(self):
self.assertTrue(runLocal("z"))
def test_local_dual(self):
self.assertTrue(runLocal("dual"))
def test_local_dualdepth(self):
self.assertTrue(runLocal("dualdepth"))
def test_local_dual_mp(self):
self.assertTrue(runLocal("dual_mp"))
def test_local_longtime(self):
self.assertTrue(runLocal("longtime"))
def test_local_confluent(self):
self.assertTrue(runLocal("confluent"))
def test_local_classic(self):
self.assertTrue(runLocal("classicDEVS"))
def test_local_classicConnect(self):
self.assertTrue(runLocal("classicDEVSconnect"))
def test_local_zeroLookahead(self):
self.assertTrue(runLocal("zeroLookahead"))
def test_local_multi(self):
self.assertTrue(runLocal("multi"))
def test_local_trace(self):
removeFile("devstrace.vcd")
removeFile("devstrace.xml")
self.assertTrue(runLocal("trace"))
# Compare XML and VCD trace files too
if not vcdEqual("devstrace.vcd", "expected/trace.vcd"):
print("VCD trace comparison did not match")
self.fail()
if not filecmp.cmp("devstrace.xml", "expected/trace.xml"):
print("XML trace comparison did not match")
self.fail()
def test_local_stateStop(self):
self.assertTrue(runLocal("stateStop"))
def test_local_atomic(self):
self.assertTrue(runLocal("atomic"))
def test_local_local(self):
self.assertTrue(runLocal("local"))
def test_local_nested(self):
self.assertTrue(runLocal("nested"))
def test_local_multiinputs(self):
self.assertTrue(runLocal("multiinputs"))
def test_local_doublelayer(self):
self.assertTrue(runLocal("doublelayer"))
def test_local_dynamicstructure(self):
self.assertTrue(runLocal("dynamicstructure"))
def test_local_random(self):
self.assertTrue(runLocal("random"))
def test_local_draw(self):
removeFile("model.dot")
self.assertTrue(runLocal("draw"))
if not filecmp.cmp("model.dot", "expected/local_model.dot"):
print("Graphviz file did not match")
self.fail()
removeFile("model.dot")
def test_local_reinit(self):
removeFile("output/reinit1")
removeFile("output/reinit2")
removeFile("output/reinit3")
try:
runLocal("reinit")
except OSError:
# Problem with the comparison of the file that doesn't exist...
pass
# Compare the files
if not filecmp.cmp("output/reinit1", "expected/reinit1") or \
not filecmp.cmp("output/reinit2", "expected/reinit2") or \
not filecmp.cmp("output/reinit3", "expected/reinit3"):
return False
else:
return True
def test_local_multisim(self):
removeFile("output/normal")
removeFile("output/dualdepth")
try:
runLocal("multisim")
except OSError:
pass
if not filecmp.cmp("output/normal", "expected/normal") or \
not filecmp.cmp("output/dualdepth", "expected/dualdepth"):
self.fail()
def test_local_continue(self):
removeFile("output/run1")
removeFile("output/run2")
try:
runLocal("continue")
except OSError:
pass
if not filecmp.cmp("output/run1", "expected/run1") or \
not filecmp.cmp("output/run2", "expected/run2"):
self.fail()
def runLocal(name):
outfile = "output/" + str(name)
removeFile(outfile)
import subprocess
try:
proc = subprocess.Popen("python testmodels/experiment.py " + str(name) + "_local >> /dev/null", shell=True)
proc.wait()
except:
import sys
print(sys.exc_info()[0])
import traceback
traceback.print_tb(sys.exc_info()[2])
proc.terminate()
# Prevent zombie
del proc
print("Exception received :(")
return False
if not filecmp.cmp(outfile, "expected/" + str(name)):
return False
return True

69
test/testLogger.py Normal file
View file

@ -0,0 +1,69 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from testutils import *
import pypdevs.logger as logger
class StubLogger(object):
def __init__(self):
self.lst_debug = []
self.lst_info = []
self.lst_warn = []
self.lst_error = []
def debug(self, msg):
self.lst_debug.append(msg)
def info(self, msg):
self.lst_info.append(msg)
def warn(self, msg):
self.lst_warn.append(msg)
def error(self, msg):
self.lst_error.append(msg)
class TestLogger(unittest.TestCase):
def setUp(self):
logger.logger = StubLogger()
logger.location = 154
def test_logger_debug(self):
self.assertTrue(logger.debug("ABC"))
self.assertTrue(logger.logger.lst_debug == ["154 -- ABC"])
self.assertTrue(logger.logger.lst_info == [])
self.assertTrue(logger.logger.lst_warn == [])
self.assertTrue(logger.logger.lst_error == [])
def test_logger_info(self):
self.assertTrue(logger.info("ABC"))
self.assertTrue(logger.logger.lst_info == ["154 -- ABC"])
self.assertTrue(logger.logger.lst_debug == [])
self.assertTrue(logger.logger.lst_warn == [])
self.assertTrue(logger.logger.lst_error == [])
def test_logger_warn(self):
self.assertTrue(logger.warn("ABC"))
self.assertTrue(logger.logger.lst_warn == ["154 -- ABC"])
self.assertTrue(logger.logger.lst_debug == [])
self.assertTrue(logger.logger.lst_info == [])
self.assertTrue(logger.logger.lst_error == [])
def test_logger_error(self):
self.assertTrue(logger.error("ABC"))
self.assertTrue(logger.logger.lst_error == ["154 -- ABC"])
self.assertTrue(logger.logger.lst_debug == [])
self.assertTrue(logger.logger.lst_info == [])
self.assertTrue(logger.logger.lst_warn == [])

157
test/testMPI.py Normal file
View file

@ -0,0 +1,157 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from testutils import *
import subprocess
import filecmp
import time
class TestMPI(unittest.TestCase):
def setUp(self):
setLogger('None', ('localhost', 514), logging.WARN)
def tearDown(self):
pass
def test_MPI_normal(self):
self.assertTrue(runMPI("normal"))
def test_MPI_z(self):
self.assertTrue(runMPI("z"))
def test_MPI_dual(self):
self.assertTrue(runMPI("dual"))
def test_MPI_dualdepth(self):
self.assertTrue(runMPI("dualdepth"))
def test_MPI_dual_mp(self):
self.assertTrue(runMPI("dual_mp"))
def test_MPI_longtime(self):
self.assertTrue(runMPI("longtime"))
def test_MPI_relocation(self):
self.assertTrue(runMPI("relocation"))
def test_MPI_confluent(self):
self.assertTrue(runMPI("confluent"))
def test_MPI_zeroLookahead(self):
self.assertTrue(runMPI("zeroLookahead"))
def test_MPI_autoAllocate(self):
self.assertTrue(runMPI("auto_allocate"))
def test_MPI_multi(self):
self.assertTrue(runMPI("multi"))
def test_MPI_stateStop(self):
self.assertTrue(runMPI("stateStop"))
def test_MPI_remoteDC(self):
self.assertTrue(runMPI("remotedc"))
def test_MPI_remoteDC_long(self):
self.assertTrue(runMPI("remotedc_long"))
def test_MPI_local(self):
self.assertTrue(runMPI("local", 1))
def test_MPI_autodist_recurse_limit(self):
self.assertTrue(runMPI("autodist"))
def test_MPI_fetch(self):
self.assertTrue(runMPI("fetch"))
def test_MPI_multiinputs(self):
self.assertTrue(runMPI("multiinputs"))
def test_MPI_reinit(self):
self.assertTrue(runMPIReinit())
def test_MPI_draw(self):
removeFile("model.dot")
self.assertTrue(runMPI("draw"))
if not filecmp.cmp("model.dot", "expected/MPI_model.dot"):
print("Graphviz file did not match")
self.fail()
removeFile("model.dot")
def test_MPI_random(self):
self.assertTrue(runMPI("random"))
#@unittest.skip("Known to run into infinite loops")
def test_MPI_checkpoint(self):
# First run the checkpoint and check whether or not the output is identical with or without checkpointing enabled
proc = subprocess.Popen("mpirun -np 3 python testmodels/experiment.py checkpoint", shell=True)
# Wait for a few seconds, should be about halfway by then
time.sleep(5)
proc.kill()
# Now try recovering
proc = subprocess.Popen("mpirun -np 3 python testmodels/experiment.py checkpoint", shell=True)
proc.wait()
# NOTE: output traces are NOT guaranteed to be identical, as it might be possible that the output was being flushed
# to disk while the problem happened. Temporarily, this is simply a smoke test.
# Now remove all generated checkpoints
proc = subprocess.Popen("rm testing_*.pdc", shell=True)
proc.wait()
def test_MPI_trace(self):
removeFile("devstrace.vcd")
removeFile("devstrace.xml")
self.assertTrue(runMPI("trace"))
# Compare XML and VCD trace files too
if not vcdEqual("devstrace.vcd", "expected/trace.vcd"):
print("VCD trace comparison did not match")
self.fail()
if not filecmp.cmp("devstrace.xml", "expected/trace.xml"):
print("XML trace comparison did not match")
self.fail()
def test_MPI_reinit(self):
removeFile("output/reinit1")
removeFile("output/reinit2")
removeFile("output/reinit3")
try:
runMPI("reinit")
except OSError:
# Problem with the comparison of the file that doesn't exist...
pass
# Compare the files
if not filecmp.cmp("output/reinit1", "expected/reinit1") or \
not filecmp.cmp("output/reinit2", "expected/reinit2") or \
not filecmp.cmp("output/reinit3", "expected/reinit3"):
return False
else:
return True
def runMPI(name, processes = 3):
removeFile("output/" + str(name))
try:
proc = subprocess.Popen("mpirun -np " + str(processes) + " python testmodels/experiment.py " + str(name), shell=True)
proc.wait()
except:
import sys
#print(sys.exc_info()[0])
proc.terminate()
# Prevent zombie
del proc
return False
# Deadlocks not handled...
# Compare to the desired result
if not filecmp.cmp("output/" + str(name), "expected/" + str(name)):
return False
return True

View file

@ -0,0 +1,209 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from testutils import *
from pypdevs.messageScheduler import MessageScheduler
from copy import deepcopy
class TestMessageScheduler(unittest.TestCase):
def setUp(self):
self.scheduler = MessageScheduler()
def tearDown(self):
pass
def test_mscheduler_schedule(self):
self.assertTrue(len(self.scheduler.heap) == 0)
self.assertTrue(len(self.scheduler.processed) == 0)
self.assertTrue(self.scheduler.invalids == set({}))
# Only [0] and [3] are important, so don't even bother
# creating the rest
msg = NetworkMessage((1, 1), {}, 12345, False, 0)
self.scheduler.schedule(msg)
self.assertTrue(len(self.scheduler.heap) == 1)
self.assertTrue(len(self.scheduler.processed) == 0)
self.assertTrue(self.scheduler.invalids == set({}))
msg = deepcopy(msg)
msg.uuid = 444
self.scheduler.schedule(msg)
self.assertTrue(len(self.scheduler.heap) == 2)
self.assertTrue(len(self.scheduler.processed) == 0)
self.assertTrue(self.scheduler.invalids == set({}))
msg = deepcopy(msg)
msg.uuid = 456
self.scheduler.schedule(msg)
self.assertTrue(len(self.scheduler.heap) == 3)
self.assertTrue(len(self.scheduler.processed) == 0)
self.assertTrue(self.scheduler.invalids == set({}))
def test_mschedule_invalids(self):
self.assertTrue(len(self.scheduler.heap) == 0)
self.assertTrue(len(self.scheduler.processed) == 0)
self.assertTrue(self.scheduler.invalids == set({}))
# Only [0] and [3] are important, so don't even bother
# creating the rest
msg = NetworkMessage((1, 1), {}, 12345, False, 0)
self.scheduler.schedule(msg)
self.assertTrue(len(self.scheduler.heap) == 1)
self.assertTrue(len(self.scheduler.processed) == 0)
self.assertTrue(self.scheduler.invalids == set({}))
msg = deepcopy(msg)
msg.uuid = 1111
self.scheduler.invalids = set({1111})
self.scheduler.schedule(msg)
self.assertTrue(len(self.scheduler.heap) == 1)
self.assertTrue(len(self.scheduler.processed) == 0)
self.assertTrue(self.scheduler.invalids == set({}))
msg = deepcopy(msg)
msg.uuid = 1111
self.scheduler.schedule(msg)
self.assertTrue(len(self.scheduler.heap) == 2)
self.assertTrue(len(self.scheduler.processed) == 0)
self.assertTrue(self.scheduler.invalids == set({}))
msg = deepcopy(msg)
msg.uuid = 234
self.scheduler.invalids.add(234)
self.scheduler.schedule(msg)
self.assertTrue(len(self.scheduler.heap) == 2)
self.assertTrue(len(self.scheduler.processed) == 0)
self.assertTrue(self.scheduler.invalids == set({}))
def test_mscheduler_read_first(self):
msg1 = NetworkMessage((3, 1), {}, 1, False, 0)
msg2 = NetworkMessage((4, 1), {}, 2, False, 0)
msg3 = NetworkMessage((5, 1), {}, 3, False, 0)
self.scheduler.heap = [msg1, msg2, msg3]
self.scheduler.processed = []
self.assertTrue(self.scheduler.heap == [msg1, msg2, msg3])
self.assertTrue(self.scheduler.processed == [])
self.assertTrue(self.scheduler.invalids == set({}))
first = self.scheduler.readFirst()
self.assertTrue(first == msg1)
self.assertTrue(self.scheduler.heap == [msg1, msg2, msg3])
self.assertTrue(self.scheduler.processed == [])
self.assertTrue(self.scheduler.invalids == set({}))
first = self.scheduler.readFirst()
self.assertTrue(first == msg1)
self.assertTrue(self.scheduler.heap == [msg1, msg2, msg3])
self.assertTrue(self.scheduler.processed == [])
self.assertTrue(self.scheduler.invalids == set({}))
self.scheduler.invalids = set({1})
first = self.scheduler.readFirst()
self.assertTrue(first == msg2)
self.assertTrue(self.scheduler.heap == [msg2, msg3])
self.assertTrue(self.scheduler.processed == [])
self.assertTrue(self.scheduler.invalids == set({}))
def test_mscheduler_removeFirst(self):
msg1 = NetworkMessage((3, 1), {}, 1, False, 0)
msg2 = NetworkMessage((4, 1), {}, 2, False, 0)
msg3 = NetworkMessage((5, 1), {}, 3, False, 0)
self.scheduler.heap = [msg1, msg2, msg3]
self.scheduler.processed = []
self.assertTrue(self.scheduler.heap == [msg1, msg2, msg3])
self.assertTrue(self.scheduler.processed == [])
self.assertTrue(self.scheduler.invalids == set({}))
self.scheduler.removeFirst()
self.assertTrue(self.scheduler.heap == [msg2, msg3])
self.assertTrue(self.scheduler.processed == [msg1])
self.assertTrue(self.scheduler.invalids == set({}))
self.scheduler.invalids = set({2})
self.scheduler.removeFirst()
self.assertTrue(self.scheduler.heap == [])
self.assertTrue(self.scheduler.processed == [msg1, msg3])
self.assertTrue(self.scheduler.invalids == set({}))
def test_mscheduler_revert(self):
msg1 = NetworkMessage((3, 1), {}, 1, False, 0)
msg2 = NetworkMessage((4, 1), {}, 2, False, 0)
msg3 = NetworkMessage((5, 1), {}, 3, False, 0)
self.scheduler.heap = [msg3]
self.scheduler.processed = [msg1, msg2]
self.scheduler.revert((4, 1))
self.assertTrue(self.scheduler.heap == [msg2, msg3])
self.assertTrue(self.scheduler.processed == [msg1])
self.assertTrue(self.scheduler.invalids == set({}))
self.scheduler.revert((2, 1))
self.assertTrue(self.scheduler.heap == [msg1, msg3, msg2])
self.assertTrue(self.scheduler.processed == [])
self.assertTrue(self.scheduler.invalids == set({}))
self.scheduler.heap = []
self.scheduler.processed = [msg1, msg2, msg3]
self.scheduler.revert((2, 1))
self.assertTrue(self.scheduler.heap == [msg1, msg2, msg3])
self.assertTrue(self.scheduler.processed == [])
self.assertTrue(self.scheduler.invalids == set({}))
def test_mscheduler_cleanup(self):
msg1 = NetworkMessage((3, 1), {}, 1, False, 0)
msg2 = NetworkMessage((4, 1), {}, 2, False, 0)
msg3 = NetworkMessage((5, 1), {}, 3, False, 0)
self.scheduler.heap = [msg3]
self.scheduler.processed = [msg1, msg2]
self.scheduler.cleanup((4, 1))
self.assertTrue(self.scheduler.heap == [msg3])
self.assertTrue(self.scheduler.processed == [msg2])
self.assertTrue(self.scheduler.invalids == set({}))
self.scheduler.cleanup((5, 1))
self.assertTrue(self.scheduler.heap == [msg3])
self.assertTrue(self.scheduler.processed == [])
self.assertTrue(self.scheduler.invalids == set({}))
self.scheduler.processed = [msg1, msg2]
self.scheduler.invalids = set({2})
self.scheduler.cleanup((4, 1))
self.assertTrue(self.scheduler.heap == [msg3])
self.assertTrue(self.scheduler.processed == [msg2])
self.assertTrue(self.scheduler.invalids == set({2}))

100
test/testRealtime.py Normal file
View file

@ -0,0 +1,100 @@
from testutils import *
import subprocess
import filecmp
import datetime
class TestRealtime(unittest.TestCase):
def setUp(self):
setLogger('None', ('localhost', 514), logging.WARN)
def tearDown(self):
pass
def test_local_realtime_thread(self):
self.assertTrue(runRealtime("realtime_thread", 35))
def test_local_realtime_tk(self):
self.assertTrue(runRealtime("realtime_tk", 35))
def test_local_realtime_loop(self):
self.assertTrue(runRealtime("realtime_loop", 35))
def test_local_realtime_thread_upscale(self):
self.assertTrue(runRealtime("realtime_thread_2.0", 70))
def test_local_realtime_tk_upscale(self):
self.assertTrue(runRealtime("realtime_tk_2.0", 70))
def test_local_realtime_loop_upscale(self):
self.assertTrue(runRealtime("realtime_loop_2.0", 70))
def test_local_realtime_thread_downscale(self):
self.assertTrue(runRealtime("realtime_thread_0.5", 17))
def test_local_realtime_tk_downscale(self):
self.assertTrue(runRealtime("realtime_tk_0.5", 17))
def test_local_realtime_loop_downscale(self):
self.assertTrue(runRealtime("realtime_loop_0.5", 17))
def test_local_realtime_nested(self):
self.assertTrue(runRealtime("nested_realtime", 20))
def test_local_realtime_dynamicstructure(self):
self.assertTrue(runRealtime("dynamicstructure_realtime", 40))
def test_local_realtime_injection(self):
proc = subprocess.Popen("python testmodels/injecting.py", shell=True)
proc.wait()
self.assertEquals(proc.returncode, 0)
def runRealtime(name, reqtime):
before = datetime.datetime.now()
try:
if runLocal(name):
# Some tests have their own test instead of the normal 'realtime' test
return True
except OSError:
pass
after = datetime.datetime.now()
# Possibly only a slight timing difference, which is allowable
f1 = open("output/realtime", 'r')
f2 = open("expected/realtime", 'r')
for l1, l2 in zip(f1, f2):
if l1 != l2:
# Check that at most 1 character is different
diffs = 0
for c1, c2 in zip(l1, l2):
if c1 != c2:
diffs += 1
if diffs > 1:
raise Exception("Multiple characters were different in the logs")
# It seems that the difference wasn't that big after all, just continue
# Seems to be done, check for time passed
diff = after - before
if not (reqtime - 1 <= diff.seconds <= reqtime + 3):
raise Exception("Total runtime was not as expected. Expected: " + str(reqtime) + "s, but got: " + str(diff.seconds) + "s")
else:
return True
def runLocal(name):
outfile = "output/" + str(name)
removeFile(outfile)
import subprocess
try:
proc = subprocess.Popen("python testmodels/experiment.py " + str(name) + "_local >> /dev/null", shell=True)
proc.wait()
except:
import sys
print(sys.exc_info()[0])
import traceback
traceback.print_tb(sys.exc_info()[2])
proc.terminate()
# Prevent zombie
del proc
print("Exception received :(")
return False
if not filecmp.cmp(outfile, "expected/" + str(name)):
return False
return True

View file

@ -0,0 +1,41 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from testutils import *
class TestReceiveExternal(unittest.TestCase):
def setUp(self):
self.sim = basicSim()
def tearDown(self):
self.sim.run_gvt = False
def test_receiveExternal(self):
self.assertTrue(self.sim.inqueue == [])
# Basic situation, inqueue empty
msg = NetworkMessage((2, 1), {}, 1234, False, 0)
self.sim.receiveExternal(msg)
self.assertTrue(self.sim.inqueue == [msg])
# Add another message, appended at the end
msg2 = NetworkMessage((3, 2), {}, 5234, False, 0)
self.sim.receiveExternal(msg2)
self.assertTrue(self.sim.inqueue == [msg, msg2])
# Append another message, not in sorted order
msg3 = NetworkMessage((1, 1), {}, 5264, False, 0)
self.sim.receiveExternal(msg3)
self.assertTrue(self.sim.inqueue == [msg, msg2, msg3])

87
test/testScheduler.py Normal file
View file

@ -0,0 +1,87 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from testutils import *
from pypdevs.schedulers.schedulerAH import SchedulerAH
class TestScheduler(unittest.TestCase):
def setUp(self):
self.models = []
for i in range(10):
ne = Generator()
ne.model_id = i
ne.time_next = (1, 1)
self.models.append(ne)
for i in range(10):
ne = Processor()
ne.model_id = i + 10
ne.time_next = (float('inf'), 1)
self.models.append(ne)
self.scheduler = SchedulerAH(self.models, 1e-9, len(self.models))
def tearDown(self):
pass
def test_scheduler_schedule(self):
# Only 10, since the Processors should not get scheduled
# due to their time_next
self.assertTrue(len(self.scheduler.heap) == 10)
def test_scheduler_unschedule(self):
self.assertTrue(len(self.scheduler.heap) == 10)
for i in self.models:
self.scheduler.unschedule(i)
# Heap should have the same length, as they became invalid
self.assertTrue(len(self.scheduler.heap) == 10)
# Clean up
self.scheduler.cleanFirst()
self.assertTrue(len(self.scheduler.heap) == 0)
for i in self.models:
self.scheduler.schedule(i)
self.scheduler.unschedule(self.models[5])
self.assertTrue(len(self.scheduler.heap) == 10)
def test_scheduler_get_imminent(self):
self.assertTrue(len(self.scheduler.heap) == 10)
self.scheduler.unschedule(self.models[2])
self.scheduler.unschedule(self.models[4])
self.scheduler.unschedule(self.models[0])
self.scheduler.unschedule(self.models[7])
verifylist = list(self.models[:10])
verifylist.remove(self.models[0])
verifylist.remove(self.models[2])
verifylist.remove(self.models[4])
verifylist.remove(self.models[7])
# Heap should have the same length, as they became invalid
self.assertTrue(len(self.scheduler.heap) == 10)
res = self.scheduler.getImminent((1, 1))
self.assertTrue(res == verifylist)
for i in self.models:
try:
self.scheduler.unschedule(i)
except TypeError:
# Some are possibly already None
pass
# List should be completely empty now
res = self.scheduler.getImminent((1, 1))
self.assertTrue(res == [])

76
test/testTermination.py Normal file
View file

@ -0,0 +1,76 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from testutils import *
class TestTermination(unittest.TestCase):
# Tests the externalInput function, which takes messages of the form:
# [[time, age], content, anti-message, UUID, color]
def setUp(self):
self.sim = basicSim()
self.msg = basicMsg()
def tearDown(self):
self.sim.run_gvt = False
def test_check_global(self):
# If check returns True, it means that we should stop
# This is for basic situations without input_scheduler
self.sim.termination_time = (5, float('inf'))
self.sim.model = Generator()
self.assertFalse(self.sim.check())
self.sim.model.time_next = (5, 1)
self.assertFalse(self.sim.check())
self.sim.model.time_next = (5, 2)
self.assertFalse(self.sim.check())
self.sim.model.time_next = (6, 1)
self.assertTrue(self.sim.check())
self.sim.model.time_next = (float('inf'), 1)
self.assertTrue(self.sim.check())
# Now there is an input_scheduler
msg = NetworkMessage(self.msg.timestamp, self.msg.content, self.msg.uuid, self.msg.color, self.msg.destination)
msg2 = NetworkMessage(self.msg.timestamp, self.msg.content, self.msg.uuid, self.msg.color, self.msg.destination)
self.sim.input_scheduler.heap = [msg]
self.sim.model.time_next = (float('inf'), 1)
# Message in input_scheduler must still be sent
msg.timestamp = (3, 1)
self.assertFalse(self.sim.check())
# Message in input_scheduler is after the termination time
msg.timestamp = (6, 1)
self.assertTrue(self.sim.check())
# Messages in input_scheduler, only last one must still be sent
msg.timestamp = (2, 1)
msg2.timestamp = (4, 1)
self.sim.prevtime = (3, 1)
self.sim.input_scheduler.heap.append(msg2)
self.assertFalse(self.sim.check())
msg.timestamp = (6, 1)
msg2.timestamp = (7, 1)
self.sim.prevtime = (3, 1)
self.sim.input_scheduler.heap.append(msg2)
self.assertTrue(self.sim.check())
self.sim.model.time_next = (3, 1)
msg.timestamp = (2, 1)
msg2.timestamp = (7, 1)
self.sim.prevtime = (2, 4)
self.sim.input_scheduler.heap.append(msg2)
self.assertFalse(self.sim.check())

47
test/testTestUtils.py Normal file
View file

@ -0,0 +1,47 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from testutils import *
class TestTestUtils(unittest.TestCase):
def test_testutils_equalStateVectors(self):
state1 = [1, 2, 3]
state2 = [1, 4, 3]
state3 = [1, 2, 4]
state4 = [1, 4, 3]
state5 = [2, 2, 4]
a = []
b = [state1]
self.assertFalse(equalStateVectors(a, b))
a = [state2]
self.assertFalse(equalStateVectors(a, b))
a = [state1, state2]
self.assertFalse(equalStateVectors(a, b))
b = [state2, state1]
self.assertFalse(equalStateVectors(a, b))
# Third field doesn't matter
a = [state1]
b = [state3]
self.assertTrue(equalStateVectors(a, b))
a = [state3, state1]
b = [state1, state3]
self.assertTrue(equalStateVectors(a, b))
# Even though it doesn't matter, length must be equal
a = [state1, state3]
b = [state1, state1, state1]
self.assertFalse(equalStateVectors(a, b))
a = [state1]
b = [state5]
self.assertFalse(equalStateVectors(a, b))

408
test/testTracers.py Normal file
View file

@ -0,0 +1,408 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from testutils import *
from tracers import *
from tracerVCD import VCDRecord
import os
class StubTracers(Tracers):
def __init__(self):
self.called = []
self.cell = False
def verboseInternal(self, model):
self.called.append(("verboseInternal", model))
def xmlInternal(self, model):
self.called.append(("xmlInternal", model))
def vcdInternal(self, model):
self.called.append(("vcdInternal", model))
def verboseExternal(self, model):
self.called.append(("verboseExternal", model))
def xmlExternal(self, model):
self.called.append(("xmlExternal", model))
def vcdExternal(self, model):
self.called.append(("vcdExternal", model))
def verboseInit(self, model):
self.called.append(("verboseInit", model))
def xmlInit(self, model):
self.called.append(("xmlInit", model))
def vcdInit(self, model):
self.called.append(("vcdInit", model))
def verboseConfluent(self, model):
self.called.append(("verboseConfluent", model))
def xmlConfluent(self, model):
self.called.append(("xmlConfluent", model))
def vcdConfluent(self, model):
self.called.append(("vcdConfluent", model))
def initXML(self):
self.called.append("initXML")
def initVCD(self):
self.called.append("initVCD")
class TestTracers(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
try:
os.remove("devstrace.xml")
except OSError:
pass
try:
os.remove("devstrace.vcd")
except OSError:
pass
try:
os.remove("devstrace.out")
except OSError:
pass
def test_VCDRecord(self):
a = VCDRecord(1, "abc.def", "inport")
self.assertTrue(a.modelName == "abc.def")
self.assertTrue(a.bitSize == None)
self.assertTrue(a.identifier == 1)
self.assertTrue(a.portName == "inport")
def test_tracers_internal(self):
model = Generator()
tracer = StubTracers()
tracer.verbose = False
tracer.xml = False
tracer.vcd = False
tracer.tracesInternal(model)
self.assertTrue(tracer.called.count(("verboseInternal", model)) == 0)
self.assertTrue(tracer.called.count(("xmlInternal", model)) == 0)
self.assertTrue(tracer.called.count(("vcdInternal", model)) == 0)
tracer = StubTracers()
tracer.verbose = True
tracer.xml = False
tracer.vcd = False
tracer.tracesInternal(model)
self.assertTrue(tracer.called.count(("verboseInternal", model)) == 1)
self.assertTrue(tracer.called.count(("xmlInternal", model)) == 0)
self.assertTrue(tracer.called.count(("vcdInternal", model)) == 0)
tracer = StubTracers()
tracer.verbose = False
tracer.xml = True
tracer.vcd = False
tracer.tracesInternal(model)
self.assertTrue(tracer.called.count(("verboseInternal", model)) == 0)
self.assertTrue(tracer.called.count(("xmlInternal", model)) == 1)
self.assertTrue(tracer.called.count(("vcdInternal", model)) == 0)
tracer = StubTracers()
tracer.verbose = False
tracer.xml = False
tracer.vcd = True
tracer.tracesInternal(model)
self.assertTrue(tracer.called.count(("verboseInternal", model)) == 0)
self.assertTrue(tracer.called.count(("xmlInternal", model)) == 0)
self.assertTrue(tracer.called.count(("vcdInternal", model)) == 1)
tracer = StubTracers()
tracer.verbose = True
tracer.xml = True
tracer.vcd = True
tracer.tracesInternal(model)
self.assertTrue(tracer.called.count(("verboseInternal", model)) == 1)
self.assertTrue(tracer.called.count(("xmlInternal", model)) == 1)
self.assertTrue(tracer.called.count(("vcdInternal", model)) == 1)
def test_tracers_init(self):
model = Generator()
tracer = StubTracers()
tracer.verbose = False
tracer.xml = False
tracer.vcd = False
tracer.tracesInit(model)
self.assertTrue(tracer.called.count(("verboseInit", model)) == 0)
self.assertTrue(tracer.called.count(("xmlInit", model)) == 0)
self.assertTrue(tracer.called.count(("vcdInit", model)) == 0)
tracer = StubTracers()
tracer.verbose = True
tracer.xml = False
tracer.vcd = False
tracer.tracesInit(model)
self.assertTrue(tracer.called.count(("verboseInit", model)) == 1)
self.assertTrue(tracer.called.count(("xmlInit", model)) == 0)
self.assertTrue(tracer.called.count(("vcdInit", model)) == 0)
tracer = StubTracers()
tracer.verbose = False
tracer.xml = True
tracer.vcd = False
tracer.tracesInit(model)
self.assertTrue(tracer.called.count(("verboseInit", model)) == 0)
self.assertTrue(tracer.called.count(("xmlInit", model)) == 1)
self.assertTrue(tracer.called.count(("vcdInit", model)) == 0)
tracer = StubTracers()
tracer.verbose = False
tracer.xml = False
tracer.vcd = True
tracer.tracesInit(model)
self.assertTrue(tracer.called.count(("verboseInit", model)) == 0)
self.assertTrue(tracer.called.count(("xmlInit", model)) == 0)
self.assertTrue(tracer.called.count(("vcdInit", model)) == 1)
tracer = StubTracers()
tracer.verbose = True
tracer.xml = True
tracer.vcd = True
tracer.tracesInit(model)
self.assertTrue(tracer.called.count(("verboseInit", model)) == 1)
self.assertTrue(tracer.called.count(("xmlInit", model)) == 1)
self.assertTrue(tracer.called.count(("vcdInit", model)) == 1)
def test_tracers_external(self):
model = Generator()
tracer = StubTracers()
tracer.verbose = False
tracer.xml = False
tracer.vcd = False
tracer.tracesExternal(model)
self.assertTrue(tracer.called.count(("verboseExternal", model)) == 0)
self.assertTrue(tracer.called.count(("xmlExternal", model)) == 0)
self.assertTrue(tracer.called.count(("vcdExternal", model)) == 0)
tracer = StubTracers()
tracer.verbose = True
tracer.xml = False
tracer.vcd = False
tracer.tracesExternal(model)
self.assertTrue(tracer.called.count(("verboseExternal", model)) == 1)
self.assertTrue(tracer.called.count(("xmlExternal", model)) == 0)
self.assertTrue(tracer.called.count(("vcdExternal", model)) == 0)
tracer = StubTracers()
tracer.verbose = False
tracer.xml = True
tracer.vcd = False
tracer.tracesExternal(model)
self.assertTrue(tracer.called.count(("verboseExternal", model)) == 0)
self.assertTrue(tracer.called.count(("xmlExternal", model)) == 1)
self.assertTrue(tracer.called.count(("vcdExternal", model)) == 0)
tracer = StubTracers()
tracer.verbose = False
tracer.xml = False
tracer.vcd = True
tracer.tracesExternal(model)
self.assertTrue(tracer.called.count(("verboseExternal", model)) == 0)
self.assertTrue(tracer.called.count(("xmlExternal", model)) == 0)
self.assertTrue(tracer.called.count(("vcdExternal", model)) == 1)
tracer = StubTracers()
tracer.verbose = True
tracer.xml = True
tracer.vcd = True
tracer.tracesExternal(model)
self.assertTrue(tracer.called.count(("verboseExternal", model)) == 1)
self.assertTrue(tracer.called.count(("xmlExternal", model)) == 1)
self.assertTrue(tracer.called.count(("vcdExternal", model)) == 1)
def test_tracers_confluent(self):
model = Generator()
tracer = StubTracers()
tracer.verbose = False
tracer.xml = False
tracer.vcd = False
tracer.tracesConfluent(model)
self.assertTrue(tracer.called.count(("verboseConfluent", model)) == 0)
self.assertTrue(tracer.called.count(("xmlConfluent", model)) == 0)
self.assertTrue(tracer.called.count(("vcdConfluent", model)) == 0)
tracer = StubTracers()
tracer.verbose = True
tracer.xml = False
tracer.vcd = False
tracer.tracesConfluent(model)
self.assertTrue(tracer.called.count(("verboseConfluent", model)) == 1)
self.assertTrue(tracer.called.count(("xmlConfluent", model)) == 0)
self.assertTrue(tracer.called.count(("vcdConfluent", model)) == 0)
tracer = StubTracers()
tracer.verbose = False
tracer.xml = True
tracer.vcd = False
tracer.tracesConfluent(model)
self.assertTrue(tracer.called.count(("verboseConfluent", model)) == 0)
self.assertTrue(tracer.called.count(("xmlConfluent", model)) == 1)
self.assertTrue(tracer.called.count(("vcdConfluent", model)) == 0)
tracer = StubTracers()
tracer.verbose = False
tracer.xml = False
tracer.vcd = True
tracer.tracesConfluent(model)
self.assertTrue(tracer.called.count(("verboseConfluent", model)) == 0)
self.assertTrue(tracer.called.count(("xmlConfluent", model)) == 0)
self.assertTrue(tracer.called.count(("vcdConfluent", model)) == 1)
tracer = StubTracers()
tracer.verbose = True
tracer.xml = True
tracer.vcd = True
tracer.tracesConfluent(model)
self.assertTrue(tracer.called.count(("verboseConfluent", model)) == 1)
self.assertTrue(tracer.called.count(("xmlConfluent", model)) == 1)
self.assertTrue(tracer.called.count(("vcdConfluent", model)) == 1)
def test_initXML(self):
tracer = Tracers()
tracer.setXML(True, "devstrace.xml")
tracer.initXML()
tracer.xml_file.close()
f = open("devstrace.xml", 'r')
c = 0
for l in f:
if c == 0: e = '<?xml version="1.0"?>'
elif c == 1: e = '<trace>'
c += 1
e = e + "\n"
self.assertTrue(e == l)
def test_startTracers(self):
tracer = StubTracers()
tracer.verbose = False
tracer.xml = False
tracer.vcd = False
tracer.startTracers()
self.assertTrue(tracer.called.count("initXML") == 0)
self.assertTrue(tracer.called.count("initVCD") == 0)
tracer = StubTracers()
tracer.verbose = True
tracer.xml = True
tracer.vcd = True
tracer.startTracers()
self.assertTrue(tracer.called.count("initXML") == 1)
self.assertTrue(tracer.called.count("initVCD") == 1)
tracer = StubTracers()
tracer.verbose = True
tracer.xml = False
tracer.vcd = False
tracer.startTracers()
self.assertTrue(tracer.called.count("initXML") == 0)
self.assertTrue(tracer.called.count("initVCD") == 0)
tracer = StubTracers()
tracer.verbose = False
tracer.xml = True
tracer.vcd = False
tracer.startTracers()
self.assertTrue(tracer.called.count("initXML") == 1)
self.assertTrue(tracer.called.count("initVCD") == 0)
tracer = StubTracers()
tracer.verbose = False
tracer.xml = False
tracer.vcd = True
tracer.startTracers()
self.assertTrue(tracer.called.count("initXML") == 0)
self.assertTrue(tracer.called.count("initVCD") == 1)
def test_stopTracers(self):
class CheckFlush(object):
def __init__(self):
self.flushed = False
def flush(self):
self.flushed = True
def write(self, text):
pass
# Just provide some coverage and check that all files get flushed
tracer = Tracers()
tracer.verbose = False
tracer.xml = False
tracer.vcd = False
tracer.verb_file = CheckFlush()
tracer.xml_file = CheckFlush()
tracer.vcd_file = CheckFlush()
tracer.stopTracers()
self.assertTrue(tracer.verb_file.flushed == False)
self.assertTrue(tracer.xml_file.flushed == False)
self.assertTrue(tracer.vcd_file.flushed == False)
tracer = Tracers()
tracer.verbose = True
tracer.xml = False
tracer.vcd = False
tracer.verb_file = CheckFlush()
tracer.xml_file = CheckFlush()
tracer.vcd_file = CheckFlush()
tracer.stopTracers()
self.assertTrue(tracer.verb_file.flushed == True)
self.assertTrue(tracer.xml_file.flushed == False)
self.assertTrue(tracer.vcd_file.flushed == False)
tracer = Tracers()
tracer.verbose = False
tracer.xml = True
tracer.vcd = False
tracer.verb_file = CheckFlush()
tracer.xml_file = CheckFlush()
tracer.vcd_file = CheckFlush()
tracer.stopTracers()
self.assertTrue(tracer.verb_file.flushed == False)
self.assertTrue(tracer.xml_file.flushed == True)
self.assertTrue(tracer.vcd_file.flushed == False)
tracer = Tracers()
tracer.verbose = False
tracer.xml = False
tracer.vcd = True
tracer.verb_file = CheckFlush()
tracer.xml_file = CheckFlush()
tracer.vcd_file = CheckFlush()
tracer.stopTracers()
self.assertTrue(tracer.verb_file.flushed == False)
self.assertTrue(tracer.xml_file.flushed == False)
self.assertTrue(tracer.vcd_file.flushed == True)
tracer = Tracers()
tracer.verbose = True
tracer.xml = True
tracer.vcd = True
tracer.verb_file = CheckFlush()
tracer.xml_file = CheckFlush()
tracer.vcd_file = CheckFlush()
tracer.stopTracers()
self.assertTrue(tracer.verb_file.flushed == True)
self.assertTrue(tracer.xml_file.flushed == True)
self.assertTrue(tracer.vcd_file.flushed == True)

124
test/testWait.py Normal file
View file

@ -0,0 +1,124 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from testutils import *
from pypdevs.basesimulator import BaseSimulator
class TestWait(unittest.TestCase):
def setUp(self):
self.sim = basicSim()
def tearDown(self):
self.sim.run_gvt = False
def checkWait(self, finish):
self.checkWaitStart()
self.checkWaitStop(finish)
def checkWaitStart(self):
# A thread, otherwise the state of the lock cannot be checked
# Though this is somewhat more difficult to terminate...
self.proc = threading.Thread(target=BaseSimulator.waitUntilOK,
args=[self.sim, 0])
self.proc.start()
def checkWaitStop(self, finish=True):
# Give it not too much time to finish
self.proc.join(0.1)
# Still running, but shouldn't finish --> OK
if self.proc.is_alive() and not finish:
return
# Still running, but should finish --> NOK
elif self.proc.is_alive() and finish: #pragma: nocover
# Force thread shutdown
self.sim.V[0] = float('inf')
self.sim.Vchange.set()
self.fail("Thread should finish, but was not finished")
# No longer running, and should finish --> OK
elif not self.proc.is_alive() and finish:
return
# No longer running, but should not finish --> NOK
elif not self.proc.is_alive() and not finish: #pragma: nocover
self.fail("Thread should keep running, but has finished")
def test_GVT_wait(self):
# Run a seperate thread for the waiting,
# after each modification, we just check wheter it is still live
self.sim.Vlock.acquire()
self.sim.V = [{0: 0}, {}]
self.sim.control_msg = [0, 0, {0: 0}]
self.checkWait(finish=True)
self.sim.V = [{0: -3}, {}]
self.sim.control_msg = [0, 0, {0: 0}]
self.checkWait(finish=True)
self.sim.V = [{0: -3}, {}]
self.sim.control_msg = [0, 0, {0: -4}]
self.checkWait(finish=True)
self.sim.V = [{0: 0}, {}]
self.sim.control_msg = [0, 0, {0: -5}]
self.checkWait(finish=True)
self.sim.V = [{0: 3}, {}]
self.sim.control_msg = [0, 0, {0: -3}]
self.checkWait(finish=True)
self.sim.V = [{0: -3}, {}]
self.sim.control_msg = [0, 0, {0: 3}]
self.checkWait(finish=True)
self.sim.V = [{0: 1}, {}]
self.sim.control_msg = [0, 0, {0: 0}]
self.checkWait(finish=False)
self.sim.notifyReceive(False)
self.checkWaitStop(finish=True)
self.sim.V = [{0: 0}, {}]
self.sim.control_msg = [0, 0, {0: 1}]
self.checkWait(finish=False)
self.sim.notifyReceive(False)
self.checkWaitStop(finish=True)
self.sim.V = [{0: 3}, {}]
self.sim.control_msg = [0, 0, {0: -2}]
self.checkWait(finish=False)
self.sim.notifyReceive(False)
self.checkWaitStop(finish=True)
# Should stop at exactly the correct time
self.sim.V = [{0: -3}, {}]
self.sim.control_msg = [0, 0, {0: 6}]
self.checkWait(finish=False)
self.sim.notifyReceive(False)
self.checkWaitStop(finish=False)
self.sim.notifyReceive(False)
self.checkWaitStop(finish=False)
self.sim.notifyReceive(False)
self.checkWaitStop(finish=True)
# Do multiple receives at once
self.sim.V = [{0: -3}, {}]
self.sim.control_msg = [0, 0, {0: 6}]
self.checkWait(finish=False)
self.sim.notifyReceive(False)
self.sim.notifyReceive(False)
self.sim.notifyReceive(False)
self.checkWaitStop(finish=True)

58
test/test_basic.py Normal file
View file

@ -0,0 +1,58 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import subprocess
import os
import sys
from testMessageScheduler import TestMessageScheduler
from testScheduler import TestScheduler
from testActions import TestActions
from testHelpers import TestHelpers
from testGVT import TestGVT
from testWait import TestWait
from testExceptions import TestExceptions
from testLocal import TestLocal
from testTermination import TestTermination
from testTestUtils import TestTestUtils
from testLogger import TestLogger
if __name__ == '__main__':
local = unittest.TestLoader().loadTestsFromTestCase(TestLocal)
actions = unittest.TestLoader().loadTestsFromTestCase(TestActions)
termination = unittest.TestLoader().loadTestsFromTestCase(TestTermination)
gvt = unittest.TestLoader().loadTestsFromTestCase(TestGVT)
exceptions = unittest.TestLoader().loadTestsFromTestCase(TestExceptions)
wait = unittest.TestLoader().loadTestsFromTestCase(TestWait)
helpers = unittest.TestLoader().loadTestsFromTestCase(TestHelpers)
scheduler = unittest.TestLoader().loadTestsFromTestCase(TestScheduler)
mscheduler = unittest.TestLoader().loadTestsFromTestCase(TestMessageScheduler)
testutils = unittest.TestLoader().loadTestsFromTestCase(TestTestUtils)
logger = unittest.TestLoader().loadTestsFromTestCase(TestLogger)
allTests = unittest.TestSuite()
allTests.addTest(testutils)
allTests.addTest(actions)
allTests.addTest(helpers)
allTests.addTest(gvt)
allTests.addTest(termination)
allTests.addTest(exceptions)
allTests.addTest(wait)
allTests.addTest(scheduler)
allTests.addTest(logger)
allTests.addTest(local)
unittest.TextTestRunner(verbosity=2, failfast=True).run(allTests)

30
test/test_mpi.py Normal file
View file

@ -0,0 +1,30 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import subprocess
import os
import sys
from testMPI import TestMPI
if __name__ == '__main__':
import mpi4py
mpi = unittest.TestLoader().loadTestsFromTestCase(TestMPI)
allTests = unittest.TestSuite()
allTests.addTest(mpi)
unittest.TextTestRunner(verbosity=2, failfast=True).run(allTests)

27
test/test_realtime.py Normal file
View file

@ -0,0 +1,27 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import subprocess
import os
import sys
from testRealtime import TestRealtime
if __name__ == '__main__':
realtime = unittest.TestLoader().loadTestsFromTestCase(TestRealtime)
allTests = unittest.TestSuite()
allTests.addTest(realtime)
unittest.TextTestRunner(verbosity=2, failfast=True).run(allTests)

View file

@ -0,0 +1,338 @@
#! /bin/env python
#import stacktracer
#stacktracer.trace_start("trace.html",interval=1,auto=True) # Set auto flag to always update file!
try:
from mpi4py import MPI
except ImportError:
pass
import models
import sys
from pypdevs.simulator import Simulator, loadCheckpoint
mn = sys.argv[1]
args = {}
args["setTerminationTime"] = [40]
args["setVerbose"] = ["output/" + mn.partition("_local")[0]]
run = True
def counter(t, m):
return m.processor2.coupled[0].state.counter != float('inf')
def counter_pull(t, m):
s = m.processor1.coupled[0].getState(t)
print(s.counter)
return s.counter != float('inf')
if mn == "confluent":
model = models.Chain(1.00)
elif mn == "confluent_local":
model = models.Chain_local(1.00)
elif mn == "rollback":
args["setTerminationTime"] = [20000]
model = models.Chain_bad()
elif mn == "normal_long":
args["setTerminationTime"] = [20000]
#args["setVerbose"] = [False]
model = models.Chain(0.66)
elif mn == "normal_long_local":
args["setTerminationTime"] = [20000]
#args["setVerbose"] = [False]
model = models.Chain_local(0.66)
elif mn == "dualdepth":
model = models.DualDepth(0.66)
elif mn == "dualdepth_local":
model = models.DualDepth_local(0.66)
elif mn == "dual":
model = models.DualChain(0.66)
elif mn == "dual_local":
model = models.DualChain_local(0.66)
elif mn == "dual_mp":
model = models.DualChainMP(0.66)
elif mn == "dual_mp_local":
model = models.DualChainMP_local(0.66)
elif mn == "local":
model = models.Local()
elif mn == "local_local":
model = models.Local()
elif mn == "longtime":
model = models.Chain(0.66)
args["setTerminationTime"] = [200]
elif mn == "longtime_local":
model = models.Chain_local(0.66)
args["setTerminationTime"] = [200]
elif mn == "atomic_local":
model = models.Generator()
elif mn == "multi":
model = models.Chain(0.50)
elif mn == "multi_local":
model = models.Chain_local(0.50)
elif mn == "multinested":
model = models.MultiNested()
args["setTerminationTime"] = [10]
elif mn == "nested_local":
model = models.Nested_local()
args["setTerminationTime"] = [20]
elif mn == "nested_realtime_local":
model = models.Nested_local()
args["setTerminationTime"] = [20]
args["setRealTime"] = [True]
args["setRealTimePorts"] = [{}]
args["setRealTimePlatformThreads"] = []
elif mn == "remotedc":
model = models.RemoteDC()
elif mn == "remotedc_long":
args["setTerminationTime"] = [200]
model = models.RemoteDC()
elif mn == "normal":
model = models.Chain(0.66)
elif mn == "allocate":
args["setTerminationTime"] = [10000]
args["setGreedyAllocator"] = []
#args["setDrawModel"] = [True, "model.dot", False]
model = models.Chain(0.66)
elif mn == "normal_local":
model = models.Chain_local(0.66)
elif mn == "zeroLookahead":
model = models.Chain(0.00)
elif mn == "zeroLookahead_local":
model = models.Chain_local(0.00)
elif mn == "stateStop":
model = models.Chain(0.66)
args["setTerminationModel"] = [model.processor2.coupled[0]]
args["setTerminationCondition"] = [counter]
del args["setTerminationTime"]
elif mn == "stateStop_local":
model = models.Chain_local(0.66)
args["setTerminationModel"] = [model.processor2.coupled[0]]
args["setTerminationCondition"] = [counter]
del args["setTerminationTime"]
elif mn == "checkpoint":
model = models.Chain(0.66)
args["setTerminationTime"] = [2000]
args["setCheckpointing"] = ["testing", 1]
if loadCheckpoint("testing") is not None:
run = False
elif mn == "checkpoint_long":
model = models.Chain(0.66)
args["setTerminationTime"] = [20000]
args["setCheckpointing"] = ["testing", 1]
if loadCheckpoint("testing") is not None:
run = False
elif mn == "checkpoint_long_local":
model = models.Chain_local(0.66)
args["setTerminationTime"] = [20000]
args["setCheckpointing"] = ["testing", 1]
if loadCheckpoint("testing") is not None:
run = False
elif mn == "autodist":
model = models.AutoDistChain(3, totalAtomics=500, iterations=1)
elif mn == "autodist_original":
from mpi4py import MPI
model = models.AutoDistChain(MPI.COMM_WORLD.Get_size(), totalAtomics=500, iterations=1)
elif mn == "autodist_checkpoint":
from mpi4py import MPI
model = models.AutoDistChain(MPI.COMM_WORLD.Get_size(), totalAtomics=500, iterations=1)
args["setTerminationTime"] = [200]
args["setShowProgress"] = []
args["setCheckpointing"] = ["testing", 1]
if loadCheckpoint("testing") is not None:
run = False
elif mn == "relocation":
model = models.Chain(0.66)
args["setTerminationTime"] = [2000]
args["setRelocationDirectives"] = [[[500, model.processor1.coupled[0], 0], [1000, model.processor1.coupled[0], 2]]]
args["setGVTInterval"] = [1]
elif mn == "relocation_activity":
model = models.Chain(0.66)
args["setTerminationTime"] = [20000]
args["setActivityRelocatorBasicBoundary"] = [1.2]
del args["setVerbose"]
args["setGVTInterval"] = [2]
elif mn == "relocation_noactivity":
model = models.Chain(0.66)
args["setTerminationTime"] = [20000]
del args["setVerbose"]
args["setGVTInterval"] = [2]
elif mn == "boundary":
model = models.Boundary()
args["setTerminationTime"] = [2000]
args["setRelocationDirectives"] = [[[100, 2, 0]]]
args["setGVTInterval"] = [1]
elif mn == "relocation_faster":
model = models.Chain(0.66)
del args["setVerbose"]
args["setTerminationTime"] = [20000]
args["setRelocationDirectives"] = [[[0, model.processor1.coupled[0], 1], [0, model.processor2.coupled[0], 2], [0, model.processor2.coupled[1], 2]]]
elif mn.startswith("realtime"):
from trafficLightModel import *
model = TrafficSystem(name="trafficSystem")
refs = {"INTERRUPT": model.trafficLight.INTERRUPT}
args["setVerbose"] = ["output/realtime"]
args["setTerminationTime"] = [35]
if "0.5" in mn:
scale = 0.5
elif "2.0" in mn:
scale = 2.0
else:
scale = 1.0
args["setRealTime"] = [True, scale]
args["setRealTimeInputFile"] = ["testmodels/input"]
args["setRealTimePorts"] = [refs]
if mn.startswith("realtime_thread"):
args["setRealTimePlatformThreads"] = []
elif mn.startswith("realtime_loop"):
args["setRealTimePlatformGameLoop"] = []
elif mn.startswith("realtime_tk"):
from Tkinter import *
myTk = Tk()
args["setRealTimePlatformTk"] = [myTk]
else:
print("Unknown subsystem requested")
sys.exit(1)
elif mn == "progress":
model = models.Chain(0.66)
args["setShowProgress"] = []
args["setTerminationTime"] = [2000]
elif mn == "progress_local":
model = models.Chain_local(0.66)
args["setShowProgress"] = []
args["setTerminationTime"] = [2000]
elif mn == "trace":
model = models.Binary()
args["setVCD"] = ["devstrace.vcd"]
args["setXML"] = ["devstrace.xml"]
elif mn == "trace_local":
model = models.Binary_local()
args["setVCD"] = ["devstrace.vcd"]
args["setXML"] = ["devstrace.xml"]
elif mn == "fetch":
model = models.Chain(0.66)
args["setFetchAllAfterSimulation"] = []
elif mn == "draw":
model = models.Chain(0.66)
args["setDrawModel"] = [True]
elif mn == "draw_local":
model = models.Chain_local(0.66)
args["setDrawModel"] = [True]
elif mn == "auto_allocate":
# Take the local variant, as this does not contain location info
model = models.Chain_local(0.66)
args["setDrawModel"] = [True]
args["setAutoAllocator"] = []
elif mn == "multiinputs":
model = models.MultipleInputs()
elif mn == "multiinputs_local":
model = models.MultipleInputs_local()
elif mn == "doublelayer_local":
model = models.DoubleLayerRoot()
elif mn == "dynamicstructure_local":
model = models.DSDEVSRoot()
args["setDSDEVS"] = [True]
elif mn == "dynamicstructure_realtime_local":
model = models.DSDEVSRoot()
args["setRealTime"] = [True]
args["setRealTimePorts"] = [{}]
args["setRealTimePlatformThreads"] = []
args["setDSDEVS"] = [True]
elif mn == "classicDEVS_local":
model = models.ClassicCoupled()
args["setClassicDEVS"] = [True]
elif mn == "classicDEVSconnect_local":
model = models.AllConnectClassic()
args["setClassicDEVS"] = [True]
elif mn == "random":
model = models.RandomCoupled()
elif mn == "random_local":
model = models.RandomCoupled_local()
elif mn == "stateStop_pull":
model = models.Chain(0.66)
args["setTerminationCondition"] = [counter_pull]
del args["setTerminationTime"]
elif mn.startswith("reinit"):
model = models.AutoDistChain(3, totalAtomics=500, iterations=1)
if "local" in mn:
model.forceSequential()
sim = Simulator(model)
sim.setAllowLocalReinit(True)
sim.setTerminationTime(40)
sim.setVerbose("output/reinit1")
sim.simulate()
sim.reinit()
sim.setVerbose("output/reinit2")
sim.setModelStateAttr(model.generator.generator, "value", 2)
sim.simulate()
sim.reinit()
sim.setVerbose("output/reinit3")
sim.setModelStateAttr(model.generator.generator, "value", 3)
sim.simulate()
run = False
elif mn.startswith("multisim"):
if "local" in mn:
sim = Simulator(models.Chain_local(0.66))
else:
sim = Simulator(models.Chain(0.66))
sim.setVerbose("output/normal")
sim.setTerminationTime(40)
sim.simulate()
if "local" in mn:
sim2 = Simulator(models.DualDepth_local(0.66))
else:
sim2 = Simulator(models.DualDepth(0.66))
sim2.setVerbose("output/dualdepth")
sim2.setTerminationTime(40)
sim2.simulate()
run = False
elif mn.startswith("continue"):
if "local" in mn:
sim = Simulator(models.Chain_local(0.66))
else:
sim = Simulator(models.Chain(0.66))
sim.setVerbose("output/run1")
sim.setTerminationTime(100.0)
sim.simulate()
sim.setModelStateAttr(sim.model.generator.generator, "value", 2)
sim.setVerbose("output/run2")
sim.setTerminationTime(200.0)
sim.simulate()
run = False
elif mn.startswith("z"):
if "local" in mn:
model = models.ZChain_local()
else:
model = models.ZChain()
if run:
sim = Simulator(model)
for arg in args.keys():
function = getattr(sim, arg)
function(*args[arg])
sim.simulate()
if mn.startswith("realtime_loop"):
# Start a game loop ourselves
import time
start_time = time.time()
while time.time() < start_time + 35.5 * scale:
before = time.time()
sim.realtime_loop_call()
time.sleep(0.001 - (before - time.time()))
elif mn.startswith("realtime_tk"):
myTk.after(int(35000 * scale), myTk.quit)
myTk.mainloop()
elif mn.startswith("realtime_thread"):
import time
time.sleep((35+0.2) * scale)
elif "realtime" in mn:
import time
time.sleep(args["setTerminationTime"][0])
elif mn == "fetch":
f = open(args["setVerbose"][0], 'w')
f.write("Generator: " + str(model.generator.generator.state) + "\n")
f.write("Processor1.Processor1: " + str(model.processor1.coupled[0].state) + "\n")
f.write("Processor1.Processor2: " + str(model.processor1.coupled[1].state) + "\n")
f.write("Processor2.Processor1: " + str(model.processor2.coupled[0].state) + "\n")
f.write("Processor2.Processor2: " + str(model.processor2.coupled[1].state) + "\n")
f.write("Processor2.Processor3: " + str(model.processor2.coupled[2].state) + "\n")
f.close()

View file

@ -0,0 +1,109 @@
from pypdevs.DEVS import AtomicDEVS, CoupledDEVS
from pypdevs.simulator import Simulator
class Root(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Root")
self.listener_A = self.addInPort("listener_A")
self.output_A = self.addOutPort("output_A")
self.mini = self.addSubModel(Mini())
self.connectPorts(self.listener_A, self.mini.listener_B)
self.connectPorts(self.mini.output_B, self.output_A)
class Mini(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Mini")
self.listener_B = self.addInPort("listener_B")
self.output_B = self.addOutPort("output_B")
self.model_one = self.addSubModel(Proc("C"))
self.model_two = self.addSubModel(Proc("D"))
self.connectPorts(self.listener_B, self.model_one.inport)
self.connectPorts(self.listener_B, self.model_two.inport)
self.connectPorts(self.model_one.outport, self.output_B)
class Proc(AtomicDEVS):
def __init__(self, name):
AtomicDEVS.__init__(self, "Proc_%s" % name)
self.inport = self.addInPort("listener_%s" % name)
self.outport = self.addOutPort("output_%s" % name)
self.state = None
def intTransition(self):
return None
def extTransition(self, inputs):
return inputs[self.inport][0]
def outputFnc(self):
return {self.outport: [self.state]}
def timeAdvance(self):
return 0.0 if self.state else float('inf')
model = Root()
sim = Simulator(model)
sim.setRealTime(True)
sim.setRealTimePorts({"input_A": model.listener_A,
"input_B": model.mini.listener_B,
"input_C": model.mini.model_one.inport,
"input_D": model.mini.model_two.inport,
"output_A": model.output_A,
"output_B": model.mini.output_B,
"output_C": model.mini.model_one.outport,
"output_D": model.mini.model_two.outport})
sim.setRealTimePlatformThreads()
def output_on_A(evt):
global on_A
on_A = evt[0]
def output_on_B(evt):
global on_B
on_B = evt[0]
sim.setListenPorts(model.output_A, output_on_A)
sim.setListenPorts(model.mini.output_B, output_on_B)
sim.simulate()
import time
on_A = None
on_B = None
sim.realtime_interrupt("input_A 1")
time.sleep(1)
if not (on_A == "1" and on_B == "1"):
raise Exception("Expected input on A or B output port")
on_A = None
on_B = None
sim.realtime_interrupt("input_B 2")
time.sleep(1)
if not (on_A == "2" and on_B == "2"):
print(on_A)
print(type(on_A))
print(on_B)
print(type(on_B))
raise Exception("Expected input on A and B output port")
on_A = None
on_B = None
sim.realtime_interrupt("input_C 3")
time.sleep(1)
if not (on_A == "3" and on_B == "3"):
print(on_A)
print(on_B)
raise Exception("Expected input on A or B output port")
on_A = None
on_B = None
sim.realtime_interrupt("input_D 4")
time.sleep(1)
if not (on_A == None and on_B == None):
raise Exception("Didn't expect input on A or B output port")

3
test/testmodels/input Normal file
View file

@ -0,0 +1,3 @@
10 INTERRUPT toManual
20 INTERRUPT toAutonomous
30 INTERRUPT toManual

939
test/testmodels/models.py Normal file
View file

@ -0,0 +1,939 @@
import sys
import os.path
from pypdevs.infinity import *
from pypdevs.DEVS import AtomicDEVS, CoupledDEVS
class Event(object):
def __init__(self, eventSize):
self.eventSize = eventSize
def __str__(self):
return "Eventsize = " + str(self.eventSize)
class ModelState(object):
def __init__(self):
self.counter = INFINITY
self.event = None
def __str__(self):
return str(self.counter)
def toXML(self):
return "<counter>" + str(self.counter) + "</counter>"
class ProcessorNPP(AtomicDEVS):
def __init__(self, name = "Processor", t_event1 = 1):
AtomicDEVS.__init__(self, name)
self.t_event1 = t_event1
self.inport = self.addInPort("inport")
self.outport = self.addOutPort("outport")
self.state = ModelState()
def timeAdvance(self):
return self.state.counter
def intTransition(self):
self.state.counter -= self.timeAdvance()
if self.state.counter == 0:
self.state.counter = INFINITY
self.state.event = None
return self.state
def extTransition(self, inputs):
self.state.counter -= self.elapsed
ev1 = inputs[self.inport][0]
if ev1 != None:
self.state.event = ev1
self.state.counter = self.t_event1
return self.state
def outputFnc(self):
output = {}
mini = self.state.counter
if self.state.counter == mini:
output[self.outport] = [self.state.event]
return output
class RemoteDCProcessor(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "RemoteDCProcessor")
mod = self.addSubModel(CoupledProcessor(1, 1), 2)
self.inport = self.addInPort("inport")
self.outport = self.addOutPort("outport")
self.connectPorts(self.inport, mod.inport)
self.connectPorts(mod.outport, self.outport)
class Processor(AtomicDEVS):
def __init__(self, name = "Processor", t_event1 = 1):
AtomicDEVS.__init__(self, name)
self.t_event1 = t_event1
self.inport = self.addInPort("inport")
self.outport = self.addOutPort("outport")
self.state = ModelState()
def timeAdvance(self):
return self.state.counter
def intTransition(self):
self.state.counter -= self.timeAdvance()
if self.state.counter == 0:
self.state.counter = INFINITY
self.state.event = None
return self.state
def extTransition(self, inputs):
self.state.counter -= self.elapsed
ev1 = inputs[self.inport][0]
if ev1 != None:
self.state.event = ev1
self.state.counter = self.t_event1
return self.state
def outputFnc(self):
mini = self.state.counter
if self.state.counter == mini:
return {self.outport: [self.state.event]}
else:
return {}
class HeavyProcessor(AtomicDEVS):
def __init__(self, name = "Processor", t_event1 = 1, iterations = 0):
AtomicDEVS.__init__(self, name)
self.t_event1 = t_event1
self.inport = self.addInPort("inport")
self.outport = self.addOutPort("outport")
self.state = ModelState()
self.iterations = iterations
def timeAdvance(self):
return self.state.counter
def intTransition(self):
self.state.counter -= self.timeAdvance()
# Do lots of work now
stupidcounter = 0
for _ in xrange(self.iterations):
pass
if self.state.counter == 0:
self.state.counter = INFINITY
self.state.event = None
return self.state
def extTransition(self, inputs):
self.state.counter -= self.elapsed
ev1 = inputs[self.inport][0]
stupidcounter = 0
for _ in xrange(self.iterations):
pass
if ev1 != None:
self.state.event = ev1
self.state.counter = self.t_event1
return self.state
def outputFnc(self):
mini = self.state.counter
stupidcounter = 0
for _ in xrange(self.iterations):
pass
if self.state.counter == mini:
return {self.outport: [self.state.event]}
class NestedProcessor(Processor):
def __init__(self, name = "NestedProcessor"):
Processor.__init__(self, name)
self.state.processed = 0
self.state.event = Event(5)
def extTransition(self, inputs):
self.state = Processor.extTransition(self, inputs)
self.state.processed += 1
return self.state
def timeAdvance(self):
from pypdevs.simulator import Simulator
model = CoupledGenerator()
sim = Simulator(model)
sim.setTerminationTime(self.state.processed)
#sim.setVerbose(True)
sim.simulate()
result = max(sim.model.generator.state.generated, 1)
return result
class Generator(AtomicDEVS):
def __init__(self, name = "Generator", t_gen_event1 = 1.0, binary = False):
AtomicDEVS.__init__(self, name)
self.state = ModelState()
# Add an extra variable
self.state.generated = 0
self.state.counter = t_gen_event1
self.state.value = 1
self.t_gen_event1 = t_gen_event1
self.outport = self.addOutPort("outport")
self.inport = self.addInPort("inport")
self.binary = binary
def timeAdvance(self):
return self.state.counter
def intTransition(self):
self.state.generated += 1
return self.state
def extTransition(self, inputs):
self.state.counter -= self.elapsed
return self.state
def outputFnc(self):
if self.binary:
return {self.outport: ["b1"]}
else:
return {self.outport: [Event(self.state.value)]}
class GeneratorNPP(AtomicDEVS):
def __init__(self, name = "Generator", t_gen_event1 = 1.0):
AtomicDEVS.__init__(self, name)
self.state = ModelState()
# Add an extra variable
self.state.generated = 0
self.state.counter = t_gen_event1
self.t_gen_event1 = t_gen_event1
self.outport = self.addOutPort("outport")
self.inport = self.addInPort("inport")
def timeAdvance(self):
return self.state.counter
def intTransition(self):
self.state.generated += 1
return self.state
def extTransition(self, inputs):
self.state.counter -= self.elapsed
return self.state
def outputFnc(self):
return {self.outport: [Event(1)]}
class CoupledGenerator(CoupledDEVS):
def __init__(self, t_gen_event1 = 1, binary = False):
CoupledDEVS.__init__(self, "CoupledGenerator")
self.generator = self.addSubModel(Generator("Generator", t_gen_event1, binary))
self.inport = self.addInPort("inport")
self.outport = self.addOutPort("outport")
self.connectPorts(self.inport, self.generator.inport)
self.connectPorts(self.generator.outport, self.outport)
class CoupledGeneratorNPP(CoupledDEVS):
def __init__(self, t_gen_event1 = 1):
CoupledDEVS.__init__(self, "CoupledGenerator")
self.generator = self.addSubModel(GeneratorNPP("Generator", t_gen_event1))
self.inport = self.addInPort("inport")
self.outport = self.addOutPort("outport")
self.connectPorts(self.inport, self.generator.inport)
self.connectPorts(self.generator.outport, self.outport)
class CoupledHeavyProcessor(CoupledDEVS):
def __init__(self, t_event1_P1, levels, iterations, name = None):
if name == None:
name = "CoupledHeavyProcessor_" + str(levels)
CoupledDEVS.__init__(self, name)
self.inport = self.addInPort("inport")
self.outport = self.addOutPort("outport")
self.coupled = []
for i in range(levels):
self.coupled.append(self.addSubModel(HeavyProcessor("Processor" + str(i), t_event1_P1, iterations)))
for i in range(levels-1):
self.connectPorts(self.coupled[i].outport, self.coupled[i+1].inport)
self.connectPorts(self.inport, self.coupled[0].inport)
self.connectPorts(self.coupled[-1].outport, self.outport)
class CoupledProcessorNPP(CoupledDEVS):
def __init__(self, t_event1_P1, levels):
CoupledDEVS.__init__(self, "CoupledProcessor_" + str(levels))
self.inport = self.addInPort("inport")
self.outport = self.addOutPort("outport")
self.coupled = []
for i in range(levels):
self.coupled.append(self.addSubModel(ProcessorNPP("Processor" + str(i), t_event1_P1)))
for i in range(levels-1):
self.connectPorts(self.coupled[i].outport, self.coupled[i+1].inport)
self.connectPorts(self.inport, self.coupled[0].inport)
self.connectPorts(self.coupled[-1].outport, self.outport)
class CoupledProcessor(CoupledDEVS):
def __init__(self, t_event1_P1, levels):
CoupledDEVS.__init__(self, "CoupledProcessor_" + str(levels))
self.inport = self.addInPort("inport")
self.outport = self.addOutPort("outport")
self.coupled = []
for i in range(levels):
self.coupled.append(self.addSubModel(Processor("Processor" + str(i), t_event1_P1)))
for i in range(levels-1):
self.connectPorts(self.coupled[i].outport, self.coupled[i+1].inport)
self.connectPorts(self.inport, self.coupled[0].inport)
self.connectPorts(self.coupled[-1].outport, self.outport)
class CoupledProcessorMP(CoupledDEVS):
def __init__(self, t_event1_P1):
CoupledDEVS.__init__(self, "CoupledProcessorMP")
self.inport = self.addInPort("inport")
p1 = self.addSubModel(Processor("Processor1", t_event1_P1))
p2 = self.addSubModel(Processor("Processor2", t_event1_P1))
p3 = self.addSubModel(Processor("Processor3", t_event1_P1))
p4 = self.addSubModel(Processor("Processor4", t_event1_P1))
self.connectPorts(self.inport, p1.inport)
self.connectPorts(self.inport, p3.inport)
self.connectPorts(p1.outport, p2.inport)
self.connectPorts(p3.outport, p4.inport)
class Binary(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Binary")
self.generator = self.addSubModel(CoupledGenerator(1.0, True))
self.processor1 = self.addSubModel(CoupledProcessor(0.6, 2), 2)
self.processor2 = self.addSubModel(CoupledProcessor(0.30, 3), 1)
self.connectPorts(self.generator.outport, self.processor1.inport)
self.connectPorts(self.processor1.outport, self.processor2.inport)
class Binary_local(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Binary")
self.generator = self.addSubModel(CoupledGenerator(1.0, True))
self.processor1 = self.addSubModel(CoupledProcessor(0.6, 2))
self.processor2 = self.addSubModel(CoupledProcessor(0.30, 3))
self.connectPorts(self.generator.outport, self.processor1.inport)
self.connectPorts(self.processor1.outport, self.processor2.inport)
class Chain_local(CoupledDEVS):
def __init__(self, ta):
CoupledDEVS.__init__(self, "Chain")
self.generator = self.addSubModel(CoupledGenerator(1.0))
self.processor1 = self.addSubModel(CoupledProcessor(ta, 2))
self.processor2 = self.addSubModel(CoupledProcessor(0.30, 3))
self.connectPorts(self.generator.outport, self.processor1.inport)
self.connectPorts(self.processor1.outport, self.processor2.inport)
class Chain(CoupledDEVS):
def __init__(self, ta):
CoupledDEVS.__init__(self, "Chain")
self.generator = self.addSubModel(CoupledGenerator(1.0), 1)
self.processor1 = self.addSubModel(CoupledProcessor(ta, 2), 2)
self.processor2 = self.addSubModel(CoupledProcessor(0.30, 3))
self.connectPorts(self.generator.outport, self.processor1.inport)
self.connectPorts(self.processor1.outport, self.processor2.inport)
class Boundary(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Boundary")
self.generator = self.addSubModel(CoupledGenerator(1.0), 1)
self.processor1 = self.addSubModel(CoupledProcessor(0.60, 2), 2)
self.processor2 = self.addSubModel(CoupledProcessor(0.30, 4), 3)
self.processor3 = self.addSubModel(CoupledProcessor(0.30, 3))
self.connectPorts(self.generator.outport, self.processor1.inport)
self.connectPorts(self.processor1.outport, self.processor2.inport)
self.connectPorts(self.processor1.outport, self.processor3.inport)
self.connectPorts(self.processor2.outport, self.processor3.inport)
class Two(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Two")
self.generator = self.addSubModel(CoupledGenerator(1.0), 1)
self.processor1 = self.addSubModel(CoupledProcessor(0.30, 3))
self.connectPorts(self.generator.outport, self.processor1.inport)
class DualChain_local(CoupledDEVS):
def __init__(self, ta):
CoupledDEVS.__init__(self, "DualChain")
self.generator = self.addSubModel(CoupledGenerator(1.0))
self.processor1 = self.addSubModel(CoupledProcessor(ta, 2))
self.processor2 = self.addSubModel(CoupledProcessor(0.30, 3))
self.connectPorts(self.generator.outport, self.processor1.inport)
self.connectPorts(self.generator.outport, self.processor2.inport)
class DualChain(CoupledDEVS):
def __init__(self, ta):
CoupledDEVS.__init__(self, "DualChain")
self.generator = self.addSubModel(CoupledGenerator(1.0), 1)
self.processor1 = self.addSubModel(CoupledProcessor(ta, 2), 2)
self.processor2 = self.addSubModel(CoupledProcessor(0.30, 3))
self.connectPorts(self.generator.outport, self.processor1.inport)
self.connectPorts(self.generator.outport, self.processor2.inport)
class DualChainMP_local(CoupledDEVS):
def __init__(self, ta):
CoupledDEVS.__init__(self, "DualChainMP")
self.generator = self.addSubModel(CoupledGenerator(1.0))
self.processor1 = self.addSubModel(CoupledProcessorMP(0.66))
self.connectPorts(self.generator.outport, self.processor1.inport)
class DualChainMP(CoupledDEVS):
def __init__(self, ta):
CoupledDEVS.__init__(self, "DualChainMP")
self.generator = self.addSubModel(CoupledGenerator(1.0), 1)
self.processor1 = self.addSubModel(CoupledProcessorMP(0.66), 2)
self.connectPorts(self.generator.outport, self.processor1.inport)
class DualDepthProcessor_local(CoupledDEVS):
def __init__(self, ta):
CoupledDEVS.__init__(self, "DualDepthProcessor")
self.inport = self.addInPort("inport")
self.outport = self.addOutPort("outport")
self.processor1 = self.addSubModel(CoupledProcessor(ta, 1))
self.processor2 = self.addSubModel(CoupledProcessor(ta, 2))
self.connectPorts(self.inport, self.processor1.inport)
self.connectPorts(self.processor1.outport, self.processor2.inport)
self.connectPorts(self.processor2.outport, self.outport)
class DualDepthProcessor(CoupledDEVS):
def __init__(self, ta):
CoupledDEVS.__init__(self, "DualDepthProcessor")
self.inport = self.addInPort("inport")
self.outport = self.addOutPort("outport")
self.processor1 = self.addSubModel(CoupledProcessor(ta, 1), 2)
self.processor2 = self.addSubModel(CoupledProcessor(ta, 2))
self.connectPorts(self.inport, self.processor1.inport)
self.connectPorts(self.processor1.outport, self.processor2.inport)
self.connectPorts(self.processor2.outport, self.outport)
class DualDepth_local(CoupledDEVS):
def __init__(self, ta):
CoupledDEVS.__init__(self, "DualDepth")
self.generator = self.addSubModel(Generator("Generator", 1.0))
self.processor = self.addSubModel(DualDepthProcessor_local(ta))
self.connectPorts(self.generator.outport, self.processor.inport)
class DualDepth(CoupledDEVS):
def __init__(self, ta):
CoupledDEVS.__init__(self, "DualDepth")
self.generator = self.addSubModel(Generator("Generator", 1.0))
self.processor = self.addSubModel(DualDepthProcessor(ta), 1)
self.connectPorts(self.generator.outport, self.processor.inport)
class Nested_local(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Nested")
self.generator = self.addSubModel(Generator("Generator", 1))
self.processor = self.addSubModel(NestedProcessor("NProcessor"))
self.connectPorts(self.generator.outport, self.processor.inport)
class MultiNested(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "MultiNested")
self.generator = self.addSubModel(Generator("Generator", 1))
self.processor1 = self.addSubModel(NestedProcessor("NProcessor1"), 1)
self.processor2 = self.addSubModel(NestedProcessor("NProcessor2"), 2)
self.connectPorts(self.generator.outport, self.processor1.inport)
self.connectPorts(self.processor1.outport, self.processor2.inport)
class Local(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Local")
self.generator = self.addSubModel(Generator("Generator", 1))
self.processor1 = self.addSubModel(CoupledProcessor(1, 2))
self.processor2 = self.addSubModel(CoupledProcessor(1, 3))
self.connectPorts(self.generator.outport, self.processor1.inport)
self.connectPorts(self.processor1.outport, self.processor2.inport)
class OptimizableChain(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "OptimizableChain")
self.generator = self.addSubModel(CoupledGenerator(1.0))
self.processor1 = self.addSubModel(CoupledProcessor(0.66, 2), 1)
self.processor2 = self.addSubModel(CoupledProcessor(0.30, 3), 2)
self.connectPorts(self.generator.outport, self.processor1.inport)
self.connectPorts(self.processor1.outport, self.processor2.inport)
class HugeOptimizableChain(CoupledDEVS):
def __init__(self, iterations):
CoupledDEVS.__init__(self, "HugeOptimizableChain")
self.generator = self.addSubModel(CoupledGenerator(1.0))
self.processor0 = self.addSubModel(CoupledHeavyProcessor(0.77, 10, iterations))
self.processor1 = self.addSubModel(CoupledHeavyProcessor(0.66, 10, iterations), 1)
self.processor2 = self.addSubModel(CoupledHeavyProcessor(0.30, 10, iterations), 2)
self.connectPorts(self.generator.outport, self.processor0.inport)
self.connectPorts(self.processor0.outport, self.processor1.inport)
self.connectPorts(self.processor0.outport, self.processor2.inport)
class HugeOptimizableLocalChain(CoupledDEVS):
def __init__(self, iterations):
CoupledDEVS.__init__(self, "HugeOptimizableChain")
self.generator = self.addSubModel(CoupledGenerator(1.0))
self.processor0 = self.addSubModel(CoupledHeavyProcessor(0.77, 10, iterations))
self.processor1 = self.addSubModel(CoupledHeavyProcessor(0.66, 10, iterations))
self.processor2 = self.addSubModel(CoupledHeavyProcessor(0.30, 10, iterations))
self.connectPorts(self.generator.outport, self.processor0.inport)
self.connectPorts(self.processor0.outport, self.processor1.inport)
self.connectPorts(self.processor0.outport, self.processor2.inport)
class LocalLong(CoupledDEVS):
def __init__(self, name):
CoupledDEVS.__init__(self, name)
self.generator = self.addSubModel(Generator("Generator", 1))
self.processor1 = self.addSubModel(CoupledProcessor(0.66, 20))
self.connectPorts(self.generator.outport, self.processor1.inport)
class ParallelChain(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "ParallelChain")
self.processor1 = self.addSubModel(LocalLong('Local1'), 1)
self.processor2 = self.addSubModel(LocalLong('Local2'), 2)
class ParallelLocalChain(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "ParallelLocalChain")
self.processor1 = self.addSubModel(LocalLong('Local1'))
self.processor2 = self.addSubModel(LocalLong('Local2'))
class ChainNoPeekPoke(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "ChainNoPeekPoke")
self.generator = self.addSubModel(CoupledGeneratorNPP(1.0))
self.processor1 = self.addSubModel(CoupledProcessorNPP(0.66, 2))
self.processor2 = self.addSubModel(CoupledProcessorNPP(0.30, 3))
self.connectPorts(self.generator.outport, self.processor1.inport)
self.connectPorts(self.processor1.outport, self.processor2.inport)
class ChainPeekPoke(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "ChainPeekPoke")
self.generator = self.addSubModel(CoupledGenerator(1.0))
self.processor1 = self.addSubModel(CoupledProcessor(0.66, 2))
self.processor2 = self.addSubModel(CoupledProcessor(0.30, 3))
self.connectPorts(self.generator.outport, self.processor1.inport)
self.connectPorts(self.processor1.outport, self.processor2.inport)
class AutoDistChain(CoupledDEVS):
def __init__(self, nodes, totalAtomics, iterations):
CoupledDEVS.__init__(self, "AutoDistChain")
self.generator = self.addSubModel(CoupledGenerator(1.0))
self.processors = []
have = 0
ta = 0.66
for i in range(nodes):
shouldhave = (float(i+1) / nodes) * totalAtomics
num = int(shouldhave - have)
have += num
if i == 0:
self.processors.append(self.addSubModel(CoupledHeavyProcessor(ta, num, iterations, "HeavyProcessor_" + str(i))))
else:
self.processors.append(self.addSubModel(CoupledHeavyProcessor(ta, num, iterations, "HeavyProcessor_" + str(i)), i))
self.connectPorts(self.generator.outport, self.processors[0].inport)
for i in range(len(self.processors)-1):
self.connectPorts(self.processors[i].outport, self.processors[i+1].inport)
class RemoteDC(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Root")
self.generator = self.addSubModel(CoupledGenerator(1.0))
self.processor1 = self.addSubModel(RemoteDCProcessor(), 1)
self.processor2 = self.addSubModel(CoupledProcessor(0.30, 3))
self.connectPorts(self.generator.outport, self.processor1.inport)
self.connectPorts(self.processor1.outport, self.processor2.inport)
class MultipleInputs(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "MultipleInputs")
self.generator = self.addSubModel(Generator(1.0))
self.processors1 = []
for i in xrange(5):
self.processors1.append(self.addSubModel(Processor("1-" + str(i), 0.3), 1))
self.connectPorts(self.generator.outport, self.processors1[-1].inport)
self.processors2 = []
for i in xrange(2):
self.processors2.append(self.addSubModel(Processor("2-" + str(i), 0.3), 2))
for s in self.processors1:
self.connectPorts(s.outport, self.processors2[-1].inport)
class MultipleInputs_local(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "MultipleInputs")
self.generator = self.addSubModel(Generator(1.0))
self.processors1 = []
for i in xrange(5):
self.processors1.append(self.addSubModel(Processor("1-" + str(i), 0.3)))
self.connectPorts(self.generator.outport, self.processors1[-1].inport)
self.processors2 = []
for i in xrange(2):
self.processors2.append(self.addSubModel(Processor("2-" + str(i), 0.3)))
for s in self.processors1:
self.connectPorts(s.outport, self.processors2[-1].inport)
class DoubleLayer1(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Layer1")
self.inport = self.addInPort("inport")
self.processor = self.addSubModel(Processor("Processor", 0.3))
self.connectPorts(self.inport, self.processor.inport)
class DoubleLayer2(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Layer2")
self.lower = self.addSubModel(DoubleLayer1())
self.inport1 = self.addInPort("inport1")
self.inport2 = self.addInPort("inport2")
self.connectPorts(self.inport1, self.lower.inport)
self.connectPorts(self.inport2, self.lower.inport)
class DoubleLayerRoot(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Root")
self.lower = self.addSubModel(DoubleLayer2())
self.generator = self.addSubModel(Generator("Generator", 1))
self.connectPorts(self.generator.outport, self.lower.inport1)
self.connectPorts(self.generator.outport, self.lower.inport2)
class DSDEVSRoot(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Root")
self.submodel = self.addSubModel(GeneratorDS())
self.submodel2 = self.addSubModel(Processor())
self.submodel3 = self.addSubModel(Processor())
self.connectPorts(self.submodel.outport, self.submodel2.inport)
self.connectPorts(self.submodel2.outport, self.submodel3.inport)
self.connectPorts(self.submodel.outport, self.submodel3.inport)
def modelTransition(self, state):
self.removeSubModel(self.submodel2)
self.submodel2 = self.addSubModel(Processor())
self.connectPorts(self.submodel2.outport, self.submodel3.inport)
self.submodel4 = self.addSubModel(CoupledProcessor(0.2, 3))
self.connectPorts(self.submodel3.outport, self.submodel4.inport)
self.submodelX = self.addSubModel(ElapsedNothing())
return False
class ElapsedNothing(AtomicDEVS):
def __init__(self):
AtomicDEVS.__init__(self, "ElapsedNothing")
self.elapsed = 0.3
self.state = 1
def intTransition(self):
return 0
def timeAdvance(self):
return self.state if self.state > 0 else float('inf')
class GeneratorDS(Generator):
def __init__(self):
Generator.__init__(self, "GEN")
self.elapsed = 0.5
def outputFnc(self):
if self.state.generated < 1:
return Generator.outputFnc(self)
else:
return {}
def modelTransition(self, state):
if self.state.generated == 1:
self.removePort(self.outport)
del self.outport
return self.state.generated == 1
class ClassicGenerator(AtomicDEVS):
def __init__(self):
AtomicDEVS.__init__(self, "Generator")
self.state = None
self.outport = self.addOutPort("outport")
def intTransition(self):
return None
def outputFnc(self):
return {self.outport: 1}
def timeAdvance(self):
return 1
class ClassicProcessor(AtomicDEVS):
def __init__(self, name):
AtomicDEVS.__init__(self, "Processor_%s" % name)
self.state = None
self.inport = self.addInPort("inport")
self.outport = self.addOutPort("outport")
def intTransition(self):
return None
def outputFnc(self):
return {self.outport: self.state}
def extTransition(self, inputs):
self.state = inputs[self.inport]
return self.state
def timeAdvance(self):
return (1.0 if self.state is not None else INFINITY)
class ClassicCoupledProcessor(CoupledDEVS):
def __init__(self, it, namecounter):
CoupledDEVS.__init__(self, "CoupledProcessor_%s_%s" % (it, namecounter))
self.inport = self.addInPort("inport")
self.outport = self.addOutPort("outport")
if it != 0:
self.subproc = self.addSubModel(ClassicCoupledProcessor(it-1, 0))
else:
self.subproc = self.addSubModel(ClassicProcessor(0))
self.subproc2 = self.addSubModel(ClassicProcessor(1))
if it != 0:
self.subproc3 = self.addSubModel(ClassicCoupledProcessor(it-1, 2))
else:
self.subproc3 = self.addSubModel(ClassicProcessor(2))
self.connectPorts(self.inport, self.subproc.inport)
self.connectPorts(self.subproc.outport, self.subproc2.inport)
self.connectPorts(self.subproc2.outport, self.subproc3.inport)
self.connectPorts(self.subproc3.outport, self.outport)
def select(self, immChildren):
if self.subproc3 in immChildren:
return self.subproc3
elif self.subproc2 in immChildren:
return self.subproc2
elif self.subproc in immChildren:
return self.subproc
else:
return immChildren[0]
class ClassicCoupled(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Coupled")
self.generator = self.addSubModel(ClassicGenerator())
self.processor = self.addSubModel(ClassicCoupledProcessor(3, 0))
self.connectPorts(self.generator.outport, self.processor.inport)
def select(self, immChildren):
if self.processor in immChildren:
return self.processor
else:
return immChildren[0]
class RandomProcessorState(object):
def __init__(self, seed):
from pypdevs.randomGenerator import RandomGenerator
self.randomGenerator = RandomGenerator(seed)
self.queue = []
self.proctime = self.randomGenerator.uniform(0.3, 3.0)
def __str__(self):
return "Random Processor State -- " + str(self.proctime)
class RandomProcessor(AtomicDEVS):
def __init__(self, seed):
AtomicDEVS.__init__(self, "RandomProcessor_" + str(seed))
self.inport = self.addInPort("inport")
self.outport = self.addOutPort("outport")
self.state = RandomProcessorState(seed)
def intTransition(self):
self.state.queue = self.state.queue[1:]
self.state.proctime = self.state.randomGenerator.uniform(0.3, 3.0)
return self.state
def extTransition(self, inputs):
if self.state.queue:
self.state.proctime -= self.elapsed
self.state.queue.extend(inputs[self.inport])
return self.state
def outputFnc(self):
return {self.outport: [self.state.queue[0]]}
def timeAdvance(self):
if self.state.queue:
return self.state.proctime
else:
return INFINITY
class RandomCoupled(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Coupled")
self.generator = self.addSubModel(Generator())
self.processor1 = self.addSubModel(RandomProcessor(1), 1)
self.processor2 = self.addSubModel(RandomProcessor(2), 2)
self.processor3 = self.addSubModel(RandomProcessor(3))
self.connectPorts(self.generator.outport, self.processor1.inport)
self.connectPorts(self.processor1.outport, self.processor2.inport)
self.connectPorts(self.processor2.outport, self.processor3.inport)
class RandomCoupled_local(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Coupled")
self.generator = self.addSubModel(Generator())
self.processor1 = self.addSubModel(RandomProcessor(1))
self.processor2 = self.addSubModel(RandomProcessor(2))
self.processor3 = self.addSubModel(RandomProcessor(3))
self.connectPorts(self.generator.outport, self.processor1.inport)
self.connectPorts(self.processor1.outport, self.processor2.inport)
self.connectPorts(self.processor2.outport, self.processor3.inport)
class Chain_bad(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Chain")
self.generator = self.addSubModel(CoupledGenerator(1.0), 0)
self.processor1 = self.addSubModel(CoupledProcessor(0.66, 2), 1)
self.processor2 = self.addSubModel(CoupledProcessor(0.66, 3), 2)
self.processor3 = self.addSubModel(CoupledProcessor(0.66, 4), 1)
self.processor4 = self.addSubModel(CoupledProcessor(0.66, 5), 0)
self.processor5 = self.addSubModel(CoupledProcessor(0.30, 6), 2)
self.connectPorts(self.generator.outport, self.processor1.inport)
self.connectPorts(self.processor1.outport, self.processor2.inport)
self.connectPorts(self.processor2.outport, self.processor3.inport)
self.connectPorts(self.processor3.outport, self.processor4.inport)
self.connectPorts(self.processor4.outport, self.processor5.inport)
class GeneratorClassic(AtomicDEVS):
def __init__(self):
AtomicDEVS.__init__(self, "Gen")
self.outport = self.addOutPort("outport")
self.state = True
def intTransition(self):
return False
def outputFnc(self):
return {self.outport: 3}
def timeAdvance(self):
return 1.0 if self.state else INFINITY
class ProcessorClassic1(AtomicDEVS):
def __init__(self):
AtomicDEVS.__init__(self, "P1")
self.inport = self.addInPort("inport")
self.outport = self.addOutPort("outport")
self.state = None
def intTransition(self):
return None
def extTransition(self, inputs):
return inputs[self.inport]
def outputFnc(self):
return {self.outport: self.state}
def timeAdvance(self):
return 1.0 if self.state is not None else INFINITY
class ProcessorClassic2(AtomicDEVS):
def __init__(self):
AtomicDEVS.__init__(self, "P2")
self.inport1 = self.addInPort("inport1")
self.inport2 = self.addInPort("inport2")
self.outport = self.addOutPort("outport")
self.state = (None, None)
def intTransition(self):
return (None, None)
def extTransition(self, inputs):
inp1 = inputs.get(self.inport1, None)
inp2 = inputs.get(self.inport2, None)
return (inp1, inp2)
def outputFnc(self):
return {self.outport: self.state}
def timeAdvance(self):
return 1.0 if self.state[0] is not None or self.state[1] is not None else INFINITY
class ProcessorClassicO2(AtomicDEVS):
def __init__(self):
AtomicDEVS.__init__(self, "PO2")
self.inport = self.addInPort("inport")
self.outport1 = self.addOutPort("outport1")
self.outport2 = self.addOutPort("outport2")
self.state = None
def intTransition(self):
return None
def extTransition(self, inputs):
return inputs[self.inport]
def outputFnc(self):
return {self.outport1: self.state, self.outport2: self.state}
def timeAdvance(self):
return 1.0 if self.state is not None else INFINITY
class ProcessorCoupledClassic(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Coupled")
self.inport1 = self.addInPort("inport1")
self.inport2 = self.addInPort("inport2")
self.outport = self.addOutPort("outport")
self.proc1 = self.addSubModel(ProcessorClassic1())
self.proc2 = self.addSubModel(ProcessorClassic1())
self.connectPorts(self.inport1, self.proc1.inport)
self.connectPorts(self.inport2, self.proc2.inport)
self.connectPorts(self.proc1.outport, self.outport)
self.connectPorts(self.proc2.outport, self.outport)
class AllConnectClassic(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "Root")
self.model1 = self.addSubModel(GeneratorClassic())
self.model2 = self.addSubModel(ProcessorCoupledClassic())
self.model3 = self.addSubModel(ProcessorClassic2())
self.model4 = self.addSubModel(ProcessorClassic1())
self.model5 = self.addSubModel(ProcessorClassicO2())
self.connectPorts(self.model1.outport, self.model2.inport1)
self.connectPorts(self.model1.outport, self.model2.inport2)
self.connectPorts(self.model2.outport, self.model3.inport1)
self.connectPorts(self.model2.outport, self.model3.inport2)
self.connectPorts(self.model3.outport, self.model5.inport)
self.connectPorts(self.model2.outport, self.model4.inport)
self.connectPorts(self.model4.outport, self.model5.inport)
def trans1(inp):
inp.eventSize += 1
return inp
def trans2(inp):
inp.eventSize = 0
return inp
class ZCoupledProcessor(CoupledDEVS):
def __init__(self, num):
CoupledDEVS.__init__(self, "CoupledProcessor_" + str(num))
self.inport = self.addInPort("inport")
self.outport = self.addOutPort("outport")
self.coupled = []
levels = 4
for i in range(levels):
self.coupled.append(self.addSubModel(Processor("Processor" + str(i), 1.0)))
for i in range(levels-1):
self.connectPorts(self.coupled[i].outport, self.coupled[i+1].inport, trans1)
self.connectPorts(self.inport, self.coupled[0].inport)
self.connectPorts(self.coupled[-1].outport, self.outport)
class ZChain_local(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "ROOT")
self.gen = self.addSubModel(Generator())
self.proc1 = self.addSubModel(ZCoupledProcessor(1))
self.proc2 = self.addSubModel(ZCoupledProcessor(2))
self.connectPorts(self.gen.outport, self.proc1.inport)
self.connectPorts(self.gen.outport, self.proc2.inport, trans2)
class ZChain(CoupledDEVS):
def __init__(self):
CoupledDEVS.__init__(self, "ROOT")
self.gen = self.addSubModel(Generator())
self.proc1 = self.addSubModel(ZCoupledProcessor(1), 1)
self.proc2 = self.addSubModel(ZCoupledProcessor(2), 2)
self.connectPorts(self.gen.outport, self.proc1.inport)
self.connectPorts(self.gen.outport, self.proc2.inport, trans2)

38
test/testmodels/reinit.py Normal file
View file

@ -0,0 +1,38 @@
#! /bin/env python
import time
start = time.clock()
print("Starting at time " + str(start))
from mpi4py import MPI
import models
import sys
from pypdevs.simulator import Simulator, loadCheckpoint
model = models.AutoDistChain(3, totalAtomics=500, iterations=1)
sim = Simulator(model)
sim.setAllowLocalReinit(True)
sim.setTerminationTime(40)
sim.setVerbose("output/reinit1")
sim1start = time.clock()
print("Sim 1 started at " + str(sim1start))
sim.simulate()
sim.setReinitStateAttr(model.generator.generator, "value", 2)
sim2start = time.clock()
sim.setRemoveTracers()
sim.setVerbose("output/reinit2")
print("Sim 2 started at " + str(sim2start))
sim.simulate()
sim.setReinitStateAttr(model.generator.generator, "value", 3)
sim3start = time.clock()
print("Sim 3 started at " + str(sim3start))
sim.setRemoveTracers()
sim.setVerbose("output/reinit3")
sim.simulate()
sim3stop = time.clock()
print("Total runtimes: ")
print("Init: " + str(sim1start - start))
print("Sim 1: " + str(sim2start - sim1start))
print("Sim 2: " + str(sim3start - sim2start))
print("Sim 3: " + str(sim3stop - sim3start))

View file

@ -0,0 +1,101 @@
"""Stack tracer for multi-threaded applications.
Usage:
import stacktracer
stacktracer.trace_start("trace.html",interval=5,auto=True) # Set auto flag to always update file!
....
stacktracer.trace_stop()
"""
import sys
import traceback
from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import HtmlFormatter
# Taken from http://bzimmer.ziclix.com/2008/12/17/python-thread-dumps/
def stacktraces():
code = []
for threadId, stack in sys._current_frames().items():
code.append("\n# ThreadID: %s" % threadId)
for filename, lineno, name, line in traceback.extract_stack(stack):
code.append('File: "%s", line %d, in %s' % (filename, lineno, name))
if line:
code.append(" %s" % (line.strip()))
return highlight("\n".join(code), PythonLexer(), HtmlFormatter(
full=False,
# style="native",
noclasses=True,
))
# This part was made by nagylzs
import os
import time
import threading
class TraceDumper(threading.Thread):
"""Dump stack traces into a given file periodically."""
def __init__(self,fpath,interval,auto):
"""
@param fpath: File path to output HTML (stack trace file)
@param auto: Set flag (True) to update trace continuously.
Clear flag (False) to update only if file not exists.
(Then delete the file to force update.)
@param interval: In seconds: how often to update the trace file.
"""
assert(interval>0.1)
self.auto = auto
self.interval = interval
self.fpath = os.path.abspath(fpath)
self.stop_requested = threading.Event()
threading.Thread.__init__(self)
def run(self):
while not self.stop_requested.isSet():
time.sleep(self.interval)
if self.auto or not os.path.isfile(self.fpath):
self.stacktraces()
def stop(self):
self.stop_requested.set()
self.join()
try:
if os.path.isfile(self.fpath):
os.unlink(self.fpath)
except:
pass
def stacktraces(self):
fout = file(self.fpath,"wb+")
try:
fout.write(stacktraces())
finally:
fout.close()
_tracer = None
def trace_start(fpath,interval=5,auto=True):
"""Start tracing into the given file."""
global _tracer
if _tracer is None:
_tracer = TraceDumper(fpath,interval,auto)
_tracer.setDaemon(True)
_tracer.start()
else:
raise Exception("Already tracing to %s"%_tracer.fpath)
def trace_stop():
"""Stop tracing."""
global _tracer
if _tracer is None:
raise Exception("Not tracing, cannot stop.")
else:
_trace.stop()
_trace = None

View file

@ -0,0 +1,339 @@
# -*- coding: Latin-1 -*-
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
# trafficLight.py --- simple Traffic Light example
# --------------------------------
# October 2005
# Hans Vangheluwe
# McGill University (Montréal)
# --------------------------------
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
# Add the directory where pydevs lives to Python's import path
import sys
# Import code for DEVS model representation:
from pypdevs.infinity import *
from pypdevs.DEVS import *
# Import for uniform random number generators
from random import uniform
from random import randint
# ====================================================================== #
class TrafficLightMode:
"""Encapsulates the system's state
"""
###
def __init__(self, current="red"):
"""Constructor (parameterizable).
"""
self.set(current)
def set(self, value="red"):
self.__colour=value
def get(self):
return self.__colour
def __str__(self):
return self.get()
class TrafficLight(AtomicDEVS):
"""A traffic light
"""
###
def __init__(self, name=None):
"""Constructor (parameterizable).
"""
# Always call parent class' constructor FIRST:
AtomicDEVS.__init__(self, name)
# STATE:
# Define 'state' attribute (initial sate):
self.state = TrafficLightMode("red")
# PORTS:
# Declare as many input and output ports as desired
# (usually store returned references in local variables):
self.INTERRUPT = self.addInPort(name="INTERRUPT")
self.OBSERVED = self.addOutPort(name="OBSERVED")
###
def extTransition(self, inputs):
"""External Transition Function."""
# Compute the new state 'Snew' based (typically) on current
# State, Elapsed time parameters and calls to 'self.peek(self.IN)'.
#input = self.peek(self.INTERRUPT)
input = inputs[self.INTERRUPT][0]
state = self.state.get()
if input == "toManual":
if state == "manual":
# staying in manual mode
return TrafficLightMode("manual")
if state in ("red", "green", "yellow"):
return TrafficLightMode("manual")
else:
raise DEVSException(\
"unknown state <%s> in TrafficLight external transition function"\
% state)
if input == "toAutonomous":
if state == "manual":
return TrafficLightMode("red")
else:
raise DEVSException(\
"unknown state <%s> in TrafficLight external transition function"\
% state)
raise DEVSException(\
"unknown input <%s> in TrafficLight external transition function"\
% input)
###
def intTransition(self):
"""Internal Transition Function.
"""
state = self.state.get()
if state == "red":
return TrafficLightMode("green")
elif state == "green":
return TrafficLightMode("yellow")
elif state == "yellow":
return TrafficLightMode("red")
else:
raise DEVSException(\
"unknown state <%s> in TrafficLight internal transition function"\
% state)
###
def outputFnc(self):
"""Output Funtion.
"""
# A colourblind observer sees "grey" instead of "red" or "green".
# BEWARE: ouput is based on the OLD state
# and is produced BEFORE making the transition.
# We'll encode an "observation" of the state the
# system will transition to !
# Send messages (events) to a subset of the atomic-DEVS'
# output ports by means of the 'poke' method, i.e.:
# The content of the messages is based (typically) on current State.
state = self.state.get()
if state == "red":
return {self.OBSERVED: ["grey"]}
#self.poke(self.OBSERVED, "grey")
# NOT self.poke(self.OBSERVED, "grey")
elif state == "green":
return {self.OBSERVED: ["yellow"]}
#self.poke(self.OBSERVED, "yellow")
# NOT self.poke(self.OBSERVED, "grey")
elif state == "yellow":
return {self.OBSERVED: ["grey"]}
#self.poke(self.OBSERVED, "grey")
# NOT self.poke(self.OBSERVED, "yellow")
else:
raise DEVSException(\
"unknown state <%s> in TrafficLight external transition function"\
% state)
###
def timeAdvance(self):
"""Time-Advance Function.
"""
# Compute 'ta', the time to the next scheduled internal transition,
# based (typically) on current State.
state = self.state.get()
if state == "red":
return 3
elif state == "green":
return 2
elif state == "yellow":
return 1
elif state == "manual":
return INFINITY
else:
raise DEVSException(\
"unknown state <%s> in TrafficLight time advance transition function"\
% state)
# ====================================================================== #
class PolicemanMode:
"""Encapsulates the Policeman's state
"""
###
def __init__(self, current="idle"):
"""Constructor (parameterizable).
"""
self.set(current)
def set(self, value="idle"):
self.__mode=value
def get(self):
return self.__mode
def __str__(self):
return self.get()
class Policeman(AtomicDEVS):
"""A policeman producing "toManual" and "toAutonomous" events:
"toManual" when going from "idle" to "working" mode
"toAutonomous" when going from "working" to "idle" mode
"""
###
def __init__(self, name=None):
"""Constructor (parameterizable).
"""
# Always call parent class' constructor FIRST:
AtomicDEVS.__init__(self, name)
# STATE:
# Define 'state' attribute (initial sate):
self.state = PolicemanMode("idle")
# ELAPSED TIME:
# Initialize 'elapsed time' attribute if required
# (by default, value is 0.0):
self.elapsed = 0
# PORTS:
# Declare as many input and output ports as desired
# (usually store returned references in local variables):
self.OUT = self.addOutPort(name="OUT")
###
# Autonomous system (no input ports),
# so no External Transition Function required
#
###
def intTransition(self):
"""Internal Transition Function.
The policeman works forever, so only one mode.
"""
state = self.state.get()
if state == "idle":
return PolicemanMode("working")
elif state == "working":
return PolicemanMode("idle")
else:
raise DEVSException(\
"unknown state <%s> in Policeman internal transition function"\
% state)
###
def outputFnc(self):
"""Output Funtion.
"""
# Send messages (events) to a subset of the atomic-DEVS'
# output ports by means of the 'poke' method, i.e.:
# The content of the messages is based (typically) on current State.
state = self.state.get()
if state == "idle":
return {self.OUT: ["toManual"]}
#self.poke(self.OUT, "toManual")
elif state == "working":
return {self.OUT: ["toAutonomous"]}
#self.poke(self.OUT, "toAutonomous")
else:
raise DEVSException(\
"unknown state <%s> in Policeman output function"\
% state)
###
def timeAdvance(self):
"""Time-Advance Function.
"""
# Compute 'ta', the time to the next scheduled internal transition,
# based (typically) on current State.
state = self.state.get()
if state == "idle":
return 200
elif state == "working":
return 100
else:
raise DEVSException(\
"unknown state <%s> in Policeman time advance function"\
% state)
# ====================================================================== #
class TrafficSystem(CoupledDEVS):
def __init__(self, name=None):
""" A simple traffic system consisting of a Policeman and a TrafficLight.
"""
# Always call parent class' constructor FIRST:
CoupledDEVS.__init__(self, name)
# Declare the coupled model's output ports:
# Autonomous, so no output ports
#self.OUT = self.addOutPort(name="OUT")
# Declare the coupled model's sub-models:
# The Policeman generating interrupts
self.policeman = self.addSubModel(Policeman(name="policeman"))
# The TrafficLight
self.trafficLight = self.addSubModel(TrafficLight(name="trafficLight"))
# Only connect ...
self.connectPorts(self.policeman.OUT, self.trafficLight.INTERRUPT)
#self.connectPorts(self.trafficLight.OBSERVED, self.OUT)
def select(self, immList):
"""Give the Policeman highest priority.
Note how the technique used below can
be generalized to encode priorities based on model type.
To distinguish between models of the same type,
the name or unique ID should be used.
"""
# return the first Policeman instance in the immList
for i in range(len(immList)):
#if immList[i].__class__ == TrafficLight:
if immList[i].__class__ == Policeman:
return immList[i]
# if no Policeman instances found, return the last entry
return immList[-1]
# Alternative: randomly choose among imminent submodels
#return immList[randint(0,len(immList))]
# If the select method is not defined, the immList[0]
# will be chosen by default.
# ====================================================================== #

120
test/testutils.py Normal file
View file

@ -0,0 +1,120 @@
# Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
# McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
sys.path.append('testmodels')
import pypdevs.middleware as middleware
import unittest
import logging
from pypdevs.logger import setLogger
setLogger('None', ('localhost', 514), logging.WARN)
from pypdevs.controller import Controller
import threading
from pypdevs.basesimulator import BaseSimulator
from pypdevs.message import NetworkMessage
from models import *
from collections import defaultdict
class StubController(Controller):
def __init__(self, name):
Controller.__init__(self, name, None, None)
self.reverted = False
# Just don't create an int, as this indicates remote locations
self.destinations = defaultdict(lambda : None)
from pypdevs.relocators.manualRelocator import ManualRelocator
self.relocator = ManualRelocator()
self.initialAllocator = None
def revert(self, a):
self.reverted = True
def receiveControl(self, msg):
thrd = threading.Thread(target=BaseSimulator.receiveControl, args=[self, msg])
thrd.start()
def equalStateVectors(v1, v2):
if len(v1) != len(v2):
return False
for i in range(len(v1)):
if v1[i][0] != v2[i][0]:
return False
if v1[i][1] != v2[i][1]:
return False
# Don't check the state, as this contains addresses
return True
def vcdEqual(f1, f2):
f1 = open(f1, 'r')
f2 = open(f2, 'r')
line = 0
for l1, l2 in zip(f1, f2):
if l1 != l2 and line != 1:
return False
line += 1
return True
def removeFile(f1):
try:
os.remove(f1)
except OSError:
# File was not there, so result is the same
pass
def basicSim():
class StubModel(object):
def __init__(self):
self.local_model_ids = set([0, 1])
class StubServer(object):
def getProxy(self, name):
return None
setLogger('None', ('localhost', 514), logging.WARN)
sim = StubController(0)
# Kernels doesn't really matter in the tests, though use a value > 1 to prevent localised optimisations
sim.server = StubServer()
sim.setGlobals(
tracers=[],
address=('localhost', 514),
loglevel=logging.WARN,
checkpoint_name="(none)",
memoization=False,
statesaver=2,
kernels=3,
checkpoint_frequency=-1,
msg_copy=0)
# Set it so that it should be initialised to a decent prevtime
sim.prevtime = (0, 1)
sim.model = StubModel()
sim.simlock.release()
return sim
def basicMsg():
class StubDEVS(object):
def __init__(self):
self.model_id = 0
class StubPort(object):
def __init__(self):
self.port_id = 0
self.hostDEVS = StubDEVS()
time = 1
age = 1
content = {StubPort(): None}
uuid = 12345
color = False
return NetworkMessage((time, age), content, uuid, color, None)