Commit 95f53c54 authored by Gertulla, Janis Luca's avatar Gertulla, Janis Luca
Browse files

Hotfix 3

parent bbed0e57
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.13.1, 2020-10-09T13:24:40. -->
<!-- Written by QtCreator 4.13.1, 2020-10-09T15:08:38. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
......
......@@ -124,7 +124,7 @@ void Client::handleData()
if(data.length() < msgLen + 2)
{
emit log("partial data: " + QString::number(data.length()) + "uint8_ts");
emit log("partial data: " + QString::number(data.length()) + " bytes");
return;
}
else
......
......@@ -41,8 +41,8 @@ uint8_t R0_1 = 6;
uint8_t R0_2 = 7;
uint8_t R0_3 = 8;
uint8_t R0_4 = 9;
uint8_t R0_5 = 10;
uint8_t R0_6 = 11;
uint8_t R0_5 = 12;
uint8_t R0_6 = 13;
#endif
......@@ -253,14 +253,14 @@ void write_bools(byte **buf, bool b1, bool b2, bool b3, bool b4, bool b5, bool b
void read_bools(byte **buf, bool *b1, bool *b2, bool *b3, bool *b4, bool *b5, bool *b6, bool *b7, bool *b8)
{
if(b1) *b1 = (**buf & 1 << 7) ? true : false;
if(b2) *b2 = (**buf & 1 << 6) ? true : false;
if(b3) *b3 = (**buf & 1 << 5) ? true : false;
if(b4) *b4 = (**buf & 1 << 4) ? true : false;
if(b5) *b5 = (**buf & 1 << 3) ? true : false;
if(b6) *b6 = (**buf & 1 << 2) ? true : false;
if(b7) *b7 = (**buf & 1 << 1) ? true : false;
if(b8) *b8 = (**buf & 1 << 0) ? true : false;
if(b1) *b1 = (**buf & (1 << 7)) ? true : false;
if(b2) *b2 = (**buf & (1 << 6)) ? true : false;
if(b3) *b3 = (**buf & (1 << 5)) ? true : false;
if(b4) *b4 = (**buf & (1 << 4)) ? true : false;
if(b5) *b5 = (**buf & (1 << 3)) ? true : false;
if(b6) *b6 = (**buf & (1 << 2)) ? true : false;
if(b7) *b7 = (**buf & (1 << 1)) ? true : false;
if(b8) *b8 = (**buf & (1 << 0)) ? true : false;
(*buf)++;
}
......@@ -290,10 +290,12 @@ void measure_turbopumps()
void handle_message(client_t &client)
{
byte msg_type;
byte msg_len;
byte *local = client.data;
byte **p = &local;
read_byte(p, &msg_type);
read_byte(p, &msg_type);
read_byte(p, &msg_len);
if( msg_type == 0 ) // ping
{
......@@ -323,42 +325,42 @@ void handle_message(client_t &client)
// change rules
if(req_state.sysOverride != new_state.sysOverride)
if(req_state.sysOverride != current_state.sysOverride)
{
new_state.sysOverride = req_state.sysOverride;
}
else if(req_state.linked != new_state.linked)
else if(req_state.linked != current_state.linked)
{
new_state.linked = req_state.linked;
}
else if(req_state.pGratActive != new_state.pGratActive)
else if(req_state.pGratActive != current_state.pGratActive)
{
new_state.pGratActive = req_state.pGratActive;
}
else if(req_state.pMcpActive != new_state.pMcpActive)
else if(req_state.pMcpActive != current_state.pMcpActive)
{
new_state.pMcpActive = req_state.pMcpActive;
}
else if(req_state.pVvActive != new_state.pVvActive)
else if(req_state.pVvActive != current_state.pVvActive)
{
new_state.pVvActive = req_state.pVvActive;
}
else if(req_state.tDetActive != new_state.tDetActive)
else if(req_state.tDetActive != current_state.tDetActive)
{
new_state.tDetActive = req_state.tDetActive;
}
else if(req_state.tDpsActive != new_state.tDpsActive)
else if(req_state.tDpsActive != current_state.tDpsActive)
{
new_state.tDpsActive = req_state.tDpsActive;
}
else if(req_state.vTdetOpen != new_state.vTdetOpen)
else if(req_state.vTdetOpen != current_state.vTdetOpen)
{
if(req_state.vTdetOpen == false)
{
......@@ -366,7 +368,7 @@ void handle_message(client_t &client)
}
else
{
if(new_state.sysOverride || !(new_state.tDetActive && (tp_states[TP_DET] < t_det_cutoff)))
if(current_state.sysOverride || !(current_state.tDetActive && (tp_states[TP_DET] < t_det_cutoff)))
{
new_state.vTdetOpen = true;
}
......@@ -388,13 +390,13 @@ void handle_message(client_t &client)
}
else
{
if(new_state.sysOverride ||
!((new_state.tDetActive && (tp_states[TP_DET] < t_det_cutoff)
|| (new_state.pGratActive && (gauge_pressures[GRAT] > p_grat_cutoff))
|| (new_state.pMcpActive && (gauge_pressures[MCP] > p_mcp_cutoff)))))
if(current_state.sysOverride ||
!((current_state.tDetActive && (tp_states[TP_DET] < t_det_cutoff)
|| (current_state.pGratActive && (gauge_pressures[GRAT] > p_grat_cutoff))
|| (current_state.pMcpActive && (gauge_pressures[MCP] > p_mcp_cutoff)))))
{
new_state.vDetOpen = true;
if(new_state.linked) {
if(current_state.linked) {
new_state.vFoilOpen = false;
}
}
......@@ -410,16 +412,16 @@ void handle_message(client_t &client)
if(req_state.vFoilOpen == true)
{
new_state.vFoilOpen = true;
if(new_state.linked){
if(current_state.linked){
new_state.vDetOpen = false;
}
}
else
{
if(new_state.sysOverride || !(new_state.pGratActive && (gauge_pressures[GRAT] > p_grat_cutoff)))
if(current_state.sysOverride || !(current_state.pGratActive && (gauge_pressures[GRAT] > p_grat_cutoff)))
{
new_state.vFoilOpen = false;
if(new_state.linked){
if(current_state.linked){
new_state.vDetOpen = true;
}
}
......@@ -438,7 +440,7 @@ void handle_message(client_t &client)
}
else
{
if(new_state.sysOverride || !(new_state.pGratActive && (gauge_pressures[GRAT] > p_grat_cutoff)))
if(current_state.sysOverride || !(current_state.pGratActive && (gauge_pressures[GRAT] > p_grat_cutoff)))
{
new_state.vDpsOpen = true;
}
......@@ -458,7 +460,7 @@ void handle_message(client_t &client)
}
else
{
if(new_state.sysOverride || !(new_state.pGratActive && (gauge_pressures[GRAT] > p_grat_cutoff)))
if(current_state.sysOverride || !(current_state.pGratActive && (gauge_pressures[GRAT] > p_grat_cutoff)))
{
new_state.pumpEnabled = true;
}
......@@ -529,12 +531,12 @@ void write_state(byte *msg)
write_bools(p, current_state.sysOverride, current_state.linked,
current_state.pGratActive, current_state.pMcpActive, current_state.pVvActive,
current_state.tDetActive, current_state.tDpsActive,
0);
false);
write_bools(p, current_state.vTdetOpen, current_state.vDetOpen, current_state.vFoilOpen, current_state.vDpsOpen,
current_state.hvmcpHigh, current_state.rbeamlineHigh,
current_state.pumpEnabled,
0);
false);
}
void send_state(EthernetClient &client)
......@@ -657,11 +659,11 @@ bool update_state()
if(current_state.hvmcpHigh == false) {
updated = true;
}
current_state.hvmcpHigh= true;
current_state.hvmcpHigh = true;
}
else
{
if(current_state.hvmcpHigh == true) updated = false;
if(current_state.hvmcpHigh == true) updated = true;
current_state.hvmcpHigh = false;
}
......@@ -744,7 +746,7 @@ void setup()
RS232.begin( 9600 );
#endif
log( NONE, "UE49Interlock starting up...\n" );
log( NONE, "UE49Interlock v0.2 starting up...\n" );
log( NETWORK, "Setting up Ethernet\n" );
......
......@@ -2,6 +2,7 @@
#define LIB_H
#include <QtCore>
#include <QLabel>
#include <memory>
enum MsgType
{
......
......@@ -35,7 +35,6 @@ MainTab::MainTab(QWidget *parent) : QWidget(parent), ui(std::make_unique<Ui::Mai
connect(ui->pumpStartButton, &QPushButton::clicked, this, &MainTab::onPumpStartButtonClicked);
connect(ui->linkButton, &QPushButton::clicked, this, &MainTab::onLinkButtonClicked);
connect(ui->tDetActive, &QCheckBox::stateChanged, this, &MainTab::onTDetActiveCheckboxClicked);
connect(ui->tDpsActive, &QCheckBox::stateChanged, this, &MainTab::onTDpsActiveCheckboxClicked);
}
......@@ -87,7 +86,6 @@ void MainTab::onNewState(PlcState &msg)
ui->pumpRunningLabel->setText(state->pumpEnabled ? "RUNNING" : "STOPPED");
ui->pumpStartButton->setText(state->pumpEnabled ? "STOP" : "START");
ui->tDetActive->setCheckState(state->tDetActive ? Qt::Checked : Qt::Unchecked);
ui->tDpsActive->setCheckState(state->tDpsActive ? Qt::Checked : Qt::Unchecked);
}
void MainTab::onDisconnect()
......@@ -221,16 +219,3 @@ void MainTab::onTDetActiveCheckboxClicked(int val)
emit log("Error: not connected.");
}
}
void MainTab::onTDpsActiveCheckboxClicked(int val)
{
// if(connected)
// {
// PlcState newStat(state.get());
// newStat.tDpsActive = val ? 1 : 0;
// emit sendState(newStat);
// }
// else
// {
// emit log("Error: not connected.");
// }
}
#ifndef MAINTAB_H
#define MAINTAB_H
#include <memory>
#include <QWidget>
#include <QPushButton>
......@@ -79,7 +78,6 @@ private slots:
void onPumpStartButtonClicked();
void onTDetActiveCheckboxClicked(int state);
void onTDpsActiveCheckboxClicked(int state);
};
......
......@@ -624,7 +624,7 @@
<property name="geometry">
<rect>
<x>110</x>
<y>540</y>
<y>570</y>
<width>88</width>
<height>22</height>
</rect>
......@@ -633,19 +633,6 @@
<string>tDet</string>
</property>
</widget>
<widget class="QCheckBox" name="tDpsActive">
<property name="geometry">
<rect>
<x>110</x>
<y>580</y>
<width>88</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>tDPS</string>
</property>
</widget>
</widget>
<resources>
<include location="visuals.qrc"/>
......
......@@ -59,7 +59,7 @@ Window::Window(QWidget *parent) : QMainWindow(parent), ui(std::make_unique<Ui::W
connect(ui->settings, &SettingsTab::log, this, &Window::log);
log("UE49Interlock v0.1 Setup finished!");
log("UE49Interlock v0.2 Setup finished!");
}
Window::~Window()
......@@ -92,7 +92,7 @@ void Window::onSystembarOverrideButtonClicked()
newState.override = !newState.override;
if(newState.override){
bool ok;
auto input = QInputDialog::getText(this, tr("Override Password"), tr("password:"), QLineEdit::Normal, "", &ok);
auto input = QInputDialog::getText(this, tr("Override Password"), tr("password:"), QLineEdit::Password, "", &ok);
if(ok)
{
if(input == "Grace4"){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment