Model checking of conveyor belt system on NuSMV using CTL specifications - model-checking

apply model checking of conveyor belt system on NuSMV using CTL specifications as the two statements shown below
to validate the correctness using photoelectric sensors as input and synchronous motors as output and reliability of the system.
verify the safety and reduce the errors using speed switch sensors as input and the same synchronous motor as output.
MODULE main
VAR
state : {BeltRunning, BeltStopped, Error, SafetyShutdown};
photoelectricSensor : boolean;
speedSwitchSensor : boolean;
ASSIGN
init(state) := BeltStopped;
next(state) :=
case
state = BeltRunning & photoelectricSensor = TRUE : BeltStopped;
state = BeltStopped & photoelectricSensor = FALSE : BeltRunning;
state = BeltRunning & photoelectricSensor = FALSE : Error;
state = BeltStopped & photoelectricSensor = TRUE : Error;
speedSwitchSensor = TRUE : SafetyShutdown;
esac;
To check whether these properties are satisfied, we can use the NuSMV "check_ctlspec" command, followed by the CTL formula that we want to check. For example, to check whether the belt will never run when there is an object on the conveyor belt, we can use the following command:
check_ctlspec -p "AG !(state = BeltRunning & photoelectricSensor = TRUE)"
There's an error on coding shows as line 15: case conditions are not exhaustive

Related

OMPython/OpenModelica parameter is not changeable

