Create a custom mobile action
- Last UpdatedApr 15, 2025
- 2 minute read
- Create a new Visual C# Class Library Project which targets the .NET Framework 4.8 with Visual Studio 2017/2019.
NOTE: The assembly created must include the file extension in its name for the AVEVA Mobile Operator Plug-In system to load it. The assembly created must also have the string "action" in the name (e.g. "CustomAction.dll"). - Add references to SAT.Core.dll and AA.Core.Mobile.dll, located in the AVEVA Mobile Operator Client installation directory (by default, "\Program Files\AVEVA\Mobile Operator\Client") in the new project.
- Open AssemblyInfo.cs, located in the "Properties" section of the solution file, and add the following lines:
[assembly: SAT.ComponentModel.Extensibility.AssemblyPlatform(SAT.ComponentModel.Extensibility.PlatformContext.Any)][assembly: SAT.ComponentModel.Services.CallingContext(SAT.ComponentModel.Services.CallingContextEnum.Default)]
- Rename the solution, class library, and assembly to "MyCustomMobileAction" (as per the "namespace" section of step 5).
-
Create a new class that inherits from AA.Core.Mobile.ComponentModel.SDK.Procedure.MobileSdkActionPlugin.
(NOTE: The GUID shown below in the line "[PluginInfo(typeof(MobileSdkActionPlugin), `GUID`)]" must match the ID created for the Custom Action.
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using SAT.ComponentModel.Extensibility;
using AA.Core.Mobile.ComponentModel.SDK.Procedure;
using System.IO;
using AA.Core.Mobile.Procedure;
using AA.Core.Mobile;
namespace MyCustomMobileAction
{
[PluginInfo(typeof(MobileSdkActionPlugin), "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")]
public class MyCustomMobileAction : MobileSdkActionPlugin
{
private string fileName = "outputFileName.txt";
public string UserName
{
get
{
return base.GetPropertyBagAttributeValue("CustomTagHostName");
}
}
public MyCustomMobileAction(string propertyBag, IProcedureNode parentNode, Guid id)
: base(propertyBag, parentNode, id)
{
}
#region IMobileActionPlugin Members
public override string Execute(IProcedureController procedureController)
{
using (StreamWriter fileStream = new StreamWriter(fileName, true))
{
fileStream.Write("User {0} and node {1} had a value of {2}", UserName,
procedureController.CurrentNode.DisplayName, procedureController.CurrentNode.Value);
}
return string.Format("MyCustomAction and wrote the file to {0}", fileName);
}
public override string StatusMessage(IProcedureController procedureController)
{
return string.Format("MyCustomAction data writer {0}", fileName);
}
public override MobileProcedureRunType ActionRunType
{
get { return MobileProcedurePluginRunType.FileIO; }
}
public override string DisplayName
{
get { return "MyCustomAction"; }
}
#endregion
}
} -
Following are the uses of the methods within the code:
- public override string Execute()
This function is called during execution and returns the result of the action based on the condition. - public override string GetPropertyBagAttributeValue()
This returns the value of the key or the value pair. - public override string DisplayName()
The display name in the Management Center. - public override string StatusMessage()
The status of the executed action. - public override bool ActionRunType()
This function denotes the type of action performed.
- public override string Execute()
- Compile the DLL.
- To use the custom action in Procedure Builder, copy the compiled DLL (from the output directory specified by the build process) to the AVEVA Mobile Operator Client installation directory (by default: "\Program Files\AVEVA\Mobile Operator\Client").