- App.tsx: full navigation (Auth stack + Main tabs with 5 screens) - Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen - HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors - MapScreen: interactive map with layer toggles (6 layers) - MarketplaceScreen: categories (6), products (5), search - ChatScreen: AI chat with quick prompts (4), bot responses - ProfileScreen: user info, stats, menu (9 items), logout - AlertsScreen: alert list with severity, acknowledge - SensorsScreen: sensor list with type filters (6 types), search - ZonesScreen: zone cards with stats - SettingsScreen: language picker (FR/EN/ES/DE), privacy, about - Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n - Hooks: useSensors, useAlerts, useNotifications, useLocation - Components: Card, Button, LoadingSpinner, ErrorBoundary, Header - Services: iotService, notificationService (with axios API client) - Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN) - Theme: colors.ts with full design system (Blue Ocean palette) - Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
114 lines
3.5 KiB
C++
114 lines
3.5 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <chrono>
|
|
#include <type_traits>
|
|
|
|
namespace facebook::react {
|
|
|
|
/*
|
|
* Represents a monotonic clock suitable for measuring intervals.
|
|
*/
|
|
using TelemetryClock = std::chrono::steady_clock;
|
|
|
|
/*
|
|
* Represents a point in time satisfied the requirements of TelemetryClock.
|
|
*/
|
|
using TelemetryTimePoint = TelemetryClock::time_point;
|
|
|
|
/*
|
|
* Represents a time interval satisfied the requirements of TelemetryClock.
|
|
*/
|
|
using TelemetryDuration = std::chrono::nanoseconds;
|
|
|
|
/*
|
|
* Represents a time point which never happens.
|
|
*/
|
|
static const TelemetryTimePoint kTelemetryUndefinedTimePoint =
|
|
TelemetryTimePoint::max();
|
|
|
|
/*
|
|
* Returns a time point representing the current point in time.
|
|
*/
|
|
static inline TelemetryTimePoint telemetryTimePointNow() {
|
|
return TelemetryClock::now();
|
|
}
|
|
|
|
/*
|
|
* Returns a number of milliseconds that passed from some epoch starting time
|
|
* point to a given time point. The epoch starting time point is not specified
|
|
* but stays the same for an application run.
|
|
*/
|
|
static inline int64_t telemetryTimePointToMilliseconds(
|
|
TelemetryTimePoint timePoint) {
|
|
return std::chrono::duration_cast<std::chrono::milliseconds>(
|
|
timePoint - TelemetryTimePoint{})
|
|
.count();
|
|
}
|
|
|
|
/*
|
|
* Returns a number of seconds that passed from "Steady Clock" epoch starting
|
|
* time point to a given time point.
|
|
*/
|
|
static inline double telemetryTimePointToSteadyClockSeconds(
|
|
TelemetryTimePoint timePoint) {
|
|
static_assert(
|
|
std::is_same<decltype(timePoint), std::chrono::steady_clock::time_point>::
|
|
value,
|
|
"`TelemetryClock` must be `std::chrono::steady_clock` to make the "
|
|
"following implementation work correctly.");
|
|
|
|
auto nanoseconds = std::chrono::duration_cast<std::chrono::nanoseconds>(
|
|
timePoint.time_since_epoch())
|
|
.count();
|
|
return (double)nanoseconds / 1.0e9;
|
|
}
|
|
|
|
/*
|
|
* Converts a time point on one clock to a time point on a different clock.
|
|
*/
|
|
template <
|
|
typename DestinationTimePointT,
|
|
typename SourceTimePointT,
|
|
typename DestnationClockT = typename DestinationTimePointT::clock,
|
|
typename SourceClockT = typename SourceTimePointT::clock>
|
|
DestinationTimePointT clockCast(SourceTimePointT timePoint) {
|
|
auto sourseClockNow = SourceClockT::now();
|
|
auto destinationClockNow = DestnationClockT::now();
|
|
return std::chrono::time_point_cast<typename DestnationClockT::duration>(
|
|
timePoint - sourseClockNow + destinationClockNow);
|
|
}
|
|
|
|
/*
|
|
* Returns a number of seconds that passed from the UNIX Epoch starting time
|
|
* point to a given time point.
|
|
* Also known as POSIX time or UNIX Timestamp.
|
|
*/
|
|
static inline double telemetryTimePointToSecondsSinceEpoch(
|
|
TelemetryTimePoint timePoint) {
|
|
auto systemClockTimePoint =
|
|
clockCast<std::chrono::system_clock::time_point, TelemetryTimePoint>(
|
|
timePoint);
|
|
return (double)std::chrono::duration_cast<std::chrono::microseconds>(
|
|
systemClockTimePoint.time_since_epoch())
|
|
.count() /
|
|
1000000.0;
|
|
}
|
|
|
|
/*
|
|
* Returns a number of milliseconds that represents the given duration object.
|
|
*/
|
|
static inline int64_t telemetryDurationToMilliseconds(
|
|
TelemetryDuration duration) {
|
|
return std::chrono::duration_cast<std::chrono::milliseconds>(duration)
|
|
.count();
|
|
}
|
|
|
|
} // namespace facebook::react
|