Commit b38c9521 authored by Claes Sjofors's avatar Claes Sjofors

Powerlink CN server added

parent 8418ca20
......@@ -90,6 +90,12 @@ int main()
exit(sts);
}
sts = gdh_GetClassList(pwr_cClass_Epl_CNServer, &oid);
if ( ODD(sts)) {
system("rt_powerlink_cn &");
exit(0);
}
// Get Powerlink handler object
sts = io_get_plhandler_object(&plhp, &oid);
if (EVEN(sts)) {
......
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include ../../special.mk
-include ../special.mk
-include special.mk
ifndef link_rule_mk
link_rule_mk := 1
link = $(ldxx) $(explinkflags) $(domap) -o $(export_exe) \
$(export_obj) $(pwr_eobj)/rt_io_user.o \
$(pwre_conf_libdir) $(pwre_conf_libpwrrt) $(pwre_conf_lib) \
-lpwr_usbio_dummy -lpwr_usb_dummy -lpwr_cifx_dummy -lpwr_nodave_dummy \
$(pwre_conf_libpwrprofibus) $(pwre_conf_libpwrpowerlinkcn) -lpcap
endif
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* 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 2 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 Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#include "pwr.h"
#include "rt_io_msg.h"
#include "rt_pwr_msg.h"
#include "rt_gdh.h"
#include "rt_io_base.h"
#include "rt_errh.h"
#include "rt_aproc.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_otherioclasses.h"
// Test for CN build
#include "Epl.h"
tEplKernel EplApiSetCdcFilename(char* pszCdcFilename_p)
{
return 0;
}
pwr_tStatus io_get_plhandler_object (
pwr_sClass_EplHandler **o,
pwr_tObjid *roid
)
{
pwr_tStatus sts;
pwr_tObjid oid;
// Get EplHandler object
sts = gdh_GetClassList(pwr_cClass_EplHandler, &oid);
if (EVEN(sts)) return sts;
sts = gdh_ObjidToPointer( oid, (void *) o);
if (EVEN(sts)) return sts;
if (roid != NULL)
*roid = oid;
return IO__SUCCESS;
}
int main()
{
pwr_tStatus sts;
io_tCtx io_ctx;
float ctime = 1;
pwr_sClass_EplHandler *plhp;
pwr_tOid oid;
struct timespec tim1, tim2;
// Make connection to error handler
errh_Init("pwr_powerlink", errh_eAnix_powerlink);
errh_SetStatus( PWR__SRVSTARTUP);
// Make connection to realtime database
sts = gdh_Init("rt_powerlink");
if (EVEN(sts)) {
errh_Fatal("rt_powerlink aborted, gdh_Init failed\n%m", sts);
errh_SetStatus( PWR__SRVTERM);
exit(sts);
}
// Get Powerlink handler object
sts = io_get_plhandler_object(&plhp, &oid);
if (EVEN(sts)) {
errh_SetStatus( 0);
errh_Info("rt_powerlink terminated, no EplHandler object found");
exit(sts);
}
// Create context and call init functions of all agent,
// rack and cardobjects
sts = io_init(io_mProcess_Powerlink, pwr_cNObjid, &io_ctx, 1, ctime);
if ( EVEN(sts)) {
errh_SetStatus( PWR__SRVTERM);
errh_Fatal("rt_powerlink aborted, io_init() failed\n%m", sts);
exit(sts);
}
tim1.tv_sec = 0;
tim1.tv_nsec = (plhp->CycleTime)*1000000000L;
aproc_TimeStamp( plhp->CycleTime, 5.0);
errh_SetStatus( PWR__SRUN);
aproc_RegisterObject( oid);
// Call IoAgentRead() IoAgentWrite() IoCardRead() IoCardWrite()
// IoModuleRead() IoModuleWrite() forever
for (;;) {
sts = io_read(io_ctx);
sts = io_write(io_ctx);
nanosleep(&tim1, &tim2);
aproc_TimeStamp( plhp->CycleTime, 5.0);
}
}
Instructions to build openPOWERLINK for Proview:
Define enviroment variable epl to the root of the openPOWERLINK
installation
> export epl=/usr/local/openPOWERLINK-Vx.x.x
Copy otherio/exp/powerlink/src/objdict.h to $epl/ObjDicts/CiA401_CN/.
Create one build directory for MN (build) and one for CN (buildcn)
> mkdir $epl/build
> mkdir $epl/buildcn
Go to $epl/build and build for MN, then go to $epl/buildcn and build for CN.
Execute 'pwre configure' and check powerlink includes and archives are found,
and finally build Proview.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -55,4 +55,16 @@ typedef struct {
struct timespec tpe, tps;
} io_sLocalEpl_CN;
typedef struct {
int byte_ordering;
int float_representation;
struct timespec tpe, tps;
int input_area_size;
int output_area_size;
void *input_area;
void *output_area;
void *tmp_area;
short inputResetEnabled;
} io_sLocalEpl_CNServer;
#endif
This diff is collapsed.
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* 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 2 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 Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#include "pwr.h"
#include "pwr_basecomponentclasses.h"
#include "rt_io_base.h"
#include "rt_io_card_init.h"
#include "rt_io_card_close.h"
#include "rt_io_card_read.h"
#include "rt_io_card_write.h"
#include "rt_io_msg.h"
#include "pwr_otherioclasses.h"
/*----------------------------------------------------------------------------*\
Init method for the Powerlink module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Read method for the Powerlink module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Write method for the Powerlink module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Close method for the Powerlink module
\*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose (
io_tCtx ctx,
io_sAgent *ap,
io_sRack *rp,
io_sCard *cp
)
{
return IO__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Epl_CNServerModule) = {
pwr_BindIoMethod(IoCardInit),
pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose),
pwr_NullMethod
};
......@@ -147,15 +147,6 @@ tEplKernel PUBLIC AppCbEvent(
io_sAgent* pUserArg_p);
tEplKernel PUBLIC AppCbSync(void);
pwr_tStatus io_bus_card_init_pl( io_tCtx ctx,
io_sCard *cp,
unsigned int *input_area_offset,
unsigned int *input_area_chansize,
unsigned int *output_area_offset,
unsigned int *output_area_chansize,
pwr_tByteOrderingEnum byte_order
);
/*----------------------------------------------------------------------------*\
Init method for the Powerlink module
......@@ -281,15 +272,16 @@ static pwr_tStatus IoAgentInit (io_tCtx ctx, io_sAgent *ap) {
struct sched_param schedParam;
// adjust process priority
if (nice (-20) == -1) // push nice level in case we have no RTPreempt
{
errh_Error("%s() couldn't set nice value! (%s)", __func__, strerror(errno));
}
schedParam.__sched_priority = MAIN_THREAD_PRIORITY;
if (pthread_setschedparam(pthread_self(), SCHED_RR, &schedParam) != 0)
{
errh_Error("%s() couldn't set thread scheduling parameters! %d", __func__, schedParam.__sched_priority);
}
// push nice level in case we have no RTPreempt
if (nice (-20) == -1) {
errh_Error("%s() couldn't set nice value! (%s)", __func__, strerror(errno));
}
//schedParam.sched_priority = MIN(sched_get_priority_max(SCHED_FIFO),
// sched_get_priority_min(SCHED_FIFO) + op->Priority);
schedParam.__sched_priority = op->Priority;
if (pthread_setschedparam(pthread_self(), SCHED_RR, &schedParam) != 0) {
errh_Error("%s() couldn't set thread scheduling parameters! %d", __func__, schedParam.__sched_priority);
}
// binds all openPOWERLINK threads to the second CPU core
cpu_set_t affinity;
......
......@@ -30,4 +30,6 @@ Nodave_PLC
Nodave_Transaction
Epl_MN
Epl_Module
Epl_CNServer
Epl_CNServerModule
#endif
\ No newline at end of file
......@@ -61,7 +61,7 @@ static pwr_tStatus Configure (
ldh_sMenuCall *ip
)
{
pwr_tCmd cmd = "openCONFIGURATOR";
pwr_tCmd cmd = "export HOME=$pwrp_login;openCONFIGURATOR";
system( cmd);
......
This diff is collapsed.
......@@ -269,6 +269,7 @@ pwr_tStatus io_bus_card_init( io_tCtx ctx,
if (chan_di->Number == 0) {
*input_area_offset += *input_area_chansize;
*input_area_chansize = GetChanSize( chan_di->Representation);
chanp->size = *input_area_chansize;
}
if ( !chanp->sop)
continue;
......@@ -278,6 +279,7 @@ pwr_tStatus io_bus_card_init( io_tCtx ctx,
chanp->offset = *input_area_offset;
chanp->mask = 1 << chan_di->Number;
chanp->size = *input_area_chansize;
if ( byte_order == pwr_eByteOrderingEnum_BigEndian) {
if ( chan_di->Representation == pwr_eDataRepEnum_Bit16)
chanp->mask = swap16( (unsigned short)chanp->mask);
......@@ -415,6 +417,7 @@ pwr_tStatus io_bus_card_init( io_tCtx ctx,
if (chan_do->Number == 0) {
*output_area_offset += *output_area_chansize;
*output_area_chansize = GetChanSize( chan_do->Representation);
chanp->size = *output_area_chansize;
}
if ( !chanp->sop)
continue;
......@@ -424,6 +427,7 @@ pwr_tStatus io_bus_card_init( io_tCtx ctx,
chanp->offset = *output_area_offset;
chanp->mask = 1 << chan_do->Number;
chanp->size = *output_area_chansize;
if ( byte_order == pwr_eByteOrderingEnum_BigEndian) {
if ( chan_do->Representation == pwr_eDataRepEnum_Bit16)
chanp->mask = swap16( (unsigned short)chanp->mask);
......@@ -473,6 +477,7 @@ pwr_tStatus io_bus_card_init( io_tCtx ctx,
if (chan_d->Number == 0) {
*input_area_offset += *input_area_chansize;
*input_area_chansize = GetChanSize( chan_d->Representation);
chanp->size = *input_area_chansize;
}
if ( !chanp->sop)
continue;
......@@ -482,6 +487,7 @@ pwr_tStatus io_bus_card_init( io_tCtx ctx,
chanp->offset = *input_area_offset;
chanp->mask = 1 << chan_d->Number;
chanp->size = *input_area_chansize;
if ( byte_order == pwr_eByteOrderingEnum_BigEndian) {
if ( chan_d->Representation == pwr_eDataRepEnum_Bit16)
chanp->mask = swap16( (unsigned short)chanp->mask);
......@@ -494,6 +500,7 @@ pwr_tStatus io_bus_card_init( io_tCtx ctx,
if (chan_d->Number == 0) {
*output_area_offset += *output_area_chansize;
*output_area_chansize = GetChanSize( chan_d->Representation);
chanp->size = *output_area_chansize;
}
if ( !chanp->sop)
continue;
......@@ -503,6 +510,7 @@ pwr_tStatus io_bus_card_init( io_tCtx ctx,
chanp->offset = *output_area_offset;
chanp->mask = 1 << chan_d->Number;
chanp->size = *output_area_chansize;
if ( byte_order == pwr_eByteOrderingEnum_BigEndian) {
if ( chan_d->Representation == pwr_eDataRepEnum_Bit16)
chanp->mask = swap16( (unsigned short)chanp->mask);
......
......@@ -142,8 +142,14 @@ pwre_config_check_lib()
fi
if test $libfound -eq 0; then
lib_array[$lib_cnt]=$libdir
lib_cnt=$((lib_cnt+1))
if test $4 == "powerlink"; then
lib_path=$libdir
elif test $4 == "powerlinkcn"; then
lib_path=$libdir
else
lib_array[$lib_cnt]=$libdir
lib_cnt=$((lib_cnt+1))
fi
fi
lib=${file##/*/lib}
......@@ -162,7 +168,9 @@ pwre_config_check_lib()
elif test $4 == "libusb"; then
conf_lib=$conf_lib" -lusb-1.0"
elif test $4 == "powerlink"; then
conf_libpowerlink=$conf_libpowerlink" -l${lib%.*}"
conf_libpowerlink=$conf_libpowerlink" -L$lib_path -l${lib%.*}"
elif test $4 == "powerlinkcn"; then
conf_libpowerlinkcn=$conf_libpowerlinkcn" -L$lib_path -l${lib%.*}"
else
conf_lib=$conf_lib" -l${lib%%.*}"
fi
......@@ -433,7 +441,8 @@ else
pwre_config_check_lib libpnioif PNAK lib pnak 1 "/usr/lib/libpnioif.a:/usr/local/lib/libpnioif.a"
pwre_config_check_lib libusb LIBUSB lib libusb 1 "/usr/lib/libusb-1.0.so:/usr/lib/$hwpl-linux-$gnu/libusb-1.0.so"
pwre_config_check_lib powerlink POWERLINK lib powerlink 1 "$epl/build/Examples/X86/Generic/powerlink_user_lib/libpowerlink.a"
pwre_config_check_lib powerlinkcn POWERLINKCN lib powerlinkcn 1 "$epl/buildcn/Examples/X86/Generic/powerlink_user_lib/libpowerlink.a"
pwre_config_check_include mq MQ 0 "/usr/local/dmq/include/p_entry.h"
pwre_config_check_include wmq WMQ 1 "/opt/mqm/inc/cmqc.h"
pwre_config_check_include cifx CIFX 1 "/usr/local/include/cifx/cifxlinux.h"
......@@ -465,6 +474,7 @@ else
echo "export pwre_conf_libpwrotherio=\"-lpwr_usbio_dummy -lpwr_usb_dummy -lpwr_cifx_dummy -lpwr_nodave_dummy -lpwr_epl_dummy\"" >> $cfile
echo "export pwre_conf_libpwrprofibus=\"-lpwr_pnak_dummy\"" >> $cfile
echo "export pwre_conf_libpwrpowerlink=\"$conf_libpowerlink\"" >> $cfile
echo "export pwre_conf_libpwrpowerlinkcn=\"$conf_libpowerlinkcn\"" >> $cfile
echo "export pwre_conf_libpwrxtt=\"-lpwr_xtt -lpwr_ge -lpwr_cow -lpwr_flow -lpwr_glow\"" >> $cfile
echo "export pwre_conf_libpwrxttgtk=\" -lpwr_xtt_gtk -lpwr_ge_gtk -lpwr_cow_gtk -lpwr_flow_gtk -lpwr_glow_gtk\"" >> $cfile
echo "export pwre_conf_libpwrxttmotif=\" -lpwr_xtt_motif -lpwr_ge_motif -lpwr_cow_motif -lpwr_flow_motif -lpwr_glow_motif\"" >> $cfile
......
......@@ -332,8 +332,8 @@ palette NavigatorPalette
class EPl_Module
menu Server
{
class Epl_Server
class Epl_ServerModule
class Epl_CNServer
class Epl_CNServerModule
}
}
menu Profibus
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment