This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Running the Hammer Engine from WO.NET

Hello,

I'm trying to execute the transient hydraulic from WO.NET because I'm implementing an optimization model that needs to execute HAMMER several times changing the Operational Curve of a valve. I tried to use the "Run" Subrutine that is included in Haestad.Calculations.Hammer.Domain.HammerNumericalEngine but it throws me an error "The Specified module could not be found (Exception from 0x8007007E)". I honestly don't know why this error is appearing, here is some of my code:

Dim Scenarios As ModelingElementCollection
Scenarios = m_DomainDataSet.ScenarioManager.Elements()

HammerNumEngine = New Haestad.Calculations.Hammer.Domain.HammerNumericalEngine(m_DomainDataSet, "HammerNumericalEngine")

HammerNumEngine.Run(Scenarios)

The element m_DomainDataSet is already created with the correct path to the file.

I hope you can help me, thanks in advance.

  • Jessica,

    Running Hammer Engine from domain level (opening just the database file) is quite difficult because at one point you need to provide NumericPresentationManager. There isn't easy to create a valid NumericPresentationManager unless you open up the project (wtg) file.

    I encourage you to look at WaterObjects.NET.WaterQualityWorkstation sample as it opens up the project file.

    Before running (computing) a model, you need to set the license properly and to understand that please look at WaterObjects.NET.PressureEngineRunner example.

    I am guessing you don't want to run all the scenarios in the model and if that's the case, after initializing the Scenarios, call Add() and add only scenario that you are interested in.

    I wish I have some simple answers for you...



  • Akshaya,

    I'm looking in WaterObjects.NET.WaterQualityWorkstation sample for a way to open a WTG file but I don't find where is created the object "CurrentProject" that is used in the NumericPresentationManager. That sample is a bit long, could you please help me find in which part of this sample is the way to open the wtg file?

    Thanks in advance, have a good day.

  • Jessica,

    In the WQWorkstationParentForm class you will see following event handler which will give you CurrentProject

    Private Sub ProjectEventChannel_ProjectOpened(ByVal sender As Object, ByVal apea As ProjectEventArgs)

    CurrentProject = apea.Project. <<= this isn't there in the code but apea.Project is the project that you opened.

    If a class is inheriting proper Haestad class such as HaestadFormModel then you can also do this:

    CurrentProject = DomainApplicationModel.ProjectManager.CurrentProject.

    To open wtg file,

    try mimicking WaterObjects.NET.WaterQualityWorkstation.Starter and see how things are done in WQWorkstationParentForm.vb

    In this event handler you will see it calls "OpenFile()" method which actually opens up the projects

    Private Sub ButtonOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOpen.Click

    HTH,



  • Akshaya,

    I'm trying to open the .wtg file in first place using the instructions showed in ButtonOpen_Click but when the code gets to the "OpenFile()" method it throws me an error "NullReferenceException". Right now my code is really simple:

    Private Sub Button_Open(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenFiles.Click

                   Dim open As OpenFileDialog = NewOpenFileDialog()

           If open.ShowDialog(Me) = DialogResult.OK Then

               OpenFile(open.FileName)

           End If

    End Sub

    I looked in the whole program but I can't find where this OpenFile method is established or if there is anything I have to call first in order to open the file. I tryed with several files but the result is the same.

    I'm really sorry for being to persistent, I hope soon I can solve this and stop bother you. Thanks in advance,

  • I also created the Function NewOpenFileDialog()

    Public Overrides Function NewOpenFileDialog() As OpenFileDialog

           Dim open As New OpenFileDialog

           open.CheckFileExists = True

           open.CheckPathExists = True

           open.DefaultExt = "wtg"

           open.ShowReadOnly = False

           Return open

       End Function