Commit d823d79f authored by Claes Sjofors's avatar Claes Sjofors

Plc core program added

parent 23fbab40
......@@ -2135,59 +2135,72 @@ ini_ProcTable (
pp->proc.flags.b.system = 1;
#endif
plc_idx = 0;
cp->plc_sigmask = 0;
for ( lsts = gdh_GetClassList(pwr_cClass_PlcProcess, &oid);
ODD(lsts);
lsts = gdh_GetNextObject( oid, &oid)) {
pwr_sClass_PlcProcess *plc;
pwr_tObjName ppname;
pwr_tObjName name;
char p_name[80];
int i;
char busidstr[10];
int found;
char idstr[80];
if ( !cp->plcfile_cnt) {
plc_idx = 0;
pp = ini_ProcInsert(sts, cp, "pwr_plc", "pwr_plc_%d", 0, 1, "rt_plc_core", cPrio_plc_init, 0, pwr_cClass_PlcProcess, "", 0);
pp->flags.b.plc = 1;
cp->plc = pp;
pp->proc.flags.b.user = 1;
pp->proc.flags.b.k_mode = 1;
pp->proc.k_size = 30;
cp->plc_sigmask |= ini_mEvent_plc1 << plc_idx;
plc_idx++;
}
else {
plc_idx = 0;
cp->plc_sigmask = 0;
for ( lsts = gdh_GetClassList(pwr_cClass_PlcProcess, &oid);
ODD(lsts);
lsts = gdh_GetNextObject( oid, &oid)) {
pwr_sClass_PlcProcess *plc;
pwr_tObjName ppname;
pwr_tObjName name;
char p_name[80];
int i;
char busidstr[10];
int found;
char idstr[80];
*sts = gdh_ObjidToName(oid, ppname, sizeof(ppname), cdh_mName_object);
if (EVEN(*sts)) break;
*sts = gdh_ObjidToName(oid, ppname, sizeof(ppname), cdh_mName_object);
if (EVEN(*sts)) break;
*sts = gdh_ObjidToPointer(oid, (void *)&plc);
if (EVEN(*sts)) break;
*sts = gdh_ObjidToPointer(oid, (void *)&plc);
if (EVEN(*sts)) break;
sprintf( busidstr, "_%04d_", cp->busid);
sprintf( busidstr, "_%04d_", cp->busid);
found = 0;
for ( i = 0; i < cp->plcfile_cnt; i++) {
s = strstr( cp->plcfile[i].name, busidstr);
if ( s) {
strncpy( name, s + 6, sizeof(name));
if ( (s = strchr( name, '.')))
*s = 0;
found = 0;
for ( i = 0; i < cp->plcfile_cnt; i++) {
s = strstr( cp->plcfile[i].name, busidstr);
if ( s) {
strncpy( name, s + 6, sizeof(name));
if ( (s = strchr( name, '.')))
*s = 0;
if ( cdh_NoCaseStrcmp( ppname, name) == 0) {
found = 1;
break;
}
if ( cdh_NoCaseStrcmp( ppname, name) == 0) {
found = 1;
break;
}
}
}
if ( !found) {
plc_idx++;
continue;
}
}
if ( !found) {
// cp->PlcProcess = plc;
snprintf( idstr, sizeof(idstr), "pwr_plc_%s", name);
snprintf(p_name, sizeof(p_name), "pwr_plc_%s_%%d_%d", name, plc->ChgCount++ % 10);
pp = ini_ProcInsert(sts, cp, idstr, p_name, 1, 1, cp->plcfile[i].name, cPrio_plc_init, plc->StartWithDebug, 0, "", plc);
pp->flags.b.plc = 1;
cp->plc = pp;
pp->proc.flags.b.user = 1;
pp->proc.flags.b.k_mode = 1;
pp->proc.k_size = 30;
cp->plc_sigmask |= ini_mEvent_plc1 << plc_idx;
plc_idx++;
continue;
}
// cp->PlcProcess = plc;
snprintf( idstr, sizeof(idstr), "pwr_plc_%s", name);
snprintf(p_name, sizeof(p_name), "pwr_plc_%s_%%d_%d", name, plc->ChgCount++ % 10);
pp = ini_ProcInsert(sts, cp, idstr, p_name, 1, 1, cp->plcfile[i].name, cPrio_plc_init, plc->StartWithDebug, 0, "", plc);
pp->flags.b.plc = 1;
cp->plc = pp;
pp->proc.flags.b.user = 1;
pp->proc.flags.b.k_mode = 1;
pp->proc.k_size = 30;
cp->plc_sigmask |= ini_mEvent_plc1 << plc_idx;
plc_idx++;
}
for (
......
include $(pwre_dir_symbols)
-include $(pwre_sroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_sroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_sroot)/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) $(linkflags) $(domap) -o $(export_exe) \
$(pwr_obj)/rt_plc_process.o \
$(export_obj) $(objects) $(rt_msg_objs) \
$(pwr_obj)/rt_io_user.o\
$(pwre_conf_libdir) $(pwre_conf_libpwrrt) $(pwre_conf_lib)
endif
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2014 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.
*/
/* rt_plc_template.c --
A template plc program used when no PlcPgm is configured. */
#include "rt_plc.h"
#include "rt_plc_proc.h"
void plc_templ_init( int DirectLink, plc_sThread *tp) {}
void plc_templ_exec( int DirectLink, plc_sThread *tp) {}
struct plc_proctbl plc_templ = {{0,0}, plc_templ_init, plc_templ_exec};
struct plc_proctbl *plc_proctbllist[] = {
&plc_templ,
(void *)0
};
......@@ -294,34 +294,46 @@ init_process ( char *name)
exit(sts);
}
if ( strstr( name, "rt_plc_core") != 0)
pp->is_core = 1;
/* Get PlcProcess object */
busid = qcom_MyBus( &sts);
if ( EVEN(sts)) return 0;
if ( !pp->is_core) {
busid = qcom_MyBus( &sts);
if ( EVEN(sts)) return 0;
sprintf( busidstr, "_%04d_", busid);
s = strstr( name, busidstr);
if ( s) {
strncpy( pp_name, s + 6, sizeof(pp_name));
if ( (s = strchr( pp_name, '.')))
*s = 0;
}
else {
strcpy( pp_name, "");
}
sprintf( busidstr, "_%04d_", busid);
s = strstr( name, busidstr);
if ( s) {
strncpy( pp_name, s + 6, sizeof(pp_name));
if ( (s = strchr( pp_name, '.')))
*s = 0;
idx = 0;
for ( sts = gdh_GetClassList(pwr_cClass_PlcProcess, &pp_oid);
ODD(sts);
sts = gdh_GetNextObject(pp_oid, &pp_oid)) {
sts = gdh_ObjidToName(pp_oid, oname, sizeof(oname), cdh_mName_object);
if (EVEN(sts)) return 0;
if ( cdh_NoCaseStrcmp( pp_name, oname) == 0) {
found = 1;
break;
}
idx++;
}
}
else {
strcpy( pp_name, "");
}
idx = 0;
for ( sts = gdh_GetClassList(pwr_cClass_PlcProcess, &pp_oid);
ODD(sts);
sts = gdh_GetNextObject(pp_oid, &pp_oid)) {
sts = gdh_ObjidToName(pp_oid, oname, sizeof(oname), cdh_mName_object);
if (EVEN(sts)) return 0;
if ( cdh_NoCaseStrcmp( pp_name, oname) == 0) {
sts = gdh_GetClassList(pwr_cClass_PlcProcess, &pp_oid);
if ( ODD(sts)) {
found = 1;
break;
idx = 0;
}
idx++;
}
if (!found) {
errh_Error("PlcProcess object not found, %s", pp_name);
......@@ -705,7 +717,16 @@ create_thread (
pwr_tStatus sts;
long int phase;
tp->aref.Objid = ptp->thread;
if ( !pp->is_core)
tp->aref.Objid = ptp->thread;
else {
sts = gdh_GetClassList(pwr_cClass_PlcThread, &tp->aref.Objid);
if (EVEN(sts)) {
errh_Error("Can't find PlcThread object, %m", sts);
return;
}
ptp->thread = tp->aref.Objid;
}
tp->init = ptp->init;
tp->exec = ptp->exec;
tp->first_scan = 1;
......
......@@ -200,6 +200,7 @@ struct plc_sProcess {
unsigned int sigmask;
thread_sMutex io_copy_mutex;
plc_sArea base;
int is_core;
};
#if defined OS_LYNX || defined OS_LINUX
......
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