Server

Introduction

The server can either run stand-alone or as part of the ApisHive application through the ApisJavaBee-module. The ModFrame server will perform the actual computations and communicate with I/O systems for instance through the ApisHive framework. It runs independently of whether one or more clients are connected. It can be configured to load an application file and start performing computations when the it starts both as a stand-alone server and when it runs as a part of the ApisHive framework.

Stand-alone server

When the server runs as stand-alone, it can be started by selecting the following entry All Programs->Apis->ModFrame->ModFrame server.

Server settings

The server settings will be read from the serverstart.ini file in the ModFrame installation directory. This is a text file where one line can contain one setting. The default value column indicates the value of the setting if it is not present in the file.

Server settingDescriptionDefault value
ServernameThe name of the ModFrame server.ModFrameServer
StartFileThe application file to load when the ModFrame server starts.
MaxClientsThe maximum number of clients. If the value is negative the number of clients is unlimited.Unlimited
maxConfigModeThe maximum number of clients that can be in configuration mode simultaneously.1
StartOnLoadThe application will start running computations automatically when the ModFrame server is started.False
WindowVisibleIf false the server window will not visible.True
ApplicationPathThe path to where the application files are stored.The home directory of the user.
LibraryPathThe path to where library files are stored.The home directory of the user.
StateFilesPathThe path to where the state files are stored.The home directory of the user.
XMLEncodingThe encoding used on the (xml) application files.UTF-8
LoginManagementIf true, enables authentication when clients try to connect to the server.False
SampleTimeThe initial time interval [ms] between computations.1000
RedirectStandardOutIf true, there will be a window in the server window displaying the standard out messages.True
RedirectStandardErrIf true, there will be a window in the server window displaying the standard err messages.True
InitialRMIPortThe port on which the RMI registry accepts requests. If the port is taken, the next port is attempted.1099
RemoteObjectPortThe port number on which the remote object receives calls (if zero, an anonymous port is chosen).0
ShutdownActionThe action which will be performed when the application is shut down. (None, Save)None
TransactionLockTimeoutThe time [ms] an external transaction can take before being timed out. (E.g. when a Tracker transaction is performed from a web page.)25000

Batch file

It is possible to create a batch file which starts the server with custom settings. Below is an example of the contents of a batch file. This must be altered to fit the installation. Using batch files it is possible to set all java options as well as the ini-file containing the elements described above.

Batch file
Copy Code
C:\\\Program Files\Java\jdk1.6.0_03\bin\javaw.exe -Xmx768m -XX:+UseConcMarkSweepGC -verbose:gc -Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel -Djava.security.policy=java.policy -classpath C:\\\Apis\ModFrame\ModFrame.jar;C:\\\Apis\ModFrame\xml.jar;C:\\\Apis\ModFrame\jtds-1.2.2.jar;C:\\\Apis\ModFrame\ClickAndTrace.jar; com.modframe.server.MFServer "C:\\\Apis\ModFrame\serverstart.ini"

Part of the ApisHive Framework

The ModFrame application can run inside the ApisHive process through the ApisJavaBee-module. In this case the settings described for the stand-alone server will be exposed as properties in the ApisJavaBee-module, and the class-path and java options are set in registry.

ApisJavaBee

This module will load a java-application. Items can be created and connected to ports in ModFrame.

Properties

PropertyDescriptionDefault value
ExchangeRateThe exchange rate in milliseconds when retrieving values from external items0 (Turned off)
RunStates whether the ModFrame is performing computations.False
JavaAppVisibleSpecifies if the ModFrame server window is visible or not. (If ApisHive is run as a windows server, the window is always invisible.)True.
JavaAppStartfileThe application file which will be opened when ApisHive is started.
ApplicationFilePathThe path to where the application files are stored.The ApisHive config folder
LibraryFilePathThe path to where the library files are stored.The ApisHive config folder
TimeStepThe computational time interval [ms] between the computations.1000
TimerThe time interval [ms] of the timer trigging the computations. This interval is the real-time interval between computations, whereas TimeStep is the simulated time interval. If the system is to be run  real-time these two properties should be equal.1000
MaxItemBufferStrategySpecifies the size of the item buffer. The item buffer will be used when a computation cycle has not finished within its time slot. A snapshot of the current item values will be put in the item buffer. When the computation cycle has finished it will read the item values from the buffer and performing computations with those values. This is useful when a sudden CPU load of the computer running ApisHive makes the computations take longer than anticipated. If the CPU load persists the item buffer will be filled to its maximum size, and warnings will be issued. If this situation is recurring either the timer interval should be increased or the CPU usage must be decreased.
Having a large maximum size will increase memory usage of ApisHive!
20
EventReportLevelThe level of the reported events from the java application. (E.g. if Warning is chosen, Warning and Alarm events will be reported, but the Information events will not.)

