C program streams
Moderators: TomKerekes, dynomotion
C program streams
Hi Tom.
I have different C programs assigned to two buttons, but they are on the same thread because I don’t have enough threads for my machine.
Is it possible to ignore pressing another while running a program on one button?
That is, when I pressed one button, I cannot press the second until the program is executed?
Regards,
Taras.
I have different C programs assigned to two buttons, but they are on the same thread because I don’t have enough threads for my machine.
Is it possible to ignore pressing another while running a program on one button?
That is, when I pressed one button, I cannot press the second until the program is executed?
Regards,
Taras.
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: C program streams
Hi Taras,
One solution might be to configure the buttons to execute in for example Thread 3, which invokes the real program to run in Thread 4 only if Thread 4 is not active.
For Example the button executes this in Thread 3:
One solution might be to configure the buttons to execute in for example Thread 3, which invokes the real program to run in Thread 4 only if Thread 4 is not active.
For Example the button executes this in Thread 3:
Code: Select all
#include "KMotionDef.h"
#define TMP 10 // which spare persist to use to transfer data
#include "KflopToKMotionCNCFunctions.c"
extern volatile int ThreadActive; // one bit for each thread
void main()
{
if (ThreadActive & (1 << 4)) return; // if Thread 4 is executing exit
if (ScreenScript("Action:4;4;0;0;0;0;BlinkKFLOP46.c"))
printf("Screen Script Failed\n");
else
printf("Screen Script Success\n");
}
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: C program streams
Hi Tom.
Thank you very much.
There are a couple more questions. So can I check if thread 5 is free?
So will it be possible to run the program in thread 5?
I understood you correctly ?
Regards,
Taras.
Thank you very much.
There are a couple more questions.
Code: Select all
if (ThreadActive & (1 << 5)) return;
Code: Select all
if (ScreenScript("Action:5;5;0;0;0;0;BlinkKFLOP46.c"))
I understood you correctly ?
Regards,
Taras.
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: C program streams
Yes. But the first parameter is the Action Type. You probably want 4 for Execute without waiting. The 2nd parameter is the Thread.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: C program streams
Hi Tom.
Thank you very much.
Here we check 5 bits of the ThreadActive byte for equality 1 ?
If equal to 1 then the thread is busy.
And here we call the script with the name BlinkKFLOP46 and parameters
1)Execution parameter(1(I/O Bit) 2(Two I/O Bit) 3(DAC) 4(Execute Prog) 5(Exec Wait) ...)
2)The thread in which the script will be executed
3)?
4)?
5)?
6)?
What do the other parameters mean?
Or does it not matter?
Regards,
Taras.
Thank you very much.
Code: Select all
if (ThreadActive & (1 << 5)) return;
If equal to 1 then the thread is busy.
Code: Select all
Action:5;5;0;0;0;0;BlinkKFLOP46.c
1)Execution parameter(1(I/O Bit) 2(Two I/O Bit) 3(DAC) 4(Execute Prog) 5(Exec Wait) ...)
2)The thread in which the script will be executed
3)?
4)?
5)?
6)?
What do the other parameters mean?
Or does it not matter?
Regards,
Taras.
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: C program streams
Hi Taras,
The parameters have different purposes depending on the Action. They are commonly not all used.
For the Execute Action the 2nd numeric parameter is the KFLOP persist Variable for any data.
The 3nd numeric parameter is a parameter to be placed in the KFLOP persist variable. This can be useful to have a single C Program used by multiple buttons to do different things based on the value.
You can use the Screen Editor's Script Dialog to help form the screen script for an Action. Selecting different Action Types will show the related parameters.
Clicking Set will create the Script:
Action:4;1;30;123;0;0;BlinkKFLOP.c
The parameters have different purposes depending on the Action. They are commonly not all used.
For the Execute Action the 2nd numeric parameter is the KFLOP persist Variable for any data.
The 3nd numeric parameter is a parameter to be placed in the KFLOP persist variable. This can be useful to have a single C Program used by multiple buttons to do different things based on the value.
You can use the Screen Editor's Script Dialog to help form the screen script for an Action. Selecting different Action Types will show the related parameters.
Clicking Set will create the Script:
Action:4;1;30;123;0;0;BlinkKFLOP.c
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: C program streams
Hi Tom.
What is the variable ScreenScript ?
How to declare it?
Regards,
Taras.
What is the variable ScreenScript ?
How to declare it?
Regards,
Taras.
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: C program streams
Hi Taras,
Sorry I don't understand the question.
Sorry I don't understand the question.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: C program streams
Hi Tom.
I used your example as is
But the compiler asks to assign a ScreenScript variable.
Regards,
Taras.
I used your example as is
Code: Select all
#include "KMotionDef.h"
#define TMP 10 // which spare persist to use to transfer data
#include "KflopToKMotionCNCFunctions.c"
extern volatile int ThreadActive; // one bit for each thread
void main()
{
if (ThreadActive & (1 << 4)) return; // if Thread 4 is executing exit
if (ScreenScript("Action:4;4;0;0;0;0;BlinkKFLOP46.c"))
printf("Screen Script Failed\n");
else
printf("Screen Script Success\n");
}
Taras.
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: C program streams
Hi Taras,
The function ScreenScript should be defined in KflopToKMotionCNCFunctions.h. Is it?
What Version of KMotion are you using?
The function ScreenScript should be defined in KflopToKMotionCNCFunctions.h. Is it?
What Version of KMotion are you using?
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.