Cancel
Showing results for 
Search instead for 
Did you mean: 

Bug: Plant Sim Crashs when testing a value in a table

Valued Contributor
Valued Contributor

 

Hi,

 

I always face an crash of PlantSim when I run a method. The Error occurs at the end of a repeat until loop when I test a value in a table. I would be grateful for every useful hint. Actually I have no idea why this happens. I am using PlantSim13.

Bugreport.PNGBug message

 

 

6 REPLIES

Re: Bug: Plant Sim Crashs when testing a value in a table

Phenom
Phenom

Acc. to the screen shot you are using 13.1.x not 13.0.x

 

for a better understanding please send a model (fragment)  or at least

 

the method code which is causing the RTE

 

 

Re: Bug: Plant Sim Crashs when testing a value in a table

Valued Contributor
Valued Contributor

Thanks for your fast reply.

 

I reduced the model to the basics. The bug occurs when I run the method "Aufträge_optimieren".

I changed the repeat until loop to a while end loop but the bug still occurs. I set an Error Stop at the bug producing line

Re: Bug: Plant Sim Crashs when testing a value in a table

Phenom
Phenom

i exchanged the method "findeLücken" in your while loop through "findeLücken2" ( code below)

 

while findeLücken2(PlanQuellen,PlanSenken)
  LückenTable:= self.~.findeLücken(PlanQuellen,PlanSenken)

 

even if this workaround solves the RTE another simtalk error pops up due to wrong dimensioned tables

 

have a look.

 

param PlanQuellen, PlanSenken: any
->boolean

var TempTable: table

TempTable.create
TempTable.MaxXDim:= 4
--Quelle oder Senke
TempTable.setzeDatentyp(1,"string")
--Anlage
TempTable.setzeDatentyp(2,"integer")
--Start
TempTable.setzeDatentyp(3,"time")
--Ende
TempTable.setzeDatentyp(4,"time")

for var i := 1 to PlanQuellen.dim
	if PlanQuellen[i].HoleSpaltenYDim(1) = 0
	
	elseif PlanQuellen[i][1,1] /= 0
		if TempTable[2,1] = 0
			TempTable[1,1]:= "Q"
			TempTable[2,1]:= i
			TempTable[3,1]:= 0
			TempTable[4,1]:= PlanQuellen[i][1,1]
		end	
	else
		for var j := 1 to PlanQuellen[i].HoleSpaltenYDim(1)/2
			if  PlanQuellen[i][1,j*2] < PlanQuellen[i][1,j*2+1]
				if TempTable[2,1] = 0 or PlanQuellen[i][1,j*2] < TempTable[3,1]
					TempTable[1,1]:= "Q"
					TempTable[2,1]:= i
					TempTable[3,1]:= PlanQuellen[i][1,j*2]
					TempTable[4,1]:= PlanQuellen[i][1,j*2+1]
				end
			end
		next	
	end
next
for var i := 1 to PlanSenken.dim
	if PlanSenken[i].HoleSpaltenYDim(1) = 0
	
	elseif PlanSenken[i][1,1] /= 0
		if TempTable[2,1] = 0
			TempTable[1,1]:= "S"
			TempTable[2,1]:= i
			TempTable[3,1]:= 0
			TempTable[4,1]:= PlanSenken[i][1,1]
		end	
	else
		for var j := 1 to PlanSenken[i].HoleSpaltenYDim(1)/2
			if  PlanSenken[i][1,j*2] < PlanSenken[i][1,j*2+1]
				if TempTable[2,1] = 0 or PlanSenken[i][1,j*2] < TempTable[3,1]
					TempTable[1,1]:= "S"
					TempTable[2,1]:= i
					TempTable[3,1]:= PlanSenken[i][1,j*2]
					TempTable[4,1]:= PlanSenken[i][1,j*2+1]
				end
			end
		next	
	end
next

var yesNo :boolean

if temptable[2,1]/=0 then
	yesNO:=true
else
	yesNO:=false
end

return YesNo

Re: Bug: Plant Sim Crashs when testing a value in a table

Valued Contributor
Valued Contributor

Thanks for your effort.

 

I understand the way you do it and I guess it would be a good solution if the loop is the problem.

 

While trying to find a solution too I recognized that the failure is actually not produced by the loop (even if the error message mentions the loop testing line).

 

The Problem was the method "Anlagenplan_Auftrag_Einfügen" which returned a table. I noticed that I don't have to give a table back since the changes in the table by the method also effect the table in the main method (thought that just happens by using "byref")

 

After I changed this part everything works fine.

 

I still think PlantSim shouldn't crash in that case but should open the debug window instead.

 

Thanks for your help!

Re: Bug: Plant Sim Crashs when testing a value in a table

Siemens Phenom Siemens Phenom
Siemens Phenom

I can reproduce the crash. It will be fixed in the next maintenance packs.

 

Normally parameters are passed by value to the called Method, i. e. the value is copied. Parameters of data type table/list/stack/queue behave differently. Local variables and formal parameters of data type table/list/stack/queue behave more like the data type object. Not the object itself is passed to the called Method, but a reference to the object. So if you pass a local variable of data type object to a formal parameter of data type object, the parameter points to the same object as the variable. When you assign a new object referece to the parameter, this does not affect the variable in the calling Method – unless the parameter is declared with the keyword byref. In this case the object variable of the calling Method and the object parameter of the called Method are actually the same variable. Assigning a value to one of them will also change the other.

The same is true for parameters of data type table/list/stack/queue. When you pass a local table variable to a formal table parameter, the parameter will point to the same table as the variable does. So if you assign a value to a table cell via the parameter, the commonly referenced table changes. When you assign a different table to the parameter, the reference changes and now points to that table. The variable of the calling Method still references the old table – unless the parameter is declared with the keyword byref.

_________________________________________________________________
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.

Re: Bug: Plant Sim Crashs when testing a value in a table

Valued Contributor
Valued Contributor

Thank you for the good explanation!