Expert properties

PropertyDescriptionDefault value
TimeReferenceItemAn item whose value will be used as a time reference for this module instead of the system time. This means that the sample time in ModFrame will vary depending on the value of this item.
StartupJavaClassThe java class which contains the startup method (StartupMethod). The default value points to the correct ModFrame class, and should not be changed when using ModFrame.com/modframe/server/MFServer
StartupJavaMethodThe static java method in the StartupJavaClass run when the module is started. The default value points to the correct ModFrame method, and should not be changed when using ModFrame.main
NativeJavaClassThe java class which contains the defintion of the native C-functions. The default value points to the correct ModFrame class, and should not be changed when using ModFrame.com/modframe/server/ApisConnector
SaveActionThe action to be performed when the application shutsdown (None, Save)None
ItemWriteMaskingSet the quality level of items that will be written to the Java application from this moduleWrite all qualities
PersistedValToInitValChoose strategy for copying and persisting current value to the InitValue.Never
PersistedStateDestinationThe destination of the state files. If the destination is not specified the states will not be persisted. The destination can either be to a file or to items. If the destination is a file the StateFileFolder property must be set to a valid folder where the files will be stored. If the destination is Items the StateLoggers property must be set to valid logger(s) to log the state of the application in Apis Honeystore.None
StateLoggersThe loggers which will log the state if PersistedStatesDestination is Items.
AutoDeletePersistenceItemsIf PersistedStateDestination is Items (or Both files and items) items will be created behind the scenes in which the states will be stored. An item of this type will be removed if the last persistence action did not include the state which corresponds to this certain item and this property is set to true. The reason why one might to turn off this option is to reduce the time spent on persisting the states.
StateFileFolderThe folder in which the state files are stored.

Items 

There are different types of items in the ApisJavaBee. Scalar, Vector and Matrix items can be connected to ports in ModFrame.

Scalar

The Scalar item type represents a scalar value of boolean, string or double precision floating point value. The value type is controlled with the ItemType attribute. It can only be chosen when creating an item and not be altered later on. The InputValue attribute specifies if the value is an input value to ModFrame or not.

ItemTypePort equivalent
BoolDigital port
DoubleAnalog port
StringString port

Vector

The Vector item type represents a vector/array value of boolean, string or double precision floating point value. The value type is controlled with the ItemType attribute. It can only be chosen when creating an item and not be altered later on. The InputValue attribute specifies if the value is an input value to ModFrame or not.

ItemTypePort equivalent
BoolN/A
DoubleAnalog vector port
StringString vector port

Matrix

The Matrix item type represents a matrix value of boolean, string or double precision floating point value. The value type is controlled with the ItemType attribute. It can only be chosen when creating an item and not be altered later on. The InputValue attribute specifies if the value is an input value to ModFrame or not.

ItemTypePort equivalent
BoolN/A
DoubleAnalog matrix port
StringN/A

StateFileItem

An item for setting the state file name. The folder which it will be stored in or read from is specified in the StateFileFolder property. The PersistedStateDestination property must also be set to File(s).

Attributes

AttributeDescription
FileAccessDecides whether the file specified in the item is in read, write or read/write mode.
TriggerOnChangeIf true the state file will be read/written to when the item changes
IncludeStateFileFolderIf true the state file will be put in the StateFileFolder, otherwise it will be stored in the current directory
ForceStopBeforeReadWill force the application to go to the STOPPED state before starting to load the state file. If this attribute is false, the application must be put in the STOPPED state manually.

StateTriggerItem

An it for trigging state reading or writing.

AttributeDescription
ReadStatesIf true triggers reading of states, if false triggers writing. All files specified in the StateFileItems with the FileAccess set to Read will be read when this value is true and the ReadStates is true. If ReadStates is false all files specified in the StateFileItems with the FileAccess set to Write will be writtent o when this value is true.

 

CommandItem

The command button can start and stop computations in ModFrame.

AttributeDescription
CommandTypeThe type of command performed when the item's value is set to true. (Run/Stop)
ResetWill perform a reset in the ModFrame at the next iteration after the command has been executed if true

StatusItem

The status items show the current status of the server.

AttributeDescription
StatusAsStringDisplays the current status as a string instead of an integer

Advanced

Class path

The class path is stored in the default value of the registry key:

HKEY_CLASSES_ROOT\Prediktor.ApisJava\CLASSPATH

ModFrame may stop working if this value is altered. Do not change the value unless you know what you are doing!

Java options

The java options are stored in the default value of the registry key:

 HKEY_CLASSES_ROOT\Prediktor.ApisJava\JAVAOPTIONS 

Altering this value may cause ModFrame to stop working properly.
The -Xrs property should always be present as the absence of this value will force ModFrame to terminate when a user logs off.