Skip to content

Commit

Permalink
Adds serialization of MMC values
Browse files Browse the repository at this point in the history
  • Loading branch information
modlfo authored and OpenModelica-Hudson committed May 29, 2015
1 parent 7f603ec commit c8a2562
Show file tree
Hide file tree
Showing 6 changed files with 750 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Compiler/CMakeLists.txt
Expand Up @@ -22,7 +22,7 @@ SET(SRCMO Absyn.mo AbsynDep.mo Algorithm.mo Builtin.mo

SET(ALLMO ${SRCMO} DAEEXT.mo DynLoad.mo Print.mo System.mo Parser.mo
TaskGraphExt.mo Corba.mo Socket.mo ErrorExt.mo Settings.mo
UnitParserExt.mo SimulationResults.mo)
UnitParserExt.mo SimulationResults.mo Serializer.mo)

# RML
IF(NOT RML)
Expand Down
62 changes: 62 additions & 0 deletions Compiler/Util/Serializer.mo
@@ -0,0 +1,62 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-2014, Open Source Modelica Consortium (OSMC),
* c/o Linköpings universitet, Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
* THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
* ACCORDING TO RECIPIENTS CHOICE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from OSMC, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/


encapsulated package Serializer
"file: Serializer.mo
package: Serializer
description: External Stream Utilities
@author: Leonardo Laguna Ruiz [leonardo@wolfram.com]
@date: 2015-05-19
RCS: $Id$
This package provides functions to serialize MetaModelica data.
The external C implementation is in TOP/Compiler/runtime/Serializer.c"


public function outputFile<T> "
Prints the structure of the object."
input T object;
input String filename;
external "C" Serializer_outputFile(object,filename) annotation(Library = {"omcruntime"});
end outputFile;

public function bypass<T> "
Serializes the object and reads it back. This function is used for testing purposes."
input T object;
output T out_object;
external "C" out_object = Serializer_bypass(object) annotation(Library = {"omcruntime"});
end bypass;


annotation(__OpenModelica_Interface="util");
end Serializer;
3 changes: 2 additions & 1 deletion Compiler/boot/LoadCompilerSources.mos
Expand Up @@ -293,7 +293,8 @@ if true then /* Suppress output */
"../Util/System.mo",
"../Util/Util.mo",
"../Util/VarTransform.mo",
"../Util/VisualXML.mo"
"../Util/VisualXML.mo",
"../Util/Serializer.mo"
};
LoadCompilerSourcesRes:= OpenModelica.Scripting.loadFiles(files,numThreads=min(5,OpenModelica.Scripting.numProcessors()));
if not LoadCompilerSourcesRes then
Expand Down
2 changes: 1 addition & 1 deletion Compiler/runtime/CMakeLists.txt
Expand Up @@ -33,7 +33,7 @@ ADD_CUSTOM_TARGET(omc_communication ALL DEPENDS ${IDL_OUTPUT})
SET(CORBASRC ${IDL_OUTPUT} omc_communication_impl.cpp corbaimpl.cpp)
SET(SRC socketimpl.c printimpl.c systemimpl.c settingsimpl.c SimulationResults.c)
SET(CPPSRC unitparser.cpp unitparserext.cpp ptolemyio.cpp Dynload.cpp BackendDAEEXT.cpp ErrorMessage.cpp errorext.cpp
systemimplmisc.cpp ${CORBASRC})
systemimplmisc.cpp ${CORBASRC} serializer.cpp)
SET(OBJ ${SRC} ${CPPSRC})

IF(WIN32)
Expand Down
3 changes: 2 additions & 1 deletion Compiler/runtime/Makefile.common
Expand Up @@ -19,7 +19,7 @@ else
configUnix =
endif

OMC_OBJ = Error_omc.o Print_omc.o System_omc.o Settings_omc.o \
OMC_OBJ = Error_omc.o Print_omc.o System_omc.o Settings_omc.o serializer.o \
IOStreamExt_omc.o ErrorMessage.o FMI_omc.o systemimplmisc.o \
UnitParserExt_omc.o unitparser.o BackendDAEEXT_omc.o Socket_omc.o matching.o matching_cheap.o \
Database_omc.o Dynload_omc.o SimulationResults_omc.o TaskGraphResults_omc.o HpcOmSchedulerExt_omc.o HpcOmBenchmarkExt_omc.o ptolemyio_omc.o \
Expand Down Expand Up @@ -58,6 +58,7 @@ ptolemyio_omc.o : ptolemyio.cpp errorext.h $(RML_COMPAT)
ErrorMessage.o : ErrorMessage.cpp ErrorMessage.hpp errorext.h
FMI_omc.o : FMIImpl.c ../OpenModelicaBootstrappingHeader.h
GraphStreamExt_omc.o : ../OpenModelicaBootstrappingHeader.h GraphStreamExt_impl.cpp $(RML_COMPAT)
serializer.o: serializer.cpp

clean:
$(RM) -rf *.a *.o omc_communication.cc omc_communication.h omc_communication-*
Expand Down

0 comments on commit c8a2562

Please sign in to comment.