Skip to content

Commit

Permalink
added serialize tests for fmi2
Browse files Browse the repository at this point in the history
  • Loading branch information
lausdahl committed Jul 11, 2024
1 parent 06ba622 commit ae74d49
Show file tree
Hide file tree
Showing 5 changed files with 278 additions and 216 deletions.
2 changes: 1 addition & 1 deletion fmi2/src/main/java/org/intocps/fmi/IFmiComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public abstract Fmi2Status setStrings(long[] scalarValueIndices,

FmuResult<Long> getSerializedFMUstateSize(IFmiComponentState state) throws FmuInvocationException;
FmuResult<byte[]> serializeFMUstate(IFmiComponentState state, long size) throws FmuInvocationException;
FmuResult<IFmiComponentState> serializeFMUstate(IFmiComponentState state, byte[] bytes, long size) throws FmuInvocationException;
FmuResult<IFmiComponentState> deSerializeFMUstate( byte[] bytes, long size) throws FmuInvocationException;

public abstract boolean isValid();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ public FmuResult<byte[]> serializeFMUstate(IFmiComponentState state, long byteSi
throw new FmuInvocationException("Invalid state");

}
public FmuResult<IFmiComponentState> serializeFMUstate(IFmiComponentState state, byte[] bytes, long size) throws FmuInvocationException{
public FmuResult<IFmiComponentState> deSerializeFMUstate( byte[] bytes, long size) throws FmuInvocationException{
long statePtr[] = new long[1];
Fmi2Status res = Fmi2Status.valueOf(nDeSerializeFMUstate(fmuPtr, componentPtr, bytes,size,statePtr));

Expand Down
3 changes: 2 additions & 1 deletion jnifmuapi/src/main/native/src/comp_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,9 +643,10 @@ JNIEXPORT jbyte JNICALL Java_org_intocps_fmi_jnifmuapi_NativeFmuComponent_nDeSer
fmi2FMUstate state;
state = NULL;
fmi2Status status = getFmuPtr(fmuPtr)->deSerializeFMUstate(c, bytes, len,&state);
if(state==fmi2OK)
if(status==fmi2OK)
{
jlong *vbody = (*env)->GetLongArrayElements(env, statePtrArr, 0);

vbody[0] = (jlong) (state);

(*env)->ReleaseLongArrayElements(env, statePtrArr, vbody, 0);
Expand Down
Loading

0 comments on commit ae74d49

Please sign in to comment.