Hi!
someone knows the structure to run a program in c ++
I´m using PCDK. Any document about this is very helpful!
Thankyou!
Hi!
someone knows the structure to run a program in c ++
I´m using PCDK. Any document about this is very helpful!
Thankyou!
It's sample from C#. Try same way just using C++. Class names should be same. In the worst case you can do custom remote run: select the program, trigger DO which is mapped to UI[Start].
private void cmdRun_Click(object sender, EventArgs e)
{
object vntStepType;
object vntLineNum;
object vntDirection;
try
{
// make sure this is not just a .vr program or something
if (!(mobjProgram is FRCTPProgram | mobjProgram is FRCKARELProgram))
{
MessageBox.Show("Must be TP or KAREL Program to Run", "Program.Run");
return;
}
// get run options
vntStepType = cboStepType.SelectedIndex - 1;
vntLineNum = short.Parse(txtCurLine.Text);
vntDirection = cboDirection.SelectedValue;
// If requested, set up conditions to detect program starting
if (chkVerifyPgmStarts.Visible & (chkVerifyPgmStarts.Checked))
{
Cursor.Current = Cursors.WaitCursor;
mstrProgramToRun = mobjProgram.Name;
mobjRunTask = null;
mobjRunTasks = FRRobotDemo.gobjRobot.Tasks;
//unsubscribe event if already subscribed
mobjRunTasks.Change -= mobjRunTasks_Change;
//subscribe event handlers
mobjRunTasks.Change += mobjRunTasks_Change;
mobjRunTasks.StartMonitor(50);
}
// Recast as TP or Karel and run
if (mobjProgram is FRCTPProgram)
{
mobjTPProgram.Run(vntStepType, vntLineNum, vntDirection);
}
else if (mobjProgram is FRCKARELProgram)
{
mobjKARELProgram.Run(vntStepType, vntLineNum, vntDirection);
}
// If requested, wait for the program to be running
if (chkVerifyPgmStarts.Visible & chkVerifyPgmStarts.Checked)
{
// Give the task object some time to be created
// If not created in that time, raise an error
mblnTimeElapsed = false;
tmrElapse.Interval = RUN_DELAY;
tmrElapse.Enabled = true;
while (!mblnTimeElapsed && mobjRunTask == null)
{
Application.DoEvents();
}
tmrElapse.Enabled = false;
mobjRunTasks.StopMonitor();
mobjRunTasks = null;
if (mobjRunTask == null)
{
MessageBox.Show(Properties.Resources.IDS_TASK_NOT_CREATED, Properties.Resources.IDS_PROGRAM_RUN);
return;
}
// Watch the task status, giving it some time to get into the running state
mblnTimeElapsed = false;
tmrElapse.Interval = RUN_DELAY;
tmrElapse.Enabled = true;
while (!mblnTimeElapsed && mobjRunTask.Status != FRETaskStatusConstants.frStatusRun)
{
Application.DoEvents();
}
tmrElapse.Enabled = false;
// Display error never saw task go into run state
if (mobjRunTask.Status != FRETaskStatusConstants.frStatusRun)
{
MessageBox.Show(Properties.Resources.IDS_DID_NOT_SEE_PGM_RUN, Properties.Resources.IDS_PROGRAM_RUN);
}
mobjRunTask = null;
Cursor = Cursors.Default;
}
// Display unexpected errors and clean up.
}
catch (Exception ex)
{
MessageBox.Show(Properties.Resources.IDS_UNEXPECTED_ERROR + ex.Message, Properties.Resources.IDS_PROGRAM_RUN);
mobjRunTask = null;
Cursor = Cursors.Default;
if (mobjRunTasks != null)
{
mobjRunTasks.StopMonitor();
}
mobjRunTasks = null;
}
}
Display More
Hi scotty,
thank you for posting this.. it is a rare example of c# code.. at least what i could find.
Is there any chance, if im not asking too much, that you can provide more code?
For example where i can see mobjProgram and chkVerifyPgmStarts declarations.
Also if you would be kind to explain, or point me to a place where i can find explanation, of FRCTPProgram and FRCKARELProgram classes. It seems that your mobjProgram derived from one of those classes.
Thank you for any help you can provide.
If you have installed PCDK on your PC/laptop, then take a look into the folder with PCDK, there you have examples in couple languages. Also you should have manual and word file with information about this classes.
If you do not have this information, then contact me and I can take a look for information.