Hello,
Module Source = current
Object obj
bool found = false
Module archiveModule = edit("/CNPE - Project/Fuqing/Engineering Specifications/Copy of FQ856000003B30444DS",true,true)
bool search(Object hObject, Module archiveModule, Module Source)
{
//
// This code snippet will follow the outlinks from a given object. (hObject)
//
//Declarations
Object curr_obj = null
Object targetObject = null
bool found = false
int absnoArchive = 0
int absnoCurrent = 0
absnoCurrent = hObject."Absolute number"
// First, find the target object.
curr_obj = object(absnoCurrent, archiveModule)
if (null curr_obj || isDeleted(curr_obj))
{
for targetObject in entire Source do
{
absnoArchive = targetObject."Absolute Number"
if (absnoArchive == absnoCurrent)
{
found = true
break
}
}
}
else
{
found = true
}
return found
}
void InLinks(Object hObject, Module archiveModule, Module Source)
{
// Follow the in-links from the selected object (hObject)
Object hInObj = null
ModName_ inModRef = null
LinkRef lr = null
Link in_Link = null
string linkSourcePath = null
Object curr_obj = null
int absnoCurrent = 0
absnoCurrent = hObject."Absolute number"
curr_obj = object(absnoCurrent, archiveModule)
// find the source (other end) of the in-link
for lr in hObject <- "*" do
{
// get the full path to the link source
// for in-links this is always in the other module
linkSourcePath = fullName(source lr)
// check that the returned path is valid
if (exists(module linkSourcePath) == true)
{
// check to see if the module is already open
if (open(module linkSourcePath) == false)
{
// open it if it is closed
edit(linkSourcePath,true,true)
}
}
}
// now we know for sure those modules are open, we can do the real work
for in_Link in hObject <- "*" do
{
// check the module at the other end of the link
inModRef = source in_Link
if (null inModRef) {continue}
// check the object at the other end of the link
hInObj = source in_Link
if (null hInObj) {continue}
if (isDeleted(hInObj)) {continue}
//and finally do something useful with the source object
//print identifier hInObj "\n"
hInObj->curr_obj
}
}
void OutLinks(Object hObject, Module archiveModule, Module Source)
{
//
// This code snippet will follow the outlinks from a given object. (hObject)
//
//Declarations
Object hTargetObj = null
Module targetModule = null
Link outLink = null
Object curr_obj = null
int absnoCurrent = 0
// now we know for sure those modules are open, we can do the real work
for outLink in hObject -> "*" do
{
absnoCurrent = hObject."Absolute number"
curr_obj = object(absnoCurrent, archiveModule)
// full path to the module at the other end of the out_link
string sTargetPath = fullName(target outLink)
if (null sTargetPath) {continue}
// only relevant if module exists with r access
if (exists(module sTargetPath) == true)
{
// ensure module is open
targetModule = read(sTargetPath, false)
}
//check that the target Module still exists
if (null targetModule ) {continue}
//check that the target object still exists
hTargetObj = target outLink
if (null hTargetObj) {continue}
if (isDeleted(hTargetObj)) {continue}
//now do something useful with the object
//print identifier hTargetObj"\n"
curr_obj->hTargetObj
}
}
for obj in entire Source do
{
if (search(obj, archiveModule, Source))
{
InLinks(obj, archiveModule, Source)
OutLinks(obj, archiveModule, Source)
}
else
{
print "mismatch\n"
}
}
SystemAdmin - Wed Oct 19 14:46:19 EDT 2011 |
Re: DXL Execution Timeout You can disable this (not recommended) or change the default cycles by using the "runLim" pragma at the beginning of the code. To disable use: pragma runLim, 0 To set a specific number of cycles, change the value from zero to how many cycles you want, so if it's 2 million cycles, use: pragma runLim, 2000000 Paul Miller Melbourne, Australia |
Re: DXL Execution Timeout
Yes, my old notes say that default runLim is 1000000; but I don't think it corresponds to lines of code but I really don't know what its counting.
If I read this correctly, you are restoring an ArchiveModule which at some time was an Ancestor of the SourceModule (such as previously archived and restored) and you want to replicate all the in and out links of each Source object in the corresponding Archive object. You should have some comment in there that says that, or what it is that you are trying to do.
Item itm
Module mod
// "item" returns whether it exists.
// "module" below returns only if its open.
itm = item(NameModFull)
if (!null itm)
mod = module(itm) // Module handle if its open
if (null mod or !isEdit(mod))
edit(linkSourcePath,true,true)
|
Re: DXL Execution Timeout llandale - Thu Oct 20 13:18:58 EDT 2011
Yes, my old notes say that default runLim is 1000000; but I don't think it corresponds to lines of code but I really don't know what its counting.
If I read this correctly, you are restoring an ArchiveModule which at some time was an Ancestor of the SourceModule (such as previously archived and restored) and you want to replicate all the in and out links of each Source object in the corresponding Archive object. You should have some comment in there that says that, or what it is that you are trying to do.
Item itm
Module mod
// "item" returns whether it exists.
// "module" below returns only if its open.
itm = item(NameModFull)
if (!null itm)
mod = module(itm) // Module handle if its open
if (null mod or !isEdit(mod))
edit(linkSourcePath,true,true)
For anyone who wants to know: The runLim count refers to iterations of the basic interpreter loop. During interpretation the DXL source is translated into micro operations for the DXL Virtual Machine. Then these microoperations are executed by the DXL VM.
pragma runLim, 47
// we start with 18 cycles
int a = 4 // 6 cycles (SUM: 24)
a = 5 // 6 cycles (SUM: 30)
int b = 8 // 6 cycles (SUM: 36)
b + a // 6 Cycles (SUM: 42)
-a // 4 Cycles (SUM: 46)
{} // 1 Cycle (SUM: 47)
// *** { ***
1.i0( BlockI 0 4 0)
// *** obj = obj__() ***
1.i4( IntAss, 1.i9, 1.i16, 1.i22)
1.i9( PushVarA, obj, 0, 0)^
1.i16(CurrentObj)^
1.i22( Pop)
// *** attrDXLName = aDXLName__() ***
1.i25( IntAss, 1.i30, 1.i37, 1.i43)
1.i30( PushVarA, attrDXLName, 0, 1)^
1.i37(AttrDXLNameGet)^
1.i43( Pop)
// No idea how we come out with 18 here ..., should be 9 or so. Probably progPrint_ is omitting some initialization stuff.
// *** int a = 4 ***
1.i46( IntAss, 1.i51, 1.i58, 1.i65) <- 1
1.i51( PushVarA, a, 0, 2)^ <- 2
1.i58( Push 4)^ <- 2
1.i65( Pop) <- 1
// *** a = 5 ***
1.i68( IntAss, 1.i73, 1.i80, 1.i87) <- 1
1.i73( PushVarA, a, 0, 2)^ <- 2
1.i80( Push 5)^ <- 2
1.i87( Pop) <- 1
// *** b = 8 ***
1.i90( IntAss, 1.i95, 1.i102, 1.i109) <- 1
1.i95( PushVarA, b, 0, 3)^ <- 2
1.i102( Push 8)^ <- 2
1.i109( Pop) <- 1
// *** b + a ***
1.i112( IntPlus, 1.i117, 1.i124, 1.i131) <- 1
1.i117( PushVarC, b, 0, 3)^ <- 2
1.i124( PushVarC, a, 0, 2)^ <- 2
1.i131( Pop) <- 1
// *** -a ***
1.i134( IntUMin, 1.i138, 1.i145) <- 1
1.i138( PushVarC, a, 0, 2)^ <- 2
1.i145( Pop) <- 1
// empty block is missing?
// *** } ***
1.i163( BlockE 0 4 0)^
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: DXL Execution Timeout Mathias Mamsch - Thu Oct 20 17:13:33 EDT 2011
For anyone who wants to know: The runLim count refers to iterations of the basic interpreter loop. During interpretation the DXL source is translated into micro operations for the DXL Virtual Machine. Then these microoperations are executed by the DXL VM.
pragma runLim, 47
// we start with 18 cycles
int a = 4 // 6 cycles (SUM: 24)
a = 5 // 6 cycles (SUM: 30)
int b = 8 // 6 cycles (SUM: 36)
b + a // 6 Cycles (SUM: 42)
-a // 4 Cycles (SUM: 46)
{} // 1 Cycle (SUM: 47)
// *** { ***
1.i0( BlockI 0 4 0)
// *** obj = obj__() ***
1.i4( IntAss, 1.i9, 1.i16, 1.i22)
1.i9( PushVarA, obj, 0, 0)^
1.i16(CurrentObj)^
1.i22( Pop)
// *** attrDXLName = aDXLName__() ***
1.i25( IntAss, 1.i30, 1.i37, 1.i43)
1.i30( PushVarA, attrDXLName, 0, 1)^
1.i37(AttrDXLNameGet)^
1.i43( Pop)
// No idea how we come out with 18 here ..., should be 9 or so. Probably progPrint_ is omitting some initialization stuff.
// *** int a = 4 ***
1.i46( IntAss, 1.i51, 1.i58, 1.i65) <- 1
1.i51( PushVarA, a, 0, 2)^ <- 2
1.i58( Push 4)^ <- 2
1.i65( Pop) <- 1
// *** a = 5 ***
1.i68( IntAss, 1.i73, 1.i80, 1.i87) <- 1
1.i73( PushVarA, a, 0, 2)^ <- 2
1.i80( Push 5)^ <- 2
1.i87( Pop) <- 1
// *** b = 8 ***
1.i90( IntAss, 1.i95, 1.i102, 1.i109) <- 1
1.i95( PushVarA, b, 0, 3)^ <- 2
1.i102( Push 8)^ <- 2
1.i109( Pop) <- 1
// *** b + a ***
1.i112( IntPlus, 1.i117, 1.i124, 1.i131) <- 1
1.i117( PushVarC, b, 0, 3)^ <- 2
1.i124( PushVarC, a, 0, 2)^ <- 2
1.i131( Pop) <- 1
// *** -a ***
1.i134( IntUMin, 1.i138, 1.i145) <- 1
1.i138( PushVarC, a, 0, 2)^ <- 2
1.i145( Pop) <- 1
// empty block is missing?
// *** } ***
1.i163( BlockE 0 4 0)^
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Hello, //noError() //(hInObj)->LinkModule->(aObject) //ErrMess = lastError() //print ErrMess "\n" Error=createLink_(hInObj,LinkModule,aObject)
2) I am trying to create linkset on the fly so that I don't manually need to add them and to prevent the errors I am getting from my first question.
Module lm = edit(LinkModule, false)
Linkset ls = create(lm, linkSourcePath, fullName(archiveModule))
if (find(ActiveObjectsArchive,(int Src."Absolute Number"),Arc)
#include <utils/linkops.dxl>
pragma runLim, 0
Module Source = current
Object Src
Module archiveModule = edit("/Sandbox/Copyof864506-1325-XNC00",true,true,true)
string LinkModule = "/CNPE - Project/Fuqing/ Admin/Satisfies"
if (null Source)
{
infoBox "This DXL must be run from a current Module."
halt
}
void InLinks(Object hObject, Module aMod)
{
// Follow the in-links from the selected object (hObject)
Object hInObj = null
ModName_ inModRef = null
LinkRef lr = null
Link in_Link = null
string linkSourcePath = null
Item itm = null
Module mod = null
Object aObject = null
int Error = 0
int absno = 0
//string ErrMess = ""
absno = hObject."Absolute number"
aObject = object(absno, aMod)
// find the source (other end) of the in-link
for lr in hObject <- "*" do
{
// get the full path to the link source
// for in-links this is always in the other module
linkSourcePath = fullName(source lr)
// check that the returned path is valid
itm = item(linkSourcePath)
if (!null itm)
{ mod = module(itm) } // Module handle if its open
if (null mod or !isEdit(mod))
{ edit(linkSourcePath,false,true,true) }
}
// now we know for sure those modules are open, we can do the real work
for in_Link in hObject <- "*" do
{
// check the module at the other end of the link
inModRef = source in_Link
if (null inModRef) {continue}
// check the object at the other end of the link
hInObj = source in_Link
if (null hInObj) {continue}
if (isDeleted(hInObj)) {continue}
Module lm = edit(LinkModule, false)
Linkset ls = create(lm, linkSourcePath, fullName(archiveModule))
//and finally do something useful with the source object
//print identifier hInObj "\n"
//noError()
//(hInObj)->LinkModule->(aObject)
//ErrMess = lastError()
//print ErrMess "\n"
Error=createLink_(hInObj,LinkModule,aObject)
if (Error!=linkErrorNoError) { reportLinkError_(hInObj,aObject,LinkModule,"",Error) }
}
}
void OutLinks(Object hObject, Module aMod)
{
//
// This code snippet will follow the outlinks from a given object. (hObject)
//
//Declarations
Object hTargetObj = null
Module targetModule = null
Link outLink = null
int Error = 0
int absno = 0
//string ErrMess = ""
absno = hObject."Absolute number"
aObject = object(absno, aMod)
// now we know for sure those modules are open, we can do the real work
for outLink in hObject -> "*" do
{
// full path to the module at the other end of the out_link
string sTargetPath = fullName(target outLink)
if (null sTargetPath) {continue}
// only relevant if module exists with r access
if (exists(module sTargetPath) == true)
{
// ensure module is open
targetModule = read(sTargetPath, false)
}
//check that the target Module still exists
if (null targetModule ) {continue}
//check that the target object still exists
hTargetObj = target outLink
if (null hTargetObj) {continue}
if (isDeleted(hTargetObj)) {continue}
//now do something useful with the object
//print identifier hTargetObj"\n"
//noError()
//(aObject)->LinkModule->(hTargetObj)
//ErrMess = lastError()
//print ErrMess "\n"
Module lm = edit (LinkModule, false)
Linkset ls = create(lm, fullName(archiveModule), sTargetPath)
Error=createLink_(aObject,LinkModule,hTargetObj)
if (Error!=linkErrorNoError) { reportLinkError_(aObject,hTargetObj,LinkModule,"",Error) }
}
}
Skip ActiveObjectsArchive = create() // KEY 'int' AbsNo; DATA: 'Object' handle
Skip DeletedObjectsArchive = create() // KEY 'int' AbsNo; DATA: 'Object' handle
Object Arc
int absno = 0
for Arc in archiveModule do
{
absno = Arc."Absolute Number"
if (!isDeleted(Arc))
{
put(ActiveObjectsArchive, absno, Arc)
}
else
{
put(DeletedObjectsArchive, absno, Arc)
}
}
for Src in entire Source do
{
absno = Src."Absolute Number"
if (find(ActiveObjectsArchive,absno,Arc))
{
InLinks(Src, archiveModule)
OutLinks(Src, archiveModule)
}
}
|