How to implement this case(in the picture)?


Hello,



To implenment this case,this is my client code
int main(){
  //create device proxy
  DeviceProxy* device =new DeviceProxy("DeviceName");	
  while(1){

    // get data G
    DeivceData rG= device->read_attribute("G");
    //do some data process
    Devicedata alpha = do_some_data_process(rG);
    //return the process result to device
    device->write_attribute(alpha);
    
    usleep(1000);
  }

  return 0;
}

Is my idea right?
Besides,I have another question about the picture.Dose the gray circle mean the hardware? How dose the device exchange data with the hardware?

Thanks!
wT
Edited 8 years ago
Hi,

yes your code is close to being right. You have understood the basic principle. You probably need to extract the returned data from your device into a data type your do_some_data_process() function understands. You can either do this in the routine itself or before you send the DeviceData to your routine.

Yes the grey bubble represents the hardware. How you communicate with the hardware is completely dependant on the hardware interface. It could be ethernet in which case you would communicate via a socket or a protocol like http, it could be a card in the pci bus in which case you need a software library to communicate with the hardware (SDK), it could be a serial line in which case you need to send commands (usually in ascii) to the device over the serial port. Nowadays ethernet is very common.

Hope this helps.

Andy
 
Register or login to create to post a reply.