[545] | 1 | #include "xmlioserver.hpp" |
---|
| 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(); |
---|
[549] | 15 | if (!context->hasServer) context->client->checkBuffers(); |
---|
| 16 | context->updateCalendar(step); |
---|
| 17 | context->sendUpdateCalendar(step); |
---|
[545] | 18 | CTimer::get("XIOS").suspend(); |
---|
| 19 | } |
---|
| 20 | |
---|
[549] | 21 | void cxios_get_current_date(cxios_date* current_date_c) |
---|
[545] | 22 | { |
---|
| 23 | CTimer::get("XIOS").resume(); |
---|
[549] | 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(); |
---|
[545] | 36 | CTimer::get("XIOS").suspend(); |
---|
| 37 | } |
---|
[549] | 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 | } |
---|
[545] | 64 | } |
---|