supla-device
Loading...
Searching...
No Matches
factory_test.h
1/*
2 * Copyright (C) AC SOFTWARE SP. Z O.O
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#ifndef SRC_SUPLA_DEVICE_FACTORY_TEST_H_
20#define SRC_SUPLA_DEVICE_FACTORY_TEST_H_
21
22#include <supla/action_handler.h>
23#include <supla/element.h>
24
26
27namespace Supla {
28
29enum TestStage {
30 TestStage_None = 0,
31 TestStage_Init = 1,
32 TestStage_RegisteredAndReady = 2,
33 TestStage_WaitForCfgButton = 3,
34 TestStage_Failed = 4,
35 TestStage_Success = 5
36};
37
38enum TestActionType {
39 TestAction_CfgButtonOnPress = 11000,
40 TestAction_DeviceStatusChange = 11101
41};
42
43namespace Device {
44
45class FactoryTest : public Supla::ActionHandler, public Supla::Element {
46 public:
47 FactoryTest(SuplaDeviceClass *sdc, uint32_t timeoutS);
48 virtual ~FactoryTest();
49
50 void onInit() override;
51 void iterateAlways() override;
52 void handleAction(int event, int action) override;
53
54 virtual int16_t getManufacturerId();
55 virtual void waitForConfigButtonPress();
56 virtual bool checkTestStep();
57
58 void setTestFailed(int reason);
59 void setTestFinished();
60 Supla::TestStage getTestStage() const;
61
62 protected:
63 bool testFailed = false;
64 bool testFinished = false;
65 bool waitForRegisteredAndReady = true;
66 bool testingMachineEnabled = true;
67 SuplaDeviceClass *sdc = nullptr;
68 uint32_t timeoutS = 30;
69 uint32_t initTimestamp = 0;
70 Supla::TestStage testStage = Supla::TestStage_None;
71 int testStep = 0;
72 // fill fail reason for devices that can show it during the test
73 // Use values >= 100 for device specific failures
74 int failReason = 0;
75};
76
77} // namespace Device
78} // namespace Supla
79#endif // SRC_SUPLA_DEVICE_FACTORY_TEST_H_
Definition SuplaDevice.h:93
Definition action_handler.h:21
void iterateAlways() override
Method called on each SuplaDevice iteration.
Definition factory_test.cpp:143
void onInit() override
Third method called on element in SuplaDevice.begin()
Definition factory_test.cpp:43
Base class for all elements of SuplaDevice.
Definition element.h:33