void ScreenEdge::update(bool force) { m_screenEdgeTimeFirst = xTime(); m_screenEdgeTimeLast = xTime(); m_screenEdgeTimeLastTrigger = xTime(); m_currentScreenEdge = ElectricNone; QRect r = QRect(0, 0, displayWidth(), displayHeight()); m_screenEdgeTop = r.top(); m_screenEdgeBottom = r.bottom(); m_screenEdgeLeft = r.left(); m_screenEdgeRight = r.right(); for (int pos = 0; pos < ELECTRIC_COUNT; ++pos) { if (force || m_screenEdgeReserved[pos] == 0) { if (m_screenEdgeWindows[pos] != None) XDestroyWindow(display(), m_screenEdgeWindows[pos]); m_screenEdgeWindows[pos] = None; } if (m_screenEdgeReserved[pos] == 0) { continue; } if (m_screenEdgeWindows[pos] != None) continue; XSetWindowAttributes attributes; attributes.override_redirect = True; attributes.event_mask = EnterWindowMask | LeaveWindowMask; unsigned long valuemask = CWOverrideRedirect | CWEventMask; int xywh[ELECTRIC_COUNT][4] = { { r.left() + 1, r.top(), r.width() - 2, 1 }, // Top { r.right(), r.top(), 1, 1 }, // Top-right { r.right(), r.top() + 1, 1, r.height() - 2 }, // Etc. { r.right(), r.bottom(), 1, 1 }, { r.left() + 1, r.bottom(), r.width() - 2, 1 }, { r.left(), r.bottom(), 1, 1 }, { r.left(), r.top() + 1, 1, r.height() - 2 }, { r.left(), r.top(), 1, 1 } }; m_screenEdgeWindows[pos] = XCreateWindow(display(), rootWindow(), xywh[pos][0], xywh[pos][1], xywh[pos][2], xywh[pos][3], 0, CopyFromParent, InputOnly, CopyFromParent, valuemask, &attributes); XMapWindow(display(), m_screenEdgeWindows[pos]); // Set XdndAware on the windows, so that DND enter events are received (#86998) Atom version = 4; // XDND version XChangeProperty(display(), m_screenEdgeWindows[pos], atoms->xdnd_aware, XA_ATOM, 32, PropModeReplace, (unsigned char*)(&version), 1); } }
void Group::updateUserTime( Time time ) { // copy of Client::updateUserTime if( time == CurrentTime ) time = xTime(); if( time != -1U && ( user_time == CurrentTime || timestampCompare( time, user_time ) > 0 )) // time > user_time user_time = time; }
/*! Updates the user time (time of last action in the active window). This is called inside kwin for every action with the window that qualifies for user interaction (clicking on it, activate it externally, etc.). */ void Client::updateUserTime( Time time ) { // copied in Group::updateUserTime if( time == CurrentTime ) time = xTime(); if( time != -1U && ( user_time == CurrentTime || timestampCompare( time, user_time ) > 0 )) // time > user_time user_time = time; group()->updateUserTime( user_time ); }
/*! Updates the user time (time of last action in the active window). This is called inside kwin for every action with the window that qualifies for user interaction (clicking on it, activate it externally, etc.). */ void Client::updateUserTime(Time time) { // copied in Group::updateUserTime if (time == CurrentTime) time = xTime(); if (time != -1U && (user_time == CurrentTime || timestampCompare(time, user_time) > 0)) { // time > user_time user_time = time; shade_below = NULL; // do not hover re-shade a window after it got interaction } group()->updateUserTime(user_time); }
bool grabXKeyboard(Window w) { if (QWidget::keyboardGrabber() != NULL) return false; if (keyboard_grabbed) return false; if (qApp->activePopupWidget() != NULL) return false; if (w == None) w = rootWindow(); if (XGrabKeyboard(display(), w, False, GrabModeAsync, GrabModeAsync, xTime()) != GrabSuccess) return false; keyboard_grabbed = true; return true; }
// Big Dot operation uint32_t getBigDot(uint32_t tablePbx, uint32_t tableInvPbx) { int i; unsigned char xTimeStorage[8]; unsigned char returnVal = 0; unsigned char bitMask = 0x1; xTimeStorage[0] = tablePbx; for (i = 1; i < 8; i++) { xTimeStorage[i] = xTime(xTimeStorage[i - 1]); } for(i = 0; i < 8; i++) { if ((tableInvPbx & bitMask) == bitMask) { returnVal ^= xTimeStorage[i]; } bitMask <<= 1; } return returnVal; }
bool grabXKeyboard(xcb_window_t w) { if (QWidget::keyboardGrabber() != NULL) return false; if (keyboard_grabbed) return false; if (qApp->activePopupWidget() != NULL) return false; if (w == XCB_WINDOW_NONE) w = rootWindow(); const xcb_grab_keyboard_cookie_t c = xcb_grab_keyboard_unchecked(connection(), false, w, xTime(), XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC); ScopedCPointer<xcb_grab_keyboard_reply_t> grab(xcb_grab_keyboard_reply(connection(), c, NULL)); if (grab.isNull()) { return false; } if (grab->status != XCB_GRAB_STATUS_SUCCESS) { return false; } keyboard_grabbed = true; return true; }
void Dialog::mkSensorModel() { QCPGraph * gr; QPen pn; double simTime = 60.0; double simStepTime = 0.1; double tempStart = 25.0; double tempCurrent = tempStart; double tempSet = 35.0; double tempDeltaPrev = 0.0; int normalFixDeep = 5; int steps = simTime / simStepTime; QVector<double> xTime(steps), yTemp(steps), yTempSet(steps); QVector<double> normalValues(normalFixDeep); normalValues.fill(0); QVector<double> tempLabels; for (int x=10; x<=50; x+=5) tempLabels.push_back(x); QVector<double> timeLabels; for (int x=0; x<=simTime; x+=5) timeLabels.push_back(x); for (int x=0; x<steps; x++) { // Calc new temp value double tempApply = 0.0; // No change double tempDelta = std::abs(tempCurrent - tempSet); double stepDir = (tempCurrent < tempSet) ? 1.0 : -1.0; if (0.1 < tempDelta) { if (tempDelta > 10) { tempApply = 0.19 * 1.0; } else { tempApply = 0.2 * (1.0 * (tempDelta/10.0) ); } // if (tempApply < 0.01) tempApply = 0.01; // qDebug() << tempApply; tempApply = tempApply * stepDir; // Calc normalzied value double lastSum = 0; for (int x=0; x<normalFixDeep; x++) lastSum += normalValues[x]; tempApply = (lastSum + tempApply) / ((double)normalFixDeep + 1.0); tempDeltaPrev = tempApply; tempCurrent = tempCurrent + tempApply; qDebug() << tempCurrent; } normalValues.push_back(tempApply); normalValues.pop_front(); xTime[x] = (double)x * simStepTime; if (10.0 == xTime[x]) tempSet = 40.0; if (40.0 == xTime[x]) tempSet = 30.0; yTempSet[x] = tempSet; yTemp[x] = tempCurrent; } gr = ui->plot->addGraph(); gr->setData(xTime, yTemp); pn.setColor(Qt::red); pn.setWidth(3); gr->setPen(pn); gr->setName("Реальное значение"); gr = ui->plot->addGraph(); gr->setData(xTime, yTempSet); pn.setColor(0x008080); pn.setWidth(1); pn.setStyle(Qt::DashLine); gr->setPen(pn); gr->setName("Конечное значение"); ui->plot->xAxis->setLabel("Время, сек"); ui->plot->xAxis->setRange(0, simTime); ui->plot->xAxis->setAutoTicks(false); ui->plot->xAxis->setTickVector(timeLabels); ui->plot->yAxis->setLabel("Температура, °C"); ui->plot->yAxis->setRange(20, 50); ui->plot->yAxis->setAutoTicks(false); ui->plot->yAxis->setTickVector(tempLabels); ui->plot->legend->setVisible(true); ui->plot->replot(); ui->plot->savePdf("graph-boiler.pdf", false, 800, 400); }
void encrypt(unsigned char PlainText[4][4], unsigned char Key[4][4], unsigned char CipherText[4][4]) { /************************************************ ******************Directives******************** ************************************************/ /************************************************ ****************Source Code********************* ************************************************/ unsigned char StateArray [4][4]; unsigned char ExpandedKey[11][4][4]; unsigned char TempKeyCol[4]; //static int i,j; // Encryption Key copied to Expanded Key [0] for(int i=0; i<4; i++) { for(int j=0; j<4; j++) { ExpandedKey[0][i][j] = Key[i][j]; } } // ExpandKey(Key, ExpandedKey); for (int i=1; i<11; i++){ // W3 copied to TempKeyRow with rotation TempKeyCol[0]=ExpandedKey[i-1][1][3]; TempKeyCol[1]=ExpandedKey[i-1][2][3]; TempKeyCol[2]=ExpandedKey[i-1][3][3]; TempKeyCol[3]=ExpandedKey[i-1][0][3]; // sBox applied TempKeyCol[0]=SBox[ TempKeyCol[0] ]; TempKeyCol[1]=SBox[ TempKeyCol[1] ]; TempKeyCol[2]=SBox[ TempKeyCol[2] ]; TempKeyCol[3]=SBox[ TempKeyCol[3] ]; // Rcon applied TempKeyCol[0]^=RCon[i-1]; // XOR for(int j=0; j<4; j++){ TempKeyCol[0] = TempKeyCol[0]^ExpandedKey[i-1][0][j]; TempKeyCol[1] = TempKeyCol[1]^ExpandedKey[i-1][1][j]; TempKeyCol[2] = TempKeyCol[2]^ExpandedKey[i-1][2][j]; TempKeyCol[3] = TempKeyCol[3]^ExpandedKey[i-1][3][j]; ExpandedKey[i][0][j] = TempKeyCol[0]; ExpandedKey[i][1][j] = TempKeyCol[1]; ExpandedKey[i][2][j] = TempKeyCol[2]; ExpandedKey[i][3][j] = TempKeyCol[3]; } } for(int i=0; i<4; i++) { for(int j=0; j<4; j++) { StateArray[i][j] = PlainText[i][j]; } } // AddRoundKey(ExpandedKey[0], StateArray); for(int i=0; i<4; i++) for(int j=0; j<4; j++) StateArray[i][j] ^= ExpandedKey[0][i][j]; // Rounds for(int r=1; r<=10; r++){ // SubBytes(StateArray); for(int i=0; i<4; i++) for(int j=0; j<4; j++) StateArray[i][j] = SBox[StateArray[i][j]]; // ShiftRows(StateArray); unsigned char x; // Row#1 - rotate 1 column to the left x = StateArray[1][0]; StateArray[1][0] = StateArray[1][1]; StateArray[1][1] = StateArray[1][2]; StateArray[1][2] = StateArray[1][3]; StateArray[1][3] = x; // Row#2 - rotate 2 column to the left x = StateArray[2][0]; StateArray[2][0] = StateArray[2][2]; StateArray[2][2] = x; x = StateArray[2][1]; StateArray[2][1] = StateArray[2][3]; StateArray[2][3] = x; // Row#3 - rotate 3 column to the left x = StateArray[3][3]; StateArray[3][3] = StateArray[3][2]; StateArray[3][2] = StateArray[3][1]; StateArray[3][1] = StateArray[3][0]; StateArray[3][0] = x; if(r!=10){ // MixColumns(StateArray); unsigned char StateArrayTmp[4][4]; for(int i=0;i<4;i++){ StateArrayTmp[0][i] = xTime(StateArray[0][i])^xTime(StateArray[1][i])^StateArray[1][i]^ StateArray[2][i]^StateArray[3][i]; StateArrayTmp[1][i] = StateArray[0][i]^xTime(StateArray[1][i])^xTime(StateArray[2][i])^ StateArray[2][i]^StateArray[3][i]; StateArrayTmp[2][i] = StateArray[0][i]^StateArray[1][i]^xTime(StateArray[2][i])^ xTime(StateArray[3][i])^StateArray[3][i]; StateArrayTmp[3][i] = xTime(StateArray[0][i])^StateArray[0][i]^StateArray[1][i]^ StateArray[2][i]^xTime(StateArray[3][i]); } // memcpy(StateArray, StateArrayTmp, 4 * 4 * sizeof(unsigned char)); for(int i=0; i<4; i++) { for(int j=0; j<4; j++) { StateArray[i][j] = StateArrayTmp[i][j]; } } } // AddRoundKey(ExpandedKey[i], StateArray); for(int i=0; i<4; i++) for(int j=0; j<4; j++) StateArray[i][j] ^= ExpandedKey[r][i][j]; } for(int i=0; i<4; i++) { for(int j=0; j<4; j++) { CipherText[i][j] = StateArray[i][j]; } } }