Skip to content

Commit

Permalink
Update FMI Kit version
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sommer committed May 16, 2022
1 parent 6d7a8c4 commit ab80acd
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 86 deletions.
8 changes: 0 additions & 8 deletions +FMIKit/getBlockDialog.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
block = get_param(block, 'Handle');
end

% check library version
libraryVersion = char(fmikit.ui.FMUBlockDialog.FMI_KIT_VERSION);

% still using the 2.7 format for userData struct
if ~strcmp(fmikit.ui.FMUBlockDialog.FMI_KIT_VERSION, '2.7')
error(['Wrong fmikit.jar version. Expected 2.7 but was ' libraryVersion '.'])
end

dialog = javaMethod('getDialog', 'fmikit.ui.FMUBlockDialog', block);

end
10 changes: 8 additions & 2 deletions +FMIKit/initialize.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ function initialize()
msg = true;
end

% check fmikit.jar version
jarVersion = char(fmikit.ui.FMUBlockDialog.FMI_KIT_VERSION);
if ~strcmp(jarVersion, FMIKit.version)
error(['Wrong fmikit.jar version. Expected ' FMIKit.version ...
' but was ' jarVersion '.'])
end

% delete re-saved block library
close_system('FMIKit_blocks', 0);
library_file = fullfile(folder, 'FMIKit_blocks.slx');
Expand Down Expand Up @@ -90,8 +97,7 @@ function initialize()
end

if msg
disp(['Initializing FMI Kit ' [num2str(FMIKit.majorVersion) '.' ...
num2str(FMIKit.minorVersion) '.' num2str(FMIKit.patchVersion)]])
disp(['Initializing FMI Kit ' FMIKit.version])

% check MATLAB version
rel = version('-release');
Expand Down
6 changes: 0 additions & 6 deletions +FMIKit/majorVersion.m

This file was deleted.

6 changes: 0 additions & 6 deletions +FMIKit/minorVersion.m

This file was deleted.

6 changes: 0 additions & 6 deletions +FMIKit/patchVersion.m

This file was deleted.

56 changes: 2 additions & 54 deletions +FMIKit/private/getUserData.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,60 +15,8 @@
userData.startValues(parameter.Prompt) = parameter.Value;
end

if any(strcmp(userData.fmiKitVersion, {'2.4', '2.6'}))

disp(['Updating ' getfullname(block) ' that was imported with an older version of FMI Kit.'])

userData.fmiKitVersion = '2.7';
set_param(block, 'UserData', userData);

% re-import the FMU
dialog = FMIKit.showBlockDialog(block, false);
dialog.loadFMU(false);
applyDialog(dialog);

model = bdroot(block);
set_param(model, 'Dirty', 'on');

disp('Save the model to apply the changes.')

userData = get_param(block, 'UserData');

end

if ~isfield(userData, 'relativeTolerance')
disp(['Adding userData.relativeTolerance to ' getfullname(block)])
userData.relativeTolerance = '0';
set_param(block, 'UserData', userData, 'UserDataPersistent', 'on')
save_system
end

if ~isfield(userData, 'logFMICalls')
disp(['Adding userData.logFMICalls to ' getfullname(block)])
userData.logFMICalls = false;
set_param(block, 'UserData', userData, 'UserDataPersistent', 'on')
save_system
end

if ~isfield(userData, 'logLevel')
disp(['Adding userData.logLevel to ' getfullname(block)])
userData.logLevel = 0;
set_param(block, 'UserData', userData, 'UserDataPersistent', 'on')
save_system
end

if ~isfield(userData, 'logFile')
disp(['Adding userData.logFile to ' getfullname(block)])
userData.logFile = '';
set_param(block, 'UserData', userData, 'UserDataPersistent', 'on')
save_system
end

if ~isfield(userData, 'logToFile')
disp(['Adding userData.logToFile to ' getfullname(block)])
userData.logToFile = false;
set_param(block, 'UserData', userData, 'UserDataPersistent', 'on')
save_system
if ~strcmp(userData.fmiKitVersion, FMIKit.version)
error([getfullname(block) ' was imported with an incompatible version of FMI Kit. Please re-import the FMU.']);
end

end
2 changes: 1 addition & 1 deletion +FMIKit/version.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function v = version()
% FMIKit.version Get the version of FMI Kit

v = [num2str(FMIKit.majorVersion) '.' num2str(FMIKit.minorVersion)];
v = '3.0-beta.1';

end
6 changes: 3 additions & 3 deletions Java/src/main/java/fmikit/ui/FMUBlockDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class FMUBlockDialog extends JDialog {
private JCheckBox resettableCheckBox;

public static boolean debugLogging = false;
public static final String FMI_KIT_VERSION = "2.7";
public static final String FMI_KIT_VERSION = "3.0-beta.1";
public static final int MODEL_EXCHANGE = 0;
public static final int CO_SIMULATION = 1;
public static HashMap<Double, FMUBlockDialog> dialogs = new HashMap<Double, FMUBlockDialog>();
Expand Down Expand Up @@ -648,8 +648,8 @@ public void setUserData(UserData userData) {
this.userData = userData;

// check the format version
if (!userData.fmiKitVersion.startsWith(FMI_KIT_VERSION)) {
throw new RuntimeException("Wrong FMI Kit version. Expected " + FMI_KIT_VERSION + " but was " + userData.fmiKitVersion);
if (!FMI_KIT_VERSION.equals(userData.fmiKitVersion)) {
throw new RuntimeException("UserData has the wrong format version. Expected " + FMI_KIT_VERSION + " but was " + userData.fmiKitVersion);
}

// Overview tab
Expand Down
Binary file modified examples/fmikit_demo_BouncingBall.slx
Binary file not shown.

0 comments on commit ab80acd

Please sign in to comment.