Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Last revision Both sides next revision | ||
compcode [2011/01/05 16:26] hourdin fixes in the code, update to new version |
compcode [2011/01/05 16:33] hourdin update again |
||
---|---|---|---|
Line 14: | Line 14: | ||
public class Your_CSharpBean_Name : IThreadCreator { | public class Your_CSharpBean_Name : IThreadCreator { | ||
private Thread t; // Private attributes of the class | private Thread t; // Private attributes of the class | ||
- | private volatile bool run = false; | + | private volatile bool run; |
+ | private volatile int eventValue; | ||
public Your_CSharpBean_Name() { | public Your_CSharpBean_Name() { | ||
// Put here your init instructions | // Put here your init instructions | ||
- | // Example of a loop that call the output | ||
- | // every second. | ||
t = new Thread(new ThreadStart(ThreadLoopMethod)); | t = new Thread(new ThreadStart(ThreadLoopMethod)); | ||
+ | run = false; | ||
+ | eventValue = 10; | ||
} | } | ||
- | public void Start() { | + | public void Start() { // method starting the thread |
if (!run) { | if (!run) { | ||
run = true; | run = true; | ||
Line 37: | Line 38: | ||
while(run) { | while(run) { | ||
Thread.Sleep(1000); | Thread.Sleep(1000); | ||
- | double result; | ||
// Check if the output is connected | // Check if the output is connected | ||
if(Output_Sample != null) | if(Output_Sample != null) | ||
// call the connected methods sequentially | // call the connected methods sequentially | ||
- | result = Output_Sample(123); | + | Output_Sample(eventValue); |
// and so on... | // and so on... | ||
} | } | ||
Line 47: | Line 47: | ||
// --- Start: Input port sample --- | // --- Start: Input port sample --- | ||
- | // an input port is a method (below) | + | // an input port is a public method (like below) |
- | public void Input_Sample(string param_name) { | + | public void Input_Sample(int intParam) { |
- | string pn = param_name; // You may use the parameters | + | eventValue = intParam; |
// No return value is expected in WComp: | // No return value is expected in WComp: | ||
// results are given using events | // results are given using events | ||
Line 56: | Line 56: | ||
// --- Start: Output port sample --- | // --- Start: Output port sample --- | ||
- | public delegate double Output_Sample_Signature(int param_name); | + | public delegate void Output_Sample_Signature(int val); |
// The delegate defines the signature of the output method | // The delegate defines the signature of the output method | ||
public event Output_Sample_Signature Output_Sample; | public event Output_Sample_Signature Output_Sample; |