]> rtime.felk.cvut.cz Git - orte.git/blob - orte/examples/reliable/publisher.c
Added renamed_include_HEADERS
[orte.git] / orte / examples / reliable / publisher.c
1 /*
2  *  $Id: publisher.c,v 0.0.0.1          2003/12/27 
3  *
4  *  DEBUG:  section                     publisher
5  *  AUTHOR: Petr Smolik                 petr.smolik@wo.cz
6  *
7  *  ORTE - OCERA Real-Time Ethernet     http://www.ocera.org/
8  *  --------------------------------------------------------------------
9  *
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  (at your option) any later version.
14  *  
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *  
20  */ 
21
22 #include <stdio.h>
23 #ifdef __RTL__
24   #include <posix/pthread.h>
25 #endif
26 #include "orte.h"
27
28 ORTEDomain        *d;
29 char              instance2Send[64];
30 int               counter=0;
31
32 void
33 sendCallBack(const ORTESendInfo *info,void *vinstance, void *sendCallBackParam) {
34   char *instance=(char*)vinstance;
35
36   switch (info->status) {
37     case NEED_DATA:
38       printf("Sampling publication, count %d\n", counter);
39       sprintf(instance,"Hello Universe! (%d)",counter++);
40       break;
41     case CQL:  //criticalQueueLevel
42       break;
43   }
44 }
45
46
47 int 
48 main(int argc, char *args[]) {
49   ORTEPublication *p;
50   NtpTime         persistence,repeating;
51
52   ORTEInit();
53   d=ORTEDomainAppCreate(ORTE_DEFAULT_DOMAIN,NULL,NULL,ORTE_FALSE);
54   ORTETypeRegisterAdd(d,"HelloMsg",NULL,NULL,64);
55   NTPTIME_BUILD(persistence,3); 
56   NTPTIME_BUILD(repeating,1); 
57   p=ORTEPublicationCreate(
58        d,
59       "Reliable HelloMsg",
60       "HelloMsg",
61       &instance2Send,
62       &persistence,
63       1,
64       sendCallBack,
65       NULL,
66       &repeating);
67   #ifndef CONFIG_ORTE_RT
68   while(1) {
69     ORTESleepMs(1000);
70   }
71   #endif
72   return 0;
73 }
74
75 #ifdef CONFIG_ORTE_RT
76 void 
77 hello_init(void) {
78   main(0,NULL);
79 }
80 void 
81 hello_exit(void) {
82   ORTEDomainAppDestroy(d);
83 }
84 MODULE_LICENSE("GPL");
85 module_init(hello_init);
86 module_exit(hello_exit);
87 #endif
88