execution management - vb.net

I started using VB just a few days ago (programming in general). Now I made some interesting things, but am stuck on just 1.
I have multiple timers that counts down their own specific times.
Once the timer runs out, the program executes another .exe for each timer.
But I'm wondering what would be the smartest way to say, 'Queue' exe's when one is already running, Queue all the others until the current once's process doesn't exist. Then execute the next.....so it will keep going.
But my only problem is, how will the program know which one to execute next and delete the previously completed one from the queue?
Also does something that can handle this exist? Or would I have to make one from scratch?
Thanks

Related

Problem with PDDL code using conditional effects

I'm trying to solve a Pacman-styled PDDL problem and there's a particular scenario I've been stuck on for days now. I'm getting the classic
ff: goal can be simplified to FALSE. No plan will solve it
which means the issue is trivial and logic related. However, I'm new to PDDL and can't seem to figure out what's causing it.
The problem is simple, Pacman (P) has to eat the Food (F), but two ghost agents (G) are blocking it. To get past them, Pacman needs to consume the Capsule (C), making him invisible.
(Edit: I've deleted the question as it was part of an assignment. I managed to solve the issue and will post the solution as soon as the assignment is graded.)
In this thread: About PDDL in AI planning #haz mentioned a good methodology to debug your PDDL Model when the goail is unreachable from the initial state.
The best way to test this out is to follow the following strategy: (1) write down a plan you know will solve it; (2) starting with the first action, set the goal to the precondition; (3) repeat to the end. If that fails, start changing the initial state to what you expect the complete state to be during the execution of the plan. – haz May 1 at 2:04
I uploaded a new version which is able to find a solution (if Ghosts are not in the path of foods):
http://editor.planning.domains/#read_session=c7Vez9nrti
Two main issues:
you never delete GhostPos, but it appears in the goal formula
If GhostPos is on the way to a FoodPos, then you can never reach the food as the move action requires not to be a Ghost.

Having trouble making my VI work as a Sub VI

I am having trouble getting the terminals to pass any data to what they are connected to because the controls they connect to are in a while loop. My frustration level is high since I would have already had this done if I wrote it in C.
First, let me say this might get a little long so if you don't want to read it, then don't. Here goes. I have watched a couple of tutorials, read a lot, and even tried a few things out in code. I get why this can't be done directly in a while loop. Having said that, it seems that I have no choice but to use while loop(s) in my VI.
My VI is loosely based on Queued Message Handler in the Templates section of creating a new VI. I have 2 things that must take place. One - I have created a TCP client where I constantly send messages to get status from the equipment I am communicating with. This is a timed event and must be handled in a while loop so I can maintain the connection to the server. I am not doing the Open, Send, Close, Reopen, Send, Close, etc. type of message handling. Too inefficient. This is the lower half of the example template.
Second - On occasion the user will press a button on the front panel which creates a message that is sent to the equipment to make it do something. And this, it would seem, needs to be in a while loop also, hence my problem. Some/most of the controls exist with the event structure. This is the top half of the example template.
I actually have this working as a front panel, but every thing is in just one while loop and I cannot get the terminals to work. Here is where my confusion comes in, if I am passing something to the while loop, I only get its value once and if it changes, you don't get that change, and if you are passing the data out of the while loop, you only get it when the loop ends. These two things are really baffling me. How can pass data that changes while using a while loop, because I have to, but the while loop breaks using the terminals. Seems circular. The TCP communications cannot stop, and I cannot find an example of how to do this using my friend Google. Am I the only person on this planet that needs to do this? Doubt it.
Not going to show my code, as this in not a code problem. It is an understanding how LabView does things vs. how you would just write the code in C using some library. And also just being unfamiliar with all the things you can do in LabView, not to mention how things are different. I don't know what I don't know, but I can learn.
I want to be able to give the VI I have created to any user and let them use it to control my equipment. If they just want to run it as a front panel, or if they want to use it as a Sub VI that is OK too. I just need to be able to make the terminals actually pass data when used that way.
Thanks, I did order a book on LabView today, but I won't get it soon. I really need to put this problem to bed.
Cannot help that much without seeing the code. But I can try to give you a little bit of an idea of what is going on.
Dataflow is an important concept to understand in LabVIEW. elements (VIs, loops, etc.) will not start until all of their inputs (ie. terminals) have been received or set by something called before, and then they only take their inputs once. If your terminal is outside the loop, then the loop can only read it's starting value. (See "Infinite Loops" on this page). A simple way of solving this would be to put the terminal inside of the loop rather than outside, so it is then read on every iteration of the loop.
As for passing values outside of the loop, there are a number of methods for this. Again, because of dataflow, you will not usually be able to access the value of something inside the loop until the loop finishes executing. However, there are a number of ways to read those values in a different loop. Local or global variables would be the simplest way, but they are not recommended by NI. The proper way of handling this is using something on the synchronization pallet. More info on the options can be found here.
Seeing as you are basing something on the Queued Message Handler, a queue might be a good way to start. LabVIEW has built in examples of code to show you how to use these functions.
Loop synchronization and asynchronous programming are fundamental concepts for writing LabVIEW code. If these are not concepts you are familiar with, I would say that you will gain a lot from showing others your actual code and having people help you with the issues. If you are concerned about sharing something proprietary, try making a simple example and posting that code instead to understand the concepts better.
Event structure to react to evr8and functional global to pass data out.
Suggest pasting block diagram.

How to check if SQLite database is locked

I have an app that makes quite a few calls to a local SQLite3 database and sometimes these calls happen very close together (from different areas of the app). How can I check, before a call to the database is made, if the database is currently locked?
Ideally I would rewrite the app (which has grown far beyond its original scope) but won't have time in this iteration.
I have no idea what to do in objective-c, but I have been using sqlite3 with c from quite long time And I also faced same issue. I used below method.
use busy_timeout and keep it configurable.
use busy_handler to keep retry for n number of time.
This two improvement works well for me, but I had observed some performance issue which i am able to handle via above configuration parameter. You need to do some trade of between fail-safe and performance.

Asynchronous treatment sometimes causes MS Access query to crash

I am working on a Winform program that uses Access (unfortunately, my firm isn't willing to go for a non-shared-drive-only server at this point) and VB.NET. I have a report that takes and displays data from the database for particular deals that works 95% of the time. 5% of the time, though, it crashes. I know that it has nothing to do with the code itself, because when it crashes is totally irrespective of which deal is being displayed. I can also consistently crash the program by clicking the triggering "View Deal" button repeatedly (this is after experimenting with sleeping the thread and disabling the button while the code executes).
The typical error when the program crashes relates to the processing of the data I'm doing before displaying it. For instance, I add a total row to the data table for some of the cash flows and then sum it up in VB. I then bind this to a DataGridView. During a crash, though, the error message says that the first column I reference doesn't exist.
Does anyone have any thoughts on how to get VB.NET to treat this synchronously? I know that Access is slow to begin with, but it's even worse when it's being used over a network (as in my case), so I want to be able to prevent this sort of thing from happening to my users.
Thanks
Rob
I think it was concurrency, so thanks to user2864740. It was concurrency in a roundabout way, though. I had several sub calls to a sub that would run a query and then add a row to a DataGridView. It turns out that I wasn't closing the connection in the sub each time, so when I tried to "bust" the program by repeatedly running the code, Access became overloaded with connections. Eventually, the code tried to move beyond the queries, since they wouldn't run anyway, and that's why I was getting issues with the DataGridView.
Hope this helps someone in the future.

Delayed function calls in ruby or rails

I'm coding a poker variant game, and need either ruby or rails to run one big loop to keep the game automated. Ie:
check every 10 seconds or so that there are enough players in the game;
when there are, deal the cards, then count down ~45 seconds, upon which showdown will happen;
in my poker variant there are 3 consecutive showdowns - therefore each showdown needs to happen slowly so the players know what's going on: ie 5 seconds to show down the first portion of the hand and declare the winner of that showdown, 5 seconds for the second and 5 seconds the third
pause a few seconds after the hand
start loop from the top again
I've had a quick look at delayed_job and resque, but they look quite complicated for what I'm trying to do. I've also considered using a javascript/jquery loop to push the server along the loop, but that seems inelegant, seeing as each of the potentially numerous players on a table will be seeking to push the loop along, rather than the server doing it centrally.
Am I missing a fairly simple function, or is it time to look deeper into delayed_job?
You pretty much need some kind daemon process, but you don't necessarily need any library.
You can write your code as a method on some module, and invoke it using rails runner. The method can execute a loop containing sleep <seconds> to execute code and wait. The easy way to stop the process is have it watch for a file to exist in /tmp or something, but you can also do things like write a pid file, and then kill the process later using its pid.