C
Telltales: Rendering Safety-Critical UI
/**************************************************************************** ** ** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Safe Renderer module ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ** ** ** ** ** ** ** ****************************************************************************//* Purpose of this example is to enable development of Qt Safe Renderer in desktop environment (Windows and Linux). Note that this example is NOT implemented according Misra C++ 2008 nor ISO26262 functional safety standards and it depends on Qt classes. You should not use this example in production environment. */ #include <QtSafeRenderer/qsafelayout.h> #include <QtSafeRenderer/qsafelayoutresourcereader.h> #include <QtSafeRenderer/statemanager.h> #include <QtSafeRenderer/qsafechecksum.h> #include <QtSafeRenderer> #include "safewindow.h" #include "eventhandler.h" using namespace SafeRenderer; //Global pointer to access the EventHandler from the filterFunction. EventHandler *g_msgHandler = NULL; static bool handleHeartbeatEvent(const QSafeEvent &event) { bool eventHandled = false; //Handle EventHeartbeatTimeout event if ((g_msgHandler != NULL) && (EventHeartbeatTimeout == event.getEventId())) { eventHandled = true; QSafeEventHeartbeatTimeout timeout(event); bool showNotif = timeout.getValue(); //Show or hide the error notification. QSafeEventVisibility notification; notification.setId(qsafe_hash_string("safeText")); notification.setValue(showNotif); g_msgHandler->processEvent(notification); } return eventHandled; } int main(int argc, char **argv) { (void)argc; (void)argv; static QSafeLayoutResourceReader hybrid("/qtcluster/layoutData/DashboardForm/DashboardForm.ui.srl"); static QSafeLayoutResourceReader sport("/qtcluster/layoutData/DashboardSportForm/DashboardSportForm.ui.srl"); hybrid.setLayoutId(qsafe_hash_string("hybrid")); sport.setLayoutId(qsafe_hash_string("sport")); SafeWindow telltaleWindow(hybrid.size(), QSafePoint(0U, 0U)); static SafeRenderer::StateManager stateManager(telltaleWindow, hybrid); stateManager.addLayout(&sport); telltaleWindow.requestUpdate(); static EventHandler msgHandler(stateManager, telltaleWindow); g_msgHandler = &msgHandler; msgHandler.installEventFilter(&handleHeartbeatEvent); msgHandler.handleEvents(); return 0; }