⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 opcomchannel.cpp

📁 This software aims to create an applet and panel tools to manage a wireless interface card, such as
💻 CPP
字号:
//
// OpcomChannel.cpp
//
// $Id: //poco/Main/Foundation/src/OpcomChannel.cpp#5 $
//
// Copyright (c) 2004, Guenter Obiltschnig/Applied Informatics.
// All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 
// 1. Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
// 
// 2. Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
// 
// 3. Redistributions in any form must be accompanied by information on
//    how to obtain complete source code for this software and any
//    accompanying software that uses this software.  The source code
//    must either be included in the distribution or be available for no
//    more than the cost of distribution plus a nominal fee, and must be
//    freely redistributable under reasonable conditions.  For an
//    executable file, complete source code means the source code for all
//    modules it contains.  It does not include source code for modules or
//    files that typically accompany the major components of the operating
//    system on which the executable file runs.
// 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//


#include "Foundation/OpcomChannel.h"
#include "Foundation/Message.h"
#include <starlet.h>
#include <opcdef.h>
#include <descrip.h>


Foundation_BEGIN


const std::string OpcomChannel::PROP_TARGET = "target";


OpcomChannel::OpcomChannel(): _target(OPC$M_NM_CENTRL)
{
}


OpcomChannel::OpcomChannel(int target): _target(target)
{
}


OpcomChannel::~OpcomChannel()
{
}


void OpcomChannel::log(const Message& msg)
{
	const std::string& text = msg.getText();
	// set up OPC buffer
	struct _opcdef buffer;
	buffer.opc$b_ms_type   = OPC$_RQ_RQST;
	buffer.opc$b_ms_target = _target;
	buffer.opc$l_ms_rqstid = 0;
	int len = text.size();
	// restrict message text to 128 chars
	if (len > 128) len = 128;
	// copy message text into buffer
	memcpy(&buffer.opc$l_ms_text, text.data(), len);

	// sys$sndopr only accepts 32-bit pointers
	#pragma pointer_size save
	#pragma pointer_size 32

	// set up the descriptor
	struct dsc$descriptor bufferDsc;
	bufferDsc.dsc$w_length  = len + 8;
	bufferDsc.dsc$a_pointer = (char*) &buffer;
	// call the system service
	sys$sndopr(&bufferDsc, 0);

	#pragma pointer_size restore
}


void OpcomChannel::setProperty(const std::string& name, const std::string& value)
{
	if (name == PROP_TARGET)
	{
		if (value == "CARDS")
			_target = OPC$M_NM_CARDS;
		else if (value == "CENTRL")
			_target = OPC$M_NM_CENTRL;
		else if (value == "CLUSTER")
			_target = OPC$M_NM_CLUSTER;
		else if (value == "DEVICE")
			_target = OPC$M_NM_DEVICE;
		else if (value == "DISKS")
			_target = OPC$M_NM_DISKS;
		else if (value == "NTWORK")
			_target = OPC$M_NM_NTWORK;
		else if (value == "TAPES")
			_target = OPC$M_NM_TAPES;
		else if (value == "PRINT")
			_target = OPC$M_NM_PRINT;
		else if (value == "SECURITY")
			_target = OPC$M_NM_SECURITY;
		else if (value == "OPER1")
			_target = OPC$M_NM_OPER1;
		else if (value == "OPER2")
			_target = OPC$M_NM_OPER2;
		else if (value == "OPER3")
			_target = OPC$M_NM_OPER3;
		else if (value == "OPER4")
			_target = OPC$M_NM_OPER4;
		else if (value == "OPER5")
			_target = OPC$M_NM_OPER5;
		else if (value == "OPER6")
			_target = OPC$M_NM_OPER6;
		else if (value == "OPER7")
			_target = OPC$M_NM_OPER7;
		else if (value == "OPER8")
			_target = OPC$M_NM_OPER8;
		else if (value == "OPER9")
			_target = OPC$M_NM_OPER9;
		else if (value == "OPER10")
			_target = OPC$M_NM_OPER10;
		else if (value == "OPER11")
			_target = OPC$M_NM_OPER11;
		else if (value == "OPER12")
			_target = OPC$M_NM_OPER12;
	}
	else
	{
		Channel::setProperty(name, value);
	}
}


std::string OpcomChannel::getProperty(const std::string& name) const
{
	if (name == PROP_TARGET)
	{
		if (_target == OPC$M_NM_CARDS)
			return "CARDS";
		else if (_target == OPC$M_NM_CENTRL)
			return "CENTRL";
		else if (_target == OPC$M_NM_CLUSTER)
			return "CLUSTER";
		else if (_target == OPC$M_NM_DEVICE)
			return "DEVICE";
		else if (_target == OPC$M_NM_DISKS)
			return "DISKS";
		else if (_target == OPC$M_NM_NTWORK)
			return "NTWORK";
		else if (_target == OPC$M_NM_TAPES)
			return "TAPES";
		else if (_target == OPC$M_NM_PRINT)
			return "PRINT";
		else if (_target == OPC$M_NM_SECURITY)
			return "SECURITY";
		else if (_target == OPC$M_NM_OPER1)
			return "OPER1";
		else if (_target == OPC$M_NM_OPER2)
			return "OPER2";
		else if (_target == OPC$M_NM_OPER3)
			return "OPER3";
		else if (_target == OPC$M_NM_OPER4)
			return "OPER4";
		else if (_target == OPC$M_NM_OPER5)
			return "OPER5";
		else if (_target == OPC$M_NM_OPER6)
			return "OPER6";
		else if (_target == OPC$M_NM_OPER7)
			return "OPER7";
		else if (_target == OPC$M_NM_OPER8)
			return "OPER8";
		else if (_target == OPC$M_NM_OPER9)
			return "OPER9";
		else if (_target == OPC$M_NM_OPER10)
			return "OPER10";
		else if (_target == OPC$M_NM_OPER11)
			return "OPER11";
		else if (_target == OPC$M_NM_OPER12)
			return "OPER12";
	}
	return Channel::getProperty(name);
}


Foundation_END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -