| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of the Falcon Player (FPP) and is Copyright (C) | ||
| 3 | * 2013-2022 by the Falcon Player Developers. | ||
| 4 | * | ||
| 5 | * The Falcon Player (FPP) is free software, and is covered under | ||
| 6 | * multiple Open Source licenses. Please see the included 'LICENSES' | ||
| 7 | * file for descriptions of what files are covered by each license. | ||
| 8 | * | ||
| 9 | * This source file is covered under the LGPL v2.1 as described in the | ||
| 10 | * included LICENSE.LGPL file. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include "fpp-pch.h" | ||
| 14 | |||
| 15 | #include "fpp-json.h" | ||
| 16 | |||
| 17 | #include "../log.h" | ||
| 18 | |||
| 19 | #include "SingleChase.h" | ||
| 20 | |||
| 21 | /* | ||
| 22 | * | ||
| 23 | */ | ||
| 24 | 6 | TestPatternSingleChase::TestPatternSingleChase() : | |
| 25 | 6 | m_chaseSize(0), | |
| 26 | 6 | m_chaseValue(255) { | |
| 27 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | LogExcess(VB_CHANNELOUT, "TestPatternSingleChase::TestPatternSingleChase()\n"); |
| 28 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | m_testPatternName = "SingleChase"; |
| 29 | 6 | } | |
| 30 | |||
| 31 | /* | ||
| 32 | * | ||
| 33 | */ | ||
| 34 | 20 | TestPatternSingleChase::~TestPatternSingleChase() { | |
| 35 | 10 | LogExcess(VB_CHANNELOUT, "TestPatternSingleChase::~TestPatternSingleChase()\n"); | |
| 36 | 20 | } | |
| 37 | |||
| 38 | /* | ||
| 39 | * | ||
| 40 | */ | ||
| 41 | 6 | int TestPatternSingleChase::Init(Json::Value config) { | |
| 42 | 6 | m_configChanged = 0; | |
| 43 | |||
| 44 |
2/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
6 | int chaseSize = JsonInt(config, "chaseSize"); |
| 45 | // SetupTest() steps through the channels by the chase size and | ||
| 46 | // CycleData() reads the channel one chase size in, so a size below 1 | ||
| 47 | // looped forever (0) or wrote before the test buffer (negative), and one | ||
| 48 | // past the buffer read beyond it. 2 is the smallest the API offers. | ||
| 49 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
|
6 | if (chaseSize < 2 || chaseSize > FPPD_MAX_CHANNELS) { |
| 50 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | LogWarn(VB_CHANNELOUT, "Single Channel Chase size %d is out of range, using %d\n", |
| 51 | chaseSize, chaseSize < 2 ? 2 : (int)FPPD_MAX_CHANNELS); | ||
| 52 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | chaseSize = chaseSize < 2 ? 2 : FPPD_MAX_CHANNELS; |
| 53 | } | ||
| 54 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | if (m_chaseSize != chaseSize) { |
| 55 | 6 | m_chaseSize = chaseSize; | |
| 56 | 6 | m_configChanged = 1; | |
| 57 | } | ||
| 58 | |||
| 59 |
2/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
6 | int chaseValue = JsonInt(config, "chaseValue"); |
| 60 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | if (m_chaseValue != chaseValue) { |
| 61 | 6 | m_chaseValue = chaseValue; | |
| 62 | 6 | m_configChanged = 1; | |
| 63 | } | ||
| 64 | |||
| 65 |
2/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
6 | return TestPatternBase::Init(config); |
| 66 | } | ||
| 67 | |||
| 68 | /* | ||
| 69 | * | ||
| 70 | */ | ||
| 71 | 6 | int TestPatternSingleChase::SetupTest(void) { | |
| 72 | 6 | uint8_t* c = (uint8_t*)m_testData; | |
| 73 | 6 | bzero(m_testData, m_channelCount); | |
| 74 | |||
| 75 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 6 times.
|
32 | for (int i = 0; i < m_channelCount; i += m_chaseSize) { |
| 76 | 26 | *c = m_chaseValue; | |
| 77 | 26 | c += m_chaseSize; | |
| 78 | } | ||
| 79 | |||
| 80 | 6 | return TestPatternBase::SetupTest(); | |
| 81 | } | ||
| 82 | |||
| 83 | /* | ||
| 84 | * | ||
| 85 | */ | ||
| 86 | 34 | void TestPatternSingleChase::CycleData(void) { | |
| 87 | 34 | memmove(m_testData + 1, m_testData, m_channelCount - 1); | |
| 88 | |||
| 89 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 24 times.
|
34 | if (m_testData[m_chaseSize] == m_chaseValue) |
| 90 | 10 | m_testData[0] = m_chaseValue; | |
| 91 | else | ||
| 92 | 24 | m_testData[0] = 0x00; | |
| 93 | 34 | } | |
| 94 | |||
| 95 | /* | ||
| 96 | * | ||
| 97 | */ | ||
| 98 | 6 | void TestPatternSingleChase::DumpConfig(void) { | |
| 99 | 6 | LogDebug(VB_CHANNELOUT, "TestPatternSingleChase::DumpConfig\n"); | |
| 100 | 6 | LogDebug(VB_CHANNELOUT, " chaseSize : %d\n", m_chaseSize); | |
| 101 | 6 | LogDebug(VB_CHANNELOUT, " chaseValue : %d (0x%x)\n", | |
| 102 | (unsigned char)m_chaseValue, (unsigned char)m_chaseValue); | ||
| 103 | |||
| 104 | 6 | TestPatternBase::DumpConfig(); | |
| 105 | 6 | } | |
| 106 |