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.

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

  • In the constructor of the class from where you are calling OpenFIle(), did you provide the HaestadParentFormModel class to its base? if not or if an improper class is given then you will get NullRefereceException.

    You won't find OpenFile() method anywhere as it's in the HaesteadParentFormModel class.

    So, please make sure you are mimicking the WaterQuality Starter sample and the parentForm.

    Thanks

    Akshaya



  • Akshaya,

    I'm mimicking the class WaterQualityWorkstationStarter but in this class are called other classes as ApplicationModel, ParentModel and ParentUIModel (inside these classes other classes are called and so on). I don't know if I have to create all these adittional classes because the WQWorkstationParentForm class needs a WQWorkstationParentFormUIModel element for the construction method.

    Thanks in advance, have a good day.

  • Akshaya,

    I decided to take a deep look into WaterQualityWorkstation sample in order to understand its operation and applying it to my problem. I imported all the references but I haven't been able to execute this sample, I still have 8 errors I don't know how to solve. I'm describing you some of the errors:

    1. In the class GraphViewerControlModel, the function NewGraphOptionsFieldsPickerTreeEditorModel() has just one codeline for the creation of a GraphOptionsFieldsPickerTreeEditorModel but that element ask me for more arguments that the ones wrote (it asks me for a MessageHandler, a NumericPresentationManager and a GraphDefaultsManager). This last one doesn't exist in the code.

    2. In the class EditorFormModelFactory, the function NewBatchRunEditorFormModel() doesn't have any instruction.

    3. In the class EditorModelFactory, the declaration of the class throws a mistake related to the need of declare the class as "MustInherit" but I don't why is this happening.

    4. In the class ApplicationModel the line "Implements IMappingApplicationModel" throws me several errors.

    I don't know if this has something related with the VisualStudio version I'm handling (2010) or maybe I'm doing something wrong. When I looked for the references I couldn't find the references for some things, but I don't know if this may be affecting the executing of the sample. I hope you can give me some guidance, I believe that If I can execute the sample I'll be able to work better with my model.

    Have a good day,

    Jessica

  • Jessica,

    Are you a member of the Bentley Developer Network? (BDN) If so, we have a separate, private community (see link below) for BDN, which may be more appropriate for questions on Waterobjects.NET

    communities.bentley.com/.../267.aspx


    Regards,

    Jesse Dringoli
    Technical Support Manager, OpenFlows
    Bentley Communities Site Administrator
    Bentley Systems, Inc.

  • Jesse,

    I just tryed to follow the link but it tells me "You do not have permissions to perform the requested action." so I think I'm not part of the BDN. Maybe the account of the university (that is linked to our license) has access but I don't. Is there any chance I can enter from this personal account?

    Best Regards,

    Jessica

Reply Children
  • Hi Jessica,

    You'd need to be a BDN member in order to join that community. However on further investigation, in the case of Waterobjects.NET, it should be fine to continue posting your questions in the Hydraulics and Hydrology forum (apologies for the confusion).

    One of our developers believes that, based on your descriptions above, the licensing dll file is missing. He suggests that it would be easier if you compile your code and copy the output into the install folder for HAMMER.  Then everything you need will already be available, instead of trying to copy from the other direction.


    Regards,

    Jesse Dringoli
    Technical Support Manager, OpenFlows
    Bentley Communities Site Administrator
    Bentley Systems, Inc.

  • Hi Jesse,

    As Akshaya told me a few days ago, I have been mimicking the WaterQualityWorkstation Sample (ParentForm and Starter classes) for opening a WTG file and run Transient Engine.

    Right now I created the following classes: ApplicationModel, ParentFormModel, ParentFormUIModel and ParentForm but just with its begining (until the constructor method).

    The situation is that the creation of ApplicationModel and ParentUIModel classes throws me an error "the class must be declared as 'MustInherit' class" which doesn't allow me to create new elements after. I can't create that classes as MustInherit because it doesn't allow me to create new elements of the class in the Starter.

    I tryed to run the sample in order to understand how this works step by step but I wasn't able to accomplish this either (in part because the classes mentioned above have the same 'MustInherit' error).

    I'm referencing the Licensing.dll files, I don't what else to do.

    Thanks in advance,

    Jessica.

  • Hi Jesse,

    During this day I was able to use the WaterQualityWorkstation Sample for establish some classes (I create ApplicationDescription, ApplicationModel, DataBaseFile, ParentForm, ParenFormModel and ParentUIModel) for opening a wtg file.

    When I executed my code everything goes well until the method OpenFile() in ParentForm because after I chose the wtg file it throws me the exception "FileNotFoundException" "It can not be found the specified module. Exception from HRESULT: 0x8007007E". I don't know what can be happening because after acepting the DialogBox where I choose the file, it appears a window from HAMMER saying "Opening File" but then crashes at appear the exception mentioned.

    This is the code of the ParentForm class I'm implementing:

    Namespace Forms
    Public Class ParentForm
    Inherits HaestadParentForm

    #Region "Constructor"
    Public Sub New(ByVal parentFormUIModel As Application.ParentFormUIModel)
    MyBase.New(parentFormUIModel.HaestadParentFormModel)
    End Sub
    #End Region

    #Region "Public Methods"
    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
    #End Region

    #Region "Event Handlers"
    Public Overloads Sub OpenFile()
    Dim open As OpenFileDialog = NewOpenFileDialog()
    If open.ShowDialog(Me) = DialogResult.OK Then
    OpenFile(open.FileName)
    End If
    End Sub
    #End Region
    End Class
    End Namespace

    I hope you can give some guidance with this. Thanks in advance.

    Jessica.

  • Hi Jessica,

    Try my suggestion from your other thread:

    communities.bentley.com/.../300182.aspx


    Regards,

    Jesse Dringoli
    Technical Support Manager, OpenFlows
    Bentley Communities Site Administrator
    Bentley Systems, Inc.