#include "ordevice_syncreference_device.h"
#define ORDEVICETEMPLATE__CLASS ORDEVICETEMPLATE__CLASSNAME
#define ORDEVICETEMPLATE__NAME ORDEVICETEMPLATE__CLASSSTR
#define ORDEVICETEMPLATE__LABEL "OR - Device SyncReference"
#define ORDEVICETEMPLATE__DESC "OR - Device SyncReference Description"
#define ORDEVICETEMPLATE__PREFIX "SyncReference"
ORDEVICETEMPLATE__CLASS,
ORDEVICETEMPLATE__LABEL,
ORDEVICETEMPLATE__DESC,
static void SamplingRateSet(
HIObject pObject,
double pValue )
{
ORDevice_SyncReference* lDevice = FBCast<ORDevice_SyncReference>(pObject);
lDevice->SamplingRate.SetPropertyValue(pValue);
FBTime lPeriod; lPeriod.SetSecondDouble(1.0/pValue);
lDevice->SamplingPeriod = lPeriod;
}
bool ORDevice_SyncReference::FBCreate()
{
FBTime lPeriod;
lPeriod.SetSecondDouble(1.0/60.0);
SamplingPeriod = lPeriod;
SamplingRate.SetPropertyValue(60);
mSyncReference = new FBSyncReference("MyDeviceSync");
mSyncId = -1;
return true;
}
void ORDevice_SyncReference::FBDestroy()
{
delete mSyncReference;
}
bool ORDevice_SyncReference::DeviceOperation( kDeviceOperations pOperation )
{
switch (pOperation)
{
case kOpInit: return Init();
case kOpStart: return Start();
case kOpStop: return Stop();
case kOpReset: return Reset();
case kOpDone: return Done();
}
return FBDevice::DeviceOperation( pOperation );
}
bool ORDevice_SyncReference::Init()
{
FBProgress lProgress;
lProgress.Caption = "Device SyncReference";
lProgress.Text = "Initializing device...";
return true;
}
bool ORDevice_SyncReference::Start()
{
FBProgress lProgress;
lProgress.Caption = "Starting up device";
mSyncId = mSyncReference->GetSyncCount();
mSyncReference->Active = true;
Status = "Ok";
return true;
}
bool ORDevice_SyncReference::Stop()
{
FBProgress lProgress;
lProgress.Caption = "Shutting down device";
mSyncReference->Active = false;
Status = "?";
return false;
}
bool ORDevice_SyncReference::Done()
{
return false;
}
bool ORDevice_SyncReference::Reset()
{
Stop();
return Start();
}
bool ORDevice_SyncReference::AnimationNodeNotify(FBAnimationNode* pAnimationNode ,FBEvaluateInfo* pEvaluateInfo)
{
return true;
}
bool ORDevice_SyncReference::DeviceEvaluationNotify( kTransportMode pMode, FBEvaluateInfo* pEvaluateInfo )
{
AckOneSampleReceived();
mSyncReference->Sync(++mSyncId);
return true;
}
void ORDevice_SyncReference::DeviceIONotify( kDeviceIOs pAction,FBDeviceNotifyInfo &pDeviceNotifyInfo)
{
switch (pAction)
{
case kIOPlayModeWrite:
case kIOStopModeWrite:
{
}break;
case kIOStopModeRead:
case kIOPlayModeRead:
{
}break;
}
}
void ORDevice_SyncReference::DeviceRecordFrame( FBDeviceNotifyInfo &pDeviceNotifyInfo )
{
}
bool ORDevice_SyncReference::FbxStore(FBFbxObject* pFbxObject,
kFbxObjectStore pStoreWhat)
{
return true;
}
bool ORDevice_SyncReference::FbxRetrieve(FBFbxObject* pFbxObject,
kFbxObjectStore pStoreWhat)
{
return true;
}