Commit 7f199704 authored by David Košenina's avatar David Košenina

thread api functions cleanup

parent 4464b45d
......@@ -69,14 +69,15 @@ int fileLoad(const char* fileName, char** buffer, ilarge* bufferSize)
return 0;
}
int fileLoadPtr(const char* fileName, char* buffer, ilarge bufferSize)
int fileLoadPtr(const char* fileName, char* buffer, ilarge* bufferSize)
{
SDL_RWops* ctx = SDL_RWFromFile(fileName, "rb");
if(!ctx)
{
return 1;
}
SDL_RWread(ctx, buffer, 1, bufferSize);
*bufferSize = min( *bufferSize, SDL_RWsize(ctx) );
SDL_RWread(ctx, buffer, 1, *bufferSize);
SDL_RWclose(ctx);
return 0;
}
......
......@@ -24,8 +24,8 @@
int fileLoadString(const char* fileName, char** string, ilarge* stringSize);
int fileSaveString(const char* fileName, char* string);
int fileLoad(const char* fileName, char** buffer, ilarge* bufferSize);
int fileLoadPtr(const char* fileName, char* buffer, ilarge bufferSize);
int fileLoad(const char* fileName, char** buffer, ilarge* bufferSize);
int fileLoadPtr(const char* fileName, char* buffer, ilarge* bufferSize);
int fileSave(const char* fileName, char* buffer, ilarge bufferSize);
int fileFree(char* memory);
......
......@@ -40,7 +40,7 @@ void OsciloskopConnection::m_choiceConnectionOnChoice(wxCommandEvent& event)
// TODO: Implement m_choiceConnectionOnChoice
if(m_choiceConnection->GetSelection() == 0)
{
sfSetUsb(getCtx());
pOsciloscope->thread.function(EThreadApiFunction::afSetUsb);
m_buttonConnect->Disable();
m_buttonDisconnect->Disable();
m_textCtrlIP->Disable();
......@@ -49,7 +49,7 @@ void OsciloskopConnection::m_choiceConnectionOnChoice(wxCommandEvent& event)
}
else
{
sfSetNetwork(getCtx());
pOsciloscope->thread.function(EThreadApiFunction::afSetNetwork);
m_buttonConnect->Enable();
m_buttonDisconnect->Enable();
m_textCtrlIP->Enable();
......@@ -76,8 +76,9 @@ void OsciloskopConnection::m_checkBoxConnectedOnCheckBox(wxCommandEvent& event)
void OsciloskopConnection::m_buttonConnectOnButtonClick(wxCommandEvent& event)
{
// TODO: Implement m_buttonConnectOnButtonClick
int ret = sfClientConnect(getCtx(), (const char*)m_textCtrlIP->GetValue(), (int)atoi(m_textCtrlPort->GetValue()));
sfServerUpload(getCtx());
pOsciloscope->thread.setIpPort((const char*)m_textCtrlIP->GetValue(), (int)atoi(m_textCtrlPort->GetValue()));
pOsciloscope->thread.function(EThreadApiFunction::afClientConnect);
pOsciloscope->thread.function(EThreadApiFunction::afServerUpload);
wxApp* app = (wxApp*)wxApp::GetInstance();
if(app)
{
......@@ -93,7 +94,7 @@ void OsciloskopConnection::m_buttonDisconnectOnButtonClick(wxCommandEvent& event
{
// TODO: Implement m_buttonDisconnectOnButtonClick
// disconnect first, becouse mode change has no affect then ...
sfClientDisconnect(getCtx());
pOsciloscope->thread.function(EThreadApiFunction::afClientDisconnect);
// automatic mode change
pOsciloscope->window.horizontal.Mode = SIGNAL_MODE_PAUSE;
pOsciloscope->signalMode = (SignalMode)pOsciloscope->window.horizontal.Mode;
......
......@@ -510,10 +510,10 @@ void OsciloskopOsciloskop::OnIdle(wxIdleEvent& event)
int open = 0;
if(pConnection)
{
open = SDL_AtomicGet(&pOsciloscope->isConnected);
open = pOsciloscope->thread.isConnected();
pConnection->setConnectedCheckBox(open);
}
int usb = SDL_AtomicGet(&pOsciloscope->isOpen);
int usb = pOsciloscope->thread.isOpen();
m_checkBox26->SetValue(usb);
}
// progress bar
......@@ -955,10 +955,8 @@ void OsciloskopOsciloskop::m_checkBoxETSOnCheckBox(wxCommandEvent& event)
pOsciloscope->redrawEts = 1;
pOsciloscope->clearRenderTarget = 1;
SDL_AtomicLock(&pOsciloscope->simLock);
pOsciloscope->simData = pOsciloscope->GetServerSim();
SDL_AtomicUnlock(&pOsciloscope->simLock);
SDL_AtomicSet(&pOsciloscope->transferSim, 1);
pOsciloscope->thread.setSimulateData( &pOsciloscope->GetServerSim() );
pOsciloscope->thread.function(EThreadApiFunction::afSetSimulateData);
}
void OsciloskopOsciloskop::m_checkBoxFullOnCheckBox(wxCommandEvent& event)
......@@ -1032,11 +1030,11 @@ void OsciloskopOsciloskop::m_textCtrlTimeFrameSizeOnTextEnter(wxCommandEvent& ev
int data = 0;
int packet = 0;
uint frameSize = 0;
sfServerDownload(getCtx());
sfGetFrameVersion(getCtx(), &version);
sfGetFrameHeader(getCtx(), &header);
sfGetFrameData(getCtx(), &data);
sfGetFramePacket(getCtx(), &packet);
pOsciloscope->thread.function(EThreadApiFunction::afServerDownload);
pOsciloscope->thread.wait();
pOsciloscope->thread.function(EThreadApiFunction::afGetFrame);
pOsciloscope->thread.wait();
pOsciloscope->thread.getFrame(&version, &header, &data, &packet);
frameSize = atoi(m_textCtrlTimeFrameSize->GetValue().ToAscii().data());
if(version == 1)
{
......@@ -1052,11 +1050,9 @@ void OsciloskopOsciloskop::m_textCtrlTimeFrameSizeOnTextEnter(wxCommandEvent& ev
pOsciloscope->window.horizontal.FrameSize = pOsciloscope->control.getSampleSize();
data = pOsciloscope->window.horizontal.FrameSize * 4;
}
sfSetFrameVersion(getCtx(), version);
sfSetFrameHeader(getCtx(), header);
sfSetFrameData(getCtx(), data);
sfSetFramePacket(getCtx(), packet);
sfServerUpload(getCtx());
pOsciloscope->thread.setFrame(version, header, data, packet);
pOsciloscope->thread.function(EThreadApiFunction::afSetFrame);
pOsciloscope->thread.function(EThreadApiFunction::afServerUpload);
m_textCtrlTimeFrameSize->SetValue(wxString::FromAscii(pFormat->integerToString(pOsciloscope->control.getSampleSize())));
pOsciloscope->control.transferData();
}
......@@ -1958,10 +1954,9 @@ void OsciloskopOsciloskop::m_comboBoxBit15OnCombobox(wxCommandEvent& event)
void OsciloskopOsciloskop::m_menuItemVersion1OnMenuSelection(wxCommandEvent& event)
{
SetDigital13To16(true);
sfSetFrameVersion(getCtx(), HARDWARE_VERSION_1);
sfSetFrameHeader(getCtx(), SCOPEFUN_FRAME_1_HEADER);
sfSetFrameData(getCtx(), SCOPEFUN_FRAME_1_DATA);
sfSetFramePacket(getCtx(), SCOPEFUN_FRAME_1_PACKET);
pOsciloscope->thread.setFrame(HARDWARE_VERSION_1, SCOPEFUN_FRAME_1_HEADER, SCOPEFUN_FRAME_1_DATA, SCOPEFUN_FRAME_1_PACKET);
pOsciloscope->thread.function(EThreadApiFunction::afSetFrame);
GetMenuBar()->GetMenu(8)->FindItemByPosition(0)->Check(1);
GetMenuBar()->GetMenu(8)->FindItemByPosition(1)->Check(0);
pOsciloscope->control.setVersion(HARDWARE_VERSION_1);
......@@ -1972,7 +1967,7 @@ void OsciloskopOsciloskop::m_menuItemVersion1OnMenuSelection(wxCommandEvent& eve
m_comboBoxTimeCapture->Append(captureTimeToStr(i));
}
m_comboBoxTimeCapture->SetSelection(pOsciloscope->control.getXRange());
sfServerUpload(getCtx());
pOsciloscope->thread.function(EThreadApiFunction::afServerUpload);
}
void OsciloskopOsciloskop::SetDigital13To16(bool enable)
......@@ -1998,17 +1993,13 @@ void OsciloskopOsciloskop::m_menuItemVersion2OnMenuSelection(wxCommandEvent& eve
int header = 0;
int data = 0;
int packet = 0;
sfGetFrameVersion(getCtx(), &version);
sfGetFrameHeader(getCtx(), &header);
sfGetFrameData(getCtx(), &data);
sfGetFramePacket(getCtx(), &packet);
pOsciloscope->thread.getFrame(&version, &header, &data, &packet);
version = HARDWARE_VERSION_2;
header = SCOPEFUN_FRAME_2_HEADER;
packet = pOsciloscope->window.storage.getPacketSize(HARDWARE_VERSION_2);
sfSetFrameVersion(getCtx(), version);
sfSetFrameHeader(getCtx(), header);
sfSetFrameData(getCtx(), data);
sfSetFramePacket(getCtx(), packet);
pOsciloscope->thread.setFrame(version, header, data, packet);
pOsciloscope->thread.function(EThreadApiFunction::afSetFrame);
GetMenuBar()->GetMenu(8)->FindItemByPosition(0)->Check(0);
GetMenuBar()->GetMenu(8)->FindItemByPosition(1)->Check(1);
pOsciloscope->control.setVersion(HARDWARE_VERSION_2);
......@@ -2019,7 +2010,7 @@ void OsciloskopOsciloskop::m_menuItemVersion2OnMenuSelection(wxCommandEvent& eve
m_comboBoxTimeCapture->Append(captureTimeToStr(i));
}
m_comboBoxTimeCapture->SetSelection(pOsciloscope->control.getXRange());
sfServerUpload(getCtx());
pOsciloscope->thread.function(EThreadApiFunction::afServerUpload);
// setupControl(pOsciloscope->window);
}
......@@ -2213,8 +2204,13 @@ void OsciloskopOsciloskop::m_menuItemReadEEPROMOnMenuSelection(wxCommandEvent& e
wxCommandEvent evt;
m_buttonPauseOnButtonClick(evt);
SEeprom eeprom;
int size = 0;
int offset = 0;
memset(eeprom.data.bytes, 0xdd, sizeof(SEeprom));
pOsciloscope->ReadEEPROM(eeprom);
pOsciloscope->thread.readUsbFromEEPROM(pOsciloscope->settings.getHardware());
pOsciloscope->thread.getEEPROM(&eeprom,&size,&offset);
wxCommandEvent et;
m_menuItemDebugOnMenuSelection(et);
if(pDebug && pDebug->IsShown())
......@@ -2232,24 +2228,27 @@ void OsciloskopOsciloskop::m_menuItemReadEEPROMOnMenuSelection(wxCommandEvent& e
void OsciloskopOsciloskop::m_menuItemWriteEEPROMOnMenuSelection(wxCommandEvent& event)
{
pOsciloscope->WriteEEPROM();
pOsciloscope->thread.writeUsbToEEPROM(pOsciloscope->settings.getHardware());
}
void OsciloskopOsciloskop::m_menuItemResetEEPROMOnMenuSelection(wxCommandEvent& event)
{
pOsciloscope->EraseEEPROM();
pOsciloscope->thread.eraseEEPROM(pOsciloscope->settings.getHardware());
}
void OsciloskopOsciloskop::m_buttonConnectOnButtonClick(wxCommandEvent& event)
{
pOsciloscope->connect();
pOsciloscope->thread.setUSB(&pOsciloscope->settings.getHardware()->getUSB());
pOsciloscope->thread.function(EThreadApiFunction::afOpenUsb);
}
void OsciloskopOsciloskop::m_buttonDisconnectOnButtonClick(wxCommandEvent& event)
{
pOsciloscope->disconnect();
pOsciloscope->signalMode = SIGNAL_MODE_PAUSE;
pOsciloscope->thread.function(EThreadApiFunction::afCloseUsb);
pOsciloscope->signalMode = SIGNAL_MODE_PAUSE;
pOsciloscope->window.horizontal.Mode = SIGNAL_MODE_PAUSE;
// must sync close button usbClose and usbCapture thread
// currrent fix is that we just wait a second which should be enought for the capture thread to exit capture state in most cases
SDL_Delay(1000);
......@@ -2258,7 +2257,7 @@ void OsciloskopOsciloskop::m_buttonDisconnectOnButtonClick(wxCommandEvent& event
void OsciloskopOsciloskop::m_buttonFirmwareUploadOnButtonClick(wxCommandEvent& event)
{
pOsciloscope->uploadFirmware();
pOsciloscope->thread.writeFpgaToArtix7( &pOsciloscope->control.control1.client1Get(), &pOsciloscope->control.control2.client2Get(), pOsciloscope->settings.getHardware());
}
void OsciloskopOsciloskop::m_choiceSpeedOnChoice(wxCommandEvent& event)
......@@ -2290,8 +2289,7 @@ void OsciloskopOsciloskop::m_choiceInputOutputOnChoice(wxCommandEvent& event)
pOsciloscope->control.setDigitalInputOutput(pOsciloscope->window.digitalSetup.inputOutput15, pOsciloscope->window.digitalSetup.inputOutput7);
pOsciloscope->control.transferData();
pOsciloscope->window.hardwareGenerator.uploadDigital();
int version = 0;
sfGetFrameVersion(getCtx(), &version);
int version = pOsciloscope->thread.getVersion();
if(m_choiceInputOutput->GetSelection() == 1)
{
m_choiceBit8->Disable();
......@@ -3202,18 +3200,35 @@ void OsciloskopOsciloskop::m_menuItemAutoCallibrateOnMenuSelection(wxCommandEven
}
void OsciloskopOsciloskop::m_menuItemReadCallibrateOnMenuSelection(wxCommandEvent& event)
{
int size = sizeof(OscHardware);
wxCommandEvent evt;
m_buttonPauseOnButtonClick(evt);
SEeprom eeprom;
int size = 0;
int offset = 0;
memset(eeprom.data.bytes, 0xdd, sizeof(SEeprom));
pOsciloscope->ReadCallibrate(eeprom);
pOsciloscope->thread.readCallibrateSettingsFromEEPROM(pOsciloscope->settings.getHardware());
pOsciloscope->thread.getEEPROM(&eeprom, &size, &offset);
wxCommandEvent et;
m_menuItemDebugOnMenuSelection(et);
if (pDebug && pDebug->IsShown())
{
pDebug->Clear();
FORMAT_BUFFER();
for (int i = 0; i < EEPROM_BYTE_COUNT; i++)
{
byte byteToPrint = eeprom.data.bytes[i];
FORMAT("%02x ", byteToPrint);
pDebug->AppendText(wxString::FromAscii(formatBuffer));
}
}
}
void OsciloskopOsciloskop::m_menuItemWriteCallibrateOnMenuSelection(wxCommandEvent& event)
{
pOsciloscope->settings.load();
pOsciloscope->WriteCallibrate();
pOsciloscope->thread.writeCallibrateSettingsToEEPROM(pOsciloscope->settings.getHardware());
}
......
......@@ -71,16 +71,12 @@ void OsciloskopStorage::m_choicePacketSizeOnChoice(wxCommandEvent& event)
int header = 0;
int data = 0;
int packet = 0;
sfGetFrameVersion(getCtx(), &version);
sfGetFrameHeader(getCtx(), &header);
sfGetFrameData(getCtx(), &data);
sfGetFramePacket(getCtx(), &packet);
pOsciloscope->thread.getFrame(&version, &header, &data, &packet);
packet = pOsciloscope->window.storage.getPacketSize(version);
sfSetFrameVersion(getCtx(), version);
sfSetFrameHeader(getCtx(), header);
sfSetFrameData(getCtx(), data);
sfSetFramePacket(getCtx(), packet);
sfServerUpload(getCtx());
pOsciloscope->thread.setFrame(version,header,data,packet);
pOsciloscope->thread.function(EThreadApiFunction::afSetFrame);
pOsciloscope->thread.function(EThreadApiFunction::afServerUpload);
}
void OsciloskopStorage::m_buttonOkOnButtonClick(wxCommandEvent& event)
......
......@@ -2152,31 +2152,9 @@ void OsciloscopeMainControl::setVersion(int ver)
}
void OsciloscopeMainControl::transferData()
{
SDL_AtomicLock(&lock);
if(version == 1)
{
hw1 = control1.client1Get();
}
if(version == 2)
{
hw2 = control2.client2Get();
}
SDL_AtomicSet(&pOsciloscope->transferData, 1);
SDL_AtomicUnlock(&lock);
}
void OsciloscopeMainControl::threadTransferData()
{
SDL_AtomicLock(&lock);
if (version == 1)
{
int ret = sfHardwareConfig1(getCtx(), &hw1);
}
if (version == 2)
{
int ret = sfHardwareConfig2(getCtx(), &hw2);
}
SDL_AtomicSet(&pOsciloscope->transferData, 0);
pOsciloscope->thread.hardwareControlFunction(&control1.client1Get(), &control2.client2Get());
SDL_AtomicUnlock(&lock);
}
......
......@@ -677,8 +677,7 @@ public:
return version;
};
public:
void transferData();
void threadTransferData();
void transferData();
public:
void setWindow(WndMain& main);
public:
......
This diff is collapsed.
......@@ -786,6 +786,123 @@ public:
void getDisplay(SDisplay* sim);
};
enum EThreadApiFunction {
afInit,
afOpenUsb,
afUploadFpga,
afUploadFxx,
afResetUsb,
afCloseUsb,
afEEPROMRead,
afEEPROMWrite,
afEEPROMErase,
afSetFrame,
afGetFrame,
afHardwareConfig1,
afHardwareConfig2,
afSimulate,
afSetSimulateData,
afSetSimulateOnOff,
afServerUpload,
afServerDownload,
afGetClientDisplay,
afUploadGenerator,
afSetUsb,
afSetNetwork,
afClientConnect,
afClientDisconnect,
};
class ThreadApi {
private:
SDL_SpinLock lock;
SDL_atomic_t sync;
Array<EThreadApiFunction,16> func;
SDL_atomic_t ret;
private:
SDL_atomic_t open;
SDL_atomic_t connected;
SDL_atomic_t simulate;
SDL_atomic_t vid;
SDL_atomic_t pid;
SDL_atomic_t sid;
SDL_atomic_t version;
SDL_atomic_t header;
SDL_atomic_t data;
SDL_atomic_t packet;
public:
SUsb usbData;
ilarge usbSize;
SFx2 fx2Data;
ilarge fx2Size;
SFpga fpgaData;
ilarge fpgaSize;
SEeprom eepromData;
ilarge eepromSize;
ilarge eepromOffset;
public:
String ip;
uint port;
uint memory;
uint threadSafe;
uint active;
uint timeout;
public:
double simulateTimeValue;
SSimulate simulateData;
SDL_atomic_t simulateOnOff;
SDisplay displayData;
SGenerator generatorData;
SHardware1 config1;
SHardware2 config2;
public:
ThreadApi();
public:
// thread
void function(EThreadApiFunction func);
void wait();
void update();
public:
// data
int getVersion();
int isOpen();
int isConnected();
int isSimulate();
void setInit(int memory, int thread, int active, int timeout);
void setFrame(int version, int header,int data,int packet);
void getFrame(int* version, int* header,int* data,int* packet);
void setUSB(SUsb* usb);
void getUSB(SUsb* usb);
void setConfig1(SHardware1* config);
void getConfig1(SHardware1* config);
void setConfig2(SHardware2* config);
void getConfig2(SHardware2* config);
void setEEPROM(SEeprom* data,int size,int offset);
void getEEPROM(SEeprom* data,int* size,int* offset);
void setSimulateData(SSimulate* sim);
void getSimulateData(SSimulate* sim);
void setGeneratorData(SGenerator* gen);
void getGeneratorData(SGenerator* gen);
void setSimulateOnOff(int onoff);
void getSimulateOnOff(int* onoff);
void setDisplay(SDisplay* display);
void getDisplay(SDisplay* display);
void setIpPort(const char* ip, uint port);
public:
// controlThread
int writeFpgaToArtix7(SHardware1* ctrl1, SHardware2* ctrl2, OscHardware* hw);
int writeUsbToEEPROM(OscHardware* hw);
int readUsbFromEEPROM(OscHardware* hw);
int writeCallibrateSettingsToEEPROM(OscHardware* hw);
int readCallibrateSettingsFromEEPROM(OscHardware* hw);
int eraseEEPROM(OscHardware* hw);
int simulateTime(double time);
int hardwareControlFunction(SHardware1* hw1, SHardware2* hw2);
public:
// captureThread
int captureFrameData(SFrameData* buffer,int toReceive,int* transfered,int type);
};
////////////////////////////////////////////////////////////////////////////////
//
// Osciloscope
......@@ -827,43 +944,11 @@ public:
bool serverActive;
SDL_Thread* serverThread;
public:
SEeprom eeprom;
SDL_SpinLock simLock;
SSimulate simData;
SDisplay customDisplayData;
SDL_atomic_t simEnable;
SDL_atomic_t simEnableValue;
SDL_atomic_t version;
SDL_atomic_t headerSize;
SDL_atomic_t maxData;
SDL_atomic_t packetSize;
SDL_atomic_t isConnected;
SDL_atomic_t isOpen;
SDL_atomic_t transferData;
SDL_atomic_t transferSim;
SDL_atomic_t customDisplayCh0;
SDL_atomic_t customDisplayCh1;
SDL_atomic_t customDisplayFun;
SDL_atomic_t customDisplayDig;
SDL_SpinLock customDisplayLock;
public:
SDL_SpinLock usbLock;
SDL_atomic_t aOpenUsb;
SDL_atomic_t aOpenUsbEeprom;
SDL_atomic_t aResetUsb;
SDL_atomic_t aUploadFpga;
SDL_atomic_t aUploadFx2;
SDL_atomic_t aUploadFx3;
SDL_atomic_t aUploadFirmware;
SDL_atomic_t aReadEEPROM;
SDL_atomic_t aWriteEEPROM;
SDL_atomic_t aReadCallibrate;
SDL_atomic_t aWriteCallibrate;
SDL_atomic_t aEraseEEPROM;
SDL_atomic_t aCloseUsb;
public:
SDL_Thread* pHardwareThread;
SDL_Thread* pCatureThread;
ThreadApi thread;
public:
SDL_Thread* pCaptureData;
SDL_Thread* pGenerateFrame;
SDL_Thread* pControlHardware;
SDL_Thread* pRenderThread;
SDL_Thread* aUpdateThread[MAX_THREAD];
public:
......@@ -960,7 +1045,9 @@ public:
Ring<OsciloscopeFrame> tmpHistory;
public:
bool renderThreadActive;
bool captureThreadActive;
bool captureDataThreadActive;
bool generateFrameThreadActive;
bool controlHardwareThreadActive;
bool updateThreadActive;
OsciloscopeFrame threadDisplay;
Ring<CapturePacket> threadHistory;
......@@ -987,35 +1074,6 @@ public:
int saveToFile(const char* file);
int loadFromFile(const char* file);
int convertToText(const char* file);
public:
void connect();
void disconnect();
public:
void openUsb(int eeprom = 0);
void resetUsb();
void uploadFpga();
void uploadFx2();
void uploadFx3();
void uploadFirmware();
void ReadEEPROM(SEeprom& out);
void WriteEEPROM();
void ReadCallibrate(SEeprom& out);
void WriteCallibrate();
void EraseEEPROM();
void closeUsb();
public:
void threadOpenUsb(int eeprom = 0);
void threadResetUsb();
void threadUploadFpga();
void threadUploadFx2();
void threadUploadFx3();
void threadUploadFirmware();
void threadReadEEPROM();
void threadWriteEEPROM();
void threadReadCallibrate();
void threadWriteCallibrate();
void threadEraseEEPROM();
void threadCloseUsb();
public:
int start();
int update(float dt);
......@@ -1048,17 +1106,14 @@ public:
void startUserInterface();
void stopUserInterface();
public:
void clientUploadGenerator(SGenerator& generator);
void clientUploadDisplay(SDisplay& display);
void clientUploadGenerator(SGenerator& generator);
void clientUploadDisplay(SDisplay& display);
public:
void setupControl(WndMain window);
public:
SSimulate GetServerSim();
void transmitSim(SSimulate& sim);
void threadTransmitSim();
public:
void simOnOff(int value);
void threadSimOnOff();
void simOnOff(int value);
};
SFContext* getCtx();
......
......@@ -1447,7 +1447,11 @@ void OsciloscopeThreadRenderer::renderAnalog(uint threadId, OsciloscopeThreadDat
////////////////////////////////////////////////////////////////////////////////
// double freq
////////////////////////////////////////////////////////////////////////////////
int version = SDL_AtomicGet(&pOsciloscope->version);
int version = 0;
int header = 0;
int data = 0;
int packet = 0;
pOsciloscope->thread.getFrame(&version,&header,&data,&packet);
uint doubleFreq = 0;
if(version == HARDWARE_VERSION_2 && wndMain.horizontal.ETS == 0)
{
......
......@@ -184,10 +184,7 @@ uint CaptureMemory::save(const char* path, uint& progress, uint& active)
int frameHeader = 0;
int frameData = 0;
int framePacket = 0;
sfGetFrameVersion(getCtx(), &version);
sfGetFrameHeader(getCtx(), &frameHeader);
sfGetFrameData(getCtx(), &frameData);
sfGetFramePacket(getCtx(), &framePacket);
pOsciloscope->thread.getFrame(&version, &frameHeader, &frameData, &framePacket);
CaptureHeader header;
header.hwVersion = version;
header.hwHeader = frameHeader;
......@@ -245,10 +242,7 @@ uint CaptureMemory::load(const char* path, uint& progress, uint& active)
int frameHeader = 0;
int frameData = 0;
int framePacket = 0;
sfGetFrameVersion(getCtx(), &version);
sfGetFrameHeader(getCtx(), &frameHeader);
sfGetFrameData(getCtx(), &frameData);
sfGetFramePacket(getCtx(), &framePacket);
pOsciloscope->thread.getFrame(&version, &frameHeader, &frameData, &framePacket);
// offset
CaptureHeader header;
SDL_RWops* ctxRead = SDL_RWFromFile(path, "rb");
......@@ -361,10 +355,7 @@ uint CaptureSSD::save(const char* path, uint& progress, uint& active)
int frameHeader = 0;
int frameData = 0;
int framePacket = 0;
sfGetFrameVersion(getCtx(), &version);
sfGetFrameHeader(getCtx(), &frameHeader);
sfGetFrameData(getCtx(), &frameData);
sfGetFramePacket(getCtx(), &framePacket);
pOsciloscope->thread.getFrame(&version, &frameHeader, &frameData, &framePacket);
CaptureHeader header;
header.hwVersion = version;
header.hwHeader = frameHeader;
......@@ -423,10 +414,7 @@ uint CaptureSSD::load(const char* path, uint& progress, uint& active)
int frameHeader = 0;
int frameData = 0;
int framePacket = 0;
sfGetFrameVersion(getCtx(), &version);
sfGetFrameHeader(getCtx(), &frameHeader);
sfGetFrameData(getCtx(), &frameData);
sfGetFramePacket(getCtx(), &framePacket);
pOsciloscope->thread.getFrame(&version, &frameHeader, &frameData, &framePacket);
// offset
CaptureHeader header;
SDL_RWops* ctxRead = SDL_RWFromFile(path, "rb");
......
......@@ -120,7 +120,7 @@ uint multiplyerFromValue(float value)
const char* captureTimeToStr(int enumerated)
{
int version = SDL_AtomicGet(&pOsciloscope->version);
int version = pOsciloscope->thread.getVersion();
if(version == 1)
{
switch(enumerated)
......@@ -355,7 +355,7 @@ double captureTimeFromEnumVersion(int enumerated, int version)
ECallibrationType getCallibrationType(int enumerated)
{
int version = SDL_AtomicGet(&pOsciloscope->version);
int version = pOsciloscope->thread.getVersion();
if(version == 2 && enumerated == t2c2ns)
{
return ct500Mhz;
......@@ -365,7 +365,7 @@ ECallibrationType getCallibrationType(int enumerated)
ECallibrationType getCallibrationType(float value)
{
int version = SDL_AtomicGet(&pOsciloscope->version);
int version = pOsciloscope->thread.getVersion();
if(version == 2 && captureTimeFromValue(value) == t2c2ns)
{
return ct500Mhz;
......@@ -375,13 +375,13 @@ ECallibrationType getCallibrationType(float value)
double captureTimeFromEnum(int enumerated)
{
int version = SDL_AtomicGet(&pOsciloscope->version);
int version = pOsciloscope->thread.getVersion();
return captureTimeFromEnumVersion(enumerated, version);
}
uint captureTimeFromValue(float value)
{
int version = SDL_AtomicGet(&pOsciloscope->version);
int version = pOsciloscope->thread.getVersion();
if(version == 1)
{
if(value < 20.f * NANO)
......
......@@ -328,12 +328,14 @@ void WndHardwareGenerator::loadCustomDigital(const char* path)
void WndHardwareGenerator::upload()
{