Interesting feature that i would like to use

Quote from average_simulide_enjoyer on February 6, 2025, 3:13 pmin arcachofo's video about scripted components, he shows a couple components that link to other components.
In version 1.1.0-SR1, is it still possible to link to components? and if yes, how?
in arcachofo's video about scripted components, he shows a couple components that link to other components.
In version 1.1.0-SR1, is it still possible to link to components? and if yes, how?

Quote from average_simulide_enjoyer on February 6, 2025, 5:56 pmi figured it out after some trial and error with the video itself.
u must add to the mcu file
linker="true"
however, the documentation about how to use the functions with the linked components is a bit lacking. how can i retrieve and set text from/to a text component?
i figured it out after some trial and error with the video itself.
u must add to the mcu file linker="true"
however, the documentation about how to use the functions with the linked components is a bit lacking. how can i retrieve and set text from/to a text component?

Quote from arcachofo on February 6, 2025, 6:11 pmYou can see something in the voltmeter examples from this post: https://simulide.com/p/forum/topic/help-with-subcircuit-scripted-circuit/#postid-1838
Voltmeter1 uses a Text component to write the voltage.
You can see something in the voltmeter examples from this post: https://simulide.com/p/forum/topic/help-with-subcircuit-scripted-circuit/#postid-1838
Voltmeter1 uses a Text component to write the voltage.

Quote from average_simulide_enjoyer on February 6, 2025, 9:52 pmDamn, that's also my post and I didn't even see the text component...
On another note, I have another question. How can we send some specific thing about a component? For example, in ur video with the animated rectangles, u use setPropValue (or some similar name). This function is not even present in the documentation (however the get one is)
My specific need is to controll a switch to open or close, or to switch between channel 1 or 2 (if I choose the switch to have dual channel instead of being open or close)
In case we can use the set function U use in ur video, to know the name of the thing, is it literally the name of the property in the .sim1 file?
Damn, that's also my post and I didn't even see the text component...
On another note, I have another question. How can we send some specific thing about a component? For example, in ur video with the animated rectangles, u use setPropValue (or some similar name). This function is not even present in the documentation (however the get one is)
My specific need is to controll a switch to open or close, or to switch between channel 1 or 2 (if I choose the switch to have dual channel instead of being open or close)
In case we can use the set function U use in ur video, to know the name of the thing, is it literally the name of the property in the .sim1 file?

Quote from arcachofo on February 6, 2025, 10:57 pmYes, you can use setPropStr( int index, string property_name, string value )
With this one you can set any property in a linked component, but you need to know the actual property Id, which often is not the same than what you see in property widget. And some hidden properties don't show in property widget.For example you can set property "Checked" in Switches which is hidden, but I think it should work.
Let's say the script is linking a switch with index 2, then you could do:component.setPropStr( 2, "Checked", "true" ); component.setPropStr( 2, "Checked", "false" );
Yes, you can use setPropStr( int index, string property_name, string value )
With this one you can set any property in a linked component, but you need to know the actual property Id, which often is not the same than what you see in property widget. And some hidden properties don't show in property widget.
For example you can set property "Checked" in Switches which is hidden, but I think it should work.
Let's say the script is linking a switch with index 2, then you could do:
component.setPropStr( 2, "Checked", "true" );
component.setPropStr( 2, "Checked", "false" );

Quote from average_simulide_enjoyer on February 7, 2025, 10:50 ami didnt mean the property widget, but the simulation file. the components have their ID fields like Pos, rotation, etc. for example, a switch:
<item itemtype="Switch" CircId="Switch-14" mainComp="false" Show_id="false" Show_Val="false" Pos="16,-124" rotation="0" hflip="1" vflip="1" label="Switch-14" idLabPos="-16,-24" labelrot="0" valLabPos="-16,20" valLabRot="0" Norm_Close="false" DT="false" Poles="1" />
these are the non hidden IDs of some fields, correct?
i still dont see "Checked", cuz saving the simulation doesnt save the switch state, so its not used. But is there a place to see the ID of every property of every single component? Perhaps somewere inside the source code?
i didnt mean the property widget, but the simulation file. the components have their ID fields like Pos, rotation, etc. for example, a switch:
<item itemtype="Switch" CircId="Switch-14" mainComp="false" Show_id="false" Show_Val="false" Pos="16,-124" rotation="0" hflip="1" vflip="1" label="Switch-14" idLabPos="-16,-24" labelrot="0" valLabPos="-16,20" valLabRot="0" Norm_Close="false" DT="false" Poles="1" />
these are the non hidden IDs of some fields, correct?
i still dont see "Checked", cuz saving the simulation doesnt save the switch state, so its not used. But is there a place to see the ID of every property of every single component? Perhaps somewere inside the source code?

Quote from arcachofo on February 7, 2025, 11:13 ami didnt mean the property widget, but the simulation file. the components have their ID fields like Pos, rotation, etc. for example, a switch:
Ok, now I understand what you mean.
You are right, in the .sim1 file you can see property Ids.And I see that "Checked" was added in version 1.2.0, maybe it should be added to 1.1.0 as well.
You can see properties in the source code, but not in one place, each component adds it's properties in it's own file.
i didnt mean the property widget, but the simulation file. the components have their ID fields like Pos, rotation, etc. for example, a switch:
Ok, now I understand what you mean.
You are right, in the .sim1 file you can see property Ids.
And I see that "Checked" was added in version 1.2.0, maybe it should be added to 1.1.0 as well.
You can see properties in the source code, but not in one place, each component adds it's properties in it's own file.

