viatra / massif

Massif is a Matlab Simulink Integration Framework for Eclipse
https://viatra.github.io/massif/
Eclipse Public License 1.0
19 stars 14 forks source link

Exception Occured when programmaticallly importing new model #201

Closed sopopoola closed 4 years ago

sopopoola commented 4 years ago

I tried to follow your developer guide here - https://github.com/viatra/massif/wiki/Developer-Guide- but it seems oomph has been slightly updated (e.g. I could not find oomph.exe in the installer file). Anyway, I tried to programmatically import a model from my Eclipse following the Java example provided here - https://viatra.github.io/massif/user/api_usage_example.html. I get the following exception. hu.bme.mit.massif.communication.datatype.CellMatlabData cannot be cast to hu.bme.mit.massif.communication.datatype.Handle

I also used the mdl file provided in the example, so I don't know what is wrong. I have Matlab R2019b installed. I am using windows , Eclipse platform version=4.11.0

here is a snippet of my code: public static void main(String[] args) { // TODO Auto-generated method stub ICommandEvaluator commandEvaluator; MatlabCommandFactory factory = null; try { //CLIInitializationUtil.setupEnvironment(); setupHeadlessEnvironment(); //SimulinkMassifHandler simulinkMassifHandler = new SimulinkMassifHandler(matlabPath);

        commandEvaluator = new CommandEvaluatorImpl(new MatlabClient("127.0.0.1", 1098, "MatlabModelProviderr2019b5452"));
        factory = new MatlabCommandFactory(commandEvaluator);

        String modelPath= "C:/Users/student/Desktop/matlab/";
        MatlabCommand addModelPath = factory.addPath();
        addModelPath.addParam(modelPath);
        addModelPath.execute();
        ModelObject model = new ModelObject("sldemo_clutch_import.mdl", commandEvaluator);
        //model.setLoadPath("C:/Users/student/Desktop/matlab/test.slx");
        model.setLoadPath(modelPath);
        model.registerApplicableFilters("famfilter");
        System.out.println(model.getLoadPathAsURI());
        Importer importer = new Importer(model, new CLISimulinkAPILogger());
        //Importer importer = new Importer(model);
        importer.traverseAndCreateEMFModel(ImportMode.FLATTENING);
        importer.saveEMFModel("test.emf");
    } catch (Exception e) {
        // TODO Auto-generated catch block
        if(factory != null)
         closeModels(factory);
        e.printStackTrace();
    } 
istvanrath commented 4 years ago

Can you try with earlier Matlab versions, e.g. 2018a/b?

sopopoola commented 4 years ago

I tried it with 2017b and it gives the same error. It works fine if I go through the GUI in Eclipse (i.e right click on a simulink model and click import), so I don't think if it is the Matlab version. Are some plugins or external dependencies missing?

Thanks

istvanrath commented 4 years ago

@imbur any insights?

abelhegedus commented 4 years ago

Please check https://github.com/viatra/massif/issues/33 and for enabling debug mode here: https://viatra.github.io/massif/user/matlab_connectors.html

Also, are you running as Java application or as an Eclipse application (with OSGi and Eclipse extensions loaded)? Based on your code (main function), you are trying to run a simple Java application, in which case you need some additional steps, see headless usage.

sopopoola commented 4 years ago

Yes, I enabled debug mode and I run it using the headless usage. Here is my setupHeadlessEnvironment() which I called in the main function snippet i posted earlier. The Debug information from Matlab is also provided private static void setupHeadlessEnvironment() { // Set up exporter for headless use CLIInitializationUtil.setupEnvironment();

    ViatraQueryEngineOptions.setSystemDefaultBackends(ReteBackendFactory.INSTANCE, ReteBackendFactory.INSTANCE, LocalSearchEMFBackendFactory.INSTANCE);    
} 

