source: XIOS/trunk/src/interface/c/iccalendar.cpp @ 597

Last change on this file since 597 was 597, checked in by rlacroix, 10 years ago

Add basic infrastructure for servers to clients communication.

File size: 2.1 KB
Line 
1#include "xios.hpp"
2
3#include "icdate.hpp"
4#include "exception.hpp"
5#include "timer.hpp"
6#include "context.hpp"
7#include "context_client.hpp"
8
9extern "C"
10{
11  void cxios_update_calendar(int step)
12  {
13    CTimer::get("XIOS").resume();
14    xios::CContext* context = CContext::getCurrent();
15    if (!context->hasServer) context->checkBuffersAndListen();
16    context->updateCalendar(step);
17    context->sendUpdateCalendar(step);
18    CTimer::get("XIOS").suspend();
19  }
20
21  void cxios_get_current_date(cxios_date* current_date_c)
22  {
23    CTimer::get("XIOS").resume();
24    const xios::CContext* context = CContext::getCurrent();
25    const boost::shared_ptr<xios::CCalendar> cal = context->getCalendar();
26    if (!cal)
27      ERROR("void cxios_get_current_date(cxios_date* current_date_c)",
28            << "Impossible to get the current date: no calendar was defined.");
29    const CDate& currentDate = cal->getCurrentDate();
30    current_date_c->year = currentDate.getYear();
31    current_date_c->month = currentDate.getMonth();
32    current_date_c->day = currentDate.getDay();
33    current_date_c->hour = currentDate.getHour();
34    current_date_c->minute = currentDate.getMinute();
35    current_date_c->second = currentDate.getSecond();
36    CTimer::get("XIOS").suspend();
37  }
38
39  int cxios_get_year_length_in_seconds(int year)
40  {
41    CTimer::get("XIOS").resume();
42    const boost::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar();
43    if (!cal)
44      ERROR("int cxios_get_year_length_in_seconds(int year)",
45            << "Impossible to get the year length: no calendar was defined.");
46    int length = cal->getYearTotalLength(CDate(*cal, year, 01, 01));
47    CTimer::get("XIOS").suspend();
48
49    return length;
50  }
51
52  int cxios_get_day_length_in_seconds()
53  {
54    CTimer::get("XIOS").resume();
55    const boost::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar();
56    if (!cal)
57      ERROR("int cxios_get_day_length_in_seconds()",
58            << "Impossible to get the day length: no calendar was defined.");
59    int length = cal->getDayLengthInSeconds();
60    CTimer::get("XIOS").suspend();
61
62    return length;
63  }
64}
Note: See TracBrowser for help on using the repository browser.