Add internal support for panel test modes, and rename "test mode" to "sensor test mode" to make the distinction clearer.
This commit is contained in:
parent
63e76f29cc
commit
ce261c1ecb
15
sdk/SMX.h
15
sdk/SMX.h
@ -12,6 +12,7 @@
|
|||||||
struct SMXInfo;
|
struct SMXInfo;
|
||||||
struct SMXConfig;
|
struct SMXConfig;
|
||||||
enum SensorTestMode;
|
enum SensorTestMode;
|
||||||
|
enum PanelTestMode;
|
||||||
enum SMXUpdateCallbackReason;
|
enum SMXUpdateCallbackReason;
|
||||||
struct SMXSensorTestModeData;
|
struct SMXSensorTestModeData;
|
||||||
|
|
||||||
@ -101,10 +102,15 @@ SMX_API void SMX_FactoryReset(int pad);
|
|||||||
// for diagnostics.
|
// for diagnostics.
|
||||||
SMX_API void SMX_ForceRecalibration(int pad);
|
SMX_API void SMX_ForceRecalibration(int pad);
|
||||||
|
|
||||||
// Set a panel test mode and request test data. This is used by the configuration tool.
|
// Set a sensor test mode and request test data. This is used by the configuration tool.
|
||||||
SMX_API void SMX_SetTestMode(int pad, SensorTestMode mode);
|
SMX_API void SMX_SetTestMode(int pad, SensorTestMode mode);
|
||||||
SMX_API bool SMX_GetTestData(int pad, SMXSensorTestModeData *data);
|
SMX_API bool SMX_GetTestData(int pad, SMXSensorTestModeData *data);
|
||||||
|
|
||||||
|
// Set a panel test mode. These only appear as debug lighting on the panel and don't
|
||||||
|
// return data to us. Lights can't be updated while a panel test mode is active.
|
||||||
|
// This applies to all connected pads.
|
||||||
|
SMX_API void SMX_SetPanelTestMode(PanelTestMode mode);
|
||||||
|
|
||||||
// Return the build version of the DLL, which is based on the git tag at build time. This
|
// Return the build version of the DLL, which is based on the git tag at build time. This
|
||||||
// is only intended for diagnostic logging, and it's also the version we show in SMXConfig.
|
// is only intended for diagnostic logging, and it's also the version we show in SMXConfig.
|
||||||
SMX_API const char *SMX_Version();
|
SMX_API const char *SMX_Version();
|
||||||
@ -291,4 +297,11 @@ struct SMXSensorTestModeData
|
|||||||
bool iBadJumper[9][4];
|
bool iBadJumper[9][4];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// The values also correspond with the protocol and must not be changed.
|
||||||
|
// These are panel-side diagnostics modes.
|
||||||
|
enum PanelTestMode {
|
||||||
|
PanelTestMode_Off = '0',
|
||||||
|
PanelTestMode_PressureTest = '1',
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -62,8 +62,10 @@ SMX_API void SMX_GetInfo(int pad, SMXInfo *info) { SMXManager::g_pSMX->GetDevice
|
|||||||
SMX_API uint16_t SMX_GetInputState(int pad) { return SMXManager::g_pSMX->GetDevice(pad)->GetInputState(); }
|
SMX_API uint16_t SMX_GetInputState(int pad) { return SMXManager::g_pSMX->GetDevice(pad)->GetInputState(); }
|
||||||
SMX_API void SMX_FactoryReset(int pad) { SMXManager::g_pSMX->GetDevice(pad)->FactoryReset(); }
|
SMX_API void SMX_FactoryReset(int pad) { SMXManager::g_pSMX->GetDevice(pad)->FactoryReset(); }
|
||||||
SMX_API void SMX_ForceRecalibration(int pad) { SMXManager::g_pSMX->GetDevice(pad)->ForceRecalibration(); }
|
SMX_API void SMX_ForceRecalibration(int pad) { SMXManager::g_pSMX->GetDevice(pad)->ForceRecalibration(); }
|
||||||
SMX_API void SMX_SetTestMode(int pad, SensorTestMode mode) { SMXManager::g_pSMX->GetDevice(pad)->SetSensorTestMode((SensorTestMode) mode); }
|
SMX_API void SMX_SetTestMode(int pad, SensorTestMode mode) { SMXManager::g_pSMX->GetDevice(pad)->SetSensorTestMode(mode); }
|
||||||
SMX_API bool SMX_GetTestData(int pad, SMXSensorTestModeData *data) { return SMXManager::g_pSMX->GetDevice(pad)->GetTestData(*data); }
|
SMX_API bool SMX_GetTestData(int pad, SMXSensorTestModeData *data) { return SMXManager::g_pSMX->GetDevice(pad)->GetTestData(*data); }
|
||||||
|
SMX_API void SMX_SetPanelTestMode(PanelTestMode mode) { SMXManager::g_pSMX->SetPanelTestMode(mode); }
|
||||||
|
|
||||||
SMX_API void SMX_SetLights(const char lightData[864])
|
SMX_API void SMX_SetLights(const char lightData[864])
|
||||||
{
|
{
|
||||||
SMX_SetLights2(lightData, 864);
|
SMX_SetLights2(lightData, 864);
|
||||||
|
@ -359,7 +359,7 @@ void SMX::SMXDevice::Update(wstring &sError)
|
|||||||
|
|
||||||
CheckActive();
|
CheckActive();
|
||||||
SendConfig();
|
SendConfig();
|
||||||
UpdateTestMode();
|
UpdateSensorTestMode();
|
||||||
|
|
||||||
{
|
{
|
||||||
uint16_t iOldState = m_pConnection->GetInputState();
|
uint16_t iOldState = m_pConnection->GetInputState();
|
||||||
@ -396,7 +396,7 @@ void SMX::SMXDevice::CheckActive()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if we need to request test mode data.
|
// Check if we need to request test mode data.
|
||||||
void SMX::SMXDevice::UpdateTestMode()
|
void SMX::SMXDevice::UpdateSensorTestMode()
|
||||||
{
|
{
|
||||||
m_Lock.AssertLockedByCurrentThread();
|
m_Lock.AssertLockedByCurrentThread();
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ private:
|
|||||||
bool IsConnectedLocked() const;
|
bool IsConnectedLocked() const;
|
||||||
|
|
||||||
// Test/diagnostics mode handling.
|
// Test/diagnostics mode handling.
|
||||||
void UpdateTestMode();
|
void UpdateSensorTestMode();
|
||||||
void HandleSensorTestDataResponse(const string &sReadBuffer);
|
void HandleSensorTestDataResponse(const string &sReadBuffer);
|
||||||
SensorTestMode m_WaitingForSensorTestModeResponse = SensorTestMode_Off;
|
SensorTestMode m_WaitingForSensorTestModeResponse = SensorTestMode_Off;
|
||||||
SensorTestMode m_SensorTestMode = SensorTestMode_Off;
|
SensorTestMode m_SensorTestMode = SensorTestMode_Off;
|
||||||
|
@ -135,6 +135,9 @@ void SMX::SMXManager::ThreadMain()
|
|||||||
// since this actually just queues commands, which are actually handled in Update.
|
// since this actually just queues commands, which are actually handled in Update.
|
||||||
SendLightUpdates();
|
SendLightUpdates();
|
||||||
|
|
||||||
|
// Send panel test mode commands if needed.
|
||||||
|
UpdatePanelTestMode();
|
||||||
|
|
||||||
// See if there are any new devices.
|
// See if there are any new devices.
|
||||||
AttemptConnections();
|
AttemptConnections();
|
||||||
|
|
||||||
@ -246,6 +249,10 @@ void SMX::SMXManager::SetLights(const string sPanelLights[2])
|
|||||||
g_Lock.AssertNotLockedByCurrentThread();
|
g_Lock.AssertNotLockedByCurrentThread();
|
||||||
LockMutex L(g_Lock);
|
LockMutex L(g_Lock);
|
||||||
|
|
||||||
|
// Don't send lights when a panel test mode is active.
|
||||||
|
if(m_PanelTestMode != PanelTestMode_Off)
|
||||||
|
return;
|
||||||
|
|
||||||
// Separate top and bottom lights commands.
|
// Separate top and bottom lights commands.
|
||||||
//
|
//
|
||||||
// sPanelLights[iPad] is
|
// sPanelLights[iPad] is
|
||||||
@ -491,6 +498,43 @@ void SMX::SMXManager::SendLightUpdates()
|
|||||||
m_aPendingLightsCommands.erase(m_aPendingLightsCommands.begin(), m_aPendingLightsCommands.begin()+1);
|
m_aPendingLightsCommands.erase(m_aPendingLightsCommands.begin(), m_aPendingLightsCommands.begin()+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SMX::SMXManager::SetPanelTestMode(PanelTestMode mode)
|
||||||
|
{
|
||||||
|
g_Lock.AssertNotLockedByCurrentThread();
|
||||||
|
LockMutex Lock(g_Lock);
|
||||||
|
m_PanelTestMode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SMX::SMXManager::UpdatePanelTestMode()
|
||||||
|
{
|
||||||
|
// If the test mode has changed, send the new test mode.
|
||||||
|
//
|
||||||
|
// When the test mode is enabled, send the test mode again periodically, or it'll time
|
||||||
|
// out on the master and be turned off. Don't repeat the PanelTestMode_Off command.
|
||||||
|
g_Lock.AssertLockedByCurrentThread();
|
||||||
|
uint32_t now = GetTickCount();
|
||||||
|
if(m_PanelTestMode == m_LastSentPanelTestMode &&
|
||||||
|
(m_PanelTestMode == PanelTestMode_Off || now - m_SentPanelTestModeAtTicks < 1000))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// When we first send the test mode command (not for repeats), turn off lights.
|
||||||
|
if(m_LastSentPanelTestMode == PanelTestMode_Off)
|
||||||
|
{
|
||||||
|
// The 'l' command used to set lights, but it's now only used to turn lights off
|
||||||
|
// for cases like this.
|
||||||
|
string sData = "l";
|
||||||
|
sData.append(108, 0);
|
||||||
|
sData += "\n";
|
||||||
|
for(int iPad = 0; iPad < 2; ++iPad)
|
||||||
|
m_pDevices[iPad]->SendCommandLocked(sData);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_SentPanelTestModeAtTicks = now;
|
||||||
|
m_LastSentPanelTestMode = m_PanelTestMode;
|
||||||
|
for(int iPad = 0; iPad < 2; ++iPad)
|
||||||
|
m_pDevices[iPad]->SendCommandLocked(ssprintf("t %c\n", m_PanelTestMode));
|
||||||
|
}
|
||||||
|
|
||||||
void SMX::SMXManager::RunInHelperThread(function<void()> func)
|
void SMX::SMXManager::RunInHelperThread(function<void()> func)
|
||||||
{
|
{
|
||||||
m_UserCallbackThread.RunInThread(func);
|
m_UserCallbackThread.RunInThread(func);
|
||||||
|
@ -45,6 +45,7 @@ public:
|
|||||||
shared_ptr<SMXDevice> GetDevice(int pad);
|
shared_ptr<SMXDevice> GetDevice(int pad);
|
||||||
void SetLights(const string sLights[2]);
|
void SetLights(const string sLights[2]);
|
||||||
void ReenableAutoLights();
|
void ReenableAutoLights();
|
||||||
|
void SetPanelTestMode(PanelTestMode mode);
|
||||||
|
|
||||||
// Run a function in the user callback thread.
|
// Run a function in the user callback thread.
|
||||||
void RunInHelperThread(function<void()> func);
|
void RunInHelperThread(function<void()> func);
|
||||||
@ -76,6 +77,13 @@ private:
|
|||||||
};
|
};
|
||||||
vector<PendingCommand> m_aPendingLightsCommands;
|
vector<PendingCommand> m_aPendingLightsCommands;
|
||||||
double m_fDelayLightCommandsUntil = 0;
|
double m_fDelayLightCommandsUntil = 0;
|
||||||
|
|
||||||
|
// Panel test mode. This is separate from the sensor test mode (pressure display),
|
||||||
|
// which is handled in SMXDevice.
|
||||||
|
void UpdatePanelTestMode();
|
||||||
|
uint32_t m_SentPanelTestModeAtTicks = 0;
|
||||||
|
PanelTestMode m_PanelTestMode = PanelTestMode_Off;
|
||||||
|
PanelTestMode m_LastSentPanelTestMode = PanelTestMode_Off;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user