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 Auroa 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, use the dlls located here:
C:\Program Files\Energy Exemplar\Aurora 13.5\AURORAMessaging.dll
C:\Program Files\Energy Exemplar\Aurora 13.5\AURORAServer.dll
C:\Program Files\Energy Exemplar\Aurora 13.5\EPIS.AURORAxmp.Common.dll
C:\Program Files\Energy Exemplar\Aurora 13.5\EPIS.AURORAxmp.Model.dll
C:\Program Files\Energy Exemplar\Aurora 13.5\EnergyExemplar.Aurora.ParameterSets.dll

If using version 14.0, use the dlls located here: 
C:\Program Files\Energy Exemplar\Aurora 14.0\AURORAMessaging.dll
C:\Program Files\Energy Exemplar\Aurora 14.0\AURORAServer.dll
C:\Program Files\Energy Exemplar\Aurora 14.0\EPIS.AURORAxmp.Common.dll
C:\Program Files\Energy Exemplar\Aurora 14.0\EPIS.AURORAxmp.Model.dll
C:\Program Files\Energy Exemplar\Aurora 14.0\EnergyExemplar.Aurora.ParameterSets.dll

If using Aurora version 14.1 or later, use the dlls located here (note that the dll names have changed slightly) 
C:\Program Files\Energy Exemplar\[Current Version]\EnergyExemplar.Aurora.Messaging.dll
C:\Program Files\Energy Exemplar\[Current Version]\EnergyExemplar.Aurora.Server.dll
C:\Program Files\Energy Exemplar\[Current Version]\EnergyExemplar.Aurora.Common.dll
C:\Program Files\Energy Exemplar\[Current Version]\EnergyExemplar.Aurora.Model.dll
C:\Program Files\Energy Exemplar\[Current Version]\EnergyExemplar.Aurora.ParameterSets.dll

 

3. Copy the x64 and x86 folders in “C:\Program Files\Energy Exemplar\[Current Version]” and 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. Make sure the Platform target for your project is set to build for "Any CPU" and also make sure that "Prefer 32-bit" is unchecked. If the box is checked, it can cause errors when running Mosek and Gurobi.

6. 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.  

7. 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


For further assistance, please contact Aurora Support.

Copyright© 1997-2024 Energy Exemplar LLC. All rights reserved.