Homepage Demos Overview Downloads Tutorials Reference
Credits
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Search

RemoteProcess.cc

Go to the documentation of this file.
00001 #include <OPENR/core_macro.h>
00002 #include "RemoteProcess.h"
00003 #include <stdio.h>
00004 
00005 RemoteProcess::RemoteProcess() : RPOPENR_isready(true)
00006 {
00007   // usercode: constructor here
00008 }
00009 
00010 RemoteProcess::~RemoteProcess()
00011 {
00012   // usercode: destructor here
00013 }
00014 
00015 void
00016 RemoteProcess::start()
00017 {
00018   // usercode: objects connected
00019   // code below is a simple example
00020 
00021   if (RPOPENR_isReady()) {
00022     RPOPENR_send("hello aibo",11);
00023     printf("local: hello aibo");
00024   }
00025 }
00026 
00027 void
00028 RemoteProcess::data_received(const char *buf)
00029 {
00030   // usercode: message received
00031   // code below is a simple example
00032 
00033   printf("remote: %s\n",buf);
00034 }
00035 
00036 OStatus
00037 RemoteProcess::DoInit(const OSystemEvent& event)
00038 {
00039   NEW_ALL_SUBJECT_AND_OBSERVER;
00040   REGISTER_ALL_ENTRY;
00041   SET_ALL_READY_AND_NOTIFY_ENTRY;
00042   return oSUCCESS;
00043 }
00044 
00045 OStatus
00046 RemoteProcess::DoStart(const OSystemEvent& event)
00047 {
00048     ENABLE_ALL_SUBJECT;
00049     ASSERT_READY_TO_ALL_OBSERVER;
00050     start();
00051     return oSUCCESS;
00052 }
00053 
00054 OStatus
00055 RemoteProcess::DoStop(const OSystemEvent& event)
00056 {
00057     DISABLE_ALL_SUBJECT;
00058     DEASSERT_READY_TO_ALL_OBSERVER;
00059     return oSUCCESS;
00060 }
00061 
00062 OStatus
00063 RemoteProcess::DoDestroy(const OSystemEvent& event)
00064 {
00065     DELETE_ALL_SUBJECT_AND_OBSERVER;
00066     return oSUCCESS;
00067 }
00068 
00069 void
00070 RemoteProcess::RPOPENR_notify(const ONotifyEvent& event) {
00071   const char *buf = (const char *)event.Data(0);
00072   data_received(buf);
00073   observer[event.ObsIndex()]->AssertReady();
00074 }
00075 
00076 int
00077 RemoteProcess::RPOPENR_send(char *buf, int bufsize) {
00078   if (RPOPENR_isready && bufsize>0) {
00079     RPOPENR_isready=false;
00080     subject[sbjRPOPENRSendString]->SetData(buf, bufsize);
00081     subject[sbjRPOPENRSendString]->NotifyObservers();
00082     return bufsize;
00083   }
00084   return 0;
00085 }
00086 
00087 /*! @file
00088  * @brief Describes RemoteProcess, sample RemoteProcessingOPENR process
00089  * @author alokl (Creator)
00090  *
00091  * $Author: ejt $
00092  * $Name: tekkotsu-1_4_1 $
00093  * $Revision: 1.3 $
00094  * $State: Exp $
00095  * $Date: 2003/06/12 23:41:40 $
00096  */
00097 

Tekkotsu v1.4
Generated Sat Jul 19 00:06:31 2003 by Doxygen 1.3.2