00001
00003
00004
00005
00006
00007
00008
00009
00010
00011
00013
00014 #include <iostream>
00015 #include "ipc/core.h"
00016 #include <ipc/partition.h>
00017 #include "cdi/Conditions.h"
00018 #include <unistd.h>
00019
00020 int main(int argc, char ** argv)
00021 {
00022 IPCCore::init( argc, argv );
00023
00024 std::cout << OWLTime() << " :: cdiISTest is initializing!" << std::endl;
00025 std::cout << OWLTime() << " :: cdiISTest -> Initializing partition [be_test]!" << std::endl;
00026 IPCPartition p("be_test");
00027
00028 std::cout << OWLTime() << " :: cdiISTest -> Initializing the dictionary!" << std::endl;
00029 ISInfoDictionary dict(p);
00030
00031 std::cout << OWLTime() << " :: cdiISTest -> Initializing Conditions object!" << std::endl;
00032 Conditions c;
00033
00034 std::vector<std::string> a;
00035
00036 std::cout << OWLTime() << " :: cdiISTest -> Adding Information objects to the list!" << std::endl;
00037 a.push_back("RunCtrl.Application_dsa_supervisor");
00038 a.push_back("RunEvents.*");
00039 a.push_back("RunParams.RunParams");
00040 a.push_back("RunParams.Conditions");
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 c.ISServers_size = 4;
00056 c.ISServers = a;
00057
00058
00059
00060 std::cout << OWLTime() << " :: cdiISTest -> subscribing the servers to the dictionary!" << std::endl;
00061 dict.insert("MyServer.Conditions", c);
00062
00063
00064
00065
00066
00067 int pid;
00068 int pid2;
00069 pid = fork();
00070
00071 if (pid == -1) {
00072 std::cerr << OWLTime() << " :: cdiISTest failed to create multiple threads!" << std::endl;
00073 exit(1);
00074 }
00075
00076 if (pid != 0) {
00077 std::cout << OWLTime() << " :: cdiISTest -> Main thread executing: PID: [" << getpid() << "]!" << std::endl;
00078 std::cout << OWLTime() << " :: cdiISTest -> Forking again the execution" << std::endl;
00079
00080 pid2 = fork();
00081
00082 if (pid2 == -1) {
00083 std::cerr << OWLTime() << " :: cdiISTest failed to create multiple threads!" << std::endl;
00084 exit(1);
00085 }
00086
00087
00088 if (pid != 0) {
00089
00090 while(1){
00091
00092
00093
00094
00095 dict.update ("MyServer.Conditions", c);
00096 sleep(5);
00097 }
00098 }
00099
00100 }
00101 printf("\n\n\tWe love Unix!\n\n");
00102 if (pid == 0) {
00103 printf("Hello World, my name is GoogooGaga!\n");
00104 printf("My process id is %d\n", getpid());
00105 printf("I have ONE papa (ofcourse), his name is Pappy, and has a process id %d\n", getppid());
00106 }
00107 exit(0);
00108
00109
00110 while(1){
00111
00112
00113
00114
00115 dict.update ("MyServer.Conditions", c);
00116 sleep(5);
00117 }
00118
00119 return 0;
00120 }