# Sample Projects The ArchestrA Object Toolkit comes with two sample ApplicationObjects: - Monitor object - WatchDog object By default, the projects for these objects are installed in the C:\Program Files\Wonderware\Toolkits\ArchestrA Object\Samples folder. You can examine these objects to learn more about the C# code generated by the ArchestrA Object Toolkit. This appendix gives a short overview of what these objects do and what their structure looks like. > **Note** > On a 64-bit operating system, projects for these objects are installed in C:\Program Files (x86)\Wonderware\Toolkits\ArchestrA Object\Samples. ## The Monitor Object The Monitor object is a very simple ApplicationObject that reads an external input value and calculates its average. It also allows the user to output a new value that is below a configurable limit. It has no custom config time code and no alarm or history settings. ### Object Structure The Monitor object uses the following primitives: - InputOutput primitive to read and write the external value; external name: PVInputOutput The Monitor object has the following custom attributes: | Name | Type | Category | Description | Additional Settings | | --- | --- | --- | --- | --- | | PV | Float | Writeable_US | Process value | Calculated Quality, Frequently Accessed, Run Time Set Handler | | PVHiLimit | Float | Writeable_USC | Limit value for PV output | | | PVInputAvg | Double | CalculatedRetentive | Average value | Calculated Quality | | ResetInputAvg | Boolean | Writeable_US | Resets the average value | Run Time Set Handler | ### Custom Object Editor The custom editor of the Monitor object has only one custom tab with controls to configure the following attributes: - PVHiLimit - PVInputOutput.Reference - PVInputOutput.SeparateFeedbackConfigured - PVInputOutput.ReferenceSecondary ### Run Time Code The Monitor object has the following custom run time code: - **SetScanState event:** - When going OnScan, set the quality of calculated attributes to Initializing. - When going OffScan, set the quality of calculated attributes to Bad. - **Execute event:** - Get the new input value and write it to the PV attribute. - Set the PV attribute’s quality to the quality of the new input value. - Calculate the new average value and write it to the PVInputAvg attribute. - **GetStatusDesc event:** Return messages for custom error codes. - **Set handler for PV attribute:** Check that new value is less than PVHiLimit. - **Set handler for ResetInputAvg:** Reset the average calculation. ## The WatchDog Object The WatchDog object demonstrates basic input/output, alarming, and historization. It also shows how to use virtual primitives. The object: - Monitors whether an input bit has changed. - Calculates the time since the bit last changed. - Raises an alarm if this time exceeds a timeout limit. - Historizes this time. - Provides optional statistics via a virtual primitive: average and maximum time since last change, time of last timeout, total number of timeouts. ### Object Structure The WatchDog object uses the following primitives: - Input primitive to read the external bit that should be monitored; external name: MonitoredBit - Alarm primitive - History primitive - Custom virtual local primitive to calculate statistics; external name: Stats The WatchDog object has the following custom attributes: | Name | Type | Category | Description | Additional Settings | | --- | --- | --- | --- | --- | | TimeSinceChange | ElapsedTime | Calculated | Time since the MonitoredBit value last changed state | Historizable | | Timeout.Limit | ElapsedTime | Writeable_USC_Lockable | Limit value for timeout alarm | Frequently Accessed, Run Time and Config Time Set Handlers | | Timeout | Boolean | Calculated | Set when timeout has occurred | Alarmable | | Stats.Enable | Boolean | PackageOnly_Lockable | Enable/disable Stats virtual primitive | Config Time Set Handler | The Stats virtual primitive has the following custom attributes: | Name | Type | Category | Description | Additional Settings | | --- | --- | --- | --- | --- | | Stats.DelayAverage | ElapsedTime | Calculated | Average time since last change | | | Stats.DelayMax | ElapsedTime | Calculated | Maximum time since last change | | | Stats.TimeoutCnt | Integer | Calculated | Timeout count | Historizable | | Stats.LastTimeout | Time | Calculated | Time of last timeout | | | Stats.Reset | Boolean | Writeable_U | Reset statistics | Run Time Set Handler | ### Custom Object Editor The custom editor of the WatchDog object has two custom tabs with controls to configure the following: - **General tab:** - Input bit (MonitoredBit.InputSource) - Enable statistics (Stats.Enable) - Enable history and alarms for attributes - **Advanced tab:** - History and alarm settings for attributes ### Config Time Code The WatchDog object has the following custom config time code: - **Set handler for Stats.Enable attribute:** Enable/disable the Stats virtual primitive. - **Set handler for Timeout.Alarmed attribute:** Enable/disable the timeout alarm primitive. - **Set handler for Timeout.Limit attribute:** Check that the new value is positive. - **Set handler for TimeSinceChanged.Historized** **attribute:** Enable/disable the history primitive for the TimeSinceChanged attribute. ### Object Run Time Code The WatchDog object has the following custom run time code: - **Startup event:** Initialize the time of last change. - **Execute event:** - Get the new input value. - Calculate the time since the last change and write it to the TimeSinceChanged attribute. - If the time exceeds the timeout limit, raise an alarm by setting the Timeout.Condition attribute to true. - **GetStatusDesc event:** Return messages for custom error codes. - **Set handler for Timeout.Limit attribute:** Check that the new value is positive. ### Stats Primitive Run Time Code The Stats virtual primitive has the following custom run time code: - **Execute event:** Calculate statistics (average/maximum time since last change, timeout count, last timeout time) and write them to the appropriate attributes. - **Set handler for Reset attribute:** Reset all statistics attributes.