modm_data.owl.stmicro.ontology

  1# Copyright 2022, Niklas Hauser
  2# SPDX-License-Identifier: MPL-2.0
  3
  4import re
  5import owlready2 as owl
  6from .. import Store
  7
  8class KeyDict:
  9    def __init__(self, values):
 10        self.values = values
 11
 12    def __getattr__(self, attr):
 13        val = self.values.get(attr, None)
 14        if val is None:
 15            raise AttributeError("'{}' has no property '{}'".format(repr(self), attr))
 16        return val
 17
 18
 19def create_ontology(did):
 20    store = Store("stmicro", did.string)
 21    ontology = store.ontology
 22
 23    # --------------------------- DEVICE IDENTIFIER ---------------------------
 24    class DeviceIdentifier(owl.Thing):
 25        namespace = ontology
 26        comment = "The unique identifier (part number) of the device."
 27
 28    class hasDeviceSchema(owl.DataProperty, owl.FunctionalProperty):
 29        namespace = ontology
 30        comment = "How to format the device identifier."
 31        domain = [DeviceIdentifier]
 32        range = [str]
 33
 34    class hasDevicePlatform(owl.DataProperty, owl.FunctionalProperty):
 35        namespace = ontology
 36        domain = [DeviceIdentifier]
 37        range = [str]
 38
 39    class hasDeviceFamily(owl.DataProperty, owl.FunctionalProperty):
 40        namespace = ontology
 41        domain = [DeviceIdentifier]
 42        range = [str]
 43
 44    class hasDeviceName(owl.DataProperty, owl.FunctionalProperty):
 45        namespace = ontology
 46        domain = [DeviceIdentifier]
 47        range = [str]
 48
 49    class hasDevicePin(owl.DataProperty, owl.FunctionalProperty):
 50        namespace = ontology
 51        domain = [DeviceIdentifier]
 52        range = [str]
 53
 54    class hasDeviceSize(owl.DataProperty, owl.FunctionalProperty):
 55        namespace = ontology
 56        domain = [DeviceIdentifier]
 57        range = [str]
 58
 59    class hasDevicePackage(owl.DataProperty, owl.FunctionalProperty):
 60        namespace = ontology
 61        domain = [DeviceIdentifier]
 62        range = [str]
 63
 64    class hasDeviceTemperature(owl.DataProperty, owl.FunctionalProperty):
 65        namespace = ontology
 66        domain = [DeviceIdentifier]
 67        range = [str]
 68
 69    class hasDeviceVariant(owl.DataProperty, owl.FunctionalProperty):
 70        namespace = ontology
 71        domain = [DeviceIdentifier]
 72        range = [str]
 73
 74    class hasDeviceCore(owl.DataProperty, owl.FunctionalProperty):
 75        namespace = ontology
 76        domain = [DeviceIdentifier]
 77        range = [str]
 78
 79    # ------------------------------- MEMORIES --------------------------------
 80    class Memory(owl.Thing):
 81        namespace = ontology
 82        comment = "Internal memory."
 83
 84    class hasMemoryStartAddress(owl.DataProperty, owl.FunctionalProperty):
 85        namespace = ontology
 86        domain = [Memory]
 87        range = [int]
 88
 89    class hasMemorySize(owl.DataProperty, owl.FunctionalProperty):
 90        namespace = ontology
 91        domain = [Memory]
 92        range = [int]
 93
 94    class hasMemoryAccess(owl.DataProperty, owl.FunctionalProperty):
 95        namespace = ontology
 96        domain = [Memory]
 97        range = [str]
 98
 99    class hasMemory(DeviceIdentifier >> Memory):
