#include "ordeviceoutput_layout.h"
#define ORDEVICEOUTPUT__LAYOUT ORDeviceOutputLayout
ORDEVICEOUTPUT__CLASSSTR,
bool ORDeviceOutputLayout::FBCreate()
{
mDevice = ((ORDeviceOutput *)(FBDevice *)Device);
UICreate ();
UIConfigure ();
UIReset ();
mDevice->OnStatusChange.Add (
this,(
FBCallback)&ORDeviceOutputLayout::EventDeviceStatusChange );
mSystem.OnUIIdle.Add (
this,(
FBCallback)&ORDeviceOutputLayout::EventUIIdle );
return true;
}
void ORDeviceOutputLayout::FBDestroy()
{
mDevice->OnStatusChange.Remove (
this,(
FBCallback)&ORDeviceOutputLayout::EventDeviceStatusChange );
mSystem.OnUIIdle.Remove (
this,(
FBCallback)&ORDeviceOutputLayout::EventUIIdle );
}
void ORDeviceOutputLayout::UICreate()
{
int lS, lH;
lS = 5;
lH = 25;
AddRegion (
"MainLayout",
"MainLayout", lS,
kFBAttachLeft,
"TabPanel", 1.00,
SetControl ( "TabPanel", mTabPanel );
SetControl ( "MainLayout", mLayoutLightParameters );
UICreateLayout0();
UICreateLayout1();
UICreateLayout2();
}
void ORDeviceOutputLayout::UICreateLayout0()
{
int lS, lW, lH;
lS = 4;
lW = 100;
lH = 18;
mLayoutLightParameters.AddRegion("LabelExportFilename", "LabelExportFilename",
mLayoutLightParameters.AddRegion("EditExportFilename", "EditExportFilename",
mLayoutLightParameters.AddRegion("LabelExportRate", "LabelExportRate",
mLayoutLightParameters.AddRegion("EditNumberExportRate", "EditNumberExportRate",
mLayoutLightParameters.SetControl("LabelExportFilename", mLabelExportFilename );
mLayoutLightParameters.SetControl("EditExportFilename", mEditExportFilename );
mLayoutLightParameters.SetControl("LabelExportRate", mLabelExportRate );
mLayoutLightParameters.SetControl("EditNumberExportRate", mEditNumberExportRate );
}
void ORDeviceOutputLayout::UICreateLayout1()
{
int lS = 5;
int lSx = 15;
int lSy = 20;
int lS_y = -15;
int lW = 100;
int lH = 18;
int lHlr = 75;
int lWlr = 200;
int lWrb = 80;
int lSlbx = 15;
int lSlby = 10;
int lWlb = 80;
mLayoutCommunication.AddRegion( "LayoutRegionSerial", "LayoutRegionSerial",
mLayoutCommunication.AddRegion( "ButtonSerialEnable", "ButtonSerialEnable",
mLayoutCommunication.AddRegion( "LabelSerialPort", "LabelSerialPort",
mLayoutCommunication.AddRegion( "ListSerialPort", "ListSerialPort",
mLayoutCommunication.AddRegion( "LabelSerialBaudRate", "LabelSerialBaudRate",
mLayoutCommunication.AddRegion( "ListSerialBaudRate", "ListSerialBaudRate",
mLayoutCommunication.SetControl( "ButtonSerialEnable", mButtonSerialEnable );
mLayoutCommunication.SetControl( "LabelSerialPort", mLabelSerialPort );
mLayoutCommunication.SetControl( "ListSerialPort", mListSerialPort );
mLayoutCommunication.SetControl( "LabelSerialBaudRate", mLabelSerialBaudRate );
mLayoutCommunication.SetControl( "ListSerialBaudRate", mListSerialBaudRate );
}
void ORDeviceOutputLayout::UICreateLayout2()
{
int lS, lW, lH;
lS = 5;
lW = 200;
lH = 25;
mLayoutInformation.AddRegion ( "LabelInformation", "LabelInformation",
mLayoutInformation.SetControl( "LabelInformation", mLabelInformation );
}
void ORDeviceOutputLayout::UIConfigure()
{
mTabPanel.Items.SetString("Light Parameters~Communication~Information");
mTabPanel.OnChange.Add(
this, (
FBCallback)&ORDeviceOutputLayout::EventTabPanelChange );
UIConfigureLayout0();
UIConfigureLayout1();
UIConfigureLayout2();
}
void ORDeviceOutputLayout::UIConfigureLayout0()
{
mLabelExportFilename.Caption = "Export File :";
mLabelExportRate.Caption = "Export Rate :";
mEditNumberExportRate.Min = 1.0;
mEditNumberExportRate.Max = 100.0;
mEditExportFilename.OnChange.Add (
this, (
FBCallback)&ORDeviceOutputLayout::EventEditExportFilenameChange );
mEditNumberExportRate.OnChange.Add (
this, (
FBCallback)&ORDeviceOutputLayout::EventEditNumberExportRateChange );
}
void ORDeviceOutputLayout::UIConfigureLayout1()
{
mLayoutCommunication.SetBorder(
"LayoutRegionSerial",
kFBEmbossBorder,
false,
true,2,1,90.0,0 );
mButtonSerialEnable.Caption = "Serial";
mButtonSerialEnable.State = 1;
mLabelSerialPort.Caption = "Port :";
int lPortNumber;
char lBuffer[40];
for( i=0; i<mSystem.CommPorts.GetCount(); i++ )
{
lPortNumber = mSystem.CommPorts[
i];
sprintf(lBuffer, "Comm %d", lPortNumber );
mListSerialPort.Items.Add( lBuffer, lPortNumber );
}
mListSerialPort.OnChange.Add(
this, (
FBCallback)&ORDeviceOutputLayout::EventListSerialPortChange );
mLabelSerialBaudRate.Caption = "Speed :";
mListSerialBaudRate.Items.Add( "9600", 9600 );
mListSerialBaudRate.Items.Add( "19200", 19200 );
mListSerialBaudRate.Items.Add( "38400", 38400 );
mListSerialBaudRate.Items.Add( "57600", 57600 );
mListSerialBaudRate.Items.Add( "115200", 115200 );
mListSerialBaudRate.Items.Add( "230400", 230400 );
mListSerialBaudRate.OnChange.Add(
this, (
FBCallback)&ORDeviceOutputLayout::EventListSerialBaudRateChange );
}
void ORDeviceOutputLayout::UIConfigureLayout2()
{
mLabelInformation.Caption = "Information...";
}
void ORDeviceOutputLayout::UIRefresh()
{
}
void ORDeviceOutputLayout::UIReset()
{
mEditNumberExportRate.Value = mDevice->GetExportRate();
mEditExportFilename.Text = mDevice->GetExportFilename();
mListSerialPort.ItemIndex = mListSerialPort.Items.Find ( mDevice->GetSerialPort() );
mListSerialBaudRate.ItemIndex = mListSerialBaudRate.Items.Find( mDevice->GetSerialBaudRate() );
}
void ORDeviceOutputLayout::EventEditExportFilenameChange(
HISender pSender,
HKEvent pEvent )
{
if( mDevice->Online )
{
mDevice->DeviceSendCommand( FBDevice::kOpStop );
}
mDevice->SetExportFilename( mEditExportFilename.Text );
mEditExportFilename.Text = mDevice->GetExportFilename();
}
void ORDeviceOutputLayout::EventEditNumberExportRateChange(
HISender pSender,
HKEvent pEvent )
{
if( mDevice->Online )
{
mDevice->DeviceSendCommand( FBDevice::kOpStop );
}
mDevice->SetExportRate( mEditNumberExportRate.Value );
mEditNumberExportRate.Value = mDevice->GetExportRate();
}
void ORDeviceOutputLayout::EventTabPanelChange(
HISender pSender,
HKEvent pEvent )
{
switch( mTabPanel.ItemIndex )
{
case 0: SetControl("MainLayout", mLayoutLightParameters ); break;
case 1: SetControl("MainLayout", mLayoutCommunication ); break;
case 2: SetControl("MainLayout", mLayoutInformation ); break;
}
}
void ORDeviceOutputLayout::EventDeviceStatusChange(
HISender pSender,
HKEvent pEvent )
{
UIReset();
}
{
if( mDevice->Online )
{
UIRefresh();
}
}
void ORDeviceOutputLayout::EventListSerialPortChange(
HISender pSender,
HKEvent pEvent )
{
if( mDevice->Online )
{
mDevice->DeviceSendCommand( FBDevice::kOpStop );
}
mDevice->SetSerialPort(mListSerialPort.Items.GetReferenceAt(mListSerialPort.ItemIndex));
mListSerialPort.ItemIndex = mListSerialPort.Items.Find(mDevice->GetSerialPort());
}
void ORDeviceOutputLayout::EventListSerialBaudRateChange(
HISender pSender,
HKEvent pEvent )
{
if( mDevice->Online )
{
mDevice->DeviceSendCommand( FBDevice::kOpStop );
}
mDevice->SetSerialBaudRate( mListSerialBaudRate.Items.GetReferenceAt(mListSerialBaudRate.ItemIndex) );
mListSerialBaudRate.ItemIndex = mListSerialBaudRate.Items.Find( mDevice->GetSerialBaudRate() );
}