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.
106 lines
3.1 KiB
106 lines
3.1 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: LgNetMessageGPIO.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of LgNetMessageGPIO.cpp
|
|
//----------------------------------------------------------------------------
|
|
#include "stdafx.h"
|
|
#include "LgNetMessageGPIO.h"
|
|
#include "..\Device\LgDeviceGPIO.h"
|
|
|
|
// commands
|
|
BOOL CLgNetMessageGPIO::BuildCmdGetOutput( INT nOutput )
|
|
{
|
|
CLgDeviceGPIO::GPIO_PIN output;
|
|
output.nIndex = nOutput;
|
|
output.bOn = 0;
|
|
return Build( CLgDeviceGPIO::CMD_GET_OUTPUT, &output, sizeof(output) );
|
|
}
|
|
|
|
BOOL CLgNetMessageGPIO::BuildCmdGetOutputAll()
|
|
{
|
|
return Build( CLgDeviceGPIO::CMD_GET_OUTPUT_ALL );
|
|
}
|
|
|
|
BOOL CLgNetMessageGPIO::BuildCmdSetOutput( INT nOutput, BOOL bOn )
|
|
{
|
|
CLgDeviceGPIO::GPIO_PIN output;
|
|
output.nIndex = nOutput;
|
|
output.bOn = bOn;
|
|
return Build( CLgDeviceGPIO::CMD_SET_OUTPUT, &output, sizeof( output ) );
|
|
}
|
|
|
|
BOOL CLgNetMessageGPIO::BuildCmdGetInput( INT nInput )
|
|
{
|
|
CLgDeviceGPIO::GPIO_PIN input;
|
|
input.nIndex = nInput;
|
|
input.bOn = 0;
|
|
return Build( CLgDeviceGPIO::CMD_GET_INPUT, &nInput, sizeof(nInput) );
|
|
}
|
|
|
|
BOOL CLgNetMessageGPIO::BuildCmdGetInputAll()
|
|
{
|
|
return Build( CLgDeviceGPIO::CMD_GET_INPUT_ALL );
|
|
}
|
|
|
|
// events
|
|
BOOL CLgNetMessageGPIO::BuildEvtSetOutput( INT nOutput, BOOL bOn )
|
|
{
|
|
CLgDeviceGPIO::GPIO_PIN output;
|
|
output.nIndex = nOutput;
|
|
output.bOn = bOn;
|
|
return Build( CLgDeviceGPIO::EVT_SET_OUTPUT, &output, sizeof( output ) );
|
|
}
|
|
|
|
BOOL CLgNetMessageGPIO::BuildEvtGetOutput( INT nOutput, BOOL bOn )
|
|
{
|
|
CLgDeviceGPIO::GPIO_PIN output;
|
|
output.nIndex = nOutput;
|
|
output.bOn = bOn;
|
|
return Build( CLgDeviceGPIO::EVT_GET_OUTPUT, &output, sizeof( output ) );
|
|
}
|
|
|
|
BOOL CLgNetMessageGPIO::BuildEvtGetOutputAll( CLgDeviceGPIO::PGPIO_PINS pPins )
|
|
{
|
|
return Build( CLgDeviceGPIO::EVT_GET_OUTPUT_ALL, pPins, sizeof(CLgDeviceGPIO::GPIO_PINS) + ( pPins->nCount ? pPins->nCount - 1 : 0 ) * sizeof(CLgDeviceGPIO::GPIO_PIN) );
|
|
}
|
|
|
|
|
|
BOOL CLgNetMessageGPIO::BuildEvtGetInput( INT nInput, BOOL bOn )
|
|
{
|
|
CLgDeviceGPIO::GPIO_PIN input;
|
|
input.nIndex = nInput;
|
|
input.bOn = bOn;
|
|
return Build( CLgDeviceGPIO::EVT_GET_INPUT, &input, sizeof( input ) );
|
|
}
|
|
|
|
|
|
BOOL CLgNetMessageGPIO::BuildEvtGetInputAll( CLgDeviceGPIO::PGPIO_PINS pPins )
|
|
{
|
|
return Build( CLgDeviceGPIO::EVT_GET_INPUT_ALL, pPins, sizeof(CLgDeviceGPIO::GPIO_PINS) + ( pPins->nCount ? pPins->nCount - 1 : 0 ) * sizeof(CLgDeviceGPIO::GPIO_PIN) );
|
|
}
|
|
|
|
|
|
BOOL CLgNetMessageGPIO::BuildEvtInputChange( INT nInput, BOOL bOn )
|
|
{
|
|
CLgDeviceGPIO::GPIO_PIN input;
|
|
input.nIndex = nInput;
|
|
input.bOn = bOn;
|
|
return Build( CLgDeviceGPIO::EVT_INPUT_CHANGE, &input, sizeof( input ) );
|
|
}
|
|
|
|
CLgDeviceGPIO::PGPIO_PINS CLgNetMessageGPIO::GetInputPins()
|
|
{
|
|
if( !CLgNetMessage::GetData() || CLgNetMessage::GetDataCount() < sizeof(CLgDeviceGPIO::GPIO_PINS) )
|
|
return NULL;
|
|
|
|
PBYTE pData = (PBYTE)CLgNetMessage::GetData();
|
|
return (CLgDeviceGPIO::PGPIO_PINS)&pData[1];
|
|
}
|