1. basyx 패키지 install
$pip install basyx-python-sdk
2. Adapter class 생성 및 필요한 method 구현
import json as js
from io import BytesIO
from fastapi import HTTPException
from basyx.aas import model
from basyx.aas.adapter import aasx, json
from config import logger
class AASXAdapter:
def read_aasx(self, aasx_file):
new_object_store: model.DictObjectStore[model.Identifiable] = (model.DictObjectStore()) # for adding elements
new_file_store = aasx.DictSupplementaryFileContainer()
# Read aasx file
try:
with aasx.AASXReader(BytesIO(aasx_file)) as f:
f.read_into(object_store=new_object_store, file_store=new_file_store)
except Exception as e:
logger.error(e)
raise HTTPException(status_code=501, detail="Invalid AASX File") # custom exception
# Transform to json
data = json.object_store_to_json(new_object_store)
data = js.loads(data)
return data
# 기존 explorer로 생성된 파일
http://www.admin-shell.io/aasx/relationships/aasx-origin
http://www.admin-shell.io/aas/2/0
# 튜토리얼 따라 생성한 파일
http://admin-shell.io/aasx/relationships/aasx-origin
https://admin-shell.io/aas/3/0 (버전으로 짐작)
1. git clone pyi40aas package
$git clone https://git.rwth-aachen.de/acplt/pyi40aas.git
2. 패키지 커스텀
필요한 json 구조에 맞춰 내부 코드 수정
3. 정상 작동 확인
