You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
2.5 KiB
105 lines
2.5 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: DeviceDO.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of DeviceDO.cpp
|
|
//----------------------------------------------------------------------------
|
|
// DeviceOUT.cpp: implementation of the CDeviceOUT class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "stdafx.h"
|
|
//#include "chicago.h"
|
|
#include "DeviceDO.h"
|
|
#include "..\..\LgLib\Version.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
CDeviceDO::CDeviceDO()
|
|
{
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CDeviceDO::CDeviceDO") );
|
|
}
|
|
|
|
CDeviceDO::~CDeviceDO()
|
|
{
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CDeviceDO::~CDeviceDO") );
|
|
}
|
|
|
|
void CDeviceDO::PostSetSwitch( BOOL bOn, int nBit )
|
|
{
|
|
DDOEVENT event;
|
|
event.id = DDOC_SET_SWITCH;
|
|
event.bOn = bOn;
|
|
event.nBit = nBit;
|
|
m_Queue.Push( event );
|
|
}
|
|
|
|
void CDeviceDO::PostGetState()
|
|
{
|
|
DDOEVENT event;
|
|
event.id = DDOC_GET_STATE;
|
|
m_Queue.Push( event );
|
|
}
|
|
|
|
void CDeviceDO::SetCount( int nCount )
|
|
{
|
|
m_arrOutput.RemoveAll();
|
|
|
|
for( INT i = 0; i < nCount; i++ )
|
|
{
|
|
m_arrOutput.AddEmpty();
|
|
m_arrOutput[i].bOn = FALSE;
|
|
m_arrOutput[i].bFirstTime = TRUE;
|
|
}
|
|
|
|
PostGetState();
|
|
}
|
|
|
|
BOOL CDeviceDO::SetDirectOutput( CDirectOutput *pDirectOutput, int nBit )
|
|
{
|
|
ASSERT( nBit < m_arrOutput.GetCount() );
|
|
if( nBit >= m_arrOutput.GetCount() )
|
|
return FALSE;
|
|
|
|
return m_arrOutput[nBit].arrDirectOutput.Add( pDirectOutput );
|
|
}
|
|
|
|
BOOL CDeviceDO::GetBit( int nBit )
|
|
{
|
|
ASSERT( nBit < m_arrOutput.GetCount() );
|
|
if( nBit >= m_arrOutput.GetCount() )
|
|
return FALSE;
|
|
|
|
return m_arrOutput[nBit].bOn;
|
|
}
|
|
|
|
void CDeviceDO::SetBit( int nBit, BOOL bOn )
|
|
{
|
|
ASSERT( nBit < m_arrOutput.GetCount() );
|
|
if( nBit >= m_arrOutput.GetCount() )
|
|
return;
|
|
|
|
if( !m_arrOutput[nBit].bFirstTime && m_arrOutput[nBit].bOn == bOn )
|
|
return;
|
|
|
|
m_arrOutput[nBit].bFirstTime = FALSE;
|
|
m_arrOutput[nBit].bOn = bOn;
|
|
|
|
for( INT i = 0; i < m_arrOutput[nBit].arrDirectOutput.GetCount(); i++ )
|
|
m_arrOutput[nBit].arrDirectOutput[i]->PostOn( bOn );
|
|
}
|