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