100        namespace = ontology
101
102    # ------------------------------ INTERRUPTS -------------------------------
103    class InterruptVector(owl.Thing):
104        namespace = ontology
105        comment = "Interrupt vector in the table."
106
107    class hasInterruptVectorPosition(owl.DataProperty, owl.FunctionalProperty):
108        namespace = ontology
109        domain = [InterruptVector]
110        range = [int]
111
112    class hasInterruptVector(owl.ObjectProperty):
113        namespace = ontology
114        domain = [DeviceIdentifier]
115        range = [InterruptVector]
116
117    # --------------------------------- PINS ----------------------------------
118    class Package(owl.Thing):
119        namespace = ontology
120        comment = "A device package identifier"
121        domain = [DeviceIdentifier]
122
123    class hasPackagePinCount(owl.DataProperty, owl.FunctionalProperty):
124        namespace = ontology
125        domain = [Package]
126        range = [int]
127
128    class hasPackage(DeviceIdentifier >> Package):
129        namespace = ontology
130
131    class Pin(owl.Thing):
132        namespace = ontology
133        comment = "A pin on a package."
134
135    class hasPinType(owl.DataProperty, owl.FunctionalProperty):
136        namespace = ontology
137        domain = [Pin]
138        range = [str]
139
140    class hasPinNumber(owl.DataProperty, owl.FunctionalProperty):
141        namespace = ontology
142        domain = [Pin]
143        range = [int]
144
145    class hasPort(owl.DataProperty, owl.FunctionalProperty):
146        namespace = ontology
147        domain = [Pin]
148        range = [str]
149
150    class hasPin(owl.ObjectProperty):
151        namespace = ontology
152        domain = [Package]
153        range = [Pin]
154
155    class pinPosition(owl.AnnotationProperty):
156        namespace = ontology
157        comment = "The pin position attached to the [Package, hasPin, Pin] relation."
158
159    # -------------------------------- SIGNALS --------------------------------
160    class Signal(owl.Thing):
161        namespace = ontology
162        comment = "Connects a pin with a peripheral function."
163
164    class AlternateFunction(Signal):
165        namespace = ontology
166        comment = "Connects to a digital peripheral function via multiplexer."
167
168    class AdditionalFunction(Signal):
169        namespace = ontology
170        comment = "Connects to an analog/special peripheral function."
171
172    class hasSignal(owl.ObjectProperty):
173        namespace = ontology
174        domain = [Pin]
175        range = [Signal]
176
177    class alternateFunction(owl.AnnotationProperty):
178        namespace = ontology
179        comment = "The AF number attached to the [Pin, hasSignal, AlternateFunction] relation."
180
181    # ------------------------------ PERIPHERALS ------------------------------
182    class Peripheral(owl.Thing):
183        namespace = ontology
184        comment = "Internal peripheral."
185
186    class hasPeripheralInstance(owl.DataProperty, owl.FunctionalProperty):
187        namespace = ontology
188        domain = [Peripheral]
189        range = [int]
190
191    class hasPeripheralType(owl.DataProperty, owl.FunctionalProperty):
192        namespace = ontology
193        domain = [Peripheral]
194        range = [str]
195
196    class hasPeripheral(owl.ObjectProperty):
197        namespace = ontology
198        domain = [DeviceIdentifier, Signal]
199        range = [Peripheral]
200
201    # ----------------------------- FLASH LATENCY -----------------------------
202    class FlashWaitState(owl.Thing):
203        namespace = ontology
204        comment = "Flash Latency for minimum frequency."
205
206    class hasWaitState(owl.DataProperty, owl.FunctionalProperty):
207        namespace = ontology
208        domain = [FlashWaitState]
209        range = [int]
210
211    class hasMaxFrequency(owl.DataProperty, owl.FunctionalProperty):
212        namespace = ontology
213        domain = [FlashWaitState]
214        range = [int]
215
216    class hasMinOperatingVoltage(owl.DataProperty, owl.FunctionalProperty):
217        namespace = ontology
218        domain = [FlashWaitState]
219        range = [float]
220
221    class hasFlashWaitState(owl.ObjectProperty):
222        namespace = ontology
223        domain = [DeviceIdentifier]
224        range = [FlashWaitState]
225
226    # -------------------------------- GENERAL --------------------------------
227    class hasName(owl.DataProperty, owl.FunctionalProperty):
228        namespace = ontology
229        domain = [Memory, Signal, Peripheral, Package, Pin]
230        range = [str]
231
232    return KeyDict(locals())
class KeyDict:
 9class KeyDict:
