Hello! I'm trying to find out if a job is running or not. Specifically, the filename that is loaded. The trouble I'm having is that SV_JOB_IN_PROGRESS returns IO_LOGICAL_1 even when I'm running a warmup routine, and haven't actually started the job. Is there a way to differentiate this?
internal bool CheckIfJobIsRunning()
{
if (File.Exists("C:\\cncm\\loadcommand.txt"))
{
return true;
}
string command = "STATE_CheckIfJobIsRunning";
m_parent.SendAndReceive(command, out var response);
FromString(response, out var value);
return Convert.ToBoolean(Convert.ToInt32(value));
}
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
There is not currently a way to determine which specific job is running, only that a job is running. Checking SV_JOB_IN_PROGRESS or SV_PROGRAM_RUNNING are the best ways to determine that.
CheckIfJobIsRunning has been retooled into IsJobRunning for the upcoming v5.40 release. It does a more programmatic way of checking the same information, without having to query the board. This would be a faster call to make in the future but does not help your current issue.
Let me mull it over some and I will see what I can come up with for you.
1 user liked this post
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
corbin wrote: ↑Wed Jul 16, 2025 12:34 pm
Thanks! Is there a difference between SV_JOB_IN_PROGRESS and SV_PROGRAM_RUNNING? I haven't poked around at SV_PROGRAM_RUNNING.
SV_PROGRAM_RUNNING is 1 if in the MDI screen or a job is in progress
SV_JOB_IN_PROGRESS is 1 if a MDI command is running (not just idly sitting there) or a job is in progress
1 user liked this post
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
For the next release, I added Job.GetCurrentlyRunningJob(out string current_job) which will give the current running job, subprogram, api command, mdi, or no job running.
1 user liked this post
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
// HACK! It is hard to tell if we are running a warmup macro or something else. so, this is a heuristic to determine that, which may not be right
if (newJobIsRunning && newJobIsRunning != _jobIsRunning)
{
int current_line_number = 0;
int program_number = 0;
_pipe.state.GetCurrentStackLevelZeroLineInfo(out current_line_number, out program_number);
int stack_level = 0;
int tempLine = 0;
int tempProgram = 0;
_pipe.state.GetCurrentLineInfo(out tempLine, out tempProgram, out stack_level);
// If we are on line 1 of the current main program...assume we really haven't started, assuming we are deeper in the stack.
// This makes a huge assumption that the first line of a program isn't something that calls a macro of some sort...which it might.
if (stack_level > 0)
{
if (current_line_number == 1)
{
newJobIsRunning = false; // Probably a macro...but like i said, this is a guess!
}
}
}
(Note: Liking will "up vote" a post in the search results helping others find good information faster)