Skip to content
Snippets Groups Projects
Commit 87c943e1 authored by al.schwinn's avatar al.schwinn
Browse files

Bug 1387 - Provide Command-Line Silecs Client

parent c1b1ea09
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.2141938844">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.2141938844" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.2141938844" name="Debug" parent="cdt.managedbuild.config.gnu.exe.debug">
<folderInfo id="cdt.managedbuild.config.gnu.exe.debug.2141938844." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.148999669" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.1502172553" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/>
<builder buildPath="${workspace_loc:/silecs-cli-client}/Debug" id="cdt.managedbuild.target.gnu.builder.exe.debug.1879335443" managedBuildOn="true" name="Gnu Make Builder.Debug" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.base.1403566861" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1842696123" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
<option id="gnu.cpp.compiler.exe.debug.option.optimization.level.1327874570" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.exe.debug.option.debugging.level.295080131" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.422825111" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.716578848" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.1945002178" superClass="gnu.c.compiler.exe.debug.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
<option id="gnu.c.compiler.exe.debug.option.debugging.level.1863346534" superClass="gnu.c.compiler.exe.debug.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1710627947" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.415604299" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.563268854" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug">
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.634389681" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.assembler.exe.debug.2024598489" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1509579893" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="cdt.managedbuild.config.gnu.exe.release.958720723">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.958720723" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.958720723" name="Release" parent="cdt.managedbuild.config.gnu.exe.release">
<folderInfo id="cdt.managedbuild.config.gnu.exe.release.958720723." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.328873722" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.1654063617" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/>
<builder buildPath="${workspace_loc:/silecs-cli-client}/Release" id="cdt.managedbuild.target.gnu.builder.exe.release.2000858798" managedBuildOn="true" name="Gnu Make Builder.Release" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.base.1798805476" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.1309368114" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release">
<option id="gnu.cpp.compiler.exe.release.option.optimization.level.702925897" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.exe.release.option.debugging.level.346748341" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1555609612" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.762305723" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.1247297257" superClass="gnu.c.compiler.exe.release.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.exe.release.option.debugging.level.1961744080" superClass="gnu.c.compiler.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1727621506" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.exe.release.1812801652" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.1740298277" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release">
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1135886637" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.assembler.exe.release.309095766" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1368235097" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="silecs-cli-client.cdt.managedbuild.target.gnu.exe.202646488" name="Executable" projectType="cdt.managedbuild.target.gnu.exe"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.2141938844;cdt.managedbuild.config.gnu.exe.debug.2141938844.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.716578848;cdt.managedbuild.tool.gnu.c.compiler.input.1710627947">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.2141938844;cdt.managedbuild.config.gnu.exe.debug.2141938844.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1842696123;cdt.managedbuild.tool.gnu.cpp.compiler.input.422825111">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.958720723;cdt.managedbuild.config.gnu.exe.release.958720723.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.762305723;cdt.managedbuild.tool.gnu.c.compiler.input.1727621506">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.958720723;cdt.managedbuild.config.gnu.exe.release.958720723.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.1309368114;cdt.managedbuild.tool.gnu.cpp.compiler.input.1555609612">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
<buildTargets>
<target name="x86_64" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>CPU=x86_64 -j4</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="clean" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
</buildTargets>
</storageModule>
</cproject>
/bin/
/build/
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>silecs-cli-client</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="cdt.managedbuild.config.gnu.exe.debug.2141938844" name="Debug">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-226059455508497530" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
<configuration id="cdt.managedbuild.config.gnu.exe.release.958720723" name="Release">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-226059455508497530" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
</project>
This diff is collapsed.
# Copyright 2016 CERN and GSI
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
PROJECT = silecs
PRODUCT = cli-client
VERSION = 1.0.2
SKIP_MANIFEST = TRUE
#local
#COMMON_MAKE_PATH ?= /common/home/bel/schwinn/lnx/workspace-silecs-neon/generic-makefiles
#global
COMMON_MAKE_PATH ?= /opt/cern/buildsystem/generic/2.9.0
# product configuration
BIN_NAME = $(PROJECT)-$(PRODUCT)
DBG = false
# Include the generic make file
include $(COMMON_MAKE_PATH)/Make.generic
\ No newline at end of file
BOOST_VERSION ?= 1.54.0
SILECS_COMM_VERSION = 1.0.2
BOOST_HOME ?= /acc/local/$(CPU)/3rdparty/boost/$(BOOST_VERSION)
#for compile out of eclipse
SILECS_COMM_HOME ?= ../../git/silecs-communication-cpp/build
#SILECS_COMM_HOME ?= ../silecs-communication-cpp/build
LIBXML_PATH ?= /usr/include/libxml2/
#for compile out of eclipse
SNAP7_BASE ?= ../../git/snap7/snap7-full
#SNAP7_BASE ?= ../snap7/snap7-full
DEPENDENT_COMPILER_OPTIONS += -I$(SILECS_COMM_HOME)/include
DEPENDENT_COMPILER_OPTIONS += -I$(LIBXML_PATH)
DEPENDENT_COMPILER_OPTIONS += -I$(BOOST_HOME)/include
DEPENDENT_LINKER_OPTIONS += -L$(SILECS_COMM_HOME)/lib/$(CPU)
DEPENDENT_LINKER_OPTIONS += -L$(SNAP7_BASE)/build/bin/$(CPU)-linux -lsnap7
DEPENDENT_LINKER_OPTIONS += -L/usr/lib64 -lxml2
DEPENDENT_LINKER_OPTIONS += -lsilecs-comm
DEPENDENT_LINKER_OPTIONS += -lstdc++ -lxml2 -lcurl
# silecs-cli-client
This component of the SILECS PLC-framework allows to connect to a silecs-configured PLC by using the command-line
## Getting Started
Please check the lab-specific SILECS-Wikis for more information:
[CERN SILECS Wiki Page][CERN_Wiki]
[GSI SILECS Wiki Page][GSI_Wiki]
## License
Licensed under the GNU GENERAL PUBLIC LICENSE Version 3. See the [LICENSE file][license] for details.
[license]: LICENSE
[CERN_Wiki]: https://wikis.cern.ch/display/SIL/SILECs+Home
[GSI_Wiki]: https://www-acc.gsi.de/wiki/Frontend/SILECS
\ No newline at end of file
#!/bin/sh
set -e
\ No newline at end of file
#!/bin/sh
set -e
CPU="x86_64"
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT") # path where this script is located in
SNAP7_PATH=${SCRIPTPATH}/../../../git/snap7/snap7-full/build/bin/${CPU}-linux
BINARY="${SCRIPTPATH}/../build/bin/${CPU}/silecs-cli-client"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SNAP7_PATH
echo "##### LD_LIBRARY_PATH: ######"
echo "$LD_LIBRARY_PATH"
echo "###################################################################"
PARAM_FILE=/common/home/bel/schwinn/lnx/workspace-silecs-neon/SiemensTestDU/generated/client/tsts7001.silecsparam
# config for SiemensTestDU
$BINARY -f $PARAM_FILE -p 1000 -d MyDevice1 -r DQ_Anlog00 -m GET_REGISTER
#!/bin/sh
set -e
\ No newline at end of file
#!/bin/sh
set -e
INSTALL_DIR=$1
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT") # path where this script is located in
mkdir -p ${INSTALL_DIR}
cp -r ${SCRIPTPATH}/build/bin ${INSTALL_DIR}
\ No newline at end of file
// Copyright 2016 CERN and GSI
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <getopt.h>
#include <iostream>
#include <unistd.h>//usleep
#include <silecs-communication/interface/utility/XMLParser.h>
#include <silecs-communication/interface/core/SilecsService.h>
#include <silecs-communication/interface/equipment/SilecsCluster.h>
#include <silecs-communication/interface/equipment/SilecsDevice.h>
#include <silecs-communication/interface/equipment/SilecsRegister.h>
const std::string startbold = "\e[1m";
const std::string endbold = "\e[0m";
enum ModeType { UNDEFINED, GET_DEVICE, GET_BLOCK, GET_REGISTER, SET_REGISTER };
std::string arg_logTopics; //comma separated list ? space-separated ?
std::string arg_parameterFile = "";
std::string arg_plcName = "";
std::string arg_deviceName = "";
std::string arg_blockName = "";
std::string arg_registerName = "";
ModeType arg_mode = UNDEFINED;
uint32_t periodicInterval = 0;
void printHelp()
{
std::cout << std::endl;
std::cout << startbold << "NAME" << endbold << std::endl;
std::cout << "\tsilecs-cli-client - Command Line Client to connect to a silecs-configured PLC" << std::endl;
std::cout << std::endl;
std::cout << startbold << "SYNOPSIS" << endbold << std::endl;
std::cout << "\tsilecs-cli-client - [OPTIONS]" << std::endl;
std::cout << std::endl;
std::cout << startbold << "DESCRIPTION" << endbold << std::endl;
std::cout << "\t Connect to a PLC and get/set values by using the Silecs-framework." << std::endl;
std::cout << startbold << "\t-b " << endbold << "silecs-block to get" << std::endl;
std::cout << startbold << "\t-d " << endbold << "silecs-device to request" << std::endl;
std::cout << startbold << "\t-f " << endbold << "path to silecs-parameter-file of the plc" << std::endl;
std::cout << startbold << "\t-h " << endbold << "print this help" << std::endl;
std::cout << startbold << "\t-i " << endbold << "start interactive session" << std::endl; // TODO: Implement
std::cout << startbold << "\t-l " << endbold << "define LOGTOPICS" << std::endl; // TODO: Implement
std::cout << startbold << "\t-m " << endbold << "mode, can be 'GET_DEVICE', 'GET_BLOCK', 'GET_REGISTER' or 'SET_REGISTER'" << std::endl;
std::cout << startbold << "\t-p " << endbold << "periodic Interval(ms) us ? to measure" << std::endl;
std::cout << startbold << "\t-r " << endbold << "optional, register to get/set" << std::endl;
std::cout << std::endl;
std::cout << startbold << "AUTHOR" << endbold << std::endl;
std::cout << "\t Written by Alexander Schwinn" << std::endl;
std::cout << std::endl;
std::cout << startbold << "REPORTING BUGS" << endbold << std::endl;
std::cout << "\t Please contact the author vie the gsi mail-address" << std::endl;
std::cout << std::endl;
std::cout << startbold << "COPYRIGHT" << endbold << std::endl;
std::cout << "\tCopyright © 2017 Free Software Foundation, Inc. License GPLv3+: GNU" << std::endl;
std::cout << "\tGPL version 3 or later <http://gnu.org/licenses/gpl.html>." << std::endl;
std::cout << "\tThis is free software: you are free to change and redistribute it." << std::endl;
std::cout << "\tThere is NO WARRANTY, to the extent permitted by law." << std::endl;
std::cout << std::endl;
}
std::string getPLCName(Silecs::XMLParser &paramParser)
{
Silecs::ElementXML mappingNode = paramParser.getFirstElementFromXPath("/SILECS-Param/SILECS-Mapping");
return mappingNode.getAttribute("plc-name");
}
Silecs::Cluster* getSilecsClusterbyDevice(std::string deviceName, Silecs::XMLParser &paramParser, Silecs::Service *silecsService)
{
Silecs::ElementXML classNode = paramParser.getFirstElementFromXPath("/SILECS-Param/SILECS-Mapping/SILECS-Class[Instance/@label='"+ deviceName + "']");
std::string className = classNode.getAttribute("name");
std::string classVersion = classNode.getAttribute("version");
return silecsService->getCluster(className,classVersion);
}
void printDevice(std::string deviceName)
{
}
void printBlock(std::string blockName)
{
}
void printRegister(Silecs::Register* reg)
{
reg->printVal();
}
void setRegister(std::string registerName,std::string value)
{
}
int connectInteractive(Silecs::Service *service, Silecs::XMLParser &paramParser)
{
//ask class
//ask device or print all devices
//ask select block or print device
//ask select register or print block
//ask get/set register
//Silecs::Cluster *cluster = NULL;
return EXIT_SUCCESS;
}
int connectNonInteractive(Silecs::Service *service, Silecs::XMLParser &paramParser, bool periodicOptionSet)
{
Silecs::Cluster *silecsCluster = getSilecsClusterbyDevice(arg_deviceName, paramParser, service);
Silecs::PLC *plc = silecsCluster->getPLC(getPLCName(paramParser),arg_parameterFile);
Silecs::Device *device = plc->getDevice(arg_deviceName);
Silecs::Register* reg = NULL;
if(!arg_registerName.empty())
reg = device->getRegister(arg_registerName);
do
{
switch(arg_mode)
{
case GET_DEVICE:
std::cout << "TODO: print device" << std::endl;
break;
case GET_BLOCK:
std::cout << "TODO: print block" << std::endl;
break;
case GET_REGISTER:
printRegister(reg);
break;
case SET_REGISTER:
std::cout << "TODO: set register" << std::endl;
break;
default:
std::cout << "Unknown mode defined by -m" << std::endl;
return EXIT_FAILURE;
}
usleep(periodicInterval);
}while ( periodicOptionSet );
return EXIT_SUCCESS;
}
int main(int argc, char **argv)
{
try
{
int opt;
bool interactiveOptionSet = false;
bool periodicOptionSet = false;
while ((opt = getopt(argc, argv, ":l:hp:r:b:d:f:m:i")) != -1)
{
std::istringstream ss(optarg);
switch (opt)
{
case 'h':
printHelp();
return EXIT_SUCCESS;
case 'l':
arg_logTopics.assign(optarg);
std::cout << "TODO: make use of log-topics + define some defaults" << std::endl;
return EXIT_FAILURE;
break;
case 'p':
{
if(interactiveOptionSet)
{
std::cout << "Error: options '-i' and '-p' are mutually exclusive " << std::endl;
printHelp();
return EXIT_FAILURE;
}
periodicOptionSet = true;
std::istringstream ss(optarg);
ss >> periodicInterval;
break;
}
case 'r':
arg_registerName.assign(optarg);
break;
case 'd':
arg_deviceName.assign(optarg);
break;
case 'f':
arg_parameterFile.assign(optarg);
break;
case 'b':
arg_blockName.assign(optarg);
break;
case 'm':
{
std::string mode;
mode.assign(optarg);
if(mode == "GET_DEVICE")
arg_mode = GET_DEVICE;
else if( mode == "GET_BLOCK")
arg_mode = GET_BLOCK;
else if( mode == "GET_REGISTER")
arg_mode = GET_REGISTER;
else if( mode == "SET_REGISTER")
arg_mode = SET_REGISTER;
else
{
std::cout << "Error: invalid mode passed. Please check the help:" << std::endl;
printHelp();
return EXIT_FAILURE;
}
break;
}
case 'i':
if(interactiveOptionSet)
{
std::cout << "Error: options '-i' and '-p' are mutually exclusive " << std::endl;
printHelp();
return EXIT_FAILURE;
}
interactiveOptionSet = true;
std::cout << "TODO: implement interactive-mode" << std::endl;
return EXIT_FAILURE;
break;
case '?':
std::cout << "Unrecognized option: " << optopt << std::endl;
}
}
if( arg_mode == GET_BLOCK && arg_blockName.empty())
{
std::cout << "Error: No block-name specified, cannot execute GET_BLOCK" << std::endl;
printHelp();
return EXIT_FAILURE;
}
if( ( arg_mode == GET_REGISTER || arg_mode == SET_REGISTER ) && arg_registerName.empty())
{
std::cout << "Error: No block-name specified, cannot execute GET_REGISTER or SET_REGISTER" << std::endl;
printHelp();
return EXIT_FAILURE;
}
if( arg_parameterFile.empty() )
{
std::cout << "Error: no parameter-file was passed. You need to at least pass -f [filename]" << std::endl;
printHelp();
return EXIT_FAILURE;
}
Silecs::XMLParser::init();
Silecs::XMLParser paramParser(arg_parameterFile,true);
// if(logTopics.length() == 0)
// {
Silecs::Service *silecsService = Silecs::Service::getInstance(0, NULL);
// }
// else
// {
// Utils::logInfo(messageConsole_,"the following log topics will be used: " + logTopics);
// char *a = new char[logTopics.size()+1];
// a[logTopics.size()]=0;
// memcpy(a,logTopics.c_str(),logTopics.size());
// char *argv[2] = { (char *)"-plcLog", a };
// silecsService = Silecs::Service::getInstance(2,argv);
// }
if(interactiveOptionSet)
{
return connectInteractive(silecsService, paramParser);
}
else
{
if( arg_deviceName.empty() )
{
std::cout << "Error: no deviceName was passed. You need to pass -d [devicename]" << std::endl;
printHelp();
return EXIT_FAILURE;
}
return connectNonInteractive(silecsService, paramParser, periodicOptionSet );
}
return EXIT_SUCCESS;
}
catch(std::string *str)
{
std::cout << str;
}
catch(std::exception& ex)
{
std::cout << ex.what();
}
catch(...)
{
std::cout << "Unexpected error caught in Main. Please notify SILECS support";
}
return -1;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment