Commit cc7c5964 authored by Claes Sjofors's avatar Claes Sjofors Committed by Claes Sjöfors

wb method PostCopy added. Implemented in WindowPlc to reset compilation time, and in PnDevice

parent 12aebcdf
......@@ -267,12 +267,19 @@ static pwr_tStatus SetIoDeviceData(pwr_tAttrRef Object, const char* Attr,
return sts;
}
static pwr_tStatus PostCopy(
ldh_tSesContext Session, pwr_tOid Object, pwr_tOid Source, pwr_tCid Class)
{
return pndevice_postcopy(Session, Object, Source, Class);
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindMethods(PnDevice) = {
pwr_BindMethod(Configure), pwr_BindMethod(ConfigureFilter),
pwr_BindMethod(CopyDevice), pwr_BindMethod(CopyDeviceFilter),
pwr_BindMethod(SyntaxCheck), pwr_BindMethod(GetIoDeviceData),
pwr_BindMethod(SetIoDeviceData), pwr_NullMethod};
pwr_dExport pwr_BindMethods(PnDevice)
= { pwr_BindMethod(Configure), pwr_BindMethod(ConfigureFilter),
pwr_BindMethod(CopyDevice), pwr_BindMethod(CopyDeviceFilter),
pwr_BindMethod(SyntaxCheck), pwr_BindMethod(GetIoDeviceData),
pwr_BindMethod(SetIoDeviceData), pwr_BindMethod(PostCopy),
pwr_NullMethod };
......@@ -264,11 +264,17 @@ static pwr_tStatus SetIoDeviceData(pwr_tAttrRef Object, const char* Attr,
return sts;
}
static pwr_tStatus PostCopy(
ldh_tSesContext Session, pwr_tOid Object, pwr_tOid Source, pwr_tCid Class)
{
return pndevice_postcopy(Session, Object, Source, Class);
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindMethods(PnDevice) = {
pwr_BindMethod(Configure), pwr_BindMethod(ConfigureFilter),
pwr_BindMethod(CopyDevice), pwr_BindMethod(CopyDeviceFilter),
pwr_BindMethod(SyntaxCheck), pwr_BindMethod(GetIoDeviceData),
pwr_BindMethod(SetIoDeviceData), pwr_NullMethod};
pwr_dExport pwr_BindMethods(PnDevice)
= { pwr_BindMethod(Configure), pwr_BindMethod(ConfigureFilter),
pwr_BindMethod(CopyDevice), pwr_BindMethod(CopyDeviceFilter),
pwr_BindMethod(SyntaxCheck), pwr_BindMethod(GetIoDeviceData),
pwr_BindMethod(SetIoDeviceData), pwr_BindMethod(PostCopy), pwr_NullMethod };
......@@ -1095,3 +1095,21 @@ pwr_tStatus pndevice_init(device_sCtx* ctx)
}
return 1;
}
pwr_tStatus pndevice_postcopy(
ldh_tSesContext Session, pwr_tOid Object, pwr_tOid Source, pwr_tCid Class)
{
pwr_tCmd cmd;
char soidstr[40];
if (cdh_ObjidIsNotNull(Source)) {
printf("-- Create $pwrp_load/pwr_pn_%s.xml\n", cdh_ObjidToFnString(0, Object));
strcpy( soidstr, cdh_ObjidToFnString(0, Source));
sprintf(cmd, "cp $pwrp_load/pwr_pn_%s.xml $pwrp_load/pwr_pn_%s.xml",
soidstr, cdh_ObjidToFnString(0, Object));
system(cmd);
}
return PWRB__SUCCESS;
}
......@@ -60,5 +60,8 @@ pwr_tStatus pndevice_init(device_sCtx* ctx);
int pndevice_help_cb(void* sctx, const char* text);
void pndevice_close_cb(void* sctx);
int pndevice_save_cb(void* sctx);
pwr_tStatus pndevice_postcopy( ldh_tSesContext Session, pwr_tOid Object,
pwr_tOid Source, pwr_tCid Class);
#endif
Volume Profibus $ClassVolume 0.0.250.7
Body SysBody 05-SEP-2005 17:51:40.00
Attr NextOix = "_X262"
Attr NextOix = "_X263"
Attr NextCix = "_X22"
Attr NextTix[0] = "_X14"
EndBody
......@@ -3842,6 +3842,11 @@ Volume Profibus $ClassVolume 0.0.250.7
Attr MethodName = "BaseIORack-PostCreate"
EndBody
EndObject
Object PostCopy $DbCallBack 263 03-APR-2019 15:28:20.40
Body SysBody 03-APR-2019 15:28:39.62
Attr MethodName = "PnDevice-PostCopy"
EndBody
EndObject
Object Template PnDevice 2151907328 01-JAN-1970 01:00:00.00
Body RtBody 22-FEB-2017 16:12:07.73
Attr Process = 1
......
......@@ -139,5 +139,10 @@ SObject pwrb:Class
Attr graphname = "Condition"
EndBody
EndObject
Object PostCopy $DbCallBack
Body SysBody
Attr MethodName = "WindowCond-PostCopy"
EndBody
EndObject
EndObject
EndSObject
......@@ -143,5 +143,10 @@ SObject pwrb:Class
Attr graphname = "Activity"
EndBody
EndObject
Object PostCopy $DbCallBack
Body SysBody
Attr MethodName = "WindowOrderact-PostCopy"
EndBody
EndObject
EndObject
EndSObject
......@@ -151,5 +151,10 @@ SObject pwrb:Class
Attr graphname = "WINDOW"
EndBody
EndObject
Object PostCopy $DbCallBack
Body SysBody
Attr MethodName = "WindowPlc-PostCopy"
EndBody
EndObject
EndObject
EndSObject
......@@ -140,5 +140,10 @@ SObject pwrb:Class
Attr graphname = "Substep"
EndBody
EndObject
Object PostCopy $DbCallBack
Body SysBody
Attr MethodName = "WindowSubstep-PostCopy"
EndBody
EndObject
EndObject
EndSObject
/*
* ProviewR Open Source Process Control.
* Copyright (C) 2005-2019 SSAB EMEA AB.
*
* This file is part of ProviewR.
*
* 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 ProviewR. If not, see <http://www.gnu.org/licenses/>
*
* Linking ProviewR statically or dynamically with other modules is
* making a combined work based on ProviewR. 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
* ProviewR give you permission to, from the build function in the
* ProviewR Configurator, combine ProviewR with modules generated by the
* ProviewR 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 ProviewR (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/* wb_c_windowcond.cpp -- work bench methods of the WindowCond class. */
#include "pwr_baseclasses.h"
#include "wb_pwrs.h"
#include "wb_pwrb_msg.h"
static pwr_tStatus PostCopy(
ldh_tSesContext Session, pwr_tOid Object, pwr_tOid Father, pwr_tCid Class)
{
pwr_tStatus sts;
pwr_tTime time = pwr_cNTime;
pwr_tUInt32 version = 0;
// Reset time for modified and compile
sts = ldh_SetObjectPar(
Session, Object, "RtBody", "Version", (char*)&version, sizeof(version));
if (EVEN(sts))
return sts;
sts = ldh_SetObjectPar(
Session, Object, "DevBody", "Modified", (char*)&time, sizeof(time));
if (EVEN(sts))
return sts;
sts = ldh_SetObjectPar(
Session, Object, "DevBody", "Compiled", (char*)&time, sizeof(time));
if (EVEN(sts))
return sts;
return PWRB__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindMethods(WindowCond) = { pwr_BindMethod(PostCopy),
pwr_NullMethod };
/*
* ProviewR Open Source Process Control.
* Copyright (C) 2005-2019 SSAB EMEA AB.
*
* This file is part of ProviewR.
*
* 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 ProviewR. If not, see <http://www.gnu.org/licenses/>
*
* Linking ProviewR statically or dynamically with other modules is
* making a combined work based on ProviewR. 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
* ProviewR give you permission to, from the build function in the
* ProviewR Configurator, combine ProviewR with modules generated by the
* ProviewR 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 ProviewR (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/* wb_c_windoworderact.cpp -- work bench methods of the WindowOrderact class. */
#include "pwr_baseclasses.h"
#include "wb_pwrs.h"
#include "wb_pwrb_msg.h"
static pwr_tStatus PostCopy(
ldh_tSesContext Session, pwr_tOid Object, pwr_tOid Father, pwr_tCid Class)
{
pwr_tStatus sts;
pwr_tTime time = pwr_cNTime;
pwr_tUInt32 version = 0;
// Reset time for modified and compile
sts = ldh_SetObjectPar(
Session, Object, "RtBody", "Version", (char*)&version, sizeof(version));
if (EVEN(sts))
return sts;
sts = ldh_SetObjectPar(
Session, Object, "DevBody", "Modified", (char*)&time, sizeof(time));
if (EVEN(sts))
return sts;
sts = ldh_SetObjectPar(
Session, Object, "DevBody", "Compiled", (char*)&time, sizeof(time));
if (EVEN(sts))
return sts;
return PWRB__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindMethods(WindowOrderact) = { pwr_BindMethod(PostCopy),
pwr_NullMethod };
/*
* ProviewR Open Source Process Control.
* Copyright (C) 2005-2019 SSAB EMEA AB.
*
* This file is part of ProviewR.
*
* 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 ProviewR. If not, see <http://www.gnu.org/licenses/>
*
* Linking ProviewR statically or dynamically with other modules is
* making a combined work based on ProviewR. 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
* ProviewR give you permission to, from the build function in the
* ProviewR Configurator, combine ProviewR with modules generated by the
* ProviewR 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 ProviewR (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/* wb_c_windowplc.cpp -- work bench methods of the WindowPlc class. */
#include "pwr_baseclasses.h"
#include "wb_pwrs.h"
#include "wb_pwrb_msg.h"
static pwr_tStatus PostCopy(
ldh_tSesContext Session, pwr_tOid Object, pwr_tOid Father, pwr_tCid Class)
{
pwr_tStatus sts;
pwr_tTime time = pwr_cNTime;
pwr_tUInt32 version = 0;
// Reset time for modified and compile
sts = ldh_SetObjectPar(
Session, Object, "RtBody", "Version", (char*)&version, sizeof(version));
if (EVEN(sts))
return sts;
sts = ldh_SetObjectPar(
Session, Object, "DevBody", "Modified", (char*)&time, sizeof(time));
if (EVEN(sts))
return sts;
sts = ldh_SetObjectPar(
Session, Object, "DevBody", "Compiled", (char*)&time, sizeof(time));
if (EVEN(sts))
return sts;
return PWRB__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindMethods(WindowPlc) = { pwr_BindMethod(PostCopy),
pwr_NullMethod };
/*
* ProviewR Open Source Process Control.
* Copyright (C) 2005-2019 SSAB EMEA AB.
*
* This file is part of ProviewR.
*
* 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 ProviewR. If not, see <http://www.gnu.org/licenses/>
*
* Linking ProviewR statically or dynamically with other modules is
* making a combined work based on ProviewR. 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
* ProviewR give you permission to, from the build function in the
* ProviewR Configurator, combine ProviewR with modules generated by the
* ProviewR 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 ProviewR (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/* wb_c_windowsubstep.cpp -- work bench methods of the WindowSubstep class. */
#include "pwr_baseclasses.h"
#include "wb_pwrs.h"
#include "wb_pwrb_msg.h"
static pwr_tStatus PostCopy(
ldh_tSesContext Session, pwr_tOid Object, pwr_tOid Father, pwr_tCid Class)
{
pwr_tStatus sts;
pwr_tTime time = pwr_cNTime;
pwr_tUInt32 version = 0;
// Reset time for modified and compile
sts = ldh_SetObjectPar(
Session, Object, "RtBody", "Version", (char*)&version, sizeof(version));
if (EVEN(sts))
return sts;
sts = ldh_SetObjectPar(
Session, Object, "DevBody", "Modified", (char*)&time, sizeof(time));
if (EVEN(sts))
return sts;
sts = ldh_SetObjectPar(
Session, Object, "DevBody", "Compiled", (char*)&time, sizeof(time));
if (EVEN(sts))
return sts;
return PWRB__SUCCESS;
}
/*----------------------------------------------------------------------------*\
Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindMethods(WindowSubstep) = { pwr_BindMethod(PostCopy),
pwr_NullMethod };
......@@ -65,6 +65,7 @@ static pwr_tString32 callBackName[] = {
"AnteUpdate", // ldh_eDbCallBack_AnteUpdate
"PostUpdate", // ldh_eDbCallBack_PostUpdate
"SyntaxCheck", // ldh_eDbCallBack_SyntaxCheck
"PostCopy", // ldh_eDbCallBack_PostCopy
"-" // ldh_eDbCallBack_
};
......
......@@ -79,6 +79,7 @@ pwr_dImport pwr_BindMethods(Application);
pwr_dImport pwr_BindMethods(FriendNodeConfig);
pwr_dImport pwr_BindMethods(SevHistThread);
pwr_dImport pwr_BindMethods(SevHistObject);
pwr_dImport pwr_BindMethods(WindowPlc);
pwr_dExport pwr_BindClasses(Base) = { pwr_BindClass(ASup),
pwr_BindClass(DsFast), pwr_BindClass(SevHist), pwr_BindClass(DsTrend),
......@@ -95,4 +96,5 @@ pwr_dExport pwr_BindClasses(Base) = { pwr_BindClass(ASup),
pwr_BindClass(PlcProcess), pwr_BindClass(PlcThread),
pwr_BindClass(NodeConfig), pwr_BindClass(SevNodeConfig),
pwr_BindClass(Application), pwr_BindClass(FriendNodeConfig),
pwr_BindClass(SevHistThread), pwr_BindClass(SevHistObject), pwr_NullClass };
pwr_BindClass(SevHistThread), pwr_BindClass(SevHistObject),
pwr_BindClass(WindowPlc), pwr_NullClass };
......@@ -204,6 +204,7 @@ typedef enum {
ldh_eDbCallBack_AnteUpdate,
ldh_eDbCallBack_PostUpdate,
ldh_eDbCallBack_SyntaxCheck,
ldh_eDbCallBack_PostCopy,
ldh_eDbCallBack_
} ldh_eDbCallBack;
......
......@@ -106,5 +106,7 @@ typedef pwr_tStatus (*wb_tMethodGetIoDeviceData)(
pwr_tAttrRef, const char*, char*, int);
typedef pwr_tStatus (*wb_tMethodSetIoDeviceData)(
pwr_tAttrRef, const char*, const char*);
typedef pwr_tStatus (*wb_tMethodPostCopy)(
ldh_tSesContext, pwr_tOid, pwr_tOid, pwr_tCid);
#endif
......@@ -207,7 +207,9 @@ wb_object wb_session::copyObject(wb_object o, wb_destination d, wb_name name)
ldh_sEvent* ep = m_srep->eventStart(onew.oid(), ldh_eEvent_ObjectCreated);
m_srep->eventNewFamily(ep, onew);
triggPostCreate(onew);
triggPostCopy(onew, o);
triggPostAdopt(parent, onew);
m_srep->eventSend(ep);
return onew;
......@@ -493,9 +495,23 @@ bool wb_session::copyOset(pwr_sAttrRef* arp, bool keepref, bool keepsym,
if (vmem)
*vmem = mem;
m_vrep->set_object_import_cb(import_cb, (void *)this);
return mem->importTree(keepref, keepsym);
}
void wb_session::import_cb(wb_orep *o, wb_orep *os, void *data)
{
wb_session *ses = (wb_session *)data;
wb_object object = wb_object(o);
wb_object source;
if (os)
source = wb_object(os);
else
source = wb_object();
ses->triggPostCopy(object, source);
}
bool wb_session::cutOset(pwr_sAttrRef* arp, bool keepref)
{
if (isReadonly())
......@@ -610,6 +626,7 @@ bool wb_session::pasteOset(
if (recycleix)
recix = m_srep->recix();
pwr_tOid* olist;
m_vrep->set_object_import_cb(import_cb, (void *)this);
mem->exportPaste(*m_vrep, doid, dest, keepoid, recix, &olist);
m_srep->update();
if (recycleix)
......
......@@ -139,6 +139,7 @@ public:
{
m_srep->recix_set_destination(d);
}
static void import_cb(wb_orep *o, wb_orep *os, void *data);
};
inline bool wb_session::isEmpty()
......
......@@ -38,6 +38,7 @@
#include "wb_bdrep.h"
#include "wb_cdrep.h"
#include "wb_merep.h"
#include "wb_volume.h"
wb_treeimport::~wb_treeimport()
{
......@@ -107,6 +108,18 @@ bool wb_treeimport::importUpdateTree(wb_vrep* vrep)
o->ref();
importUpdateObject(o, vrep);
if (m_object_import_cb) {
oid.oix = it->first;
oid.vid = vrep->vid();
wb_orep* os = vrep->object(&sts, oid);
if (ODD(sts))
os->ref();
else
os = 0;
(m_object_import_cb)(o, os, m_object_import_cb_data);
if (os)
os->unref();
}
o->unref();
}
return true;
......
......@@ -52,6 +52,8 @@ class wb_treeimport {
std::map<pwr_tOix, pwr_tOix> m_translation_table;
std::map<pwr_tCid, pwr_tCid> m_translation_table_cid;
pwr_tVid m_import_source_vid;
void (*m_object_import_cb)(wb_orep *, wb_orep *, void *);
void *m_object_import_cb_data;
typedef std::map<pwr_tOix, pwr_tOix>::iterator iterator_translation_table;
typedef std::map<pwr_tCid, pwr_tCid>::iterator iterator_translation_table_cid;
......@@ -61,6 +63,7 @@ class wb_treeimport {
bool importUpdateObject(wb_orep* o, wb_vrep* vrep);
public:
wb_treeimport() : m_object_import_cb(0) {}
virtual ~wb_treeimport();
virtual bool importTree(bool keepref, bool keepsym) = 0;
virtual bool importTreeObject(wb_merep* merep, pwr_tOid oid, pwr_tCid cid,
......@@ -81,6 +84,10 @@ public:
pwr_tCid importTranslateCid(pwr_tCid cid);
void importSetSourceVid(pwr_tVid vid);
bool importUpdateTree(wb_vrep* vrep);
void set_object_import_cb(void (*object_import_cb)(wb_orep *, wb_orep *, void *), void *data) {
m_object_import_cb = object_import_cb;
m_object_import_cb_data = data;
}
};
#endif
......@@ -903,6 +903,36 @@ pwr_tStatus wb_volume::triggPostRename(wb_object& o)
return sts;
}
pwr_tStatus wb_volume::triggPostCopy(wb_object& o, wb_object& so)
{
pwr_tStatus sts;
char* methodName;
wb_tMethod method;
// Call object method, or inherited method
for (wb_cdef cd = cdef(o.cid()); cd; cd = cd.super()) {
wb_cdrep* cdrep = cd;
cdrep->dbCallBack(&sts, ldh_eDbCallBack_PostCopy, &methodName, 0);
if (ODD(sts)) {
m_vrep->erep()->method(&sts, methodName, &method);
if (EVEN(sts))
return LDH__SUCCESS;
if (so) {
sts = ((wb_tMethodPostCopy)(method))(
(ldh_tSesContext)this, o.oid(), so.oid(), so.cid());
} else
sts = ((wb_tMethodPostCopy)(method))(
(ldh_tSesContext)this, o.oid(), pwr_cNObjid, pwr_cNClassId);
return sts;
}
}
return LDH__SUCCESS;
}
ldh_sRefInfo* wb_volume::refinfo(wb_object o, ldh_sRefInfo* rp)
{
int rows;
......
......@@ -161,6 +161,7 @@ public:
pwr_tStatus triggPostMove(wb_object& o);
pwr_tStatus triggPostUnadopt(wb_object& father, wb_object& o);
pwr_tStatus triggPostRename(wb_object& o);
pwr_tStatus triggPostCopy(wb_object& o, wb_object& so);
ldh_sRefInfo* refinfo(wb_object o, ldh_sRefInfo* rp);
......
......@@ -42,3 +42,7 @@ FriendNodeConfig
SevHistThread
SevHistObject
AppGraph
WindowCond
WindowOrderact
WindowPlc
WindowSubstep
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