Commit 14a9271d authored by Jerome Legrand's avatar Jerome Legrand

C006 libraries (pandoc.py and taste.py) and examples

parent 45cb4a1a
#! /usr/bin/python
import ocarina
import taste
import lmp
def main ():
aadlFiles = ['../projects/DemoIV.aadl', '../projects/TASTE-Dataview.aadl', '../projects/TASTE_IV_Properties.aadl', \
'../projects/taste_properties.aadl', '../projects/data_model.aadl', '../projects/base_types.aadl', '../projects/deployment.aadl']
ret = taste.load (aadlFiles, "interfaceview::IV::interfaceview.others")
print 'load', ret
print '\nROOT'
iv = taste.getTasteRoot()
taste.visitIV(iv, False)
functionNames = taste.getFunctions (resType = 'names')
print '\nFUNCTIONS', functionNames
functions = taste.getFunctions ()
for function in functions:
taste.visitFunction(function, 1, False)
features = taste.getPIRIs('name')
print '\nFEATURES', features
features = taste.getPIRIs()
for feature in features:
taste.printPIRI(feature, 1)
pis = taste.getPIs('name')
print '\nPIS', pis
pis = taste.getPIs()
for pi in pis:
taste.printPIRI(pi,1)
ris = taste.getRIs('name')
print '\nRIS', ris
ris = taste.getRIs()
for ri in ris:
taste.printPIRI(ri, 1)
connections = taste.getConnections(resType = 'name')
print '\nCONNECTIONS', connections
connections = taste.getConnections()
for connection in connections:
taste.printConnection(connection, 1)
if __name__ == "__main__":
main ()
#~ sys.exit (0); # exit
#! /usr/bin/python
import ocarina
import taste
import lmp
def main ():
mainAADLFile = 'DemoDV.aadl'
aadlFiles = [mainAADLFile, 'TASTE_DV_Properties.aadl', 'DemoIV.aadl', 'TASTE-Dataview.aadl', \
'TASTE_IV_Properties.aadl', 'taste_properties.aadl', 'data_model.aadl', 'base_types.aadl', 'deployment.aadl', \
'Cheddar_Properties.aadl', 'arinc653.aadl', 'TestLibHW.aadl']
ret = taste.load (aadlFiles, "deploymentview::DV::deploymentview.others")
print 'load', ret
dv = taste.getTasteRoot()
taste.visitDV(dv)
if __name__ == "__main__":
main ()
#~ sys.exit (0); # exit
#! /usr/bin/python
import ocarina
import taste
import lmp
def main ():
mainAADLFile = 'DemoIV2.aadl'
aadlFiles = [mainAADLFile, 'TASTE-Dataview.aadl', 'TASTE_IV_Properties.aadl', 'taste_properties.aadl', 'data_model.aadl', \
'base_types.aadl', 'deployment.aadl']
ret = taste.load (aadlFiles, "interfaceview::IV::interfaceview.others")
print 'load', ret
iv = taste.getTasteRoot()
taste.visitIV(iv)
if __name__ == "__main__":
main ()
#~ sys.exit (0); # exit
#! /usr/bin/python
import ocarina
import lmp
import taste
#~ from taste import *
from pandoc import *
def main ():
## load iv files
aadlFiles = ['../projects/DemoIV.aadl', '../projects/TASTE-Dataview.aadl', '../projects/TASTE_IV_Properties.aadl', \
'../projects/taste_properties.aadl', '../projects/data_model.aadl', '../projects/base_types.aadl', '../projects/deployment.aadl']
ret = taste.load (aadlFiles, "interfaceview::IV::interfaceview.others")
print 'load', ret
#~ indent = '\t'
indent = ''
indent2 = '\t'
## start the pandoc document
newDocument('Demo IV Documentation ', ['Jerome Legrand'], 'July the 24th 2017')
addTOC()
newPage()
## ROOT
iv = taste.getTasteRoot()
label = taste.getComponentLabel(iv)
headerText = 'IV ' + label
header (headerText)
comment = taste.getComment (iv)
if comment != '':
header('Description', 2)
comment = removeFormatting(comment)
paragraph(comment)
## root attributes
header('Attributes', 2)
text = 'The iv ' + bold(label) + ' has the following attributes : '
rawText(text)
attributesList = []
attributes = taste.getComponentAttributes (iv)
for name, value in attributes.items():
#~ text += indent + '* ' + name + ' = ' + value + '\n'
attributesList.append(italic(name) + ' = ' + value)
listBlock (attributesList)
## FUNCTIONS
newPage()
functions = taste.getFunctions()
for function in functions:
## function header
label = taste.getComponentLabel(function)
headerText = 'Function ' + label
header(headerText)
## Description
description = taste.getDescription (function)
if description != '':
header('Description', 2)
description = removeFormatting(description)
paragraph(description)
## attributes
header('Attributes', 2)
text = 'The function ' + bold(label) + ' has the following attributes : '
rawText(text)
attributesList = []
attributes = taste.getComponentAttributes (function)
for name, value in attributes.items():
attributesList.append(italic(name) + ' = ' + value)
listBlock (attributesList)
## functions CP
contParams = taste.getFunctionCP (function)
if contParams != []:
header('Context Parameters', 2)
text = 'The function' + bold(label) + ' has the following context parameters : '
rawText(text)
contParamList = []
for contParam in contParams:
cpLabel = taste.getLabel(contParam)
contParamList.append(cpLabel)
listBlock (attributesList)
## PI/RI
pis = taste.getFunctionFeatures (function, 'provided')
if pis != []:
header('Provided Interfaces', 2)
text = 'The function ' + bold(label) + ' has the following pis.'
rawText(text)
addPIRIInfo(pis)
ris = taste.getFunctionFeatures (function, 'required')
if ris != []:
header('Required Interfaces', 2)
text = 'The function ' + bold(label) + ' has the following ris.'
rawText(text)
addPIRIInfo(ris)
finalizeDocument()
#~ printDocument ()
#~ serialize ('ivDoc.md')
#~ convert('test.latex', 'latex')
convert('test.pdf', 'latex')
def addPIRIInfo(features):
for feature in features:
featureLabel = taste.getFeatureLabel(feature)
featureCategory = taste.getCategory(feature)
headerText = featureCategory + ' ' + featureLabel
header(headerText, 3)
description = taste.getDescription (feature)
if description != '':
#~ header('Description', 3)
description = removeFormatting(description)
paragraph(description)
## attributes
text = 'The ' + featureCategory + ' ' + bold(featureLabel) + ' has the following attributes : '
rawText(text)
attributesList = []
attributes = taste.getFeatureAttributes (feature)
for name, value in attributes.items():
attributesList.append(italic(name) + ' = ' + value)
listBlock (attributesList)
## parameters
parameters = taste.getParameters (feature)
if parameters != []:
header('Parameters', 4)
text = 'The ' + featureCategory + ' ' + bold(featureLabel) + ' has the following parameters : '
rawText(text)
parameterList = []
for parameter in parameters:
parameterLabel = taste.getParameterLabel(parameter)
parameterList.append(parameterLabel)
## attributes
paramAttList = []
attributes = taste.getFeatureAttributes (parameter)
for name, value in attributes.items():
paramAttList.append(italic(name) + ' = ' + value)
## other
direction = taste.getDirection(parameter)
paramAttList.append(italic('direction') + ' = ' + direction)
if paramAttList != []:
parameterList.append(paramAttList)
listBlock (parameterList)
if __name__ == "__main__":
main ()
#~ sys.exit (0); # exit
This image diff could not be displayed because it is too large. You can view the blob instead.
#! /usr/bin/python
#~ import pandoc
from pandoc import *
def main ():
newDocument('title\nof the document', ['author1', 'author2'], '25 june\n2017')
addTOC()
newPage()
header ('Test quote Block', 1, '#header1')
quoteBlock (['text 1', ['text 2', ['text 3'], 'text 4'], 'text 5'])
#~ text ('test header reference [header1]')
text ('"blabla"')
pageBreak()
header ('Test code Block')
header ('with string', 2)
code1 = 'if (a > 3) { \n moveShip(5 * gravity, DOWN); \n}'
codeBlock (code1)
header ('with list', 2)
code2 = ['if (a > 3) {', ' moveShip(5 * gravity, DOWN);', '}']
codeBlock (code2)
header ('fenced with string', 2)
codeBlockFenced (code1)
newPage()
header ('Test line Block')
header ('with string', 2)
lineBlock1 = 'line 1 \nline 2 \nline 3'
lineBlock (lineBlock1)
header ('with list', 2)
lineBlock2 = ['line 1', 'line 2', 'line 3']
lineBlock (lineBlock2)
newPage()
header ('Test list Block')
header ('bullet list', 2)
testList1 = ['ab', ['a', ['a', 'b'], 'b', 'c'], 'b', 'c']
listBlock(testList1)
header ('ordered list', 2)
testList2 = ['ab', 'bc', 'cd']
orderedlistBlock(testList2)
newPage()
header ('horizontal rules')
horizontalRule ()
horizontalRule ('*', 4)
horizontalRule ('_', 20)
newPage()
header ('tables')
header ('simple table', 2)
header ('with header', 3)
table1_1 = [ \
[['t1', 'right'],['title2', 'left'],['t3', 'center'], ['t4', 'default']], \
['12', '12', '123', '12'], \
['123', '123', '1234', '1234'], \
['1', '1', '1', '1'] \
]
table1_2 = [ \
[['tt1', 'right', 10],['title2', 'left', 1],['t3', 'center', 10], ['t4', 'default', 40]], \
['12', '12', '123', '12'], \
['123', '123', '1234', '1234'], \
['1', '1', '1', '1'] \
]
table(table1_1, 'table 1_1 caption')
newLine()
table(table1_2, 'table 1_2 caption')
newLine()
header ('without header', 3)
table2 = [ \
[['', 'right', 10],['', 'left', 5],['', 'center', 2], ['', 'default', 20]], \
['12', '12', '123', '12'], \
['123', '123', '1234', '1234'], \
['1', '1', '1', '1'] \
]
table(table2, 'test', ' ')
newPage()
header ('multiline table', 2)
header ('with header', 3)
table3_1 = [ \
[['Centered\nHeader', 'center'],['Default\nAligned', 'default'],['Right\nAligned\ntest', 'right'], ['Left\nAligned', 'left']], \
['First', 'rowbidule', '12.0', 'Example of a row that\nspans multiple lines.'], \
['Second', 'row', '5.0', 'Here\'s another one. Note\nthe blank line between\nrows.'], \
]
table(table3_1)
header ('without header', 3)
table3_2 = [ \
[['', 'center'],['', 'default'],['', 'right', 20], ['', 'left', 50]], \
['First', 'row', '12.0', 'Example of a row that\nspans multiple lines.'], \
['Second', 'row', '5.0', 'Here\'s another one. Note\nthe blank line between\nrows.'], \
]
table(table3_2)
header ('grid table', 2)
header ('with header', 3)
table4_1 = [ \
[['Fruit', 'default'],['Price', 'default'],['Advantages', 'default']], \
['Bananas', '$1.34', '- built-in wrapper\n- bright color'], \
['Oranges', '$2.10', '- cures scurvy\n- tasty'], \
]
table(table4_1, '', ' ', 'grid')
table4_2 = [ \
[['Fruit', 'left', 20],['Price', 'center'],['Advantages', 'right', 30]], \
['Bananas', '$1.34', '- built-in wrapper\n- bright color'], \
['Oranges', '$2.10', '- cures scurvy\n- tasty'], \
]
table(table4_2, '', ' ', 'grid')
header ('without header', 3)
table4_3 = [ \
[['', 'left'],['', 'center'],['', 'right']], \
['Bananas', '$1.34', '- built-in wrapper\n- bright color'], \
['Oranges', '$2.10', '- cures scurvy\n- tasty'], \
]
#~ table4_3 = [ \
#~ [['', 'left', 20],['', 'center'],['', 'right', 30]], \
#~ ['Bananas', '$1.34', '- built-in wrapper\n- bright color'], \
#~ ['Oranges', '$2.10', '- cures scurvy\n- tasty'], \
#~ ]
table(table4_3, '', ' ', 'grid')
header ('pipe table', 2)
header ('with header', 3)
table5_1 = [ \
[['Right', 'right'],['Left', 'left'],['Default', 'default'], ['Center', 'center']], \
['12', '12', '123', '12'], \
['123', '123', '123', '123'], \
['1', '1', '1', '1'] \
]
table(table5_1, '', ' ', 'pipe')
table5_2 = [ \
[['Right\ntruc', 'right'],['Left', 'left', 30],['Default', 'default'], ['Center', 'center']], \
['12', '12', '123', '12'], \
['123', '123', '123', '123'], \
['1', '1', '1', '1'] \
]
table(table5_2, '', ' ', 'pipe')
header ('without header', 3)
table5_3 = [ \
[['', 'right'],['', 'left'],['', 'default'], ['', 'center']], \
['12', '12', '123', '12'], \
['123', '123', '123', '123'], \
['1', '1', '1', '1'] \
]
table(table5_3, '', ' ', 'pipe')
newPage()
header ('text formatting')
header ('emphase', 2)
rawText('this is an ' + italic('italic') + ' emphase')
newLine()
rawText('this is a ' + bold('bold') + ' emphase')
newLine()
header ('strikeout', 2)
rawText('this is a ' + strikeout('strike out'))
newLine()
header ('power and indice', 2)
rawText('power : 2' + power('10'))
newLine()
rawText('indice : H' + indice('2') + '0')
newLine()
header ('verbatim', 2)
rawText('verbatim text : ' + verbatim('this is a verbatim text') + '\n')
rawText('verbatim text : ' + verbatim('this is a `verbatim` text'))
newLine()
header ('small caps', 2)
rawText('small caps text : ' + smallCaps('this is a smallcaps text'))
header ('math', 2)
## tex math format shall be used with \\ for special char
formula = '\\sqrt{\\frac{x^2}{3}}'
rawText('math formula : ' + math(formula))
newLine()
newPage()
header ('references')
header ('automatic link', 2)
urlLink = url('http://google.com')
emailLink = email('sam@green.eggs.ham')
rawText('url : ' + urlLink)
rawText('email : ' + emailLink)
newLine()
header ('inline link', 2)
header ('url', 3)
inlineLink = url('http://fsf.org', 'inline link', 'click here for a good time!')
rawText('This is an ' + inlineLink)
header ('email', 3)
inlineLink = email('sam@green.eggs.ham', 'Write me !')
rawText(inlineLink)
newLine()
header ('reference link', 2)
header ('non implicit', 3)
referenceLink = reference('FSF', 'My Website')
rawText('See ' + referenceLink)
newLine()
header ('implicit', 3)
referenceLink = reference('My Website')
rawText('See ' + referenceLink)
newLine()
header ('internal link', 2)
headerLink = reference('#introduction', 'Introduction')
text ('See the ' + headerLink)
newLine()
text ('Or')
newLine()
headerLink = reference('Introduction')
text ('See the ' + headerLink)
newLine()
header ('images', 2)
imageRef = image('la_lune.jpg', 'la lune', 'Voyage to the moon')
rawText('An image : ' + imageRef)
newLine()
imageRef = image('la_lune.jpg', width = '50%')
rawText('An image : ' + imageRef)
newLine()
imageRef = image('Blade Runner')
rawText('An image : ' + imageRef)
newLine()
header ('definition', 2)
definedReference('http://fsf.org', 'FSF', 'click here for a good time!')
definedReference('http://truc.org', 'My Website')
definedReference('#introduction', 'Introduction')
definedReference('BladeRunner.gif', 'Blade Runner', 'title', 'width=10cm height=20px')
newLine()
newPage()
header('footnote')
header('reference with label', 2)
f1 = footnote()
f2 = footnote('longFoot')
rawText('this is a simple footnote ' + f1 + ' and a long one ' + f2)
newLine()
header('inline footnote', 2)
f3 = footnote(text = 'Inlines notes are easier to write, since \nyou don\'t have to pick an identifier and move down to type the \nnote.')
rawText('Here is an inline note.' + f3)
newLine()
header('definition', 2)
definedFootnote('1', 'A simple footnote.')
definedFootnote('longFoot', 'Here\'s one with multiple blocks.\n\nSubsequent paragraphs are indented to show that they\nbelong to the previous footnote.\n\nThe whole paragraph can be indented, or just the first \nline. In this way, multi-paragraph footnotes work like \nmulti-paragraph list items.', '\n')
newLine()
newPage()
header('citations')
c1 = citations('See @doe99', 'pp. 33-35', '@smith04')
rawText('Blah blah ' + c1 + '\n')
c2 = citations('@doe99', '@smith04')
rawText('Blah blah ' + c2 + '\n')
c3 = citations('@doe99', 'pp. 33-35, 38-39')
rawText('Blah blah ' + c3 + '\n')
c4 = citations('-@doe99')
rawText('Blah blah ' + c4 + '\n')
addBibliography('./biblio.bib')
finalizeDocument()
#~ printDocument ()
#~ serialize ('test.md')
convert('test.pdf', 'latex')
if __name__ == "__main__":
main ()
#~ sys.exit (0); # exit
This diff is collapsed.
This diff is collapsed.
property set Cheddar_Properties is
Dispatch_Seed_is_Predictable : aadlboolean
applies to (thread, thread group);
Context_Switch_Overhead : inherit Time
applies to (thread, thread group);
Source_Text : inherit list of aadlstring applies to (virtual processor, processor, thread);
Automaton_Name : inherit list of aadlstring applies to (virtual processor, processor, thread);
Dispatch_Seed_Value : aadlinteger
applies to (thread, thread group);
Dispatch_Absolute_Time : inherit Time
applies to (thread, thread group);
Criticality : aadlinteger
applies to (thread, thread group);
Bound_On_Data_Blocking_Time : inherit Time
applies to (thread, thread group);
Dispatch_Jitter : inherit Time
applies to (thread, thread group);
Fixed_Priority : aadlinteger 0..255
applies to (thread, thread group);
POSIX_Scheduling_Policy : enumeration (SCHED_FIFO, SCHED_RR, SCHED_OTHERS)
applies to (thread, thread group);
Dispatch_Offset_Value_0 : aadlinteger
applies to (thread, thread group);
Dispatch_Offset_Time_0 : inherit Time
applies to (thread, thread group);
Dispatch_Offset_Value_1 : aadlinteger
applies to (thread, thread group);
Dispatch_Offset_Time_1 : inherit Time
applies to (thread, thread group);
Dispatch_Offset_Value_2 : aadlinteger
applies to (thread, thread group);
Dispatch_Offset_Time_2 : inherit Time
applies to (thread, thread group);
Dispatch_Offset_Value_3 : aadlinteger
applies to (thread, thread group);
Dispatch_Offset_Time_3 : inherit Time
applies to (thread, thread group);
Dispatch_Offset_Value_4 : aadlinteger
applies to (thread, thread group);
Dispatch_Offset_Time_4 : inherit Time
applies to (thread, thread group);
Dispatch_Offset_Value_5 : aadlinteger
applies to (thread, thread group);
Dispatch_Offset_Time_5 : inherit Time
applies to (thread, thread group);
Task_Precedencies : list of aadlstring
applies to (system);
Scheduler_Quantum : inherit Time
applies to (processor, virtual processor);
Preemptive_Scheduler : aadlboolean
applies to (processor, virtual processor);
Scheduling_Protocol : list of Supported_Scheduling_Protocols
applies to (processor, virtual processor);
Data_Concurrency_State : aadlinteger
applies to (data);
Critical_Section : list of aadlstring
applies to (virtual processor, thread, data);
Source_Global_Heap_Size : Size
applies to (process);
Source_Global_Stack_Size : Size
applies to (process);
Source_Global_Text_Size : Size
applies to (process);
Source_Global_Data_Size : Size
applies to (process);
end Cheddar_Properties;
---------------------------------------------------
-- AADL2.1
-- TASTE type deploymentview
-- (c)Ellidiss Technologies
-- generated code: do not edit
---------------------------------------------------
PACKAGE deploymentview::DV::Node1
PUBLIC
WITH ocarina_buses;
WITH ocarina_drivers;
WITH Taste;
WITH Deployment;
WITH TASTE_DV_Properties;
PROCESS App1
END App1;
PROCESS IMPLEMENTATION App1.others
END App1.others;
DEVICE driver
EXTENDS ocarina_drivers::generic_serial
FEATURES
link : REFINED TO REQUIRES BUS ACCESS ocarina_buses::serial.generic {
Taste::coordinates => "113835 67430";
};
PROPERTIES
Taste::Interface_Coordinates => "138660 69107" APPLIES TO link;
Deployment::Help => "Write your ASN.1 configuration here";
END driver;
DEVICE IMPLEMENTATION driver.others
EXTENDS ocarina_drivers::generic_serial.raw
END driver.others;
END deploymentview::DV::Node1;
PACKAGE deploymentview::DV::Node2
PUBLIC
WITH ocarina_buses;
WITH ocarina_drivers;
WITH Taste;
WITH Deployment;
WITH TASTE_DV_Properties;
PROCESS App2