Now i was wondering how do i patch this code in VL having the phidget dll imported and everything showing up in the nodebrowser? i gave it a try naively but getting nowhere.
I have attached my vl project and also the c# code i am trying to patch. The phidget dll is also included.
The simplest working code as v4 node is this (without the plugin and pindefinitions clutter etc.)
VoltageInput vin = new VoltageInput();
bool init = true;
public void Init()
{
if (init)
{
vin.Open();
init = false;
}
}
//called when data for any output pin is requested
public void Evaluate(int SpreadMax)
{
Init();
FAttached[0] = vin.Attached;
}
How do i say that in VL?
I want to add eventhandlers and stuff later but at first i would like to see at least that “vin.Attached” turns true.
I know this might be difficult to answer when you do not have a phidget board around to try but maybe there is something pretty obvious you can point me to rightaway.
My naive approach that does nothing (also tried assigning create and update wildly, often ending in VL stalling):
great example, this should really be easy.
i did two things to your patch that i’d say should get it working:
insert a pad between Open and Attached because the Create->Open part you only want to do once (on Create), then store the VoltageInput to the pad, then read the Attached state every frame. insert the pad via: SHIFT+dblclick on the link
you’ve manually assigned Attached to “Create” as well. rightclick → Assign → Pop it, so it falls back to its default operation (ie. Update)
in alphas this will give you an error because now still the pad is not initialized but it should then look like this and you should save:
to re-run the constructor (Create) you ALT+rightclick (reset) the vvvv wrapper node. now for me this crashes vvvv completely but i’m assuming this is because i don’t have a device attached and you’d have to take some more precautions for that.
good. no need to worry about the yellow links in this case. hovering the link with the mouse will show you a warning message. it is about the fact that the VoltageInput type is mutable and in case two nodes downstream would write to it you’d need to be more careful…
This is really fun and i did some more to the plugin but i got stuck now with the event handling.
Im am not sure what pointer or method this means and what to connect there. When updated, it says the method must not be null. Also not sure how to use the invoke regions from the events-category really.
Codewise i would like it to react on attach-events for example: