Use enumeration in mappView

Hi Tommy,

I have a tip for you, maybe complex to implement with value like 127 and 261…

I’ve same problem but for PLCOpen state of an axis, here is a solution :

  • You use a DropDownBox where you force enable to false
  • Style your DropDownBox to look like TextOutput, think about that you need to edit Disabled style, DropDownBox will be disabled
  • Create the dataprovider you need, I’ve created yours using a python script:
# Construction of json dataprovider
text_to_write: str = "["

for i in range(0, 262):
    text: str = ""
    match i:
        case 0: text = "INITIALISATION"
        case 1: text = "RESET_COMM"
        case 2: text = "RESET_APP"
        case 3: text = "PRE_OPERATIONAL"
        case 4: text = "STOPPED"
        case 5: text = "OPERATIONAL"
        case 6: text = "UNKNOW_ERROR"
        case 127: text = "PRE_OPERATIONAL"
        case 261: text = "OPERATIONAL + Module OK"
    text_to_write += f"{{'value': '{i}', 'text': '{text}' }},"
# Delete last comma to have a valid dataprovider
text_to_write = text_to_write[:-1]

text_to_write += "]"

# Write to a file
with open("test.json", "w") as f:
    f.write(text_to_write)

You can open the content in xml where you created the DropDownBox and copy paste the dataProvider generated

<Widget xsi:type="widgets.brease.DropDownBox" id="DropDownBox1" top="90" left="325" width="320" zIndex="0" dataProvider="[{'value':'0','text':'INITIALISATION'},{'value':'1','text':'RESET_COMM'},{'value':'2','text':'RESET_APP'},{'value':'3','text':'PRE_OPERATIONAL'},{'value':'4','text':'STOPPED'},{'value':'5','text':'OPERATIONAL'},{'value':'6','text':'UNKNOW_ERROR'},{'value':'7','text':''},{'value':'8','text':''},{'value':'9','text':''},{'value':'10','text':''},{'value':'11','text':''},{'value':'12','text':''},{'value':'13','text':''},{'value':'14','text':''},{'value':'15','text':''},{'value':'16','text':''},{'value':'17','text':''},{'value':'18','text':''},{'value':'19','text':''},{'value':'20','text':''},{'value':'21','text':''},{'value':'22','text':''},{'value':'23','text':''},{'value':'24','text':''},{'value':'25','text':''},{'value':'26','text':''},{'value':'27','text':''},{'value':'28','text':''},{'value':'29','text':''},{'value':'30','text':''},{'value':'31','text':''},{'value':'32','text':''},{'value':'33','text':''},{'value':'34','text':''},{'value':'35','text':''},{'value':'36','text':''},{'value':'37','text':''},{'value':'38','text':''},{'value':'39','text':''},{'value':'40','text':''},{'value':'41','text':''},{'value':'42','text':''},{'value':'43','text':''},{'value':'44','text':''},{'value':'45','text':''},{'value':'46','text':''},{'value':'47','text':''},{'value':'48','text':''},{'value':'49','text':''},{'value':'50','text':''},{'value':'51','text':''},{'value':'52','text':''},{'value':'53','text':''},{'value':'54','text':''},{'value':'55','text':''},{'value':'56','text':''},{'value':'57','text':''},{'value':'58','text':''},{'value':'59','text':''},{'value':'60','text':''},{'value':'61','text':''},{'value':'62','text':''},{'value':'63','text':''},{'value':'64','text':''},{'value':'65','text':''},{'value':'66','text':''},{'value':'67','text':''},{'value':'68','text':''},{'value':'69','text':''},{'value':'70','text':''},{'value':'71','text':''},{'value':'72','text':''},{'value':'73','text':''},{'value':'74','text':''},{'value':'75','text':''},{'value':'76','text':''},{'value':'77','text':''},{'value':'78','text':''},{'value':'79','text':''},{'value':'80','text':''},{'value':'81','text':''},{'value':'82','text':''},{'value':'83','text':''},{'value':'84','text':''},{'value':'85','text':''},{'value':'86','text':''},{'value':'87','text':''},{'value':'88','text':''},{'value':'89','text':''},{'value':'90','text':''},{'value':'91','text':''},{'value':'92','text':''},{'value':'93','text':''},{'value':'94','text':''},{'value':'95','text':''},{'value':'96','text':''},{'value':'97','text':''},{'value':'98','text':''},{'value':'99','text':''},{'value':'100','text':''},{'value':'101','text':''},{'value':'102','text':''},{'value':'103','text':''},{'value':'104','text':''},{'value':'105','text':''},{'value':'106','text':''},{'value':'107','text':''},{'value':'108','text':''},{'value':'109','text':''},{'value':'110','text':''},{'value':'111','text':''},{'value':'112','text':''},{'value':'113','text':''},{'value':'114','text':''},{'value':'115','text':''},{'value':'116','text':''},{'value':'117','text':''},{'value':'118','text':''},{'value':'119','text':''},{'value':'120','text':''},{'value':'121','text':''},{'value':'122','text':''},{'value':'123','text':''},{'value':'124','text':''},{'value':'125','text':''},{'value':'126','text':''},{'value':'127','text':'PRE_OPERATIONAL'},{'value':'128','text':''},{'value':'129','text':''},{'value':'130','text':''},{'value':'131','text':''},{'value':'132','text':''},{'value':'133','text':''},{'value':'134','text':''},{'value':'135','text':''},{'value':'136','text':''},{'value':'137','text':''},{'value':'138','text':''},{'value':'139','text':''},{'value':'140','text':''},{'value':'141','text':''},{'value':'142','text':''},{'value':'143','text':''},{'value':'144','text':''},{'value':'145','text':''},{'value':'146','text':''},{'value':'147','text':''},{'value':'148','text':''},{'value':'149','text':''},{'value':'150','text':''},{'value':'151','text':''},{'value':'152','text':''},{'value':'153','text':''},{'value':'154','text':''},{'value':'155','text':''},{'value':'156','text':''},{'value':'157','text':''},{'value':'158','text':''},{'value':'159','text':''},{'value':'160','text':''},{'value':'161','text':''},{'value':'162','text':''},{'value':'163','text':''},{'value':'164','text':''},{'value':'165','text':''},{'value':'166','text':''},{'value':'167','text':''},{'value':'168','text':''},{'value':'169','text':''},{'value':'170','text':''},{'value':'171','text':''},{'value':'172','text':''},{'value':'173','text':''},{'value':'174','text':''},{'value':'175','text':''},{'value':'176','text':''},{'value':'177','text':''},{'value':'178','text':''},{'value':'179','text':''},{'value':'180','text':''},{'value':'181','text':''},{'value':'182','text':''},{'value':'183','text':''},{'value':'184','text':''},{'value':'185','text':''},{'value':'186','text':''},{'value':'187','text':''},{'value':'188','text':''},{'value':'189','text':''},{'value':'190','text':''},{'value':'191','text':''},{'value':'192','text':''},{'value':'193','text':''},{'value':'194','text':''},{'value':'195','text':''},{'value':'196','text':''},{'value':'197','text':''},{'value':'198','text':''},{'value':'199','text':''},{'value':'200','text':''},{'value':'201','text':''},{'value':'202','text':''},{'value':'203','text':''},{'value':'204','text':''},{'value':'205','text':''},{'value':'206','text':''},{'value':'207','text':''},{'value':'208','text':''},{'value':'209','text':''},{'value':'210','text':''},{'value':'211','text':''},{'value':'212','text':''},{'value':'213','text':''},{'value':'214','text':''},{'value':'215','text':''},{'value':'216','text':''},{'value':'217','text':''},{'value':'218','text':''},{'value':'219','text':''},{'value':'220','text':''},{'value':'221','text':''},{'value':'222','text':''},{'value':'223','text':''},{'value':'224','text':''},{'value':'225','text':''},{'value':'226','text':''},{'value':'227','text':''},{'value':'228','text':''},{'value':'229','text':''},{'value':'230','text':''},{'value':'231','text':''},{'value':'232','text':''},{'value':'233','text':''},{'value':'234','text':''},{'value':'235','text':''},{'value':'236','text':''},{'value':'237','text':''},{'value':'238','text':''},{'value':'239','text':''},{'value':'240','text':''},{'value':'241','text':''},{'value':'242','text':''},{'value':'243','text':''},{'value':'244','text':''},{'value':'245','text':''},{'value':'246','text':''},{'value':'247','text':''},{'value':'248','text':''},{'value':'249','text':''},{'value':'250','text':''},{'value':'251','text':''},{'value':'252','text':''},{'value':'253','text':''},{'value':'254','text':''},{'value':'255','text':''},{'value':'256','text':''},{'value':'257','text':''},{'value':'258','text':''},{'value':'259','text':''},{'value':'260','text':''},{'value':'261','text':'OPERATIONAL + Module OK'}]" enable="false" />
  • Last step is to create a binding from your DropDownBox, you bind “selectedIndex” to any integer or enumeration. Please use oneWay (Read Only) binding
<Binding mode="oneWay">
	<Source xsi:type="opcUa" refId="::AsGlobalPV:test_enumeration" attribute="value" />
	<Target xsi:type="brease" contentRefId="content_test" widgetRefId="DropDownBox1" attribute="selectedIndex" />
</Binding>

Hope this help !
Regards,
Florent

1 Like