devices/devicesync/ordevicesync_hardware.cxx

devices/devicesync/ordevicesync_hardware.cxx
/***************************************************************************************
Autodesk(R) Open Reality(R) Samples
(C) 2009 Autodesk, Inc. and/or its licensors
All rights reserved.
AUTODESK SOFTWARE LICENSE AGREEMENT
Autodesk, Inc. licenses this Software to you only upon the condition that
you accept all of the terms contained in the Software License Agreement ("Agreement")
that is embedded in or that is delivered with this Software. By selecting
the "I ACCEPT" button at the end of the Agreement or by copying, installing,
uploading, accessing or using all or any portion of the Software you agree
to enter into the Agreement. A contract is then formed between Autodesk and
either you personally, if you acquire the Software for yourself, or the company
or other legal entity for which you are acquiring the software.
AUTODESK, INC., MAKES NO WARRANTY, EITHER EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
PURPOSE REGARDING THESE MATERIALS, AND MAKES SUCH MATERIALS AVAILABLE SOLELY ON AN
"AS-IS" BASIS.
IN NO EVENT SHALL AUTODESK, INC., BE LIABLE TO ANYONE FOR SPECIAL, COLLATERAL,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES IN CONNECTION WITH OR ARISING OUT OF PURCHASE
OR USE OF THESE MATERIALS. THE SOLE AND EXCLUSIVE LIABILITY TO AUTODESK, INC.,
REGARDLESS OF THE FORM OF ACTION, SHALL NOT EXCEED THE PURCHASE PRICE OF THE
MATERIALS DESCRIBED HEREIN.
Autodesk, Inc., reserves the right to revise and improve its products as it sees fit.
Autodesk and Open Reality are registered trademarks or trademarks of Autodesk, Inc.,
in the U.S.A. and/or other countries. All other brand names, product names, or
trademarks belong to their respective holders.
GOVERNMENT USE
Use, duplication, or disclosure by the U.S. Government is subject to restrictions as
set forth in FAR 12.212 (Commercial Computer Software-Restricted Rights) and
DFAR 227.7202 (Rights in Technical Data and Computer Software), as applicable.
Manufacturer is Autodesk, Inc., 10 Duke Street, Montreal, Quebec, Canada, H3C 2L7.
***************************************************************************************/
//--- Class declaration
#include "ordevicesync_hardware.h"
#include <math.h>
/************************************************
* Constructor.
************************************************/
ORDeviceSync_Template_Hardware::ORDeviceSync_Template_Hardware()
{
mServerAddress = "255.255.255.255";
mServerPort = 0;
mCounter = 0;
}
/************************************************
* Destructor.
************************************************/
ORDeviceSync_Template_Hardware::~ORDeviceSync_Template_Hardware()
{
}
/************************************************
* Open device communications.
************************************************/
bool ORDeviceSync_Template_Hardware::Init()
{
// TODO: Initialize device
return true;
}
/************************************************
* Open device communications.
************************************************/
bool ORDeviceSync_Template_Hardware::Open()
{
// TODO: Open network connection to server
mCounter = 0;
return true;
}
/************************************************
* Get device setup information.
************************************************/
bool ORDeviceSync_Template_Hardware::GetSetupInfo()
{
// TODO: Get setup information from client
return true;
}
/************************************************
* Start device data stream.
************************************************/
bool ORDeviceSync_Template_Hardware::StartDataStream()
{
// TODO: ask server to start sending data
mCounter = 0;
return true;
}
/************************************************
* Fetch a data packet from the device.
************************************************/
bool ORDeviceSync_Template_Hardware::FetchDataPacket()
{
//Returns true if a new data packet is ready
// TODO: insert time stamp from data packet
FBTime lTime = mSystem.SystemTime;
double lVal = lTime.GetSecondDouble();
double w = 1.0;
double p = 3.14;
double a = 20.0;
double lData = a*sin( w*lVal + p);
mDefaultPacket.Time = lTime;
mDefaultPacket.Data = lData;
mCounter++;
// TODO: Replace this bogus code with real NON-BLOCKING TCP, UDP or serial calls
// to your data server.
if( mCounter % 2 == 0 )
{
return false;
}
return true;
}
/************************************************
* Stop device data stream.
************************************************/
bool ORDeviceSync_Template_Hardware::StopDataStream()
{
// TODO: ask server to stop sending data
return true;
}
/************************************************
* Close device communications.
************************************************/
bool ORDeviceSync_Template_Hardware::Close()
{
// TODO: Close network connection to server
return true;
}
/************************************************
* Shut down hardware.
************************************************/
bool ORDeviceSync_Template_Hardware::Done()
{
// TODO: Close network connection to server
return true;
}