Scripting Aurora from Visual Studio

1. Create a new VB or C# .NET Framework project in Visual Studio. 

2. You will need to reference 5 Aurora dlls to script Aurora in Visual Studio. The location and names of these dlls can change depending on what version of Aurora you are using.

If using version 13.4 or earlier, use the dlls located here: 

C:\Program Files (x86)\AURORA\AURORA\AURORAMessaging.dll

C:\Program Files (x86)\AURORA\AURORA\AURORAServer.dll
C:\Program Files (x86)\AURORA\AURORA\EPIS.AURORAxmp.Common.dll

C:\Program Files (x86)\AURORA\AURORA\EPIS.AURORAxmp.Model.dll

C:\Program Files (x86)\AURORA\AURORA\EnergyExemplar.Aurora.ParameterSets.dll

 

If using version 13.5 or 14.0, use the dlls located here (Note that the Aurora Version would be "Aurora 13.5" or "Aurora 14.0" depneding on what is installed on your machine): 
C:\Program Files\Energy Exemplar\[Aurora Version]\AURORAMessaging.dll
C:\Program Files\Energy Exemplar\[Aurora Version]\AURORAServer.dll
C:\Program Files\Energy Exemplar\[Aurora Version]\EPIS.AURORAxmp.Common.dll
C:\Program Files\Energy Exemplar\[Aurora Version]\EPIS.AURORAxmp.Model.dll
C:\Program Files\Energy Exemplar\[Aurora Version]\EnergyExemplar.Aurora.ParameterSets.dll

 

If using version 14.1 or above, use the dlls located here (note that the dll names have changed slightly and that the Aurora Version would be Aurora 14.1 or Aurora 14.2 depending on what is installed on your machine): 
C:\Program Files\Energy Exemplar\[Aurora Version]\EnergyExemplar.Aurora.Messaging.dll
C:\Program Files\Energy Exemplar\[Aurora Version]\EnergyExemplar.Aurora.Server.dll
C:\Program Files\Energy Exemplar\[Aurora Version]\EnergyExemplar.Aurora.Common.dll
C:\Program Files\Energy Exemplar\[Aurora Version]\EnergyExemplar.Aurora.Model.dll
C:\Program Files\Energy Exemplar\[Aurora Version]\EnergyExemplar.Aurora.ParameterSets.dll

 

3. Copy the x64 and x86 folders in “C:\Program Files\Energy Exemplar\Aurora 14.0”

Paste them in the bin\Debug folder of your Visual Studio project, i.e., “C:\Users\conner\source\repos \AuroraScriptProject\AuroraScriptProject\bin\Debug”. Use bin\Release if you are running your project in Release mode.

4. Make sure your Target framework in the project is .NET Framework 4.8. 

5. Declare the ComApplication and ComDataSet object.  

After declaring these objects, call AC.InitializeAURORAXMP(). This function is used when scripting Aurora in a separate application like Visual Studios or Excel.  Use this after declaring the ComApplication and ComDataSet objects, before loading an Aurora project.  

6. Start coding! 

 

C# Example Code

Here is a basic example of how to open an Aurora project and run the simulation.  

using System;
using System.Collections.Generic;
using AURORAServer;

namespace AuroraScriptProject
{
    class Program
    {
        static void Main(string[] args)
        {
            ComApplication AC = new ComApplication()  

ComDataSet ADS = new ComDataSet();

            AC.InitializeAURORAXMP();

            AC.LoadProjectWaitForDBRead("C:\\AURORAxmp\\Alberta_Default_20190201.apz");

            AC.Run();
        }
    }
}

VB Example Code

Here is a basic example of how to open an Aurora project, run a simulation, and report the run completion percentage to the screen, as well as any errors.

Imports System

Imports System.Diagnostics

Imports System.Threading

Imports AURORAServer

Imports AURORAMessaging

Module Module1

    Sub Main()

        Dim x As AURORAObject = New AURORAObject("C:\AURORAxmp\Nodal_10Bus_Example.apz")

    End Sub

End Module

Public Class AURORAObject

    Public AC As ComApplication

    Public ADS As ComDataSet

    Public ASTAT As AURORAStat

    Sub New(Projectfile As String)

        AC = New ComApplication

        ADS = New ComDataSet

        ASTAT = New AURORAStat

        Dim percentComplete As Double = AC.VarSimT.PercentStudyCompleted

        Dim errorMessage As Boolean = False

        Dim isRunning As Boolean = True

        Dim watch As Stopwatch = Stopwatch.StartNew()

        watch.Start()

        AC.InitializeAURORAXMP()

        AC.LoadProjectWaitForDBRead(Projectfile)

        errorMessage = AC.VarAURORAStatus.AuroraError

        If (errorMessage = True) Then

            Exit Sub

        End If

        While (isRunning <> False)

            AC.StepOneHour()

            percentComplete = AC.VarSimT.PercentStudyCompleted

            errorMessage = AC.VarAURORAStatus.AuroraError

            If (errorMessage = True) Then

                Console.WriteLine("Error occurred during AURORAxmp simulation. Exiting...")

                Exit Sub

            End If

            isRunning = AC.VarAURORAStatus.SimulationRunning

            Console.WriteLine("Percent complete: " & percentComplete)

        End While

        Console.WriteLine("Run complete.")

    End Sub

End Class

 

Scripting

Scripting Aurora from Visual Studios