HML to OML Migration

Activate 2019 introduced the concept of H2O, the migration of the scripting language HyperMath to OpenMatrix.

OML is the official replacement for HML, the scripting language supported in Altair Activate 2016-2017.3.

Role of OML in Altair Activate Version 2019 and Above

OML is the standard scripting language supported in Activate and Compose. Some common applications for OML in Activate models include:

  • Creating variables
  • Writing contexts
  • Writing block definitions
  • Interacting with models through the OML Command Window
  • Loading libraries

What You Need to Know for the H2O Migration

  • Although HML and OML have some syntactic differences, their overall conception and field of application are similar, and the migration from HML to OML is seamless in most cases.
  • Language and reference guides for OML can be found in the Compose and Activate documentation.

What You Need to Do if You are Working with Models Created with Altair Activate 2016-2017.3

  • In most cases, no action is required. Activate version 2019 and above includes an automatic translator which converts legacy models.
  • In cases where models contain contexts with advanced HML scripts, any functions that are converted into OML require review and testing. The same applies to models that are accompanied by HML scripts for preparing data.

What You Need to Change for the H2O Migration

  • For block parameters defined as strings, change the double quotes in HML to single quotes in OML.
  • Replace the HMLCustomBlock in models with the OMLCustomblock.
  • Note that legacy solidThinking Activate block libraries are automatically converted into Altair Activate block libraries when opened in a current version of Altair Activate.

Migrating an HML Script/Context

  • Migration example for the context in the Activate demo model, Hybrid_Extended_Kalman_Filter.scm:


  • Migration example from a script found in the Optimization chapter of the Extended Definitions for Advanced Users (PDF):


API Changes

  • Activate provides APIs to create, edit and manipulate models. These APIs have been migrated from HML to OML but retain very similar names and arguments.
  • More information about the APIs is available in the Extended Definitions for Advanced Users.

HMLCustomBlock

  • The migration from the HMLCustomBlock to the OMLCustomBlock involves migrating the HML code that defines the block behavior. With the help of a skeleton generator found in the OMLCustomBlock, migrating each part of the block code is very easy.
  • HMLCustomBlock empty skeleton:
    
    function HmlBlockFunction(block,flag)
      u1=vssGetInPortData(block,1);
      nevprt=vssGetEventCode(block);
      if flag ==  hwscpEngineBlock.INITIALIZE then
      elseif flag ==  hwscpEngineBlock.REINITIALIZE then
      elseif flag ==  hwscpEngineBlock.TERMINATE then
      elseif flag ==  hwscpEngineBlock.OUTPUT_UPDATE then
        //vssSetOutPortData(block,1,y1,vssGetOutputDataType(block,1));
      end
    end
    
  • OMLCustomBlock empty skeleton:
    
    function OmlBlockFunction(block,flag)
      u1=vssGetInputData(block,1);
      nevprt=vssGetEventCode(block);
      if flag == vssBlockInitializeFlag
      elseif flag == vssBlockReinitializeFlag
      elseif flag == vssBlockTerminateFlag
      elseif flag == vssBlockOutputUpdateFlag
        %%vssSetOutputData(block,1,y1,vssGetOutputDataType(block,1));
      end
    end
    
  • Migration Example of the Activate demo model Fft_anim.scm:


Migrating Libraries

The following commands can be executed in the OML Command Window:

run('<install>/hwx/modules/sim/engine/scripts/oml/bdeMigrateModelToOml.oml')
migrate_library(libpath)

Commands for Migration

  • Although Activate automatically converts most models, some scripts may require individual conversion.
  • OML commands have been added and exposed to facilitate the migration.
  • Migration of an HML file:
    hwscpEngineUtilsAPIs_TranslateHmlFile('file1.hml', 'file1.oml')
  • Migration of an HML expression:
    hwscpEngineUtilsAPIs_TranslateHmlString('<hmlstring>')