Quote from average_simulide_enjoyer on February 8, 2025, 12:04 pmdue to the lack of that property, i decided to use
"Norm_Close"
it should work still, but "Checked" property would be helpfull.
And btw, i never used a repo in my life, where can i find the code of all or most components? i tried the repo that is in resources/knowledge base/source code (in this website), and i didnt find them. probably searched in the wrong spot
due to the lack of that property, i decided to use "Norm_Close"
it should work still, but "Checked" property would be helpfull.
And btw, i never used a repo in my life, where can i find the code of all or most components? i tried the repo that is in resources/knowledge base/source code (in this website), and i didnt find them. probably searched in the wrong spot

Quote from average_simulide_enjoyer on February 8, 2025, 6:18 pmim stuck trying something. im trying to make a read of open circuit voltage (shorted to groundto ground) and shorted current, so i can get the output impedance of a circuit. however, when i close the switch to read the shorted current, the voltage changes obviously, and it overrites the voltage variable. this is the implementation of updateStep:
bool first_read = true; void updateStep() // Executed at the simulation fps { if (!volt_changed or ignore_voltage_change) return; ignore_voltage_change = true; print("i was here"); if (measure_out_impedance) { component.setPropStr(4, "Norm_Close", "true"); // voltage input to in component.setPropStr(5, "Norm_Close", "true"); // current output to out component.setPropStr(3, "Norm_Close", "false"); // voltage output to ground if (first_read) volt = abs(Vin.getVoltage()); else first_read = false; //only read voltage once voltage = calculateUnits(volt, 1, 5); // get open circuit voltage Vout.setVoltage(volt); // output the read voltage //component.setPropStr(4, "Norm_Close", "false"); // voltage input to source component.setPropStr(5, "Norm_Close", "false"); // current output to ground curr = abs(Iin.getVoltage()); current = calculateUnits(curr, 2, 5); // get short circuit current print("a\nv = " + volt + "\ni = " + curr); } else { component.setPropStr(3, "Norm_Close", "true"); component.setPropStr(4, "Norm_Close", "true"); component.setPropStr(5, "Norm_Close", "true"); // reset pins for measurement volt = abs(Vin.getVoltage()); curr = abs(Iin.getVoltage()); voltage = calculateUnits(volt, 1, 5); current = calculateUnits(curr, 2, 5); } impedance = calculateUnits(1, 0, 11); sendValues(); ignore_voltage_change = false; volt_changed = false; }
btw, for some reason linked component 4 (a double throw switch) doesnt like to return to the normal state of normally closed after i make it normally open, as when it switches it stays stuck there
im stuck trying something. im trying to make a read of open circuit voltage (shorted to groundto ground) and shorted current, so i can get the output impedance of a circuit. however, when i close the switch to read the shorted current, the voltage changes obviously, and it overrites the voltage variable. this is the implementation of updateStep:
bool first_read = true;
void updateStep() // Executed at the simulation fps
{
if (!volt_changed or ignore_voltage_change) return;
ignore_voltage_change = true;
print("i was here");
if (measure_out_impedance) {
component.setPropStr(4, "Norm_Close", "true"); // voltage input to in
component.setPropStr(5, "Norm_Close", "true"); // current output to out
component.setPropStr(3, "Norm_Close", "false"); // voltage output to ground
if (first_read) volt = abs(Vin.getVoltage());
else first_read = false; //only read voltage once
voltage = calculateUnits(volt, 1, 5); // get open circuit voltage
Vout.setVoltage(volt); // output the read voltage
//component.setPropStr(4, "Norm_Close", "false"); // voltage input to source
component.setPropStr(5, "Norm_Close", "false"); // current output to ground
curr = abs(Iin.getVoltage());
current = calculateUnits(curr, 2, 5); // get short circuit current
print("a\nv = " + volt + "\ni = " + curr);
}
else {
component.setPropStr(3, "Norm_Close", "true");
component.setPropStr(4, "Norm_Close", "true");
component.setPropStr(5, "Norm_Close", "true"); // reset pins for measurement
volt = abs(Vin.getVoltage());
curr = abs(Iin.getVoltage());
voltage = calculateUnits(volt, 1, 5);
current = calculateUnits(curr, 2, 5);
}
impedance = calculateUnits(1, 0, 11);
sendValues();
ignore_voltage_change = false;
volt_changed = false;
}
btw, for some reason linked component 4 (a double throw switch) doesnt like to return to the normal state of normally closed after i make it normally open, as when it switches it stays stuck there

Quote from arcachofo on February 8, 2025, 6:38 pmWithout the circuit and complete code I can't know very much, but I see some possible issues:
Lines 12 & 13 in your code above (not is your sources I guess)
if (first_read) volt = abs(Vin.getVoltage()); else first_read = false; //only read voltage once
If first_read is true then it will be true again. Never become false.
Then in lines 10 and 19 you close and open switch 5, but all this is happening at the same time, so the first one just do nothing:
component.setPropStr(5, "Norm_Close", "true"); // current output to out component.setPropStr(5, "Norm_Close", "false"); // current output to ground
You need to open or close switches, wait for the switches to actually do it and the circuit to update voltages and at next updateStep() you can read voltages.
I guess this is the same problem for switch 4.
Without the circuit and complete code I can't know very much, but I see some possible issues:
Lines 12 & 13 in your code above (not is your sources I guess)
if (first_read) volt = abs(Vin.getVoltage());
else first_read = false; //only read voltage once
If first_read is true then it will be true again. Never become false.
Then in lines 10 and 19 you close and open switch 5, but all this is happening at the same time, so the first one just do nothing:
component.setPropStr(5, "Norm_Close", "true"); // current output to out
component.setPropStr(5, "Norm_Close", "false"); // current output to ground
You need to open or close switches, wait for the switches to actually do it and the circuit to update voltages and at next updateStep() you can read voltages.
I guess this is the same problem for switch 4.