source: XIOS3/trunk/src/interface/c/iccalendar.cpp @ 2406

Last change on this file since 2406 was 2406, checked in by ymipsl, 19 months ago

Refactor management of client context and server context.
YM

File size: 2.4 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  TRY
13  {
14    CTimer::get("XIOS").resume();
15    CTimer::get("XIOS update calendar").resume();
16    xios::CContext* context = CContext::getCurrent();
17//    if (!context->hasServer && !context->client->isAttachedModeEnabled())
18      context->eventLoop();
19//ym      context->checkBuffersAndListen();
20     
21    context->updateCalendar(step);
22    context->sendUpdateCalendar(step);
23    CTimer::get("XIOS update calendar").suspend();
24    CTimer::get("XIOS").suspend();
25  }
26  CATCH_DUMP_STACK
27
28  void cxios_get_current_date(cxios_date* current_date_c)
29  TRY
30  {
31    CTimer::get("XIOS").resume();
32    const xios::CContext* context = CContext::getCurrent();
33    const std::shared_ptr<xios::CCalendar> cal = context->getCalendar();
34    if (!cal)
35      ERROR("void cxios_get_current_date(cxios_date* current_date_c)",
36            << "Impossible to get the current date: no calendar was defined.");
37    const CDate& currentDate = cal->getCurrentDate();
38    current_date_c->year = currentDate.getYear();
39    current_date_c->month = currentDate.getMonth();
40    current_date_c->day = currentDate.getDay();
41    current_date_c->hour = currentDate.getHour();
42    current_date_c->minute = currentDate.getMinute();
43    current_date_c->second = currentDate.getSecond();
44    CTimer::get("XIOS").suspend();
45  }
46  CATCH_DUMP_STACK
47
48  int cxios_get_year_length_in_seconds(int year)
49  TRY
50  {
51    CTimer::get("XIOS").resume();
52    const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar();
53    if (!cal)
54      ERROR("int cxios_get_year_length_in_seconds(int year)",
55            << "Impossible to get the year length: no calendar was defined.");
56    int length = cal->getYearTotalLength(CDate(*cal, year, 01, 01));
57    CTimer::get("XIOS").suspend();
58
59    return length;
60  }
61  CATCH_DUMP_STACK
62
63  int cxios_get_day_length_in_seconds()
64  TRY
65  {
66    CTimer::get("XIOS").resume();
67    const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar();
68    if (!cal)
69      ERROR("int cxios_get_day_length_in_seconds()",
70            << "Impossible to get the day length: no calendar was defined.");
71    int length = cal->getDayLengthInSeconds();
72    CTimer::get("XIOS").suspend();
73
74    return length;
75  }
76  CATCH_DUMP_STACK
77}
Note: See TracBrowser for help on using the repository browser.