10    def __init__(self, values):
11        self.values = values
12
13    def __getattr__(self, attr):
14        val = self.values.get(attr, None)
15        if val is None:
16            raise AttributeError("'{}' has no property '{}'".format(repr(self), attr))
17        return val
KeyDict(values)
10    def __init__(self, values):
11        self.values = values
values
def create_ontology(did):
 20def create_ontology(did):
 21    store = Store("stmicro", did.string)
 22    ontology = store.ontology
 23
 24    # --------------------------- DEVICE IDENTIFIER ---------------------------
 25    class DeviceIdentifier(owl.Thing):
 26        namespace = ontology
 27        comment = "The unique identifier (part number) of the device."
 28
 29    class hasDeviceSchema(owl.DataProperty, owl.FunctionalProperty):
 30        namespace = ontology
 31        comment = "How to format the device identifier."
 32        domain = [DeviceIdentifier]
 33        range = [str]
 34
 35    class hasDevicePlatform(owl.DataProperty, owl.FunctionalProperty):
 36        namespace = ontology
 37        domain = [DeviceIdentifier]
 38        range = [str]
 39
 40    class hasDeviceFamily(owl.DataProperty, owl.FunctionalProperty):
 41        namespace = ontology
 42        domain = [DeviceIdentifier]
 43        range = [str]
 44
 45    class hasDeviceName(owl.DataProperty, owl.FunctionalProperty):
 46        namespace = ontology
 47        domain = [DeviceIdentifier]
 48        range = [str]
 49
 50    class hasDevicePin(owl.DataProperty, owl.FunctionalProperty):
 51        namespace = ontology
 52        domain = [DeviceIdentifier]
 53        range = [str]
 54
 55    class hasDeviceSize(owl.DataProperty, owl.FunctionalProperty):
 56        namespace = ontology
 57        domain = [DeviceIdentifier]
 58        range = [str]
 59
 60    class hasDevicePackage(owl.DataProperty, owl.FunctionalProperty):
 61        namespace = ontology
 62        domain = [DeviceIdentifier]
 63        range = [str]
 64
 65    class hasDeviceTemperature(owl.DataProperty, owl.FunctionalProperty):
 66        namespace = ontology
 67        domain = [DeviceIdentifier]
 68        range = [str]
 69
 70    class hasDeviceVariant(owl.DataProperty, owl.FunctionalProperty):
 71        namespace = ontology
 72        domain = [DeviceIdentifier]
 73        range = [str]
 74
 75    class hasDeviceCore(owl.DataProperty, owl.FunctionalProperty):
 76        namespace = ontology
 77        domain = [DeviceIdentifier]
 78        range = [str]
 79
 80    # ------------------------------- MEMORIES --------------------------------
 81    class Memory(owl.Thing):
 82        namespace = ontology
 83        comment = "Internal memory."
 84
 85    class hasMemoryStartAddress(owl.DataProperty, owl.FunctionalProperty):
 86        namespace = ontology
 87        domain = [Memory]
 88        range = [int]
 89
 90    class hasMemorySize(owl.DataProperty, owl.FunctionalProperty):
 91        namespace = ontology
 92        domain = [Memory]
 93        range = [int]
 94
 95    class hasMemoryAccess(owl.DataProperty, owl.FunctionalProperty):
 96        namespace = ontology
 97        domain = [Memory]
 98        range = [str]
 99
