Assembly Registration and Configuration
Once an assembly is compiled, it is ready to be registered and configured with gSharp.
Assembly Registration
An assembly is registered with gSharp as follows.
Place the assembly in the gSharp staging folder. See the Post-installation section. This is the folder that gSharp will scan for assemblies to register.
Open the gSharp Administration application and click the button in the assemblies tab:

The Assembly Registration dialog will open and display the available assemblies, including the new assembly. Select the assembly in the upper section to inspect its module(s) in the lower section:

Click the OK button and wait for the dialog to close. This may take some time while the gSharp server copies the file, inspects it, registers it, starts an assembly host, and initializes it. When the import is complete, the gSharp Administration application will display the newly registered assembly:

Module Point Configuration
The assembly is now ready to be configured with point references and contexts.
To configure each point, click the button in the Data Points box.
The Point Selector dialog opens. Use this dialog to navigate the assets and select a point.
- PI Asset Framework
- Canary Asset Hierarchy

Because a gSharp module's data point is contextless, the element selected is only used to provide access to its attributes. The element itself is ignored by the dialog. In the example above, all the tanks in the list are based on the same template and therefore any of them could be used to select an attribute.

Because a gSharp module's data point is contextless, the asset selected is only used to provide access to its tags. The asset itself is ignored by the dialog. In the example above, all the tanks in the list are based on the same asset type and therefore any of them could be used to select a tag.
Once an attribute/tag is selected from the dialog, it is assigned to the module point. This is known as the point descriptor.

This point descriptor field is a text box and the value can instead be manually typed in.
Context Creation
For a calculation to run, it needs a gSharp context defined to associate the calculation with an AF element. Notice that the Contexts section of the module is empty. This is because no contexts have yet been added to the module. This is done in the Module view of the Administration app.
Expand the GSharpTankDemo in the Assemblies section and click on the TankVolume branch.

Add a new empty context by clicking the button in the top right corner of the Contexts section.

Configure the context with an asset from the data store by clicking the button of the Path field in the context. Use the Context Selector dialog to specify which asset is to be used for this context.
- PI Asset Framework
- Canary Asset Hierarchy


Once an asset is selected from the dialog, the asset's name will be set in the Name field and its fully qualified path will be set in the Path field.
Save the context by clicking the button in the context.
The module will save and refresh. During the save process the module's points are resolved against the context's asset and, when validated, the current value will be displayed in the context's Points list.
- PI Asset Framework
- Canary Asset Hierarchy


Schedule Configuration
Add a schedule by clicking the button above the Schedules section of the context and select an appropriate schedule to add.
- PI Asset Framework
- Canary Asset Hierarchy

Notice that the popup list does not contain the output point Volume because that is designated in the C# class as being an output point. The list also does not contain the Diameter point as the resolved AF attribute for that point does not generate events.

Notice that the popup list does not contain the output point Volume because that is designated in the C# class as being an output point.
Select the Level natural schedule to add it to the Schedules list.
- PI Asset Framework
- Canary Asset Hierarchy


Save the context again. Now that a schedule has been added, the context is ready to start.
Run State
The gSharp server maintains a cascading running status of calculations at the following levels:
- Assembly Level - Enable and disable the running state of all contexts of all modules in an assembly.
- Module Level - Enable and disable the running state of all contexts of a single module.
- Context Level - Enable and disable the running state of a single context.
- Schedule Level - Enable and disable the running state of a single schedule within a context. If a context has multiple schedules and one schedule is disabled, the other enabled schedules will continue to run.
The cascading run status at any level affects the run statuses of child items in the following ways:
- If the run status at any level is set to Disabled, all of the child run statuses will inherit the disabled state and become effectively disabled. This inheritance of the disabled run state does not actually change the child's actual run state but merely forces it to be disabled, regardless of its own prescribed run state.
- If the run status at any level is set to Enabled, all immediate child run statuses will assume their prescribed run state and not inherit the run state of the parent.
This cascading run state allows a disabled parent state to disable its children without actually changing their prescribed states. So if a user decides to temporarily disable a module, the contexts' run states are not changed, only affected, and therefore when the module is re-enabled, the contexts' run states are restored.
Run statuses are indicated in the Administration app in various places as follows:
Enabled
Disabled
Enabled but disabled by its parent run state
Disabled and disabled by its parent run state
The context defined above shows a run state of Disabled (). Its module and assembly run states are both Enabled (
). Its schedule is Enabled but disabled by inheritance of the disabled state of the context (
).
The module is disabled by default so a context can be created but it does not start until the user is ready to start it.
Click the button and the context will start and display the active icon.
- PI Asset Framework
- Canary Asset Hierarchy


Logging
The call to Log.Info() in the TankVolume module logs an entry in the server log every time the calculation executes:
Log.Info($"Calculated the volume of tank '{Context.ContextName}' with a level of {level:0}cm to be {volume / 1000:0.0}L");
Viewing Logs
Check the log panel of the management application. It may have a variety of log entries and among them will be the log entries from the module (depending on how frequently the schedule runs).
