Skip to content

Commit

Permalink
- Added SimulationResults_omc.cpp
Browse files Browse the repository at this point in the history
- Added the remaining external functions in System_omc.cpp
- Main.main now passes the gcc linker and produces a 15MB executable that at the very least can display the help text on start (the main() function ignores argv,argc)


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7146 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Nov 21, 2010
1 parent b494467 commit db22d3e
Show file tree
Hide file tree
Showing 7 changed files with 290 additions and 163 deletions.
6 changes: 3 additions & 3 deletions Compiler/SimulationResults.mo
Expand Up @@ -45,7 +45,7 @@ public function readPtolemyplotVariables
input String inVisVars;
output list<String> outStringLst;

external "C" ;
external "C" outStringLst=SimulationResults_readPtolemyplotVariables(inString,inVisVars) annotation(Library = "omcruntime");
end readPtolemyplotVariables;

public function readPtolemyplotDataset
Expand All @@ -54,14 +54,14 @@ public function readPtolemyplotDataset
input Integer inInteger;
output Values.Value outValue;

external "C" ;
external "C" outValue=SimulationResults_readPtolemyplotDataset(inString,inStringLst,inInteger) annotation(Library = "omcruntime");
end readPtolemyplotDataset;

public function readPtolemyplotDatasetSize
input String inString;
output Values.Value outValue;

external "C" ;
external "C" outValue=SimulationResults_readPtolemyplotDatasetSize(inString) annotation(Library = "omcruntime");
end readPtolemyplotDatasetSize;

end SimulationResults;
Expand Down
4 changes: 2 additions & 2 deletions Compiler/runtime/Makefile.common
Expand Up @@ -18,7 +18,7 @@ else
endif

SRC = RTOpts_rml.c Print_rml.c System_rml.c Settings_rml.c \
SimulationResults.c IOStreamExt_rml.c rtclock.c Database.c Socket_rml.c
SimulationResults_rml.c IOStreamExt_rml.c rtclock.c Database.c Socket_rml.c

CPPSRC = unitparser.cpp UnitParserExt_rml.cpp ptolemyio.cpp \
BackendDAEEXT_rml.cpp ErrorMessage.cpp Error_rml.cpp OptManager_rml.cpp \
Expand All @@ -29,7 +29,7 @@ OBJ = $(SRC:.c=.o) $(CPPSRC:.cpp=.o) $(CPPSRC:.cc=.o)
OMC_OBJ = Error_omc.o Print_omc.o RTOpts_omc.o System_omc.o Settings_omc.o \
IOStreamExt_omc.o ErrorMessage.o systemimplmisc.o rtclock.o \
UnitParserExt_omc.o unitparser.o BackendDAEEXT_omc.o Socket_omc.o \
corbaimpl_stub_omc.o Dynload_omc.o OptManager_omc.o
corbaimpl_stub_omc.o Dynload_omc.o OptManager_omc.o SimulationResults_omc.o

all: runtime.a install
.PHONY: all install
Expand Down
53 changes: 53 additions & 0 deletions Compiler/runtime/SimulationResults_omc.cpp
@@ -0,0 +1,53 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-2010, Linköpings University,
* Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THIS OSMC PUBLIC
* LICENSE (OSMC-PL). ANY USE, REPRODUCTION OR DISTRIBUTION OF
* THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THE OSMC
* PUBLIC LICENSE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from Linköpings University, either from the above address,
* from the URL: http://www.ida.liu.se/projects/OpenModelica
* and in the OpenModelica distribution.
*
* 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.
*
*/

#include <stdio.h>

extern "C" {

void* SimulationResults_readPtolemyplotVariables(const char *filename, const char *visvars)
{
fprintf(stderr, "SimulationResults_readPtolemyplotVariables NYI\n");
throw 1;
}

void* SimulationResults_readPtolemyplotDataset(const char *filename, void *vars, int i)
{
fprintf(stderr, "SimulationResults_readPtolemyplotDataset NYI\n");
throw 1;
}

void* SimulationResults_readPtolemyplotDatasetSize(const char *filename)
{
fprintf(stderr, "SimulationResults_readPtolemyplotDatasetSize NYI\n");
throw 1;
}

}
File renamed without changes.
71 changes: 71 additions & 0 deletions Compiler/runtime/System_omc.cpp
Expand Up @@ -341,4 +341,75 @@ extern const char* System_readEnv(const char *envname)
return strdup(envvalue);
}

extern void System_getCurrentDateTime(int* sec, int* min, int* hour, int* mday, int* mon, int* year)
{
time_t t;
struct tm* localTime;
time( &t );
localTime = localtime(&t);
*sec = localTime->tm_sec;
*min = localTime->tm_min;
*hour = localTime->tm_hour;
*mday = localTime->tm_mday;
*mon = localTime->tm_mon + 1;
*year = localTime->tm_year + 1900;
}

extern const char* System_getUUIDStr()
{
return strdup(SystemImpl__getUUIDStr());
}

extern int System_loadLibrary(const char *name)
{
int res = SystemImpl__loadLibrary(name);
if (res == -1) throw 1;
return res;
}

#if defined(__MINGW32__) || defined(_MSC_VER)
void* System_subDirectories(const char *directory)
{
void *res;
WIN32_FIND_DATA FileData;
BOOL more = TRUE;
char pattern[1024];
HANDLE sh;

sprintf(pattern, "%s\\*.*", directory);

res = mmc_mk_nil();
sh = FindFirstFile(pattern, &FileData);
if (sh != INVALID_HANDLE_VALUE) {
while(more) {
if (strcmp(FileData.cFileName,"..") != 0 &&
strcmp(FileData.cFileName,".") != 0 &&
(FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
{
res = mmc_mk_cons(mmc_mk_scon(FileData.cFileName),res);
}
more = FindNextFile(sh, &FileData);
}
if (sh != INVALID_HANDLE_VALUE) FindClose(sh);
}
return res;
}
#else
void* System_subDirectories(const char *directory)
{
int i,count;
void *res;
struct dirent **files;
select_from_dir = directory;
count = scandir(directory, &files, file_select_directories, NULL);
res = mmc_mk_nil();
for (i=0; i<count; i++)
{
res = mmc_mk_cons(mmc_mk_scon(files[i]->d_name),res);
free(files[i]);
}
return res;
}
#endif

}

0 comments on commit db22d3e

Please sign in to comment.