first, I cannot attach my vi files, sorry. I'm not allowed, but I can attach snippets.
I've got a vi that opens and executes functions from a script file, and I'd like to be able to continuously click a button to reload the script file without having to restart the program. Currently the script file commands sit outside my main while loop and and uses a case statement to put the system in idle mode (manual control) when the button is not depressed before launching the program, or if it is, it will instantly open a dialog box looking for a script file upon program launch. I'd like to be able to open a script file numerous times during the execution of my program, but don't fully understand how, and this may be my own misunderstanding of what's going on with the code if I move it inside the main while loop. how is this best accomplished?
If you put your code outside of the loop, it is only executed once (very important: "dataflow"). You need to put the code into a loop to execute it multiple times.
You can insert the vi-snippet into your vi by drag&drop.
My vi contains two different options. You can change the vi as you need it, my vi is incomplete. I inserted a simple 2D-Array because I'm not sure if the vi you use after building the path is selfmade or given by LabVIEW.
For both options you should let the code run in some kind of state machine and use an Event Structure (I think you already implemented your program this way since you wrote about a main loop).
Version 1:
Everytime you click the button, the event is triggered and the code inside the event structure is executed.
Version 2:
Here you set a boolean if the button is pressed and handle the event with that value.
Since you wrote that you already have a main while loop, this option might be better four you. The first loop would be your main-loop, second one would be the loop in Version 2. You just need to add another case for the script to be loaded in.
VI:
I hope this is helpful for your problem.
Feel free to ask if you need more help or if you have any questions :)
Related
I am building a NetLogo model that needs to integrate with another model (not NetLogo). So if the NetLogo model is set up to run continuously, at each tick I want it to wait for a file created by the linked model to appear within the parent folder. Once this file appears, NetLogo reads it in and continues with all the steps specified in Go. So essentially, i would like NetLogo to pause while it waits for the file and then once the file appears, resume. I tried using the 'while' function, but it did not do the job.
For example, when I set it up this way
to go
while [file-exists? "biosim.asc"][
grow-grass
grow-herd
delete-biosim
tick]
Here, NetLogo reads in the biosim file and after the procedures grow-grass, grow-herd are completed, the program deletes the ascii file biosim. Ideally I would like it to then wait for a new file by the name biosim to appear in the working folder and then repeat the steps. The above code does not get me what I want. Any help would be appreciated.
Thanks,
Rekha
What happens if you instead use the while loop to hold the run when the file is not there, and then put the actions outside the loop. For example:
to go
while [not file-exists? "biosim.asc"] [wait 1]
grow-grass
grow-herd
delete-biosim
tick
end
You could probably simply have [] instead of the wait but I suspect that would be fairly inefficient as it would constantly check. This instead checks every 1 second (you can make the check shorter or longer of course depending on how often the file is created) and once the file is there, it moves on to the other code.
Another option depends on what language the other model is built in. If it's something like R of java, you can control the NetLogo model from that code and couple the models directly.
I have created two vi's in LabVIEW: one to acquire serial data and another to plot the acquired data on an XY graph.
The second VI gets called when a Value Change event occurs on a button in the first VI. But the problem is that when the second VI is called the first VI suspends its operation, hence the values don't get updated.
Is there any solution for this?
First VI block diagram:
First VI front panel:
Second VI (ALL DATA) block diagram:
Well, you are doing some nasty stuff with global variables. This works but is not considered as good practice. (Have a look at queues and notifiers). Further, I don't see how your data gets written to those variables...
In any case, put your 2nd VI in a separate while-loop and schedule it to about 100ms (that is usually enough to update front panels or to interact with users. I'm not sure if your button-event is the right way to go. That is exactly because, the second VI waits for the callback. Just use a simple button and a true-false case to let the second VI keep running (this should even be the solution if you don't want to move the case to a second VI). Just make sure that you change the mechanics of the button to be a switch because you're checking its value not at infinite speed and you want to ensure that it gets caught every time, you click it;)
You will need to use the VI Server functionality. The exact method has changed over the years, but I believe the current recommended implementation is to use 'Start Asynchronous Call'
There is an example that you can view using the example finder. To open the example finder navigate to Help>Find Examples. Then select the 'Search' tab and search for 'asynchronous'. Finally select the VI called 'Asynchronous Call and Forget.vi'
There are other variations for asynchronous implementations, but this is probably a good place to start.
I wrote a Pharo program that generates my daily task non-stop.
The program itself works fine, however I always need to instantiate my object in the playground to run it. Is there some other way of doing it automatically without having to create an object and send a message to it?
Yes, you can. Save the image after you have instantiated your application and closed everything else. Then just start pharo from the image and you will have your application started.
If you want to do it more production wise you could use pharo-launcher.
For more detailed information you could squeak wiki which you can adjust to Pharo.
I would do one of three thing here:
Add an item to the World menu, so you can bring up the menu and select your task. See a Stackoverflow Answer on that same topic.
You could write some triggering code in a .st file on your file system, then use StartupPreferencesLoader to load it on startup.
Create a window morph with a button that, once pressed, runs your code. Open the window, quit and save image changes. Never close the window.
I´d like to know how can I stop execution in smalltalk. I entered an infinite loop and don´t want to loose the code that´s written. I tried using pause button but doesn´t seem to be right.
Normally, even if you are unable to stop execution, you should be able to get the code changes you made back from the .changes file. If you can restart the image, there is a 'recover lost changes' menu entry. Always first make a backup copy of the changes and image files before trying this. (In Pharo/Squeak. Other smalltalk have similar possibilities)
it depends on the dialect and possibly keyboard settings.
try CMD-. or CTRL-., which works in most dialects.
On windows 10.
I need to automate the repeated process of these steps.
1. Open up an image in GIMP. Scale it to 110%.
2. Export as somefile name(for example input001.jpg).
3. Go to http://deepdreamgenerator.com/ in a browser. click on button, browse to the exported file.
4. Wait for it to generate result, save image as result file (for example dream001.jpg).
then repeat from step 1 with the result file from step 4...but keep increasing the filename number so export it as input002.jpg...
What software would allow me to do this?
the only software i know of that * MIGHT * be able to automate that process is AutoHotKey
You would need to keep the windows which you're automating static (ie. make sure they don't move) and then write keyboard and mouse macros in autohotkey to press the buttons and do the things you want.
I tried AutoHotKey but didn't feel like learning a whole new scripting language so I found something simpler called GhostMouse.
It just has record,play,stop buttons.
after recording and closing out of program it asks if i want to save script. clicked yes gave it a name, and then edited the script file..and copied and pasted as many times as i wanted the script to run (before copying and pasting i deleted the last 3 lines which has to do with clicking the stop button which i didn't want the script to do).
You can also try Sikuli for same. It's an image comparator
http://www.sikuli.org/
Reference :-
http://doc.sikuli.org/tutorials/