TDF and TDF script changes (application changes pending):

- Added new `pad` element to TDFs
- Refactored `pin` and `signal` elements to accommodate new `pad` element
- Improved validation of signal-to-pad relation in TDF validation script
- Added key attribute to `variant` element
- Removed `package` attribute from `variant` element
This commit is contained in:
Nav
2024-08-13 22:17:49 +01:00
parent d44eb49ca1
commit 8ba29c258d
269 changed files with 60017 additions and 48825 deletions

View File

@@ -5,6 +5,7 @@ use DOMDocument;
use DOMNode;
use DOMNodeList;
use DOMElement;
use Targets\TargetDescriptionFiles\Pad;
use Targets\TargetDescriptionFiles\Services\StringService;
use Targets\TargetDescriptionFiles\Services\Xml\Exceptions\XmlParsingException;
use Targets\TargetDescriptionFiles\AddressSpace;
@@ -370,7 +371,7 @@ class FromXmlService
$attributes = $this->getNodeAttributesByName($element);
return new Signal(
$attributes['pad-id'] ?? null,
$attributes['pad-key'] ?? null,
$this->stringService->tryStringToInt($attributes['index'] ?? null),
$attributes['function'] ?? null,
$attributes['group'] ?? null,
@@ -378,6 +379,16 @@ class FromXmlService
);
}
public function padFromElement(DOMElement $element): Pad
{
$attributes = $this->getNodeAttributesByName($element);
return new Pad(
$attributes['key'] ?? null,
$attributes['name'] ?? null
);
}
public function pinoutFromElement(DOMElement $element): Pinout
{
$attributes = $this->getNodeAttributesByName($element);
@@ -409,7 +420,7 @@ class FromXmlService
return new Pin(
$attributes['position'] ?? null,
$attributes['pad'] ?? null
$attributes['pad-key'] ?? null
);
}
@@ -418,9 +429,9 @@ class FromXmlService
$attributes = $this->getNodeAttributesByName($element);
return new Variant(
$attributes['key'] ?? null,
$attributes['name'] ?? null,
$attributes['pinout-key'] ?? null,
$attributes['package'] ?? null
$attributes['pinout-key'] ?? null
);
}
}

View File

@@ -8,6 +8,7 @@ use Targets\TargetDescriptionFiles\BitField;
use Targets\TargetDescriptionFiles\MemorySegment;
use Targets\TargetDescriptionFiles\MemorySegmentSection;
use Targets\TargetDescriptionFiles\Module;
use Targets\TargetDescriptionFiles\Pad;
use Targets\TargetDescriptionFiles\Peripheral;
use Targets\TargetDescriptionFiles\RegisterGroupInstance;
use Targets\TargetDescriptionFiles\PhysicalInterface;
@@ -185,7 +186,7 @@ class ToXmlService
public function signalToXml(Signal $signal, DOMDocument $document): DOMElement
{
$element = $document->createElement('signal');
$element->setAttribute('pad-id', $signal->padId);
$element->setAttribute('pad-key', $signal->padKey);
if ($signal->index !== null) {
$element->setAttribute('index', $signal->index);
@@ -349,6 +350,15 @@ class ToXmlService
return $element;
}
public function padToXml(Pad $pad, DOMDocument $document): DOMElement
{
$element = $document->createElement('pad');
$element->setAttribute('key', $pad->key);
$element->setAttribute('name', $pad->name);
return $element;
}
public function pinoutToXml(Pinout $pinout, DOMDocument $document): DOMElement
{
$element = $document->createElement('pinout');
@@ -371,7 +381,10 @@ class ToXmlService
{
$element = $document->createElement('pin');
$element->setAttribute('position', $pin->position);
$element->setAttribute('pad', $pin->pad);
if (!empty($pin->padKey)) {
$element->setAttribute('pad-key', $pin->padKey);
}
return $element;
}
@@ -379,9 +392,9 @@ class ToXmlService
public function variantToXml(Variant $variant, DOMDocument $document): DOMElement
{
$element = $document->createElement('variant');
$element->setAttribute('key', $variant->key);
$element->setAttribute('name', $variant->name);
$element->setAttribute('pinout-key', $variant->pinoutKey);
$element->setAttribute('package', $variant->package);
return $element;
}

View File

@@ -98,6 +98,14 @@ class XmlService
$tdf->modules[] = $this->fromXmlService->moduleFromElement($element);
}
$padElements = $this->fromXmlService->getDeviceElementsFromXPath(
'pads/pad',
$document
);
foreach ($padElements as $element) {
$tdf->pads[] = $this->fromXmlService->padFromElement($element);
}
$pinoutElements = $this->fromXmlService->getDeviceElementsFromXPath(
'pinouts/pinout',
$document
@@ -186,6 +194,13 @@ class XmlService
$deviceElement->append($modulesElement);
$padsElement = $document->createElement('pads');
foreach ($tdf->pads as $pad) {
$padsElement->append($this->toXmlService->padToXml($pad, $document));
}
$deviceElement->append($padsElement);
$pinoutsElement = $document->createElement('pinouts');
foreach ($tdf->pinouts as $pinout) {
$pinoutsElement->append($this->toXmlService->pinoutToXml($pinout, $document));