I have modeled a building in OpenModelica using Buildings library. I am curretly using OMPython and OMCSessionZMQ to set and optimize OpenModelica parameters in Python.
I just found out that for some parameters isChangeable = False, i.e., mSenFac, and I cannot use mod.setParameters( ) to set those parameters.
mSenFac can be found in Buildings.Fluid.MixingVolumes.MixingVolume, which is later used in Buildings.ThermalZones.ReducedOrder.RC.
Instead, I have been suggested to use
mod.sendExpression("setParameterValue(BuildingModels.oneElement, thermalZoneOneElement.mSenFac, 5), parsed = False)" and rebuild the model using mod.buildModel( ) API.
BuildingModels.oneElement is my model name
thermalZoneOneElement.mSenFac is the parameter I want to set.
However, this method also did not work for me, which I don't know why.
I need to be able to set mSenFac in iterations in an optimization algorithm. I would appreciate it if anyone can answer the following questions:
Is it possible to make isChangeable = True for mSenFac?
Is there any other way to set mSenFac using OMPython?
Best regards,
Farnaz
Running this script:
loadString("
package BuildingModels
model oneElement
Integer mSenFacParameter = 1;
Buildings.ThermalZones.ReducedOrder.RC.OneElement thermalZoneOneElement;
end oneElement;
end BuildingModels;
"); getErrorString();
list(BuildingModels.oneElement); getErrorString();
// using setParameterValue can only set top level parameters
setParameterValue(BuildingModels.oneElement, mSenFacParameter, 6); getErrorString();
list(BuildingModels.oneElement); getErrorString();
// using setComponentModifierValue can set component modifiers
setComponentModifierValue(BuildingModels.oneElement, thermalZoneOneElement.mSenFac, $Code(=6)); getErrorString();
list(BuildingModels.oneElement); getErrorString();
// using setComponentModifierValue can set component modifiers
setComponentModifierValue(BuildingModels.oneElement, thermalZoneOneElement.mSenFac, $Code(=mSenFacParameter)); getErrorString();
list(BuildingModels.oneElement); getErrorString();
gives you:
true
""
"model oneElement
Integer mSenFacParameter = 1;
Buildings.ThermalZones.ReducedOrder.RC.OneElement thermalZoneOneElement;
end oneElement;"
""
Ok
""
"model oneElement
Integer mSenFacParameter = 6;
Buildings.ThermalZones.ReducedOrder.RC.OneElement thermalZoneOneElement;
end oneElement;"
""
Ok
""
"model oneElement
Integer mSenFacParameter = 6;
Buildings.ThermalZones.ReducedOrder.RC.OneElement thermalZoneOneElement(mSenFac = 6);
end oneElement;"
""
Ok
""
"model oneElement
Integer mSenFacParameter = 6;
Buildings.ThermalZones.ReducedOrder.RC.OneElement thermalZoneOneElement(mSenFac = mSenFacParameter);
end oneElement;"
""
Basically set the component modifier, build the code, simulate it, take the results.

How can i add this other condition to this code?

i have this subroutine that i use to make labels. for some reason i cant just make another subroutine where instead of "CGI_SAMPLE_LABEL" it uses "YCI_SAMPLE_LABEL" because of other subroutines. any suggestions on how i can add this so that it chooses either one or the other. if tried using WHERE OR but that didn't work. i edited some of the tags because LIMS basic language is also like smalltalk.
LabelType = "CGI_SAMPLE_LABEL"
pTableNameStr = "SAMPLE"
pLabelNameStr = "CGI_SAMPLE_LABEL"
'Breakpoint(aReason)
NumSamples = Ubound(selectedObjects, 1)
FOR X = 1 TO NumSamples
SampleNumber = selectedObjects[x]
pKeyNameArr[1] = SampleNumber
pNumLabelsInt = 1
pLabelNameStr = "CGI_SAMPLE_LABEL"
pReasonStr = "Auto Label Generation"
pActivityStr = "Label printed for sample logged event"
GOSUB FN_LABEL_PRINT_ALL
NEXT 'Sample
RETURN

How do I make a VBA function output the result of an If, then statement to a cell?

This is my first time ever doing any coding, so I am sorry if it is awful and could be much better. My problem is that I just get a #VALUE error in the cell when I try to use this function and I do not know why.
The program is supposed to take whichever information that the user inputs and decide whether or not this specific connector will work for the designated inputs. Whether the connector works is based on which cables can be used and the type of connector input by the user.
Function CONNECTOR1(Cable As Double, Connector As String, Row As Double) As String
CableI = Worksheets("Sheet1").Range("A4").String
ConnectorI = Worksheets("Sheet1").Range("B4").String
MaxdBLossI = Worksheets("Sheet1").Range("D4").Value
ConnectorTypeI = Worksheets("Sheet1").Range("E4").String
If IsEmpty(CableI) = True And IsEmpty(ConnectorI) = True And Not IsEmpty(MaxdBLossI) And Not IsEmpty(ConnectorTypeI) Then
If ConnectorTypeI = Worksheets("Sheet1").Range("I" & Row).Value And Application.WorksheetFunction.CountIf(Range("N3:N500"), Cable) Then
CONNECTOR1 = Connector
End If
ElseIf IsEmpty(ConnectorTypeI) = True And CableI = Cable Then
CONNECTOR1 = Connector
ElseIf CableI = "" Then
If Application.WorksheetFunction.CountIf(Range("N3:N500"), Cable) Then
CONNECTOR1 = Connector
End If
ElseIf ConnectorTypeI = Worksheets("Sheet1").Range("I" & Row).Value And CableI = Cable Then
CONNECTOR1 = Connector
Else
CONNECTOR1 = Worksheets("Sheet2").Range("O" & Row).ClearContents
End If
End Function
'The goal of this code is for it to decide based on which inputs the user has given, if a certain connector will satisfy the criteria
'Connectors only work for a specific number of cables, so this set of code is only for a connector that works with one cable
'CableI is a cable part number input by the user
'ConnectorI is a connector part number input by the user
'MaxdBLossI is an input amount of acceptable signal loss
'ConnectorTypeI is an input for the specific type of connector needed`

How can I use installscript to detect Excel.exe running?

Ive been trying to detect the excel process in my installshield installer.
I have a custom action that runs after appsearch and pops a window if it finds the process and displays a warning to the user.
I have tried using some old examples I found on installsite.org and using the findWindow() call. Neither seems to find excel.exe in the process list.
Here is a snippet of code I was using when trying the findwindow
export prototype MyTestFunction(HWND);
function MyTestFunction(hMSI)
HWND nHwnd;
begin
nHwnd = FindWindow("EXCEL", "");
if (nHwnd != 0) then
MessageBox("found excel", WARNING);
SendMessage(nHwnd, WM_CLOSE, 0, 0);
else
MessageBox("cant find excel", WARNING);
endif;
end;
Note that only the else block ever seems to fire regardless of the application being open or closed.
I have tried several different variants of this mostly just replacing the "excel" with different capitalization, extensions and versions. Nothing seems to detect the window. I used Spy++ and it reported that the window is named after the name of the currently opened notebook which complicates things since I have no way of knowing what a user could have opened.
I am open to suggestions here. The only requirement for this solution is that it has to be able to run as either a custom action or part of an install condition from within Installshield.
You could use a vbscript Custom Action.
You can run this CA at the begining of UISequence or ExecuteSequence (or both) If you want it as a part of the Install condition.
Add the code in a vbscript function and configure "Return Processing" Option for the Custom Action to "Synchonous (Check exit code)" if you want to stop the installation process.
Here is my script:
Public Function StopProcess
Dim objWMIService, objProcess, colProcess
Dim strComputer, executableFileName
Const IDABORT = 3
strComputer = "."
executableFileName = "excel.exe"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery("Select * from Win32_Process Where Name = '" & executableFileName & "'")
For Each objProcess in colProcess
objProcess.Terminate()
' OR
StopProcess = IDABORT
Exit for
Next
End function
Obviously trying to figure out if a process is running by finding the associated window has its pitfalls.
My suggestion is to detect if the process for Excel.exe is running. It would involve enumerating the processes on the system. Modify your code accordingly. Its easier to do it using C++ but there are numerous examples available which show you how to achieve what i have just stated.
https://community.flexerasoftware.com/archive/index.php?t-162141.html
https://community.flexerasoftware.com/archive/index.php?t-188807.html
Take
We can write a InstallScript code as well to achieve this. Please refer the code below :
function CheckRunningProcessAndTerminate(hMSI)
// To Do: Declare local variables.
OBJECT wmi,objProc;
STRING szProcessName;
begin
// To Do: Write script that will be executed when MyFunction is called.
szProcessName = "Excel.exe";
set wmi = CoGetObject("winmgmts://./root/cimv2", "");
set objProc = wmi.ExecQuery("Select * from Win32_Process where Name = '" + szProcessName + "'");
if (objProc.count > 0) then
MessageBox("Process is running.", INFORMATION);
//kill proces
TerminateProcesses(szProcessName);
//objProc.Terminate(); //I tried this, but it didn't worked.
else
MessageBox("Process is not running.", INFORMATION);
endif;
end;

excel 2010 add-in setup project with setup factory

I am developing an excel add-in. I have serial numbers(ex. 100 psc) and I want to check when excel add-in installing on pc. But I cant do it with VS2010 setup project because it is not supporting serial number list storing and checking.
so I want to do this with setup factory and I did it like this link:
link
but I have a problem excel ;
if I select "Yes", excel working for opening .dll, if select "No", it do anything.
and my setup factory list like this.
and my setup factory "on post install script", my Addinfilename value is "Posta Guvercini Excel AddIn For 2010.dll"
-- Determine registry key (2 = HK CURRENT USER)
sVersions = Registry.GetKeyNames(2, "Software\\Microsoft\\Office");
-- Iterate through the registry keys per MS Office-version
--Next line has SetupFactory 8 code
--for iCount1, sVersion in sVersions do
for iCount1, sVersion in pairs(sVersions) do
-- Try opening the registry key
sSubKey = "Software\\Microsoft\\Office\\"..sVersion..
"\\Excel\\Options\\"
sValues = Registry.GetValueNames(2, sSubKey);
--initialize index counter
iIndex = -2
if sValues then
--Determine the index of the maximimum OPEN registry entry
--Next line has SetupFactory 8 code
--for iCount2, sValue in sValues do
for iCount2, sValue in pairs(sValues) do
if (String.Left(sValue, 4) == "OPEN") then
--Check whether the user did not already install
--the same add-in to prevent errors when opening Excel
sKeysValue = Registry.GetValue(2, sSubKey, sValue, true)
if String.Find(sKeysValue, SessionVar.Expand(
"%AddinFileName%"), 1, false) > 0 then
iIndex = -1
-- leave loop
break;
else
if (sValue == "OPEN") then
iIndex = 0
else
iIndex = String.ToNumber(String.Mid(
sValue, 5, String.Length(sValue)-4))
end;
end;
end;
end;
-- -1 means: This add-in is already installed; we're done
if iIndex ~= -1 then
--Determine path based on variable "%AddinFileName%
sAppPath = String.Char(34)..
SessionVar.Expand("%AppFolder%")..
"\\"..
SessionVar.Expand("%AddinFileName%")..
String.Char(34)
-- -2 is the initialized value of the index counter
if (iIndex == -2) then
-- OPEN-key does not exist
Registry.SetValue(2, sSubKey, "OPEN",
sAppPath, REG_SZ)
else
Registry.SetValue(2, sSubKey, "OPEN"..(iIndex + 1),
sAppPath, REG_SZ)
end;
end;
end;
end;
Looks like you are building an Automation addin. If so you need to prefix the addin name with /A to tell Excel that its an automation addin. otherwise its expecting an XLL or an XLA or an XLAM
i solve this problem. When doing excel installiation, we must use registry record.
result = Registry.SetValue( HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Office\\Excel\\Addins\\company" , "LoadBehavior" , "3" , REG_DWORD );
result = Registry.SetValue(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Office\\Excel\\Addins\\company" ,"FriendlyName", "program name", REG_SZ);
result = Registry.SetValue( HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Office\\Excel\\Addins\\company" , "Description" , "program name" , REG_SZ );
result = Registry.SetValue(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Office\\Excel\\Addins\\company" ,"Manifest", SessionVar.Expand("%AppFolder%\\myvtofile.vsto|vstolocal"), REG_SZ);
for add-in start when excel startup.
LoadBehavior key's value should be "3".

Resources