Skip to content

Commit

Permalink
- simulation_events.cpp -> c
Browse files Browse the repository at this point in the history
- add list for simulation_events

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10411 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Nov 10, 2011
1 parent a92e823 commit c630f5c
Show file tree
Hide file tree
Showing 9 changed files with 407 additions and 161 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Expand Up @@ -18,12 +18,13 @@ ADD_SUBDIRECTORY(testsuite)
ENDIF(RUN_TESTS)

# Subdirectorys
ADD_SUBDIRECTORY(c_runtime)
#ADD_SUBDIRECTORY(c_runtime)
#ADD_SUBDIRECTORY(modelica_parser)
#ADD_SUBDIRECTORY(flat_modelica_parser)
#ADD_SUBDIRECTORY(Compiler)
#ADD_SUBDIRECTORY(doc)
#ADD_SUBDIRECTORY(Examples)
ADD_SUBDIRECTORY(SimulationRuntime)

# -------------------------------------------------------------
# Models
Expand All @@ -33,8 +34,9 @@ ADD_SUBDIRECTORY(c_runtime)
# BUILDMODEL(model dir Flags CSRC)
SET(OMC_DEBUG ${OMCTRUNCHOME}/build/bin/omc.exe)
#BUILDMODEL(BouncingBall ${CMAKE_CURRENT_SOURCE_DIR}/testsuite/mosfiles-dassl +d=bltdump "")
#BUILDMODEL(Simple ${CMAKE_CURRENT_SOURCE_DIR}/build/bin/Test +d=bltdump)
#BUILDMODEL(Test ${CMAKE_CURRENT_SOURCE_DIR}/build/bin/Test +d=dumpdaelow)
#BUILDMODEL(WheelLoader_der_state ${CMAKE_CURRENT_SOURCE_DIR}/build/bin/Test +d=bltdump "")
#BUILDMODELFMU(Test ${CMAKE_CURRENT_SOURCE_DIR}/build/bin/Test/FMU +d=bltdump "")
#BUILDMODEL(Test1 ${CMAKE_CURRENT_SOURCE_DIR}/build/bin/Test/FMU +d=bltdump "")
BUILDMODELFMUMOS(WheelLoader D:/Programming/Models/Radlader/radlader-cnh/WheelLoader.mos +d=bltdump "")
#BUILDMODELMOS(Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum D:/Software/OpenModelicaProject/OpenModelica/build/bin/Test/Pendulum.mos +d= "")
BUILDMODELMOS(CombiTimeTableTest D:/Software/OpenModelicaProject/OpenModelica/testsuite/mosfiles/CombiTimeTableTest1.mos +d= "")
6 changes: 3 additions & 3 deletions SimulationRuntime/c/simulation/math-support/CMakeLists.txt
Expand Up @@ -5,11 +5,11 @@
SET(math_support_sources bigden.c enorm.c hybrd1.c nelmead.c qform.c r1updt.c
biglag.c dogleg.c fdjac1.c hybrj.c newuoa.c qrfac.c trsapp.c
dpmpar.c hybrd.c lsame.c newuob.c r1mpyq.c update.c
simulation_events.cpp simulation_delay.c
simulation_init.c dgesv_aux.c ringbuffer.c )
simulation_events.c simulation_delay.c
simulation_init.c dgesv_aux.c ringbuffer.c list.c)

SET(math_support_headers blaswrap.h matrix.h ringbuffer.h simulation_delay.h
simulation_events.h simulation_init.h)
simulation_events.h simulation_init.h list.h)

# Library util
ADD_LIBRARY(math-support ${math_support_sources} ${math_support_headers})
Expand Down
3 changes: 2 additions & 1 deletion SimulationRuntime/c/simulation/math-support/Makefile.in
Expand Up @@ -14,14 +14,15 @@ FFLAGS = -O -fexceptions
OBJS = bigden.o enorm.o hybrd1.o nelmead.o qform.o r1updt.o \
biglag.o dogleg.o fdjac1.o hybrj.o newuoa.o qrfac.o trsapp.o \
dpmpar.o hybrd.o lsame.o newuob.o r1mpyq.o update.o \
simulation_events.o ringbuffer.o simulation_delay.o simulation_init.o dgesv_aux.o \
simulation_events.o ringbuffer.o simulation_delay.o simulation_init.o dgesv_aux.o list.o \

HFILES = blaswrap.h \
matrix.h \
ringbuffer.h \
simulation_delay.h \
simulation_events.h \
simulation_init.h \
list.h \


LIBS = libmath-support.a
Expand Down
118 changes: 118 additions & 0 deletions SimulationRuntime/c/simulation/math-support/list.c
@@ -0,0 +1,118 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, Linköping University,
* 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
* AND 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öping University, 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.
*
*/

/* File: list.c
*
* Description: This file is a C header file for the simulation runtime.
* It contains a simple linked list
*/

#include "list.h"
#include <stdlib.h>
#include <assert.h>

void list_push_front(int data, List *list)
{
List_Node *new_node = 0;
assert(list);
new_node = (List_Node*) malloc(sizeof(List_Node));
new_node->data = data;
new_node->next = list->first;
list->first = new_node;
if (list->last == NULL) {
list->last = list->first;
}
}

void list_push_back(int data, List *list)
{
List_Node *new_node = 0;
assert(list==0?0:1);
new_node = (List_Node*) malloc(sizeof(List_Node));
new_node->data = data;
new_node->next = 0;
if (list->last!=NULL) {
list->last->next = new_node;
}
list->last = new_node;
if (list->first == NULL) {
list->first = list->last;
}
}

int list_empty(List list)
{
return list.first==0?1:0;
}

int list_front(List list)
{
assert(list.first);
return list.first->data;
}

int list_last(List list)
{
assert(list.last);
return list.last->data;
}

void list_pop_front(List *list)
{
if (list != NULL) {
if (list->first != NULL) {
List_Node *node = list->first->next;
free(list);
list->first = node;
if (list->first == 0) {
list->last = list->first;
}
}
}
}

void list_clear(List *list)
{
if (list == NULL) {
return;
}
while(list->first != NULL) {
list_pop_front(list);
}
}

List_Node* list_next(List_Node* node)
{
if (node==0) {
return 0;
}
return node->next;
}
75 changes: 75 additions & 0 deletions SimulationRuntime/c/simulation/math-support/list.h
@@ -0,0 +1,75 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, Linköping University,
* 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
* AND 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öping University, 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.
*
*/

/* File: list.h
*
* Description: This file is a C header file for the simulation runtime.
* It contains a simple linked list
*/

#ifndef _LIST_H
#define _LIST_H

#ifdef __cplusplus
extern "C" {
#endif

typedef struct list_node {
int data;
struct list_node *next;
} List_Node;

typedef struct list_list {
struct list_node *first;
struct list_node *last;
} List;

void list_push_front(int data, List *list);

void list_push_back(int data, List *list);

int list_empty(List list);

int list_front(List list);

int list_last(List list);

void list_pop_front(List *list);

void list_clear(List *list);

List_Node* list_next(List_Node* node);

#ifdef __cplusplus
}
#endif

#endif /* _LIST_H */

0 comments on commit c630f5c

Please sign in to comment.