getLinkedValue() in script ?

Quote from LWT98709 on February 22, 2025, 2:09 amHello !
In the "Linked component" page, it says that scripted components can be linked. But, how can we retrieve the linked value? There is no getLinkedValue() function?
Hello !
In the "Linked component" page, it says that scripted components can be linked. But, how can we retrieve the linked value? There is no getLinkedValue() function?

Quote from arcachofo on February 22, 2025, 4:34 pmBut, how can we retrieve the linked value? There is no getLinkedValue() function?
No, there is no getLinkedValue() function.
A component can send data to others, not retrieve.
What each component can do is listed in the page you merntioned: https://simulide.com/p/linking-components/
But, how can we retrieve the linked value? There is no getLinkedValue() function?
No, there is no getLinkedValue() function.
A component can send data to others, not retrieve.
What each component can do is listed in the page you merntioned: https://simulide.com/p/linking-components/

Quote from LWT98709 on February 22, 2025, 5:47 pmI am simulating a heating resistor / NTC thermistor pair.
Both components are scripted components.
The heating resistor calculates the temperature based on its dissipated power.
The thermistor must retrieve this temperature. But how?Desired scenario: the resistor links the thermistor (resistor = linker, thermistor = linked). The resistor does setLinkedValue(). But how from the thermistor script to retrieve the value?
Finally, I found a workaround ...
The thermistor links the resistor (thermistor = linker, resistor = linked). The resistor has a "secret" property called "Temperature" that is updated by the resistor script. The thermistor uses getPropStr(0, "Temperature) to retrieve this property, then parseFloat() it to retrieve the temperature.
I am simulating a heating resistor / NTC thermistor pair.
Both components are scripted components.
The heating resistor calculates the temperature based on its dissipated power.
The thermistor must retrieve this temperature. But how?
Desired scenario: the resistor links the thermistor (resistor = linker, thermistor = linked). The resistor does setLinkedValue(). But how from the thermistor script to retrieve the value?
Finally, I found a workaround ...
The thermistor links the resistor (thermistor = linker, resistor = linked). The resistor has a "secret" property called "Temperature" that is updated by the resistor script. The thermistor uses getPropStr(0, "Temperature) to retrieve this property, then parseFloat() it to retrieve the temperature.

Quote from arcachofo on February 22, 2025, 6:47 pmYou can do much simpler and efficient than using Property + parseFloat().
Following what happens in the circuit:
The resistor emits heat, so just link resistor to thermistor and resistor sends data to thermistor.How to do:
Resistor links to thermistor, it has index 0 (there is no other component linked).
in resistor script, when voltage changes call:component.setLinkedValue( 0, heatData, 0 ); // This will call thermistor script
Then in thermistor script you implement the function that will be called:
void setLinkedValue( double heatData, int i ) { double current = heatData*k; // Do whatever you want with heatData // You can also use parameter int i for whatever you want }
You can do much simpler and efficient than using Property + parseFloat().
Following what happens in the circuit:
The resistor emits heat, so just link resistor to thermistor and resistor sends data to thermistor.
How to do:
Resistor links to thermistor, it has index 0 (there is no other component linked).
in resistor script, when voltage changes call:
component.setLinkedValue( 0, heatData, 0 ); // This will call thermistor script
Then in thermistor script you implement the function that will be called:
void setLinkedValue( double heatData, int i )
{
double current = heatData*k; // Do whatever you want with heatData
// You can also use parameter int i for whatever you want
}

Quote from LWT98709 on February 22, 2025, 7:38 pmAh OK ! Thanks.
This is what I was looking for.
It's more a kind of callback function than if the linked component has to retrieve the value. Understood.
Ah OK ! Thanks.
This is what I was looking for.
It's more a kind of callback function than if the linked component has to retrieve the value. Understood.