Matlab info Executing command: Type: mtEval, command: massif = massif_functions(), numberOfOutputArguments: 0 Executing command: Type: mtEval, command: ImporterTmpResult = addpath('C:/Users/student/Desktop/matlab/'), numberOfOutputArguments: 0 Executing command: Type: mtEval, command: class(ImporterTmpResult), numberOfOutputArguments: 1 Executing command: Type: mtEval, command: ImporterTmpResult(1:end), numberOfOutputArguments: 1 Executing command: Type: mtEval, command: massif = massif_functions(), numberOfOutputArguments: 0 Executing command: Type: mtEval, command: load_system('sldemo_clutch_import.mdl'), numberOfOutputArguments: 0 Executing command: Type: mtEval, command: ImporterTmpResult = get_param('sldemo_clutch_import.mdl','FileName'), numberOfOutputArguments: 0 Executing command: Type: mtEval, command: class(ImporterTmpResult), numberOfOutputArguments: 1 Executing command: Type: mtEval, command: ImporterTmpResult(1:end), numberOfOutputArguments: 1 Executing command: Type: mtEval, command: ImporterTmpResult = get_param('sldemo_clutch_import.mdl','BlockDiagramType'), numberOfOutputArguments: 0 Executing command: Type: mtEval, command: class(ImporterTmpResult), numberOfOutputArguments: 1 Executing command: Type: mtEval, command: ImporterTmpResult(1:end), numberOfOutputArguments: 1 Executing command: Type: mtEval, command: [r0,r1,r2] = fileparts('C:\Users\student\Desktop\matlab;C:\Users\student\git\hawk;C:\Users\student\Documents\MATLAB;C:\Program Files\MATLAB\R2017b\toolbox\matlab\datafun;C:\Program Files\MATLAB\R2017b\toolbox\matlab\datatypes;C:\Program Files\MATLAB\R2017b\toolbox\matlab\elfun;C:\Program Files\MATLAB\R2017b\toolbox\matlab\elmat;C:\Program Files\MATLAB\R2017b\toolbox\matlab\funfun;C:\Program Files\MATLAB\R2017b\toolbox\matlab\general;C:\Program Files\MATLAB\R2017b\toolbox\matlab\iofun;C:\Program Files\MATLAB\R2017b\toolbox\matlab\lang;C:\Program Files\MATLAB\R2017b\toolbox\matlab\matfun;C:\Program Files\MATLAB\R2017b\toolbox\matlab\mvm;C:\Program Files\MATLAB\R2017b\toolbox\matlab\ops;C:\Program Files\MATLAB\R2017b\toolbox\matlab\polyfun;C:\Program Files\MATLAB\R2017b\toolbox\matlab\randfun;C:\Program Files\MATLAB\R2017b\toolbox\matlab\sparfun;C:\Program Files\MATLAB\R2017b\toolbox\matlab\specfun;C:\Program Files\MATLAB\R2017b\toolbox\matlab\strfun;C:\Program Files\MATLAB\R2017b\toolbox\matlab\timefun;C:\Program Files\MATLAB\R2017b\toolbox\matlab\validators;C:\Program Files\MATLAB\R2017b\toolbox\matlab\demos;C:\Program Files\MATLAB\R2017b\toolbox\matlab\graph2d;C:\Program Files\MATLAB\R2017b\toolbox\matlab\graph3d;C:\Program Files\MATLAB\R2017b\toolbox\matlab\graphics;C:\Program Files\MATLAB\R2017b\toolbox\matlab\graphics\obsolete;C:\Program Files\MATLAB\R2017b\toolbox\matlab\plottools;C:\Program Files\MATLAB\R2017b\toolbox\matlab\scribe;C:\Program Files\MATLAB\R2017b\toolbox\matlab\scribe\obsolete;C:\Program Files\MATLAB\R2017b\toolbox\matlab\specgraph;C:\Program Files\MATLAB\R2017b\toolbox\matlab\uitools;C:\Program Files\MATLAB\R2017b\toolbox\matlab\uitools\obsolete;C:\Program Files\MATLAB\R2017b\toolbox\matlab\hardware\stubs;C:\Program Files\MATLAB\R2017b\toolbox\matlab\images;C:\Program Files\MATLAB\R2017b\toolbox\local;C:\Program Files\MATLAB\R2017b\toolbox\matlab\maps;C:\Program Files\MATLAB\R2017b\toolbox\matlab\graphics\maps;C:\Program Files\MATLAB\R2017b\toolbox\matlab\optimfun;C:\Program Files\MATLAB\R2017b\toolbox\matlab\bigdata;C:\Program Files\MATLAB\R2017b\toolbox\matlab\codeanalysis\analysis;C:\Program Files\MATLAB\R2017b\toolbox\matlab\codetools;C:\Program Files\MATLAB\R2017b\toolbox\matlab\codetools\embeddedoutputs;C:\Program Files\MATLAB\R2017b\toolbox\matlab\datamanager;C:\Program Files\MATLAB\R2017b\toolbox\matlab\datastoreio;C:\Program Files\MATLAB\R2017b\toolbox\matlab\depfun;C:\Program Files\MATLAB\R2017b\toolbox\matlab\graphfun;C:\Program Files\MATLAB\R2017b\toolbox\matlab\guide;C:\Program Files\MATLAB\R2017b\toolbox\matlab\helptools;C:\Program Files\MATLAB\R2017b\toolbox\matlab\icons;C:\Program Files\MATLAB\R2017b\toolbox\matlab\mapreduceio;C:\Program Files\MATLAB\R2017b\toolbox\matlab\testframework\core;C:\Program Files\MATLAB\R2017b\toolbox\matlab\testframework\obsolete;C:\Program Files\MATLAB\R2017b\toolbox\matlab\testframework\ext;C:\Program Files\MATLAB\R2017b\toolbox\matlab\testframework\measurement;C:\Program Files\MATLAB\R2017b\toolbox\matlab\testframework\mock;C:\Program Files\MATLAB\R2017b\toolbox\matlab\testframework\performance;C:\Program Files\MATLAB\R2017b\toolbox\matlab\verctrl;C:\Program Files\MATLAB\R2017b\toolbox\matlab\winfun;C:\Program Files\MATLAB\R2017b\toolbox\matlab\winfun\NET;C:\Program Files\MATLAB\R2017b\toolbox\simulink\components;C:\Program Files\MATLAB\R2017b\toolbox\simulink\dee;C:\Program Files\MATLAB\R2017b\toolbox\rtw\accel;C:\Program Files\MATLAB\R2017b\toolbox\coder\simulinkcoder_core;C:\Program Files\MATLAB\R2017b\toolbox\coder\objectives;C:\Program Files\MATLAB\R2017b\toolbox\simulinktest\core\simharness\simharness;C:\Program Files\MATLAB\R2017b\toolbox\simulinktest\core\testsequence\testsequence;C:\Program Files\MATLAB\R2017b\toolbox\simulink\blocks\library;C:\Program Files\MATLAB\R2017b\toolbox\simulink\blocks\library\simulinkcoder;C:\Program Files\MATLAB\R2017b\toolbox\simulink\blocks\obsolete;C:\Program Files\MATLAB\R2017b\toolbox\simulink\blocks;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\dataclasses;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\MPlayIO;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\dataobjectwizard;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\slresolve;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\units;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\resources;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\model_transformer;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\clone_detection;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\sfuncheck;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\string;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\templates\core;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simdemos\dataclasses;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simdemos;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simdemos\aerospace;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simdemos\automotive;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simdemos\simfeatures;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simdemos\simfeatures\modelreference;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simdemos\simfeatures\datadictionary;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simdemos\automotive\fuelsys;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simdemos\simgeneral;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simdemos\industrial;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simdemos\automotive\powerwindow;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sldependency;C:\Program Files\MATLAB\R2017b\toolbox\simulink\diagram\mi\m;C:\Program Files\MATLAB\R2017b\toolbox\slde\slde;C:\Program Files\MATLAB\R2017b\toolbox\slde\slde\resources;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink_export_methods;C:\Program Files\MATLAB\R2017b\toolbox\simulink\hmi;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\modeladvisor;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\modeladvisor\fixpt;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\modeladvisor\misra;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\modeladvisor\security;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\templates\product;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sdi;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sysarch\sysarch;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\frameedit;C:\Program Files\MATLAB\R2017b\toolbox\simulink\ui\library_browser\core\m;C:\Program Files\MATLAB\R2017b\toolbox\simulink\ui\modeldocbrowser\core;C:\Program Files\MATLAB\R2017b\toolbox\simulink\webblocks\widgets\m;C:\Program Files\MATLAB\R2017b\toolbox\stateflow\stateflow;C:\Program Files\MATLAB\R2017b\toolbox\stateflow\coder;C:\Program Files\MATLAB\R2017b\toolbox\stateflow\sfdemos;C:\Program Files\MATLAB\R2017b\toolbox\matlab\addons;C:\Program Files\MATLAB\R2017b\toolbox\matlab\addons\cef;C:\Program Files\MATLAB\R2017b\toolbox\matlab\addons\fallbackmanager;C:\Program Files\MATLAB\R2017b\toolbox\matlab\addons\supportpackages;C:\Program Files\MATLAB\R2017b\toolbox\matlab\addons_product;C:\Program Files\MATLAB\R2017b\toolbox\matlab\supportpackagemanagement;C:\Program Files\MATLAB\R2017b\toolbox\matlab\addons_toolbox;C:\Program Files\MATLAB\R2017b\toolbox\matlab\addon_enable_disable_management\matlab;C:\Program Files\MATLAB\R2017b\toolbox\matlab\appdesigner\appdesigner;C:\Program Files\MATLAB\R2017b\toolbox\matlab\appdesigner\appdesigner\interface;C:\Program Files\MATLAB\R2017b\toolbox\matlab\appdesigner\appdesigner\runtime;C:\Program Files\MATLAB\R2017b\toolbox\matlab\apps;C:\Program Files\MATLAB\R2017b\toolbox\matlab\audiovideo;C:\Program Files\MATLAB\R2017b\toolbox\rtw\targets\AUTOSAR\AUTOSAR\dataclasses;C:\Program Files\MATLAB\R2017b\toolbox\rtw\targets\AUTOSAR\AUTOSAR;C:\Program Files\MATLAB\R2017b\toolbox\matlab\cefclient;C:\Program Files\MATLAB\R2017b\toolbox\coder\codedescriptor_core;C:\Program Files\MATLAB\R2017b\toolbox\coder\coder;C:\Program Files\MATLAB\R2017b\toolbox\coder\connectivity;C:\Program Files\MATLAB\R2017b\toolbox\rtw\targets\connectivity;C:\Program Files\MATLAB\R2017b\toolbox\coder\emlcodermex;C:\Program Files\MATLAB\R2017b\toolbox\coder\coverage;C:\Program Files\MATLAB\R2017b\toolbox\rtw\rtw;C:\Program Files\MATLAB\R2017b\toolbox\rtw\targets\shared;C:\Program Files\MATLAB\R2017b\toolbox\coder\foundation;C:\Program Files\MATLAB\R2017b\toolbox\coder\foundation\build;C:\Program Files\MATLAB\R2017b\toolbox\coder\foundation\build\tools\registry;C:\Program Files\MATLAB\R2017b\toolbox\coder\foundation\tfl;C:\Program Files\MATLAB\R2017b\toolbox\coder\foundation\tfl\AUTOSAR\AUTOSAR4p0\IFX;C:\Program Files\MATLAB\R2017b\toolbox\coder\foundation\tfl\AUTOSAR\AUTOSAR4p0\IFL;C:\Program Files\MATLAB\R2017b\toolbox\coder\foundation\tfl\gui;C:\Program Files\MATLAB\R2017b\toolbox\coder\foundation\templates;C:\Program Files\MATLAB\R2017b\toolbox\shared\simtargets;C:\Program Files\MATLAB\R2017b\toolbox\coder\profile;C:\Program Files\MATLAB\R2017b\toolbox\coder\rtiostream;C:\Program Files\MATLAB\R2017b\toolbox\coder\trace;C:\Program Files\MATLAB\R2017b\toolbox\coder\xcp;C:\Program Files\MATLAB\R2017b\toolbox\shared\comparisons;C:\Program Files\MATLAB\R2017b\toolbox\simulink\compiled_model_interface;C:\Program Files\MATLAB\R2017b\toolbox\matlab\configtools;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\common;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\configuration;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\connector;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\editor;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\figures;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\file;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\framework;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\http;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\interpreter;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\json;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\logger;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\messageservice;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\mgg;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\microservices;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\nativebridge;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\restmatlab;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\security;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\session;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\shadowfiles;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\usmatlabhost;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\visualization;C:\Program Files\MATLAB\R2017b\toolbox\matlab\connector2\worker;C:\Program Files\MATLAB\R2017b\toolbox\shared\cosimservice\ddg;C:\Program Files\MATLAB\R2017b\toolbox\matlab\reports;C:\Program Files\MATLAB\R2017b\toolbox\matlab\datatools\datatoolsservices\matlab;C:\Program Files\MATLAB\R2017b\toolbox\matlab\datatools\inspector\matlab;C:\Program Files\MATLAB\R2017b\toolbox\matlab\datatools\peermodel_mcos\matlab;C:\Program Files\MATLAB\R2017b\toolbox\matlab\datatools\plotstab\matlab;C:\Program Files\MATLAB\R2017b\toolbox\matlab\datatools\variableeditor\matlab;C:\Program Files\MATLAB\R2017b\toolbox\matlab\datatools\workspacebrowser\matlab;C:\Program Files\MATLAB\R2017b\toolbox\dig\dig;C:\Program Files\MATLAB\R2017b\toolbox\shared\dastudio\dpvu\dpvu;C:\Program Files\MATLAB\R2017b\toolbox\shared\dastudio\dpvu\dpvu\metamodel;C:\Program Files\MATLAB\R2017b\toolbox\shared\dastudio\dpvu\dpvu\actions;C:\Program Files\MATLAB\R2017b\toolbox\shared\spc\src_ml;C:\Program Files\MATLAB\R2017b\toolbox\shared\dsp\simulink\dsp;C:\Program Files\MATLAB\R2017b\toolbox\eml\eml;C:\Program Files\MATLAB\R2017b\toolbox\matlab\external\engines\engine_api;C:\Program Files\MATLAB\R2017b\examples\coder_fixedpoint_simulink;C:\Program Files\MATLAB\R2017b\examples\ecoder;C:\Program Files\MATLAB\R2017b\examples\fuelsys_shared;C:\Program Files\MATLAB\R2017b\examples\graphics;C:\Program Files\MATLAB\R2017b\examples\graphics2;C:\Program Files\MATLAB\R2017b\examples\matlab;C:\Program Files\MATLAB\R2017b\examples\matlab_featured;C:\Program Files\MATLAB\R2017b\examples\simulink;C:\Program Files\MATLAB\R2017b\examples\simulinkcoder;C:\Program Files\MATLAB\R2017b\examples\sldo;C:\Program Files\MATLAB\R2017b\examples\sldo_stats;C:\Program Files\MATLAB\R2017b\examples\stats;C:\Program Files\MATLAB\R2017b\examples\stats_featured;C:\Program Files\MATLAB\R2017b\examples\symbolic;C:\Program Files\MATLAB\R2017b\toolbox\matlab\filebrowser;C:\Program Files\MATLAB\R2017b\toolbox\matlab\findfiles;C:\Program Files\MATLAB\R2017b\toolbox\fixedpoint\fixedpointtool;C:\Program Files\MATLAB\R2017b\toolbox\fixedpoint\fidemos;C:\Program Files\MATLAB\R2017b\toolbox\fixedpoint\fixedpoint;C:\Program Files\MATLAB\R2017b\toolbox\fixpoint;C:\Program Files\MATLAB\R2017b\toolbox\fixpoint\fpca;C:\Program Files\MATLAB\R2017b\toolbox\matlab\uitools\uicomponents\components;C:\Program Files\MATLAB\R2017b\toolbox\hdlcoder\hdlcommon;C:\Program Files\MATLAB\R2017b\toolbox\hdlcoder\hdlcommon\modelcheckeradvisor;C:\Program Files\MATLAB\R2017b\toolbox\hdlcoder\hdllib\ml_lib;C:\Program Files\MATLAB\R2017b\toolbox\hdlcoder\hdllib\sl_lib;C:\Program Files\MATLAB\R2017b\toolbox\hdlcoder\hdlslrt;C:\Program Files\MATLAB\R2017b\toolbox\shared\hadoopserializer;C:\Program Files\MATLAB\R2017b\toolbox\shared\appdes\services;C:\Program Files\MATLAB\R2017b\toolbox\shared\hwmanager\hwconnection;C:\Program Files\MATLAB\R2017b\toolbox\shared\hwmanager\hwmanagerapp;C:\Program Files\MATLAB\R2017b\toolbox\shared\hwmanager\hwmanagerapp\devices;C:\Program Files\MATLAB\R2017b\toolbox\shared\hwmanager\hwmanagerapp\providers;C:\Program Files\MATLAB\R2017b\toolbox\shared\hwmanager\hwmanagerapp\plugins;C:\Program Files\MATLAB\R2017b\toolbox\shared\hwmanager\hwmanagerapp\framework;C:\Program Files\MATLAB\R2017b\toolbox\shared\hwmanager\hwmanagerapp\framework\modules;C:\Program Files\MATLAB\R2017b\toolbox\shared\hwmanager\hwsetup;C:\Program Files\MATLAB\R2017b\toolbox\shared\hwmanager\hwsetup\hwwidgets;C:\Program Files\MATLAB\R2017b\toolbox\shared\hwmanager\hwsetup\hwtemplates;C:\Program Files\MATLAB\R2017b\toolbox\shared\hwmanager\hwsetup\launch;C:\Program Files\MATLAB\R2017b\toolbox\shared\hwmanager\logger;C:\Program Files\MATLAB\R2017b\toolbox\idelink\foundation;C:\Program Files\MATLAB\R2017b\toolbox\idelink\foundation\autointerface;C:\Program Files\MATLAB\R2017b\toolbox\idelink\foundation\autointerface\ideregisterplugins;C:\Program Files\MATLAB\R2017b\toolbox\idelink\foundation\util;C:\Program Files\MATLAB\R2017b\toolbox\idelink\foundation\errorhandler;C:\Program Files\MATLAB\R2017b\toolbox\idelink\foundation\xmakefile;C:\Program Files\MATLAB\R2017b\toolbox\idelink\foundation\hookpoints;C:\Program Files\MATLAB\R2017b\toolbox\matlab\imagesci;C:\Program Files\MATLAB\R2017b\toolbox\shared\instrument;C:\Program Files\MATLAB\R2017b\toolbox\shared\spcuilib\logicanalyzer;C:\Program Files\MATLAB\R2017b\toolbox\shared\m3i;C:\Program Files\MATLAB\R2017b\toolbox\simulink\mask\iconeditor;C:\Program Files\MATLAB\R2017b\toolbox\shared\mldatx;C:\Program Files\MATLAB\R2017b\toolbox\multisim;C:\Program Files\MATLAB\R2017b\toolbox\matlab\networklib;C:\Program Files\MATLAB\R2017b\toolbox\matlab\pathtool;C:\Program Files\MATLAB\R2017b\toolbox\shared\codeinstrum\codeinstrum;C:\Program Files\MATLAB\R2017b\toolbox\shared\cxxfe_mi\cxxfe_mi;C:\Program Files\MATLAB\R2017b\toolbox\shared\polyspace;C:\Program Files\MATLAB\R2017b\toolbox\matlab\external\interfaces\python;C:\Program Files\MATLAB\R2017b\toolbox\realtime;C:\Program Files\MATLAB\R2017b\toolbox\realtime\realtime;C:\Program Files\MATLAB\R2017b\toolbox\realtime\realtime\rtw;C:\Program Files\MATLAB\R2017b\toolbox\rptgenext\slxmlcomp;C:\Program Files\MATLAB\R2017b\toolbox\rptgenext\rptgenextdemos\slxmlcomp;C:\Program Files\MATLAB\R2017b\toolbox\rptgen\xmlcomp;C:\Program Files\MATLAB\R2017b\toolbox\matlab\serial;C:\Program Files\MATLAB\R2017b\toolbox\simulink\blocks\sb2sl;C:\Program Files\MATLAB\R2017b\toolbox\shared\advisor;C:\Program Files\MATLAB\R2017b\toolbox\shared\asynciolib;C:\Program Files\MATLAB\R2017b\toolbox\shared\cgir_fe;C:\Program Files\MATLAB\R2017b\toolbox\shared\cgxe\cgxe;C:\Program Files\MATLAB\R2017b\toolbox\shared\cmlink\api;C:\Program Files\MATLAB\R2017b\toolbox\shared\coder\coder;C:\Program Files\MATLAB\R2017b\toolbox\shared\configset;C:\Program Files\MATLAB\R2017b\toolbox\shared\controllib\general;C:\Program Files\MATLAB\R2017b\toolbox\shared\controllib\graphics;C:\Program Files\MATLAB\R2017b\toolbox\shared\controllib\graphics\utils;C:\Program Files\MATLAB\R2017b\toolbox\shared\controllib\graphics\plotoptions;C:\Program Files\MATLAB\R2017b\toolbox\shared\dastudio;C:\Program Files\MATLAB\R2017b\toolbox\shared\deviceplugindetection;C:\Program Files\MATLAB\R2017b\toolbox\shared\dspblks\dspblks;C:\Program Files\MATLAB\R2017b\toolbox\shared\dspblks\dspmex;C:\Program Files\MATLAB\R2017b\toolbox\shared\dsp\dialog;C:\Program Files\MATLAB\R2017b\toolbox\shared\hdlshared;C:\Program Files\MATLAB\R2017b\toolbox\shared\hdlshared\hdlshared_gui;C:\Program Files\MATLAB\R2017b\toolbox\shared\hdlshared\hdlshared_soc;C:\Program Files\MATLAB\R2017b\toolbox\shared\hotpluglib;C:\Program Files\MATLAB\R2017b\toolbox\shared\hwconnectinstaller;C:\Program Files\MATLAB\R2017b\toolbox\shared\hwconnectinstaller\common;C:\Program Files\MATLAB\R2017b\toolbox\shared\imageio;C:\Program Files\MATLAB\R2017b\toolbox\shared\io;C:\Program Files\MATLAB\R2017b\toolbox\shared\maputils;C:\Program Files\MATLAB\R2017b\toolbox\shared\measure;C:\Program Files\MATLAB\R2017b\toolbox\shared\mlreportgen\dom;C:\Program Files\MATLAB\R2017b\toolbox\shared\mlreportgen\dom\dom;C:\Program Files\MATLAB\R2017b\toolbox\shared\mlreportgen\dom\dom\help;C:\Program Files\MATLAB\R2017b\toolbox\shared\mlreportgen\ppt;C:\Program Files\MATLAB\R2017b\toolbox\shared\mlreportgen\ppt\ppt;C:\Program Files\MATLAB\R2017b\toolbox\shared\mlreportgen\ppt\ppt\help;C:\Program Files\MATLAB\R2017b\toolbox\shared\mlreportgen\rpt;C:\Program Files\MATLAB\R2017b\toolbox\shared\mlreportgen\rpt\rpt;C:\Program Files\MATLAB\R2017b\toolbox\shared\multimedia;C:\Program Files\MATLAB\R2017b\toolbox\shared\networklib;C:\Program Files\MATLAB\R2017b\toolbox\shared\optimlib;C:\Program Files\MATLAB\R2017b\toolbox\shared\reqmgt;C:\Program Files\MATLAB\R2017b\toolbox\shared\reqmgt\mmutils;C:\Program Files\MATLAB\R2017b\toolbox\shared\rptgen;C:\Program Files\MATLAB\R2017b\toolbox\shared\sdi;C:\Program Files\MATLAB\R2017b\toolbox\shared\sigbldr;C:\Program Files\MATLAB\R2017b\toolbox\shared\siglib;C:\Program Files\MATLAB\R2017b\toolbox\shared\simulink\sysarch\sysarch;C:\Program Files\MATLAB\R2017b\toolbox\shared\slcc\slcc;C:\Program Files\MATLAB\R2017b\toolbox\shared\slcc_cov\slcc_cov;C:\Program Files\MATLAB\R2017b\toolbox\shared\slci\slci;C:\Program Files\MATLAB\R2017b\toolbox\shared\sl_coverage_configset;C:\Program Files\MATLAB\R2017b\toolbox\shared\sldv;C:\Program Files\MATLAB\R2017b\toolbox\shared\sldv_sfcn\sldv_sfcn;C:\Program Files\MATLAB\R2017b\toolbox\shared\slreportgen\reportexplorer;C:\Program Files\MATLAB\R2017b\toolbox\shared\slreportgen\rpt;C:\Program Files\MATLAB\R2017b\toolbox\shared\slreportgen\rpt\rpt;C:\Program Files\MATLAB\R2017b\toolbox\shared\slreportgen\utils;C:\Program Files\MATLAB\R2017b\toolbox\shared\spcuilib\slscopes;C:\Program Files\MATLAB\R2017b\toolbox\shared\slvnv;C:\Program Files\MATLAB\R2017b\toolbox\shared\sl_async_streaming;C:\Program Files\MATLAB\R2017b\toolbox\shared\sl_web_widgets;C:\Program Files\MATLAB\R2017b\toolbox\shared\spreadsheet;C:\Program Files\MATLAB\R2017b\toolbox\shared\statslib;C:\Program Files\MATLAB\R2017b\toolbox\shared\statslib\sensitivity;C:\Program Files\MATLAB\R2017b\toolbox\shared\supportpkgservices\legacysupportpkginfo;C:\Program Files\MATLAB\R2017b\toolbox\shared\supportpkgservices\installservices;C:\Program Files\MATLAB\R2017b\toolbox\shared\supportpkgservices\supportpackageroot;C:\Program Files\MATLAB\R2017b\toolbox\shared\supportpkgservices\installedapi;C:\Program Files\MATLAB\R2017b\toolbox\shared\supportsoftware\launcher;C:\Program Files\MATLAB\R2017b\toolbox\shared\supportsoftware\services;C:\Program Files\MATLAB\R2017b\toolbox\shared\supportsoftware\upgrade;C:\Program Files\MATLAB\R2017b\toolbox\shared\system\coder;C:\Program Files\MATLAB\R2017b\toolbox\shared\system\coreblocks;C:\Program Files\MATLAB\R2017b\toolbox\shared\system\sfun;C:\Program Files\MATLAB\R2017b\toolbox\shared\system\simulink;C:\Program Files\MATLAB\R2017b\toolbox\shared\testmeaslib\general;C:\Program Files\MATLAB\R2017b\toolbox\shared\testmeaslib\graphics;C:\Program Files\MATLAB\R2017b\toolbox\shared\simulink;C:\Program Files\MATLAB\R2017b\toolbox\shared\simulation_data_repository;C:\Program Files\MATLAB\R2017b\toolbox\sl3d\sl3d;C:\Program Files\MATLAB\R2017b\toolbox\sl3d\sl3ddemos;C:\Program Files\MATLAB\R2017b\toolbox\coder\foundation\passmanager;C:\Program Files\MATLAB\R2017b\toolbox\shared\simulink\slcheck_services;C:\Program Files\MATLAB\R2017b\toolbox\slcoverage;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink_data_dictionary\sldd;C:\Program Files\MATLAB\R2017b\toolbox\sldv\sldv;C:\Program Files\MATLAB\R2017b\toolbox\simulink\slexportprevious;C:\Program Files\MATLAB\R2017b\toolbox\simulink\slhistory;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\slproject\simulink;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\slproject;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\slproject\menu;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\slproject\examples;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\slproject\templates;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sltemplate;C:\Program Files\MATLAB\R2017b\toolbox\sltp\editor;C:\Program Files\MATLAB\R2017b\toolbox\sltp\legend;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sl_async_streaming;C:\Program Files\MATLAB\R2017b\toolbox\simulink\fixedandfloat;C:\Program Files\MATLAB\R2017b\toolbox\simulink\fixedandfloat\obsolete;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sl_graphics_services\tools;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\iodata\iomap;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\sourceBlocks;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\iodata\ioformat;C:\Program Files\MATLAB\R2017b\toolbox\shared\sl_messages;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\performance;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\performance\performancea;C:\Program Files\MATLAB\R2017b\toolbox\sl_pir_cap;C:\Program Files\MATLAB\R2017b\toolbox\shared\slpir;C:\Program Files\MATLAB\R2017b\toolbox\shared\dastudio\seqdiagram;C:\Program Files\MATLAB\R2017b\toolbox\shared\diagnostic;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\scenarioconnector;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\scenarioconnector\ui;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\scenarioconnector\ui\toolstrip\modelsection;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\scenarioconnector\ui\toolstrip\filesection;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\editor;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\editor\ui;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\ui;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\ui\comparisontool;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\ui\mapping;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\ui\mapping\callbacks;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\ui\mapping\util;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\ui\toolstrip;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\ui\toolstrip\open\streaming;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\ui\toolstrip\help;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\ui\toolstrip\open;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\ui\toolstrip\session;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\ui\toolstrip\report;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\derivedSignals;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\sl_sta_editor_block;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\repository;C:\Program Files\MATLAB\R2017b\toolbox\simulink\sta\repository\util;C:\Program Files\MATLAB\R2017b\toolbox\simulink\ui\sl_studio\sl_studio;C:\Program Files\MATLAB\R2017b\toolbox\simulink\ui\sl_studio\sl_studio\toolstrip\SimulinkStudio;C:\Program Files\MATLAB\R2017b\toolbox\shared\sl_units_mldatx;C:\Program Files\MATLAB\R2017b\toolbox\simulink\simulink\upgradeadvisor;C:\Program Files\MATLAB\R2017b\toolbox\matlab\spf\matlabhost;C:\Program Files\MATLAB\R2017b\toolbox\matlab\spf\matlabservices;C:\Program Files\MATLAB\R2017b\toolbox\stats\bayesoptim;C:\Program Files\MATLAB\R2017b\toolbox\stats\bigdata;C:\Program Files\MATLAB\R2017b\toolbox\stats\classreg;C:\Program Files\MATLAB\R2017b\toolbox\stats\clustering;C:\Program Files\MATLAB\R2017b\toolbox\stats\featlearn;C:\Program Files\MATLAB\R2017b\toolbox\stats\stats;C:\Program Files\MATLAB\R2017b\toolbox\stats\statsdemos;C:\Program Files\MATLAB\R2017b\toolbox\stats\distributed;C:\Program Files\MATLAB\R2017b\toolbox\stats\gpu;C:\Program Files\MATLAB\R2017b\toolbox\stats\mlearnapp;C:\Program Files\MATLAB\R2017b\toolbox\matlab\storage\matlabdrive;C:\Program Files\MATLAB\R2017b\toolbox\matlab\storage\mldrivedesktop;C:\Program Files\MATLAB\R2017b\toolbox\symbolic\symbolic;C:\Program Files\MATLAB\R2017b\toolbox\symbolic\symbolicdemos;C:\Program Files\MATLAB\R2017b\toolbox\matlab\system;C:\Program Files\MATLAB\R2017b\toolbox\matlab\system\editor;C:\Program Files\MATLAB\R2017b\toolbox\target\codertarget;C:\Program Files\MATLAB\R2017b\toolbox\target\codertarget\rtw;C:\Program Files\MATLAB\R2017b\toolbox\target\codertarget\matlabcoder;C:\Program Files\MATLAB\R2017b\toolbox\matlab\timeseries;C:\Program Files\MATLAB\R2017b\toolbox\matlab\toolboxmanagement\matlab_api;C:\Program Files\MATLAB\R2017b\toolbox\matlab\toolbox_packaging;C:\Program Files\MATLAB\R2017b\toolbox\matlab\toolstrip;C:\Program Files\MATLAB\R2017b\toolbox\matlab\uicomponents\uicomponents\plugin\appdesigner;C:\Program Files\MATLAB\R2017b\toolbox\matlab\uicomponents\uicomponents\plugin\appdesigner\graphics;C:\Program Files\MATLAB\R2017b\toolbox\matlab\uicomponents\uicomponents;C:\Program Files\MATLAB\R2017b\toolbox\matlab\uicomponents\uicomponents\graphics;C:\Program Files\MATLAB\R2017b\toolbox\shared\spcuilib\unifiedscopes;C:\Program Files\MATLAB\R2017b\toolbox\matlab\webcam;C:\Program Files\MATLAB\R2017b\toolbox\matlab\external\interfaces\webservices\http;C:\Program Files\MATLAB\R2017b\toolbox\matlab\external\interfaces\json;C:\Program Files\MATLAB\R2017b\toolbox\matlab\external\interfaces\webservices\restful;C:\Program Files\MATLAB\R2017b\toolbox\matlab\external\interfaces\webservices;C:\Program Files\MATLAB\R2017b\toolbox\matlab\external\interfaces\webservices\wsdl'), numberOfOutputArguments: 0 Executing command: Type: mtEval, command: ImporterTmpResult = {r0,r1,r2}, numberOfOutputArguments: 0 Executing command: Type: mtEval, command: class(ImporterTmpResult), numberOfOutputArguments: 1 Executing command: Type: mtEval, command: ImporterTmpResult(1:end), numberOfOutputArguments: 1 Executing command: Type: mtEval, command: ImporterTmpResult = find_system('sldemo_clutch_import.mdl','IncludeCommented','on','SearchDepth',1.0,'LookUnderMasks','all','FindAll','on','FollowLinks','on','type','block'), numberOfOutputArguments: 0 Executing command: Type: mtEval, command: class(ImporterTmpResult), numberOfOutputArguments: 1 Executing command: Type: mtEval, command: ImporterTmpResult(1:end), numberOfOutputArguments: 1 Executing command: Type: mtEval, command: ImporterTmpResult = get_param('sldemo_clutch_import.mdl','Handle'), numberOfOutputArguments: 0 Executing command: Type: mtEval, command: class(ImporterTmpResult), numberOfOutputArguments: 1 Executing command: Type: mtEval, command: ImporterTmpResult(1:end), numberOfOutputArguments: 1 Executing command: Type: mtEval, command: bdclose('all'), numberOfOutputArguments: 0

