[591] | 1 | #include "xios.hpp" |
---|
[545] | 2 | |
---|
[549] | 3 | #include "icdate.hpp" |
---|
[545] | 4 | #include "exception.hpp" |
---|
| 5 | #include "timer.hpp" |
---|
| 6 | #include "context.hpp" |
---|
| 7 | #include "context_client.hpp" |
---|
| 8 | |
---|
| 9 | extern "C" |
---|
| 10 | { |
---|
[549] | 11 | void cxios_update_calendar(int step) |
---|
[1622] | 12 | TRY |
---|
[545] | 13 | { |
---|
| 14 | CTimer::get("XIOS").resume(); |
---|
[1753] | 15 | CTimer::get("XIOS update calendar").resume(); |
---|
[545] | 16 | xios::CContext* context = CContext::getCurrent(); |
---|
[704] | 17 | if (!context->hasServer && !context->client->isAttachedModeEnabled()) |
---|
[1761] | 18 | context->eventLoop(); |
---|
| 19 | //ym context->checkBuffersAndListen(); |
---|
| 20 | |
---|
[549] | 21 | context->updateCalendar(step); |
---|
| 22 | context->sendUpdateCalendar(step); |
---|
[1753] | 23 | CTimer::get("XIOS update calendar").suspend(); |
---|
[545] | 24 | CTimer::get("XIOS").suspend(); |
---|
| 25 | } |
---|
[1622] | 26 | CATCH_DUMP_STACK |
---|
[545] | 27 | |
---|
[549] | 28 | void cxios_get_current_date(cxios_date* current_date_c) |
---|
[1622] | 29 | TRY |
---|
[545] | 30 | { |
---|
| 31 | CTimer::get("XIOS").resume(); |
---|
[549] | 32 | const xios::CContext* context = CContext::getCurrent(); |
---|
[1542] | 33 | const std::shared_ptr<xios::CCalendar> cal = context->getCalendar(); |
---|
[549] | 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(); |
---|
[545] | 44 | CTimer::get("XIOS").suspend(); |
---|
| 45 | } |
---|
[1622] | 46 | CATCH_DUMP_STACK |
---|
[549] | 47 | |
---|
| 48 | int cxios_get_year_length_in_seconds(int year) |
---|
[1622] | 49 | TRY |
---|
[549] | 50 | { |
---|
| 51 | CTimer::get("XIOS").resume(); |
---|
[1542] | 52 | const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar(); |
---|
[549] | 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 | } |
---|
[1622] | 61 | CATCH_DUMP_STACK |
---|
[549] | 62 | |
---|
| 63 | int cxios_get_day_length_in_seconds() |
---|
[1622] | 64 | TRY |
---|
[549] | 65 | { |
---|
| 66 | CTimer::get("XIOS").resume(); |
---|
[1542] | 67 | const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar(); |
---|
[549] | 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 | } |
---|
[1622] | 76 | CATCH_DUMP_STACK |
---|
[545] | 77 | } |
---|