Maybe a bad title--I don't really know Groovy, except as it is similar to C++ and scripting languages that support OO constructs.
I have a data structures that I'd like multiple methods in a device driver to access. For example:
def mediaInputs =
[
// This map is keyed by the device name--this must be an enry in the lirc server's conf file /etc/lircd/lirc.conf
// The value's correspond to remote keys that control which input is selected on that device
"STR-DE985": [
valid_inputs:["MD/DAT","TV/SAT","VIDEO1/AUX","VIDEO_2","VIDEO_3"],
streaming_input:"VIDEO1/AUX",
satellite_input: "VIDEO_2"
],
"panny": [
valid_inputs:["HDMI_1", "HDMI_2", "HDMI_3", "VIDEO_1", "VIDEO_2", "VIDEO_3", "VIDEO_4"],
streaming_input:"VIDEO1/AUX",
satellite_input: "VIDEO_2"
],
"RC-R0900": [
valid_inputs:["VIDEO1", "VIDEO2","VIDEO3","TAPE_1", "TAPE_2"],
streaming_input:"",
satellite_input: ""
]
]
But, I can demonstrate my ignorance more simply:
def myVar = "hello"
How do I access myVar in driver method?
I've tried everything that's commented in this method:
def logConfig()
{
//key = device.getName()
//log.info $myVar nothing prints
//log.info "$myVar" "null" is printed
// log.info "${myVar} nothing prints
//log.info this.myVar nothing prints
// log.info ${this}.myVar 2021-05-30 10:05:05.081 am errororg.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: user_driver_Flying_Nerd_IR_Control_503.$() is applicable for argument types: (user_driver_Flying_Nerd_IR_Control_503$_logConfig_closure3) values: [user_driver_Flying_Nerd_IR_Control_503$_logConfig_closure3@163c267]
//log.info this.$myvar nothingPrints
}
So, what is the correct syntax to use in a driver method to access a variable like myVar (or, mediaInputs)?