Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for arbitrary data mapping #58

Open
Joshpolansky opened this issue Dec 14, 2023 · 3 comments · May be fixed by #61
Open

Add support for arbitrary data mapping #58

Joshpolansky opened this issue Dec 14, 2023 · 3 comments · May be fixed by #61
Assignees

Comments

@Joshpolansky
Copy link
Member

add a data-map attribute that accepts json? Could also just see it accepting an array of key-value pairs. Could also allow selectors with the element as a scope.

something like:

OnUpdate(el){
For (map [key, pvname ])
El.querySelector(item) = machine.value(pvname)
}

or the simple version would just set like this:
image

@Joshpolansky
Copy link
Member Author

Joshpolansky commented Dec 14, 2023

I might also propose a more complex mapping, to accommodate all the other possibilities.

"[target attr]":{
"Data-var-name":"[pvname]",
"SourceUnits":"[unit type]",
"DisplayUnits": "[unit type]",
"Selector":"[css-selector]"
..
}

@sclaiborne
Copy link
Member

To clarify in the default case you are asking for data-map to map value (pv) to key (attribute) on the same element. So...

<ob-rudder-medium rudderAngle="0"
   rudderSetPointAngle="0"
   showPortStarboard="false"
   showSetPoint="false"
   data-map="{ 'rudderAngle' : 'tmplitTest:tmplit.Slider' , ' rudderSetPointAngle' : 'tmp1itTest:tmplit.Numericlnput' }"/>

Assuming variables tmplitTest:tmplit.Slider = 100 and tmp1itTest:tmplit.Numericlnput = 200 Then

<ob-rudder-medium rudderAngle="100"
   rudderSetPointAngle="200"
   showPortStarboard="false"
   showSetPoint="false"
   data-map="{ 'rudderAngle' : 'tmplitTest:tmplit.Slider' , ' rudderSetPointAngle' : 'tmp1itTest:tmplit.Numericlnput' }"/>

Then if 'rudderAngle' : started with a {, you would parse it for additional information?

@Joshpolansky
Copy link
Member Author

Joshpolansky commented Dec 15, 2023

Yes, but actually.. I would parse it and check if the parsed value was a string or object. If it's a string we assume it's a PV, but if it's an object we get the parameters from the object

@Joshpolansky Joshpolansky self-assigned this Jan 4, 2024
@Joshpolansky Joshpolansky linked a pull request Jan 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants