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