100    class hasMemory(DeviceIdentifier >> Memory):
101        namespace = ontology
102
103    # ------------------------------ INTERRUPTS -------------------------------
104    class InterruptVector(owl.Thing):
105        namespace = ontology
106        comment = "Interrupt vector in the table."
107
108    class hasInterruptVectorPosition(owl.DataProperty, owl.FunctionalProperty):
109        namespace = ontology
110        domain = [InterruptVector]
111        range = [int]
112
113    class hasInterruptVector(owl.ObjectProperty):
114        namespace = ontology
115        domain = [DeviceIdentifier]
116        range = [InterruptVector]
117
118    # --------------------------------- PINS ----------------------------------
119    class Package(owl.Thing):
120        namespace = ontology
121        comment = "A device package identifier"
122        domain = [DeviceIdentifier]
123
124    class hasPackagePinCount(owl.DataProperty, owl.FunctionalProperty):
125        namespace = ontology
126        domain = [Package]
127        range = [int]
128
129    class hasPackage(DeviceIdentifier >> Package):
130        namespace = ontology
131
132    class Pin(owl.Thing):
133        namespace = ontology
134        comment = "A pin on a package."
135
136    class hasPinType(owl.DataProperty, owl.FunctionalProperty):
137        namespace = ontology
138        domain = [Pin]
139        range = [str]
140
141    class hasPinNumber(owl.DataProperty, owl.FunctionalProperty):
142        namespace = ontology
143        domain = [Pin]
144        range = [int]
145
146    class hasPort(owl.DataProperty, owl.FunctionalProperty):
147        namespace = ontology
148        domain = [Pin]
149        range = [str]
150
151    class hasPin(owl.ObjectProperty):
152        namespace = ontology
153        domain = [Package]
154        range = [Pin]
155
156    class pinPosition(owl.AnnotationProperty):
157        namespace = ontology
158        comment = "The pin position attached to the [Package, hasPin, Pin] relation."
159
160    # -------------------------------- SIGNALS --------------------------------
161    class Signal(owl.Thing):
162        namespace = ontology
163        comment = "Connects a pin with a peripheral function."
164
165    class AlternateFunction(Signal):
166        namespace = ontology
167        comment = "Connects to a digital peripheral function via multiplexer."
168
169    class AdditionalFunction(Signal):
170        namespace = ontology
171        comment = "Connects to an analog/special peripheral function."
172
173    class hasSignal(owl.ObjectProperty):
174        namespace = ontology
175        domain = [Pin]
176        range = [Signal]
177
178    class alternateFunction(owl.AnnotationProperty):
179        namespace = ontology
180        comment = "The AF number attached to the [Pin, hasSignal, AlternateFunction] relation."
181
182    # ------------------------------ PERIPHERALS ------------------------------
183    class Peripheral(owl.Thing):
184        namespace = ontology
185        comment = "Internal peripheral."
186
187    class hasPeripheralInstance(owl.DataProperty, owl.FunctionalProperty):
188        namespace = ontology
189        domain = [Peripheral]
190        range = [int]
191
192    class hasPeripheralType(owl.DataProperty, owl.FunctionalProperty):
193        namespace = ontology
194        domain = [Peripheral]
195        range = [str]
196
197    class hasPeripheral(owl.ObjectProperty):
198        namespace = ontology
199        domain = [DeviceIdentifier, Signal]
200        range = [Peripheral]
201
202    # ----------------------------- FLASH LATENCY -----------------------------
203    class FlashWaitState(owl.Thing):
204        namespace = ontology
205        comment = "Flash Latency for minimum frequency."
206
207    class hasWaitState(owl.DataProperty, owl.FunctionalProperty):
208        namespace = ontology
209        domain = [FlashWaitState]
210        range = [int]
211
212    class hasMaxFrequency(owl.DataProperty, owl.FunctionalProperty):
213        namespace = ontology
214        domain = [FlashWaitState]
215        range = [int]
216
217    class hasMinOperatingVoltage(owl.DataProperty, owl.FunctionalProperty):
218        namespace = ontology
219        domain = [FlashWaitState]
220        range = [float]
221
222    class hasFlashWaitState(owl.ObjectProperty):
223        namespace = ontology
224        domain = [DeviceIdentifier]
225        range = [FlashWaitState]
226
227    # -------------------------------- GENERAL --------------------------------
228    class hasName(owl.DataProperty, owl.FunctionalProperty):
229        namespace = ontology
230        domain = [Memory, Signal, Peripheral, Package, Pin]
231        range = [str]
232
233    return KeyDict(locals())