py-apx 0.4.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
py_apx-0.4.4/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Conny Gustafsson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ include README.rst
py_apx-0.4.4/PKG-INFO ADDED
@@ -0,0 +1,43 @@
1
+ Metadata-Version: 2.4
2
+ Name: py-apx
3
+ Version: 0.4.4
4
+ Summary: A framework for sending AUTOSAR signal data to non-AUTOSAR applications
5
+ Home-page: http://github.com/cogu/py-apx
6
+ Author: Conny Gustafsson
7
+ Author-email: congus8@gmail.com
8
+ License: MIT
9
+ Project-URL: Documentation, https://py-apx.readthedocs.io/
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Programming Language :: Python :: 3.6
12
+ Description-Content-Type: text/x-rst
13
+ License-File: LICENSE
14
+ Requires-Dist: cfile==0.2.0
15
+ Requires-Dist: autosar<0.5.0
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: home-page
22
+ Dynamic: license
23
+ Dynamic: license-file
24
+ Dynamic: project-url
25
+ Dynamic: requires-dist
26
+ Dynamic: summary
27
+
28
+ APX
29
+ ---
30
+
31
+ A framework for sending AUTOSAR signal data to non-AUTOSAR applications.
32
+
33
+ Prerequisites
34
+ -------------
35
+
36
+ * `Python 3 <https://www.python.org/>`_
37
+ * `autosar <https://github.com/cogu/autosar>`_
38
+
39
+ Documentation
40
+ -------------
41
+ Documentation can be found `here <http://py-apx.readthedocs.io/en/latest/>`_
42
+
43
+
@@ -0,0 +1,16 @@
1
+ APX
2
+ ---
3
+
4
+ A framework for sending AUTOSAR signal data to non-AUTOSAR applications.
5
+
6
+ Prerequisites
7
+ -------------
8
+
9
+ * `Python 3 <https://www.python.org/>`_
10
+ * `autosar <https://github.com/cogu/autosar>`_
11
+
12
+ Documentation
13
+ -------------
14
+ Documentation can be found `here <http://py-apx.readthedocs.io/en/latest/>`_
15
+
16
+
@@ -0,0 +1,16 @@
1
+ __version__ = "0.4.4"
2
+ from apx.base import *
3
+ from apx.vm_base import *
4
+ from apx.node import *
5
+ from apx.file import *
6
+ from apx.file_map import *
7
+ from apx.file_manager import *
8
+ from apx.node_data import *
9
+ from apx.parser import Parser
10
+ from apx.context import *
11
+ from apx.client import *
12
+ from apx.compiler import *
13
+ from apx.vm import *
14
+ from apx.generator import NodeGenerator, ComGenerator
15
+ from apx.tester import *
16
+
@@ -0,0 +1,124 @@
1
+ class ApxSignature(object):
2
+ def __init__(self,mainType,name,dsg,attr=""):
3
+ self.mainType=mainType
4
+ self.name=name
5
+ self.dsg=dsg
6
+ self.attr=attr
7
+ def __str__(self):
8
+ if (self.attr != None) and len(self.attr)>0:
9
+ return '%s"%s"%s:%s'%(self.mainType,self.name,self.dsg,self.attr)
10
+ else:
11
+ return '%s"%s"%s'%(self.mainType,self.name,self.dsg)
12
+
13
+ class ApxType(object):
14
+ @staticmethod
15
+ def _calcUIntTypeLen(dataType):
16
+ if dataType['type']=='integer':
17
+ if dataType['min'] == 0:
18
+ return int(math.ceil(math.log(dataType['max'],2)))
19
+ return None
20
+
21
+ @staticmethod
22
+ def _calcIntTypeLen(dataType):
23
+ if dataType['type']=='integer':
24
+ if dataType['min'] < 0:
25
+ return int(math.ceil(math.log(abs(dataType['max']),2)))+1
26
+ return None
27
+
28
+ @staticmethod
29
+ def _calcDataSignature(dataType):
30
+ global typeData
31
+ global args
32
+ typeCode = None
33
+
34
+ if dataType['type']=='boolean':
35
+ return 'C(0,1)'
36
+ if dataType['type']=='integer':
37
+ return ApxType._getIntegerTypeCode(dataType)
38
+ elif dataType['type'] == 'array':
39
+ typeCode = ApxType._getIntegerTypeCode(typeData.find(dataType['typeRef']))
40
+ if typeCode != None:
41
+ return "%s[%d]"%(typeCode,int(dataType['length']))
42
+ else:
43
+ raise Exception("unsupported type: %s"%typeData.find(dataType['typeRef']))
44
+ elif dataType['type'] == 'string':
45
+ typeCode = 'a'
46
+ if typeCode != None:
47
+ return "%s[%d]"%(typeCode,int(dataType['length'])+1)
48
+ elif dataType['type'] == 'record':
49
+ result="{"
50
+ for elem in dataType['elements']:
51
+ #uncomment to remove _RE from end of element names
52
+ #if elem['name'].endswith('_RE'):
53
+ #elem['name']=elem['name'][:-3]
54
+ childType = typeData.find(elem['typeRef'])
55
+ result+='"%s"%s'%(elem['name'],ApxType._calcDataSignature(childType))
56
+
57
+ result+="}"
58
+ return result
59
+ else: raise Exception('uhandled data type: %s'%dataType['type'])
60
+ return ""
61
+
62
+ @staticmethod
63
+ def _getIntegerTypeCode(dataType):
64
+ global args
65
+ if dataType['min'] >= 0:
66
+ bits = ApxType._calcUIntTypeLen(dataType)
67
+ if bits <=8:
68
+ if (dataType['min']>0) or (dataType['max']<255):
69
+ return 'C(%d,%d)'%(dataType['min'],dataType['max'])
70
+ else:
71
+ return 'C'
72
+ elif bits <=16:
73
+ return 'S'
74
+ elif bits <=32:
75
+ return 'L'
76
+ elif bits <=64:
77
+ return 'U'
78
+ elif dataType['min']<0:
79
+ bits = ApxType._calcIntTypeLen(dataType)
80
+ if bits <=8:
81
+ if (dataType['min']>-128) or dataType['max']<127:
82
+ return 'c(%d,%d)'%(dataType['min'],dataType['max'])
83
+ else:
84
+ return 'c'
85
+ elif bits <=16:
86
+ return 's'
87
+ elif bits <=32:
88
+ return 'l'
89
+ elif bits <=64:
90
+ return 'u'
91
+ else:
92
+ print("not implemented (min=%s)"%dataType['min'])
93
+
94
+ @staticmethod
95
+ def _calcAttribute(dataType):
96
+ if dataType['type']=='integer':
97
+ typeSemantics = typeData.find('/DataType/Semantics/%s'%dataType['name'])
98
+ if (typeSemantics != None) and ('valueTable' in typeSemantics):
99
+ v=','.join(['"%s"'%x for x in typeSemantics['valueTable']])
100
+ return "VT(%s)"%v
101
+ return None
102
+
103
+ def __init__(self,dataType):
104
+ self.name = dataType['name']
105
+ self.signature = ApxSignature('T',dataType['name'],ApxType._calcDataSignature(dataType),ApxType._calcAttribute(dataType))
106
+
107
+
108
+ class ApxPort(object):
109
+ def __init__(self,name,typeIndex,attrib):
110
+ self.name = name
111
+ self.typeIndex = typeIndex
112
+ self.attrib=attrib
113
+ def getAttrStr(self):
114
+ result=""
115
+ if self.attrib['initValue']!=None:
116
+ result+="=%s"%self.attrib['initValue']
117
+ if self.attrib['isQueued']:
118
+ if self.attrib['queueLen']!=None:
119
+ result+="Q[%d]"%self.attrib['queueLen']
120
+ else:
121
+ result+="Q"
122
+ if self.attrib['isParameter']:
123
+ result+="P"
124
+ return result