Thanks

sopopoola commented 4 years ago

I also noticed that when the program sent this command "get_param('sldemo_clutch_import.mdl','Handle')" a long list of file paths is returned as the result (and I guess it should be a double value to be cast as Handle). Here is a part of the file result ['C:\Users\student\Desktop\matlab;C:\Users\student\git\massif\plugins\hu.bme.mit.massif.simulink.api\scripts;C:\Users\student\Documents\MATLAB;C:\ProgramFiles\MATLAB\R2017b\toolbox\matlab\datafun;C:\Program Files\MATLAB\R2017b\toolbox\matlab\datatypes;....................'']

I also tried to run the command directly from MatLab and I get an error like this "'sldemo_clutch_import.mdl' is not a valid model name because it is not a valid MATLAB function name."

istvanrath commented 4 years ago

We've seen this before: #149

You are hitting a MATLAB-specific obscure error: https://www.mathworks.com/matlabcentral/answers/385376-error-while-opening-simulink-model

The resolution is to make sure your file names correspond to the rules described on https://www.mathworks.com/help/matlab/matlab_prog/variable-names.html

sopopoola commented 4 years ago

I finally resolved the issue. it turns out that I should not include the extension ".mdl" in the name of the file. so instead of ModelObject model = new ModelObject("sldemo_clutch_import.mdl", commandEvaluator);

It should be ModelObject model = new ModelObject("sldemo_clutch_import", commandEvaluator);

Bonus Note: I also tried running it on R2014b but I was getting an error in MATLAB about undefined variable "br.com.embraer.massif.commandevaluation.server". It turns out it was because the Matlab version was shipped with version 7 instead of version 8. So I changed the Matlab_home environment to the java version I want.

abelhegedus commented 4 years ago

Thanks for giving back to the community by sharing your solution!