blob: 93212dbb2d8c269055e51b2608752aadaaefd0f0 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2012, 2023 AIT, Hit robot group
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Filip Andren - initial API and implementation and/or initial documentation
* Tibalt Zhao - Merge additem into opc connect
*******************************************************************************/
#include "Cmd_AddConnection.h"
#include "opcconnectionimpl.h"
#include "opcconnection.h"
#include "opcprocessvar.h"
CCmd_AddConnection::CCmd_AddConnection(COpcConnectionImpl *paConnectionimpl, const char* paGroupName,
unsigned long paReqUpdateRate, float paDeadBand, std::vector<COpcProcessVar*> paNewItems) :
mConnection(paConnectionimpl), mGroupName(paGroupName), mReqUpdateRate(paReqUpdateRate), mDeadBand(paDeadBand) {
for(auto opcVar : paNewItems){
if(COpcProcessVar::e_FBInput == opcVar->getItemFunction()){
mWriteItems.push_back(opcVar->getItemName());
}
else if(COpcProcessVar::e_FBOutput == opcVar->getItemFunction()){
mReadItems.push_back(opcVar->getItemName());
}
else{
DEVLOG_ERROR("COpcProcessVar::getItemFunction() returned unknown value\n");
}
}
}
void CCmd_AddConnection::runCommand(){
if(mConnection->connect(mGroupName)){
if(mConnection->addGroup(mGroupName,mReqUpdateRate,mDeadBand)){
mConnection->addItemList(mGroupName,mReadItems, mWriteItems);
}
}
}
const char* CCmd_AddConnection::getCommandName() const{
return "Cmd_AddConnection";
}