43351members
217784posts

Default Shared with other embedded mimics to False?

Highlighted
Lieutenant JG

Default Shared with other embedded mimics to False?

I am pretty sure the answer is no, but is there any way to make the default for "Shared with other embedded mimics" to be False?

 

I know why it is true by default, but for this project, it should be fine without it.

 

At the moment I am showing/hiding lines based on some parameters that are read as the mimic loads.

I need it false because with "Shared with other embedded mimics" set to true:

Mimic_load on the embedded mimic does not work.

If a button executes the code all the embedded mimics change, instead of just the one.

 

Unchecking the "Shared with other embedded mimics" box is an extra step I don't want the users to have to do. It will make their task even more complex when creating a new location.

10 REPLIES 10
Highlighted
Commander

Re: Default Shared with other embedded mimics to False?

You could try having your embedded mimic embedded in another mimic that the end-user will 'instantiate' and in which your current embedded mimic has the 'Shared with other embedded mimics' tick box unticked within the new embedded mimic you would create to hold the original.

Gee that felt inception like to describe.

 

I'm not sure if the Mimic_load method is called on every embedded mimic however, I've only ever really used it on Top Level Mimics.

 

So the flow would be:

 

User Mimic -> Your new mimic (tick box setting shouldn't matter) -> Your existing mimic (set to 'Shared with embedded mimics' FALSE)

This is generally all that is required when doing embedded mimics, is to break the chain somewhere before you end up using a hover animation or similar (i.e. something that needs its own unique 'instance data').


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
Highlighted
Lieutenant JG

Re: Default Shared with other embedded mimics to False?

Bevan,

 

Well unfortunately, in this case anyway, that did not work.

I gave me the exact same behavior.

I still had to uncheck it on the embedded version of the New Mimic to make it work.

Highlighted
Commander

Re: Default Shared with other embedded mimics to False?

Mimic_Load is designed to be used with top-level Mimics only, and should not be used in scripts on embedded Mimics. This is because it is difficult to predict when the script will run:
•With embedded Mimics that are configured to be shared, Mimic_Load runs whenever the embedded Mimic is loaded into the Mimic cache. When a host Mimic (a Mimic that contains an embedded Mimic) is displayed, ClearSCADA checks whether the embedded Mimic is stored in the Mimic cache: •If the embedded Mimic is not in the Mimic cache, ClearSCADA will load the embedded Mimic in to the cache and run its script. By loading the embedded Mimic into the Mimic cache, ClearSCADA reduces the overall load of the Mimic, which means the Mimic requires less system resources.
•If the embedded Mimic is already in the Mimic cache, the cached version will be referenced and its script will not run (as it is already in the Mimic cache). The Mimic places less demand on system resources (as a local reference to the cached embedded Mimic is used). As a result, the script does not run.

•With embedded Mimics that are not shared, Mimic_Load runs whenever a non-shared instance of that embedded Mimic is initialized. For example, if a Mimic named ‘Control Room’ contains three embedded versions of a ‘Valve’ Mimic, the script on the ‘Valve’ Mimic will run three times - when each of the embedded versions are initialized.



ClearSCADA help says you shouldn't use it on embedded Mimics 😛

But, it sounds like that final item should apply in the situation that I'm suggesting.  Each embedded mimic that a user places on the page should have a non-shared instance of your original embedded mimic within it.

I suspect that since you're playing with fringe cases here in the script execution you may be running into slightly less well defined behaviour, and hence 'bugs' (or undesired features).

Do you have a support ticket open for this?

 

You could try setting the Mimic Cache size to be 0KB.  I suspect that this won't work however..


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
Highlighted
Lieutenant JG

Re: Default Shared with other embedded mimics to False?

I swear I read in the help that you could use Mimic_Load but not Mimic_Navigate.

 

I think I found a completely different solution. I think I can just manipulate the animations to do what I want.

Highlighted
Lieutenant

Re: Default Shared with other embedded mimics to False?

You can't, but you might be able to set it programatically using the unsupported ViewX interface. There is some code hanging around that is 10 years old but might still work. I'll message it to you. Anyone else wanting it please raise a case with support, but don't expect it to work!

Highlighted
Sisko

Re: Default Shared with other embedded mimics to False?

To be clear about the automation interface for ViewX, it is extensively used for many purposes, both live and for engineering/configuration, and we can answer queries on its use. But the API is neither complete for all ViewX operations nor is it invariant between releases (although it pretty much has been).

 

Here is an example of vbs or mimic script to analyse embedded mimic sharing (and also indirect animations).

 

'Sample vbs or mimic script program to examine mimics for embedded shared mimics and indirect animations
'Sample code only
Sub GoFindEmbeddedShared

	LogClear
	SystemName = "Local"

	Dim xvw
   	Set xvw = CreateObject("Serck.ViewXApplication")
	' If used in a vbs script , then log in:
	'xvw.logon systemName, "User", "Password"

	MimicName = "Default"

	ProcessMimic MimicName, SystemName, xvw
		
	LogClose
End Sub

Sub ProcessMimic( mimicName, systemName, xvw)
	Dim mim
	Log "Analyse," & mimicName
    Set mim = xvw.Mimics.OpenFromServer( False, systemName, mimicName )

	if mim.ScriptEnabled then
		Log "Script is enabled," & mimicName & "," & len(mim.Script) & ",bytes"
		if (InStr( UCASE(mim.Script), "MIMIC_NAVIGATE") > 0) or (InStr( UCASE(mim.Script), "MIMIC_LOAD") > 0) then
			Log "Mimic Load or Navigate Found," & mimicName
		end if
	end if

	For each Layer in mim.Layers
		mim.ActiveLayer=Layer

	    For Each Item In Layer
			' Find shared flags
	        If Item.Type = 3 Then
	        	If Item.Shared = True Then
					'You can set unshared using:
					'Item.Shared = False
					Log "Shared," & mimicName & "," & Item.Name & "," & Item.Definition
	        	End If
	        	'Embedded mimic - call inner
	        	cMimicPos = InStr( Item.Definition, "CMimic") 'Get CS Name from SCX:////CMimic/<name>
	        	mName = mid( Item.Definition, cMimicPos + 7)
	        	if left(mName,1) <> "." then
	        		newMimicName = mName
	        	else
	        		'need to convert relative to absolute, using path of mimicName
	        		'get # of dots to left of mName e.g. ..A.B -> ,,A,B
	        		mNameArr = split( mName, ".")
	        		dotCount = 0
	        		i = 0
	        		for i = 0 to ubound(mNameArr)
	        			if (mNameArr(i) <> "") then
	        				exit for
	        			end if
	        		next
	        		'e.g. if .A then i=1, if ..A.B then i = 2
	        		'now split parent mimic path, e.g. a.b.c -> a,b,c
	        		mParentPath = split( mimicName, ".") 
	        		newMimicName = ""
	        		for i = 0 to ubound( mParentPath) - i 'Path folder names but not mimic name (-1), remove 1 more for each .
	        			newMimicName = newMimicName + mParentPath( i) + "."
	        		next
	        		'now append non-blank names from relative path
	        		newMimicName = newMimicName
	        		for i = 0 to ubound(mNameArr)
	        			if (mNameArr(i) <> "") then
	        				newMimicName = newMimicName + mNameArr(i) + "."
	        			end if
	        		next
	        		'remove extra .
	        		newMimicName = left(newMimicName, len(newMimicName)-1 )
	        	end if
				' Call recursively
	        	ProcessMimic newMimicName, systemName, xvw
			End If
			' Find animations
		    For Each Ani In Item.Animations
		    	aniProperty = Ani.Property
		    	aniExpression = Ani.Expression
		    	If InStr(aniExpression,"[")>0 and InStr(aniExpression,"]")>0 then
		    		Log "Indirect," & mimicName & "," & Item.Name & "," & aniProperty & "," & aniExpression
					'If any animations are indirect, then all mimics up the chain should not be shared
		    	End If
			Next
		Next
	Next
	Mim.Close
End Sub

' Logging to file
Dim objFSO
Dim objFile

Sub Log( text)
	objFile.Write text & vbCrLf
End Sub

Sub LogClear( )
	Set objFSO=CreateObject("Scripting.FileSystemObject")
	outFile="c:\FindEmbeddedIndirect.txt"
	Set objFile = objFSO.CreateTextFile(outFile,True)
End Sub

Sub LogClear( )
	objFile.Close
End Sub

 

Highlighted
Lieutenant JG

Re: Default Shared with other embedded mimics to False?

Thanks, everyone for your suggestions.

 

I don't think using the Automation interface is practical for this application. That would still be something that the user adding a new location would have to do.

 

What I ended up with script-wise was a comparison of the first two characters of an instance name with a group of parameters in another instance. to show/hide lines and animate some colors.

getting to that was a process of a few failures on how to get the animation I wanted where there is the option of using a bunch of different instances, in different orders of location.

 

I found a solution that does not use any scripting. So far I have not broken it anyway.

My new solution just uses the animations and compares the first two characters of the Name (which is set through a mimic parameter) and String Parameter by using LEFT()

 

This method does not need the Shared with other embedded mimics set to False.

So while it solves my specific issue it is not a solution to the actual question I asked.

 

 

Highlighted
Ensign

Re: Default Shared with other embedded mimics to False?

i know the documentation on this leaves some to be desired, but are the item.type numbers enumerated anywhere? 

 

ex:

If Item.Type = 3 Then
Highlighted
Lieutenant JG

Re: Default Shared with other embedded mimics to False?

You can enumerate the DrwType class, from some of my code (ignore the Return, I just didn't change them to something meaningful in the snippet):

 

        Select Case obj.Type
            Case DrwType.DrwButton
                Return COST_OTHER
            Case DrwType.DrwEmbeddedAlarmList
                Return COST_ALARMLIST
            Case DrwType.DrwEmbeddedDynagraph
                Return COST_TREND
            Case DrwType.DrwEmbeddedGraph
                Return COST_TREND
            Case DrwType.DrwEmbeddedList
                Return COST_SQLLIST
            Case DrwType.DrwEmbeddedMimic
                Return 0 '' Calculated on load not on scan, i.e. cost is added elsewhere
            Case DrwType.DrwEmbeddedXYPlot
                Return COST_TREND
            Case DrwType.DrwEmbeddedXYZPlot
                Return COST_TREND
            Case DrwType.DrwGroup
                Return COST_OTHER
            Case DrwType.DrwHLink
                Return COST_OTHER
            Case DrwType.DrwImage
                Return COST_BITMAP
            Case DrwType.DrwOLE
                Return COST_OTHER
            Case DrwType.DrwPieChart
                Return COST_PIECHART
            Case DrwType.DrwPipe
                Return COST_PIPE
            Case DrwType.DrwPolyline
                Return COST_PRIMITIVE
            Case DrwType.DrwRemoteImage
                Return COST_REMOTEIMAGE
            Case DrwType.DrwText
                Return COST_PRIMITIVE
            Case Else
                Return COST_OTHER
        End Select

 

Highlighted
Ensign

Re: Default Shared with other embedded mimics to False?

ooooo nice! thanks for this!  it'll certainly come in handy.