X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fclock.cxx;h=39f6f582f0b9ad566cb298aecd197da0f8470817;hb=9d995907db00728da7eac9297ecbab93ed8a7400;hp=994c357c05f26e0d47e900ee0b9516e65e6d090a;hpb=541d41af83da1ae51d7cfb51f19f725c7563276c;p=flightgear.git diff --git a/src/Instrumentation/clock.cxx b/src/Instrumentation/clock.cxx index 994c357c0..39f6f582f 100644 --- a/src/Instrumentation/clock.cxx +++ b/src/Instrumentation/clock.cxx @@ -5,6 +5,11 @@ // // $Id$ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include #include "clock.hxx" #include @@ -12,12 +17,17 @@ #include
-Clock::Clock () - : _is_serviceable(true), - _gmt_time_sec(0), - _offset_sec(0), - _indicated_sec(0), - _standstill_offset(0) +Clock::Clock(SGPropertyNode *node) : + _name(node->getStringValue("name", "clock")), + _num(node->getIntValue("number", 0)), + _is_serviceable(true), + _gmt_time_sec(0), + _offset_sec(0), + _indicated_sec(0), + _indicated_min(0), + _indicated_hour(0), + _local_hour(0), + _standstill_offset(0) { _indicated_string[0] = '\0'; } @@ -29,10 +39,19 @@ Clock::~Clock () void Clock::init () { - _serviceable_node = fgGetNode("/instrumentation/clock/serviceable", true); - _offset_node = fgGetNode("/instrumentation/clock/offset-sec", true); - _sec_node = fgGetNode("/instrumentation/clock/indicated-sec", true); - _string_node = fgGetNode("/instrumentation/clock/indicated-string", true); + std::string branch; + branch = "/instrumentation/" + _name; + + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); + _serviceable_node = node->getChild("serviceable", 0, true); + _offset_node = node->getChild("offset-sec", 0, true); + _sec_node = node->getChild("indicated-sec", 0, true); + _min_node = node->getChild("indicated-min", 0, true); + _hour_node = node->getChild("indicated-hour", 0, true); + _lhour_node = node->getChild("local-hour", 0, true); + _string_node = node->getChild("indicated-string", 0, true); + _string_node1 = node->getChild("indicated-short-string", 0, true); + _string_node2 = node->getChild("local-short-string", 0, true); } void @@ -51,6 +70,14 @@ Clock::update (double delta_time_sec) int min = t->tm_min; int sec = t->tm_sec; + // compute local time zone hour + int tzoffset_hours = globals->get_time_params()->get_local_offset() / 3600; + int lhour = hour + tzoffset_hours; + if (lhour < 0) + lhour += 24; + if (lhour >= 24) + lhour -= 24; + long gmt = (hour * 60 + min) * 60 + sec; int offset = _offset_node->getLongValue(); @@ -89,7 +116,18 @@ Clock::update (double delta_time_sec) sprintf(_indicated_string, "%02d:%02d:%02d", hour, min, sec); _string_node->setStringValue(_indicated_string); + sprintf(_indicated_short_string, "%02d:%02d", hour, min); + _string_node1->setStringValue(_indicated_short_string); + sprintf(_local_short_string, "%02d:%02d", lhour, min); + _string_node2->setStringValue(_local_short_string); _is_serviceable = true; + + _indicated_min = min; + _min_node->setLongValue(_indicated_min); + _indicated_hour = hour; + _hour_node->setLongValue(_indicated_hour); + _local_hour = lhour; + _lhour_node->setLongValue(_local_hour); }