@@ -595,13 +595,29 @@ private void RecordClocksAndClockedVariables()
595595 // retrieve and send CAN frames
596596 var outputCan = FmuCanManager . GetCanData ( ) ;
597597 SilKitCanManager . SendAllFrames ( outputCan ) ;
598+
599+ // retrieve RPC server results from the FMU and submit them
600+ var rpcServerResults = FmuRpcServerManager . GetOperations ( ) ;
601+ SilKitRpcServerManager . SubmitResult ( rpcServerResults ) ;
602+
603+ // retrieve RPC client calls from the FMU and send them
604+ var rpcClientCalls = FmuRpcClientManager . GetOperations ( ) ;
605+ SilKitRpcClientManager . Call ( rpcClientCalls ) ;
598606 }
599607
600608 private void ApplyClocksAndClockedInputs ( )
601609 {
602610 // handle received CAN frames
603611 var receivedSilKitCanData = SilKitCanManager . RetrieveReceivedCanData ( _lastSimStep ! . Value ) ;
604612 FmuCanManager . SetCanData ( receivedSilKitCanData ) ;
613+
614+ // handle client RPC results
615+ var recvRpcResults = SilKitRpcClientManager . RetrieveReceivedRpcEvents ( _lastSimStep ! . Value ) ;
616+ FmuRpcClientManager . SetData ( recvRpcResults ) ;
617+
618+ // handle server RPC calls
619+ var recvRpcCalls = SilKitRpcServerManager . RetrieveReceivedRpcCalls ( _lastSimStep ! . Value ) ;
620+ FmuRpcServerManager . SetData ( recvRpcCalls ) ;
605621 }
606622
607623 public void StartSimulation ( )
@@ -735,6 +751,8 @@ private void OnSimulationStep(ulong nowInNs, ulong durationInNs)
735751
736752 FmuEntity . UpdateDiscreteStates ( out discreteStatesNeedUpdate , out terminateRequested ) ;
737753
754+ RecordClocksAndClockedVariables ( ) ;
755+
738756 if ( terminateRequested )
739757 {
740758 SilKitCanManager . StopCanControllers ( ) ;
@@ -743,8 +761,6 @@ private void OnSimulationStep(ulong nowInNs, ulong durationInNs)
743761 return ;
744762 }
745763
746- RecordClocksAndClockedVariables ( ) ;
747-
748764 } while ( discreteStatesNeedUpdate ) ;
749765
750766 FmuEntity . EnterStepMode ( ) ;
@@ -769,14 +785,6 @@ private void OnSimulationStep(ulong nowInNs, ulong durationInNs)
769785 FmuDataManager . SetData ( receivedSilKitDataStruct ) ;
770786 FmuDataManager . SetData ( receivedSilKitDataClockedStruct ) ;
771787
772- // handle client RPC results
773- var receivedRpcResults = SilKitRpcClientManager . RetrieveReceivedRpcEvents ( _lastSimStep ! . Value ) ;
774- FmuRpcClientManager . SetData ( receivedRpcResults ) ;
775-
776- // handle server RPC calls
777- var receivedRpcCalls = SilKitRpcServerManager . RetrieveReceivedRpcCalls ( _lastSimStep ! . Value ) ;
778- FmuRpcServerManager . SetData ( receivedRpcCalls ) ;
779-
780788 _lastSimStep = nowInNs ;
781789
782790 if ( _initialSimTime > 0 )
@@ -845,14 +853,6 @@ private void OnSimulationStep(ulong nowInNs, ulong durationInNs)
845853 FmuDataManager . SetData ( receivedSilKitDataStructEventMode ) ;
846854 FmuDataManager . SetData ( receivedSilKitDataClockedStructEventMode ) ;
847855
848- // handle client RPC results
849- var recvRpcResults = SilKitRpcClientManager . RetrieveReceivedRpcEvents ( _lastSimStep ! . Value ) ;
850- FmuRpcClientManager . SetData ( recvRpcResults ) ;
851-
852- // handle server RPC calls
853- var recvRpcCalls = SilKitRpcServerManager . RetrieveReceivedRpcCalls ( _lastSimStep ! . Value ) ;
854- FmuRpcServerManager . SetData ( recvRpcCalls ) ;
855-
856856 do
857857 {
858858 ApplyClocksAndClockedInputs ( ) ;
@@ -869,12 +869,6 @@ private void OnSimulationStep(ulong nowInNs, ulong durationInNs)
869869 return ;
870870 }
871871
872- var rpcCalls = FmuRpcServerManager . GetOperations ( ) ;
873- SilKitRpcServerManager . SubmitResult ( rpcCalls ) ;
874-
875- var futureRpcCalls = FmuRpcClientManager . GetOperations ( ) ;
876- SilKitRpcClientManager . Call ( futureRpcCalls ) ;
877-
878872 } while ( discreteStatesNeedUpdate ) ;
879873
880874 // Retrieve and publish non-structured variables
0 commit comments