Shift several device controller related variables to shared memory.
This commit is contained in:
parent
ef7932102f
commit
c724b5b9fb
@ -2,129 +2,107 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "tslib.h"
|
#include "tslib.h"
|
||||||
|
#include "shared_mem_buffer.h"
|
||||||
//#include "controlBus.h"
|
//#include "controlBus.h"
|
||||||
|
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
// control serial interface gui <--> serial
|
// control serial interface gui <--> serial
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static QString rs_comportName; // z.B. "COM48"
|
//static QString rs_comportName; // z.B. "COM48"
|
||||||
static QString rs_baudStr; // z.B. "19200"
|
//static QString rs_baudStr; // z.B. "19200"
|
||||||
static int rs_baudNr; //0...5 oder -1
|
//static int rs_baudNr; //0...5 oder -1
|
||||||
static uint8_t rs_connect; // 0,1
|
//static uint8_t rs_connect; // 0,1
|
||||||
|
|
||||||
void epi_setSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect)
|
void epi_setSerial(int BaudNr,
|
||||||
{
|
QString BaudStr,
|
||||||
// qDebug() << "ENTER" << BaudNr << BaudStr << ComName << connect;
|
QString ComName,
|
||||||
|
uint8_t connect) {
|
||||||
|
memset(&SharedMemBuffer::getData()->rs.comportName[0], 0x00,
|
||||||
|
sizeof(SharedMemBuffer::getData()->rs.comportName));
|
||||||
|
strncpy(SharedMemBuffer::getData()->rs.comportName,
|
||||||
|
ComName.toStdString().c_str(),
|
||||||
|
sizeof(SharedMemBuffer::getData()->rs.comportName)-1);
|
||||||
|
|
||||||
rs_comportName = ComName;
|
memset(&SharedMemBuffer::getData()->rs.baudStr[0], 0x00,
|
||||||
rs_baudStr = BaudStr;
|
sizeof(SharedMemBuffer::getData()->rs.baudStr));
|
||||||
rs_baudNr = BaudNr; // 0=1200 1=9600 2=19200 3=38400 4=57600 5=115200 oder -1
|
strncpy(SharedMemBuffer::getData()->rs.baudStr,
|
||||||
rs_connect = connect; // 0/1
|
BaudStr.toStdString().c_str(),
|
||||||
|
sizeof(SharedMemBuffer::getData()->rs.baudStr)-1);
|
||||||
|
|
||||||
// qDebug() << "LEAVE" << rs_baudNr << rs_baudStr << rs_comportName << rs_connect;
|
SharedMemBuffer::getData()->rs.baudNr = BaudNr;
|
||||||
|
SharedMemBuffer::getData()->rs.connect = connect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void epi_closeSerial(void)
|
void epi_closeSerial(void) {
|
||||||
{
|
SharedMemBuffer::getData()->rs.connect = 0;
|
||||||
rs_connect=0;
|
|
||||||
// qDebug() << "ENTER/LEAVE rc_connect=0";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void gpi_serialChanged(void)
|
void gpi_serialChanged(void) {
|
||||||
{
|
|
||||||
// serial confirms that port was closed or opened
|
// serial confirms that port was closed or opened
|
||||||
rs_connect=2; // Flanke, nur 1x öffnen/schließen
|
// rs_connect=2; // Flanke, nur 1x öffnen/schließen
|
||||||
//qDebug() << "ENTER/LEAVE rc_connect=2";
|
SharedMemBuffer::getData()->rs.connect = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t gpi_getSerialConn(void)
|
uint8_t gpi_getSerialConn(void) {
|
||||||
{
|
return SharedMemBuffer::getDataConst()->rs.connect;
|
||||||
return rs_connect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int gpi_getBaudNr(void)
|
int gpi_getBaudNr(void) {
|
||||||
{
|
return SharedMemBuffer::getDataConst()->rs.baudNr;
|
||||||
return rs_baudNr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString gpi_getComPortName(void)
|
QString gpi_getComPortName(void) {
|
||||||
{
|
return SharedMemBuffer::getDataConst()->rs.comportName;
|
||||||
return rs_comportName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool rs_portIsOpen;
|
void gpi_serialIsOpen(bool offen) {
|
||||||
|
SharedMemBuffer::getData()->rs.portIsOpen = offen;
|
||||||
void gpi_serialIsOpen(bool offen)
|
|
||||||
{
|
|
||||||
//qDebug() << "ENTER/LEAVE offen=" << offen;
|
|
||||||
rs_portIsOpen=offen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool epi_isSerialPortOpen()
|
bool epi_isSerialPortOpen() {
|
||||||
{
|
|
||||||
// true: port is open false: port is closed
|
// true: port is open false: port is closed
|
||||||
//qDebug() << "ENTER/LEAVE offen=" << rs_portIsOpen;
|
return SharedMemBuffer::getDataConst()->rs.portIsOpen;
|
||||||
return rs_portIsOpen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
// Control transfer gui <--> serial
|
// Control transfer gui <--> serial
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void epi_startEmmision(char start) {
|
||||||
static char AutoEmissionOn; // 1: zyklisch Anfragen zum Slave senden
|
SharedMemBuffer::getData()->AutoEmissionOn = start;
|
||||||
|
|
||||||
void epi_startEmmision(char start)
|
|
||||||
{
|
|
||||||
AutoEmissionOn=start;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gpi_isEmmisionOn(void)
|
bool gpi_isEmmisionOn(void) {
|
||||||
{
|
return SharedMemBuffer::getDataConst()->AutoEmissionOn;
|
||||||
return AutoEmissionOn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------
|
uint16_t gpi_getPeriodicSendTimeVal() {
|
||||||
|
SharedMemBuffer::getData()->datif.sendingPer_changed = 0;
|
||||||
static uint16_t datif_sendingPeriod;
|
if ((SharedMemBuffer::getDataConst()->datif.sendingPeriod < 3) ||
|
||||||
static bool datif_sendingPer_changed;
|
(SharedMemBuffer::getDataConst()->datif.sendingPeriod > 10000)) {
|
||||||
|
|
||||||
uint16_t gpi_getPeriodicSendTimeVal()
|
|
||||||
{
|
|
||||||
datif_sendingPer_changed=0;
|
|
||||||
if (datif_sendingPeriod<3 || datif_sendingPeriod>10000)
|
|
||||||
return 130; // ms, default
|
return 130; // ms, default
|
||||||
else
|
}
|
||||||
return datif_sendingPeriod;
|
return SharedMemBuffer::getDataConst()->datif.sendingPeriod;
|
||||||
}
|
}
|
||||||
|
|
||||||
void epi_setPeriodicSendTimeVal(uint16_t val)
|
void epi_setPeriodicSendTimeVal(uint16_t val) {
|
||||||
{
|
if (val>=3 && val<10000) {
|
||||||
if (val>=3 && val<10000)
|
SharedMemBuffer::getData()->datif.sendingPer_changed = 1;
|
||||||
{
|
SharedMemBuffer::getData()->datif.sendingPeriod = val;
|
||||||
datif_sendingPer_changed=1;
|
|
||||||
datif_sendingPeriod=val;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gpi_PeriodicSendTimeHasChanged()
|
bool gpi_PeriodicSendTimeHasChanged() {
|
||||||
{
|
return SharedMemBuffer::getDataConst()->datif.sendingPer_changed;
|
||||||
return datif_sendingPer_changed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------
|
|
||||||
|
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
// Status Display gui <--> serial
|
// Status Display gui <--> serial
|
||||||
// ///////////////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
// linke Spalte, über Connect Button
|
// linke Spalte, über Connect Button
|
||||||
static QString txt4comStateLine;
|
static QString txt4comStateLine;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user