STEPlib SysML: How To use the IS AP243 Scripts¶
This page explains how to use the Scripts of the STEP architecture to generate the documentation for the IS for AP243. Other pages (in progress) explain the process for other APs which include content for more of the architecture.
Contents:
The image below shows the models in the STEP Extended Architecture that are used by, and generated for, the International Standard documentation.
Contents:
Prerequists¶
Warning
work in progress
DO A SPELL CHECKING BEFORE EXPORTING.
Needs:
java (saxon and tagsoup jar provided)
Python json.tool (for pretty print of JSON schema)
Ruby (for generation of Canonical XMI) and additional Gems:
Ruby 2.5.3 (using an internet connection without proxy/firewall):
gem install mini_portile2 gem install systemu gem install macaddr gem install uuid gem install rubyzip gem install nokogiri
Commands are assuming executingting in cmd window on PC.
Generate the Core model¶
Important
The core model must be generated before running these scripts. See STEPlib SysML: How To use the IS Core Model Scripts.
Export images from MagicDraw¶
Assuming a MagicDraw license is available:
In MagicDraw use the STEPlibutilsMagicDrawexportDiagramsMacro.js to generate the diagram images. see Load Macros for how to load and use macros.
Open each of the following models in turn and run the macro. This should create the png in the folder that contains the dvlp for the model:
- Activity_model/dvlp/Activity_model.mdzip
- Data_planning_model/dvlp/Data_planning_model.mdzip
- Services_model/dvlp/Services_model.mdzip (if required)
- Domain_model_conformance/dvlp/Domain_model_conformance.mdzip (if required)
- Domain_model_TestData/dvlp/Domain_model_TestData.mdzip (if required)
- Domain_model/dvlp/Domain_model
If there is no MagicDraw license, then the macros are not available. In this case the process is to export the diagrams using the inbuilt exporter, then generate and run a batch file which will rename the resultant images.
Open each of the models listed above and then select File > Save As Image
Select all the diagrams and save as png to the model folder without dvlp, overwriting existing files:
when executing the scripts, after the CanonicalGenerateIDsXML labeled rename images if not using the macro.
Todo
find out how to use macros with “reader” MagicDraw. Have checked with normal MagicDraw in evaluation model (i.e. no SysML license) and works OK.
Convert the SysML models to Canonical XMI¶
- Convert MagicDraw mdzip into Canonical XMI.
Todo
NOTE: The top level package needs an annotated element that has the Nnumber for the XSD and XMI plus other text.
Either drag and drop the Application_protocols/AP2xx folder onto the STEPlib/utils/MagicDraw/genXMIFromFolder.bat
Or (if the above fails) execute the following calls:
cd STEPlib/utils/MagicDraw
for /D %i in (../../Application_protocols/AP243/*) do (ruby "to_cxmi.rb" mdzip="../../Application_protocols/AP243/%i/dvlp/%~ni.mdzip" ruby "..\ExpToXMI\to_cxmi.rb" xmi="../../Application_protocols/AP243/%i/%~ni.xmi" ruby "..\ExpToXMI\to_cxmi.rb" xmi="../../Application_protocols/AP243/%i/%~ni.di")
or if that fails hardcode the path:
for /D %i in (C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\*) do (ruby "to_cxmi.rb" mdzip="%i/dvlp/%~ni.mdzip" ruby "..\ExpToXMI\to_cxmi.rb" xmi="%i/%~ni.xmi" ruby "..\ExpToXMI\to_cxmi.rb" xmi="%i/%~ni.di")
or if that fails:
(temp fix as scripts internal relative paths not working)
cd STEPlib/utils/MagicDraw/runFromHereForAP
for /D %i in (../../../Application_protocols/AP243/*) do (ruby "to_cxmi.rb" mdzip="../../../Application_protocols/AP243/%i/dvlp/%~ni.mdzip" ruby "..\..\ExpToXMI\runFromHereForAP\to_cxmi.rb" xmi="../../../Application_protocols/AP243/%i/%~ni.xmi" ruby "..\..\ExpToXMI\runFromHereForAP\to_cxmi.rb" xmi="../../../Application_protocols/AP243/%i/%~ni.di")
.
For some reason the “for /D etc” does or via hard code.
cd STEPlib/utils/MagicDraw
ruby to_cxmi.rb mdzip=C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\Domain_model\dvlp\Domain_model.mdzip
ruby to_cxmi.rb mdzip=C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\Domain_model\dvlp\Domain_model_conformance.mdzip
ruby to_cxmi.rb mdzip=C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\Domain_model\dvlp\Domain_model_TestData.mdzip
ruby to_cxmi.rb mdzip=C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\Concept_model\dvlp\Conceptual_model.mdzip
ruby to_cxmi.rb mdzip=C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\Activity_model\dvlp\Activity_model.mdzip
ruby to_cxmi.rb mdzip=C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\Services_model\dvlp\Services_model.mdzip
cd ../ExpToXMI
ruby to_cxmi.rb xmi=C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\Domain_model\Domain_model.xmi
ruby to_cxmi.rb xmi=C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\Domain_model\Domain_model_conformance.xmi
ruby to_cxmi.rb xmi=C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\Domain_model\Domain_model_TestData.xmi
ruby to_cxmi.rb xmi=C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\Concept_model\Conceptual_model.xmi
ruby to_cxmi.rb xmi=C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\Activity_model\Activity_model.xmi
ruby to_cxmi.rb xmi=C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\Services_model\Services_model.xmi
ruby to_cxmi.rb xmi=C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\Domain_model\Domain_model.di
ruby to_cxmi.rb xmi=C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\Domain_model\Domain_model_conformance.di
ruby to_cxmi.rb xmi=C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\Domain_model\Domain_model_TestData.di
ruby to_cxmi.rb xmi=C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\Concept_model\Conceptual_model.di
ruby to_cxmi.rb xmi=C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\Activity_model\Activity_model.di
ruby to_cxmi.rb xmi=C:\Users\JCROCKFORD1\Documents\Git\ISOBoostGit\ap243branch\STEPlib\Application_protocols\AP243\Services_model\Services_model.di
.
Generate All¶
Important
The core model must be generated before running these scripts. See STEPlib SysML: How To use the IS Core Model Scripts.
Note
The following assume exporting {243} with a short name {mossec}. These should be changed to values appropriate for the documentation being generated.
Initial steps:
- Follow the instructions in Export images from MagicDraw
- Edit the data in ExtractID/VariablesData243.xml and AntPub/VariablesData243.xml
- The cover.htm and the XHTML files in subfolders of AntPub/input/AP243STEPmod_files are not touched and should be edited manually, they are copied as is into the output/data folder.
Todo
convert this into batch script with arguments e.g. for {mossec} and {243} and hardcoded relative paths {Harmo}
Execute the following calls:
del /q AntPub\output\data\application_protocols\mossec /s
del /q AntPub\output\data\domain_models\mossec /s
mkdir AntPub\output\data\application_protocols\mossec
mkdir AntPub\output\data\application_protocols\mossec\pictures
mkdir AntPub\output\data\application_protocols\mossec\refdata
mkdir AntPub\output\data\application_protocols\mossec\sys
mkdir AntPub\output\data\application_protocols\mossec\sys\script
xcopy AntPub\input\script AntPub\output\data\application_protocols\mossec\sys\script /s /e
mkdir AntPub\output\data\domain_models\mossec
mkdir AntPub\output\data\domain_models\mossec\pictures
mkdir AntPub\output\data\domain_models\mossec\refdata
mkdir AntPub\output\data\domain_models\mossec\sys
mkdir AntPub\output\data\domain_models\mossec\sys\script
xcopy AntPub\input\script AntPub\output\data\domain_models\mossec\sys\script /s /e
del /q Antpub\input\maps\*
powershell Compress-Archive -Path ..\Application_protocols\AP243\Domain_model\*.di, ..\Application_protocols\AP243\Domain_model\*.xmi -DestinationPath AntPub\output\data\domain_models\mossec\Domain_model_XMI.zip -Force
powershell Compress-Archive -Path ..\Application_protocols\AP243\refdata\*.owl -Update -DestinationPath AntPub\output\data\domain_models\mossec\Domain_model_XMI.zip
powershell Compress-Archive -Path ..\Core_model\refdata\*.owl -Update -DestinationPath AntPub\output\data\domain_models\mossec\Domain_model_XMI.zip
powershell Compress-Archive -Path ..\Application_protocols\AP243\Activity_model\*.di, ..\Application_protocols\AP243\Activity_model\*.xmi -DestinationPath AntPub\output\data\application_protocols\mossec\Activity_model.zip -Force
powershell Compress-Archive -Path ..\Application_protocols\AP243\Data_planning_model\*.di, ..\Application_protocols\AP243\Data_planning_model\*.xmi -DestinationPath AntPub\output\data\application_protocols\mossec\Data_planning_model.zip -Force
cd ExtractID
del /q output\html\*
java -jar ../saxon9-8-0-6.jar -t VariablesData243.xml CanonicalGenerateIDsXML.xsl
copy output\sysml_models_ids.xml ..\AntPub\input\. /y
//rename images if not using the macro
java -jar ../saxon9-8-0-6.jar -t model_to_generate=DM relativePath=..\..\Application_protocols\AP243\Domain_model ./output/sysml_models_ids.xml CanonicalRenameMDimages.xsl
move output\renameimages.bat ..\..\Application_protocols\AP243\Domain_model\.
..\..\Application_protocols\AP243\Domain_model\renameimages.bat
java -jar ../saxon9-8-0-6.jar -t model_to_generate=AAM relativePath=..\..\Application_protocols\AP243\Activity_model ./output/sysml_models_ids.xml CanonicalRenameMDimages.xsl
move output\renameimages.bat ..\..\Application_protocols\AP243\Activity_model\.
..\..\Application_protocols\AP243\Activity_model\renameimages.bat
java -jar ../saxon9-8-0-6.jar -t model_to_generate=CM relativePath=..\..\Application_protocols\AP243\Data_planning_model ./output/sysml_models_ids.xml CanonicalRenameMDimages.xsl
move output\renameimages.bat ..\..\Application_protocols\AP243\Data_planning_model\.
..\..\Application_protocols\AP243\Data_planning_model\renameimages.bat
java -jar ../saxon9-8-0-6.jar -t model_to_generate=SM relativePath=..\..\Application_protocols\AP243\Services_model ./output/sysml_models_ids.xml CanonicalRenameMDimages.xsl
move output\renameimages.bat ..\..\Application_protocols\AP243\Services_model\.
..\..\Application_protocols\AP243\Services_model\renameimages.bat
//DM
java -jar ../saxon9-8-0-6.jar -t model_to_generate=DM VariablesData243.xml CanonicalExtract_ID.xsl
xcopy output\html\* ..\AntPub\input\maps
move output\html\* ..\AntPub\output\data\domain_models\mossec
xcopy ..\..\Application_protocols\AP243\Domain_model\_*.png ..\AntPub\output\data\domain_models\mossec\pictures
java -jar ../saxon9-8-0-6.jar -t model_to_generate=AAM VariablesData243.xml CanonicalExtract_ID.xsl
java -jar ../saxon9-8-0-6.jar -t model_to_generate=CM VariablesData243.xml CanonicalExtract_ID.xsl
java -jar ../saxon9-8-0-6.jar -t model_to_generate=SM VariablesData243.xml CanonicalExtract_ID.xsl
xcopy output\html\* ..\AntPub\input\maps
move output\html\* ..\AntPub\output\data\application_protocols\mossec
xcopy ..\..\Application_protocols\AP243\Activity_model\_*.png ..\AntPub\output\data\application_protocols\mossec\pictures
xcopy ..\..\Application_protocols\AP243\Data_planning_model\_*.png ..\AntPub\output\data\application_protocols\mossec\pictures
xcopy ..\..\Application_protocols\AP243\Services_model\_*.png ..\AntPub\output\data\application_protocols\mossec\pictures
cd ../AntImp
java -jar ../saxon9-8-0-6.jar -t variablesFileName=../AntPub/VariablesData243.xml ../../Application_protocols/AP243/Domain_model/Domain_model.xmi DomainModel_canonicalxmi_to_xsd.xsl > unsorted_DomainModel_from_cxmi.xsd
java -jar ../saxon9-8-0-6.jar -t unsorted_DomainModel_from_cxmi.xsd DomainModel_sort_xsd.xsl > DomainModel.xsd
copy DomainModel.xsd ..\AntPub\output\data\domain_models\mossec /y
java -jar ../saxon9-8-0-6.jar -t debuggingMode=0 variablesFileName=../AntPub/VariablesData243.xml ../../Application_protocols/AP243/Domain_model/Domain_model.xmi DomainModel_canonicalxmi_to_json.xsl
type DomainModel_NotPretty243.json | python -m json.tool > DomainModel.json
copy DomainModel.json ..\AntPub\output\data\domain_models\mossec /y
cd ../AntPub
xcopy .\input\AP243STEPmod_files\* .\output /s /e /y
java -jar ../saxon9-8-0-6.jar -t model_to_generate=AP variablesFileName=VariablesData243.xml ../../Application_protocols/AP243/Data_planning_model/Data_planning_model.xmi CanonicalAPClause4_Documentations.xsl --suppressXsltNamespaceCheck:on 2>243_4_error.log
java -jar ../saxon9-8-0-6.jar -t model_to_generate=AP variablesFileName=VariablesData243.xml ../../Application_protocols/AP243/Domain_model/Domain_model.xmi CanonicalConformanceModelSingle_Documentations.xsl --suppressXsltNamespaceCheck:on
java -jar ../saxon9-8-0-6.jar -t model_to_generate=AP variablesFileName=VariablesData243.xml ../../Application_protocols/AP243/Activity_model/Activity_model.xmi CanonicalAAM_Documentations.xsl --suppressXsltNamespaceCheck:on 2>243_AAM_error.log
java -jar ../saxon9-8-0-6.jar -t model_to_generate=AP variablesFileName=VariablesData243.xml termtag=APterms ./VariablesData243.xml TermsDefs.xsl
java -jar ../saxon9-8-0-6.jar -t model_to_generate=AP variablesFileName=VariablesData243.xml nr_or_biblio=nr ./VariablesData243.xml NormRefs_Biblio.xsl
java -jar ../saxon9-8-0-6.jar -t model_to_generate=AP variablesFileName=VariablesData243.xml nr_or_biblio=biblio ./VariablesData243.xml NormRefs_Biblio.xsl
java -jar ../saxon9-8-0-6.jar -t model_to_generate=AP variablesFileName=VariablesData243.xml ./VariablesData243.xml Canonical_index.xsl --suppressXsltNamespaceCheck:on
java -jar ../saxon9-8-0-6.jar -t model_to_generate=AP ./VariablesData243.xml renumber_figurestables.xsl --suppressXsltNamespaceCheck:on
java -jar ../saxon9-8-0-6.jar -t model_to_generate=DM split4=1 variablesFileName=VariablesData243.xml ../../Application_protocols/AP243/Domain_model/Domain_model.xmi CanonicalDomainModel_clause4.xsl --suppressXsltNamespaceCheck:on 2>4443_4_error.log
java -jar ../saxon9-8-0-6.jar -t model_to_generate=DM splitModel=1 variablesFileName=VariablesData243.xml ../../Application_protocols/AP243/Domain_model/Domain_model.xmi CanonicalDomainModel_clause5.xsl 2>4443_5_error.log
java -jar ../saxon9-8-0-6.jar -t model_to_generate=DM ./input/sysml_models_ids.xml termtag=DMterms variablesFileName=VariablesData243.xml DomainModel_annex_bom_expg.xsl
java -jar ../saxon9-8-0-6.jar -t model_to_generate=DM variablesFileName=VariablesData243.xml termtag=DMterms ./VariablesData243.xml TermsDefs.xsl
java -jar ../saxon9-8-0-6.jar -t model_to_generate=DM variablesFileName=VariablesData243.xml nr_or_biblio=nr ./VariablesData243.xml NormRefs_Biblio.xsl
java -jar ../saxon9-8-0-6.jar -t model_to_generate=DM variablesFileName=VariablesData243.xml nr_or_biblio=biblio ./VariablesData243.xml NormRefs_Biblio.xsl
java -jar ../saxon9-8-0-6.jar -t model_to_generate=DM variablesFileName=VariablesData243.xml ./VariablesData243.xml CanonicalDomainModel_index.xsl --suppressXsltNamespaceCheck:on
java -jar ../saxon9-8-0-6.jar -t model_to_generate=DM variablesFileName=VariablesData243.xml ./VariablesData243.xml ReferenceData.xsl --suppressXsltNamespaceCheck:on
java -jar ../saxon9-8-0-6.jar -t model_to_generate=DM variablesFileName=VariablesData243.xml ./VariablesData243.xml Canonical_index.xsl --suppressXsltNamespaceCheck:on
java -jar ../saxon9-8-0-6.jar -t model_to_generate=DM ./VariablesData243.xml renumber_figurestables.xsl --suppressXsltNamespaceCheck:on
java -jar ../saxon9-8-0-6.jar -t model_to_generate=DM variablesFileName=VariablesData243.xml ../../Application_protocols/AP243/Domain_model/Domain_model.xmi CanonicalDomainModel_Home.xsl --suppressXsltNamespaceCheck:on
java -jar ../saxon9-8-0-6.jar -t model_to_generate=DM ./VariablesData243.xml xhtml_to_htm.xsl
java -jar ../saxon9-8-0-6.jar -t model_to_generate=AP ./VariablesData243.xml xhtml_to_htm.xsl
// delete interim files
del /q output\data\application_protocols\mossec\sys\*.xhtml
del /q output\data\application_protocols\mossec\sys\*.xml
del /q output\data\domain_models\mossec\sys\*.xhtml
del /q output\data\domain_models\mossec\sys\*.xml
//cd ../generate_owl
//java -jar ../saxon9.jar -t ../Domain_model.xml AP243_DomainToOWL.xsl > ../AntPub/input/domain_model.owl
//copy ..\AntPub\input\domain_model.owl ..\AntPub\output\data\application_protocols\mossec\refdata\ap243_RDL-en-v1-0.owl /y
// clause 6 using the Domain_model_conformance.xmi
//java -jar ../saxon9-8-0-6.jar -t model_to_generate=AP variablesFileName=VariablesData243.xml ../../Application_protocols/AP243/Domain_model_conformance/Domain_model_conformance.xmi CanonicalConformanceModel_Documentations.xsl --suppressXsltNamespaceCheck:on 2>243_6_error.log
// clause 6 - single cc using Domain_model.xmi
Section author: Judith Crockford (AP243)