Hi,
I would like to change the value of PropertyValues which are created using PVMT addon, to do this I’ve created the following code:
include('workspace://Python4Capella/simplified_api/capella.py')
if False:
from simplified_api.capella import *
# include needed for utilities
include('workspace://Python4Capella/utilities/CapellaPlatform.py')
if False:
from utilities.CapellaPlatform import *
# include needed for the requirement API
include('workspace://Python4Capella/simplified_api/requirement.py')
if False:
from simplified_api.requirement import *
# include needed for the pvmt API
include('workspace://Python4Capella/simplified_api/pvmt.py')
if False:
from simplified_api.pvmt import *
import pandas as pd
import numpy as np
aird_path = '/In-Flight Entertainment System/In-Flight Entertainment System.aird'
model = CapellaModel()
model.open(aird_path)
model = CapellaModel()
model.open(aird_path)
# gets the SystemEngineering and print its name
se = model.get_system_engineering()
pc_pkg = se.get_physical_architecture().get_physical_component_pkg()
data = {'PC_name':['ComponentA', 'ComponentB'],
'PV':['SafetyLevel', 'SafetyLevel']
, 'PV_value':['DAL_D','DAL_A']}
df = pd.DataFrame(data)
df = df.set_index("PC_name", drop = False)
allPC=se.get_all_contents_by_type(PhysicalComponent)
model.start_transaction()
try:
for pc in allPC:
for pvName in PVMT.get_p_v_names(pc):
pc_name=pc.get_name()
pv_values=PVMT.get_p_v_value(pc, pvName)
print("PC: ", pc_name, pvName, pv_values)
if pc.get_name() in df['PC_name'].values and pvName in df['PV'].values :
row = df.loc[pc_name, : ]
pv_value=row['PV_value']
print("update to", pv_value)
except:
# if something went wrong we rollback the transaction
model.rollback_transaction()
raise
else:
# if everything is ok we commit the transaction
model.commit_transaction()
# save the Capella model
model.save()
being a PropertyValue of type EnumerationPropertyValue in Type is EnumerationPropertyType and in value is EnumerationPropertyLiteral which are stored in the extension folder
and if I try to get the EnumerationPropertyType and its EnumerationPropertyLiteral executing the following code , I get other values that are not in the extension folder.
for x in se.get_all_contents_by_type(EnumerationPropertyType):
print(x.get_name())
for y in x.get_all_contents_by_type(EnumerationPropertyLiteral):
print(y.get_name())
Does anyone know how to change these values?
Thanks you !