source: trunk/MagicSoft/Control/SubsystemIO/mainForPeriodicSignal.cxx@ 1248

Last change on this file since 1248 was 1054, checked in by casaldaliga, 23 years ago
changed .H to .hxx in includes to work with new naming
File size: 1.1 KB
Line 
1#include <iostream>
2#include "PeriodicSignal.hxx"
3#include <stdio.h>
4//for signals
5#include <sigc++/signal_system.h>
6using namespace SigC;
7class Counter:public Object
8{
9public:
10 int max;
11 int count;
12 int incr;
13
14 Counter(int max_, int incr_)
15 :max(max_),incr(incr_),count(0)
16 {};
17 void isIncrementPossible()
18 {
19 count+=incr;
20// cout<<"Counter by "<<incr<<" to "<<max<<" is at "<<count<<"\n";
21 printf("Counter by %d to %d is at %d\n",incr,max,count);
22 };
23 void PrintIAmDone()
24 {
25 cout<<"Counter by "<<incr<<" to "<<max<<" is done!"<<"\n";
26 };
27
28};
29bool end;
30
31void endMe()
32{
33 end=true;
34}
35
36int main()
37{
38 end=false;
39 Counter byTwo(100,25), byThree(100,33);
40
41 PeriodicSignal byTwoEachSec(1000000);
42 byTwoEachSec.signal.connect(slot(byTwo,&Counter::isIncrementPossible));
43 byTwoEachSec.Start();
44
45 PeriodicSignal byThreeEachTwoSec(2000000);
46 byThreeEachTwoSec.signal.connect(slot(byThree,&Counter::isIncrementPossible));
47 byThreeEachTwoSec.Start();
48
49 while(!end){
50 }
51
52
53 return 0;
54}
Note: See TracBrowser for help on using the repository browser.