mirror of
https://github.com/EEVengers/ThunderScope.git
synced 2025-04-22 17:43:44 +00:00
Working on triggering
This commit is contained in:
parent
bc49870f06
commit
15531a13c2
.gitignore
Software/waveview/scope_link
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,3 +6,5 @@ tags
|
||||
|
||||
# clangd compile commands generated by bear for clangd lsp use
|
||||
compile_commands.json
|
||||
compile_commands.commands.json
|
||||
.clangd
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
void SetCopyFunc(CopyFuncs Func);
|
||||
void stopHandler();
|
||||
|
||||
unsigned int bytesRead;//used for testing
|
||||
uint64_t bytesRead;//used for testing
|
||||
|
||||
EVSharedCache* threadSharedCache;
|
||||
|
||||
|
63
Software/waveview/scope_link/include/transferSpoof.hpp
Normal file
63
Software/waveview/scope_link/include/transferSpoof.hpp
Normal file
@ -0,0 +1,63 @@
|
||||
//
|
||||
// EVDataTransferThread.hpp
|
||||
// Scope
|
||||
//
|
||||
// Created by Daniel Vasile on 2019-07-30.
|
||||
// Copyright © 2019 EEVengers. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef transferSpoof_hpp
|
||||
#define transferSpoof_hpp
|
||||
|
||||
#include "EVLibrary.hpp"
|
||||
#include <atomic>
|
||||
#include <boost/lockfree/queue.hpp>
|
||||
#include "common.hpp"
|
||||
|
||||
enum CopyFuncs
|
||||
{
|
||||
DataTransferFullBuffRead
|
||||
};
|
||||
|
||||
/*
|
||||
Container class that encapsulates all data transfers that occur in this program.
|
||||
FTDIChip -> DataHandler
|
||||
DataHandler -> DigitalProcessingHandler
|
||||
DigitalProcessingHandler -> Electron app
|
||||
*/
|
||||
class transferSpoof
|
||||
{
|
||||
public:
|
||||
|
||||
transferSpoof(boost::lockfree::queue<buffer*, boost::lockfree::fixed_sized<false>> *outputQ);
|
||||
|
||||
uint64_t bytesRead;//used for testing
|
||||
|
||||
~transferSpoof();
|
||||
|
||||
void createThread();
|
||||
void destroyThread();
|
||||
|
||||
uint32_t getCount();
|
||||
uint32_t getCountBytes();
|
||||
void setCount(uint32_t);
|
||||
void clearCount();
|
||||
|
||||
private:
|
||||
boost::lockfree::queue<buffer*, boost::lockfree::fixed_sized<false>> *outputQueue;
|
||||
|
||||
void coreLoop();
|
||||
|
||||
std::atomic<bool> transferComplete;
|
||||
std::atomic<bool> threadExists;
|
||||
|
||||
std::thread handlerThread;
|
||||
|
||||
uint32_t count;
|
||||
|
||||
protected:
|
||||
|
||||
std::mutex lockThread;
|
||||
};
|
||||
|
||||
#endif
|
@ -76,10 +76,8 @@ void testTriggerThroughput()
|
||||
// Run loop
|
||||
while (newDataQueue.pop(currentBuffer)) {
|
||||
trigger.checkTrigger(currentBuffer);
|
||||
// if (trigger.checkTrigger(currentBuffer)) {
|
||||
// count++;
|
||||
// }
|
||||
}
|
||||
|
||||
count = trigger.countTriggered;
|
||||
|
||||
// Take Timestamp
|
||||
|
101
Software/waveview/scope_link/src/transferSpoof.cpp
Normal file
101
Software/waveview/scope_link/src/transferSpoof.cpp
Normal file
@ -0,0 +1,101 @@
|
||||
//
|
||||
// transferSpoof.cpp
|
||||
//
|
||||
// Created by Alex Vandenberg on 2020-11-08.
|
||||
// Copyright © 2020 EEVengers. All rights reserved.
|
||||
//
|
||||
|
||||
#include "transferSpoof.hpp"
|
||||
|
||||
transferSpoof::transferSpoof(boost::lockfree::queue<buffer*, boost::lockfree::fixed_sized<false>> *outputQ)
|
||||
{
|
||||
transferComplete.store(false);
|
||||
threadExists.store(false);
|
||||
|
||||
assert(outputQ != NULL);
|
||||
outputQueue = outputQ;
|
||||
|
||||
bytesRead = 0;
|
||||
|
||||
clearCount();
|
||||
}
|
||||
|
||||
void transferSpoof::coreLoop()
|
||||
{
|
||||
buffer* tempBuffer;
|
||||
uint8_t num = 0;
|
||||
boost::lockfree::queue<buffer*, boost::lockfree::fixed_sized<false>> tempQueue{1024};
|
||||
|
||||
for (uint32_t i = 0; i < 1024; i++) {
|
||||
tempBuffer = bufferAllocator.allocate(1);
|
||||
bufferAllocator.construct(tempBuffer);
|
||||
|
||||
for (uint32_t j = 0; j < BUFFER_SIZE; j++) {
|
||||
tempBuffer->data[i] = num;
|
||||
num++;
|
||||
}
|
||||
|
||||
tempQueue.push(tempBuffer);
|
||||
}
|
||||
|
||||
while (tempQueue.pop(tempBuffer)) {
|
||||
outputQueue->push(tempBuffer);
|
||||
count++;
|
||||
std::this_thread::sleep_for(std::chrono::nanoseconds(1));
|
||||
}
|
||||
transferComplete.store(true);
|
||||
}
|
||||
|
||||
void transferSpoof::createThread()
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(lockThread);
|
||||
|
||||
// Check it thread created
|
||||
if (threadExists.load() == false) {
|
||||
handlerThread = std::thread(&transferSpoof::coreLoop, this);
|
||||
threadExists.store(true);
|
||||
} else {
|
||||
// Thread already created
|
||||
throw EVException(10, "createThread(): Thread already created");
|
||||
}
|
||||
}
|
||||
|
||||
void transferSpoof::destroyThread()
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(lockThread);
|
||||
|
||||
if (threadExists.load() == true) {
|
||||
handlerThread.join();
|
||||
|
||||
// clear thread exists flag
|
||||
threadExists.store(false);
|
||||
} else {
|
||||
// Thread does not exist
|
||||
throw EVException(10, "createThread(): thread does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
transferSpoof::~transferSpoof()
|
||||
{
|
||||
handlerThread.join();
|
||||
}
|
||||
|
||||
uint32_t transferSpoof::getCount()
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
uint32_t transferSpoof::getCountBytes()
|
||||
{
|
||||
return getCount() * BUFFER_SIZE;
|
||||
}
|
||||
|
||||
void transferSpoof::setCount(uint32_t newCount)
|
||||
{
|
||||
count = newCount;
|
||||
}
|
||||
|
||||
void transferSpoof::clearCount()
|
||||
{
|
||||
setCount(0);
|
||||
}
|
Loading…
Reference in New Issue
Block a user