text
stringlengths
65
6.05M
lang
stringclasses
8 values
type
stringclasses
2 values
id
stringlengths
64
64
// code formatter id shift alt f - don't use it unless it can be modded to meet the standards used in my code // note the todo items in this file and make the changes indicated /* Note Note Note Note Note Note Note */ // Name: Merged-Box-Azimuth_Encoder // Created: 5-10-21 // Author: Paul Kirk // if it's required to set a home point or park point marker A_Counter is the variable which must be set. // see below for north, east, south, west values for A_Counter // for any position X degrees the tick position to set for A_counter is ticksperDomeRev / (360/ x ) // there are 26.25 rotations of the encoder wheel for one complete rotation of the pulsar dome. // in a previous version without the toothed wheel around the perimeter, 26 encoder wheel revolutions equalled 10413 encoder ticks // from which it can bee calculated that 1 encoder wheel rev equates to 400.5 ticks. // so in the pulsar system with the toothed wheel around the perimeter, it takes 26.25 revs of the encoder wheel for 1 dome rotation // In terms of ticks therefore, the total number of ticks for a Pulsar dome revolution is 26.25 * 400.5 = 10513 // North = 0 // East = ticksperDomeRev/4 // South = ticksperDomeRev/2 // West = ticksperDomeRev*3/4 - no its not. #include <avr/cpufunc.h> /* Required header file */ #include <Arduino.h> #include <SPI.h> // SET UP AS SPI SLAVE // from microchip example below #include <avr/io.h> #include <avr/interrupt.h> // function declarations void encoder(); void interrupt(); void EastSync(); void WestSync(); bool PowerForCamera(bool State); void resetViaSWR(); void lightup(); static void SPI0_init(void); // end function declarations // encoder: #define A_PHASE 2 // USES PINS 2 AND 3 for encoder interrupt #define B_PHASE 13 #define NorthPin 18 #define EastPin 28 // changed for SPI #define SouthPin 20 #define WestPin 29 // changed for spi #define CameraPower 10 #define off false #define on true #define ledPin 12 // change for spi // #define ASCOM Serial #define Monitor Serial2 // encoder: // should this be set for 261 degrees? Otherwise the driver will request a move to 261 which will move the aperture out of alignment with the parked dome (and scope) // the position for 261 is set in Setup() below to reflect this. volatile long A_Counter; // volatile because it's used in the interrupt routine volatile bool homeFlag; // General String pkversion = "4.0"; float Azimuth; // The data type is important to avoid integer arithmetic in the encoder() routine uint16_t integerAzimuth; // this is what is returned to the stepper routine by SPI - just to avoid the complication of sending float over SPI // and also because we really don't need fractional degrees for dome movement. float SyncAz; volatile int azcount; long Sendcount = 0; long pkstart = 0; /* just trying to get the value below as close as possible. One full dome rev at ticksperdomerev = 10513 was 2 degrees out - started at 260 and the same point after one full rev was 262. Spreadsheet gives 1 degree = 29 ticks (at 10513 per rev), so try reducing by 60 as below. */ float ticksperDomeRev = 25880; //was 10513 (changed 20/4/22) this was worked out empirically by counting the number of encoder wheel rotations for one dome rev. 11-9-21 long calltime = 0; bool cameraPowerState = off; // to be returned via SPI to the Stepper routine - the bytes represent the Azimuth volatile byte highByteReturn; volatile byte lowByteReturn; // to hold the incoming request from master volatile char SPIReceipt; void setup() { pinMode(NorthPin, INPUT_PULLUP); // these are 4 microswitches for syncing the encoder pinMode(EastPin, INPUT_PULLUP); pinMode(SouthPin, INPUT_PULLUP); pinMode(WestPin, INPUT_PULLUP); pinMode(ledPin, OUTPUT); pinMode(CameraPower, OUTPUT); //turn the camera power of at startup: digitalWrite (CameraPower, LOW); // LOW is camera power OFF // notes for serial comms - ASCOM.begin(19200); // with ASCOM driver refer to DIP 40 pinout to get correct pin numbers for all the serial ports - see the google doc - 'Pin config for Radio Encoder MCU' Monitor.begin(19200); // Serial comms with monitor program // encoder: pinMode(A_PHASE, INPUT_PULLUP); pinMode(B_PHASE, INPUT_PULLUP); // pins 2,3,18,19,20,21 are the only pins available to use with interrupts on the mega2560 (no pin limit)restrictions on 4809) attachInterrupt(digitalPinToInterrupt(A_PHASE), interrupt, RISING); // interrupt for the encoder device // interupts for the azimuth syncs below attachInterrupt(digitalPinToInterrupt(EastPin), EastSync, RISING); attachInterrupt(digitalPinToInterrupt(WestPin), WestSync, FALLING); azcount = 0; A_Counter = ticksperDomeRev / (360.0 / 261.0); // the position of due west - 261 for the dome when the scope is at 270. PowerForCamera(off); // camera power is off by default // delay(15000); //THIS DELAY is set to give the operator time to open com12 (ASCOM port) to check if the message below arrives tested ok 22/11/21 // ASCOM.print("MCU RESET"); // SPI stuff - NOTE that the encoder is the SPI slave SPI0_init(); // interrupt for SPI servicing // SPI.attachInterrupt(); // send data on MISO // pinMode (MISO, OUTPUT); sei(); /* Enable Global Interrupts */ // the code below flashes LED five times causing 5 second delay lightup(); } // end setup void loop() { // Serial.println("HERE"); encoder(); // Serial.println(String(Azimuth) + "# "); // Serial.println(String(remA_counter)); // delay(1000); if (ASCOM.available() > 0) // request from ASCOM Driver { // Serial.print("A_Counter "); // Serial.println(A_Counter); encoder(); String ReceivedData = ""; //The code below gives a visual indication of ASCOM - just toggles LED each time an ASCOM request is received if (digitalRead(ledPin) == LOW) { digitalWrite(ledPin, HIGH); // ASCOM.println("Setting HIGH"); } else { digitalWrite(ledPin, LOW); // ASCOM.println("Setting LOW"); } ReceivedData = ASCOM.readStringUntil('#'); // Serial.print("received "); // Serial.println(ReceivedData ); if (ReceivedData.indexOf("AZ", 0) > -1) // { ASCOM.print(String(Azimuth) + "#"); } // Sync to Azimuth code below: if (ReceivedData.indexOf("STA", 0) > -1) // { ReceivedData.remove(0, 3); // strip 1st three chars SyncAz = ReceivedData.toFloat(); if ((SyncAz > 0.0) && (SyncAz <= 360.0)) // check for a valid azimuth value { // now work out the tick position for this azimuth A_Counter = ticksperDomeRev / (360 / SyncAz); } // endif } // endif // todo - test the code segment below from the DOME driver if (ReceivedData.indexOf( "azimuth", 0) >-1) { ASCOM.print("azimuth#"); // this is to respond to MCU identification query request from the ASCOM DOME driver - used by the driver to identify the ASCOM comport in use } } if (Monitor.available() > 0) // Monitor is comms with the windows forms arduino monitoring app { String MonitorData = Monitor.readStringUntil('#'); //todo remove line below // ASCOM.print(MonitorData); if (MonitorData.indexOf("monitorencoder", 0) > -1) // THIS IS THE MONITOR PROGRAM INTERROGATING TO CHECK IT IS IN COMMS WITH THE CORRECT mcu { // in this case we return encoder# to indicate this is the correct MCU Monitor.print("monitorencoder#"); } if (MonitorData.indexOf("reset", 0) > -1) // { //todo remove two lines below ASCOM.print("resetting"); delay(1000); resetViaSWR(); } if (MonitorData.indexOf("CAMON", 0) > -1) // { PowerForCamera(on); } if (MonitorData.indexOf("CAMOFF", 0) > -1) // { PowerForCamera(off); } if (MonitorData.indexOf("EncoderRequest", 0) > -1) { if (azcount > 240) { azcount = 0; } // endif Monitor.print(String(Azimuth) + "#" + String(azcount) + "#"); // write the two monitoring values to the windows forms Arduino Monitor program // Monitor.print(String(azcount) + "#"); // check status of the power to the camera and print to monitor program if (cameraPowerState) { Monitor.print("ON#"); } else { Monitor.print("OFF#"); } } // Endif } // endif } // end void loop void encoder() { // Encoder: if (A_Counter < 0) { A_Counter = A_Counter + ticksperDomeRev; // set the counter floor value } if (A_Counter > ticksperDomeRev) // set the counter ceiling value { A_Counter = A_Counter - ticksperDomeRev; } Azimuth = float(A_Counter) / (ticksperDomeRev / 360.0); // (ticks for one dome rev) / 360 (degrees) - about 29 // i.e number of ticks per degree // some error checking if (Azimuth < 1) { Azimuth = 1.0; } if (Azimuth > 360.0) { Azimuth = 360.0; } // now store the float azimuth into an uint16_t and for the highbyte and lowbyte for spi transmission to the Stepper routine integerAzimuth = Azimuth; // REMEMBER Azimuth needs to be float due to effects of integer arithmetic. lowByteReturn = lowByte(integerAzimuth); highByteReturn = highByte(integerAzimuth); } // end void encoder // interrupt used by the encoder: void interrupt() // Interrupt function { char i, j; i = digitalRead(B_PHASE); j = digitalRead(A_PHASE); if (i == j) { A_Counter -= 1; } else { A_Counter += 1; // increment the counter which represents increasing dome angle } // end else clause } // end void interrupt void EastSync() { A_Counter = ticksperDomeRev / 4.0; } void WestSync() //this acts as the home position { A_Counter = ticksperDomeRev / (360.0 / 261.0); // set the azimuth to 261 degrees (west) homeFlag= true; // set this for transmission to the stepper when home is found } bool PowerForCamera(bool State) { if (State) { digitalWrite(CameraPower, HIGH); // cameraPowerState = on; } else { digitalWrite(CameraPower, LOW); //NB as above cameraPowerState = off; } } void resetViaSWR() { _PROTECTED_WRITE(RSTCTRL.SWRR, 1); } void lightup() { for (int i = 0; i < 5; i++) { digitalWrite(ledPin, HIGH); delay(1000); digitalWrite(ledPin, LOW); delay(1000); } } // SPI interrupt routine ISR(SPI0_INT_vect) // was this in arduino -> (SPI_STC_vect) { SPIReceipt = SPI0.DATA; if (SPIReceipt == 'A') // a dummy transaction which loads the SPDR with the low byte { // in readiness for the 'L' transaction SPI0.DATA = lowByteReturn; } if (SPIReceipt == 'L') // low byte is returned and SPDR is loaded with the high byte { // in readiness for the 'H' transaction SPI0.DATA = highByteReturn; } if (SPIReceipt == 'H') // High byte is returned and SPDR is loaded with homeflag { // in readiness for the 'S' transaction SPI0.DATA = homeFlag; // sends status of the home position true if at the home position i.e. the sensor has been activated } if (SPIReceipt == 'S') // Homeflag is returned and SPDR is loaded with zero { // in readiness for the next 'A' transaction SPI0.DATA = 0x00; // fill spdr with 0 azcount++; // counter is sent to the monitor program as an indication that SPI comms between stepper and encoder are live homeFlag = false; // now that the homeflag state has been sent to the stepper, reset it } SPI0.INTFLAGS = SPI_IF_bm; /* Clear the Interrupt flag by writing 1 */ } // end of interrupt routine SPI_STC_vect static void SPI0_init(void) { PORTA.DIR &= ~PIN4_bm; /* Set MOSI pin direction to input */ PORTA.DIR |= PIN5_bm; /* Set MISO pin direction to output */ PORTA.DIR &= ~PIN6_bm; /* Set SCK pin direction to input */ PORTA.DIR &= ~PIN7_bm; /* Set SS pin direction to input */ SPI0.CTRLA = SPI_DORD_bm /* LSB is transmitted first */ | SPI_ENABLE_bm /* Enable module */ & (~SPI_MASTER_bm); /* SPI module in Slave mode */ SPI0.INTCTRL = SPI_IE_bm; /* SPI Interrupt enable */ }
C++
CL
fb0a0cabda99ad1ff16713cc7a7eb23c4f5888ac7f823cac8f06123704ae79d0
#include "sol.hpp" #include "../common.hpp" #include <algorithm> #include <bitset> #include <memory> #include <string.h> #include <stdio.h> static constexpr size_t MASK_LEN = 36; struct Write { char mask[MASK_LEN]; uint64_t dst; uint64_t val; }; struct MemoryWrite { uint64_t addr; uint64_t val; }; template <bool ReportProgress> uint64_t calcMemorySum(std::vector<MemoryWrite>& memory) { constexpr uint32_t HASH_BITS = MASK_LEN / 2; std::vector<int> firstInGroup(1 << HASH_BITS, -1); std::vector<int> nextInSameGroup(memory.size()); uint64_t ans = 0; for (int i = (int)memory.size() - 1; i >= 0; i--) { if constexpr (ReportProgress) { setSolutionProgress(50 + (memory.size() - i) * 50 / memory.size()); } const uint32_t group = ((uint32_t)memory[i].addr & (uint32_t)((1 << HASH_BITS) - 1)) ^ ((uint32_t)memory[i].addr >> (uint32_t)HASH_BITS); bool blocked = false; for (int j = firstInGroup[group]; j != -1; j = nextInSameGroup[j]) { if (memory[i].addr == memory[j].addr) { blocked = true; break; } } if (!blocked) { ans += memory[i].val; nextInSameGroup[i] = firstInGroup[group]; firstInGroup[group] = i; } } return ans; } std::vector<MemoryWrite>* part2MemoryGlobal; void writeAll(const Write& write, uint32_t idx, uint64_t dst) { if (idx == MASK_LEN) { part2MemoryGlobal->push_back({ dst, write.val }); return; } const uint64_t bm = (uint64_t)1 << (uint64_t)idx; if (write.mask[idx] == '0') { writeAll(write, idx + 1, dst | (write.dst & bm)); return; } if (write.mask[idx] == '1') { writeAll(write, idx + 1, dst | bm); return; } writeAll(write, idx + 1, dst | bm); writeAll(write, idx + 1, dst); } bool solveDay14(std::string_view input, AnswerBuffer& ans) { char mask[MASK_LEN]; size_t reserveCountWrites = std::count(input.begin(), input.end(), '\n') + 1; std::vector<Write> part2Writes; part2Writes.reserve(reserveCountWrites); std::vector<MemoryWrite> part1Memory; part1Memory.reserve(reserveCountWrites); size_t part2WritesMult = 0; size_t part2ReserveCount = 0; while (!input.empty()) { std::string_view line = takeCharsUntil(input, "\n"); if (line.starts_with("mask")) { memcpy(mask, &line[line.size() - MASK_LEN], MASK_LEN); std::reverse(std::begin(mask), std::end(mask)); part2WritesMult = 1 << (size_t)std::count(std::begin(mask), std::end(mask), 'X'); } else if (line.starts_with("mem")) { Write& write = part2Writes.emplace_back(); write.val = parseInt(line.substr(line.find('=') + 1)); write.dst = parseInt(line.substr(line.find('[') + 1)); memcpy(write.mask, mask, MASK_LEN); uint64_t valPart1 = write.val; for (size_t i = 0; i < MASK_LEN; i++) { uint64_t maskHere = (uint64_t)1 << (uint64_t)i; if (mask[i] == '1') { valPart1 |= maskHere; } else if (mask[i] == '0') { valPart1 &= ~maskHere; } } part1Memory.push_back({ write.dst, valPart1 }); part2ReserveCount += part2WritesMult; } } assert(part2Writes.size() <= reserveCountWrites); assert(part1Memory.size() <= reserveCountWrites); uint64_t part1Ans = calcMemorySum<false>(part1Memory); std::vector<MemoryWrite> part2Memory; part2Memory.reserve(part2ReserveCount); part2MemoryGlobal = &part2Memory; for (size_t i = 0; i < part2Writes.size(); i++) { setSolutionProgress(i * 50 / part2Writes.size()); writeAll(part2Writes[i], 0, 0); } assert(part2Memory.size() <= part2ReserveCount); uint64_t part2Ans = calcMemorySum<true>(part2Memory); snprintf(ans.ans1, sizeof(ans.ans1), "%lld", part1Ans); snprintf(ans.ans2, sizeof(ans.ans2), "%lld", part2Ans); return true; }
C++
CL
bc96497e0a71174ffee8a7e75b5db601acadce4017d7b0f55206c14b49365b7f
//===- X86InplaceValueFusion.h --------------------------------------------===// // // The ONNC Project // // See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef TARGET_X86_X86_INPLACE_VALUE_FUSIBLE_H_H #define TARGET_X86_X86_INPLACE_VALUE_FUSIBLE_H_H #include <onnc/IR/ComputeOperator.h> namespace onnc { namespace x86 { bool IsInplaceValueFusible(const ComputeOperator& pOp); } // namespace x86 } // namespace onnc #endif
C++
CL
b85f5d445113bfe036ef4bc0d06d3b6f3d7751bd62bbc4b311ee2de63c9da6aa
#pragma once #pragma comment (lib, "Ws2_32.lib") #pragma comment (lib, "Mswsock.lib") #pragma comment (lib, "AdvApi32.lib") #ifndef __WINDOWSSOCKET_HPP__ #define __WINDOWSSOCKET_HPP__ #include <iostream> #include <winsock2.h> #include <ws2tcpip.h> #include <Windows.h> #include <string> #include <cstdlib> #include <cstring> #include <sys/types.h> #include <errno.h> #include <istream> #include <signal.h> #include <sstream> #include <stdio.h> #include <stdlib.h> #include <list> #include "ISocket.hpp" typedef _W64 unsigned int ssize_t; # define UNDEFINED 0 # define BUFF_SIZE 2048 class WindowsSocket : public ISocket { public: virtual ~WindowsSocket(); WindowsSocket(); bool Connect(const std::string& host, const std::string& port); bool ConnectFd(int fd); int recv(char **data); int sendv(const std::string& data); int getSocket() const; struct sockaddr_in getSource() const; void setUDP(const bool& val); bool isUDP() const; void setHost(const std::string& ip); const std::string& getHost() const; struct sockaddr_in _addr; private: struct hostent * _server; int _socket; std::string _host; std::string _port; bool _close; bool _udp; }; #endif /*!__WINDOWSSOCKET_HPP__*/
C++
CL
be4571ba7b7cd095a1410b5ac16d4b8f3768570440c35131fec88f8dc2ef5162
// == BALESTRA ENGINE - Codecraft Productions // ===================================================== // Copyright @2014 - Created by Henrique.F // == REFERENCES // ===================================================== #ifndef _INC_BENVIRONMENT_SOUND #define _INC_BENVIRONMENT_SOUND #include "BalestraPrecompiledHeader.h" #include "IBalestraDevice.h" namespace BalestraEngine { class BalestraSoundChannel; class BalestraEnvironmentSound : public IBalestraDevice { public: // == METHODS ====================================== BalestraEnvironmentSound(BalestraConfiguration* configuration); virtual BalestraSoundChannel* createSoundChannel(); private: protected: }; } #endif
C++
CL
0e2dc0520bcb934f79c620607c94f1987464967ab9be1cc508d630862f0c50f2
#pragma once #ifndef DISABLE_LOCALSOLVER #include "ListModel.h" class ListBetaModel : public ListModel { class SerialSGSBetaFunction : public ListSchedulingNativeFunction { public: explicit SerialSGSBetaFunction(ProjectWithOvertime &_p) : ListSchedulingNativeFunction(_p) {} int varCount() override; SGSResult decode(std::vector<int>& order, const localsolver::LSExternalArgumentValues& context) override; }; void addAdditionalData(localsolver::LSModel &model, localsolver::LSExpression& obj) override; std::vector<int> parseScheduleFromSolution(localsolver::LSSolution& sol) override; std::vector<localsolver::LSExpression> betaVar; static ProjectWithOvertime::BorderSchedulingOptions options; public: ListBetaModel(ProjectWithOvertime &_p) : ListModel(_p, new SerialSGSBetaFunction(_p)), betaVar(p.numJobs) {} virtual ~ListBetaModel() {} static void setVariant(int variant); }; //============================================================================================================== class ListTauModel : public ListModel { class SerialSGSTauFunction : public ListSchedulingNativeFunction { public: explicit SerialSGSTauFunction(ProjectWithOvertime &_p) : ListSchedulingNativeFunction(_p) {} int varCount() override; SGSResult decode(std::vector<int>& order, const localsolver::LSExternalArgumentValues& context) override; }; std::vector<localsolver::LSExpression> tauVar; void addAdditionalData(localsolver::LSModel &model, localsolver::LSExpression& obj) override; std::vector<int> parseScheduleFromSolution(localsolver::LSSolution& sol) override; public: ListTauModel(ProjectWithOvertime &_p) : ListModel(_p, new SerialSGSTauFunction(_p)), tauVar(p.numJobs) {} virtual ~ListTauModel() {} }; //============================================================================================================== class ListTauDiscreteModel : public ListModel { class SerialSGSIntegerFunction : public ListSchedulingNativeFunction { public: explicit SerialSGSIntegerFunction(ProjectWithOvertime &_p) : ListSchedulingNativeFunction(_p) {} int varCount() override; SGSResult decode(std::vector<int>& order, const localsolver::LSExternalArgumentValues& context) override; }; static const localsolver::lsint IV_COUNT = 4; std::vector<localsolver::LSExpression> tauVar; void addAdditionalData(localsolver::LSModel &model, localsolver::LSExpression& obj) override; std::vector<int> parseScheduleFromSolution(localsolver::LSSolution& sol) override; public: ListTauDiscreteModel(ProjectWithOvertime &_p) : ListModel(_p, new SerialSGSIntegerFunction(_p)), tauVar(p.numJobs) {} virtual ~ListTauDiscreteModel() {} }; //============================================================================================================== class ListAlternativesModel : public ListModel { class SerialSGSAlternativesDecoder : public ListSchedulingNativeFunction { public: explicit SerialSGSAlternativesDecoder(ProjectWithOvertime &_p) : ListSchedulingNativeFunction(_p) {} int varCount() override; SGSResult decode(std::vector<int>& order, const localsolver::LSExternalArgumentValues& context) override; }; std::vector<int> parseScheduleFromSolution(localsolver::LSSolution &sol) override; void addAdditionalData(localsolver::LSModel &model, localsolver::LSExpression &obj) override {} public: ListAlternativesModel(ProjectWithOvertime &_p) : ListModel(_p, new SerialSGSAlternativesDecoder(_p)) {} virtual ~ListAlternativesModel() {} }; #endif
C++
CL
834c18c638058d204ee924370e5fcb848aeb569078ce7c2f9aa3983d110fa7d9
#include "ltr35.h" #include "lqmeas/lqtdefs.h" #include "lqmeas/devs/ltr/crates/LtrCrate.h" #include "lqmeas/ifaces/out/DacSignals/DacSignalSin.h" #include <math.h> #ifndef M_PI #define M_PI 3.1415926535897932384626433832795 #endif namespace LQMeas { LTR35::LTR35(QSharedPointer<LtrCrate> crate, unsigned slot, QObject *parent) : LtrModule(crate, slot, typeModuleID, parent), DevOutStream(this), m_outFreq(LTR35_DAC_FREQ_DEFAULT), m_sender(this) { LTR35_Init(&m_hnd); for (int ch = 0; ch < LTR35_DAC_CHANNEL_CNT; ch++) m_dacModes[ch] = OutChModeRam; } QString LTR35::typeModuleName() { return "LTR35"; } LTR35::~LTR35() { if (isOpened()) close(); } QString LTR35::name() const { return typeModuleName(); } QString LTR35::modificationName() const { return QString("%1-%2-%3").arg(name()).arg(QString::number(m_hnd.ModuleInfo.Modification)) .arg(QString::number(m_hnd.ModuleInfo.DacChCnt)); } QString LTR35::serial() const { return QSTRING_FROM_CSTR(m_hnd.ModuleInfo.Serial); } unsigned LTR35::verFPGA() const { return m_hnd.ModuleInfo.VerFPGA; } unsigned LTR35::verPLD() const { return m_hnd.ModuleInfo.VerPLD; } unsigned LTR35::modification() { return m_hnd.ModuleInfo.Modification; } QString LTR35::errorString(int err) const { return QSTRING_FROM_CSTR(LTR35_GetErrorString(err)); } bool LTR35::isOpened() const { return LTR35_IsOpened(&m_hnd) == LTR_OK; } #if 0 Error LTR35::outSignalsGenerate() { Error err = Error::Success(); unsigned int sig_size; m_hnd.Cfg.Mode = LTR35_MODE_CYCLE; m_hnd.Cfg.DataFmt = LTR35_FORMAT_24; err = configure(); /* обновление реально установленных частот сигналов */ if (err.isSuccess()) { unsigned out_ch = m_hnd.State.SDRAMChCnt + 1; unsigned max_sig_size = LTR35_MAX_POINTS_PER_PAGE/out_ch; err = calcCycleSigsParams(m_hnd.State.DacFreq, max_sig_size, &sig_size); } if (err.isSuccess()) { QVector<double> dac_data; QVector<unsigned> dig_data; err = outGenRamData(0, sig_size, dac_data, dig_data); if (err.isSuccess()) { if (dig_data.size()==0) { unsigned dig_data = LTR35_DIGOUT_WORD_DIS_H | LTR35_DIGOUT_WORD_DIS_L; err = protSendStreamData(0, 0, &dig_data, 1, 0, 1000); } } if (err.isSuccess() && ((dac_data.size() + dig_data.size())!=0)) { err = protSendStreamData(dac_data.data(), dac_data.size(), dig_data.data(), dig_data.size(), 0, 3000 + (dig_data.size() + dac_data.size())/1000); } if (err.isSuccess() && m_sender.unsentWordsCnt()) { err = error(LTR_ERROR_SEND_INSUFFICIENT_DATA); reportError("Передано в модуль меньше данных, чем запрашивалось", err); } } if (err.isSuccess()) { err = error(LTR35_SwitchCyclePage(&m_hnd, 0, 30000)); if (!err.isSuccess()) { reportError("Ошибка установки сигнала", err); } } return err; } #endif void LTR35::setRange(int ch, int range) { Q_ASSERT((ch < LTR35_DAC_CHANNEL_CNT) && (range < LTR35_DAC_CH_OUTPUTS_CNT)); m_hnd.Cfg.Ch[ch].Output = range; } int LTR35::range(int ch) { Q_ASSERT(ch < LTR35_DAC_CHANNEL_CNT); return m_hnd.Cfg.Ch[ch].Output; } double LTR35::outDacMaxVal(int ch) const { Q_ASSERT(ch < LTR35_DAC_CHANNEL_CNT); return m_hnd.ModuleInfo.DacOutDescr[m_hnd.Cfg.Ch[ch].Output].AmpMax; } double LTR35::outDacMinVal(int ch) const { Q_ASSERT(ch < LTR35_DAC_CHANNEL_CNT); return m_hnd.ModuleInfo.DacOutDescr[m_hnd.Cfg.Ch[ch].Output].AmpMin; } double LTR35::dacMaxRangeVal(unsigned range) const { Q_ASSERT(range < LTR35_DAC_CH_OUTPUTS_CNT); return m_hnd.ModuleInfo.DacOutDescr[range].AmpMax; } double LTR35::outDacMaxVal() const { return m_hnd.ModuleInfo.DacOutDescr[0].AmpMax; } double LTR35::outDacMaxFreq() const { return LTR35_DAC_FREQ_MAX; } bool LTR35::outGenRunning() const { return m_hnd.State.Run ? true : false; } TLTR *LTR35::channel() const { return &m_hnd.Channel; } Error LTR35::protOpen() { Error err = error(LTR35_Open(&m_hnd, crate()->ltrdIpAddr(), crate()->ltrdTcpPort(), crate()->serial().toLatin1(), slot())); if (err.isSuccess()) { outSetDacChCnt(m_hnd.ModuleInfo.DacChCnt); outSetDigChCnt(m_hnd.ModuleInfo.DoutLineCnt); } if (!err.isSuccess()) LTR35_Close(&m_hnd); return err; } Error LTR35::protClose() { return error(LTR35_Close(&m_hnd)); } Error LTR35::protConfigure() { static const BYTE arith_src_codes[LTR35_ARITH_SRC_CNT] = { LTR35_CH_SRC_COS1, LTR35_CH_SRC_COS2, LTR35_CH_SRC_COS3, LTR35_CH_SRC_COS4 }; INT arith_src[LTR35_DAC_CHANNEL_CNT]; QList<double> arith_freqs; double dac_freq = m_outFreq; Error err; err = error(LTR35_Stop(&m_hnd, 0)); for (int ch=0; (ch < outDacChannelsCnt()) && err.isSuccess(); ch++) { if (outDacChMode(ch) == OutChModeHard) { QSharedPointer<DacSignal> sig = outDacSignal(ch); if (sig) { QSharedPointer<DacSignalSin> sin = qSharedPointerDynamicCast<DacSignalSin>(sig); if (!sin) { /* в арифметическом режиме можем выводить только синус */ err = error(LTR35_ERR_UNSUPPORTED_CONFIG); } else { /** @todo проверка, запоминание фазы и выбор sin/cos */ double freq = sig->signalFreq(); if (freq>0) { int src = -1; /* пробуем найти арифметический источник с такой же частотой */ for (int i=0; i < arith_freqs.size(); i++) { if (qAbs(freq-arith_freqs.at(i)) < 0.001) { src = i; } } /* если не нашли источник, значит новый, но может * быть не больше LTR35_ARITH_SRC_CNT */ if (src < 0) { if (arith_freqs.size()!=LTR35_ARITH_SRC_CNT) { src = arith_freqs.size(); arith_freqs.append(freq); } else { err = error(LTR35_ERR_UNSUPPORTED_CONFIG); } } if (err.isSuccess()) arith_src[ch] = src; } } } } } if (err.isSuccess()) { err = error(LTR35_FillFreq(&m_hnd.Cfg, dac_freq, &dac_freq)); LQMeasLog->report(LogLevel::DebugMedium, tr("synthesizer parameters a = %1, b = %2, r = %3") .arg(QString::number(m_hnd.Cfg.Synt.a)) .arg(QString::number(m_hnd.Cfg.Synt.b)) .arg(QString::number(m_hnd.Cfg.Synt.r)), this); } /* установка арифметических источников */ if (err.isSuccess() && arith_freqs.size()) { for (int s=0; s < arith_freqs.size(); s++) { m_hnd.Cfg.ArithSrc[s].Phase = 0; /** @todo */ m_hnd.Cfg.ArithSrc[s].Delta = 2.*M_PI*arith_freqs.at(s)/dac_freq; } } if (err.isSuccess()) { for (unsigned ch = 0; ch < m_hnd.ModuleInfo.DacChCnt; ch++) { QSharedPointer<DacSignal> sig = outDacSignal(ch); if (sig) { m_hnd.Cfg.Ch[ch].Enabled = 1; if (outDacChMode(ch) == OutChModeRam) { m_hnd.Cfg.Ch[ch].Source = LTR35_CH_SRC_SDRAM; } else { QSharedPointer<DacSignalSin> sin = qSharedPointerDynamicCast<DacSignalSin>(sig); m_hnd.Cfg.Ch[ch].Source = arith_src_codes[arith_src[ch]]; m_hnd.Cfg.Ch[ch].ArithAmp = sin->amplitude(); m_hnd.Cfg.Ch[ch].ArithOffs = sin->offset(); double sig_freq = dac_freq * m_hnd.Cfg.ArithSrc[arith_src[ch]].Delta/(2.*M_PI); sig->setRealParams(sig_freq, dac_freq); } } else { m_hnd.Cfg.Ch[ch].Enabled = 0; } } err = error(LTR35_Configure(&m_hnd)); } return err; } Error LTR35::protLoadConfig(QSettings &set) { int intval; bool ok; int ch_cnt = set.beginReadArray("Channels"); for (int ch=0; (ch < ch_cnt) && (ch< outDacChannelsCnt()); ch++) { set.setArrayIndex(ch); intval = set.value("Output", LTR35_DAC_OUT_FULL_RANGE).toInt(&ok); if (ok && ((intval == LTR35_DAC_OUT_FULL_RANGE) || (intval == LTR35_DAC_OUT_DIV_RANGE))) { m_hnd.Cfg.Ch[ch].Output = intval; } else { LQMeasLog->report(LogLevel::Warning, tr("Load config: invalid output number value for channel %1") .arg(QString::number(ch+1)), this); } intval = set.value("GenMode", OutChModeRam).toInt(&ok); if (ok && ((intval == OutChModeRam) || (intval == OutChModeHard))) { outDacSetChMode(ch, (OutChMode)intval); } else { LQMeasLog->report(LogLevel::Warning, tr("Load config: invalid output generation mode for channel %1") .arg(QString::number(ch+1)), this); } } set.endArray(); outLoadSignalConfig(set); DevOut::OutRamSyncMode outMode = (DevOut::OutRamSyncMode)set.value("OutMode", DevOut::OutRamSyncModeStream).toInt(); if ((outMode == DevOut::OutRamSyncModeStream) || (outMode == DevOut::OutRamSyncModeCycle)) { outSetRamSyncMode(outMode); } else { LQMeasLog->report(LogLevel::Warning, tr("Load config: invalid output mode value"), this); } /** @note Настройки источников и т.п. не сохраняются, т.к. они рассчитываются по установленным сигналам. Также не сохраняется значение выходной частоты, т.к. сейчас используется только 192 КГц Пока не сохраняются настройки: StreamStatusPeriod, EchoEnable, EchoChannel */ return Error::Success(); } Error LTR35::protSaveConfig(QSettings &set) const { set.beginWriteArray("Channels"); for (int ch=0; ch < outDacChannelsCnt(); ch++) { set.setArrayIndex(ch); set.setValue("Output", m_hnd.Cfg.Ch[ch].Output); set.setValue("GenMode", outDacChMode(ch)); } set.endArray(); set.setValue("OutMode", outRamSyncMode()); return Error::Success(); } Error LTR35::protOutStreamInit() { m_hnd.Cfg.Mode = LTR35_MODE_STREAM; m_hnd.Cfg.DataFmt = LTR35_FORMAT_20; Error err = configure(); if (err.isSuccess()) { err = digStreamLoadPrepare(); } return err; } Error LTR35::protOutStreamStart() { return error(LTR35_StreamStart(&m_hnd, 0)); } Error LTR35::protOutStreamStop(unsigned tout) { return protOutCycleGenStop(); } Error LTR35::protOutCycleLoadStart(unsigned size) { Error err = Error::Success(); if (!outGenRunning()) { m_hnd.Cfg.Mode = LTR35_MODE_CYCLE; m_hnd.Cfg.DataFmt = LTR35_FORMAT_24; err = configure(); } if (err.isSuccess()) err = digStreamLoadPrepare(); return err; } Error LTR35::protOutCycleLoadFinish() { if (outGenRunning()) return error(LTR35_SwitchCyclePage(&m_hnd, 0, 30000)); return Error::Success(); } Error LTR35::protOutCycleGenStart() { return error(LTR35_SwitchCyclePage(&m_hnd, 0, 30000)); } Error LTR35::protOutCycleGenStop() { return error(LTR35_StopWithTout(&m_hnd, 0, 10000)); } Error LTR35::protOutSendData(const double *dac_data, unsigned dac_size, const unsigned *dig_data, unsigned dig_size, unsigned flags, unsigned tout) { Error err = Error::Success(); if (m_sender.unsentWordsCnt()) { err = m_sender.flushData(tout); } if (err.isSuccess()) { if (m_sender.unsentWordsCnt()!=0) { err = StdErrors::SendBusy(); } else { DWORD snd_dac_req_size = dac_size; DWORD snd_dig_req_size = dig_size; DWORD snd_size = (snd_dac_req_size + snd_dig_req_size) * (m_hnd.Cfg.DataFmt==LTR35_FORMAT_20 ? 1 : 2); QScopedArrayPointer<DWORD> wrds (new DWORD[snd_size]); err = error(LTR35_PrepareData(&m_hnd, dac_data, &snd_dac_req_size, (const DWORD*)dig_data, &snd_dig_req_size, LTR35_PREP_FLAGS_VOLT, wrds.data(), &snd_size)); if (!err.isSuccess()) { LQMeasLog->error(tr("Prepare data error"), err, this); } else { m_sender.setFrameSize(snd_size); err = m_sender.putFrames(wrds.data(), snd_size, tout, 0); } } } return err; } Error LTR35::protOutFlushData(unsigned tout) { Error err = Error::Success(); if (m_sender.unsentWordsCnt()) { err = m_sender.flushData(tout); } if (err.isSuccess()) { if (m_sender.unsentWordsCnt()!=0) { err = StdErrors::SendBusy(); } } if (err.isSuccess()) { m_sender.setFrameSize(0); } return err; } Error LTR35::rawWordsSend(const DWORD *wrds, unsigned size, unsigned tout, unsigned *sent_size) { Error err = Error::Success(); int send_res = LTR35_Send(&m_hnd, wrds, size, tout); if (send_res >= 0) { *sent_size = send_res; } else { err = error(send_res); } return err; } Error LTR35::digStreamLoadPrepare() { /* если цифровые выходы не разрешены, то загружаем одиночное слово, переводящее их в третье состояние */ Error err = Error::Success(); bool dout_en = false; for (int ch=0; (ch < outDigChannelsCnt()) && !dout_en; ch++) { if (outDigValidRamSignal(ch)) { dout_en = true; } } /* передача слова для запрета цифровых выходов, если ни один не был разрешен */ if (!dout_en) { unsigned dig_data = LTR35_DIGOUT_WORD_DIS_H | LTR35_DIGOUT_WORD_DIS_L; err = protOutSendData(0, 0, &dig_data, 1, 0, 1000); } return err; } }
C++
CL
ee5608e942a8f98e57f961301834bb9263431759d1dd9f4be963e8cd804b9629
#include <ios> #include <iostream> #include <iomanip> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <netinet/in.h> #include <arpa/inet.h> #include <ifaddrs.h> #include <linux/if_packet.h> void printMACAddress(unsigned char *buf) { std::ios state(nullptr); state.copyfmt(std::cout); // save current formatting settings std::cout << std::hex << std::setfill('0'); for (int i = 0; i < 5; ++i) { std::cout << std::setw(2) << (int)buf[i] << ":"; } std::cout << std::setw(2) << (int)buf[5] << std::endl; std::cout.copyfmt(state); // restore previous formatting settings return; } void printIPAddress(sockaddr_in *in_addr) { char *s_addr = inet_ntoa(in_addr->sin_addr); std::cout << s_addr << std::endl; } int main(void) { // Allocate a buffer to store hostname in const size_t HOSTNAME_SZ = 0x100; char hostname[HOSTNAME_SZ] = {0}; // Fetch our hostname in the passed buffer gethostname(hostname, HOSTNAME_SZ); std::cout << "Hostname is : " << hostname << std::endl; // Create an ifaddrs struct to pass to `getifaddrs` ifaddrs *ifaptr = (ifaddrs *)malloc(sizeof(ifaddrs)); if (getifaddrs(&ifaptr) != 0) { std::cerr << "Unable to get network interfaces" << std::endl; exit(1); } // to iterate over results struct ifaddrs *it = ifaptr; while (it != nullptr) { if (it->ifa_name == nullptr || strcmp(it->ifa_name, "lo") != 0){ sockaddr *addr = it->ifa_addr; // If it is an IPv4 addr if (addr->sa_family == AF_INET) { std::cout << "IP Address for " << it->ifa_name << " is: "; printIPAddress((sockaddr_in *)addr); // If it is a physical address } else if (addr->sa_family == AF_PACKET) { std::cout << "MAC Address for " << it->ifa_name << " is: "; sockaddr_ll *s = (sockaddr_ll *)addr; printMACAddress(s->sll_addr); } } it = it->ifa_next; } freeifaddrs(ifaptr); ifaptr = nullptr; return 0; }
C++
CL
9029efdb02ed0c0a4c7d669a97571a8176fde63be82824cd5c5d7eb6d40199c5
#pragma once // // Caps Lock mutators. // class CapsLockMutator: public KeyEventHandler { }; class CapsLockSwapper: public CapsLockMutator { public: virtual DISPOSITION KeyDown( KBDLLHOOKSTRUCT* pkb ); virtual DISPOSITION KeyUp( KBDLLHOOKSTRUCT* pkb ); }; class CapsLockReplacer: public CapsLockMutator { public: virtual DISPOSITION KeyDown( KBDLLHOOKSTRUCT* pkb ); virtual DISPOSITION KeyUp( KBDLLHOOKSTRUCT* pkb ); }; class CapsLockMutatorFactory { public: static CapsLockMutator* Create( CAPS_LOCK_SWAP_MODE swapMode ); private: CapsLockMutatorFactory( ); CapsLockMutatorFactory( CapsLockMutatorFactory& ); CapsLockMutatorFactory& operator=( CapsLockMutatorFactory& ); }; // // Caps lock togglers. // class CapsLockToggler: public KeyEventHandler { }; class CapsLockPressTwiceToggler: public CapsLockToggler { public: CapsLockPressTwiceToggler( ): allowDown ( false ), allowUp ( false ) { } virtual DISPOSITION KeyDown( KBDLLHOOKSTRUCT* pkb ); virtual DISPOSITION KeyUp( KBDLLHOOKSTRUCT* pkb ); private: bool allowDown; bool allowUp; DISPOSITION _Implementation( KBDLLHOOKSTRUCT* pkb, bool& allow ); }; class CapsLockDisabledToggler: public CapsLockToggler { public: virtual DISPOSITION KeyDown( KBDLLHOOKSTRUCT* pkb ); virtual DISPOSITION KeyUp( KBDLLHOOKSTRUCT* pkb ); }; class CapsLockTogglerFactory { public: static CapsLockToggler* Create( CAPS_LOCK_TOGGLE_MODE toggleMode ); private: CapsLockTogglerFactory( ); CapsLockTogglerFactory( CapsLockTogglerFactory& ); CapsLockTogglerFactory& operator=( CapsLockTogglerFactory& ); }; // // Top-level caps lock handler. // class CapsLockKeyHandler: public KeyEventHandler { public: virtual inline DISPOSITION KeyDown( KBDLLHOOKSTRUCT* pkb ) { return _Implementation( pkb ); } virtual inline DISPOSITION KeyUp( KBDLLHOOKSTRUCT* pkb ) { return _Implementation( pkb ); } private: DISPOSITION _Implementation( KBDLLHOOKSTRUCT* pkb ); };
C++
CL
44feea08770d6d40d8e9cb9d6015c1f8afbd0b5136d291c978f8a7f56e4eb281
#pragma once #include <functional> #include "RuleToken.h" #include "Delegates.h" #include "Node.h" #define Autoname(builder) \ do \ { \ builder.SetName(__func__); \ } \ while(false) namespace Spark { class IRuleBuilder { public: template <class T, class... Rest> inline void Add(T t, Rest... rest) { RuleToken tok; tok.Set(t); AddInternal(tok); Add(rest...); } inline void AddEmpty() { AddEmptyInternal(); } template <class T> void AddString(T val) { auto rule = GenerateStringRule(val); Add(rule); RequestFlatten(); } virtual void SetName(std::string name) = 0; template <class T> void SetNodeType() { auto factory = [](std::vector<NodePtr>& vec) { std::shared_ptr<T> val = std::make_shared<T>(vec); return AsNode(val); }; SetNodeTypeInternal(factory); } void Ignore(int index) { IgnoreInternal(index); } private: inline void Add() { EndInternal(); } // End point template <class T> RuleFuncWrapper GenerateStringRule(T& val) { auto end = [=](IRuleBuilder& b) { auto base = GenerateStringRule(val); b.Add(base); b.AddEmpty(); }; auto base = [=](IRuleBuilder& b) { b.Add(val, end); }; return base; } protected: virtual void AddInternal(RuleToken tok) = 0; virtual void EndInternal() = 0; virtual void AddEmptyInternal() = 0; virtual void RequestFlatten() = 0; virtual void SetNodeTypeInternal(std::function<NodePtr(std::vector<NodePtr>&)> factory) = 0; virtual void IgnoreInternal(int index) = 0; }; }
C++
CL
c9ebad1c41d79b35d41240a754723d04e47c889e79f7080fa23edd9dc17fc7cb
#ifndef INCLUDED_AEGIS_AGTA_ASSETPOOL_H #define INCLUDED_AEGIS_AGTA_ASSETPOOL_H #include <vector> namespace agta { template<typename T> class AssetPool { public: AssetPool(); AssetPool(size_t batchSize); ~AssetPool(); size_t createAsset(); void destroyAsset(size_t id); T& assetForId(size_t id); public: static const size_t DEFAULT_BATCH_SIZE = 500; typedef std::vector<std::pair<bool, T> > AssetList; typedef std::vector<size_t> FreeAssetIdList; size_t m_batchSize; size_t m_count; AssetList m_assets; FreeAssetIdList m_freeAssetIds; }; template<typename T> AssetPool<T>::AssetPool() : m_batchSize(DEFAULT_BATCH_SIZE), m_count(0), m_assets(DEFAULT_BATCH_SIZE) {} template<typename T> AssetPool<T>::AssetPool(size_t batchSize) : m_batchSize(batchSize), m_count(0), m_assets(batchSize) {} template<typename T> AssetPool<T>::~AssetPool() {} template<typename T> size_t AssetPool<T>::createAsset() { size_t id; // if there are free asset ids, allocate from one of those. if (!m_freeAssetIds.empty()) { id = m_freeAssetIds.back(); m_freeAssetIds.pop_back(); } else { id = ++m_count; if (id >= m_assets.size()) { // hit the limit for assets throw std::exception(); } } // Get the asset info at location 'id' std::pair<bool, T>& p = m_assets[id - 1]; // Mark the asset as active p.first = true; return id; }; template<typename T> void AssetPool<T>::destroyAsset(size_t id) { if (id >= m_assets.size()) { throw std::exception(); } std::pair<bool, T>& p = m_assets[id - 1]; p.first = false; p.second = T(); m_freeAssetIds.push_back(id); } template<typename T> T& AssetPool<T>::assetForId(size_t id) { if (id >= m_assets.size()) { throw std::exception(); } std::pair<bool, T>& p = m_assets[id - 1]; // Verify the asset is active if (!p.first) { throw std::exception(); } return p.second; } } // namespace #endif // INCLUDED
C++
CL
47dd5130bcaf7c415648ebc59779e6eb5a0e78a53bb9077d12806f84966825b6
/* * Copyright (c) 1996, David Mazieres <dm@uun.org> * Copyright (c) 2008, Damien Miller <djm@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "wtf/CryptographicallyRandomNumber.h" #include "base/rand_util.h" #include <string.h> namespace WTF { static bool s_shouldUseAlwaysZeroRandomSourceForTesting = false; void setAlwaysZeroRandomSourceForTesting() { s_shouldUseAlwaysZeroRandomSourceForTesting = true; } uint32_t cryptographicallyRandomNumber() { uint32_t result; cryptographicallyRandomValues(&result, sizeof(result)); return result; } void cryptographicallyRandomValues(void* buffer, size_t length) { if (s_shouldUseAlwaysZeroRandomSourceForTesting) { memset(buffer, '\0', length); return; } // This should really be crypto::RandBytes(), but WTF can't depend on crypto. // The implementation of crypto::RandBytes() is just calling // base::RandBytes(), so both are actually same. base::RandBytes(buffer, length); } } // namespace WTF
C++
CL
a66abfe6e403aafcb1f65af239ba1c0554db593110fc386ed4377a0f29e9f12f
// Copyright 2022 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_EXTENSIONS_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_UTILS_H_ #define CHROME_BROWSER_EXTENSIONS_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_UTILS_H_ #include "chromeos/crosapi/mojom/cros_display_config.mojom.h" #include "extensions/browser/api/system_display/display_info_provider.h" namespace extensions { // Callback function for CrosDisplayConfigController crosapi interface. // Reused by both ash and lacros implementations of DisplayInfoProvider. // Converts input display layout |info| from crosapi to extension api type. // Passes converted array into a |callback|. void OnGetDisplayLayoutResult( base::OnceCallback<void(DisplayInfoProvider::DisplayLayoutList)> callback, crosapi::mojom::DisplayLayoutInfoPtr info); } // namespace extensions #endif // CHROME_BROWSER_EXTENSIONS_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_UTILS_H_
C++
CL
6d1313b68879bdbaf826201e0825c1e67fbb4393bc0b14a4a7232ae934ff2a32
// // Copyright (C) University College London, 2007-2012, all rights reserved. // // This file is part of HemeLB and is CONFIDENTIAL. You may not work // with, install, use, duplicate, modify, redistribute or share this // file, or any part thereof, other than as allowed by any agreement // specifically made by you with University College London. // #ifndef HEMELBSETUPTOOL_CYLINDERGENERATOR_H #define HEMELBSETUPTOOL_CYLINDERGENERATOR_H #include "GeometryGenerator.h" #include "Index.h" #include "GetSet.h" #include "Iolet.h" #include "GenerationError.h" class GeometryWriter; class Site; class BlockWriter; struct CylinderData { // Cylinder parameters Vector Centre; Vector Axis; double Radius; double Length; }; class CylinderGenerator : public GeometryGenerator { public: CylinderGenerator(); virtual ~CylinderGenerator(); inline void SetCylinderCentre(Vector v) { this->Cylinder->Centre = v; } inline void SetCylinderAxis(Vector n) { this->Cylinder->Axis = n; } inline void SetCylinderRadius(double r) { this->Cylinder->Radius = r; } inline void SetCylinderLength(double l) { this->Cylinder->Length = l; } private: virtual void ComputeBounds(double []) const; void ClassifySite(Site& site); void ComputeCylinderNormalAtAPoint(Vector& wallNormal, const Vector& surfacePoint, const Vector& cylinderAxis) const; CylinderData* Cylinder; protected: virtual int BlockInsideOrOutsideSurface(const Block &block) { return 0; } }; #endif // HEMELBSETUPTOOL_CYLINDERGENERATOR_H
C++
CL
e33d4ea5f97252c9bd097eae9547f78452d0bd0f724b4b4381395b8b3e99fa61
/************************************************************************//** * @file pin_transform.c * * @version 1.0.0 * * @author RedBearLab * * @date 2016/11/10 * * @brief Main body of the project. * * @copyright Copyright (c) 2012-2016 RedBearLab * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ /**************************************************************************** * HEADER FILES ****************************************************************************/ #include "Arduino.h" #include "pin_transform.h" /**************************************************************************** * MACRO DEFINITIONS ****************************************************************************/ /**************************************************************************** * GLOBAL VARIABLES ****************************************************************************/ /**************************************************************************** * LOCAL VARIABLES ****************************************************************************/ /**************************************************************************** * LOCAL FUNCTION PROTOTYPES ****************************************************************************/ /**************************************************************************** * FUNCTION ACHIEVMENT ****************************************************************************/ PinName Pin_Arduino_to_nRF52(uint8_t pin) { PinName return_pin = (PinName)NC; #ifdef nRF52DK switch(pin) { case 0 : return_pin = P0_11;break;//D0/RX case 1 : return_pin = P0_12;break;//D1/TX case 2 : return_pin = P0_13;break;//D2/SDA0 case 3 : return_pin = P0_14;break;//D3/SCL0 case 4 : return_pin = P0_15;break;//D4 case 5 : return_pin = P0_16;break;//D5 case 6 : return_pin = P0_17;break;//D6 case 7 : return_pin = P0_18;break;//D7 case 8 : return_pin = P0_19;break;//D8 case 9 : return_pin = P0_20;break;//D9 case 10 : return_pin = P0_22;break;//D10 case 11 : return_pin = P0_23;break;//D11 case 12 : return_pin = P0_24;break;//D12 case 13 : return_pin = P0_25;break;//D13/LED case 14 : return_pin = P0_26;break;//SDA1 case 15 : return_pin = P0_27;break;//SCL1 case 16 : return_pin = P0_3;break;//A0 case 17 : return_pin = P0_4;break;//A1 case 18 : return_pin = P0_28;break;//A2 case 19 : return_pin = P0_29;break;//A3 case 20 : return_pin = P0_30;break;//A4 case 21 : return_pin = P0_31;break;//A5 case 22 : return_pin = P0_5;break; //UART_CTS case 23 : return_pin = P0_6;break; //UART_TXD case 24 : return_pin = P0_7;break; //UART_RTS case 25 : return_pin = P0_8;break; //UART_RXD case 26 : return_pin = P0_2;break; case 27 : return_pin = P0_21;break; case 28 : return_pin = P0_9;break; case 29 : return_pin = P0_10;break; case 30 : return_pin = P0_0;break; case 31 : return_pin = P0_1;break; default : return_pin = (PinName)NC;break; } #endif #ifdef RBL_BLEND2 switch(pin) { case 0 : return_pin = P0_11;break;//D0/RX case 1 : return_pin = P0_12;break;//D1/TX case 2 : return_pin = P0_13;break;//D2/SDA0 case 3 : return_pin = P0_14;break;//D3/SCL0 case 4 : return_pin = P0_15;break;//D4 case 5 : return_pin = P0_16;break;//D5 case 6 : return_pin = P0_17;break;//D6 case 7 : return_pin = P0_18;break;//D7 case 8 : return_pin = P0_19;break;//D8 case 9 : return_pin = P0_20;break;//D9 case 10 : return_pin = P0_22;break;//D10 case 11 : return_pin = P0_23;break;//D11 case 12 : return_pin = P0_24;break;//D12 case 13 : return_pin = P0_25;break;//D13/LED case 14 : return_pin = P0_26;break;//SDA1 case 15 : return_pin = P0_27;break;//SCL1 case 16 : return_pin = P0_3;break;//A0 case 17 : return_pin = P0_4;break;//A1 case 18 : return_pin = P0_28;break;//A2 case 19 : return_pin = P0_29;break;//A3 case 20 : return_pin = P0_30;break;//A4 case 21 : return_pin = P0_31;break;//A5 case 22 : return_pin = P0_5;break; //UART_CTS case 23 : return_pin = P0_6;break; //UART_TXD case 24 : return_pin = P0_7;break; //UART_RTS case 25 : return_pin = P0_8;break; //UART_RXD case 26 : return_pin = P0_2;break; case 27 : return_pin = P0_21;break; case 28 : return_pin = P0_9;break; case 29 : return_pin = P0_10;break; case 30 : return_pin = P0_0;break; case 31 : return_pin = P0_1;break; default : return_pin = (PinName)NC;break; } #endif #ifdef BLE_NANO2 switch(pin) { case 0 : return_pin = P0_30;break; //D0/RXD case 1 : return_pin = P0_29;break; //D1/TXD case 2 : return_pin = P0_28;break; //D2/CTS case 3 : return_pin = P0_2;break; //D3/RTS case 4 : return_pin = P0_5;break; //D4 case 5 : return_pin = P0_4;break; //D5 case 6 : return_pin = P0_3;break; //D6 case 7 : return_pin = P0_6;break; //D7 case 8 : return_pin = P0_7;break; //D8 case 9 : return_pin = P0_8;break; //D9 case 10 : return_pin = P0_21;break; //D10 case 13 : return_pin = P0_11;break; //D13/LED case 14 : return_pin = P0_9;break; //NFC1 case 15 : return_pin = P0_10;break; //NFC2 default : return_pin = (PinName)NC;break; } #endif return (return_pin); } /**************************************************************************** * END OF FILE ****************************************************************************/
C++
CL
0b4144703c0339fbbcc31a07d44a170c5ae69a213d3edcb9e8e5552d31585673
/* * File name: bmp.c * Created on: 15. 3. 2014 * Author: Adam Siroky * Login: xsirok07 * Type: Source file * Description: Include functions for dictionary */ #include "gif2bmp.h" #include <stdio.h> #include <stdlib.h> #include <getopt.h> #include <unistd.h> #include <sys/types.h> #include <string.h> #include <inttypes.h> #include "gif.h" #include "dictionary.h" #include "constant.h" /** * Create and initialize new dictionary item * * @param colorIndex Color table index of new list item * @return Pointer to new list item */ tLIST_ITEM *newDicItem(int colorIndex) { tLIST_ITEM *item = (tLIST_ITEM*)malloc(sizeof(tLIST_ITEM)); if (item != NULL) item->colorTableIndex = colorIndex; item->nextColor = NULL; return item; } /** * Dealocate dictionary list item * * @param list Pointer to list item */ void freeFirstListItem(tDIC_ITEM *list) { tLIST_ITEM *item = list->first; if(item != NULL) { list->first = item->nextColor; free(item); } } /** * Dealocate dictionary color list * @param list */ void dealocateColorList(tDIC_ITEM *list) { while (list->first != NULL) freeFirstListItem(list); list->last = NULL; } /** * Get color list length (number of colors) * * @param list Dictionary color list * @return List length */ int listLength(tDIC_ITEM *list) { int length = 0; tLIST_ITEM *item = list->first; while (item != NULL) { length++; item = item->nextColor; } return length; } /** * Copy dictionary source list to dictionary destination list * * @param sourcelist Pointer to dictionary source list * @param destlist Pointer to dictionary destination list * @return 0 on success, 1 on failure */ int copyLists(tDIC_ITEM *sourcelist, tDIC_ITEM *destlist) { // Get source list first item tLIST_ITEM *sourceItem = sourcelist->first; // Copy first item if (sourceItem != NULL) { destlist->first = newDicItem(sourceItem->colorTableIndex); if (destlist->first == NULL) { fprintf(stderr, "%s", "Can not create dictionary."); return EXIT_FAILURE; } destlist->last = destlist->first; } else // Empty source list return EXIT_SUCCESS; // Copy rest of list tLIST_ITEM *destItem = destlist->first; sourceItem = sourceItem->nextColor; while (sourceItem != NULL) { destItem->nextColor = newDicItem(sourceItem->colorTableIndex); destlist->last = destItem->nextColor; if (destItem->nextColor == NULL) { fprintf(stderr, "%s", "Can not create dictionary."); return EXIT_FAILURE; } destItem = destItem->nextColor; sourceItem = sourceItem->nextColor; } return EXIT_SUCCESS; } /** * Dealocate created dictionary records (from index EOI + 1) * * @param dictionary Pointer to dictionary */ void freeDictionary (tDICTIONARY *dictionary) { //for (int i = (dictionary->endOfInformationCode + 1); i < DICTIONARY_MAX_SIZE; i++) { for (int i = 0; i < DICTIONARY_MAX_SIZE; i++) { dealocateColorList(&(dictionary->colors[i])); } } /** * Init dictionary from active color palette (reader->activeColorTable) * * @param dictionary Pointer to dictionary * @param reader Pointer to GIF reader * @return 0 on success, 1 on failure */ int initDictionary (tDICTIONARY *dictionary, tGIFREADER *reader) { // Init dictionary pointers for (int i = 0; i < DICTIONARY_MAX_SIZE; i++) { dictionary->colors[i].first = NULL; dictionary->colors[i].last = NULL; } // Insert color table into dictionary int i; for (i = 0; i < reader->activeColorTableSize; i++) { dictionary->colors[i].first = newDicItem(i); if (dictionary->colors[i].first == NULL) { fprintf(stderr, "%s", "Can not create dictionary."); return EXIT_FAILURE; } dictionary->colors[i].last = dictionary->colors[i].first; } // Init dictionary control values dictionary->clearCode = i; dictionary->endOfInformationCode = i + 1; dictionary->previousCode = -1; dictionary->firstEmptyCode = i + 2; // Set dictionary max value for current LZW size switch (reader->lzwSize) { case(2): dictionary->curMaxCode = _2_BITS_MAX_CODE; break; case(3): dictionary->curMaxCode = _3_BITS_MAX_CODE; break; case(4): dictionary->curMaxCode = _4_BITS_MAX_CODE; break; case(5): dictionary->curMaxCode = _5_BITS_MAX_CODE; break; case(6): dictionary->curMaxCode = _6_BITS_MAX_CODE; break; case(7): dictionary->curMaxCode = _7_BITS_MAX_CODE; break; case(8): dictionary->curMaxCode = _8_BITS_MAX_CODE; break; case(9): dictionary->curMaxCode = _9_BITS_MAX_CODE; break; case(10): dictionary->curMaxCode = _10_BITS_MAX_CODE; break; case(11): dictionary->curMaxCode = _11_BITS_MAX_CODE; break; case(12): dictionary->curMaxCode = _12_BITS_MAX_CODE; break; default: fprintf(stderr, "%s", "Unsupported LZW size."); cerr << reader->lzwSize << endl; return EXIT_FAILURE; } // Check dictionary capacity for current LZW size if ((dictionary->firstEmptyCode > dictionary->curMaxCode) && (reader->lzwSize < 12)) { // Increase LZW size and max code value reader->lzwSize++; switch (reader->lzwSize) { case(2): dictionary->curMaxCode = _2_BITS_MAX_CODE; break; case(3): dictionary->curMaxCode = _3_BITS_MAX_CODE; break; case(4): dictionary->curMaxCode = _4_BITS_MAX_CODE; break; case(5): dictionary->curMaxCode = _5_BITS_MAX_CODE; break; case(6): dictionary->curMaxCode = _6_BITS_MAX_CODE; break; case(7): dictionary->curMaxCode = _7_BITS_MAX_CODE; break; case(8): dictionary->curMaxCode = _8_BITS_MAX_CODE; break; case(9): dictionary->curMaxCode = _9_BITS_MAX_CODE; break; case(10): dictionary->curMaxCode = _10_BITS_MAX_CODE; break; case(11): dictionary->curMaxCode = _11_BITS_MAX_CODE; break; case(12): dictionary->curMaxCode = _12_BITS_MAX_CODE; break; } } return EXIT_SUCCESS; } /** * reInit dictionary from active color palette (reader->activeColorTable) * * @param dictionary Pointer to dictionary * @param reader Pointer to GIF reader * @return 0 on success, 1 on failure */ int reInitDictionary (tDICTIONARY *dictionary, tGIFREADER *reader) { // set new dictionary variable int i = reader->activeColorTableSize; dictionary->clearCode = i; dictionary->endOfInformationCode = i + 1; dictionary->firstEmptyCode = i + 2; // Set dictionary max value switch (reader->lzwSize) { case(2): dictionary->curMaxCode = _2_BITS_MAX_CODE; break; case(3): dictionary->curMaxCode = _3_BITS_MAX_CODE; break; case(4): dictionary->curMaxCode = _4_BITS_MAX_CODE; break; case(5): dictionary->curMaxCode = _5_BITS_MAX_CODE; break; case(6): dictionary->curMaxCode = _6_BITS_MAX_CODE; break; case(7): dictionary->curMaxCode = _7_BITS_MAX_CODE; break; case(8): dictionary->curMaxCode = _8_BITS_MAX_CODE; break; case(9): dictionary->curMaxCode = _9_BITS_MAX_CODE; break; case(10): dictionary->curMaxCode = _10_BITS_MAX_CODE; break; case(11): dictionary->curMaxCode = _11_BITS_MAX_CODE; break; case(12): dictionary->curMaxCode = _12_BITS_MAX_CODE; break; default: fprintf(stderr, "%s", "Unsupported LZW size."); return EXIT_FAILURE; } // Check dictionary capacity for current LZW size if ((dictionary->firstEmptyCode > dictionary->curMaxCode) && (reader->lzwSize < 12)) { // Increase LZW size and set new current max code reader->lzwSize++; switch (reader->lzwSize) { case(2): dictionary->curMaxCode = _2_BITS_MAX_CODE; break; case(3): dictionary->curMaxCode = _3_BITS_MAX_CODE; break; case(4): dictionary->curMaxCode = _4_BITS_MAX_CODE; break; case(5): dictionary->curMaxCode = _5_BITS_MAX_CODE; break; case(6): dictionary->curMaxCode = _6_BITS_MAX_CODE; break; case(7): dictionary->curMaxCode = _7_BITS_MAX_CODE; break; case(8): dictionary->curMaxCode = _8_BITS_MAX_CODE; break; case(9): dictionary->curMaxCode = _9_BITS_MAX_CODE; break; case(10): dictionary->curMaxCode = _10_BITS_MAX_CODE; break; case(11): dictionary->curMaxCode = _11_BITS_MAX_CODE; break; case(12): dictionary->curMaxCode = _12_BITS_MAX_CODE; break; } } // Reinit rest of dictionary indexes for (i = i + 2; i < DICTIONARY_MAX_SIZE; i++) { dealocateColorList(&(dictionary->colors[i])); dictionary->colors[i].first = NULL; dictionary->colors[i].last = NULL; } return EXIT_SUCCESS; } /** * Look for code in dictionary * * @param dictionary Pointer to dictionary * @param code Code to look for * @return 0 on success, 1 on failure */ int codeInDictionary(tDICTIONARY *dictionary, u_int32_t *code) { // Check code range if (*code >= DICTIONARY_MAX_SIZE) { fprintf(stderr, "%s", "Can not create dictionary."); return EXIT_FAILURE; } // Code in dictionary? if (dictionary->colors[*code].first == NULL) return EXIT_FAILURE; else return EXIT_SUCCESS; }
C++
CL
59a41123ac304881f863852de42b4a975dc459e5a4f6b550fad15a2f2188c67d
// wrapouter1_class0.cpp // This file is generated by Shroud nowrite-version. Do not edit. // Copyright (c) 2017-2020, Lawrence Livermore National Security, LLC and // other Shroud Project Developers. // See the top-level COPYRIGHT file for details. // // SPDX-License-Identifier: (BSD-3-Clause) // #include "wrapouter1_class0.h" #include "outer1.hpp" extern "C" { // ---------------------------------------- // Function: void method // Requested: c // Match: c_default void LIB_outer1_class0_method(LIB_outer1_class0 * self) { outer1::class0 *SH_this = static_cast<outer1::class0 *>(self->addr); SH_this->method(); } } // extern "C"
C++
CL
223f0abb0a3cfe53d98ceab5c0510c2d0aef2523dc2eb6b1c42477dd6ca84634
//////////////////////////////////////////////////////////////////////////////// /// @file CondVar.cpp /// /// @author Hubert lehaiping@126.com /// /// @brief Implementation of OS Independent Condition Variable /// /// Copyright (c) 2019 XXX /// All rights reserved /////////////////////////////////////////////////////////////////////////////// #include "system/CondVar.hpp" namespace happybus { namespace common { namespace system { CondVar::CondVar(): mCondVar() { os::condvar::init(mCondVar); } CondVar::~CondVar() { os::condvar::destroy(mCondVar); } void CondVar::wait(happybus::common::system::Mutex& mutex) { os::condvar::wait(mCondVar, mutex); } bool CondVar::wait(happybus::common::system::Mutex& mutex, const uint32_t timeoutMS) { return os::condvar::wait(mCondVar, mutex, timeoutMS); } void CondVar::signal() { os::condvar::signal(mCondVar); } void CondVar::broadcast() { os::condvar::broadcast(mCondVar); } } } }
C++
CL
214e4f97249d071a6ec21241c097d45dcc5489a3e3ce86eccb1c3e53502a3edb
#ifndef MEMORY_DRIVER_H #define MEMORY_DRIVER_H #include "cpu_driver.h" #include "tap.h" #include "pqos.h" #include <string> struct Setting { unsigned core; struct pqos_mon_data pgrp; enum pqos_mon_event events; }; class MemoryDriver { private: std::string path; Tap *tap; CpuDriver *cpu_d; bool is_numa; double BE_bandwidth; uint64_t update_time; double *bandwidths; bool update(); public: MemoryDriver(Tap *t, CpuDriver *cd); double measure_dram_bw(); double predicted_total_bw(); double LC_bw(); double BE_bw(); double BE_bw_per_core(); void clear(); }; #endif
C++
CL
f1a29762c67506a896254afee7dcaab723e1ae4dce4b5b2363ccb4b308efd853
#include "serverNetwork.h" SSVR_NAMESPACE_BEGIN uint64_t ServerNetwork::s_send_pack_id_seed = 0; // interface -------------------------------------------------------------- ServerNetwork::ServerNetwork() { slog_d("new ServerNetwork=%0", (uint64_t)this); m_is_running = false; m_listen_sid = 0; m_timer_id = 0; } ServerNetwork::~ServerNetwork() { slog_d("delete ServerNetwork=%0", (uint64_t)this); __stop(); if (m_init_param.m_sapi != NULL) { if (m_listen_sid != 0) m_init_param.m_sapi->releaseSvrListenSocket(m_listen_sid); m_init_param.m_work_looper->releasseTimer(m_timer_id); } slog_d("delete ServerNetwork=%0 end", (uint64_t)this); } bool ServerNetwork::init(const InitParam& init_param) { slog_d("init server network"); if (m_init_param.m_callback != nullptr) { slog_d("ServerNetwork::init m_init_param.m_callback != nullptr, maybe already init? ignore."); return true; } if (init_param.m_callback == NULL || init_param.m_unpacker == NULL || init_param.m_sapi == NULL || init_param.m_work_looper == NULL || init_param.m_svr_port == 0 || init_param.m_svr_ip_or_name.size() == 0 || init_param.m_send_cmd_type_to_cgi_info_map.size() == 0) { slog_e("ServerNetwork::init fail, param is invalid."); return false; } m_init_param = init_param; m_timer_id = m_init_param.m_work_looper->createTimer(this); return true; } bool ServerNetwork::start() { slog_d("start server network"); if (m_is_running) return true; m_init_param.m_work_looper->addMsgHandler(this); m_init_param.m_work_looper->addMsgTimerHandler(this); ITcpSocketCallbackApi::CreateSvrSocketParam param; param.m_callback_looper = m_init_param.m_work_looper; param.m_callback_target = this; param.m_svr_ip_or_name = m_init_param.m_svr_ip_or_name; param.m_svr_port = m_init_param.m_svr_port; if (!m_init_param.m_sapi->createSvrListenSocket(&m_listen_sid, param)) { slog_e("ServerNetwork::start fail to createSvrListenSocket"); return false; } if (!m_init_param.m_sapi->startSvrListenSocket(m_listen_sid)) { slog_e("ServerNetwork::start fail to startSvrListenSocket"); return false; } if (!m_init_param.m_work_looper->startTimer(m_timer_id, 1, 1)) { slog_e("ServerNetwork::start fail to startTimer"); return false; } m_is_running = true; return true; } void ServerNetwork::stop() { slog_d("stop server network"); __stop(); slog_d("stop server network end"); } ServerNetwork::SendPack * ServerNetwork::newSendPack(socket_id_t sid, session_id_t ssid, uint32_t send_cmd_type, uint32_t send_seq) { ServerCgiInfo* cgi_info = __getServerCgiInofoBySendCmdType(send_cmd_type); if (cgi_info == NULL) { slog_d("ServerNetwork::newSendPack fail to find cgi info, send_cmd_type=%0", send_cmd_type); return nullptr; } if (cgi_info->m_cgi_type == EServerCgiType_s2cPush && send_seq != 0) { slog_e("ServerNetwork::newSendPack fail, cgi_type=push, and send_seq != 0, send_seq=%0", send_seq); return nullptr; } SendPack* send_pack = new SendPack(); send_pack->m_send_pack_id = ++s_send_pack_id_seed; send_pack->m_send_cmd_type = send_cmd_type; send_pack->m_send_seq = send_seq; send_pack->m_sid = sid; send_pack->m_ssid = ssid; return send_pack; } bool ServerNetwork::sendPackToClient(const SendPack& send_pack) { if (!m_is_running) { slog_e("ServerNetwork::sendPackToClient fail, !m_is_running! %0", send_pack.toOverviewString()); return false; } if (send_pack.m_send_whole_pack_bin.getLen() == 0) { slog_e("ServerNetwork::sendPackToClient fail, len == 0! %0", send_pack.toOverviewString()); return false; } ServerCgiInfo* cgi_info = __getServerCgiInofoBySendCmdType(send_pack.m_send_cmd_type); if (cgi_info == nullptr) { slog_e("ServerNetwork::sendPackToClient fail, cgi_info == null! %0", send_pack.toOverviewString()); return false; } if ((cgi_info->m_cgi_type == EServerCgiType_c2sReq_s2cResp && send_pack.m_send_seq == 0) || (cgi_info->m_cgi_type == EServerCgiType_s2cPush && send_pack.m_send_seq != 0) || (cgi_info->m_cgi_type == EServerCgiType_s2cReq_c2sResp && send_pack.m_send_seq == 0)) { slog_e("ServerNetwork::sendPackToClient fail, invalid send_seq! %0", send_pack.toOverviewString()); return false; } __Client* c = __getClientBySid(send_pack.m_sid); if (c == NULL) { slog_e("ServerNetwork::sendPackToClient fail, __Client == null! %0", send_pack.toOverviewString()); return false; } slog_d("send pack to client, %0", send_pack.toOverviewString()); __SendPackInfo* spi = new __SendPackInfo(); spi->m_pack = send_pack; spi->m_send_pack_start_time_ms = TimeUtil::getMsTime(); spi->m_cgi_info = cgi_info; c->m_send_pack_infos.push_back(spi); __postSendPackMsgToSelf(); return true; } void ServerNetwork::cancelSendPackToClient(socket_id_t client_sid, uint64_t send_pack_id) { slog_d("cancel send pack to client, sid=%0, send_pack_id=%1", client_sid, send_pack_id); if (!m_is_running) return; __Client* c = __getClientBySid(client_sid); if (c == NULL) return; int index = c->getSpiIndexBySendPackId(send_pack_id); if (index < 0) return; __SendPackInfo* spi = c->m_send_pack_infos[index]; if (c->m_sending_index == index) { spi->m_is_cancel = true; } else { delete_and_erase_vector_element_by_index(&c->m_send_pack_infos, index); } } void ServerNetwork::disconnectClient(socket_id_t client_sid) { slog_d("disconnectClient, sid=%0", client_sid); if (!m_is_running) return; __stopClient(client_sid); } // message handler ------------------------------------------------------ void ServerNetwork::onMessage(Message * msg, bool* isHandled) { if (msg->m_target != this) return; //ScopeMutex __l(m_mutex); if (!m_is_running) return; if (msg->m_sender == m_init_param.m_sapi) { switch (msg->m_msg_type) { case ITcpSocketCallbackApi::EMsgType_svrListenSocketStarted: __onSvrStartedMsg((ITcpSocketCallbackApi::SvrListenSocketStartedMsg*)msg); break; case ITcpSocketCallbackApi::EMsgType_svrListenSocketStopped: __onSvrStoppedMsg((ITcpSocketCallbackApi::SvrListenSocketStoppedMsg*)msg); break; case ITcpSocketCallbackApi::EMsgType_svrListenSocketAccepted: __onSvrAcceptMsg((ITcpSocketCallbackApi::SvrListenSocketAcceptedMsg*)msg); break; case ITcpSocketCallbackApi::EMsgType_svrTranSocketStopped: __onSvrTranStoppedMsg((ITcpSocketCallbackApi::SvrTranSocketStoppedMsg*)msg); break; case ITcpSocketCallbackApi::EMsgType_svrTranSocketRecvData: __onSvrTranRecvDataMsg((ITcpSocketCallbackApi::SvrTranSocketRecvDataMsg*)msg); break; case ITcpSocketCallbackApi::EMsgType_svrTranSocketSendDataEnd: __onSvrTranSendDataEndMsg((ITcpSocketCallbackApi::SvrTranSocketSendDataEndMsg*)msg); break; } } else if (msg->m_sender == this) { switch (msg->m_msg_type) { case __EMsgType_sendPack: __onSendPackMsg(); break; } } } void ServerNetwork::onMessageTimerTick(uint64_t timer_id, void* user_data) { if (timer_id != m_timer_id) return; //ScopeMutex __l(m_mutex); } void ServerNetwork::__onSvrStartedMsg(ITcpSocketCallbackApi::SvrListenSocketStartedMsg * msg) { slog_v("__onSvrStartedMsg"); } void ServerNetwork::__onSvrStoppedMsg(ITcpSocketCallbackApi::SvrListenSocketStoppedMsg * msg) { slog_v("__onSvrStoppedMsg"); __stopAllClients(); } void ServerNetwork::__onSvrAcceptMsg(ITcpSocketCallbackApi::SvrListenSocketAcceptedMsg * msg) { slog_v("__onSvrAcceptMsg"); socket_id_t listen_sid = msg->m_svr_listen_sid; socket_id_t tran_sid = msg->m_svr_trans_sid; if (listen_sid != m_listen_sid) return; __Client* client = new __Client(); client->m_sid = tran_sid; m_sid_to_client_map[client->m_sid] = client; __postClientConnectedMsgToTarget(tran_sid); } void ServerNetwork::__onSvrTranStoppedMsg(ITcpSocketCallbackApi::SvrTranSocketStoppedMsg* msg) { slog_v("__onSvrTranStoppedMsg"); socket_id_t listen_sid = msg->m_svr_listen_sid; socket_id_t tran_sid = msg->m_svr_trans_sid; if (listen_sid != m_listen_sid) return; __Client* client = __getClientBySid(tran_sid); if (client == NULL) return; __postClientDisconnectedMsgToTarget(client->m_sid); delete_and_erase_map_element_by_key(&m_sid_to_client_map, tran_sid); } void ServerNetwork::__onSvrTranRecvDataMsg(ITcpSocketCallbackApi::SvrTranSocketRecvDataMsg * msg) { slog_v("__onSvrTranRecvDataMsg, len=%0", msg->m_data.getLen()); socket_id_t listen_sid = msg->m_svr_listen_sid; socket_id_t tran_sid = msg->m_svr_trans_sid; if (listen_sid != m_listen_sid) return; __Client* client = __getClientBySid(tran_sid); if (client == NULL) return; client->m_recv_data.append(msg->m_data); while (true) { UnpackResult r; m_init_param.m_unpacker->unpackServerRecvPack(client->m_recv_data.getData(), client->m_recv_data.getLen(), &r); if (r.m_result_type == EUnpackResultType_fail) { slog_e("EUnpackResultType_fail"); __postClientDisconnectedMsgToTarget(client->m_sid); __stopClient(client->m_sid); break; } else if (r.m_result_type == EUnpackResultType_ok) { client->m_recv_data.shrinkBegin(r.m_unpack_raw_data_len); RecvPack* recv_pack = new RecvPack(); recv_pack->m_recv_cmd_type = r.m_recv_cmd_type; recv_pack->m_recv_seq = r.m_recv_seq; recv_pack->m_recv_ext = r.m_recv_ext; recv_pack->m_sid = client->m_sid; recv_pack->m_ssid = r.m_ssid; int sent_pack_index = client->getSpiIndexBySeq(recv_pack->m_recv_seq); if (sent_pack_index >= 0) { __SendPackInfo* spi = client->m_send_pack_infos[sent_pack_index]; spi->m_pack.m_send_whole_pack_bin.clear(); //SendPackEndMsg* m = new SendPackEndMsg(); //m->m_send_pack_id = send_pack->m_pack.m_send_pack_id; //m->m_recv_pack = recv_pack; //__postMessageToTarget(m); m_init_param.m_callback->onServerNetwork_sendPackToClientEnd(this, client->m_sid, EErrCode_ok, spi->m_pack.m_send_pack_id, recv_pack); delete_and_erase_vector_element_by_index(&client->m_send_pack_infos, sent_pack_index); } else { //RecvPackMsg* m = new RecvPackMsg(); //m->m_recv_pack = recv_pack; //__postMessageToTarget(m); m_init_param.m_callback->onServerNetwork_recvPackFromClient(this, client->m_sid, recv_pack); } slog_v("recv pack, sid=%0, cmd_type=%1, seq=%2\n", client->m_sid, recv_pack->m_recv_cmd_type, recv_pack->m_recv_seq); if (client->m_recv_data.getLen() == 0) break; } else if(r.m_result_type == EUnpackResultType_needMoreData) { break; } else { slog_e("unpack err"); } } } void ServerNetwork::__onSvrTranSendDataEndMsg(ITcpSocketCallbackApi::SvrTranSocketSendDataEndMsg * msg) { slog_v("__onSvrTranSendDataEndMsg"); socket_id_t listen_sid = msg->m_svr_listen_sid; socket_id_t tran_sid = msg->m_svr_trans_sid; if (listen_sid != m_listen_sid) return; __Client* client = __getClientBySid(tran_sid); if (client == NULL) return; if (client->m_sending_index < 0) { //slog_e("ServerNetwork::__onSvrTranSendDataEndMsg client->m_sending_index < 0 err\n"); __doSendPacks(); return; } int sending_index = client->m_sending_index; client->m_sending_index = -1; __SendPackInfo* spi = client->m_send_pack_infos[sending_index]; if (spi->m_cgi_info->m_cgi_type != EServerCgiType_s2cReq_c2sResp) { if (!spi->m_is_cancel) { slog_d("send pack to client end, sid=%0, pack id=%1", spi->m_pack.m_sid, spi->m_pack.m_send_pack_id); m_init_param.m_callback->onServerNetwork_sendPackToClientEnd(this, client->m_sid, EErrCode_ok, spi->m_pack.m_send_pack_id, nullptr); } delete_and_erase_vector_element_by_index(&client->m_send_pack_infos, sending_index); } __doSendPacks(); } void ServerNetwork::__onSendPackMsg() { __doSendPacks(); } // private function ---------------------------------------------------------- void ServerNetwork::__stop() { if (!m_is_running) return; m_init_param.m_work_looper->removeMsgHandler(this); m_init_param.m_work_looper->removeMsgTimerHandler(this); m_init_param.m_work_looper->stopTimer(m_timer_id); __stopAllClients(); m_is_running = false; } void ServerNetwork::__stopClient(socket_id_t client_sid) { SidToClientMap::iterator it = m_sid_to_client_map.find(client_sid); if (it == m_sid_to_client_map.end()) return; m_init_param.m_sapi->stopSvrTranSocket(client_sid); delete it->second; m_sid_to_client_map.erase(it); } void ServerNetwork::__stopAllClients() { for (SidToClientMap::iterator it = m_sid_to_client_map.begin(); it != m_sid_to_client_map.end(); ++it) { m_init_param.m_sapi->stopSvrTranSocket(it->second->m_sid); delete it->second; } m_sid_to_client_map.clear(); } void ServerNetwork::__checkTimeOutSendPacks() { #define SVR_SEND_PACK_TIME_OUT_MS 30 * 1000 uint64_t cur_time = TimeUtil::getMsTime(); for (SidToClientMap::iterator it = m_sid_to_client_map.begin(); it != m_sid_to_client_map.end(); ++it) { __Client* c = it->second; for (size_t i = 0; i < c->m_send_pack_infos.size(); ++i) { __SendPackInfo* spi = c->m_send_pack_infos[i]; if (cur_time < spi->m_send_pack_start_time_ms + SVR_SEND_PACK_TIME_OUT_MS) continue; m_init_param.m_callback->onServerNetwork_sendPackToClientEnd(this, c->m_sid, EErrCode_system, spi->m_pack.m_send_pack_id, NULL); delete_and_erase_vector_element_by_index(&c->m_send_pack_infos, (int)i); --i; } } } void ServerNetwork::__doSendPacks() { std::vector<socket_id_t> err_sids; for (SidToClientMap::iterator it = m_sid_to_client_map.begin(); it != m_sid_to_client_map.end(); ++it) { if (!__doSendClientPacks(it->second)) { err_sids.push_back(it->first); } } for (size_t i = 0; i < err_sids.size(); ++i) { __stopClient(err_sids[i]); } } bool ServerNetwork::__doSendClientPacks(__Client* c) { if (c->m_sending_index >= 0) return true; if (c->m_send_pack_infos.size() == 0) return true; for (size_t i = 0; i < c->m_send_pack_infos.size(); ++i) { if (c->m_send_pack_infos[i]->m_is_sent) continue; c->m_sending_index = (int)i; __SendPackInfo* spi = c->m_send_pack_infos[i]; spi->m_send_pack_start_time_ms = TimeUtil::getMsTime(); if (!m_init_param.m_sapi->sendDataFromSvrTranSocketToClient(c->m_sid, spi->m_pack.m_send_whole_pack_bin.getData(), spi->m_pack.m_send_whole_pack_bin.getLen())) return false; break; } return true; } void ServerNetwork::__postSendPackMsgToSelf() { Message* msg = new Message(); msg->m_sender = this; msg->m_target = this; msg->m_msg_type = __EMsgType_sendPack; m_init_param.m_work_looper->postMessage(msg); } void ServerNetwork::__postClientConnectedMsgToTarget(socket_id_t client_sid) { m_init_param.m_callback->onServerNetwork_clientConnected(this, client_sid); //ClientConnectedMsg * m = new ClientConnectedMsg(); //m->m_client_sid = client_sid; //__postMessageToTarget(m); } void ServerNetwork::__postClientDisconnectedMsgToTarget(socket_id_t client_sid) { m_init_param.m_callback->onServerNetwork_clientDisconnected(this, client_sid); //ClientDisconnectedMsg * m = new ClientDisconnectedMsg(); //m->m_client_sid = client_sid; //__postMessageToTarget(m); } ServerNetwork::__Client* ServerNetwork::__getClientBySid(socket_id_t sid) { SidToClientMap::iterator it = m_sid_to_client_map.find(sid); if (it == m_sid_to_client_map.end()) return NULL; return it->second; } ServerCgiInfo * ServerNetwork::__getServerCgiInofoBySendCmdType(uint32_t send_cmd_type) { auto it = m_init_param.m_send_cmd_type_to_cgi_info_map.find(send_cmd_type); if (it == m_init_param.m_send_cmd_type_to_cgi_info_map.end()) return nullptr; return &it->second; } int ServerNetwork::__Client::getSpiIndexBySendPackId(uint64_t send_pack_id) { for (size_t i = 0; i < m_send_pack_infos.size(); ++i) { if (m_send_pack_infos[i]->m_pack.m_send_pack_id == send_pack_id) return (int)i; } return -1; } int ServerNetwork::__Client::getSpiIndexBySeq(uint32_t seq) { for (size_t i = 0; i < m_send_pack_infos.size(); ++i) { if (m_send_pack_infos[i]->m_pack.m_send_seq == seq) return (int)i; } return -1; } SSVR_NAMESPACE_END
C++
CL
24d884bb02713a898e33bad222a56272984c96969f8d2675a023ca266c4e6855
// Solution.cxx: implementation of the cxxSolution class. // ////////////////////////////////////////////////////////////////////// #ifdef _DEBUG #pragma warning(disable : 4786) // disable truncation warning (Only used by debugger) #endif #include <set> #include <cassert> // assert #include <algorithm> // std::sort #include "Utils.h" // define first #include "Phreeqc.h" #include "Solution.h" #include "cxxMix.h" #include "phqalloc.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// cxxSolution::cxxSolution(PHRQ_io * io) // // default constructor for cxxSolution // : cxxNumKeyword(io) { this->io = io; this->new_def = false; this->patm = 1.0; this->tc = 25.0; this->ph = 7.0; this->pe = 4.0; this->mu = 1e-7; this->ah2o = 1.0; this->total_h = 111.1; this->total_o = 55.55; this->cb = 0.0; this->density = 1.0; this->mass_water = 1.0; this->soln_vol = 1.0; this->total_alkalinity = 0.0; this->totals.type = cxxNameDouble::ND_ELT_MOLES; this->master_activity.type = cxxNameDouble::ND_SPECIES_LA; this->species_gamma.type = cxxNameDouble::ND_SPECIES_GAMMA; this->initial_data = NULL; } cxxSolution::cxxSolution(const cxxSolution &old_sol) : initial_data(NULL) { *this = old_sol; } const cxxSolution & cxxSolution::operator =(const cxxSolution &rhs) { if (this != &rhs) { this->io = rhs.io; this->n_user = rhs.n_user; this->n_user_end = rhs.n_user_end; this->description = rhs.description; this->new_def = rhs.new_def; this->patm = rhs.patm; this->tc = rhs.tc; this->ph = rhs.ph; this->pe = rhs.pe; this->mu = rhs.mu; this->ah2o = rhs.ah2o; this->total_h = rhs.total_h; this->total_o = rhs.total_o; this->density = rhs.density; this->cb = rhs.cb; this->mass_water = rhs.mass_water; this->soln_vol = rhs.soln_vol; this->total_alkalinity = rhs.total_alkalinity; this->totals = rhs.totals; this->master_activity = rhs.master_activity; this->species_gamma = rhs.species_gamma; this->isotopes = rhs.isotopes; if (this->initial_data) delete initial_data; if (rhs.initial_data != NULL) this->initial_data = new cxxISolution(*rhs.initial_data); else this->initial_data = NULL; } return *this; } cxxSolution::cxxSolution(std::map < int, cxxSolution > &solutions, cxxMix & mix, int l_n_user, PHRQ_io * io) // // constructor for cxxSolution from mixture of solutions // : cxxNumKeyword(io) { // // Zero out solution data // this->zero(); this->n_user = this->n_user_end = l_n_user; this->new_def = false; this->ah2o = 0; // // Mix solutions // const std::map < int, LDBLE >&mixcomps = mix.Get_mixComps(); std::map < int, LDBLE >::const_iterator it; for (it = mixcomps.begin(); it != mixcomps.end(); it++) { std::map < int, cxxSolution >::const_iterator sol = solutions.find(it->first); if (sol == solutions.end()) { std::ostringstream msg; msg << "Solution " << it->first << " not found in mix_cxxSolutions."; error_msg(msg.str(), CONTINUE); } else { const cxxSolution *cxxsoln_ptr1 = &(sol->second); this->add(*cxxsoln_ptr1, it->second); } } } cxxSolution::~cxxSolution() { delete this->initial_data; } void cxxSolution::dump_xml(std::ostream & s_oss, unsigned int indent) const { unsigned int i; s_oss.precision(DBL_DIG - 1); std::string indent0(""), indent1(""); for (i = 0; i < indent; ++i) indent0.append(Utilities::INDENT); for (i = 0; i < indent + 1; ++i) indent1.append(Utilities::INDENT); // Solution element and attributes s_oss << indent0; s_oss << "<solution " << "\n"; s_oss << indent1; s_oss << "soln_n_user=\"" << this->n_user << "\" " << "\n"; s_oss << indent1; s_oss << "soln_description=\"" << this->description << "\"" << "\n"; s_oss << indent1; s_oss << "soln_tc=\"" << this->tc << "\"" << "\n"; s_oss << indent1; s_oss << "soln_ph=\"" << this->ph << "\"" << "\n"; s_oss << indent1; s_oss << "soln_solution_pe=\"" << this->pe << "\"" << "\n"; s_oss << indent1; s_oss << "soln_mu=\"" << this->mu << "\"" << "\n"; s_oss << indent1; s_oss << "soln_ah2o=\"" << this->ah2o << "\"" << "\n"; s_oss << indent1; s_oss << "soln_total_h=\"" << this->total_h << "\"" << "\n"; s_oss << indent1; s_oss << "soln_total_o=\"" << this->total_o << "\"" << "\n"; s_oss << indent1; s_oss << "soln_cb=\"" << this->cb << "\"" << "\n"; s_oss << indent1; s_oss << "soln_mass_water=\"" << this->mass_water << "\"" << "\n"; s_oss << indent1; s_oss << "soln_vol=\"" << this->soln_vol << "\"" << "\n"; s_oss << indent1; s_oss << "soln_total_alkalinity=\"" << this-> total_alkalinity << "\"" << "\n"; s_oss << indent1; s_oss << "\">" << "\n"; // soln_total conc structures this->totals.dump_xml(s_oss, indent + 1); // master_activity map this->master_activity.dump_xml(s_oss, indent + 1); // species_gamma map this->species_gamma.dump_xml(s_oss, indent + 1); // End of solution s_oss << indent0; s_oss << "</solution>" << "\n"; return; } void cxxSolution::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) const { unsigned int i; s_oss.precision(DBL_DIG - 1); std::string indent0(""), indent1(""), indent2(""); for (i = 0; i < indent; ++i) indent0.append(Utilities::INDENT); for (i = 0; i < indent + 1; ++i) indent1.append(Utilities::INDENT); for (i = 0; i < indent + 2; ++i) indent2.append(Utilities::INDENT); // Solution element and attributes s_oss << indent0; int n_user_local = (n_out != NULL) ? *n_out : this->n_user; s_oss << "SOLUTION_RAW " << n_user_local << " " << this->description << "\n"; s_oss << indent1; s_oss << "-temp " << this->tc << "\n"; s_oss << indent1; s_oss << "-pressure " << this->patm << "\n"; // new identifier s_oss << indent1; s_oss << "-total_h " << this->total_h << "\n"; // new identifier s_oss << indent1; s_oss << "-total_o " << this->total_o << "\n"; // new identifier s_oss << indent1; s_oss << "-cb " << this->cb << "\n"; // new identifier s_oss << indent1; s_oss << "-density " << this->density << "\n"; // soln_total conc structures s_oss << indent1; s_oss << "-totals" << "\n"; this->totals.dump_raw(s_oss, indent + 2); // Isotopes { for (std::map < std::string, cxxSolutionIsotope >::const_iterator it = this->isotopes.begin(); it != isotopes.end(); ++it) { s_oss << indent1 << "-Isotope" << "\n"; it->second.dump_raw(s_oss, indent + 2); } } s_oss << indent1; s_oss << "-pH " << this->ph << "\n"; s_oss << indent1; s_oss << "-pe " << this->pe << "\n"; // new identifier s_oss << indent1; s_oss << "-mu " << this->mu << "\n"; // new identifier s_oss << indent1; s_oss << "-ah2o " << this->ah2o << "\n"; // new identifier s_oss << indent1; s_oss << "-mass_water " << this->mass_water << "\n"; // new identifier s_oss << indent1; s_oss << "-soln_vol " << this->soln_vol << "\n"; // new identifier s_oss << indent1; s_oss << "-total_alkalinity " << this->total_alkalinity << "\n"; // master_activity map s_oss << indent1; s_oss << "-activities" << "\n"; this->master_activity.dump_raw(s_oss, indent + 2); // species_gamma map s_oss << indent1; s_oss << "-gammas" << "\n"; this->species_gamma.dump_raw(s_oss, indent + 2); return; } #ifdef USE_REVISED_READ_RAW void cxxSolution::read_raw(CParser & parser, bool check) { // Used if it is modify cxxNameDouble original_totals = this->totals; cxxNameDouble original_activities(this->master_activity); this->master_activity.clear(); std::istream::pos_type ptr; std::istream::pos_type next_char; std::string token; int opt_save; // Read solution number and description this->read_number_description(parser.line()); this->Set_new_def(false); opt_save = CParser::OPT_ERROR; bool tc_defined(false); bool ph_defined(false); bool pe_defined(false); bool mu_defined(false); bool ah2o_defined(false); bool total_h_defined(false); bool total_o_defined(false); bool cb_defined(false); bool mass_water_defined(false); bool total_alkalinity_defined(false); for (;;) { int opt = parser.get_option(vopts, next_char); if (opt == CParser::OPT_DEFAULT) { opt = opt_save; } switch (opt) { case CParser::OPT_EOF: break; case CParser::OPT_KEYWORD: break; case CParser::OPT_DEFAULT: case CParser::OPT_ERROR: opt = CParser::OPT_EOF; parser.error_msg("Unknown input in SOLUTION_RAW keyword.", PHRQ_io::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE); continue; case 0: // totals { cxxNameDouble temp_totals; if (temp_totals.read_raw(parser, next_char) != CParser::PARSER_OK) { parser.incr_input_error(); parser. error_msg("Expected element name and moles for totals.", PHRQ_io::OT_CONTINUE); } else { this->totals.merge_redox(temp_totals); } } opt_save = 0; break; case 1: // activities if (this->master_activity.read_raw(parser, next_char) != CParser::PARSER_OK) { parser.incr_input_error(); parser. error_msg ("Expected species name and log activity for activities.", PHRQ_io::OT_CONTINUE); } opt_save = 1; break; case 2: // gammas if (this->species_gamma.read_raw(parser, next_char) != CParser::PARSER_OK) { parser.incr_input_error(); parser. error_msg ("Expected species name and activity coefficient for gammas.", PHRQ_io::OT_CONTINUE); } opt_save = 2; break; case 3: // isotope { std::string name; if (!(parser.get_iss() >> name)) { parser.incr_input_error(); parser.error_msg("Expected character value for isotope name.", PHRQ_io::OT_CONTINUE); } else { cxxSolutionIsotope iso(this->Get_io()); iso.Set_isotope_name(name.c_str()); iso.read_raw(parser, check); this->isotopes[name] = iso; } } opt_save = CParser::OPT_DEFAULT; break; case 4: // temp case 5: // tc_avoid_conflict_with_technetium case 6: // temperature if (!(parser.get_iss() >> this->tc)) { this->tc = 25.0; parser.incr_input_error(); parser.error_msg("Expected numeric value for temperature.", PHRQ_io::OT_CONTINUE); } tc_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 7: // ph if (!(parser.get_iss() >> this->ph)) { this->ph = 7.0; parser.incr_input_error(); parser.error_msg("Expected numeric value for pH.", PHRQ_io::OT_CONTINUE); } ph_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 8: // pe if (!(parser.get_iss() >> this->pe)) { this->pe = 4.0; parser.incr_input_error(); parser.error_msg("Expected numeric value for pe.", PHRQ_io::OT_CONTINUE); } pe_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 9: // mu case 10: // ionic_strength if (!(parser.get_iss() >> this->mu)) { this->mu = 1e-7; parser.incr_input_error(); parser.error_msg("Expected numeric value for ionic strength.", PHRQ_io::OT_CONTINUE); } mu_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 11: // ah2o case 12: // activity_water if (!(parser.get_iss() >> this->ah2o)) { this->ah2o = 1.0; parser.incr_input_error(); parser. error_msg("Expected numeric value for activity of water.", PHRQ_io::OT_CONTINUE); } ah2o_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 13: // total_h if (!(parser.get_iss() >> this->total_h)) { this->total_h = 111.1; parser.incr_input_error(); parser.error_msg("Expected numeric value for total hydrogen.", PHRQ_io::OT_CONTINUE); } total_h_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 14: // total_o if (!(parser.get_iss() >> this->total_o)) { this->total_o = 55.55; parser.incr_input_error(); parser.error_msg("Expected numeric value for total oxygen.", PHRQ_io::OT_CONTINUE); } total_o_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 15: // mass_water case 16: // mass_h2o if (!(parser.get_iss() >> this->mass_water)) { this->mass_water = 1.0; parser.incr_input_error(); parser.error_msg("Expected numeric value for mass of water.", PHRQ_io::OT_CONTINUE); } mass_water_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 17: // total_alkalinity case 18: // total_alk if (!(parser.get_iss() >> this->total_alkalinity)) { this->total_alkalinity = 0; parser.incr_input_error(); parser. error_msg("Expected numeric value for total_alkalinity.", PHRQ_io::OT_CONTINUE); } total_alkalinity_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 19: // cb case 20: // charge_balance if (!(parser.get_iss() >> this->cb)) { this->cb = 0; parser.incr_input_error(); parser.error_msg("Expected numeric value for charge balance.", PHRQ_io::OT_CONTINUE); } cb_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 21: // density if (!(parser.get_iss() >> this->density)) { this->density = 1.0; parser.incr_input_error(); parser.error_msg("Expected numeric value for density.", PHRQ_io::OT_CONTINUE); } opt_save = CParser::OPT_DEFAULT; break; } if (opt == CParser::OPT_EOF || opt == CParser::OPT_KEYWORD) break; } if (check) { // all members must be defined if (tc_defined == false) { parser.incr_input_error(); parser.error_msg("Temp not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } if (ph_defined == false) { parser.incr_input_error(); parser.error_msg("pH not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } if (pe_defined == false) { parser.incr_input_error(); parser.error_msg("pe not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } if (mu_defined == false) { parser.incr_input_error(); parser.error_msg("Ionic strength not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } if (ah2o_defined == false) { parser.incr_input_error(); parser. error_msg("Activity of water not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } if (total_h_defined == false) { parser.incr_input_error(); parser.error_msg("Total hydrogen not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } if (total_o_defined == false) { parser.incr_input_error(); parser.error_msg("Total oxygen not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } if (cb_defined == false) { parser.incr_input_error(); parser.error_msg("Charge balance not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } if (mass_water_defined == false) { parser.incr_input_error(); parser.error_msg("Temp not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } if (total_alkalinity_defined == false) { parser.incr_input_error(); parser. error_msg("Total alkalinity not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } } // Update activities if (original_activities.size() > 0) { cxxNameDouble new_activities = this->master_activity; this->master_activity = original_activities; this->Update_activities(original_totals); cxxNameDouble::iterator it = new_activities.begin(); for ( ; it != new_activities.end(); it++) { this->master_activity[it->first] = it->second; } } return; } #endif void cxxSolution::read_raw(CParser & parser, bool check) { // Used if it is modify cxxNameDouble simple_original_totals = this->totals.Simplify_redox(); cxxNameDouble original_activities(this->master_activity); this->master_activity.clear(); std::istream::pos_type ptr; std::istream::pos_type next_char; std::string token; int opt_save; // Read solution number and description this->read_number_description(parser.line()); opt_save = CParser::OPT_ERROR; bool tc_defined(false); bool ph_defined(false); bool pe_defined(false); bool mu_defined(false); bool ah2o_defined(false); bool total_h_defined(false); bool total_o_defined(false); bool cb_defined(false); bool mass_water_defined(false); bool total_alkalinity_defined(false); for (;;) { int opt = parser.get_option(vopts, next_char); if (opt == CParser::OPT_DEFAULT) { opt = opt_save; } switch (opt) { case CParser::OPT_EOF: break; case CParser::OPT_KEYWORD: break; case CParser::OPT_DEFAULT: case CParser::OPT_ERROR: opt = CParser::OPT_EOF; parser.error_msg("Unknown input in SOLUTION_RAW keyword.", PHRQ_io::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE); continue; case 0: // totals { cxxNameDouble temp_totals; if (temp_totals.read_raw(parser, next_char) != CParser::PARSER_OK) { parser.incr_input_error(); parser. error_msg("Expected element name and moles for totals.", PHRQ_io::OT_CONTINUE); } else { this->totals.merge_redox(temp_totals); } } opt_save = 0; break; case 1: // activities if (this->master_activity.read_raw(parser, next_char) != CParser::PARSER_OK) { parser.incr_input_error(); parser. error_msg ("Expected species name and log activity for activities.", PHRQ_io::OT_CONTINUE); } opt_save = 1; break; case 2: // gammas if (this->species_gamma.read_raw(parser, next_char) != CParser::PARSER_OK) { parser.incr_input_error(); parser. error_msg ("Expected species name and activity coefficient for gammas.", PHRQ_io::OT_CONTINUE); } opt_save = 2; break; case 3: // isotope { std::string name; if (!(parser.get_iss() >> name)) { parser.incr_input_error(); parser.error_msg("Expected character value for isotope name.", PHRQ_io::OT_CONTINUE); } else { cxxSolutionIsotope iso(this->Get_io()); iso.Set_isotope_name(name.c_str()); iso.read_raw(parser, check); this->isotopes[name] = iso; } } opt_save = CParser::OPT_DEFAULT; break; case 4: // temp case 5: // tc_avoid_conflict_with_technetium case 6: // temperature if (!(parser.get_iss() >> this->tc)) { this->tc = 25.0; parser.incr_input_error(); parser.error_msg("Expected numeric value for temperature.", PHRQ_io::OT_CONTINUE); } tc_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 7: // ph if (!(parser.get_iss() >> this->ph)) { this->ph = 7.0; parser.incr_input_error(); parser.error_msg("Expected numeric value for pH.", PHRQ_io::OT_CONTINUE); } ph_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 8: // pe if (!(parser.get_iss() >> this->pe)) { this->pe = 4.0; parser.incr_input_error(); parser.error_msg("Expected numeric value for pe.", PHRQ_io::OT_CONTINUE); } pe_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 9: // mu case 10: // ionic_strength if (!(parser.get_iss() >> this->mu)) { this->mu = 1e-7; parser.incr_input_error(); parser.error_msg("Expected numeric value for ionic strength.", PHRQ_io::OT_CONTINUE); } mu_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 11: // ah2o case 12: // activity_water if (!(parser.get_iss() >> this->ah2o)) { this->ah2o = 1.0; parser.incr_input_error(); parser. error_msg("Expected numeric value for activity of water.", PHRQ_io::OT_CONTINUE); } ah2o_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 13: // total_h if (!(parser.get_iss() >> this->total_h)) { this->total_h = 111.1; parser.incr_input_error(); parser.error_msg("Expected numeric value for total hydrogen.", PHRQ_io::OT_CONTINUE); } total_h_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 14: // total_o if (!(parser.get_iss() >> this->total_o)) { this->total_o = 55.55; parser.incr_input_error(); parser.error_msg("Expected numeric value for total oxygen.", PHRQ_io::OT_CONTINUE); } total_o_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 15: // mass_water case 16: // mass_h2o if (!(parser.get_iss() >> this->mass_water)) { this->mass_water = 1.0; parser.incr_input_error(); parser.error_msg("Expected numeric value for mass of water.", PHRQ_io::OT_CONTINUE); } mass_water_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 17: // total_alkalinity case 18: // total_alk if (!(parser.get_iss() >> this->total_alkalinity)) { this->total_alkalinity = 0; parser.incr_input_error(); parser. error_msg("Expected numeric value for total_alkalinity.", PHRQ_io::OT_CONTINUE); } total_alkalinity_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 19: // cb case 20: // charge_balance if (!(parser.get_iss() >> this->cb)) { this->cb = 0; parser.incr_input_error(); parser.error_msg("Expected numeric value for charge balance.", PHRQ_io::OT_CONTINUE); } cb_defined = true; opt_save = CParser::OPT_DEFAULT; break; case 21: // density if (!(parser.get_iss() >> this->density)) { this->density = 1.0; parser.incr_input_error(); parser.error_msg("Expected numeric value for density.", PHRQ_io::OT_CONTINUE); } opt_save = CParser::OPT_DEFAULT; break; case 22: // pressure if (!(parser.get_iss() >> this->patm)) { this->patm = 1.0; parser.incr_input_error(); parser.error_msg("Expected numeric value for pressure.", PHRQ_io::OT_CONTINUE); } opt_save = CParser::OPT_DEFAULT; break; case 23: // soln_vol if (!(parser.get_iss() >> this->soln_vol)) { this->soln_vol = 1.0; parser.incr_input_error(); parser.error_msg("Expected numeric value for solution volume.", PHRQ_io::OT_CONTINUE); } opt_save = CParser::OPT_DEFAULT; break; } if (opt == CParser::OPT_EOF || opt == CParser::OPT_KEYWORD) break; } if (check) { // all members must be defined if (tc_defined == false) { parser.incr_input_error(); parser.error_msg("Temp not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } if (ph_defined == false) { parser.incr_input_error(); parser.error_msg("pH not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } if (pe_defined == false) { parser.incr_input_error(); parser.error_msg("pe not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } if (mu_defined == false) { parser.incr_input_error(); parser.error_msg("Ionic strength not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } if (ah2o_defined == false) { parser.incr_input_error(); parser. error_msg("Activity of water not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } if (total_h_defined == false) { parser.incr_input_error(); parser.error_msg("Total hydrogen not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } if (total_o_defined == false) { parser.incr_input_error(); parser.error_msg("Total oxygen not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } if (cb_defined == false) { parser.incr_input_error(); parser.error_msg("Charge balance not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } if (mass_water_defined == false) { parser.incr_input_error(); parser.error_msg("Temp not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } if (total_alkalinity_defined == false) { parser.incr_input_error(); parser. error_msg("Total alkalinity not defined for SOLUTION_RAW input.", PHRQ_io::OT_CONTINUE); } } // Update activities if (original_activities.size() > 0) { cxxNameDouble simple_this_totals = this->totals.Simplify_redox(); cxxNameDouble::iterator it = simple_original_totals.begin(); for ( ; it != simple_original_totals.end(); it++) { cxxNameDouble::iterator jit = simple_this_totals.find(it->first); if (jit != simple_this_totals.end()) { if (it->second > 0 && jit->second > 0.0) { LDBLE f = jit->second / it->second; if (f != 1) { original_activities.Multiply_activities_redox(it->first, f); } } } } original_activities.merge_redox(this->master_activity); this->master_activity = original_activities; } return; } void cxxSolution::Update(LDBLE h_tot, LDBLE o_tot, LDBLE charge, const cxxNameDouble &const_nd) { // H, O, charge, totals, and activities of solution are updated this->total_h = h_tot; this->total_o = o_tot; this->cb = charge; // Don`t bother to update activities? //this->Update(const_nd); this->totals = const_nd; } void cxxSolution::Update_activities(const cxxNameDouble &original_tot) { // Totals and activities of solution are updated // nd does not have H, O, charge cxxNameDouble simple_original = original_tot.Simplify_redox(); // totals after read cxxNameDouble simple_new = this->totals.Simplify_redox(); // make factors cxxNameDouble factors; { cxxNameDouble::iterator it = simple_new.begin(); cxxNameDouble::iterator jit = simple_original.begin(); while (it != simple_new.end() && jit != simple_original.end()) { int j = strcmp(it->first.c_str(), jit->first.c_str()); if (j < 0) { it++; } else if (j == 0) { if (jit->second != it->second) { if (it->second > 0 && jit->second > 0) { factors[it->first] = log10(jit->second / it->second); } } it++; jit++; } else { jit++; } } // simple_new now has factors for master activities // Now add factors to activities { cxxNameDouble::iterator activity_it = this->master_activity.begin(); cxxNameDouble::iterator factors_it = factors.begin(); std::string activity_ename; std::basic_string < char >::size_type indexCh; while (activity_it != master_activity.end() && factors_it != factors.end()) { activity_ename = activity_it->first; if (activity_ename.size() > 3) { indexCh = activity_ename.find("("); if (indexCh != std::string::npos) { activity_ename = activity_ename.substr(0, indexCh); } } int j = strcmp(factors_it->first.c_str(), activity_ename.c_str()); if (j < 0) { factors_it++; } else if (j == 0) { activity_it->second += factors_it->second; activity_it++; } else { activity_it++; } } } } } void cxxSolution::Update(const cxxNameDouble &const_nd) { // const_nd is a list of new totals, assumed to be inclusive of all elements // Totals and activities of solution are updated // nd does not have H, O, charge cxxNameDouble simple_original = this->totals.Simplify_redox(); cxxNameDouble simple_new = const_nd.Simplify_redox(); cxxNameDouble factors; { // make factors cxxNameDouble::iterator it = simple_new.begin(); cxxNameDouble::iterator jit = simple_original.begin(); while (it != simple_new.end() && jit != simple_original.end()) { int j = strcmp(it->first.c_str(), jit->first.c_str()); if (j < 0) { it++; } else if (j == 0) { if (jit->second != it->second) { if (it->second > 0 && jit->second > 0) { factors[it->first] = log10(it->second / jit->second); } } it++; jit++; } else { jit++; } } // simple_new now has factors for master activities // Now add log factors to log activities { cxxNameDouble::iterator activity_it = this->master_activity.begin(); cxxNameDouble::iterator factors_it = factors.begin(); std::string activity_ename; std::basic_string < char >::size_type indexCh; while (activity_it != master_activity.end() && factors_it != factors.end()) { activity_ename = activity_it->first; if (factors_it->first[0] < activity_ename[0]) { factors_it++; continue; } else if (factors_it->first[0] > activity_ename[0]) { activity_it++; continue; } if (activity_ename.size() > 3) { indexCh = activity_ename.find("("); if (indexCh != std::string::npos) { activity_ename = activity_ename.substr(0, indexCh); } } int j = strcmp(factors_it->first.c_str(), activity_ename.c_str()); if (j < 0) { factors_it++; } else if (j == 0) { activity_it->second += factors_it->second; activity_it++; } else { activity_it++; } } } } // update totals this->totals = simple_new; } #ifdef SKIP void cxxSolution::Update(const cxxNameDouble &const_nd) { // const_nd is updated totals cxxNameDouble simple_original_totals = this->totals.Simplify_redox(); cxxNameDouble original_activities(this->master_activity); this->master_activity.clear(); // Update activities if (original_activities.size() > 0) { cxxNameDouble nd = const_nd; cxxNameDouble simple_this_totals = nd.Simplify_redox(); cxxNameDouble::iterator it = simple_original_totals.begin(); for ( ; it != simple_original_totals.end(); it++) { cxxNameDouble::iterator jit = simple_this_totals.find(it->first); if (jit != simple_this_totals.end()) { if (it->second != 0) { LDBLE f = jit->second / it->second; if (f != 1) { original_activities.Multiply_activities_redox(it->first, f); } } } } original_activities.merge_redox(this->master_activity); this->master_activity = original_activities; } return; } #endif void cxxSolution::zero() { this->tc = 0.0; this->ph = 0.0; this->pe = 0.0; this->mu = 0.0; this->ah2o = 0.0; this->total_h = 0.0; this->total_o = 0.0; this->cb = 0.0; this->density = 1.0; this->mass_water = 0.0; this->soln_vol = 0.0; this->total_alkalinity = 0.0; this->totals.type = cxxNameDouble::ND_ELT_MOLES; this->master_activity.type = cxxNameDouble::ND_SPECIES_LA; this->species_gamma.type = cxxNameDouble::ND_SPECIES_GAMMA; this->patm = 1.0; this->initial_data = NULL; } void cxxSolution::add(const cxxSolution & addee, LDBLE extensive) // // Add existing solution to "this" solution // { if (extensive == 0.0) return; LDBLE ext1 = this->mass_water; LDBLE ext2 = addee.mass_water * extensive; LDBLE f1 = ext1 / (ext1 + ext2); LDBLE f2 = ext2 / (ext1 + ext2); this->tc = f1 * this->tc + f2 * addee.tc; this->ph = f1 * this->ph + f2 * addee.ph; this->pe = f1 * this->pe + f2 * addee.pe; this->mu = f1 * this->mu + f2 * addee.mu; this->ah2o = f1 * this->mu + f2 * addee.ah2o; this->total_h += addee.total_h * extensive; this->total_o += addee.total_o * extensive; this->cb += addee.cb * extensive; this->density = f1 * this->density + f2 * addee.density; this->patm = f1 * this->patm + f2 * addee.patm; this->mass_water += addee.mass_water * extensive; this->soln_vol += addee.soln_vol * extensive; this->total_alkalinity += addee.total_alkalinity * extensive; this->totals.add_extensive(addee.totals, extensive); this->master_activity.add_log_activities(addee.master_activity, f1, f2); this->species_gamma.add_intensive(addee.species_gamma, f1, f2); this->Add_isotopes(addee.isotopes, f2, extensive); } void cxxSolution::multiply(LDBLE extensive) // // Multiply existing solution by extensive // { if (extensive == 0.0 || extensive == 1.0) return; this->total_h *= extensive; this->total_o *= extensive; this->cb *= extensive; this->mass_water *= extensive; this->soln_vol *= extensive; this->total_alkalinity *= extensive; this->totals.multiply(extensive); this->Multiply_isotopes(extensive); } LDBLE cxxSolution::Get_total(const char *string) const { cxxNameDouble::const_iterator it = this->totals.find(string); if (it == this->totals.end()) { return (0.0); } else { return (it->second); } } #ifdef SKIP LDBLE cxxSolution::Get_total_element(const char *string) const { cxxNameDouble::const_iterator it; LDBLE d = 0.0; for (it = this->totals.begin(); it != this->totals.end(); ++it) { // C++ way to do it std::string ename(string); std::string current_ename(it->first); std::basic_string < char >::size_type indexCh; indexCh = current_ename.find("("); if (indexCh != std::string::npos) { current_ename = current_ename.substr(0, indexCh); } if (current_ename == ename) { d += it->second; } } return (d); } #endif void cxxSolution::Set_total(char *string, LDBLE d) { this->totals[string] = d; } LDBLE cxxSolution::Get_master_activity(char *string) const { cxxNameDouble::const_iterator it = this->master_activity.find(string); if (it == this->master_activity.end()) { return (0.0); } else { return (it->second); } } void cxxSolution::Set_master_activity(char *string, LDBLE d) { this->master_activity[string] = d; } void cxxSolution::Add_isotopes(const std::map < std::string, cxxSolutionIsotope > & old, LDBLE intensive, LDBLE extensive) { for (std::map < std::string, cxxSolutionIsotope >::const_iterator itold = old.begin(); itold != old.end(); ++itold) { std::map < std::string, cxxSolutionIsotope >::iterator it_this; it_this = this->isotopes.find(itold->first); if (it_this != this->isotopes.end()) { LDBLE t = it_this->second.Get_total(); t += itold->second.Get_total() * extensive; it_this->second.Set_total(t); t = it_this->second.Get_ratio(); t += itold->second.Get_ratio() * intensive; it_this->second.Set_ratio(t); t = it_this->second.Get_ratio_uncertainty(); t += itold->second.Get_ratio_uncertainty() * intensive; it_this->second.Set_ratio_uncertainty(t); it_this->second.Set_ratio_uncertainty_defined(it_this->second.Get_ratio_uncertainty_defined() || itold->second.Get_ratio_uncertainty_defined()); } else { cxxSolutionIsotope iso(itold->second); iso.Set_total(itold->second.Get_total() * extensive); this->Get_isotopes()[iso.Get_isotope_name()] = iso; } } } void cxxSolution::Multiply_isotopes(LDBLE extensive) { std::map < std::string, cxxSolutionIsotope>::iterator it; for (it = this->isotopes.begin(); it != this->isotopes.end(); it++) { LDBLE total = it->second.Get_total(); total *= extensive; it->second.Set_total(total); } } const std::vector< std::string >::value_type temp_vopts[] = { std::vector< std::string >::value_type("totals"), // 0 std::vector< std::string >::value_type("activities"), // 1 std::vector< std::string >::value_type("gammas"), // 2 std::vector< std::string >::value_type("isotopes"), // 3 std::vector< std::string >::value_type("temp"), // 4 std::vector< std::string >::value_type("tc_avoid_conflict_with_technetium"), // 5 std::vector< std::string >::value_type("temperature"), // 6 std::vector< std::string >::value_type("ph"), // 7 std::vector< std::string >::value_type("pe"), // 8 std::vector< std::string >::value_type("mu"), // 9 std::vector< std::string >::value_type("ionic_strength"), // 10 std::vector< std::string >::value_type("ah2o"), // 11 std::vector< std::string >::value_type("activity_water"), // 12 std::vector< std::string >::value_type("total_h"), // 13 std::vector< std::string >::value_type("total_o"), // 14 std::vector< std::string >::value_type("mass_water"), // 15 std::vector< std::string >::value_type("mass_h2o"), // 16 std::vector< std::string >::value_type("total_alkalinity"), // 17 std::vector< std::string >::value_type("total_alk"), // 18 std::vector< std::string >::value_type("cb"), // 19 std::vector< std::string >::value_type("charge_balance"), // 20 std::vector< std::string >::value_type("density"), // 21 std::vector< std::string >::value_type("pressure"), // 22 std::vector< std::string >::value_type("soln_vol") // 23 }; const std::vector< std::string > cxxSolution::vopts(temp_vopts, temp_vopts + sizeof temp_vopts / sizeof temp_vopts[0]);
C++
CL
c96a61e4d98224fcd5a5fd1c756a305740d787f473a5b91d80882fb98c2461c0
//------------------------------------------------------------------------------ // File: BonDriver.cpp // Implementation of BonDriver.dll // // This code is borrowed from BonDriver_Shiro //------------------------------------------------------------------------------ #ifdef _DEBUG #define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> #endif #include "BonTuner.h" // DllMain ///////////////////////////////////////////// BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID /* lpReserved */ ) { switch(ul_reason_for_call){ case DLL_PROCESS_ATTACH: #ifdef _DEBUG ::_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif CBonTuner::Init(hModule); break; case DLL_PROCESS_DETACH: CBonTuner::Finalize(); break; } return TRUE; }
C++
CL
092d6a33a75f780857b9301f80859eca7273857b959b5b37c4be620310754d27
#pragma once #include <Siv3D.hpp> /// <summary> /// 敵の種類 (衝突した時のダメージ) /// </summary> enum class EnemyType : int { Bunchin = 10, Yotiyoti = 15, Danmaku = 20 }; /// <summary> /// 敵 /// </summary> class Enemy { protected: RectF m_region; PlayMode m_mode; Vec2 m_playerPos; public: Enemy(const Vec2& pos) { m_region = RectF(180).setCenter(pos); } virtual ~Enemy() {} virtual int getDamage(bool intersects) = 0; virtual EnemyType getType() const = 0; RectF getRect() const { return m_region; } void setRect(const RectF& rect) { m_region = rect; } void setPlayerPos(const Vec2& pos) { m_playerPos = pos; } void setPlayMode(const PlayMode mode) { m_mode = mode; } bool intersects(const RectF& region) { return region.intersects(m_region); } virtual void update() = 0; virtual void draw() const = 0; }; /// <summary> /// Bunchin, 動かないけど当たると痛い /// </summary> class EnemyBunchin : public Enemy { public: EnemyBunchin(const Vec2& pos) : Enemy(pos) { } void update() { } EnemyType getType() const { return EnemyType::Bunchin; } int getDamage(bool intersects) { return intersects ? static_cast<int>(EnemyType::Bunchin) : 0; } void draw() const { m_region.movedBy(-m_playerPos + Window::BaseCenter() + Vec2(0, GameInfo::playerPosOffset))(TextureAsset(L"juujigun")).draw(); } }; /// <summary> /// Yotiyoti, よちよちブロックの上を左右に動く。当たると痛い。 /// </summary> class EnemyYotiyoti : public Enemy { private: int m_range; // +/- どのくらい移動するか (座標) const int m_speed = 3; // 移動速度 int m_relative; // 相対座標 bool m_faceRight; public: EnemyYotiyoti(const Vec2& pos, const int range) : Enemy(pos), m_range(range), m_relative(0), m_faceRight(true) { } void update() { if (Abs(m_relative) >= m_range) { m_faceRight = !m_faceRight; } m_relative += (m_faceRight ? 1 : -1) * m_speed; m_region.moveBy((m_faceRight ? 1 : -1) * m_speed, 0); } EnemyType getType() const { return EnemyType::Yotiyoti; } void setRange(const int range) { m_range = range; } int getRange() { return m_range; } int getDamage(bool intersects) { return intersects ? static_cast<int>(EnemyType::Yotiyoti) : 0; } void draw() const { m_region.movedBy(-m_playerPos + Window::BaseCenter() + Vec2(0, GameInfo::playerPosOffset))(TextureAsset(L"chusei_heishi_tetsukabuto")).draw(); } }; /// <summary> /// Danmaku, 空に浮かびながら弾を打ってくる。弾幕ってほどでもない。 /// </summary> class EnemyDanmaku : public Enemy { private: static constexpr int BULLET_DAMAGE = 10; Array<std::pair<Vec2, Vec2>> m_bullets; Stopwatch m_swInterval; static constexpr int BULLET_SPEED = 3; public: EnemyDanmaku(const Vec2& pos) : Enemy(pos) { } void update() { if (m_swInterval.ms() >= 300) { m_swInterval.reset(); } if (!m_swInterval.isActive() && m_region.center.distanceFrom(m_playerPos + Vec2(0, -100)) <= 500) { m_bullets.emplace_back(std::make_pair(m_region.center, m_playerPos + Vec2(0, -100))); m_swInterval.start(); } auto it = m_bullets.begin(); while (it != m_bullets.end()) { double dx = it->second.x - it->first.x; double dy = it->second.y - it->first.y; double prevDist = it->first.distanceFrom(it->second); it->first.moveBy(BULLET_SPEED * Cos(Atan2(dy, dx)), BULLET_SPEED * Sin(Atan2(dy, dx))); if (prevDist <= it->first.distanceFrom(it->second)) { it = m_bullets.erase(it); } else { it++; } } } EnemyType getType() const { return EnemyType::Danmaku; } int getDamage(bool intersects) { if (intersects) { return static_cast<int>(EnemyType::Danmaku); } const RectF player(m_playerPos + Vec2(-100, -200), Vec2(200, 200)); int damage = 0; auto it = m_bullets.begin(); while (it != m_bullets.end()) { if (Circle(it->first, 10).intersects(player)) { damage += BULLET_DAMAGE; it = m_bullets.erase(it); } else { it++; } } return damage; } void draw() const { // 敵 m_region.movedBy(-m_playerPos + Window::BaseCenter() + Vec2(0, GameInfo::playerPosOffset))(TextureAsset(L"war_sensya_noman")).draw(); // 弾 for (const auto p : m_bullets) { Circle(p.first, 10).movedBy(-m_playerPos + Window::BaseCenter() + Vec2(0, GameInfo::playerPosOffset)).draw(Palette::Red); } } };
C++
CL
446a8ab00295a66f0ef661a1a86540c389d1776c377c75cd4789c5c959a349f7
/*MQTT*/ #include <SPI.h> #include <Ethernet.h> #include <PubSubClient.h> #include <Time2.h> #include "Timer.h" #include <EEPROM.h> #include <Wire.h> //http://arduino.cc/en/Reference/Wire #include <DS3232RTC.h> #include "RS485_protocol.h" #include <SoftwareSerial.h> SoftwareSerial rs485 (2, 3); // receive pin, transmit pin Timer t; byte mac[] = { 0x00, 0xaa, 0xbb, 0xcc, 0xde, 0x02 }; //MAC address of Ethernet shield, use arp -an to find by IP byte server[] = { 192, 168, 1, 24 }; // IP Address of your MQTT Server. Where RasPi <nd Mosquitto is. byte ip[] = { 192, 168, 1, 202 }; // IP for this device. Arduino IP. EthernetClient ethClient; void callback(char* topic, byte* payload, unsigned int length); PubSubClient client(server, 1883, callback, ethClient); char message_buff[100]; char* clientId = "<CLIENT-ID>"; // * set a random string (max 23 chars, will be the MQTT client id) char* deviceId = "<DEVICE-ID>"; // * set your device id (will be the MQTT client username) char* deviceSecret = "<DEVICE-SECRET>"; // * set your device secret (will be the MQTT client password) char* outTopic[] = { "irrigazione/timeRTC/1", //comunica RTC time a OpenHab "irrigazione/triggerTimeAck/1", //Ack. Dopo aver ricevuto l'ora in MQTT la ritrasmetto ad OpenHab per aver certezza "irrigazione/timeToRemain/1", //Trasmette il tempo rimanente all'irragazione aggiornandolo alla frequenza UPDATEFREQUENCY "irrigazione/status/1" , //Trasmette lo stato, attivo o spento dell'irrigazione. "irrigazione/event", }; // * MQTT channel where physical updates are published const char* inTopic[] = {"time/1", //Serve a ricevere l'ora attuale aggiornata da internet "irrigazione/triggerTime/1", //Riceve l'ora a cui parte l'irrigazione "irrigazione/reset", }; //------------------------------------------------------------------------------- const char MODALITY_SELECTOR = 5; const char SQW_PIN = 2; unsigned int zona[] = {31,32,33, 34,35,36,37,38,39,40}; //pinout for relay output unsigned int timerZona[] = {2,2,2,2,2,2,2,2,2,2}; // minuti per ogni zona unsigned int NumZone = 10; //valore nel setup /*int tm_min,tm_alarm_min,timeToIrrigation; int anno, mese, giorno, ora, minuto, ora_allarme, minuto_allarme = 0; String TimeToRemain; unsigned int long tmp, count; int tm_rtc_tmp; */ void(* Riavvia)(void) = 0; void alarmIsr(); void startIrrigazione(); void tmPrint(tmElements_t tm); void setupDS3231(ALARM_TYPES_t tipologiaAllarme, byte minuti, byte ore, byte giorno); tmElements_t calculateDelay(int delayTime); void mqttConnection(); void mqttSubscribe(); tmElements_t getMQTTdate(byte * payload, unsigned int length); void sendMQTTstring(String stringa, int topicnumber); void sendMQTTdate(tmElements_t tm, int topicnumber); void notifyTimeToStart(); void sendMQTTstatus(); void setupSmart(void); void setupStupid(); void periodic(); void reset(); void notifyEndOfIrrigazione(); void setIrrigationDate( tmElements_t tm ); tmElements_t getIrrigationDate(); tmElements_t getCurrentDate(); void rtcError(); void setup(void) { Serial.begin(9600); Serial.println("IRRIGATION SETUP\n\n"); for(int i=0; i< NumZone; i++) { pinMode(zona[i], OUTPUT); //PULLUP?? digitalWrite(zona[i],LOW); delay(200); } //get mode, stupid or smart pinMode(MODALITY_SELECTOR, INPUT_PULLUP); //se a massa,modality=1 (automatico) if(digitalRead(MODALITY_SELECTOR)==HIGH){ Serial.print(" - MODALITY SMART\n"); setupSmart(); } else{ Serial.print(" - MODALITY STUPID\n"); setupStupid(); } } void setupSmart(void){ Ethernet.begin(mac, ip); mqttConnection(); tmElements_t tm_current_alarm = getIrrigationDate(); while(tm_current_alarm.Year == 0 && tm_current_alarm.Month == 0 && tm_current_alarm.Day == 0 && tm_current_alarm.Hour == 0 && tm_current_alarm.Minute == 0 ){ mqttConnection(); } Serial.print("Setup completed"); int r = t.every(60000, periodic , (void*)0); } void setupStupid(){ startIrrigazione(); //così da farla partire subito, poi nel loop ogni 24 h si setta l'interrup tmElements_t tm_alarm = calculateDelay(1440); //24h=24x60min Serial.print("RTC Time: "); tmPrint(getCurrentDate()); Serial.print("Alarm Time: "); tmPrint(tm_alarm); setupDS3231(ALM2_MATCH_HOURS, tm_alarm.Minute, tm_alarm.Hour , 1); } volatile boolean alarmIsrWasCalled = false; void alarmIsr() { alarmIsrWasCalled = true; } void loop(void) { if (alarmIsrWasCalled){ if (RTC.alarm(ALARM_2)) { // setScenario(modality, scenario); Serial.println("Interrupt scattato a: "); tmPrint(getCurrentDate()); /** * TODO: memorizzare lo storico delle irrigazioni qua. */ startIrrigazione(); notifyEndOfIrrigazione(); } alarmIsrWasCalled = false; //TODO SPOSTA SOPRA?? } mqttConnection(); t.update(); } void periodic(){ notifyTimeToStart(); } /** * IRRIGATION FUNCTION */ void startIrrigazione(){ Serial.println("\n START IRRIGAZIONE"); for(int NumeroZona=0; NumeroZona<NumZone-1; NumeroZona++){ unsigned int minutiPerZona=timerZona[NumeroZona]; digitalWrite(zona[NumeroZona],HIGH); for(int count = minutiPerZona; count > 1; count--){ Serial.println("time to finish" + count); delay(60000); // 1 minuto } digitalWrite(zona[NumeroZona],LOW); } } /** * RTC FUNCTIONS */ void tmPrint(tmElements_t tm) { // digital clock display of the time Serial.print(tm.Hour); Serial.print(":"); Serial.print(tm.Minute); Serial.print(' '); Serial.print(tm.Day); Serial.print("/"); Serial.print(tm.Month); Serial.print("/"); Serial.print(tm.Year); Serial.println(); } void setupDS3231(ALARM_TYPES_t tipologiaAllarme, byte minuti, byte ore, byte giorno){ Serial.println("Setup DS3231"); /** * first control the i2c comunication with RTC and update clock. */ //setSyncProvider() causes the Time library to synchronize with the //external RTC by calling RTC.get() every five minutes by default. setSyncProvider(RTC.get); if (timeStatus() != timeSet){ Serial.println(" RTC local sync FAIL!"); } else{ //Serial.println("RTC local Sync succed"); } // printDateTime( RTC.get() ); //Disable the default square wave of the SQW pin. RTC.squareWave(SQWAVE_NONE); //Attach an interrupt on the falling of the SQW pin. //digitalWrite(SQW_PIN, HIGH); //redundant with the following line pinMode(SQW_PIN, INPUT_PULLUP); attachInterrupt(INT0, alarmIsr, FALLING); RTC.setAlarm(tipologiaAllarme, minuti, ore, giorno); //daydate parameter should be between 1 and 7 RTC.alarm(ALARM_2); //ensure RTC interrupt flag is cleared RTC.alarmInterrupt(ALARM_2, true); } tmElements_t calculateDelay(int delayTime){ tmElements_t tm; tmElements_t tm_rtc = getCurrentDate(); int month_length; month_length=32;//uno in più perché i giorni partono da 1 e non da zero. if(tm_rtc.Month==4 || tm_rtc.Month==6 || tm_rtc.Month==9 || tm_rtc.Month==11){ month_length = 31; } if(tm_rtc.Month == 2){ month_length = 29; } int var1=tm_rtc.Minute+(delayTime%60); tm.Minute=var1%60; int var2 = (tm_rtc.Hour+(delayTime/60)+var1/60); tm.Hour=var2%24; int var3=tm_rtc.Day + var2/24; tm.Day = var3%month_length+var3/month_length;//TODO metti mounth lenght tm.Month = tm_rtc.Month+var3/month_length; tm.Year = tm_rtc.Year; return tm; } /** * MQTT FUNCTIONS */ void mqttConnection() { // add reconnection logics if (!client.connected()) { // connection to MQTT server if (client.connect("ArduinoMQTTrele")) //clientId, deviceId, deviceSecret)) { Serial.println("[PHYSICAL] Successfully connected with MQTT"); mqttSubscribe(); // topic subscription } } client.loop(); } void mqttSubscribe() { for (int i = 0; i < (sizeof(inTopic)/sizeof(int)); i++){ client.subscribe(inTopic[i]); client.loop(); Serial.print("subscribe: "); Serial.println(inTopic[i]); } } void mqttPublish(int i, char* messaggio) { // build the topic with the light item client.publish(outTopic[i], messaggio); } tmElements_t getMQTTdate(byte * payload, unsigned int length){ tmElements_t tm; int intbuff[19]; //TODO FARLO VOLATILE? Serial.println("\nMESSAGE RECEIVED ON TOPIC TIME/1 SYNC ARDUINO TIMER WITH OPENHAB TIMER"); int i; char stringbuff[19]; for(i=0; i<length; i++) { intbuff[i] = (int)payload[i]-48; //convert ascii number in int. stringbuff[i]=payload[i]; } stringbuff[i] = '\0'; String RTCtime = String(stringbuff); //le variabili intere levale e lascia tm.Hour= (intbuff[8]... /* int anno = ((intbuff[0])*1000+(intbuff[1])*100+(intbuff[2])*10+(intbuff[3])); int mese = (intbuff[5])*10+(intbuff[6]); int giorno = (intbuff[8])*10+(intbuff[9]); int ora = (intbuff[11])*10+(intbuff[12]); int minuto = (intbuff[14])*10+(intbuff[15]);*/ tm.Hour = (intbuff[11])*10+(intbuff[12]); tm.Minute = (intbuff[14])*10+(intbuff[15]); tm.Day = (intbuff[8])*10+(intbuff[9]); tm.Month = (intbuff[5])*10+(intbuff[6]); tm.Year = ((intbuff[0])*1000+(intbuff[1])*100+(intbuff[2])*10+(intbuff[3]))-2000; return tm; } void sendMQTTstring(String stringa, int topicnumber){ unsigned int str_len = stringa.length() +1; char cbuff[str_len]; stringa.toCharArray(cbuff,str_len); mqttPublish(topicnumber, cbuff); } void sendMQTTdate(tmElements_t tm, int topicnumber){ String stringa = String(tm.Hour) + ":" + String(tm.Minute); unsigned int str_len = stringa.length() +1; char cbuff[str_len]; stringa.toCharArray(cbuff,str_len); mqttPublish(topicnumber, cbuff); } void notifyTimeToStart(){ tmElements_t tm_rtc = getCurrentDate(); tmElements_t tm_alarm = getIrrigationDate(); int timeToIrrigation; int currentTime =tm_rtc.Hour*60+tm_rtc.Minute; int startTime = tm_alarm.Hour*60+tm_alarm.Minute; if(currentTime <= startTime){ timeToIrrigation = startTime - currentTime; } else{ timeToIrrigation = (1440 - currentTime) + startTime; } String OreRemain = String(abs(timeToIrrigation/60)); String MinutoRemain = String(abs((timeToIrrigation%60))); String TimeToRemain = OreRemain + ":" + MinutoRemain; sendMQTTstring(TimeToRemain,2); } void notifyEndOfIrrigazione(){ } void callback(char* topic, byte* payload, unsigned int length) { if(strcmp(topic, inTopic[0])==0){ //TOPIC 0 è l'aggiornamento dell'ora corrente da internet. //ricevuta la nuova ora da internet si controlla si è necessario sincronizzare il sistema rispetto a questo riferimento. //1 leggere tempo dall'RTC, se non lo leggi segnali in mqtt malfunzionamento scrivendo ora impossibile tipo 25 //2 confronti l'ora RTC con ora del riferimento //se differiscono allora setti l'ora di riferimento dentro al real time clok. //se questo avviene in startup allora aggiorni lo scenario zero. tmElements_t tm = getMQTTdate(payload,length); tmElements_t tm_rtc = getCurrentDate(); if(tm.Hour != tm_rtc.Hour || tm.Minute != tm_rtc.Minute || tm.Year != tm_rtc.Year){ Serial.print("Re-sync RTC clock with remote NTP clock"); RTC.write(tm); } } if(strcmp(topic, inTopic[1])==0){ //TPOIC 1 è l'ora dell'allarme quando deve scattare tmElements_t tm_alarm = getMQTTdate(payload,length); setupDS3231(ALM2_MATCH_HOURS, tm_alarm.Minute, tm_alarm.Hour, 1); sendMQTTdate(tm_alarm,1); setIrrigationDate(tm_alarm); //salva in eeprom } if(strcmp(topic, inTopic[2])==0){ //TOPI del reset reset(); Riavvia(); } } void reset(){ for (int i = 0 ; i < EEPROM.length() ; i++) { EEPROM.write(i, 0); } } void setIrrigationDate( tmElements_t tm ){ EEPROM.write(0, tm.Year); EEPROM.write(1, tm.Month); EEPROM.write(2, tm.Day); EEPROM.write(3, tm.Hour); EEPROM.write(4, tm.Minute); } tmElements_t getIrrigationDate(){ tmElements_t tm; tm.Year = EEPROM.read(0); tm.Month = EEPROM.read(1); tm.Day = EEPROM.read(2); tm.Hour = EEPROM.read(3); tm.Minute = EEPROM.read(4); return tm; } tmElements_t getCurrentDate() { tmElements_t tm; if(RTC.read(tm)==0){//success return tm; } else { rtcError(); } } void rtcError(){ Serial.print("RTC ERROR"); } /* void fWrite (const byte what) { rs485.write (what); } int fAvailable () { return rs485.available (); } int fRead () { return rs485.read (); } */
C++
CL
1cca263e5aea90c28622da67d91a782b804dbe95a525b60b8a8a1e42a7d4c263
//--------------------------------------------------------------------------- #ifndef TransferMultiH #define TransferMultiH #define PreviousTransfer "History" #define CurrentTransfer "Current" //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> #include "NumericEdit.h" #include "VirtualTrees.hpp" #include <DB.hpp> #include <DBCtrls.hpp> #include <IBCustomDataSet.hpp> #include <IBDatabase.hpp> #include <IBQuery.hpp> #include <Buttons.hpp> #include <ExtCtrls.hpp> #include <Dialogs.hpp> #include <ComCtrls.hpp> #include <DBGrids.hpp> #include <Grids.hpp> #include <IBSQL.hpp> //--------------------------------------------------------------------------- struct TStockNodeData { WideString Text; int Key; int StockRequestKey; AnsiString Unit; double SourceOnHand; double DestOnHand; double Quantity; bool Initialised; TDateTime InitialisedTime; double Transfer_Real_Quantity; }; //--------------------------------------------------------------------------- const WM_LOADTRANSFER = WM_USER + 7; class TfrmTransferMulti : public TForm { __published: // IDE-managed Components TIBQuery *qrStockLoc1Old; TIBQuery *qrGetTransferStock; TDataSource *dsTransferedStock; TDBGrid *dbgTransferedStock; TDataSource *dsStockLoc1; TIBQuery *qrStockLoc2Old; TDataSource *dsStockLoc2; TIBTransaction *Transaction; TIBQuery *qrUsersOld; TIBQuery *qrGetPreviousTransfers; TVirtualStringTree *vtvStockQty; TNumericEdit *neStockQty; TTreeView *tvTransfers; TIBQuery *qrStock; TPanel *Panel1; TPanel *Panel2; TPanel *Panel9; TLabel *Label5; TLabel *lbeFrom; TLabel *lbeTo; TLabel *Label3; TLabel *lbeTitle; TLabel *lbeTransferNumber; TBitBtn *btnOk; TBitBtn *btnCancel; TBitBtn *btnFind; TFindDialog *FindDialog; TBitBtn *btnScan; TIBQuery *qrFindBarcode; TDateTimePicker *dtpTransferDate; TLabel *Label1; TEdit *edReference; TLabel *Label2; TIBQuery *IBQuery1; TIBQuery *qrUpdateStockRequest; TIBQuery *qrStockTransferManual; TIBQuery *qrdelete_stock_request; TIBQuery *qrfetch_request_number; TIBQuery *qrUpdateStockRequestQuantity; TIBSQL *sqlTransferNumber; TIBQuery *qrfindCommitedRequest; TBitBtn *btnReprint; TIBQuery *qrfetch_request_no; TIBQuery *qrUpdateRealRequestedQty; TIBQuery *qrQuantityUpdate; TIBQuery *qrStockReqUnit; void __fastcall FormShow(TObject *Sender); void __fastcall vtvStockQtyGetText(TBaseVirtualTree *Sender, PVirtualNode Node, TColumnIndex Column, TVSTTextType TextType, WideString &CellText); void __fastcall vtvStockQtyGetImageIndex(TBaseVirtualTree *Sender, PVirtualNode Node, TVTImageKind Kind, TColumnIndex Column, bool &Ghosted, int &ImageIndex); void __fastcall vtvStockQtyAfterPaint(TBaseVirtualTree *Sender, TCanvas *TargetCanvas); void __fastcall vtvStockQtyBeforePaint(TBaseVirtualTree *Sender, TCanvas *TargetCanvas); void __fastcall vtvStockQtyFocusChanged(TBaseVirtualTree *Sender, PVirtualNode Node, TColumnIndex Column); void __fastcall vtvStockQtyFocusChanging(TBaseVirtualTree *Sender, PVirtualNode OldNode, PVirtualNode NewNode, TColumnIndex OldColumn, TColumnIndex NewColumn, bool &Allowed); void __fastcall vtvStockQtyKeyDown(TObject *Sender, WORD &Key, TShiftState Shift); void __fastcall vtvStockQtyCreateEditor(TBaseVirtualTree *Sender, PVirtualNode Node, TColumnIndex Column, IVTEditLink *EditLink); void __fastcall vtvStockQtyEditing(TBaseVirtualTree *Sender, PVirtualNode Node, TColumnIndex Column, bool &Allowed); void __fastcall vtvStockQtyEdited(TBaseVirtualTree *Sender, PVirtualNode Node, TColumnIndex Column); void __fastcall neStockQtyKeyDown(TObject *Sender, WORD &Key, TShiftState Shift); void __fastcall btnOkClick(TObject *Sender); void __fastcall FormClose(TObject *Sender, TCloseAction &Action); void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose); void __fastcall btnFindClick(TObject *Sender); void __fastcall FindDialogFind(TObject *Sender); void __fastcall btnScanClick(TObject *Sender); void __fastcall neStockQtyKeyPress(TObject *Sender, char &Key); void __fastcall tvTransfersChange(TObject *Sender, TTreeNode *Node); void __fastcall btnReprintClick(TObject *Sender); private: // User declarations void __fastcall WMLoadTransfer(TMessage& Message); BEGIN_MESSAGE_MAP MESSAGE_HANDLER(WM_LOADTRANSFER, TMessage, WMLoadTransfer) END_MESSAGE_MAP(TForm) void LoadTreeView(); TStringList *BatchKeyList; void LoadStocksForManualMode(); void LoadStocksForStockRequestMode(); public: // User declarations __fastcall TfrmTransferMulti(TComponent* Owner); AnsiString Source; AnsiString Destination; TStringList* SelectedStockRequestKeys; TStringList* TransfferedStockRequestKeys; TStringList* StockRequestToBeDeletedKeys; bool isStockRequestMode; TDateTime StartTime; TStringList* CommittedStockRequestKeys; int Transfer_no; float StockTakeQty ; }; //--------------------------------------------------------------------------- //extern PACKAGE TfrmTransferMulti *frmTransferMulti; //--------------------------------------------------------------------------- #endif
C++
CL
ce046c9725f44b530e37cf788abb874464c7da07c1d4ebb293791cd7ac1b5b2f
// ------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. // ------------------------------------------------------------ #include "stdafx.h" #include <boost/test/unit_test.hpp> #include "Common/boost-taef.h" using namespace std; Common::StringLiteral const TraceType("CertificateManagerTest"); namespace Common { class CertificateManagerTest { protected: static StringLiteral const TestSource; bool VerifyInStore(wstring subName, wstring store, wstring flag); bool VerifyFile(wstring path); wstring GetDirectory(); }; StringLiteral const CertificateManagerTest::TestSource("CertificateManagerTest"); BOOST_FIXTURE_TEST_SUITE(CertificateManagerSuite, CertificateManagerTest); BOOST_AUTO_TEST_CASE(VerifyCertInStoreWithExpireDateNoDNS) { Trace.WriteInfo(CertificateManagerTest::TestSource, "*** Verify if Cert exists in Store"); wstring subName = L"TestCert_1"; wstring store = L"ROOT"; wstring profile = L"M"; SYSTEMTIME dt; GetSystemTime(&dt); dt.wDay += 1; FILETIME ft; SystemTimeToFileTime(&dt, &ft); DateTime dtExpire(ft); CertificateManager *cf = new CertificateManager(subName,dtExpire); auto error = cf->ImportToStore(store,profile); VERIFY_IS_TRUE(error.IsSuccess()); VERIFY_IS_TRUE_FMT(VerifyInStore(subName,store,profile), "No certificate found with given subject name {0}",subName); } BOOST_AUTO_TEST_CASE(VerifyCertInStoreWithDNSNoExpireDate) { Trace.WriteInfo(CertificateManagerTest::TestSource, "*** Verify if Cert exists in Store"); wstring subName = L"TestCert_2"; wstring DNS = L"client.sf.lrc.com"; wstring store = L"ROOT"; wstring profile = L"M"; CertificateManager *cf = new CertificateManager(subName, DNS); auto error = cf->ImportToStore(store, profile); VERIFY_IS_TRUE(error.IsSuccess()); VERIFY_IS_TRUE_FMT(VerifyInStore(subName, store, profile), "No certificate found with given subject name {0}", subName); } BOOST_AUTO_TEST_CASE(VerifyCertPFXNoDNSNoDate) { Trace.WriteInfo(CertificateManagerTest::TestSource, "*** Verify if Cert generated as PFX"); wstring subName = L"TestCert_3"; wstring path = L"TestCert_3.pfx"; CertificateManager *cf = new CertificateManager(subName); SecureString passWord(L""); auto error = cf->SaveAsPFX(path, passWord); VERIFY_IS_TRUE(error.IsSuccess()); VERIFY_IS_TRUE_FMT(VerifyFile(path), "Certificate with given subject name {0} could not be opened", subName); } BOOST_AUTO_TEST_CASE(VerifyCertDeletion) { Trace.WriteInfo(CertificateManagerTest::TestSource, "*** Verify if Cert deletes from store"); wstring subName = L"TestCert_4"; wstring store = L"ROOT"; wstring profile = L"M"; CertificateManager *cf = new CertificateManager(subName); auto error = cf->ImportToStore(store, profile); VERIFY_IS_TRUE(error.IsSuccess()); error = CertificateManager::DeleteCertFromStore(L"TestCert", store, profile, false); VERIFY_IS_TRUE(error.IsSuccess()); } BOOST_AUTO_TEST_CASE(VerifyPFXGeneration) { Trace.WriteInfo(CertificateManagerTest::TestSource, "Verify if PFX is generated for Alice cert"); wstring path = GetDirectory(); Trace.WriteInfo(CertificateManagerTest::TestSource, "Current Directory Path {0} ", path); wstring PFXfileName = path + L"\\certificate.pfx"; SecureString passWord(L""); std::vector<wstring> accountNamesForACL = { L"SYSTEM", L"Administrators"} ; auto error = CertificateManager::GenerateAndACLPFXFromCer( X509StoreLocation::LocalMachine, L"My", L"ad fc 91 97 13 16 8d 9f a8 ee 71 2b a2 f4 37 62 00 03 49 0d", PFXfileName, passWord, accountNamesForACL); VERIFY_IS_TRUE(error.IsSuccess()); } BOOST_AUTO_TEST_SUITE_END(); bool CertificateManagerTest::VerifyInStore(wstring subName, wstring store, wstring flag) { HCERTSTORE hStore = NULL; PCCERT_CONTEXT pTargetCert = NULL; LPCTSTR store_w = store.c_str(); if (flag == L"U") hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_CURRENT_USER, store_w); else if (flag == L"M") hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_LOCAL_MACHINE, store_w); //Enumerate over all certs and retreive those which match subName pTargetCert = CertEnumCertificatesInStore(hStore, pTargetCert); while (pTargetCert) { DWORD cbSize; //Gets size in cbSize cbSize = CertGetNameString(pTargetCert, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, NULL, 0); if (!cbSize) { return false; } //Provide cbSize to get cert name in pszName vector<wchar_t> buffer(cbSize, 0); wchar_t *pszName = &buffer[0]; if (!CertGetNameString(pTargetCert, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, pszName, cbSize)) { return false; } if (subName.compare(pszName) == 0) { CertDuplicateCertificateContext(pTargetCert); if (!CertDeleteCertificateFromStore(pTargetCert)) { return false; } } pTargetCert = CertEnumCertificatesInStore(hStore, pTargetCert); } CertFreeCertificateContext(pTargetCert); return true; } bool CertificateManagerTest::VerifyFile(wstring path) { File f; if (f.TryOpen(path).IsSuccess()) { f.Close(); File::Delete(path); return true; } else { return false; } } wstring CertificateManagerTest::GetDirectory() { wstring path; auto winSize = GetCurrentDirectory(0, NULL); auto stlSize = static_cast<size_t>(winSize); path.resize(stlSize); GetCurrentDirectory(winSize, const_cast<wchar_t *>(path.data())); path.resize(winSize - 1); return path; } }
C++
CL
75337369e9266393d6f4d2a6b63ec04a32176d751310df3a31ece0a056aa4a2f
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil c-basic-offset: 3 -*- */ // vim:cindent:ts=3:sw=3:et:tw=80:sta: /***************************vjVTK copyright begin ***************************** * * The vjVTK library is a derivitive work, based on two * seperate projects, VR Juggler and the Visualization Toolkit. * Those portions of this package which are taken from the * original works remains the works of their original authors. * For the original copyrights please refer to vrj-copyright.c.txt * and VTK_Copyright.txt respectively. vjVTK is distributed * to the extent possible under the terms of the LGPL licensing * * copyright (c) 2005,2006 Kristopher J. Blom * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * ----------------------------------------------------------------- * ***************************vjVTK copyright end ******************************/ /*========================================================================= Program: Visualization Toolkit Module: $RCSfile: vtkVJOpenGLCamera.h,v $ Language: C++ Date: $Date: 2006/10/22 19:45:45 $ Version: $Revision: 1.6 $ Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ // .NAME vtkOpenGLCamera - OpenGL camera // .SECTION Description // vtkOpenGLCamera is a concrete implementation of the abstract class // vtkCamera. vtkOpenGLCamera interfaces to the OpenGL rendering library. #ifndef __vtkVJOpenGLCamera_h #define __vtkVJOpenGLCamera_h #include "vtkCamera.h" #include <vrj/Display/Projection.h> class vtkOpenGLRenderer; class VTK_RENDERING_EXPORT vtkVJOpenGLCamera : public vtkCamera { public: static vtkVJOpenGLCamera *New(); vtkTypeRevisionMacro(vtkVJOpenGLCamera,vtkCamera); virtual void PrintSelf(ostream& os, vtkIndent indent); // Description: // Implement base class method. void Render(vtkRenderer *ren); void UpdateViewport(vtkRenderer *ren); /** * This function is really a hack. Basically it is due to the fact * That Juggler created the windows and we have to accept the possibility * of tracked surfaces (changing off-axis projection) which VTK doesn't * natively work with. Introduced originally to enable VTK's sphere * bounding box culling method. * * @param projection The vrj:Projection object for this camera's face. * Needed to get the projection matrix (frustum) */ void SetVJProjection(vrj::Projection* projection); virtual vtkMatrix4x4 *GetPerspectiveTransformMatrix(double aspect, double nearz, double farz); virtual vtkMatrix4x4 *GetViewTransformMatrix(); /** * This function is overridden in order to allow the * off-axis projection which we may end up with Juggler * Basically we just use Juggler's information to fill * in methods native to VTK. * * @param aspect window's aspect ratio * @param planes the parameters of the viewing volume */ // virtual void GetFrustumPlanes(float aspect, float planes[24]); protected: vtkVJOpenGLCamera(); ~vtkVJOpenGLCamera() {}; private: vtkVJOpenGLCamera(const vtkVJOpenGLCamera&); // Not implemented. void operator=(const vtkVJOpenGLCamera&); // Not implemented. // vrj::Projection* mVJProjection; // double mVJViewMat[16]; vtkMatrix4x4* mUserTransformMatrix; float mVJFrustum[6]; }; #endif
C++
CL
03bba9af2d9ee564aaf2a459580fc042b5e3eb04da7d081f01154a5e5160981c
#pragma once #include <string> namespace Astra { class TimezoneHelper { public: TimezoneHelper() { struct tm time_info; time_t secs, local_secs, gmt_secs; time(&secs); //带时区时间 tzset(); localtime_r(&secs, &time_info); local_secs = mktime(&time_info); //不带时区时间 gmtime_r(&secs, &time_info); gmt_secs = mktime(&time_info); timezone_diff_secs = local_secs - gmt_secs; } static int64_t timezone_diff_secs; }; class TimeUtility { public: // 得到当前的毫秒 static int64_t GetCurrentMS(); // 得到当前的微妙 static int64_t GetCurrentUS(); // 得到字符串形式的时间 格式:2015-04-10 10:11:12 static std::string GetStringTime(); // 得到字符串形式的详细时间 格式: 2015-04-10 10:11:12.967151 static const char *GetStringTimeDetail(bool reset_time = true); // 将字符串格式(2015-04-10 10:11:12)的时间,转为time_t(时间戳) static time_t GetTimeStamp(const std::string &time); // 取得两个时间戳字符串t1-t2的时间差,精确到秒,时间格式为2015-04-10 10:11:12 static time_t GetTimeDiff(const std::string &t1, const std::string &t2); static int GetDateAsInt(time_t time); static int GetTimeAsInt(time_t time); static const char *GetDateTimeStr(time_t time, char *buff, size_t buff_len); static const char *GetDateTimeStr(tm &tm, char *buff, size_t buff_len); static void ParseTime(time_t time, int &hour, int &minute, int &second); static void ParseDate(time_t time, int &year, int &month, int &day); static void ParseDateTime(time_t time, int &year, int &month, int &day, int &hour, int &minute, int &second); static void FastParseDateTime(time_t time, int &year, int &month, int &day, int &hour, int &minute, int &second, int time_zone = 8); static void tm2time(const time_t &t, struct tm &tt); static uint32_t NowDateHourInt(); static uint32_t NowDateInt(); }; // 沙漏,计算时间消耗辅助类 class HourGlassMS { public: HourGlassMS(); void Reset(); // 从记时到现在流逝的时间ms time_t Elapse(); private: time_t m_begin_time; }; } // namespace Astra
C++
CL
a6b750862c16530b43f2dda9f02298d2c3ca358e01e267563d2d4c34d9bd58fa
//Arduino 1.0+ Only //Arduino 1.0+ Only #include "Wire.h" #define DS1307_ADDRESS 0x68 #define DISPLAY_ADDRESS1 0x71 //This is the default address of the OpenSegment with both solder jumpers open int second; int minute; int hour; int currentTime; boolean stopWatchRunning = false; int stopWatchSecond = 0; int stopWatchMinute = 0; int stopWatchHour = 0; int currentSecond; int previousSecond; const int buttonGRN = 15; //green button's output connection const int buttonRED = 14; //red button's output connection const int ledBRED = 7; //the red button's LED connection const int ledBGRN = 8; //the green button's LED connection long menuHoldCounter = 0; //variable for counting how long the green button has been held const int menuHoldTime = 3000; int modeSelect = 1; //the starting value that sets the starting function state unsigned long previousMillis = 0; void setup(){ Wire.begin(); //Join the bus as master Serial.begin(9600); //Start serial communication at 9600 for debug statements Serial1.begin(9600); //Start serial communication on the Pro Micro's TXO and RXI pinMode(ledBGRN, OUTPUT); pinMode(ledBRED, OUTPUT); clearDisplay(); //Send the reset command to the display - this forces the cursor to return to the beginning of the display Wire.beginTransmission(DISPLAY_ADDRESS1); Wire.write(0x77); // Decimal control command Wire.write(0b00000010); // Turns on the second decimal Wire.endTransmission(); delay(100); } void loop(){ //Serial.print("Main Loop Current Mode: "); //debug serial print the RTC's date readings //Serial.println(modeSelect); unsigned long currentMillis = millis(); //save the milli time at the start of the loop //save the amount of time the green button is held down if (digitalRead(buttonGRN)){ menuHoldCounter += (currentMillis - previousMillis); } else { menuHoldCounter = 0; } //if the green button is held down past menuHoldTime toggle the menu boolean if (menuHoldCounter > menuHoldTime){ modeSelect = 0; menuHoldCounter = 0; } //choose a function based on the modeSelect value switch (modeSelect){ case 0: menu(); break; case 1: clockDisplay(); break; case 2: stopWatch(); break; } previousMillis = currentMillis; } void menu(){ int menuSelect = 1; //variable for choosing a mode //indicate menu mode by turning on the button LEDs... digitalWrite(ledBGRN, true); digitalWrite(ledBRED, true); //indicate menu mode by flashing the display for(int x = 0; x < 3; x++){ i2cSendValue(0); //Send all zeros to the display delay(250); clearDisplay(); delay(250); } //loop until a mode other than menu is selected while(modeSelect == 0){ i2cSendValue(menuSelect); //display the current mode selector value, starts at one delay(1); // a very small delay to prevent flickering //when the green button is pressed increment the menuSelect variable if (digitalRead(buttonGRN)){ digitalWrite(ledBGRN, false); if (menuSelect <= 1){ ++menuSelect; } else { menuSelect = 1; } delay(300); digitalWrite(ledBGRN, true); } //when the red button is pressed change the modeSelect, which will end the while loop and return to the main loop if (digitalRead(buttonRED)){ digitalWrite(ledBRED, false); modeSelect = menuSelect; delay(500); digitalWrite(ledBGRN, false); } } Wire.beginTransmission(DISPLAY_ADDRESS1); Wire.write(0x77); // Decimal control command Wire.write(0b00000010); // Turns on the second decimal Wire.endTransmission(); delay(100); } void stopWatch(){ digitalWrite(ledBGRN, stopWatchRunning); digitalWrite(ledBRED, !stopWatchRunning); i2cSendValue((stopWatchMinute*100)+stopWatchSecond); Serial.print("Stop Watch Running?: "); Serial.println(stopWatchRunning); Serial.print("Seconds: "); Serial.println(stopWatchSecond); Serial.print("Minutes: "); Serial.println(stopWatchMinute); Serial.print("Hours: "); Serial.println(stopWatchHour); getDate(); //retreive time from DS1037 currentSecond = second; if(stopWatchRunning){ getDate(); //retreive time from DS1037 currentSecond = second; if (currentSecond != previousSecond){ stopWatchSecond++; if (stopWatchSecond >= 60){ stopWatchSecond = 0; stopWatchMinute++; if (stopWatchMinute >= 60){ stopWatchMinute = 0; stopWatchHour++; } } } } if (digitalRead(buttonGRN) && stopWatchRunning == false){ digitalWrite(ledBGRN, true); digitalWrite(ledBRED, false); stopWatchRunning = true; delay(500); } if (digitalRead(buttonRED) && stopWatchRunning == true){ digitalWrite(ledBRED, true); digitalWrite(ledBGRN, false); stopWatchRunning = false; delay(500); } previousSecond = currentSecond; delay(100); } byte bcdToDec(byte val){ // Convert binary coded decimal to normal decimal numbers return ( (val/16*10) + (val%16) ); } void getDate(){ // Reset the register pointer Wire.beginTransmission(DS1307_ADDRESS); byte zero = 0x00; Wire.write(zero); Wire.endTransmission(); Wire.requestFrom(DS1307_ADDRESS, 7); second = bcdToDec(Wire.read()); minute = bcdToDec(Wire.read()); hour = bcdToDec(Wire.read() & 0b111111); //24 hour time int weekDay = bcdToDec(Wire.read()); //0-6 -> sunday - Saturday int monthDay = bcdToDec(Wire.read()); int month = bcdToDec(Wire.read()); int year = bcdToDec(Wire.read()); //print the date EG 3/1/11 23:59:59 /* Serial.print(month); Serial.print("/"); Serial.print(monthDay); Serial.print("/"); Serial.print(year); Serial.print(" "); Serial.print(hour); Serial.print(":"); Serial.print(minute); Serial.print(":"); Serial.println(second);*/ } //Given a number, i2cSendValue chops up an integer into four values and sends them out over I2C void i2cSendValue(int tempCycles){ Wire.beginTransmission(DISPLAY_ADDRESS1); // transmit to device #1 Wire.write(tempCycles / 1000); //Send the left most digit tempCycles %= 1000; //Now remove the left most digit from the number we want to display Wire.write(tempCycles / 100); tempCycles %= 100; Wire.write(tempCycles / 10); tempCycles %= 10; Wire.write(tempCycles); //Send the right most digit Wire.endTransmission(); //Stop I2C transmission } void clockDisplay(){ getDate(); //retreive date and time from DS1307 int currentTime = ((hour*100)+minute); //convert the time into a string to display on the sevSeg Serial.print("The Current Time is: "); Serial.println(currentTime); i2cSendValue(currentTime); //Send the four characters to the display delay(1000); } void clearDisplay(){ Wire.beginTransmission(DISPLAY_ADDRESS1); Wire.write('v'); Wire.endTransmission(); }
C++
CL
ac23ab1d40c6c2aa0949009d23d5e207190fbfe86af42d3b5ecf21a7c5fee0b0
#include <thread> #include <unordered_map> #include "kvmsg.hpp" #include <random> #include <format> #include <boost/algorithm/string.hpp> #include <fmt/core.h> #include <zmqpp/zmqpp.hpp> #include "bstar.hpp" class clonesrv6 { private: zmqpp::context_t ctx_; std::unordered_map<std::string, kvmsg> kvmap_; bstar bstar_; public: clonesrv6() : bstar_(true, "a", "b") { } }; int main() { clonesrv6 srv{}; }
C++
CL
9cae482831172f1fc52765a690a1a6e184cb1fda5f667d39196e897bf1889379
#ifndef RGBD_CALIB_OPENCV_HELPER_HPP #define RGBD_CALIB_OPENCV_HELPER_HPP #include <opencv/cv.h> #include <opencv/highgui.h> #include <string> /*! Prepare a chessboard calibration pattern for OpenCV calibrateCamera. */ void calibrationPattern(std::vector< std::vector<cv::Point3f> >& output, int pattern_width, int pattern_height, float square_size, int nb_images); void calibrationPattern(std::vector<cv::Point3f> & output, int pattern_width, int pattern_height, float square_size); double computeError(const cv::Mat& F, const std::vector<std::vector<cv::Point2f> >& rgb_corners, const std::vector<std::vector<cv::Point2f> >& depth_corners); void writeMatrix(cv::FileStorage& output_file, const std::string& name, const cv::Mat& matrix); void readMatrix(cv::FileStorage& input_file, const std::string& name, cv::Mat& matrix); #endif // #ifndef RGBD_CALIB_OPENCV_HELPER_HPP
C++
CL
0fb521fc8657fb37c4071861ade309c74a87563ba6749b42f38c12d6d563a92f
// This file is generated by WOK (CPPExt). // Please do not edit this file; modify original file instead. // The copyright and license terms as defined for the original file apply to // this header file considered to be the "object code" form of the original source. #ifndef _IGESAppli_Node_HeaderFile #define _IGESAppli_Node_HeaderFile #ifndef _Standard_HeaderFile #include <Standard.hxx> #endif #ifndef _Standard_DefineHandle_HeaderFile #include <Standard_DefineHandle.hxx> #endif #ifndef _Handle_IGESAppli_Node_HeaderFile #include <Handle_IGESAppli_Node.hxx> #endif #ifndef _gp_XYZ_HeaderFile #include <gp_XYZ.hxx> #endif #ifndef _Handle_IGESGeom_TransformationMatrix_HeaderFile #include <Handle_IGESGeom_TransformationMatrix.hxx> #endif #ifndef _IGESData_IGESEntity_HeaderFile #include <IGESData_IGESEntity.hxx> #endif #ifndef _Handle_IGESData_TransfEntity_HeaderFile #include <Handle_IGESData_TransfEntity.hxx> #endif #ifndef _Standard_Integer_HeaderFile #include <Standard_Integer.hxx> #endif class IGESGeom_TransformationMatrix; class gp_XYZ; class gp_Pnt; class IGESData_TransfEntity; //! defines Node, Type <134> Form <0> <br> //! in package IGESAppli <br> //! Geometric point used in the definition of a finite element. <br> class IGESAppli_Node : public IGESData_IGESEntity { public: Standard_EXPORT IGESAppli_Node(); //! This method is used to set the fields of the class Node <br> //! - aCoord : Nodal Coordinates <br> //! - aCoordSystem : the Nodal Displacement Coordinate <br> //! System Entity (default 0 is Global <br> //! Cartesian Coordinate system) <br> Standard_EXPORT void Init(const gp_XYZ& aCoord,const Handle(IGESGeom_TransformationMatrix)& aCoordSystem) ; //! returns the nodal coordinates <br> Standard_EXPORT gp_Pnt Coord() const; //! returns TransfEntity if a Nodal Displacement Coordinate <br> //! System Entity is defined <br> //! else (for Global Cartesien) returns Null Handle <br> Standard_EXPORT Handle_IGESData_TransfEntity System() const; //! Computes & returns the Type of Coordinate System : <br> //! 0 GlobalCartesian, 1 Cartesian, 2 Cylindrical, 3 Spherical <br> Standard_EXPORT Standard_Integer SystemType() const; //! returns the Nodal coordinates after transformation <br> Standard_EXPORT gp_Pnt TransformedNodalCoord() const; DEFINE_STANDARD_RTTI(IGESAppli_Node) protected: private: gp_XYZ theCoord; Handle_IGESGeom_TransformationMatrix theSystem; }; // other Inline functions and methods (like "C++: function call" methods) #endif
C++
CL
93adda0289930ccfc12cb2262111ac4678117321af7be075f44ec0fed6a31d9a
#include <fcntl.h> #include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> #include <string.h> #include <netinet/in.h> #include <netinet/tcp.h> #include <netdb.h> #include "connectors.h" #include "err.h" UdpSock UdpConnector::initServer(uint16_t port) { int sock = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP); if (sock < 0) err("Couldn't create socket\n"); struct sockaddr_in6 server_addr; server_addr.sin6_family = AF_INET6; server_addr.sin6_addr = in6addr_any; server_addr.sin6_port = htons(port); int b = bind(sock, (struct sockaddr*)&server_addr, (socklen_t)sizeof(server_addr)); if (b < 0) { err("Binding stream socket (:%d)\n", port); } if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) /* tryb nieblokujący */ err("fcntl"); return UdpSock(sock); } int get_host_addrinfo(int family, struct addrinfo** addr_out, const char* host, struct addrinfo* addr_hints, bool udp) { (void)memset(addr_hints, 0, sizeof(struct addrinfo)); addr_hints->ai_family = family; addr_hints->ai_socktype = udp ? SOCK_DGRAM : SOCK_STREAM; addr_hints->ai_protocol = udp ? IPPROTO_UDP : IPPROTO_TCP; return getaddrinfo(host, NULL, addr_hints, addr_out) != 0; } int get_sockaddr6(struct sockaddr_in6* sockaddr, const char* host, uint16_t port, bool udp) { struct addrinfo addr_hints; struct addrinfo* addr; if (get_host_addrinfo(AF_INET6, &addr, host, &addr_hints, udp)) return -1; memset(sockaddr, 0, sizeof(struct sockaddr_in6)); sockaddr->sin6_family = AF_INET6; memcpy(sockaddr->sin6_addr.s6_addr, ((struct sockaddr_in6*)(addr->ai_addr))->sin6_addr.s6_addr, sizeof(struct in6_addr)); // address IP sockaddr->sin6_port = htons(port); freeaddrinfo(addr); return 0; } int get_sockaddr4(struct sockaddr_in* sockaddr, const char* host, uint16_t port, bool udp) { struct addrinfo addr_hints; struct addrinfo* addr; if (get_host_addrinfo(AF_INET, &addr, host, &addr_hints, udp)) return -1; memset(sockaddr, 0, sizeof(struct sockaddr_in)); sockaddr->sin_family = AF_INET; sockaddr->sin_addr.s_addr = ((struct sockaddr_in*)(addr->ai_addr))->sin_addr.s_addr; // address IP sockaddr->sin_port = htons(port); freeaddrinfo(addr); return 0; } Sock TcpConnector::connectTo(std::string host, uint16_t port) { struct sockaddr_in6 addrip6; struct sockaddr_in addrip4; int sock = -1; debug("Connecting to %s:%d over TCP\n", host.c_str(), port); debug("Trying with IPv6\n"); if (!get_sockaddr6(&addrip6, host.c_str(), port, false)) sock = socket(AF_INET6, SOCK_STREAM, 0); if (sock < 0 || connect(sock, (sockaddr*)&addrip6, sizeof(addrip6)) != 0) { // IPv4 check close(sock); debug("Retrying with IPv4\n"); get_sockaddr4(&addrip4, host.c_str(), port, false); sock = socket(AF_INET, SOCK_STREAM, 0); if (connect(sock, (sockaddr*)&addrip4, sizeof(addrip4)) != 0) err("Could not connect\n"); } int flag = 1; setsockopt(sock, /* socket affected */ IPPROTO_TCP, /* set option at TCP level */ TCP_NODELAY, /* name of option */ (char*)&flag, /* the cast is historical cruft */ sizeof(int)); /* length of option value */ return Sock(sock); } UdpSock UdpConnector::connectTo(std::string host, uint16_t port) { struct sockaddr_in6 addrip6; struct sockaddr_in addrip4; int sock = -1; debug("Connecting to %s:%d over UDP\n", host.c_str(), port); debug("Trying with IPv6\n"); if (!get_sockaddr6(&addrip6, host.c_str(), port, true)) sock = socket(AF_INET6, SOCK_DGRAM, 0); if (sock < 0 || connect(sock, (sockaddr*)&addrip6, sizeof(addrip6)) != 0) { // IPv4 check close(sock); debug("Retrying with IPv4\n"); get_sockaddr4(&addrip4, host.c_str(), port, true); sock = socket(AF_INET, SOCK_DGRAM, 0); if (connect(sock, (sockaddr*)&addrip4, sizeof(addrip4)) != 0) err("Could not connect\n"); } return UdpSock(sock); }
C++
CL
dc5342a4702f426d293569af9781e055ca52ac503706c80815c0ecffdefe9125
#include <renderable_object.hpp> #include <algorithm> #include <iostream> #include <logger/logger.hpp> #include <factory.hpp> namespace renderer { constexpr std::size_t RENDR_BUF_CONTENT_SIZE{ 100000 }; constexpr std::size_t RENDR_BUF_DEFAULT_HEAD_POS{ 90000 }; Renderable::Renderable() { view_configuration.configure( View_config::supported_configs::world_space_coord ); LOG0( "New renderable, ID: ", id ); } void Renderable::set_shader( shaders::Shader::raw_poiner shader ) { rendering_data.shader = shader; } std::string Renderable::nice_name() { return "(nice name not provided)"; } ////////////////////////////////////// /// core_renderer ///////////////////////////////////// Rendr_data_buffer::Rendr_data_buffer() { LOG3( "Creating the rendering data buffer, size: ", RENDR_BUF_CONTENT_SIZE, ", default head position:", RENDR_BUF_DEFAULT_HEAD_POS ); /* * This can be tuned to allow more elements. */ try { rendr_content_buffer = std::make_unique< Rendr::raw_pointer[] >( RENDR_BUF_CONTENT_SIZE ); } catch ( std::exception& ex ) { PANIC( "Failed to allocate the buffer for the renderable object." ); } rendr_content = rendr_content_buffer.get(); buffer_head = RENDR_BUF_DEFAULT_HEAD_POS + 1; buffer_tail = RENDR_BUF_DEFAULT_HEAD_POS; } void Rendr_data_buffer::add_new_rendr( Rendr::pointer& rendr ) { /* * object with view mode set to camera_space_coord * should be rendered last. */ if ( false == rendr->object->view_configuration.is_camera_space() ) { LOG0( "Adding new rendr with ID:", rendr->id, " at the HEAD of the buffer, IDX:", buffer_head ); if ( buffer_head == 0 ) { //TODO: Those panic can be removed.. in the future.. //Just shift the buffer or whatever else.. PANIC( "No more buffer space at the head." ); } rendr_content[ --buffer_head ] = rendr.get(); } else { LOG0( "Adding new rendr with ID:", rendr->id, " at the TAIL of the buffer, IDX:", buffer_tail ); if ( buffer_tail == RENDR_BUF_CONTENT_SIZE - 1 ) { PANIC( "No more buffer space at the tail!" ); } rendr_content[ ++buffer_tail ] = rendr.get(); } } Core_renderer::Core_renderer( const types::win_size& window, const glm::mat4& proj, const glm::mat4& def_ortho, const scene::Camera::pointer cam ) : config( window ), camera{ cam } { LOG3( "Creating the core renderer!" ); config.projection = proj; config.ortho = def_ortho; shader = factory< shaders::Shader >::create(); shader->load_fragment_shader( shader->read_shader_body( "../model_shader.frag" ) ); shader->load_vertex_shader( shader->read_shader_body( "../model_shader.vert" ) ); if ( !shader->create_shader_program() ) { ERR( "Unable to create the model shader!" ); throw std::runtime_error( "Shader creation failure" ); } shader->use_shaders(); config.view_loc = shader->load_location( "view" ); config.projection_loc = shader->load_location( "projection" ); config.cur_perspective = perspective_type::projection; glUniformMatrix4fv( config.projection_loc, 1, GL_FALSE, glm::value_ptr( config.projection ) ); config.model_loc = shader->load_location( "model" ); config.color_loc = shader->load_location( "object_color" ); framebuffers = factory< buffers::Framebuffers >::create( window ); game_lights = std::make_shared< lighting::Core_lighting >(); model_picking = factory< Model_picking >::create( shader, framebuffers ); frustum = factory< scene::Frustum >::create( camera, 45.0f, ( GLfloat )window.width / ( GLfloat )window.height, 1.0f, 100.0f ); frustum_raw_ptr = frustum.get(); } types::id_type Core_renderer::add_renderable( Renderable::pointer object ) { if ( nullptr == object ) { ERR( "Invalid renderable provided" ); return -1; } LOG0( "Adding new renderable, ID ", object->id, ", name: ", object->nice_name() ); Rendr::pointer new_rendr = factory< Rendr >::create(); new_rendr->object = object.get(); new_rendr->object->set_shader( shader.get() ); renderables[ new_rendr->id ] = new_rendr; LOG0( "Assigned ID: ", new_rendr->id ); /* * object with view mode set to camera_space_coord * should be rendered last. */ rendr_data.add_new_rendr( new_rendr ); /* if( object->view_configuration.is_camera_space() ) { rendering_content.insert( rendering_content.begin() , new_rendr.get() ); } else { rendering_content.push_back( new_rendr.get() ); }*/ model_picking->add_model( object ); return new_rendr->id; } long Core_renderer::render() { long num_of_render_op{ 0 }; game_lights->calculate_lighting( shader ); frustum->update(); config.view_matrix = camera->get_view(); config.is_def_view_matrix_loaded = true; glUniformMatrix4fv( config.view_loc, 1, GL_FALSE, glm::value_ptr( config.view_matrix ) ); /* * The rendering loop is performed twice, * once for the rendering to the default framebuffer * the second time in order to update the mouse picking * data */ int_fast32_t buffer_idx_cnt = 0; for ( int_fast64_t idx = rendr_data.buffer_head; idx <= rendr_data.buffer_tail; ++idx ) { Rendr::raw_pointer cur = rendr_data.rendr_content[ idx ]; if ( Rendering_state::states::rendering_enabled != cur->object->rendering_state.current() ) { continue; } /* * We need all those variables only in the first rendering loop */ const bool is_camera_space = cur->object->view_configuration.is_camera_space(); if ( false == is_camera_space && frustum_raw_ptr->is_inside( cur->object->rendering_data.position ) < 0.0f ) { continue; } prepare_for_rendering( cur ); /* * Save the index of the renderables that are going to be * rendered, not need to loop throught all the twice. */ if ( buffer_idx_cnt >= RENDR_CTX_BUF_SIZE ) { ERR( "Rendering context buffer size exhausted! Current size: ", RENDR_CTX_BUF_SIZE, ", Interrupting the rendering!" ); return num_of_render_op; } rendering_content_idx_buffer[ buffer_idx_cnt++ ] = idx; prepare_rendr_color( cur ); if ( false == cur->object->render( ) ) { ERR( "Rendering error for renderable ID:", cur->object->id, ", disabling rendering for this renderable!" ); cur->object->rendering_state.set_error(); continue; } cur->object->clean_after_render( ); ++num_of_render_op; } /* * Second loop. */ model_picking->prepare_to_update(); for ( int_fast32_t idx = 0 ; idx < buffer_idx_cnt; ++idx ) { Rendr::raw_pointer cur = rendr_data.rendr_content[ rendering_content_idx_buffer[ idx ] ]; prepare_for_rendering( cur ); model_picking->update( cur->object ); cur->object->clean_after_render( ); ++num_of_render_op; } model_picking->complete_update(); return num_of_render_op; } lighting::lighting_pointer Core_renderer::scene_lights() { return game_lights; } Model_picking::pointer Core_renderer::picking() { return model_picking; } void Core_renderer::clear() { framebuffers->clear(); } bool Core_renderer::prepare_for_rendering( Rendr::raw_pointer cur ) { const bool is_camera_space = cur->object->view_configuration.is_camera_space(); switch_proper_perspective( cur->object ); glUniformMatrix4fv( config.model_loc, 1, GL_FALSE, glm::value_ptr( cur->object->rendering_data.model_matrix ) ); if ( is_camera_space ) { glUniformMatrix4fv( config.view_loc, 1, GL_FALSE, glm::value_ptr( cur->object->rendering_data.model_matrix ) ); config.is_def_view_matrix_loaded = false; } else if ( false == config.is_def_view_matrix_loaded ) { glUniformMatrix4fv( config.view_loc, 1, GL_FALSE, glm::value_ptr( config.view_matrix ) ); config.is_def_view_matrix_loaded = true; } cur->object->prepare_for_render( ); return true; } void Core_renderer::prepare_rendr_color( Rendr::raw_pointer cur ) const { types::color color = cur->object->rendering_data.default_color; glUniform4f( config.color_loc, color.r, color.g, color.b, color.a ); } void Core_renderer::switch_proper_perspective( const Renderable::raw_pointer obj ) { if ( obj->view_configuration.is_camera_space() && perspective_type::projection == config.cur_perspective ) { /* * Need to switch from projection to ortho */ glUniformMatrix4fv( config.projection_loc, 1, GL_FALSE, glm::value_ptr( config.ortho ) ); config.cur_perspective = perspective_type::ortho; } else if ( obj->view_configuration.is_world_space() && perspective_type::ortho == config.cur_perspective ) { /* * Need to switch from ortho to projection */ glUniformMatrix4fv( config.projection_loc, 1, GL_FALSE, glm::value_ptr( config.projection ) ); config.cur_perspective = perspective_type::projection; } } ////////////////////////////////////// /// Model_picking ///////////////////////////////////// Model_picking::Model_picking( shaders::Shader::pointer shader, buffers::Framebuffers::pointer framebuffers ) : game_shader{ shader }, framebuffers{ framebuffers } { LOG3( "Creating a new Model_picking object" ); picking_buffer_id = framebuffers->create_buffer(); shader_color_loc = game_shader->load_location( "object_color" ); } types::color Model_picking::add_model( Renderable::pointer object ) { types::color assigned_color = color_operations.get_color(); uint64_t color_code = color_operations.get_color_code( color_operations.denormalize_color( assigned_color ) ); auto it = color_to_rendr.find( color_code ); if ( it != color_to_rendr.end() ) { PANIC( "Not able to generate unique color codes." ); } LOG0( "Adding new object with color code: ", color_code, ", for the color: ", color_operations.denormalize_color( assigned_color ) ); rendrid_to_color[ object->id ] = color_code; color_to_rendr[ color_code ] = object; return assigned_color; } std::size_t Model_picking::pick( const GLuint x, const GLuint y ) { LOG3( "New 'simple' pick request: ", x, "/", y, ". queue size: ", pick_requests.size() ); pick_requests.push_back( { x, y, pick_type::simple } ); return pick_requests.size(); } std::size_t Model_picking::pick_toggle( const GLuint x, const GLuint y ) { LOG3( "New 'toggle' pick request: ", x, "/", y, ". queue size: ", pick_requests.size() ); pick_requests.push_back( { x, y, pick_type::toggle } ); return pick_requests.size(); } void Model_picking::unpick() { selected.removel_all(); } std::vector< Renderable::pointer > Model_picking::get_selected() { auto rendrs = selected.get_selected(); std::vector< Renderable::pointer > ret; for ( auto&& sel : rendrs ) { ret.push_back( sel->object ); } return ret; } std::vector<types::id_type> Model_picking::get_selected_ids() { auto rendrs = selected.get_selected(); std::vector< types::id_type > ids; for ( auto&& sel : rendrs ) { ids.push_back( sel->object->id ); } return ids; } void Model_picking::update( const Renderable::raw_pointer object ) const { const auto it = rendrid_to_color.find( object->id ); if ( rendrid_to_color.end() != it ) { //The object exist in our 'database' auto color = color_operations.get_color_rgba( it->second ); color = color_operations.normalize_color( color ); glUniform4f( shader_color_loc, color.r, color.g, color.b, color.a ); object->render( ); } } void Model_picking::prepare_to_update() { /* * Render the model in our model picking * framebuffer */ framebuffers->bind( picking_buffer_id ); game_shader->disable_light_calculations(); game_shader->disable_texture_calculations(); } void Model_picking::complete_update() { /* * Good opportunity to update whatever need * to be updated before cleaning up */ if ( pointed_model.update_required ) { pointed_model.pointed = model_at_position( pointed_model.x, pointed_model.y ); } process_pick_requests(); //Clean up game_shader->enable_texture_calculations(); game_shader->enable_light_calculations(); /* * return to default framebuffer */ framebuffers->unbind(); } void Model_picking::process_pick_requests() { for ( auto&& req : pick_requests ) { auto obj = model_at_position( req.x, req.y ); if ( obj == nullptr ) { continue; } if ( req.type == pick_type::simple ) { LOG0( "Picking model with ID: ", obj->id ); selected.add( obj ); } else if ( req.type == pick_type::toggle ) { if ( true == selected.is_selected( obj ) ) { LOG0( "Model with ID:", obj->id, " already selected, unselecting." ); //Already selected, toggle selection selected.remove( obj ); } else { LOG0( "Picking model with ID: ", obj->id, ". Position: ", obj->rendering_data.position ); selected.add( obj ); } } } pick_requests.clear(); } Renderable::pointer Model_picking::model_at_position( const GLuint x, const GLuint y ) { /* * Read the color from the model picking * frame buffer */ GLubyte pixels[3] = { 0, 0, 0 }; glReadPixels( x, y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pixels ); /* * Attempt to find the model corresponding * to the color */ const types::color color( pixels[0], pixels[1], pixels[2], 1.0f ); const uint64_t color_code = color_operations.get_color_code( color ); auto it = color_to_rendr.find( color_code ); if ( it != color_to_rendr.end() ) { return it->second; } return nullptr; } void Model_picking::set_pointed_model( const GLuint x, const GLuint y ) { pointed_model.x = x; pointed_model.y = y; pointed_model.update_required = true; } Renderable::pointer Model_picking::get_pointed_model() const { return pointed_model.pointed; } ////////////////////////////////////// /// Color_creator ///////////////////////////////////// Color_creator::Color_creator( const GLfloat step ) : color_step{ step }, next_color{ types::color( 1.0f ) }, num_of_colors{ 0 } { if ( step <= 0.0f ) { PANIC( "Negative step not allowed!" ); } max_num_of_colors = std::pow( glm::floor( 1.0f / step ), 3 ); LOG3( "Number of supported colors: ", max_num_of_colors ); } types::color Color_creator::get_color() { if ( num_of_colors >= max_num_of_colors ) { PANIC( "No more available colors, limit:", max_num_of_colors ); } auto color = next_color; auto apply_step = [this]( GLfloat & component ) { component -= color_step; if ( component < 0 ) { component = 1.0f; } return component; }; /* * Calculate the next color, note that * if we complete all the available colors * give the color_step, then the generation * restart from the beginning (white color) */ for ( int i{ 2 } ; i >= 0 ; --i ) { if ( apply_step( next_color[i] ) != 1.0f ) { break; } } ++num_of_colors; return color; } types::color Color_creator::denormalize_color( types::color color ) const { for ( int i {0}; i < 3; ++i ) { color[ i ] = std::floor( color[ i ] * 255.0f + 0.5f ); } return color; } types::color Color_creator::normalize_color( types::color color ) const { color /= 255.0f; color.a = 1.0f; return color; } uint64_t Color_creator::get_color_code( const types::color& color ) { return ( uint64_t )color.r << 16 | ( uint64_t )color.g << 8 | ( uint64_t )color.b; } types::color Color_creator::get_color_rgba( const uint64_t color_code ) const { return types::color( ( color_code >> 16 ) & 0xFF, ( color_code >> 8 ) & 0xFF, ( color_code ) & 0xFF, 1.0f ); } void Selected_models::add( Renderable::pointer object ) { LOG0( "Adding new selected model, ID: ", object->id, ", current size: ", selected.size() ); if ( find( object ) != selected.end() ) { LOG0( "Object already selected, cannot select twice!" ); return; } auto new_model_info = factory< Selected_model_info >::create( object->rendering_data.default_color, object ); selected.push_back( new_model_info ); /* * Change the default color * to highlight the model */ object->rendering_data.default_color.r *= 20.0f; } bool Selected_models::remove( Renderable::pointer object ) { auto it = find( object ); if ( it != selected.end() ) { LOG0( "Removing selected model, ID:", object->id ); object->rendering_data.default_color = ( *it )->original_color; selected.erase( it ); return true; } return false; } std::size_t Selected_models::removel_all() { for ( auto&& obj : selected ) { obj->object->rendering_data.default_color = obj->original_color; } const auto cnt = selected.size(); selected.clear(); return cnt; } std::size_t Selected_models::count() const { return selected.size(); } const Selected_model_info::container& Selected_models::get_selected() { return selected; } bool Selected_models::is_selected( const Renderable::pointer& obj ) { return find( obj ) != selected.end(); } Selected_model_info::container::iterator Selected_models::find( const Renderable::pointer& obj ) { for ( auto it = selected.begin() ; it != selected.end() ; ++it ) { if ( ( *it )->object == obj ) { return it; } } return selected.end(); } Renderable::pointer Core_renderer_proxy::pointed_model() const { return core_renderer->picking()->get_pointed_model(); } }
C++
CL
f005af2cf1ab32934a39a0e33889b925bb9092e8c300ec0381cbf2dc92141d66
#ifndef VECT_HPP #define VECT_HPP #include <iostream> #include <assert.h> #include <algorithm> #include <initializer_list> using namespace std; #ifdef _WIN32 typedef unsigned int uint; #endif template<class T = double, uint N = 2> class vect { T values [N]; public: typedef T CType; // component type static const uint dims = N; // vector size (number of dimensions) // initializes the vector in the origin vect ( const T value = 0 ) { fill( values, values + N, value ); } // initializes vector with random components uniformly drawn from a specific range vect ( Random& gen, const vect& minvalues = vect(-32), const vect& maxvalues = vect(32) ) { for ( uint i = 0; i < N; ++i ) values[i] = ( maxvalues[i] - minvalues[i] ) * gen.real() + minvalues[i]; } // copy constructor vect ( const vect& v ) { copy( v.values, v.values + N, values ); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ // initializes from a list (only works with c++0x) vect ( std::initializer_list<T> v ) { assert( v.size() == sizeof( values ) / sizeof( T ) ); copy( v.begin(), v.end(), values ); } #endif T* bits ( ) { return values; } // returns a reference to the i-th component. I avoid checks for more speed T& operator[] ( uint i ) { return values[i]; } T operator[] ( uint i ) const { return values[i]; } // assign v to *this vect& operator= ( const vect& v ) { copy( v.values, v.values + N, values ); return *this; } // subtract v from *this vect& operator-= ( const vect& v ) { for ( uint i = 0; i < N; ++i ) values[i] -= v.values[i]; return *this; } // returns the difference vector (*this - v) vect operator- ( const vect& v ) const { return vect(*this) -= v; } // unary - (changes sign to the components) vect operator- ( ) const { return vect() -= (*this); } vect& operator+= ( const vect& v ) { for ( uint i = 0; i < N; ++i ) values[i] += v.values[i]; return *this; } vect operator+ ( const vect& v ) const { return vect(*this) += v; } // euclidean norm T norm ( ) const { /*T out = 0.0; for ( uint i = 0; i < N; ++i ) out += values[i] * values[i];*/ return sqrt( (*this) * (*this) ); } // dot product of two vectors T operator* ( const vect& v ) const { //return inner_product( values, values + N, v.values, 0 ); T out = 0; for ( uint i = 0; i < N; ++i ) out += values[i] * v[i]; return out; } // multiplication by a scalar vect& operator*= ( const T& s ) { for ( uint i = 0; i < N; ++i ) values[i] *= s; return *this; } friend vect operator* ( T s, const vect& v ) { return vect(v) *= s; } friend ostream& operator<< ( ostream & os, const vect& v ) { os << "["; //os.precision( 2 ); for ( uint i = 0; i < N - 1; ++i ) os << v.values[i] << ", "; return os << v.values[N-1] << "]"; } }; #endif // VECT_HPP
C++
CL
a9b2efe3fe59a531b012fe34c93e2e689f736cc639421f294a6728881c7ae054
#ifndef FRMPRICEIMPORT_H #define FRMPRICEIMPORT_H #include <QDialog> #include "historicalPrices.h" class QFile; class frmPriceImport_UI; class frmPriceImport : public QDialog { Q_OBJECT public: enum column { column_Symbol, column_Date, column_Type, column_Value }; frmPriceImport(const historicalPricesMap &pricesMap_, QWidget *parent_ = 0); ~frmPriceImport(); historicalPricesMap getHistoricalPricesMap() { return m_pricesMap; } private slots: void accept(); void moveDown(); void moveUp(); void browse(); private: frmPriceImport_UI *ui; historicalPricesMap m_pricesMap; bool mergePrices(const historicalPricesMap &newPriceMap_, bool dryRun_); bool duplicatePriceCheck(const QString &symbol_, historicalPrices::type type_, const QMap<int, double> &values_, bool &askAgain); bool validateFilePath(); bool validateRow(int row_, const QStringList line_, const QHash<int, int> &columns_, const QString &dateFormat_); QString selectedDelimiter(); QString selectedDateFormat(); QHash<int, int> selectedColumnOrder(); }; #endif // FRMPRICEIMPORT_H
C++
CL
a6006125cda64734e4ff3bc8e2d075b986d0a4363ac1e110e1356d41e579083e
#ifndef POINTDECOLLECTE_H #define POINTDECOLLECTE_H #include <vector> #include "produit.h" #include "gestionnaireproduits.h" class Producteur; /** @brief La classe PointDeCollecte. ** ** Elle contient un constructeur, le lieu, un @ref GestionnaireProduits, et un bool qui définit si il est ouvert ou fermé. ** ** @version 1 ** ** @author P. Marty, M. Labalette, A. Larcher **/ class PointDeCollecte { private: std::string lieu; std::string jourCycle; GestionnaireProduits produitsDuPC; bool ouvert; public: /// @brief Le constructeur par défaut attribue la valeur passée en paramètre. /// /// Constructeur de la classe PointDeCollecte /// /// @param l lieux du point de collecte PointDeCollecte(std::string l); /// @brief Mets a jour la date du cycle /// /// @param jour un string pour mettre a jour la nouvelle date void setDate(std::string jour) { jourCycle = jour; }; /// @brief Recupere le lieu du point de collecte /// /// @return le lieu du point de collecte std::string getLocation() { return lieu; }; /// @brief ferme temporairement un point de collecte en mettant sa date a FERME /// /// @param pc PointDeCollecte le point de collecte a fermer temporairement void fermerPCTemp() { jourCycle = std::string("closed"); }; /// @brief Regarde si le point de collecte n'est pas fermer /// /// @return True si le point de collecte n'est pas fermer bool pcOpen() { return (jourCycle.compare(std::string("closed")) == 0); }; ~PointDeCollecte(); }; #endif // POINTDECOLLECTE_H
C++
CL
11050b4e9e39136fbdf1bc3ad389fed32d752d9736c14e44c7abe72c4df01855
#ifndef TIME_OPTIMIZER_CLASS_H_ #define TIME_OPTIMIZER_CLASS_H_ #include "ros/ros.h" // Locally defined #include "drone_planner/PVA.h" #include "drone_planner/helper.h" // TimeOptimizer libraries #include "traj_poly_mono.h" #include "time_optimizer_ecos.h" namespace time_optimizer { class TimeOptimizerClass { public: // Planning parameters double sampling_freq_; double max_vel_, max_acc_, max_jerk_, d_s_, rho_; uint poly_num_coeff_, num_segments_; // The variables below would not be necessary, but sometimes GetPVAatTime // returns samples that are wierdly high at segment transitions, // so we cap them using the variables below double max_vel_sample_, max_acc_sample_; // Trajectory to optimize on Eigen::MatrixXd polyCoeff_; Eigen::VectorXd polyTime_; // Time allocation structure (defined in timeAllocator.h) Allocator * time_allocator_ = new Allocator(); // Trajectory's final time double final_time_; TimeOptimizerClass(const double &max_vel, const double &max_acc, const double &max_jerk, const double &d_s, const double &rho, const uint &poly_order, const double &sampling_freq, const Eigen::MatrixXd &polyCoeff, const Eigen::VectorXd &polyTime, const bool &visualize_output, std::vector<drone_planner::PVA> *pva_vec, float *final_time); bool SolveMinTimeOpt(const std::string &solver); void GetTrajectoryPVA(std::vector<drone_planner::PVA> *pva_vec, float *final_time); Eigen::Vector3d getPosPoly(const Eigen::MatrixXd &polyCoeff, const int &k, const double &t); Eigen::Vector3d getVelPoly(const Eigen::MatrixXd &polyCoeff, const int &k, const double &t); Eigen::Vector3d getAccPoly(const Eigen::MatrixXd &polyCoeff, const int &k, const double &t); void GetPVAatTime(const double &time_in, geometry_msgs::Point *pos, geometry_msgs::Vector3 *vel, geometry_msgs::Vector3 *acc); }; } // namespace time_optimizer #endif // TIME_OPTIMIZER_CLASS_H_
C++
CL
dcffbe66782612d6d5fd2b9ddc150b4f7b46879fdd461bf559d3ee2a50655a2f
#if defined(__cplusplus) && !defined(_BDAQ_NO_NAMESPACE) # ifndef BEGIN_NAMEAPCE_AUTOMATION_BDAQ # define BEGIN_NAMEAPCE_AUTOMATION_BDAQ namespace Automation { namespace BDaq { # define END_NAMEAPCE_AUTOMATION_BDAQ } /*BDaq*/ } /*Automation*/ # endif #else # ifndef BEGIN_NAMEAPCE_AUTOMATION_BDAQ # define BEGIN_NAMEAPCE_AUTOMATION_BDAQ # define END_NAMEAPCE_AUTOMATION_BDAQ # endif #endif // ********************************************************** // Bionic DAQ types // ********************************************************** #ifndef _BDAQ_TYPES_DEFINED #define _BDAQ_TYPES_DEFINED BEGIN_NAMEAPCE_AUTOMATION_BDAQ #define MAX_DEVICE_DESC_LEN 64 #define MAX_VRG_DESC_LEN 256 #define MAX_SIG_DROP_DESC_LEN 256 #define MAX_AI_CH_COUNT 128 #define MAX_AO_CH_COUNT 128 #define MAX_DIO_PORT_COUNT 32 #define MAX_CNTR_CH_COUNT 8 typedef signed char int8; typedef signed short int16; typedef unsigned char uint8; typedef unsigned short uint16; #if defined(_WIN32) || defined(WIN32) # define BDAQCALL WINAPI # ifndef _WIN64 typedef signed int int32; typedef unsigned int uint32; # else typedef signed long int32; typedef unsigned long uint32; # endif // typedef signed __int64 int64; // typedef unsigned __int64 uint64; #else # define BDAQCALL typedef signed int int32; typedef unsigned int uint32; typedef signed long long int64; typedef unsigned long long uint64; typedef void * HANDLE; #endif typedef enum tagTerminalBoard { WiringBoard = 0, PCLD8710, PCLD789, PCLD8115, } TerminalBoard; typedef enum tagModuleType { DaqAny = -1, DaqGroup = 1, DaqDevice, DaqAi, DaqAo, DaqDio, DaqCounter, } ModuleType; typedef enum tagAccessMode { ModeRead = 0, ModeWrite, ModeWriteWithReset, ModeReserved = 0xffffffff, } AccessMode; typedef enum tagMathIntervalType { /* Right boundary definition, define the maximum value state, use the bit 0,1 */ RightOpenSet = 0x0, /* No maximum value limitation. */ RightClosedBoundary = 0x1, /* The maximum value is included. */ RightOpenBoundary = 0x2, /* The maximum value is not included. */ /* Left boundary definition, define the minimum value state, used the bit 2, 3 */ LeftOpenSet = 0x0, /* No minimum value limitation. */ LeftClosedBoundary = 0x4, /* The minimum value is included. */ LeftOpenBoundary = 0x8, /* The minimum value is not included */ /* The signality expression */ Boundless = 0x0, /* Boundless set. (LeftOpenSet | RightOpenSet) */ /* The combination notation */ LOSROS = 0x0, /* (LeftOpenSet | RightOpenSet), algebra notation: (un-limit, max) */ LOSRCB = 0x1, /* (LeftOpenSet | RightClosedBoundary), algebra notation: (un-limit, max ] */ LOSROB = 0x2, /* (LeftOpenSet | RightOpenBoundary), algebra notation: (un-limit, max) */ LCBROS = 0x4, /* (LeftClosedBoundary | RightOpenSet), algebra notation: [min, un-limit) */ LCBRCB = 0x5, /* (LeftClosedBoundary | RightClosedBoundary), algebra notation: [ min, right ] */ LCBROB = 0x6, /* (LeftClosedBoundary | RightOpenBoundary), algebra notation: [ min, right) */ LOBROS = 0x8, /* (LeftOpenBoundary | RightOpenSet), algebra notation: (min, un-limit) */ LOBRCB = 0x9, /* (LeftOpenBoundary | RightClosedBoundary), algebra notation: (min, right ] */ LOBROB = 0xA, /* (LeftOpenBoundary | RightOpenBoundary), algebra notation: (min, right) */ } MathIntervalType; typedef struct tagMathInterval { int32 Type; double Min; double Max; } MathInterval, * PMathInterval; typedef enum tagAiChannelType { AllSingleEnded = 0, AllDifferential, AllSeDiffAdj, MixedSeDiffAdj, } AiChannelType; typedef enum tagAiSignalType { SingleEnded = 0, Differential, } AiSignalType; typedef enum tagFilterType { FilterNone = 0, LowPass, HighPass, BandPass, BandStop, } FilterType; typedef enum tagDioPortType { PortDi = 0, // the port number references to a DI port PortDo, // the port number references to a DO port PortDio, // the port number references to a DI port and a DO port Port8255A, // the port number references to a PPI port A mode DIO port. Port8255C, // the port number references to a PPI port C mode DIO port. PortIndvdlDio, // the port number references to a port whose each channel can be configured as in or out. } DioPortType; typedef enum tagDioPortDir { Input = 0x00, LoutHin = 0x0F, LinHout = 0xF0, Output = 0xFF, } DioPortDir; typedef enum tagSamplingMethod { EqualTimeSwitch = 0, Simultaneous, } SamplingMethod; typedef enum tagTemperatureDegree { Celsius = 0, Fahrenheit, Rankine, Kelvin, } TemperatureDegree; typedef enum tagBurnoutRetType { Current = 0, ParticularValue, UpLimit, LowLimit, LastCorrectValue, } BurnoutRetType; typedef enum tagValueUnit { Kilovolt, /* KV */ Volt, /* V */ Millivolt, /* mV */ Microvolt, /* uV */ Kiloampere, /* KA */ Ampere, /* A */ Milliampere, /* mA */ Microampere, /* uA */ CelsiusUnit, /* Celsius */ } ValueUnit; typedef enum tagValueRange { V_OMIT = -1, /* Unknown when get, ignored when set */ V_Neg15To15 = 0, /* +/- 15 V */ V_Neg10To10, /* +/- 10 V */ V_Neg5To5, /* +/- 5 V */ V_Neg2pt5To2pt5, /* +/- 2.5 V */ V_Neg1pt25To1pt25, /* +/- 1.25 V */ V_Neg1To1, /* +/- 1 V */ V_0To15, /* 0~15 V */ V_0To10, /* 0~10 V */ V_0To5, /* 0~5 V */ V_0To2pt5, /* 0~2.5 V */ V_0To1pt25, /* 0~1.25 V */ V_0To1, /* 0~1 V */ mV_Neg625To625, /* +/- 625mV */ mV_Neg500To500, /* +/- 500 mV */ mV_Neg312pt5To312pt5, /* +/- 312.5 mV */ mV_Neg200To200, /* +/- 200 mV */ mV_Neg150To150, /* +/- 150 mV */ mV_Neg100To100, /* +/- 100 mV */ mV_Neg50To50, /* +/- 50 mV */ mV_Neg30To30, /* +/- 30 mV */ mV_Neg20To20, /* +/- 20 mV */ mV_Neg15To15, /* +/- 15 mV */ mV_Neg10To10, /* +/- 10 mV */ mV_Neg5To5, /* +/- 5 mV */ mV_0To625, /* 0 ~ 625 mV */ mV_0To500, /* 0 ~ 500 mV */ mV_0To150, /* 0 ~ 150 mV */ mV_0To100, /* 0 ~ 100 mV */ mV_0To50, /* 0 ~ 50 mV */ mV_0To20, /* 0 ~ 20 mV */ mV_0To15, /* 0 ~ 15 mV */ mV_0To10, /* 0 ~ 10 mV */ mA_Neg20To20, /* +/- 20mA */ mA_0To20, /* 0 ~ 20 mA */ mA_4To20, /* 4 ~ 20 mA */ mA_0To24, /* 0 ~ 24 mA */ /* For USB4702_4704 */ V_Neg2To2, /* +/- 2 V */ V_Neg4To4, /* +/- 4 V */ V_Neg20To20, /* +/- 20 V */ Jtype_0To760C = 0x8000, /* T/C J type 0~760 'C */ Ktype_0To1370C, /* T/C K type 0~1370 'C */ Ttype_Neg100To400C, /* T/C T type -100~400 'C */ Etype_0To1000C, /* T/C E type 0~1000 'C */ Rtype_500To1750C, /* T/C R type 500~1750 'C */ Stype_500To1750C, /* T/C S type 500~1750 'C */ Btype_500To1800C, /* T/C B type 500~1800 'C */ Pt392_Neg50To150, /* Pt392 -50~150 'C */ Pt385_Neg200To200, /* Pt385 -200~200 'C */ Pt385_0To400, /* Pt385 0~400 'C */ Pt385_Neg50To150, /* Pt385 -50~150 'C */ Pt385_Neg100To100, /* Pt385 -100~100 'C */ Pt385_0To100, /* Pt385 0~100 'C */ Pt385_0To200, /* Pt385 0~200 'C */ Pt385_0To600, /* Pt385 0~600 'C */ Pt392_Neg100To100, /* Pt392 -100~100 'C */ Pt392_0To100, /* Pt392 0~100 'C */ Pt392_0To200, /* Pt392 0~200 'C */ Pt392_0To600, /* Pt392 0~600 'C */ Pt392_0To400, /* Pt392 0~400 'C */ Pt392_Neg200To200, /* Pt392 -200~200 'C */ Pt1000_Neg40To160, /* Pt1000 -40~160 'C */ Balcon500_Neg30To120, /* Balcon500 -30~120 'C */ Ni518_Neg80To100, /* Ni518 -80~100 'C */ Ni518_0To100, /* Ni518 0~100 'C */ Ni508_0To100, /* Ni508 0~100 'C */ Ni508_Neg50To200, /* Ni508 -50~200 'C */ Thermistor_3K_0To100, /* Thermistor 3K 0~100 'C */ Thermistor_10K_0To100, /* Thermistor 10K 0~100 'C */ Jtype_Neg210To1200C, /* T/C J type -210~1200 'C */ Ktype_Neg270To1372C, /* T/C K type -270~1372 'C */ Ttype_Neg270To400C, /* T/C T type -270~400 'C */ Etype_Neg270To1000C, /* T/C E type -270~1000 'C */ Rtype_Neg50To1768C, /* T/C R type -50~1768 'C */ Stype_Neg50To1768C, /* T/C S type -50~1768 'C */ Btype_40To1820C, /* T/C B type 40~1820 'C */ Jtype_Neg210To870C, /* T/C J type -210~870 'C */ Rtype_0To1768C, /* T/C R type 0~1768 'C */ Stype_0To1768C, /* T/C S type 0~1768 'C */ Ttype_Neg20To135C, /* T/C T type -20~135 'C */ /* 0xC000 ~ 0xF000 : user customized value range type */ UserCustomizedVrgStart = 0xC000, UserCustomizedVrgEnd = 0xF000, /* AO external reference type */ V_ExternalRefBipolar = 0xF001, /* External reference voltage unipolar */ V_ExternalRefUnipolar = 0xF002, /* External reference voltage bipolar */ } ValueRange; typedef enum tagSignalPolarity { Negative = 0, Positive, } SignalPolarity; typedef enum tagSignalCountingType { CountingNone = 0, DownCount, /* counter value decreases on each clock */ UpCount, /* counter value increases on each clock */ PulseDirection, /* counting direction is determined by two signals, one is clock, the other is direction signal */ TwoPulse, /* counting direction is determined by two signals, one is up-counting signal, the other is down-counting signal */ AbPhaseX1, /* AB phase, 1x rate up/down counting */ AbPhaseX2, /* AB phase, 2x rate up/down counting */ AbPhaseX4, /* AB phase, 4x rate up/down counting */ } SignalCountingType; typedef enum tagOutSignalType{ SignalOutNone = 0, /* no output or output is 'disabled' */ ChipDefined, /* hardware chip defined */ NegChipDefined, /* hardware chip defined, negative logical */ PositivePulse, /* a low-to-high pulse */ NegativePulse, /* a high-to-low pulse */ ToggledFromLow, /* the level toggled from low to high */ ToggledFromHigh, /* the level toggled from high to low */ } OutSignalType; typedef enum tagCounterCapability { Primary = 1, InstantEventCount, OneShot, TimerPulse, InstantFreqMeter, InstantPwmIn, InstantPwmOut, UpDownCount, } CounterCapability; typedef enum tagCounterOperationMode { C8254_M0 = 0, /*8254 mode 0, interrupt on terminal count */ C8254_M1, /*8254 mode 1, hardware retriggerable one-shot */ C8254_M2, /*8254 mode 2, rate generator */ C8254_M3, /*8254 mode 3, square save mode */ C8254_M4, /*8254 mode 4, software triggered strobe */ C8254_M5, /*8254 mode 5, hardware triggered strobe */ C1780_MA, /* Mode A level & pulse out, Software-Triggered without Hardware Gating */ C1780_MB, /* Mode B level & pulse out, Software-Triggered with Level Gating, = 8254_M0 */ C1780_MC, /* Mode C level & pulse out, Hardware-triggered strobe level */ C1780_MD, /* Mode D level & Pulse out, Rate generate with no hardware gating */ C1780_ME, /* Mode E level & pulse out, Rate generator with level Gating */ C1780_MF, /* Mode F level & pulse out, Non-retriggerable One-shot (Pulse type = 8254_M1) */ C1780_MG, /* Mode G level & pulse out, Software-triggered delayed pulse one-shot */ C1780_MH, /* Mode H level & pulse out, Software-triggered delayed pulse one-shot with hardware gating */ C1780_MI, /* Mode I level & pulse out, Hardware-triggered delay pulse strobe */ C1780_MJ, /* Mode J level & pulse out, Variable Duty Cycle Rate Generator with No Hardware Gating */ C1780_MK, /* Mode K level & pulse out, Variable Duty Cycle Rate Generator with Level Gating */ C1780_ML, /* Mode L level & pulse out, Hardware-Triggered Delayed Pulse One-Shot */ C1780_MO, /* Mode O level & pulse out, Hardware-Triggered Strobe with Edge Disarm */ C1780_MR, /* Mode R level & pulse out, Non-Retriggerbale One-Shot with Edge Disarm */ C1780_MU, /* Mode U level & pulse out, Hardware-Triggered Delayed Pulse Strobe with Edge Disarm */ C1780_MX, /* Mode X level & pulse out, Hardware-Triggered Delayed Pulse One-Shot with Edge Disarm */ } CounterOperationMode; typedef enum tagCounterValueRegister { CntLoad, CntPreset = CntLoad, CntHold, CntOverCompare, CntUnderCompare, } CounterValueRegister; typedef enum tagCounterCascadeGroup { GroupNone = 0, /* no cascade*/ Cnt0Cnt1, /* Counter 0 as first, counter 1 as second. */ Cnt2Cnt3, /* Counter 2 as first, counter 3 as second */ Cnt4Cnt5, /* Counter 4 as first, counter 5 as second */ Cnt6Cnt7, /* Counter 6 as first, counter 7 as second */ } CounterCascadeGroup; typedef enum tagFreqMeasureMethod { AutoAdaptive = 0, /* Intelligently select the measurement method according to the input signal. */ CountingPulseBySysTime, /* Using system timing clock to calculate the frequency */ CountingPulseByDevTime, /* Using the device timing clock to calculate the frequency */ PeriodInverse, /* Calculate the frequency from the period of the signal */ } FreqMeasureMethod; typedef enum tagActiveSignal { ActiveNone = 0, RisingEdge, FallingEdge, BothEdge, HighLevel, LowLevel, } ActiveSignal; typedef enum tagTriggerAction { ActionNone = 0, /* No action to take even if the trigger condition is satisfied */ DelayToStart, /* Begin to start after the specified time is elapsed if the trigger condition is satisfied */ DelayToStop, /* Stop execution after the specified time is elapsed if the trigger condition is satisfied */ } TriggerAction; typedef enum tagSignalPosition { InternalSig = 0, OnConnector, OnAmsi, } SignalPosition; typedef enum tagSignalDrop { SignalNone = 0, /* No connection */ /*Internal signal connector*/ SigInternalClock, /* Device built-in clock, If the device has several built-in clock, this represent the highest freq one. */ SigInternal1KHz, /* Device built-in clock, 1KHz */ SigInternal10KHz, /* Device built-in clock, 10KHz */ SigInternal100KHz, /* Device built-in clock, 100KHz */ SigInternal1MHz, /* Device built-in clock, 1MHz */ SigInternal10MHz, /* Device built-in clock, 10MHz */ SigInternal20MHz, /* Device built-in clock, 20MHz */ SigInternal30MHz, /* Device built-in clock, 30MHz */ SigInternal40MHz, /* Device built-in clock, 40MHz */ SigInternal50MHz, /* Device built-in clock, 50MHz */ SigInternal60MHz, /* Device built-in clock, 60MHz */ SigDiPatternMatch, /* When DI pattern match occurred */ SigDiStatusChange, /* When DI status change occurred */ /*Function pin on connector*/ SigExtAnaClock, /* Analog clock pin of connector */ SigExtAnaScanClock, /* scan clock pin of connector */ SigExtAnaTrigger, /* external analog trigger pin of connector */ SigExtDigClock, /* digital clock pin of connector */ SigExtDigTrigger0, /* external digital trigger 0 pin(or DI start trigger pin) of connector */ SigExtDigTrigger1, /* external digital trigger 1 pin(or DI stop trigger pin) of connector */ SigExtDigTrigger2, /* external digital trigger 2 pin(or DO start trigger pin) of connector */ SigExtDigTrigger3, /* external digital trigger 3 pin(or DO stop trigger pin) of connector */ SigCHFrzDo, /* Channel freeze DO ports pin */ /*Signal source or target on the connector*/ /*AI channel pins*/ SigAi0, SigAi1, SigAi2, SigAi3, SigAi4, SigAi5, SigAi6, SigAi7, SigAi8, SigAi9, SigAi10, SigAi11, SigAi12, SigAi13, SigAi14, SigAi15, SigAi16, SigAi17, SigAi18, SigAi19, SigAi20, SigAi21, SigAi22, SigAi23, SigAi24, SigAi25, SigAi26, SigAi27, SigAi28, SigAi29, SigAi30, SigAi31, SigAi32, SigAi33, SigAi34, SigAi35, SigAi36, SigAi37, SigAi38, SigAi39, SigAi40, SigAi41, SigAi42, SigAi43, SigAi44, SigAi45, SigAi46, SigAi47, SigAi48, SigAi49, SigAi50, SigAi51, SigAi52, SigAi53, SigAi54, SigAi55, SigAi56, SigAi57, SigAi58, SigAi59, SigAi60, SigAi61, SigAi62, SigAi63, /*AO channel pins*/ SigAo0, SigAo1, SigAo2, SigAo3, SigAo4, SigAo5, SigAo6, SigAo7, SigAo8, SigAo9, SigAo10, SigAo11, SigAo12, SigAo13, SigAo14, SigAo15, SigAo16, SigAo17, SigAo18, SigAo19, SigAo20, SigAo21, SigAo22, SigAo23, SigAo24, SigAo25, SigAo26, SigAo27, SigAo28, SigAo29, SigAo30, SigAo31, /*DI pins*/ SigDi0, SigDi1, SigDi2, SigDi3, SigDi4, SigDi5, SigDi6, SigDi7, SigDi8, SigDi9, SigDi10, SigDi11, SigDi12, SigDi13, SigDi14, SigDi15, SigDi16, SigDi17, SigDi18, SigDi19, SigDi20, SigDi21, SigDi22, SigDi23, SigDi24, SigDi25, SigDi26, SigDi27, SigDi28, SigDi29, SigDi30, SigDi31, SigDi32, SigDi33, SigDi34, SigDi35, SigDi36, SigDi37, SigDi38, SigDi39, SigDi40, SigDi41, SigDi42, SigDi43, SigDi44, SigDi45, SigDi46, SigDi47, SigDi48, SigDi49, SigDi50, SigDi51, SigDi52, SigDi53, SigDi54, SigDi55, SigDi56, SigDi57, SigDi58, SigDi59, SigDi60, SigDi61, SigDi62, SigDi63, SigDi64, SigDi65, SigDi66, SigDi67, SigDi68, SigDi69, SigDi70, SigDi71, SigDi72, SigDi73, SigDi74, SigDi75, SigDi76, SigDi77, SigDi78, SigDi79, SigDi80, SigDi81, SigDi82, SigDi83, SigDi84, SigDi85, SigDi86, SigDi87, SigDi88, SigDi89, SigDi90, SigDi91, SigDi92, SigDi93, SigDi94, SigDi95, SigDi96, SigDi97, SigDi98, SigDi99, SigDi100, SigDi101, SigDi102, SigDi103, SigDi104, SigDi105, SigDi106, SigDi107, SigDi108, SigDi109, SigDi110, SigDi111, SigDi112, SigDi113, SigDi114, SigDi115, SigDi116, SigDi117, SigDi118, SigDi119, SigDi120, SigDi121, SigDi122, SigDi123, SigDi124, SigDi125, SigDi126, SigDi127, SigDi128, SigDi129, SigDi130, SigDi131, SigDi132, SigDi133, SigDi134, SigDi135, SigDi136, SigDi137, SigDi138, SigDi139, SigDi140, SigDi141, SigDi142, SigDi143, SigDi144, SigDi145, SigDi146, SigDi147, SigDi148, SigDi149, SigDi150, SigDi151, SigDi152, SigDi153, SigDi154, SigDi155, SigDi156, SigDi157, SigDi158, SigDi159, SigDi160, SigDi161, SigDi162, SigDi163, SigDi164, SigDi165, SigDi166, SigDi167, SigDi168, SigDi169, SigDi170, SigDi171, SigDi172, SigDi173, SigDi174, SigDi175, SigDi176, SigDi177, SigDi178, SigDi179, SigDi180, SigDi181, SigDi182, SigDi183, SigDi184, SigDi185, SigDi186, SigDi187, SigDi188, SigDi189, SigDi190, SigDi191, SigDi192, SigDi193, SigDi194, SigDi195, SigDi196, SigDi197, SigDi198, SigDi199, SigDi200, SigDi201, SigDi202, SigDi203, SigDi204, SigDi205, SigDi206, SigDi207, SigDi208, SigDi209, SigDi210, SigDi211, SigDi212, SigDi213, SigDi214, SigDi215, SigDi216, SigDi217, SigDi218, SigDi219, SigDi220, SigDi221, SigDi222, SigDi223, SigDi224, SigDi225, SigDi226, SigDi227, SigDi228, SigDi229, SigDi230, SigDi231, SigDi232, SigDi233, SigDi234, SigDi235, SigDi236, SigDi237, SigDi238, SigDi239, SigDi240, SigDi241, SigDi242, SigDi243, SigDi244, SigDi245, SigDi246, SigDi247, SigDi248, SigDi249, SigDi250, SigDi251, SigDi252, SigDi253, SigDi254, SigDi255, /*DIO pins*/ SigDio0, SigDio1, SigDio2, SigDio3, SigDio4, SigDio5, SigDio6, SigDio7, SigDio8, SigDio9, SigDio10, SigDio11, SigDio12, SigDio13, SigDio14, SigDio15, SigDio16, SigDio17, SigDio18, SigDio19, SigDio20, SigDio21, SigDio22, SigDio23, SigDio24, SigDio25, SigDio26, SigDio27, SigDio28, SigDio29, SigDio30, SigDio31, SigDio32, SigDio33, SigDio34, SigDio35, SigDio36, SigDio37, SigDio38, SigDio39, SigDio40, SigDio41, SigDio42, SigDio43, SigDio44, SigDio45, SigDio46, SigDio47, SigDio48, SigDio49, SigDio50, SigDio51, SigDio52, SigDio53, SigDio54, SigDio55, SigDio56, SigDio57, SigDio58, SigDio59, SigDio60, SigDio61, SigDio62, SigDio63, SigDio64, SigDio65, SigDio66, SigDio67, SigDio68, SigDio69, SigDio70, SigDio71, SigDio72, SigDio73, SigDio74, SigDio75, SigDio76, SigDio77, SigDio78, SigDio79, SigDio80, SigDio81, SigDio82, SigDio83, SigDio84, SigDio85, SigDio86, SigDio87, SigDio88, SigDio89, SigDio90, SigDio91, SigDio92, SigDio93, SigDio94, SigDio95, SigDio96, SigDio97, SigDio98, SigDio99, SigDio100, SigDio101, SigDio102, SigDio103, SigDio104, SigDio105, SigDio106, SigDio107, SigDio108, SigDio109, SigDio110, SigDio111, SigDio112, SigDio113, SigDio114, SigDio115, SigDio116, SigDio117, SigDio118, SigDio119, SigDio120, SigDio121, SigDio122, SigDio123, SigDio124, SigDio125, SigDio126, SigDio127, SigDio128, SigDio129, SigDio130, SigDio131, SigDio132, SigDio133, SigDio134, SigDio135, SigDio136, SigDio137, SigDio138, SigDio139, SigDio140, SigDio141, SigDio142, SigDio143, SigDio144, SigDio145, SigDio146, SigDio147, SigDio148, SigDio149, SigDio150, SigDio151, SigDio152, SigDio153, SigDio154, SigDio155, SigDio156, SigDio157, SigDio158, SigDio159, SigDio160, SigDio161, SigDio162, SigDio163, SigDio164, SigDio165, SigDio166, SigDio167, SigDio168, SigDio169, SigDio170, SigDio171, SigDio172, SigDio173, SigDio174, SigDio175, SigDio176, SigDio177, SigDio178, SigDio179, SigDio180, SigDio181, SigDio182, SigDio183, SigDio184, SigDio185, SigDio186, SigDio187, SigDio188, SigDio189, SigDio190, SigDio191, SigDio192, SigDio193, SigDio194, SigDio195, SigDio196, SigDio197, SigDio198, SigDio199, SigDio200, SigDio201, SigDio202, SigDio203, SigDio204, SigDio205, SigDio206, SigDio207, SigDio208, SigDio209, SigDio210, SigDio211, SigDio212, SigDio213, SigDio214, SigDio215, SigDio216, SigDio217, SigDio218, SigDio219, SigDio220, SigDio221, SigDio222, SigDio223, SigDio224, SigDio225, SigDio226, SigDio227, SigDio228, SigDio229, SigDio230, SigDio231, SigDio232, SigDio233, SigDio234, SigDio235, SigDio236, SigDio237, SigDio238, SigDio239, SigDio240, SigDio241, SigDio242, SigDio243, SigDio244, SigDio245, SigDio246, SigDio247, SigDio248, SigDio249, SigDio250, SigDio251, SigDio252, SigDio253, SigDio254, SigDio255, /*Counter clock pins*/ SigCntClk0, SigCntClk1, SigCntClk2, SigCntClk3, SigCntClk4, SigCntClk5, SigCntClk6, SigCntClk7, /*counter gate pins*/ SigCntGate0, SigCntGate1, SigCntGate2, SigCntGate3, SigCntGate4, SigCntGate5, SigCntGate6, SigCntGate7, /*counter out pins*/ SigCntOut0, SigCntOut1, SigCntOut2, SigCntOut3, SigCntOut4, SigCntOut5, SigCntOut6, SigCntOut7, /*counter frequency out pins*/ SigCntFout0, SigCntFout1, SigCntFout2, SigCntFout3, SigCntFout4, SigCntFout5, SigCntFout6, SigCntFout7, /*AMSI pins*/ SigAmsiPin0, SigAmsiPin1, SigAmsiPin2, SigAmsiPin3, SigAmsiPin4, SigAmsiPin5, SigAmsiPin6, SigAmsiPin7, SigAmsiPin8, SigAmsiPin9, SigAmsiPin10, SigAmsiPin11, SigAmsiPin12, SigAmsiPin13, SigAmsiPin14, SigAmsiPin15, SigAmsiPin16, SigAmsiPin17, SigAmsiPin18, SigAmsiPin19, /*new clocks*/ SigInternal2Hz, /* Device built-in clock, 2Hz */ SigInternal20Hz, /* Device built-in clock, 20Hz */ SigInternal200Hz, /* Device built-in clock, 200KHz */ SigInternal2KHz, /* Device built-in clock, 2KHz */ SigInternal20KHz, /* Device built-in clock, 20KHz */ SigInternal200KHz, /* Device built-in clock, 200KHz */ SigInternal2MHz, /* Device built-in clock, 2MHz */ } SignalDrop; /* * Event Id */ typedef enum tagEventId { EvtDeviceRemoved = 0, /* The device was removed from system */ EvtDeviceReconnected, /* The device is reconnected */ EvtPropertyChanged, /* Some properties of the device were changed */ /*----------------------------------------------------------------- * AI events *-----------------------------------------------------------------*/ EvtBufferedAiDataReady, EvtBufferedAiOverrun, EvtBufferedAiCacheOverflow, EvtBufferedAiStopped, /*----------------------------------------------------------------- * AO event IDs *-----------------------------------------------------------------*/ EvtBufferedAoDataTransmitted, EvtBufferedAoUnderrun, EvtBufferedAoCacheEmptied, EvtBufferedAoTransStopped, EvtBufferedAoStopped, /*----------------------------------------------------------------- * DIO event IDs *-----------------------------------------------------------------*/ EvtDiintChannel000, EvtDiintChannel001, EvtDiintChannel002, EvtDiintChannel003, EvtDiintChannel004, EvtDiintChannel005, EvtDiintChannel006, EvtDiintChannel007, EvtDiintChannel008, EvtDiintChannel009, EvtDiintChannel010, EvtDiintChannel011, EvtDiintChannel012, EvtDiintChannel013, EvtDiintChannel014, EvtDiintChannel015, EvtDiintChannel016, EvtDiintChannel017, EvtDiintChannel018, EvtDiintChannel019, EvtDiintChannel020, EvtDiintChannel021, EvtDiintChannel022, EvtDiintChannel023, EvtDiintChannel024, EvtDiintChannel025, EvtDiintChannel026, EvtDiintChannel027, EvtDiintChannel028, EvtDiintChannel029, EvtDiintChannel030, EvtDiintChannel031, EvtDiintChannel032, EvtDiintChannel033, EvtDiintChannel034, EvtDiintChannel035, EvtDiintChannel036, EvtDiintChannel037, EvtDiintChannel038, EvtDiintChannel039, EvtDiintChannel040, EvtDiintChannel041, EvtDiintChannel042, EvtDiintChannel043, EvtDiintChannel044, EvtDiintChannel045, EvtDiintChannel046, EvtDiintChannel047, EvtDiintChannel048, EvtDiintChannel049, EvtDiintChannel050, EvtDiintChannel051, EvtDiintChannel052, EvtDiintChannel053, EvtDiintChannel054, EvtDiintChannel055, EvtDiintChannel056, EvtDiintChannel057, EvtDiintChannel058, EvtDiintChannel059, EvtDiintChannel060, EvtDiintChannel061, EvtDiintChannel062, EvtDiintChannel063, EvtDiintChannel064, EvtDiintChannel065, EvtDiintChannel066, EvtDiintChannel067, EvtDiintChannel068, EvtDiintChannel069, EvtDiintChannel070, EvtDiintChannel071, EvtDiintChannel072, EvtDiintChannel073, EvtDiintChannel074, EvtDiintChannel075, EvtDiintChannel076, EvtDiintChannel077, EvtDiintChannel078, EvtDiintChannel079, EvtDiintChannel080, EvtDiintChannel081, EvtDiintChannel082, EvtDiintChannel083, EvtDiintChannel084, EvtDiintChannel085, EvtDiintChannel086, EvtDiintChannel087, EvtDiintChannel088, EvtDiintChannel089, EvtDiintChannel090, EvtDiintChannel091, EvtDiintChannel092, EvtDiintChannel093, EvtDiintChannel094, EvtDiintChannel095, EvtDiintChannel096, EvtDiintChannel097, EvtDiintChannel098, EvtDiintChannel099, EvtDiintChannel100, EvtDiintChannel101, EvtDiintChannel102, EvtDiintChannel103, EvtDiintChannel104, EvtDiintChannel105, EvtDiintChannel106, EvtDiintChannel107, EvtDiintChannel108, EvtDiintChannel109, EvtDiintChannel110, EvtDiintChannel111, EvtDiintChannel112, EvtDiintChannel113, EvtDiintChannel114, EvtDiintChannel115, EvtDiintChannel116, EvtDiintChannel117, EvtDiintChannel118, EvtDiintChannel119, EvtDiintChannel120, EvtDiintChannel121, EvtDiintChannel122, EvtDiintChannel123, EvtDiintChannel124, EvtDiintChannel125, EvtDiintChannel126, EvtDiintChannel127, EvtDiintChannel128, EvtDiintChannel129, EvtDiintChannel130, EvtDiintChannel131, EvtDiintChannel132, EvtDiintChannel133, EvtDiintChannel134, EvtDiintChannel135, EvtDiintChannel136, EvtDiintChannel137, EvtDiintChannel138, EvtDiintChannel139, EvtDiintChannel140, EvtDiintChannel141, EvtDiintChannel142, EvtDiintChannel143, EvtDiintChannel144, EvtDiintChannel145, EvtDiintChannel146, EvtDiintChannel147, EvtDiintChannel148, EvtDiintChannel149, EvtDiintChannel150, EvtDiintChannel151, EvtDiintChannel152, EvtDiintChannel153, EvtDiintChannel154, EvtDiintChannel155, EvtDiintChannel156, EvtDiintChannel157, EvtDiintChannel158, EvtDiintChannel159, EvtDiintChannel160, EvtDiintChannel161, EvtDiintChannel162, EvtDiintChannel163, EvtDiintChannel164, EvtDiintChannel165, EvtDiintChannel166, EvtDiintChannel167, EvtDiintChannel168, EvtDiintChannel169, EvtDiintChannel170, EvtDiintChannel171, EvtDiintChannel172, EvtDiintChannel173, EvtDiintChannel174, EvtDiintChannel175, EvtDiintChannel176, EvtDiintChannel177, EvtDiintChannel178, EvtDiintChannel179, EvtDiintChannel180, EvtDiintChannel181, EvtDiintChannel182, EvtDiintChannel183, EvtDiintChannel184, EvtDiintChannel185, EvtDiintChannel186, EvtDiintChannel187, EvtDiintChannel188, EvtDiintChannel189, EvtDiintChannel190, EvtDiintChannel191, EvtDiintChannel192, EvtDiintChannel193, EvtDiintChannel194, EvtDiintChannel195, EvtDiintChannel196, EvtDiintChannel197, EvtDiintChannel198, EvtDiintChannel199, EvtDiintChannel200, EvtDiintChannel201, EvtDiintChannel202, EvtDiintChannel203, EvtDiintChannel204, EvtDiintChannel205, EvtDiintChannel206, EvtDiintChannel207, EvtDiintChannel208, EvtDiintChannel209, EvtDiintChannel210, EvtDiintChannel211, EvtDiintChannel212, EvtDiintChannel213, EvtDiintChannel214, EvtDiintChannel215, EvtDiintChannel216, EvtDiintChannel217, EvtDiintChannel218, EvtDiintChannel219, EvtDiintChannel220, EvtDiintChannel221, EvtDiintChannel222, EvtDiintChannel223, EvtDiintChannel224, EvtDiintChannel225, EvtDiintChannel226, EvtDiintChannel227, EvtDiintChannel228, EvtDiintChannel229, EvtDiintChannel230, EvtDiintChannel231, EvtDiintChannel232, EvtDiintChannel233, EvtDiintChannel234, EvtDiintChannel235, EvtDiintChannel236, EvtDiintChannel237, EvtDiintChannel238, EvtDiintChannel239, EvtDiintChannel240, EvtDiintChannel241, EvtDiintChannel242, EvtDiintChannel243, EvtDiintChannel244, EvtDiintChannel245, EvtDiintChannel246, EvtDiintChannel247, EvtDiintChannel248, EvtDiintChannel249, EvtDiintChannel250, EvtDiintChannel251, EvtDiintChannel252, EvtDiintChannel253, EvtDiintChannel254, EvtDiintChannel255, EvtDiCosintPort000, EvtDiCosintPort001, EvtDiCosintPort002, EvtDiCosintPort003, EvtDiCosintPort004, EvtDiCosintPort005, EvtDiCosintPort006, EvtDiCosintPort007, EvtDiCosintPort008, EvtDiCosintPort009, EvtDiCosintPort010, EvtDiCosintPort011, EvtDiCosintPort012, EvtDiCosintPort013, EvtDiCosintPort014, EvtDiCosintPort015, EvtDiCosintPort016, EvtDiCosintPort017, EvtDiCosintPort018, EvtDiCosintPort019, EvtDiCosintPort020, EvtDiCosintPort021, EvtDiCosintPort022, EvtDiCosintPort023, EvtDiCosintPort024, EvtDiCosintPort025, EvtDiCosintPort026, EvtDiCosintPort027, EvtDiCosintPort028, EvtDiCosintPort029, EvtDiCosintPort030, EvtDiCosintPort031, EvtDiPmintPort000, EvtDiPmintPort001, EvtDiPmintPort002, EvtDiPmintPort003, EvtDiPmintPort004, EvtDiPmintPort005, EvtDiPmintPort006, EvtDiPmintPort007, EvtDiPmintPort008, EvtDiPmintPort009, EvtDiPmintPort010, EvtDiPmintPort011, EvtDiPmintPort012, EvtDiPmintPort013, EvtDiPmintPort014, EvtDiPmintPort015, EvtDiPmintPort016, EvtDiPmintPort017, EvtDiPmintPort018, EvtDiPmintPort019, EvtDiPmintPort020, EvtDiPmintPort021, EvtDiPmintPort022, EvtDiPmintPort023, EvtDiPmintPort024, EvtDiPmintPort025, EvtDiPmintPort026, EvtDiPmintPort027, EvtDiPmintPort028, EvtDiPmintPort029, EvtDiPmintPort030, EvtDiPmintPort031, EvtBufferedDiDataReady, EvtBufferedDiOverrun, EvtBufferedDiCacheOverflow, EvtBufferedDiStopped, EvtBufferedDoDataTransmitted, EvtBufferedDoUnderrun, EvtBufferedDoCacheEmptied, EvtBufferedDoTransStopped, EvtBufferedDoStopped, EvtReflectWdtOccured, /*----------------------------------------------------------------- * Counter/Timer event IDs *-----------------------------------------------------------------*/ EvtCntTerminalCount0, EvtCntTerminalCount1, EvtCntTerminalCount2, EvtCntTerminalCount3, EvtCntTerminalCount4, EvtCntTerminalCount5, EvtCntTerminalCount6, EvtCntTerminalCount7, EvtCntOverCompare0, EvtCntOverCompare1, EvtCntOverCompare2, EvtCntOverCompare3, EvtCntOverCompare4, EvtCntOverCompare5, EvtCntOverCompare6, EvtCntOverCompare7, EvtCntUnderCompare0, EvtCntUnderCompare1, EvtCntUnderCompare2, EvtCntUnderCompare3, EvtCntUnderCompare4, EvtCntUnderCompare5, EvtCntUnderCompare6, EvtCntUnderCompare7, EvtCntEcOverCompare0, EvtCntEcOverCompare1, EvtCntEcOverCompare2, EvtCntEcOverCompare3, EvtCntEcOverCompare4, EvtCntEcOverCompare5, EvtCntEcOverCompare6, EvtCntEcOverCompare7, EvtCntEcUnderCompare0, EvtCntEcUnderCompare1, EvtCntEcUnderCompare2, EvtCntEcUnderCompare3, EvtCntEcUnderCompare4, EvtCntEcUnderCompare5, EvtCntEcUnderCompare6, EvtCntEcUnderCompare7, EvtCntOneShot0, EvtCntOneShot1, EvtCntOneShot2, EvtCntOneShot3, EvtCntOneShot4, EvtCntOneShot5, EvtCntOneShot6, EvtCntOneShot7, EvtCntTimer0, EvtCntTimer1, EvtCntTimer2, EvtCntTimer3, EvtCntTimer4, EvtCntTimer5, EvtCntTimer6, EvtCntTimer7, EvtCntPwmInOverflow0, EvtCntPwmInOverflow1, EvtCntPwmInOverflow2, EvtCntPwmInOverflow3, EvtCntPwmInOverflow4, EvtCntPwmInOverflow5, EvtCntPwmInOverflow6, EvtCntPwmInOverflow7, EvtUdIndex0, EvtUdIndex1, EvtUdIndex2, EvtUdIndex3, EvtUdIndex4, EvtUdIndex5, EvtUdIndex6, EvtUdIndex7, EvtCntPatternMatch0, EvtCntPatternMatch1, EvtCntPatternMatch2, EvtCntPatternMatch3, EvtCntPatternMatch4, EvtCntPatternMatch5, EvtCntPatternMatch6, EvtCntPatternMatch7, EvtCntCompareTableEnd0, EvtCntCompareTableEnd1, EvtCntCompareTableEnd2, EvtCntCompareTableEnd3, EvtCntCompareTableEnd4, EvtCntCompareTableEnd5, EvtCntCompareTableEnd6, EvtCntCompareTableEnd7, } EventId ; /* * Property Attribute and Id */ typedef enum tagPropertyAttribute { ReadOnly = 0, Writable = 1, Modal = 0, Nature = 2, } PropertyAttribute; typedef enum tagPropertyId { /*----------------------------------------------------------------- * common property *-----------------------------------------------------------------*/ CFG_Number, CFG_ComponentType, CFG_Description, CFG_Parent, CFG_ChildList, /*----------------------------------------------------------------- * component specified Property IDs -- group *-----------------------------------------------------------------*/ CFG_DevicesNumber, CFG_DevicesHandle, /*----------------------------------------------------------------- * component specified Property IDs -- device *-----------------------------------------------------------------*/ CFG_DeviceGroupNumber, CFG_DeviceProductID, CFG_DeviceBoardID, CFG_DeviceBoardVersion, CFG_DeviceDriverVersion, CFG_DeviceDllVersion, CFG_DeviceLocation, /* Reserved for later using */ CFG_DeviceBaseAddresses, /* Reserved for later using */ CFG_DeviceInterrupts, /* Reserved for later using */ CFG_DeviceSupportedTerminalBoardTypes, /* Reserved for later using */ CFG_DeviceTerminalBoardType, /* Reserved for later using */ CFG_DeviceSupportedEvents, CFG_DeviceHotResetPreventable, /* Reserved for later using */ CFG_DeviceLoadingTimeInit, /* Reserved for later using */ CFG_DeviceWaitingForReconnect, CFG_DeviceWaitingForSleep, /*----------------------------------------------------------------- * component specified Property IDs -- AI, AO... *-----------------------------------------------------------------*/ CFG_FeatureResolutionInBit, CFG_FeatureDataSize, CFG_FeatureDataMask, CFG_FeatureChannelNumberMax, CFG_FeatureChannelConnectionType, CFG_FeatureBurnDetectedReturnTypes, CFG_FeatureBurnoutDetectionChannels, CFG_FeatureOverallVrgType, CFG_FeatureVrgTypes, CFG_FeatureExtRefRange, CFG_FeatureExtRefAntiPolar, CFG_FeatureCjcChannels, CFG_FeatureChannelScanMethod, CFG_FeatureScanChannelStartBase, CFG_FeatureScanChannelCountBase, CFG_FeatureConvertClockSources, CFG_FeatureConvertClockRateRange, /* Reserved for later using */ CFG_FeatureScanClockSources, CFG_FeatureScanClockRateRange, /* Reserved for later using */ CFG_FeatureScanCountMax, /* Reserved for later using */ CFG_FeatureTriggersCount, CFG_FeatureTriggerSources, CFG_FeatureTriggerActions, CFG_FeatureTriggerDelayCountRange, CFG_FeatureTriggerSources1, /* Reserved for later using */ CFG_FeatureTriggerActions1, /* Reserved for later using */ CFG_FeatureTriggerDelayCountRange1, /* Reserved for later using */ CFG_ChannelCount, CFG_ConnectionTypeOfChannels, CFG_VrgTypeOfChannels, CFG_BurnDetectedReturnTypeOfChannels, CFG_BurnoutReturnValueOfChannels, CFG_ExtRefValueForUnipolar, /* Reserved for later using */ CFG_ExtRefValueForBipolar, /* Reserved for later using */ CFG_CjcChannel, CFG_CjcUpdateFrequency, /* Reserved for later using */ CFG_CjcValue, CFG_SectionDataCount, CFG_ConvertClockSource, CFG_ConvertClockRatePerChannel, CFG_ScanChannelStart, CFG_ScanChannelCount, CFG_ScanClockSource, /* Reserved for later using */ CFG_ScanClockRate, /* Reserved for later using */ CFG_ScanCount, /* Reserved for later using */ CFG_TriggerSource, CFG_TriggerSourceEdge, CFG_TriggerSourceLevel, CFG_TriggerDelayCount, CFG_TriggerAction, CFG_TriggerSource1, /* Reserved for later using */ CFG_TriggerSourceEdge1, /* Reserved for later using */ CFG_TriggerSourceLevel1, /* Reserved for later using */ CFG_TriggerDelayCount1, /* Reserved for later using */ CFG_TriggerAction1, /* Reserved for later using */ CFG_ParentSignalConnectionChannel, CFG_ParentCjcConnectionChannel, CFG_ParentControlPort, /*----------------------------------------------------------------- * component specified Property IDs -- DIO *-----------------------------------------------------------------*/ CFG_FeaturePortsCount, CFG_FeaturePortsType, CFG_FeatureNoiseFilterOfChannels, CFG_FeatureNoiseFilterBlockTimeRange, /* Reserved for later using */ CFG_FeatureDiintTriggerEdges, CFG_FeatureDiintOfChannels, CFG_FeatureDiintGateOfChannels, CFG_FeatureDiCosintOfChannels, CFG_FeatureDiPmintOfChannels, CFG_FeatureSnapEventSources, CFG_FeatureDiSnapEventSources = CFG_FeatureSnapEventSources, /*For compatible*/ CFG_FeatureDoFreezeSignalSources, /* Reserved for later using */ CFG_FeatureDoReflectWdtFeedIntervalRange, /* Reserved for later using */ CFG_FeatureDiPortScanMethod, /* Reserved for later using */ CFG_FeatureDiConvertClockSources, /* Reserved for later using */ CFG_FeatureDiConvertClockRateRange, /* Reserved for later using */ CFG_FeatureDiScanClockSources, CFG_FeatureDiScanClockRateRange, /* Reserved for later using */ CFG_FeatureDiScanCountMax, CFG_FeatureDiTriggersCount, CFG_FeatureDiTriggerSources, CFG_FeatureDiTriggerActions, CFG_FeatureDiTriggerDelayCountRange, CFG_FeatureDiTriggerSources1, CFG_FeatureDiTriggerActions1, CFG_FeatureDiTriggerDelayCountRange1, CFG_FeatureDoPortScanMethod, /* Reserved for later using */ CFG_FeatureDoConvertClockSources, /* Reserved for later using */ CFG_FeatureDoConvertClockRateRange, /* Reserved for later using */ CFG_FeatureDoScanClockSources, CFG_FeatureDoScanClockRateRange, /* Reserved for later using */ CFG_FeatureDoScanCountMax, CFG_FeatureDoTriggersCount, CFG_FeatureDoTriggerSources, CFG_FeatureDoTriggerActions, CFG_FeatureDoTriggerDelayCountRange, CFG_FeatureDoTriggerSources1, CFG_FeatureDoTriggerActions1, CFG_FeatureDoTriggerDelayCountRange1, CFG_DirectionOfPorts, CFG_DiDataMaskOfPorts, CFG_DoDataMaskOfPorts, CFG_NoiseFilterOverallBlockTime, /* Reserved for later using */ CFG_NoiseFilterEnabledChannels, CFG_DiintTriggerEdgeOfChannels, CFG_DiintGateEnabledChannels, CFG_DiCosintEnabledChannels, CFG_DiPmintEnabledChannels, CFG_DiPmintValueOfPorts, CFG_DoInitialStateOfPorts, /* Reserved for later using */ CFG_DoFreezeEnabled, /* Reserved for later using */ CFG_DoFreezeSignalState, /* Reserved for later using */ CFG_DoReflectWdtFeedInterval, /* Reserved for later using */ CFG_DoReflectWdtLockValue, /* Reserved for later using */ CFG_DiSectionDataCount, CFG_DiConvertClockSource, CFG_DiConvertClockRatePerPort, CFG_DiScanPortStart, CFG_DiScanPortCount, CFG_DiScanClockSource, CFG_DiScanClockRate, CFG_DiScanCount, CFG_DiTriggerAction, CFG_DiTriggerSource, CFG_DiTriggerSourceEdge, CFG_DiTriggerSourceLevel, /* Reserved for later using */ CFG_DiTriggerDelayCount, CFG_DiTriggerAction1, CFG_DiTriggerSource1, CFG_DiTriggerSourceEdge1, CFG_DiTriggerSourceLevel1, /* Reserved for later using */ CFG_DiTriggerDelayCount1, CFG_DoSectionDataCount, CFG_DoConvertClockSource, CFG_DoConvertClockRatePerPort, CFG_DoScanPortStart, CFG_DoScanPortCount, CFG_DoScanClockSource, CFG_DoScanClockRate, CFG_DoScanCount, CFG_DoTriggerAction, CFG_DoTriggerSource, CFG_DoTriggerSourceEdge, CFG_DoTriggerSourceLevel, /* Reserved for later using */ CFG_DoTriggerDelayCount, CFG_DoTriggerAction1, CFG_DoTriggerSource1, CFG_DoTriggerSourceEdge1, CFG_DoTriggerSourceLevel1, /* Reserved for later using */ CFG_DoTriggerDelayCount1, /*----------------------------------------------------------------- * component specified Property IDs -- Counter/Timer *-----------------------------------------------------------------*/ /*common feature*/ CFG_FeatureCapabilitiesOfCounter0 = 174, CFG_FeatureCapabilitiesOfCounter1, CFG_FeatureCapabilitiesOfCounter2, CFG_FeatureCapabilitiesOfCounter3, CFG_FeatureCapabilitiesOfCounter4, CFG_FeatureCapabilitiesOfCounter5, CFG_FeatureCapabilitiesOfCounter6, CFG_FeatureCapabilitiesOfCounter7, /*primal counter features*/ CFG_FeatureChipOperationModes = 206, CFG_FeatureChipSignalCountingTypes, /*timer/pulse features*/ CFG_FeatureTmrCascadeGroups = 211, /*frequency measurement features*/ CFG_FeatureFmMethods = 213, /*Primal counter properties */ CFG_ChipOperationModeOfCounters = 220, CFG_ChipSignalCountingTypeOfCounters, CFG_ChipLoadValueOfCounters, CFG_ChipHoldValueOfCounters, CFG_ChipOverCompareValueOfCounters, CFG_ChipUnderCompareValueOfCounters, CFG_ChipOverCompareEnabledCounters, CFG_ChipUnderCompareEnabledCounters, /*frequency measurement properties*/ CFG_FmMethodOfCounters = 231, CFG_FmCollectionPeriodOfCounters, //##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // v1.1 //##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx CFG_DevicePrivateRegionLength, CFG_SaiAutoConvertClockRate, CFG_SaiAutoConvertChannelStart, CFG_SaiAutoConvertChannelCount, CFG_ExtPauseSignalEnabled, CFG_ExtPauseSignalPolarity, CFG_OrderOfChannels, CFG_InitialStateOfChannels, //##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // v1.2: new features & properties of counter //##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx /*primal counter features*/ CFG_FeatureChipClkSourceOfCounter0 = 242, CFG_FeatureChipClkSourceOfCounter1, CFG_FeatureChipClkSourceOfCounter2, CFG_FeatureChipClkSourceOfCounter3, CFG_FeatureChipClkSourceOfCounter4, CFG_FeatureChipClkSourceOfCounter5, CFG_FeatureChipClkSourceOfCounter6, CFG_FeatureChipClkSourceOfCounter7, CFG_FeatureChipGateSourceOfCounter0, CFG_FeatureChipGateSourceOfCounter1, CFG_FeatureChipGateSourceOfCounter2, CFG_FeatureChipGateSourceOfCounter3, CFG_FeatureChipGateSourceOfCounter4, CFG_FeatureChipGateSourceOfCounter5, CFG_FeatureChipGateSourceOfCounter6, CFG_FeatureChipGateSourceOfCounter7, CFG_FeatureChipValueRegisters, /*one-shot features*/ CFG_FeatureOsClkSourceOfCounter0, CFG_FeatureOsClkSourceOfCounter1, CFG_FeatureOsClkSourceOfCounter2, CFG_FeatureOsClkSourceOfCounter3, CFG_FeatureOsClkSourceOfCounter4, CFG_FeatureOsClkSourceOfCounter5, CFG_FeatureOsClkSourceOfCounter6, CFG_FeatureOsClkSourceOfCounter7, CFG_FeatureOsGateSourceOfCounter0, CFG_FeatureOsGateSourceOfCounter1, CFG_FeatureOsGateSourceOfCounter2, CFG_FeatureOsGateSourceOfCounter3, CFG_FeatureOsGateSourceOfCounter4, CFG_FeatureOsGateSourceOfCounter5, CFG_FeatureOsGateSourceOfCounter6, CFG_FeatureOsGateSourceOfCounter7, /*Pulse width measurement features*/ CFG_FeaturePiCascadeGroups, /*Primal counter properties */ CFG_ChipClkSourceOfCounters = 279, CFG_ChipGateSourceOfCounters, /*one-shot properties*/ CFG_OsClkSourceOfCounters, CFG_OsGateSourceOfCounters, CFG_OsDelayCountOfCounters, /*Timer pulse properties*/ CFG_TmrFrequencyOfCounters, /*Pulse width modulation properties*/ CFG_PoHiPeriodOfCounters, CFG_PoLoPeriodOfCounters, //##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // v1.3: new features & properties of counter //##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx /*Event counting features & properties*/ CFG_FeatureEcClkPolarities, CFG_FeatureEcGatePolarities, CFG_FeatureEcGateControlOfCounters, CFG_EcClkPolarityOfCounters, CFG_EcGatePolarityOfCounters, CFG_EcGateEnabledOfCounters, /*one-shot features & properties*/ CFG_FeatureOsClkPolarities, CFG_FeatureOsGatePolarities, CFG_FeatureOsOutSignals, CFG_OsClkPolarityOfCounters, CFG_OsGatePolarityOfCounters, CFG_OsOutSignalOfCounters, /*timer/pulse features & properties*/ CFG_FeatureTmrGateControlOfCounters, CFG_FeatureTmrGatePolarities, CFG_FeatureTmrOutSignals, CFG_FeatureTmrFrequencyRange, CFG_TmrGateEnabledOfCounters, CFG_TmrGatePolarityOfCounters, CFG_TmrOutSignalOfCounters, /*Pulse width modulation features & properties*/ CFG_FeaturePoGateControlOfCounters, CFG_FeaturePoGatePolarities, CFG_FeaturePoHiPeriodRange, CFG_FeaturePoLoPeriodRange, CFG_FeaturePoOutCountRange, CFG_PoGateEnabledOfCounters, CFG_PoGatePolarityOfCounters, CFG_PoOutCountOfCounters, //##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // v1.4: new features & properties of counter //##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx CFG_FeatureChipClkPolarities, CFG_FeatureChipGatePolarities, CFG_FeatureChipOutSignals, CFG_ChipClkPolarityOfCounters, CFG_ChipGatePolarityOfCounters, CFG_ChipOutSignalOfCounters, //##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // v1.5: new features & properties of counter //##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx CFG_FeatureOsDelayCountRange, //##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // v1.6: new features & properties of counter //##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx CFG_FeatureUdCountingTypes, CFG_FeatureUdInitialValues, CFG_UdCountingTypeOfCounters, CFG_UdInitialValueOfCounters, CFG_UdCountValueResetTimesByIndexs, //##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // v1.7: new features & properties of AI //##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx CFG_FeatureFilterTypes, CFG_FeatureFilterCutoffFreqRange, CFG_FeatureFilterCutoffFreq1Range, CFG_FilterTypeOfChannels, CFG_FilterCutoffFreqOfChannels, CFG_FilterCutoffFreq1OfChannels, } PropertyId; #define BioFailed(c) ((unsigned)(c) >= (unsigned)0xE0000000) typedef enum tagErrorCode { /// <summary> /// The operation is completed successfully. /// </summary> Success = 0, ///************************************************************************ /// warning ///************************************************************************ /// <summary> /// The interrupt resource is not available. /// </summary> WarningIntrNotAvailable = 0xA0000000, /// <summary> /// The parameter is out of the range. /// </summary> WarningParamOutOfRange = 0xA0000001, /// <summary> /// The property value is out of range. /// </summary> WarningPropValueOutOfRange = 0xA0000002, /// <summary> /// The property value is not supported. /// </summary> WarningPropValueNotSpted = 0xA0000003, /// <summary> /// The property value conflicts with the current state. /// </summary> WarningPropValueConflict = 0xA0000004, /// <summary> /// The value range of all channels in a group should be same, /// such as 4~20mA of PCI-1724. /// </summary> WarningVrgOfGroupNotSame = 0xA0000005, ///*********************************************************************** /// error ///*********************************************************************** /// <summary> /// The handle is NULL or its type doesn't match the required operation. /// </summary> ErrorHandleNotValid = 0xE0000000, /// <summary> /// The parameter value is out of range. /// </summary> ErrorParamOutOfRange = 0xE0000001, /// <summary> /// The parameter value is not supported. /// </summary> ErrorParamNotSpted = 0xE0000002, /// <summary> /// The parameter value format is not the expected. /// </summary> ErrorParamFmtUnexpted = 0xE0000003, /// <summary> /// Not enough memory is available to complete the operation. /// </summary> ErrorMemoryNotEnough = 0xE0000004, /// <summary> /// The data buffer is null. /// </summary> ErrorBufferIsNull = 0xE0000005, /// <summary> /// The data buffer is too small for the operation. /// </summary> ErrorBufferTooSmall = 0xE0000006, /// <summary> /// The data length exceeded the limitation. /// </summary> ErrorDataLenExceedLimit = 0xE0000007, /// <summary> /// The required function is not supported. /// </summary> ErrorFuncNotSpted = 0xE0000008, /// <summary> /// The required event is not supported. /// </summary> ErrorEventNotSpted = 0xE0000009, /// <summary> /// The required property is not supported. /// </summary> ErrorPropNotSpted = 0xE000000A, /// <summary> /// The required property is read-only. /// </summary> ErrorPropReadOnly = 0xE000000B, /// <summary> /// The specified property value conflicts with the current state. /// </summary> ErrorPropValueConflict = 0xE000000C, /// <summary> /// The specified property value is out of range. /// </summary> ErrorPropValueOutOfRange = 0xE000000D, /// <summary> /// The specified property value is not supported. /// </summary> ErrorPropValueNotSpted = 0xE000000E, /// <summary> /// The handle hasn't own the privilege of the operation the user wanted. /// </summary> ErrorPrivilegeNotHeld = 0xE000000F, /// <summary> /// The required privilege is not available because someone else had own it. /// </summary> ErrorPrivilegeNotAvailable = 0xE0000010, /// <summary> /// The driver of specified device was not found. /// </summary> ErrorDriverNotFound = 0xE0000011, /// <summary> /// The driver version of the specified device mismatched. /// </summary> ErrorDriverVerMismatch = 0xE0000012, /// <summary> /// The loaded driver count exceeded the limitation. /// </summary> ErrorDriverCountExceedLimit = 0xE0000013, /// <summary> /// The device is not opened. /// </summary> ErrorDeviceNotOpened = 0xE0000014, /// <summary> /// The required device does not exist. /// </summary> ErrorDeviceNotExist = 0xE0000015, /// <summary> /// The required device is unrecognized by driver. /// </summary> ErrorDeviceUnrecognized = 0xE0000016, /// <summary> /// The configuration data of the specified device is lost or unavailable. /// </summary> ErrorConfigDataLost = 0xE0000017, /// <summary> /// The function is not initialized and can't be started. /// </summary> ErrorFuncNotInited = 0xE0000018, /// <summary> /// The function is busy. /// </summary> ErrorFuncBusy = 0xE0000019, /// <summary> /// The interrupt resource is not available. /// </summary> ErrorIntrNotAvailable = 0xE000001A, /// <summary> /// The DMA channel is not available. /// </summary> ErrorDmaNotAvailable = 0xE000001B, /// <summary> /// Time out when reading/writing the device. /// </summary> ErrorDeviceIoTimeOut = 0xE000001C, /// <summary> /// The given signature does not match with the device current one. /// </summary> ErrorSignatureNotMatch = 0xE000001D, /// <summary> /// Undefined error /// </summary> ErrorUndefined = 0xE000FFFF, } ErrorCode; // Advantech CardType ID typedef enum tagProductId { BD_DEMO = 0x00, // demo board BD_PCL818 = 0x05, // PCL-818 board BD_PCL818H = 0x11, // PCL-818H BD_PCL818L = 0x21, // PCL-818L BD_PCL818HG = 0x22, // PCL-818HG BD_PCL818HD = 0x2b, // PCL-818HD BD_PCM3718 = 0x37, // PCM-3718 BD_PCM3724 = 0x38, // PCM-3724 BD_PCM3730 = 0x5a, // PCM-3730 BD_PCI1750 = 0x5e, // PCI-1750 BD_PCI1751 = 0x5f, // PCI-1751 BD_PCI1710 = 0x60, // PCI-1710 BD_PCI1712 = 0x61, // PCI-1712 BD_PCI1710HG = 0x67, // PCI-1710HG BD_PCI1711 = 0x73, // PCI-1711 BD_PCI1711L = 0x75, // PCI-1711L BD_PCI1713 = 0x68, // PCI-1713 BD_PCI1753 = 0x69, // PCI-1753 BD_PCI1760 = 0x6a, // PCI-1760 BD_PCI1720 = 0x6b, // PCI-1720 BD_PCM3718H = 0x6d, // PCM-3718H BD_PCM3718HG = 0x6e, // PCM-3718HG BD_PCI1716 = 0x74, // PCI-1716 BD_PCI1731 = 0x75, // PCI-1731 BD_PCI1754 = 0x7b, // PCI-1754 BD_PCI1752 = 0x7c, // PCI-1752 BD_PCI1756 = 0x7d, // PCI-1756 BD_PCM3725 = 0x7f, // PCM-3725 BD_PCI1762 = 0x80, // PCI-1762 BD_PCI1721 = 0x81, // PCI-1721 BD_PCI1761 = 0x82, // PCI-1761 BD_PCI1723 = 0x83, // PCI-1723 BD_PCI1730 = 0x87, // PCI-1730 BD_PCI1733 = 0x88, // PCI-1733 BD_PCI1734 = 0x89, // PCI-1734 BD_PCI1710L = 0x90, // PCI-1710L BD_PCI1710HGL = 0x91,// PCI-1710HGL BD_PCM3712 = 0x93, // PCM-3712 BD_PCM3723 = 0x94, // PCM-3723 BD_PCI1780 = 0x95, // PCI-1780 BD_CPCI3756 = 0x96, // CPCI-3756 BD_PCI1755 = 0x97, // PCI-1755 BD_PCI1714 = 0x98, // PCI-1714 BD_PCI1757 = 0x99, // PCI-1757 BD_MIC3716 = 0x9A, // MIC-3716 BD_MIC3761 = 0x9B, // MIC-3761 BD_MIC3753 = 0x9C, // MIC-3753 BD_MIC3780 = 0x9D, // MIC-3780 BD_PCI1724 = 0x9E, // PCI-1724 BD_PCI1758UDI = 0xA3, // PCI-1758UDI BD_PCI1758UDO = 0xA4, // PCI-1758UDO BD_PCI1747 = 0xA5, // PCI-1747 BD_PCM3780 = 0xA6, // PCM-3780 BD_MIC3747 = 0xA7, // MIC-3747 BD_PCI1758UDIO = 0xA8, // PCI-1758UDIO BD_PCI1712L = 0xA9, // PCI-1712L BD_PCI1763UP = 0xAC, // PCI-1763UP BD_PCI1736UP = 0xAD, // PCI-1736UP BD_PCI1714UL = 0xAE, // PCI-1714UL BD_MIC3714 = 0xAF, // MIC-3714 BD_PCM3718HO = 0xB1, // PCM-3718HO BD_PCI1741U = 0xB3, // PCI-1741U BD_MIC3723 = 0xB4, // MIC-3723 BD_PCI1718HDU = 0xB5, // PCI-1718HDU BD_MIC3758DIO = 0xB6, // MIC-3758DIO BD_PCI1727U = 0xB7, // PCI-1727U BD_PCI1718HGU = 0xB8, // PCI-1718HGU BD_PCI1715U = 0xB9, // PCI-1715U BD_PCI1716L = 0xBA, // PCI-1716L BD_PCI1735U = 0xBB, // PCI-1735U BD_USB4711 = 0xBC, // USB4711 BD_PCI1737U = 0xBD, // PCI-1737U BD_PCI1739U = 0xBE, // PCI-1739U BD_PCI1742U = 0xC0, // PCI-1742U BD_USB4718 = 0xC6, // USB-4718 BD_MIC3755 = 0xC7, // MIC3755 BD_USB4761 = 0xC8, // USB4761 BD_PCI1784 = 0XCC, // PCI-1784 BD_USB4716 = 0xCD, // USB4716 BD_PCI1752U = 0xCE, // PCI-1752U BD_PCI1752USO = 0xCF, // PCI-1752USO BD_USB4751 = 0xD0, // USB4751 BD_USB4751L = 0xD1, // USB4751L BD_USB4750 = 0xD2, // USB4750 BD_MIC3713 = 0xD3, // MIC-3713 BD_USB4711A = 0xD8, // USB4711A BD_PCM3753P = 0xD9, // PCM3753P BD_PCM3784 = 0xDA, // PCM3784 BD_PCM3761I = 0xDB, // PCM-3761I BD_MIC3751 = 0xDC, // MIC-3751 BD_PCM3730I = 0xDD, // PCM-3730I BD_PCM3813I = 0xE0, // PCM-3813I BD_PCIE1744 = 0xE1, //PCIE-1744 BD_PCI1730U = 0xE2, // PCI-1730U BD_PCI1760U = 0xE3, //PCI-1760U BD_MIC3720 = 0xE4, //MIC-3720 BD_PCM3810I = 0xE9, // PCM-3810I BD_USB4702 = 0xEA, // USB4702 BD_USB4704 = 0xEB, // USB4704 BD_PCM3810I_HG = 0xEC, // PCM-3810I_HG BD_PCI1713U = 0xED, // PCI-1713U // !!!BioDAQ only Product ID starts from here!!! BD_PCI1706U = 0x800, BD_PCI1706MSU = 0x801, BD_PCI1706UL = 0x802, BD_PCIE1752 = 0x803, BD_PCIE1754 = 0x804, BD_PCIE1756 = 0x805, BD_MIC1911 = 0x806, BD_MIC3750 = 0x807, BD_MIC3711 = 0x808, BD_PCIE1730 = 0x809, BD_PCI1710_ECU = 0x80A, BD_PCI1720_ECU = 0x80B, BD_PCIE1760 = 0x80C, BD_PCIE1751 = 0x80D, BD_ECUP1060 = 0x80E, } ProductId; END_NAMEAPCE_AUTOMATION_BDAQ #endif // _BDAQ_TYPES_DEFINED // ********************************************************** // Bionic DAQ COM style class library // ********************************************************** #if !defined(_BDAQ_TYPES_ONLY) && !defined(_BDAQ_COM_STYLE_CLASS_LIB) #define _BDAQ_COM_STYLE_CLASS_LIB #ifndef _BIONIC_DAQ_DLL # if defined(_WIN32) # include <Windows.h> # endif #endif BEGIN_NAMEAPCE_AUTOMATION_BDAQ // ********************************************************** // Forward declare // ********************************************************** class DeviceCtrlBase; class AiCtrlBase; class InstantAiCtrl; class BufferedAiCtrl; class AoCtrlBase; class InstantAoCtrl; class BufferedAoCtrl; class DioCtrlBase; class DiCtrlBase; class DoCtrlBase; class InstantDiCtrl; class InstantDoCtrl; class BufferedDiCtrl; class BufferedDoCtrl; class CntrCtrlBase; class EventCounterCtrl; class FreqMeterCtrl; class OneShotCtrl; class PwMeterCtrl; class PwModulatorCtrl; class TimerPulseCtrl; class UdCounterCtrl; // ********************************************************** // factory method define // ********************************************************** #ifndef _BIONIC_DAQ_DLL # if defined(_WIN32) || defined(WIN32) // the following two methods are for internal using only, don't call them directly! __inline HMODULE GetBDaqLibInstance() { static HMODULE instance = LoadLibrary(TEXT("biodaq.dll")); return instance; } __inline void* GetBDaqApiAddress(char const * name) { #ifdef _WIN32_WCE return GetProcAddressA(GetBDaqLibInstance(), name); #else return GetProcAddress(GetBDaqLibInstance(), name); #endif } __inline void* BDaqObjectCreate(char const * creator) { void*(BDAQCALL *fn)() = (void*(BDAQCALL *)())GetBDaqApiAddress(creator); return fn(); } // Global APIs __inline ErrorCode AdxDeviceGetLinkageInfo( int32 deviceParent, /*IN*/ int32 index, /*IN*/ int32 *deviceNumber, /*OUT*/ wchar_t *description, /*OUT OPTIONAL*/ int32 *subDeviceCount) /*OUT OPTIONAL*/ { typedef ErrorCode (BDAQCALL *PfnGetLinkageInfo)(int32,int32,int32*,wchar_t*,int32*); PfnGetLinkageInfo fn = (PfnGetLinkageInfo)GetBDaqApiAddress("AdxDeviceGetLinkageInfo"); return fn ? fn(deviceParent, index, deviceNumber, description, subDeviceCount) : ErrorDriverNotFound; } __inline ErrorCode AdxGetValueRangeInformation( ValueRange type, /*IN*/ int32 descBufSize, /*IN*/ wchar_t *description, /*OUT OPTIONAL*/ MathInterval *range, /*OUT OPTIONAL*/ ValueUnit *unit) /*OUT OPTIONAL */ { typedef ErrorCode (BDAQCALL *PfnGetVrgInfo)(int32,int32,wchar_t*,MathInterval*,int32*); PfnGetVrgInfo fn = (PfnGetVrgInfo)GetBDaqApiAddress("AdxGetValueRangeInformation"); return fn ? fn(type, descBufSize, description, range, (int32*)unit) : ErrorDriverNotFound; } __inline ErrorCode AdxGetSignalConnectionInformation( SignalDrop signal, /*IN*/ int32 descBufSize, /*IN*/ wchar_t *description,/*OUT OPTIONAL*/ SignalPosition *position) /*OUT OPTIONAL*/ { typedef ErrorCode (BDAQCALL *PfnGetSignalCnntInfo)(int32,int32,wchar_t*,int32*); PfnGetSignalCnntInfo fn = (PfnGetSignalCnntInfo)GetBDaqApiAddress("AdxGetSignalConnectionInformation"); return fn ? fn(signal, descBufSize, description, (int32*)position) : ErrorDriverNotFound; } __inline ErrorCode AdxEnumToString( wchar_t const *enumTypeName, /*IN*/ int32 enumValue, /*IN*/ int32 enumStringLength, /*IN*/ wchar_t *enumString) /*OUT*/ { typedef ErrorCode (BDAQCALL *PfnEnumToStr)(wchar_t const*,int32,int32,wchar_t*); PfnEnumToStr fn = (PfnEnumToStr)GetBDaqApiAddress("AdxEnumToString"); return fn ? fn(enumTypeName, enumValue, enumStringLength, enumString) : ErrorDriverNotFound; } __inline ErrorCode AdxStringToEnum( wchar_t const *enumTypeName, /*IN*/ wchar_t const *enumString, /*IN*/ int32 *enumValue) /*OUT*/ { typedef ErrorCode (BDAQCALL *PfnStrToEnum)(wchar_t const*,wchar_t const*,int32*); PfnStrToEnum fn = (PfnStrToEnum)GetBDaqApiAddress("AdxStringToEnum"); return fn ? fn(enumTypeName, enumString, enumValue) : ErrorDriverNotFound; } // Biodaq object create methods __inline InstantAiCtrl* AdxInstantAiCtrlCreate() { return (InstantAiCtrl*)BDaqObjectCreate("AdxInstantAiCtrlCreate"); } __inline BufferedAiCtrl* AdxBufferedAiCtrlCreate() { return (BufferedAiCtrl*)BDaqObjectCreate("AdxBufferedAiCtrlCreate"); } __inline InstantAoCtrl* AdxInstantAoCtrlCreate() { return (InstantAoCtrl*)BDaqObjectCreate("AdxInstantAoCtrlCreate"); } __inline BufferedAoCtrl* AdxBufferedAoCtrlCreate() { return (BufferedAoCtrl*)BDaqObjectCreate("AdxBufferedAoCtrlCreate"); } __inline InstantDiCtrl* AdxInstantDiCtrlCreate() { return (InstantDiCtrl*)BDaqObjectCreate("AdxInstantDiCtrlCreate"); } __inline BufferedDiCtrl* AdxBufferedDiCtrlCreate() { return (BufferedDiCtrl*)BDaqObjectCreate("AdxBufferedDiCtrlCreate"); } __inline InstantDoCtrl* AdxInstantDoCtrlCreate() { return (InstantDoCtrl*)BDaqObjectCreate("AdxInstantDoCtrlCreate"); } __inline BufferedDoCtrl* AdxBufferedDoCtrlCreate() { return (BufferedDoCtrl*)BDaqObjectCreate("AdxBufferedDoCtrlCreate"); } __inline EventCounterCtrl* AdxEventCounterCtrlCreate() { return (EventCounterCtrl*)BDaqObjectCreate("AdxEventCounterCtrlCreate"); } __inline FreqMeterCtrl* AdxFreqMeterCtrlCreate() { return (FreqMeterCtrl*)BDaqObjectCreate("AdxFreqMeterCtrlCreate"); } __inline OneShotCtrl* AdxOneShotCtrlCreate() { return (OneShotCtrl*)BDaqObjectCreate("AdxOneShotCtrlCreate"); } __inline PwMeterCtrl* AdxPwMeterCtrlCreate() { return (PwMeterCtrl*)BDaqObjectCreate("AdxPwMeterCtrlCreate"); } __inline PwModulatorCtrl* AdxPwModulatorCtrlCreate() { return (PwModulatorCtrl*)BDaqObjectCreate("AdxPwModulatorCtrlCreate"); } __inline TimerPulseCtrl* AdxTimerPulseCtrlCreate() { return (TimerPulseCtrl*)BDaqObjectCreate("AdxTimerPulseCtrlCreate"); } __inline UdCounterCtrl* AdxUdCounterCtrlCreate() { return (UdCounterCtrl*)BDaqObjectCreate("AdxUdCounterCtrlCreate"); } # else // Non-win32 extern "C" { // Global APIs ErrorCode AdxDeviceGetLinkageInfo( int32 deviceParent, /*IN*/ int32 index, /*IN*/ int32 *deviceNumber, /*OUT*/ wchar_t *description, /*OUT OPTIONAL*/ int32 *subDeviceCount); /*OUT OPTIONAL*/ ErrorCode AdxGetValueRangeInformation( ValueRange type, /*IN*/ int32 descBufSize, /*IN*/ wchar_t *description, /*OUT OPTIONAL*/ MathInterval *range, /*OUT OPTIONAL*/ ValueUnit *unit); /*OUT OPTIONAL */ ErrorCode AdxGetSignalConnectionInformation( SignalDrop signal, /*IN*/ int32 descBufSize, /*IN*/ wchar_t *description,/*OUT OPTIONAL*/ SignalPosition *position); /*OUT OPTIONAL*/ ErrorCode AdxEnumToString( wchar_t const *enumTypeName, /*IN*/ int32 enumValue, /*IN*/ int32 enumStringLength, /*IN*/ wchar_t *enumString); /*OUT*/ ErrorCode AdxStringToEnum( wchar_t const *enumTypeName, /*IN*/ wchar_t const *enumString, /*IN*/ int32 *enumValue); /*OUT*/ // Biodaq object create methods InstantAiCtrl* AdxInstantAiCtrlCreate(); BufferedAiCtrl* AdxBufferedAiCtrlCreate(); InstantAoCtrl* AdxInstantAoCtrlCreate(); BufferedAoCtrl* AdxBufferedAoCtrlCreate(); InstantDiCtrl* AdxInstantDiCtrlCreate(); BufferedDiCtrl* AdxBufferedDiCtrlCreate(); InstantDoCtrl* AdxInstantDoCtrlCreate(); BufferedDoCtrl* AdxBufferedDoCtrlCreate(); EventCounterCtrl* AdxEventCounterCtrlCreate(); FreqMeterCtrl* AdxFreqMeterCtrlCreate(); OneShotCtrl* AdxOneShotCtrlCreate(); PwMeterCtrl* AdxPwMeterCtrlCreate(); PwModulatorCtrl* AdxPwModulatorCtrlCreate(); TimerPulseCtrl* AdxTimerPulseCtrlCreate(); UdCounterCtrl* AdxUdCounterCtrlCreate(); } # endif #endif // _BIONIC_DAQ_DLL // ********************************************************** // types definition // ********************************************************** typedef struct tagDeviceInformation{ int32 DeviceNumber; AccessMode DeviceMode; int32 ModuleIndex; wchar_t Description[MAX_DEVICE_DESC_LEN]; explicit tagDeviceInformation(int32 deviceNumber = -1, AccessMode mode = ModeWriteWithReset, int32 moduleIndex = 0) { Init(deviceNumber, NULL, mode, moduleIndex); } explicit tagDeviceInformation(wchar_t const *deviceDesc, AccessMode mode = ModeWriteWithReset, int32 moduleIndex = 0) { Init(-1, deviceDesc, mode, moduleIndex); } void Init(int32 deviceNumber, wchar_t const *deviceDesc, AccessMode mode, int32 moduleIndex) { DeviceNumber = deviceNumber; DeviceMode = mode; ModuleIndex = moduleIndex; if (deviceDesc == NULL) Description[0] = L'\0'; else { for (int i = 0; i < (MAX_DEVICE_DESC_LEN - 1) && (Description[i] = *deviceDesc++); ++i){} Description[MAX_DEVICE_DESC_LEN - 1] = L'\0'; } } }DeviceInformation; typedef struct tagDeviceTreeNode{ int32 DeviceNumber; int32 ModulesIndex[8]; wchar_t Description[MAX_DEVICE_DESC_LEN]; }DeviceTreeNode; typedef struct tagDeviceEventArgs { // ^_^ // at present nothing is needed to be passed to user // it is just a place-holder for later extension. }DeviceEventArgs; typedef struct tagBfdAiEventArgs { int32 Offset; // offset of the new data int32 Count; // amount of the new data }BfdAiEventArgs; typedef struct tagBfdAoEventArgs { int32 Offset; // offset of blank area int32 Count; // amount of blank area }BfdAoEventArgs; typedef struct tagBfdDiEventArgs { int32 Offset; // offset of the new data int32 Count; // amount of the new data }BfdDiEventArgs; typedef struct tagBfdDoEventArgs { int32 Offset; // offset of blank area int32 Count; // amount of blank area }BfdDoEventArgs; typedef struct tagDiSnapEventArgs{ int32 SrcNum; int32 Length; uint8 PortData[MAX_DIO_PORT_COUNT]; }DiSnapEventArgs; typedef struct tagCntrEventArgs{ int32 Channel; }CntrEventArgs; typedef struct tagUdCntrEventArgs{ int32 SrcId; int32 Length; int32 Data[MAX_CNTR_CH_COUNT]; }UdCntrEventArgs; typedef struct tagPulseWidth{ double HiPeriod; double LoPeriod; }PulseWidth; typedef enum tagControlState { Idle = 0, Ready, Running, Stopped } ControlState; // ********************************************************** // classes definition // ********************************************************** // ---------------------------------------------------------- // common classes // ---------------------------------------------------------- template<class T> class ICollection { public: virtual void BDAQCALL Dispose() = 0; // destroy the instance virtual int32 BDAQCALL getCount() = 0; virtual T & BDAQCALL getItem(int32 index) = 0; }; class AnalogChannel { public: virtual int32 BDAQCALL getChannel() = 0; virtual ValueRange BDAQCALL getValueRange() = 0; virtual ErrorCode BDAQCALL setValueRange(ValueRange value) = 0; }; class AnalogInputChannel : public AnalogChannel { public: virtual AiSignalType BDAQCALL getSignalType() = 0; virtual ErrorCode BDAQCALL setSignalType(AiSignalType value) = 0; virtual BurnoutRetType BDAQCALL getBurnoutRetType() = 0; virtual ErrorCode BDAQCALL setBurnoutRetType(BurnoutRetType value) = 0; virtual double BDAQCALL getBurnoutRetValue() = 0; virtual ErrorCode BDAQCALL setBurnoutRetValue(double value) = 0; }; class CjcSetting { public: virtual int32 BDAQCALL getChannel() = 0; virtual ErrorCode BDAQCALL setChannel(int32 ch) = 0; virtual double BDAQCALL getValue() = 0; virtual ErrorCode BDAQCALL setValue(double value) = 0; }; class ScanChannel { public: virtual int32 BDAQCALL getChannelStart() = 0; virtual ErrorCode BDAQCALL setChannelStart(int32 value) = 0; virtual int32 BDAQCALL getChannelCount() = 0; virtual ErrorCode BDAQCALL setChannelCount(int32 value) = 0; virtual int32 BDAQCALL getSamples() = 0; virtual ErrorCode BDAQCALL setSamples(int32 value) = 0; virtual int32 BDAQCALL getIntervalCount() = 0; virtual ErrorCode BDAQCALL setIntervalCount(int32 value) = 0; }; class ConvertClock { public: virtual SignalDrop BDAQCALL getSource() = 0; virtual ErrorCode BDAQCALL setSource(SignalDrop value) = 0; virtual double BDAQCALL getRate() = 0; virtual ErrorCode BDAQCALL setRate(double value) = 0; }; class ScanClock { public: virtual SignalDrop BDAQCALL getSource() = 0; virtual ErrorCode BDAQCALL setSource(SignalDrop value) = 0; virtual double BDAQCALL getRate() = 0; virtual ErrorCode BDAQCALL setRate(double value) = 0; virtual int32 BDAQCALL getScanCount() = 0; virtual ErrorCode BDAQCALL setScanCount(int32 value) = 0; }; class Trigger { public: virtual SignalDrop BDAQCALL getSource() = 0; virtual ErrorCode BDAQCALL setSource(SignalDrop value) = 0; virtual ActiveSignal BDAQCALL getEdge() = 0; virtual ErrorCode BDAQCALL setEdge(ActiveSignal value) = 0; virtual double BDAQCALL getLevel() = 0; virtual ErrorCode BDAQCALL setLevel(double value) = 0; virtual TriggerAction BDAQCALL getAction() = 0; virtual ErrorCode BDAQCALL setAction(TriggerAction value) = 0; virtual int32 BDAQCALL getDelayCount() = 0; virtual ErrorCode BDAQCALL setDelayCount(int32 value) = 0; }; class PortDirection { public: virtual int32 BDAQCALL getPort() = 0; virtual DioPortDir BDAQCALL getDirection() = 0; virtual ErrorCode BDAQCALL setDirection(DioPortDir value) = 0; }; class NoiseFilterChannel { public: virtual int32 BDAQCALL getChannel() = 0; virtual bool BDAQCALL getEnabled() = 0; virtual ErrorCode BDAQCALL setEnabled(bool value) = 0; }; class DiintChannel { public: virtual int32 BDAQCALL getChannel() = 0; virtual bool BDAQCALL getEnabled() = 0; virtual ErrorCode BDAQCALL setEnabled(bool value) = 0; virtual bool BDAQCALL getGated() = 0; virtual ErrorCode BDAQCALL setGated(bool value) = 0; virtual ActiveSignal BDAQCALL getTrigEdge() = 0; virtual ErrorCode BDAQCALL setTrigEdge(ActiveSignal value) = 0; }; class DiCosintPort { public: virtual int32 BDAQCALL getPort() = 0; virtual uint8 BDAQCALL getMask() = 0; virtual ErrorCode BDAQCALL setMask(uint8 value) = 0; }; class DiPmintPort { public: virtual int32 BDAQCALL getPort() = 0; virtual uint8 BDAQCALL getMask() = 0; virtual ErrorCode BDAQCALL setMask(uint8 value) = 0; virtual uint8 BDAQCALL getPattern() = 0; virtual ErrorCode BDAQCALL setPattern(uint8 value) = 0; }; class ScanPort { public: virtual int32 BDAQCALL getPortStart() = 0; virtual ErrorCode BDAQCALL setPortStart(int32 value) = 0; virtual int32 BDAQCALL getPortCount() = 0; virtual ErrorCode BDAQCALL setPortCount(int32 value) = 0; virtual int32 BDAQCALL getSamples() = 0; virtual ErrorCode BDAQCALL setSamples(int32 value) = 0; virtual int32 BDAQCALL getIntervalCount() = 0; virtual ErrorCode BDAQCALL setIntervalCount(int32 value) = 0; }; // ---------------------------------------------------------- // ctrl base class // ---------------------------------------------------------- class DeviceEventListener { public: virtual void BDAQCALL DeviceEvent(void * sender, DeviceEventArgs * args) = 0; }; class DeviceCtrlBase { public: // method virtual void BDAQCALL Dispose() = 0; // destroy the instance virtual void BDAQCALL Cleanup() = 0; // release the resources allocated. virtual ErrorCode BDAQCALL UpdateProperties() = 0; // event virtual void BDAQCALL addRemovedListener(DeviceEventListener & listener) = 0; virtual void BDAQCALL removeRemovedListener(DeviceEventListener & listener) = 0; virtual void BDAQCALL addReconnectedListener(DeviceEventListener & listener) = 0; virtual void BDAQCALL removeReconnectedListener(DeviceEventListener & listener) = 0; virtual void BDAQCALL addPropertyChangedListener(DeviceEventListener & listener) = 0; virtual void BDAQCALL removePropertyChangedListener(DeviceEventListener & listener) = 0; // property virtual void BDAQCALL getSelectedDevice(DeviceInformation &x) = 0; virtual ErrorCode BDAQCALL setSelectedDevice(DeviceInformation const &x) = 0; virtual bool BDAQCALL getInitialized() = 0; virtual bool BDAQCALL getCanEditProperty() = 0; virtual HANDLE BDAQCALL getDevice() = 0; virtual HANDLE BDAQCALL getModule() = 0; virtual ICollection<DeviceTreeNode>* BDAQCALL getSupportedDevices() = 0; virtual ICollection<AccessMode>* BDAQCALL getSupportedModes() = 0; }; // ---------------------------------------------------------- // AI related classes // ---------------------------------------------------------- typedef ICollection<AnalogInputChannel> AiChannelCollection; class AiFeatures { public: // ADC features virtual int32 BDAQCALL getResolution() = 0; virtual int32 BDAQCALL getDataSize() = 0; virtual int32 BDAQCALL getDataMask() = 0; // channel features virtual int32 BDAQCALL getChannelCountMax() = 0; virtual AiChannelType BDAQCALL getChannelType() = 0; virtual bool BDAQCALL getOverallValueRange() = 0; virtual bool BDAQCALL getThermoSupported() = 0; virtual ICollection<ValueRange>* BDAQCALL getValueRanges() = 0; virtual ICollection<BurnoutRetType>* BDAQCALL getBurnoutReturnTypes() = 0; // CJC features virtual ICollection<int32>* BDAQCALL getCjcChannels() = 0; // buffered ai->basic features virtual bool BDAQCALL getBufferedAiSupported() = 0; virtual SamplingMethod BDAQCALL getSamplingMethod() = 0; virtual int32 BDAQCALL getChannelStartBase() = 0; virtual int32 BDAQCALL getChannelCountBase() = 0; // buffered ai->conversion clock features virtual ICollection<SignalDrop>* BDAQCALL getConvertClockSources() = 0; virtual MathInterval BDAQCALL getConvertClockRange() = 0; // buffered ai->burst scan virtual bool BDAQCALL getBurstScanSupported() = 0; virtual ICollection<SignalDrop>* BDAQCALL getScanClockSources() = 0; virtual MathInterval BDAQCALL getScanClockRange() = 0; virtual int32 BDAQCALL getScanCountMax() = 0; // buffered ai->trigger features virtual bool BDAQCALL getTriggerSupported() = 0; virtual int32 BDAQCALL getTriggerCount() = 0; virtual ICollection<SignalDrop>* BDAQCALL getTriggerSources() = 0; virtual ICollection<TriggerAction>* BDAQCALL getTriggerActions() = 0; virtual MathInterval BDAQCALL getTriggerDelayRange() = 0; }; class AiCtrlBase : public DeviceCtrlBase { public: // property virtual AiFeatures* BDAQCALL getFeatures() = 0; virtual AiChannelCollection* BDAQCALL getChannels() = 0; virtual int32 BDAQCALL getChannelCount() = 0; }; class InstantAiCtrl : public AiCtrlBase { public: // method virtual ErrorCode BDAQCALL ReadAny(int32 chStart, int32 chCount, void *dataRaw, double *dataScaled) = 0; // property virtual CjcSetting* BDAQCALL getCjc() = 0; // helpers ErrorCode BDAQCALL Read(int32 ch, double &dataScaled) { return ReadAny(ch, 1, NULL, &dataScaled); } ErrorCode BDAQCALL Read(int32 ch, int16 &dataRaw) { return ReadAny(ch, 1, &dataRaw, NULL); } ErrorCode BDAQCALL Read(int32 ch, int32 &dataRaw) { return ReadAny(ch, 1, &dataRaw, NULL); } ErrorCode BDAQCALL Read(int32 chStart, int32 chCount, double dataScaled[]) { return ReadAny(chStart, chCount, NULL, dataScaled); } ErrorCode BDAQCALL Read(int32 chStart, int32 chCount, int16 dataRaw[], double dataScaled[]) { return ReadAny(chStart, chCount, dataRaw, dataScaled); } ErrorCode BDAQCALL Read(int32 chStart, int32 chCount, int32 dataRaw[], double dataScaled[]) { return ReadAny(chStart, chCount, dataRaw, dataScaled); } }; class BfdAiEventListener { public: virtual void BDAQCALL BfdAiEvent(void * sender, BfdAiEventArgs * args) = 0; }; class BufferedAiCtrl : public AiCtrlBase { public: // event virtual void BDAQCALL addDataReadyListener(BfdAiEventListener & listener) = 0; virtual void BDAQCALL removeDataReadyListener(BfdAiEventListener & listener) = 0; virtual void BDAQCALL addOverrunListener(BfdAiEventListener & listener) = 0; virtual void BDAQCALL removeOverrunListener(BfdAiEventListener & listener) = 0; virtual void BDAQCALL addCacheOverflowListener(BfdAiEventListener & listener) = 0; virtual void BDAQCALL removeCacheOverflowListener(BfdAiEventListener & listener) = 0; virtual void BDAQCALL addStoppedListener(BfdAiEventListener & listener) = 0; virtual void BDAQCALL removeStoppedListener(BfdAiEventListener & listener) = 0; // method virtual ErrorCode BDAQCALL Prepare() = 0; virtual ErrorCode BDAQCALL RunOnce() = 0; virtual ErrorCode BDAQCALL Start() = 0; virtual ErrorCode BDAQCALL Stop() = 0; virtual ErrorCode BDAQCALL GetDataI16(int32 count, int16 rawData[]) = 0; virtual ErrorCode BDAQCALL GetDataI32(int32 count, int32 rawData[]) = 0; virtual ErrorCode BDAQCALL GetDataF64(int32 count, double scaledData[]) = 0; virtual void BDAQCALL Release() = 0; // property virtual void* BDAQCALL getBuffer() = 0; virtual int32 BDAQCALL getBufferCapacity() = 0; virtual ControlState BDAQCALL getState() = 0; virtual ScanChannel* BDAQCALL getScanChannel() = 0; virtual ConvertClock* BDAQCALL getConvertClock() = 0; virtual ScanClock* BDAQCALL getScanClock() = 0; virtual Trigger* BDAQCALL getTrigger() = 0; virtual bool BDAQCALL getStreaming() = 0; virtual ErrorCode BDAQCALL setStreaming(bool value) = 0; // helpers ErrorCode BDAQCALL GetData(int32 count, int16 rawData[]) { return GetDataI16(count, rawData); } ErrorCode BDAQCALL GetData(int32 count, int32 rawData[]) { return GetDataI32(count, rawData); } ErrorCode BDAQCALL GetData(int32 count, double scaledData[]) { return GetDataF64(count, scaledData); } }; // ---------------------------------------------------------- // AO related classes // ---------------------------------------------------------- typedef ICollection<AnalogChannel> AoChannelCollection; class AoFeatures { public: // DAC features virtual int32 BDAQCALL getResolution() = 0; virtual int32 BDAQCALL getDataSize() = 0; virtual int32 BDAQCALL getDataMask() = 0; // channel features virtual int32 BDAQCALL getChannelCountMax() = 0; virtual ICollection<ValueRange>* BDAQCALL getValueRanges() = 0; virtual bool BDAQCALL getExternalRefAntiPolar() = 0; virtual MathInterval BDAQCALL getExternalRefRange() = 0; // buffered ao->basic features virtual bool BDAQCALL getBufferedAoSupported() = 0; virtual SamplingMethod BDAQCALL getSamplingMethod() = 0; virtual int32 BDAQCALL getChannelStartBase() = 0; virtual int32 BDAQCALL getChannelCountBase() = 0; // buffered ao->conversion clock features virtual ICollection<SignalDrop>* BDAQCALL getConvertClockSources() = 0; virtual MathInterval BDAQCALL getConvertClockRange() = 0; // buffered ao->trigger features virtual bool BDAQCALL getTriggerSupported() = 0; virtual int32 BDAQCALL getTriggerCount() = 0; virtual ICollection<SignalDrop>* BDAQCALL getTriggerSources() = 0; virtual ICollection<TriggerAction>* BDAQCALL getTriggerActions() = 0; virtual MathInterval BDAQCALL getTriggerDelayRange() = 0; }; class AoCtrlBase : public DeviceCtrlBase { public: // property virtual AoFeatures* BDAQCALL getFeatures() = 0; virtual AoChannelCollection* BDAQCALL getChannels() = 0; virtual int32 BDAQCALL getChannelCount() = 0; virtual double BDAQCALL getExtRefValueForUnipolar() = 0; virtual ErrorCode BDAQCALL setExtRefValueForUnipolar(double value) = 0; virtual double BDAQCALL getExtRefValueForBipolar() = 0; virtual ErrorCode BDAQCALL setExtRefValueForBipolar(double value) = 0; }; class InstantAoCtrl : public AoCtrlBase { public: // method virtual ErrorCode BDAQCALL WriteAny(int32 chStart, int32 chCount, void *dataRaw, double *dataScaled) = 0; // helpers ErrorCode BDAQCALL Write(int32 ch, double dataScaled) { return WriteAny(ch, 1, NULL, &dataScaled); } ErrorCode BDAQCALL Write(int32 ch, int16 dataRaw) { return WriteAny(ch, 1, &dataRaw, NULL); } ErrorCode BDAQCALL Write(int32 ch, int32 dataRaw) { return WriteAny(ch, 1, &dataRaw, NULL); } ErrorCode BDAQCALL Write(int32 chStart, int32 chCount, double dataScaled[]) { return WriteAny(chStart, chCount, NULL, dataScaled); } ErrorCode BDAQCALL Write(int32 chStart, int32 chCount, int16 dataRaw[]) { return WriteAny(chStart, chCount, dataRaw, NULL); } ErrorCode BDAQCALL Write(int32 chStart, int32 chCount, int32 dataRaw[]) { return WriteAny(chStart, chCount, dataRaw, NULL); } }; class BfdAoEventListener { public: virtual void BDAQCALL BfdAoEvent(void * sender, BfdAoEventArgs * args) = 0; }; class BufferedAoCtrl : public AoCtrlBase { public: // event virtual void BDAQCALL addDataTransmittedListener(BfdAoEventListener & listener) = 0; virtual void BDAQCALL removeDataTransmittedListener(BfdAoEventListener & listener) = 0; virtual void BDAQCALL addUnderrunListener(BfdAoEventListener & listener) = 0; virtual void BDAQCALL removeUnderrunListener(BfdAoEventListener & listener) = 0; virtual void BDAQCALL addCacheEmptiedListener(BfdAoEventListener & listener) = 0; virtual void BDAQCALL removeCacheEmptiedListener(BfdAoEventListener & listener) = 0; virtual void BDAQCALL addTransitStoppedListener(BfdAoEventListener & listener) = 0; virtual void BDAQCALL removeTransitStoppedListener(BfdAoEventListener & listener) = 0; virtual void BDAQCALL addStoppedListener(BfdAoEventListener & listener) = 0; virtual void BDAQCALL removeStoppedListener(BfdAoEventListener & listener) = 0; // method virtual ErrorCode BDAQCALL Prepare() = 0; virtual ErrorCode BDAQCALL RunOnce() = 0; virtual ErrorCode BDAQCALL Start() = 0; virtual ErrorCode BDAQCALL Stop(int32 action) = 0; virtual ErrorCode BDAQCALL SetDataI16(int32 count, int16 rawData[]) = 0; virtual ErrorCode BDAQCALL SetDataI32(int32 count, int32 rawData[]) = 0; virtual ErrorCode BDAQCALL SetDataF64(int32 count, double scaledData[]) = 0; virtual void BDAQCALL Release() = 0; // property virtual void* BDAQCALL getBuffer() = 0; virtual int32 BDAQCALL getBufferCapacity() = 0; virtual ControlState BDAQCALL getState() = 0; virtual ScanChannel* BDAQCALL getScanChannel() = 0; virtual ConvertClock* BDAQCALL getConvertClock() = 0; virtual Trigger* BDAQCALL getTrigger() = 0; virtual bool BDAQCALL getStreaming() = 0; virtual ErrorCode BDAQCALL setStreaming(bool value) = 0; // helpers ErrorCode BDAQCALL SetData(int32 count, int16 rawData[]) { return SetDataI16(count, rawData); } ErrorCode BDAQCALL SetData(int32 count, int32 rawData[]) { return SetDataI32(count, rawData); } ErrorCode BDAQCALL SetData(int32 count, double scaledData[]) { return SetDataF64(count, scaledData); } }; // ---------------------------------------------------------- // DIO related classes // ---------------------------------------------------------- class DioFeatures { public: // port features virtual bool BDAQCALL getPortProgrammable() = 0; virtual int32 BDAQCALL getPortCount() = 0; virtual ICollection<uint8>* BDAQCALL getPortsType() = 0; virtual bool BDAQCALL getDiSupported() = 0; virtual bool BDAQCALL getDoSupported() = 0; // channel features virtual int32 BDAQCALL getChannelCountMax() = 0; }; class DioCtrlBase : public DeviceCtrlBase { public: virtual int32 BDAQCALL getPortCount() = 0; virtual ICollection<PortDirection>* BDAQCALL getPortDirection() = 0; }; class DiFeatures : public DioFeatures { public: virtual ICollection<uint8>* BDAQCALL getDataMask() = 0; // di noise filter features virtual bool BDAQCALL getNoiseFilterSupported() = 0; virtual ICollection<uint8>* BDAQCALL getNoiseFilterOfChannels() = 0; virtual MathInterval BDAQCALL getNoiseFilterBlockTimeRange() = 0; // di interrupt features virtual bool BDAQCALL getDiintSupported() = 0; virtual bool BDAQCALL getDiintGateSupported() = 0; virtual bool BDAQCALL getDiCosintSupported() = 0; virtual bool BDAQCALL getDiPmintSupported() = 0; virtual ICollection<ActiveSignal>* BDAQCALL getDiintTriggerEdges() = 0; virtual ICollection<uint8>* BDAQCALL getDiintOfChannels() = 0; virtual ICollection<uint8>* BDAQCALL getDiintGateOfChannels() = 0; virtual ICollection<uint8>* BDAQCALL getDiCosintOfPorts() = 0; virtual ICollection<uint8>* BDAQCALL getDiPmintOfPorts() = 0; virtual ICollection<int32>* BDAQCALL getSnapEventSources() = 0; // buffered di->basic features virtual bool BDAQCALL getBufferedDiSupported() = 0; virtual SamplingMethod BDAQCALL getSamplingMethod() = 0; // buffered di->conversion clock features virtual ICollection<SignalDrop>* BDAQCALL getConvertClockSources() = 0; virtual MathInterval BDAQCALL getConvertClockRange() = 0; // buffered di->burst scan virtual bool BDAQCALL getBurstScanSupported() = 0; virtual ICollection<SignalDrop>* BDAQCALL getScanClockSources() = 0; virtual MathInterval BDAQCALL getScanClockRange() = 0; virtual int32 BDAQCALL getScanCountMax() = 0; // buffered di->trigger features virtual bool BDAQCALL getTriggerSupported() = 0; virtual int32 BDAQCALL getTriggerCount() = 0; virtual ICollection<SignalDrop>* BDAQCALL getTriggerSources() = 0; virtual ICollection<TriggerAction>* BDAQCALL getTriggerActions() = 0; virtual MathInterval BDAQCALL getTriggerDelayRange() = 0; }; class DiCtrlBase : public DioCtrlBase { public: virtual DiFeatures* BDAQCALL getFeatures() = 0; virtual ICollection<NoiseFilterChannel>* BDAQCALL getNoiseFilter() = 0; }; class DiSnapEventListener { public: virtual void BDAQCALL DiSnapEvent(void * sender, DiSnapEventArgs * args) = 0; }; class InstantDiCtrl : public DiCtrlBase { public: // event virtual void BDAQCALL addInterruptListener(DiSnapEventListener & listener) = 0; virtual void BDAQCALL removeInterruptListener(DiSnapEventListener & listener) = 0; virtual void BDAQCALL addChangeOfStateListener(DiSnapEventListener & listener) = 0; virtual void BDAQCALL removeChangeOfStateListener(DiSnapEventListener & listener) = 0; virtual void BDAQCALL addPatternMatchListener(DiSnapEventListener & listener) = 0; virtual void BDAQCALL removePatternMatchListener(DiSnapEventListener & listener) = 0; // method virtual ErrorCode BDAQCALL ReadAny(int32 portStart, int32 portCount, uint8 data[]) = 0; virtual ErrorCode BDAQCALL SnapStart() = 0; virtual ErrorCode BDAQCALL SnapStop() = 0; // property virtual ICollection<DiintChannel>* BDAQCALL getDiintChannels() = 0; virtual ICollection<DiCosintPort>* BDAQCALL getDiCosintPorts() = 0; virtual ICollection<DiPmintPort>* BDAQCALL getDiPmintPorts() = 0; // helpers ErrorCode BDAQCALL Read(int32 port, uint8 & data) { return ReadAny(port, 1, &data); } ErrorCode BDAQCALL Read(int32 portStart, int32 portCount, uint8 data[]) { return ReadAny(portStart, portCount, data); } }; class BfdDiEventListener { public: virtual void BDAQCALL BfdDiEvent(void * sender, BfdDiEventArgs * args) = 0; }; class BufferedDiCtrl : public DiCtrlBase { public: // event virtual void BDAQCALL addDataReadyListener(BfdDiEventListener & listener) = 0; virtual void BDAQCALL removeDataReadyListener(BfdDiEventListener & listener) = 0; virtual void BDAQCALL addOverrunListener(BfdDiEventListener & listener) = 0; virtual void BDAQCALL removeOverrunListener(BfdDiEventListener & listener) = 0; virtual void BDAQCALL addCacheOverflowListener(BfdDiEventListener & listener) = 0; virtual void BDAQCALL removeCacheOverflowListener(BfdDiEventListener & listener) = 0; virtual void BDAQCALL addStoppedListener(BfdDiEventListener & listener) = 0; virtual void BDAQCALL removeStoppedListener(BfdDiEventListener & listener) = 0; // method virtual ErrorCode BDAQCALL Prepare() = 0; virtual ErrorCode BDAQCALL RunOnce() = 0; virtual ErrorCode BDAQCALL Start() = 0; virtual ErrorCode BDAQCALL Stop() = 0; virtual ErrorCode BDAQCALL GetData(int32 count, uint8 data[]) = 0; virtual void BDAQCALL Release() = 0; // property virtual void* BDAQCALL getBuffer() = 0; virtual int32 BDAQCALL getBufferCapacity() = 0; virtual ControlState BDAQCALL getState() = 0; virtual ScanPort* BDAQCALL getScanPort() = 0; virtual ConvertClock* BDAQCALL getConvertClock() = 0; virtual ScanClock* BDAQCALL getScanClock() = 0; virtual Trigger* BDAQCALL getTrigger() = 0; virtual bool BDAQCALL getStreaming() = 0; virtual ErrorCode BDAQCALL setStreaming(bool value) = 0; }; class DoFeatures : public DioFeatures { public: virtual ICollection<uint8>* BDAQCALL getDataMask() = 0; // do freeze features virtual ICollection<SignalDrop>* BDAQCALL getDoFreezeSignalSources() = 0; // do reflect Wdt features virtual MathInterval BDAQCALL getDoReflectWdtFeedIntervalRange() = 0; // buffered do->basic features virtual bool BDAQCALL getBufferedDoSupported() = 0; virtual SamplingMethod BDAQCALL getSamplingMethod() = 0; // buffered do->conversion clock features virtual ICollection<SignalDrop>* BDAQCALL getConvertClockSources() = 0; virtual MathInterval BDAQCALL getConvertClockRange() = 0; // buffered do->burst scan virtual bool BDAQCALL getBurstScanSupported() = 0; virtual ICollection<SignalDrop>* BDAQCALL getScanClockSources() = 0; virtual MathInterval BDAQCALL getScanClockRange() = 0; virtual int32 BDAQCALL getScanCountMax() = 0; // buffered do->trigger features virtual bool BDAQCALL getTriggerSupported() = 0; virtual int32 BDAQCALL getTriggerCount() = 0; virtual ICollection<SignalDrop>* BDAQCALL getTriggerSources() = 0; virtual ICollection<TriggerAction>* BDAQCALL getTriggerActions() = 0; virtual MathInterval BDAQCALL getTriggerDelayRange() = 0; }; class DoCtrlBase : public DioCtrlBase { public: virtual DoFeatures* BDAQCALL getFeatures() = 0; }; class InstantDoCtrl : public DoCtrlBase { public: // method virtual ErrorCode BDAQCALL WriteAny(int32 portStart, int32 portCount, uint8 data[]) = 0; virtual ErrorCode BDAQCALL ReadAny(int32 portStart, int32 portCount, uint8 data[]) = 0; // helpers ErrorCode BDAQCALL Write(int32 port, uint8 data) { return WriteAny(port, 1, &data); } ErrorCode BDAQCALL Write(int32 portStart, int32 portCount, uint8 data[]) { return WriteAny(portStart, portCount, data); } ErrorCode BDAQCALL Read(int32 port, uint8 &data) { return ReadAny(port, 1, &data); } ErrorCode BDAQCALL Read(int32 portStart, int32 portCount, uint8 data[]) { return ReadAny(portStart, portCount, data); } }; class BfdDoEventListener { public: virtual void BDAQCALL BfdDoEvent(void * sender, BfdDoEventArgs * args) = 0; }; class BufferedDoCtrl : public DoCtrlBase { public: // event virtual void BDAQCALL addDataTransmittedListener(BfdDoEventListener & listener) = 0; virtual void BDAQCALL removeDataTransmittedListener(BfdDoEventListener & listener) = 0; virtual void BDAQCALL addUnderrunListener(BfdDoEventListener & listener) = 0; virtual void BDAQCALL removeUnderrunListener(BfdDoEventListener & listener) = 0; virtual void BDAQCALL addCacheEmptiedListener(BfdDoEventListener & listener) = 0; virtual void BDAQCALL removeCacheEmptiedListener(BfdDoEventListener & listener) = 0; virtual void BDAQCALL addTransitStoppedListener(BfdDoEventListener & listener) = 0; virtual void BDAQCALL removeTransitStoppedListener(BfdDoEventListener & listener) = 0; virtual void BDAQCALL addStoppedListener(BfdDoEventListener & listener) = 0; virtual void BDAQCALL removeStoppedListener(BfdDoEventListener & listener) = 0; // method virtual ErrorCode BDAQCALL Prepare() = 0; virtual ErrorCode BDAQCALL RunOnce() = 0; virtual ErrorCode BDAQCALL Start() = 0; virtual ErrorCode BDAQCALL Stop(int32 action) = 0; virtual ErrorCode BDAQCALL SetData(int32 count, uint8 data[]) = 0; virtual void BDAQCALL Release() = 0; // property virtual void* BDAQCALL getBuffer() = 0; virtual int32 BDAQCALL getBufferCapacity() = 0; virtual ControlState BDAQCALL getState() = 0; virtual ScanPort* BDAQCALL getScanPort() = 0; virtual ConvertClock* BDAQCALL getConvertClock() = 0; virtual Trigger* BDAQCALL getTrigger() = 0; virtual bool BDAQCALL getStreaming() = 0; virtual ErrorCode BDAQCALL setStreaming(bool value) = 0; }; // ---------------------------------------------------------- // Counter related classes // ---------------------------------------------------------- class CntrEventListener { public: virtual void BDAQCALL CntrEvent(void * sender, CntrEventArgs * args) = 0; }; class CounterCapabilityIndexer { public: virtual void BDAQCALL Dispose() = 0; // destroy the instance virtual int32 BDAQCALL getCount() = 0; virtual ICollection<CounterCapability>* BDAQCALL getItem(int32 channel) = 0; }; class CntrFeatures { public: // channel features virtual int32 BDAQCALL getChannelCountMax() = 0; virtual int32 BDAQCALL getResolution() = 0; virtual int32 BDAQCALL getDataSize() = 0; virtual CounterCapabilityIndexer* BDAQCALL getCapabilities() = 0; }; class CntrFeaturesExt { public: // noise filter features virtual bool BDAQCALL getNoiseFilterSupported() = 0; virtual ICollection<uint8>* BDAQCALL getNoiseFilterOfChannels() = 0; virtual MathInterval BDAQCALL getNoiseFilterBlockTimeRange() = 0; }; class CntrCtrlExt { public: virtual NoiseFilterChannel* BDAQCALL getNoiseFilter() = 0; }; class CntrCtrlBase : public DeviceCtrlBase, public CntrCtrlExt { public: // property virtual int32 BDAQCALL getChannel() = 0; virtual ErrorCode BDAQCALL setChannel(int32 ch) = 0; virtual bool BDAQCALL getEnabled() = 0; virtual ErrorCode BDAQCALL setEnabled(bool enabled) = 0; virtual bool BDAQCALL getRunning() = 0; }; class EventCounterFeatures : public CntrFeatures, public CntrFeaturesExt { // No any other features at present for event counting. }; class EventCounterCtrl : public CntrCtrlBase { public: // property virtual EventCounterFeatures* BDAQCALL getFeatures() = 0; virtual int32 BDAQCALL getValue() = 0; }; class FreqMeterFeatures : public CntrFeatures, public CntrFeaturesExt { public: virtual ICollection<FreqMeasureMethod>* BDAQCALL getFmMethods() = 0; }; class FreqMeterCtrl : public CntrCtrlBase { public: // property virtual FreqMeterFeatures* BDAQCALL getFeatures() = 0; virtual double BDAQCALL getValue() = 0; virtual FreqMeasureMethod BDAQCALL getMethod() = 0; virtual ErrorCode BDAQCALL setMethod(FreqMeasureMethod value) = 0; virtual double BDAQCALL getCollectionPeriod() = 0; virtual ErrorCode BDAQCALL setCollectionPeriod(double value) = 0; }; class OneShotFeatures : public CntrFeatures, public CntrFeaturesExt { public: virtual bool BDAQCALL getOneShotEventSupported() = 0; virtual MathInterval BDAQCALL getDelayCountRange() = 0; }; class OneShotCtrl : public CntrCtrlBase { public: // event virtual void BDAQCALL addOneShotListener(CntrEventListener & listener) = 0; virtual void BDAQCALL removeOneShotListener(CntrEventListener & listener) = 0; // property virtual OneShotFeatures* BDAQCALL getFeatures() = 0; virtual int32 BDAQCALL getDelayCount() = 0; virtual ErrorCode BDAQCALL setDelayCount(int32 value) = 0; }; class TimerPulseFeatures : public CntrFeatures, public CntrFeaturesExt { public: virtual MathInterval BDAQCALL getTimerFrequencyRange() = 0; virtual bool BDAQCALL getTimerEventSupported() = 0; }; class TimerPulseCtrl : public CntrCtrlBase { public: // event virtual void BDAQCALL addTimerTickListener(CntrEventListener & listener) = 0; virtual void BDAQCALL removeTimerTickListener(CntrEventListener & listener) = 0; // property virtual TimerPulseFeatures* BDAQCALL getFeatures() = 0; virtual double BDAQCALL getFrequency() = 0; virtual ErrorCode BDAQCALL setFrequency(double value) = 0; }; class PwMeterFeatures : public CntrFeatures, public CntrFeaturesExt { public: virtual ICollection<CounterCascadeGroup>* BDAQCALL getPwmCascadeGroup() = 0; virtual bool BDAQCALL getOverflowEventSupported() = 0; }; class PwMeterCtrl : public CntrCtrlBase { public: // event virtual void BDAQCALL addOverflowListener(CntrEventListener & listener) = 0; virtual void BDAQCALL removeOverflowListener(CntrEventListener & listener) = 0; // property virtual PwMeterFeatures* BDAQCALL getFeatures() = 0; virtual void BDAQCALL getValue(PulseWidth &width) = 0; }; class PwModulatorFeatures : public CntrFeatures, public CntrFeaturesExt { public: virtual MathInterval BDAQCALL getHiPeriodRange() = 0; virtual MathInterval BDAQCALL getLoPeriodRange() = 0; }; class PwModulatorCtrl : public CntrCtrlBase { public: // property virtual PwModulatorFeatures* BDAQCALL getFeatures() = 0; virtual void BDAQCALL getPulseWidth(PulseWidth &width) = 0; virtual ErrorCode BDAQCALL setPulseWidth(PulseWidth const &width) = 0; }; class UdCounterFeatures : public CntrFeatures, public CntrFeaturesExt { public: virtual ICollection<SignalCountingType>* BDAQCALL getCountingTypes() = 0; virtual ICollection<int32>* BDAQCALL getInitailValues() = 0; virtual ICollection<int32>* BDAQCALL getSnapEventSources() = 0; }; class UdCntrEventListener { public: virtual void BDAQCALL UdCntrEvent(void * sender, UdCntrEventArgs * args) = 0; }; class UdCounterCtrl : public CntrCtrlBase { public: // event virtual void BDAQCALL addUdCntrEventListener(UdCntrEventListener &listener) = 0; virtual void BDAQCALL removeUdCntrEventListener(UdCntrEventListener &listener) = 0; // method virtual ErrorCode BDAQCALL SnapStart(int32 srcId) = 0; virtual ErrorCode BDAQCALL SnapStop(int32 srcId) = 0; virtual ErrorCode BDAQCALL CompareSetTable(int32 count, int32 *table) = 0; virtual ErrorCode BDAQCALL CompareSetInterval(int32 start, int32 increment,int32 count) = 0; virtual ErrorCode BDAQCALL CompareClear() = 0; virtual ErrorCode BDAQCALL ValueReset() = 0; // property virtual UdCounterFeatures* BDAQCALL getFeatures() = 0; virtual int32 BDAQCALL getValue() = 0; virtual SignalCountingType BDAQCALL getCountingType() = 0; virtual ErrorCode BDAQCALL setCountingType(SignalCountingType value) = 0; virtual int32 BDAQCALL getInitialValue() = 0; virtual ErrorCode BDAQCALL setInitialValue(int32 value) = 0; virtual int32 BDAQCALL getResetTimesByIndex() = 0; virtual ErrorCode BDAQCALL setResetTimesByIndex(int32 value) = 0; }; END_NAMEAPCE_AUTOMATION_BDAQ #endif // _BDAQ_COM_LIKE_CLASS_LIB
C++
CL
bbb8dc016ff3eca872909676e07a25af76326e3b85bff5e3590f83199feb2710
//question link http://www.spoj.com/problems/PALIN/ /* * If the input comprises of all 9's then the answer is 1 followed by n-1 0's * * and then 1 (here n is the number of digits in the given number * * For other cases the documentation with the code does the explanation * */ #include <bits/stdc++.h> using namespace std; #define f(q, a, b) for(int q = int(a); q<int(b); q++) #define fb(q, a, b) for(int q = int(a); q>int(b); q--) #define pb(v, x) v.push_back(x) #define A first #define B second typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef pair<int, int> pii; typedef map<int, int> mii; //ifstream in("input"); //ofstream out("output"); int main() { //reading input int t; cin>>t; while(t--){ //since input size is large it is read as a string and then converted to number string s; cin>>s; int num[1000010], n = s.size(); //boolean variable for checking the all digits as 9 case bool all9 = true; f(q, 0, n){ num[q] = int(s[q]) - int('0'); if(all9 && num[q]!=9) all9 = false; } //dealing with the all 9's scenario if(all9){ cout<<"1"; f(q, 0, n){ if(q==n-1) cout<<"1"; else cout<<"0"; } cout<<endl; continue; } /* * now the number is split into two halves, 123 has 1 and 3 as two halves and 1234 has 12 and 34 * * similarly the mid is comprised of 2 in 123 and 23 in 1234. Following this scenario three * * conditions arise: * 1. The number is palindrome * 2. The left half can be copied to right half and problem is complete * 3. The left half is copied to the right half but the resulting number is smaller than original* * For cases 1 and 3 we will need to increment the mid, if mid is 9 then the increment will have * * to be cascaded futher down; in all 3 cases we first create a mirror of the left half in the * * right half and then proceed for further computation. * */ //finding the left half and right half int mid = n/2, left = mid-1; int right = n%2? mid+1: mid; bool increment = false; //if the number is a palindrome case is checked here while(left>-1 && num[left]==num[right]){ left--; right++; } /* * if left<0 it means we have scanned the whole array and the two halves were equal meaning the * * number is a palindrome, otherwise we check if the left half is smaller, which corresponds to * * case 3, either of these two will mean that we need to increment the mid hence the boolean * * variable increment is set to true if either one of them is true * */ if(left<0 || num[left]<num[right]) increment = true; //copy the left half to the right half while(left>=0) num[right++] = num[left--]; //case 1 and 3 are handled here if(increment){ int add = 1; left = mid-1; //if the number of digits is odd if(n%2!=0){ num[mid]+=add; //add will be 1 if num[mid] was 9 otherwise no cascading required add = num[mid]/10; //if num[mid] was 9 this step will make it 0 after incrementation num[mid]%=10; right = mid+1; } else right = mid; //cascade the effect of incrementing mid, note that this only takes place if mid is comprised of 9 or 99 //same logic as above is carried out here while(left>=0){ num[left]+=add; add = num[left]/10; num[left]%=10; num[right++] = num[left--]; } } //displaying the output f(q, 0, n) cout<<num[q]; cout<<endl; } }
C++
CL
497654e6cdd9b812b6ec6c86e18676a8ca70116751b0ff80870081e857687117
/* * Warhammer Age of Sigmar battle simulator. * * Copyright (C) 2019 by Rick Weyrauch - rpweyrauch@gmail.com * * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) */ #ifndef SKARBRAND_H #define SKARBRAND_H #include <Unit.h> #include <Weapon.h> namespace Khorne { class Skarbrand : public Unit { public: static const int BASESIZE = 100; static const int WOUNDS = 14; static const int POINTS_PER_UNIT = 400; static Unit* Create(const ParameterList& parameters); static void Init(); Skarbrand(); ~Skarbrand() override = default; bool configure(); void visitWeapons(std::function<void(const Weapon*)>& visitor) override; enum Rage { Angry = 0, Furious, Seething, Enraged, Incandescent }; protected: int getDamageTableIndex() const; void onWounded() override; private: Rage m_rageLevel = Angry; Weapon m_slaughter, m_carnage; static bool s_registered; }; // // TODO: abilities // Abilities Implemented // ------------------------------------------- // Skarbrand's Rage No // Roar of Total Rage No // Total Carnage No // } // namespace Khorne #endif //SKARBRAND_H
C++
CL
4b970786e1f1ce72fe5e4e41a2f6a35804496507d22c0d149fe72e741c7a3e20
/////////////////////////////////////////////////////////////////////////////// // Application : MoleSVN // Package : UI // File : RenameWindow.h // Description : defines window which will display Rename parameters, like // URL repository, revision // Author : cedric.bresson@artcoder.com /////////////////////////////////////////////////////////////////////////////// #ifndef __RenameWindow_h__ #define __RenameWindow_h__ #include "../Config.h" #include "../Svn/SvnCommands.h" class RenameWindow : public BWindow { public: // -- Life-cycle ---------------------------------------------------------- RenameWindow(Rename* pCmd); // Description : constructor virtual ~RenameWindow(); // Description : destructor // -- Hooks --------------------------------------------------------------- virtual void MessageReceived(BMessage *message); private: void CreateView(); // Description : build UI bool CheckParameters(); // Description : returns true if the Rename parameters entered by the // user are valid. std::string m_strOldName; // Description : name to rename BTextControl* m_pRename; Rename* m_pCmd; }; #endif //__RenameWindow_h__
C++
CL
dc4debda9f9f8bad6a7167de6a7abc9284ce58acc2071f4fd81c8aad25faa80e
#include "erhe_physics/bullet/bullet_uniform_scaling_shape.hpp" #include <BulletCollision/CollisionShapes/btUniformScalingShape.h> namespace erhe::physics { auto ICollision_shape::create_uniform_scaling_shape( ICollision_shape* shape, const float scale ) -> ICollision_shape* { return new Bullet_uniform_scaling_shape(shape, scale); } auto ICollision_shape::create_uniform_scaling_shape_shared( ICollision_shape* shape, const float scale ) -> std::shared_ptr<ICollision_shape> { return std::make_shared<Bullet_uniform_scaling_shape>(shape, scale); } Bullet_uniform_scaling_shape::Bullet_uniform_scaling_shape( ICollision_shape* shape, const float scale ) : Bullet_collision_shape{&m_uniform_scaling_shape} , m_uniform_scaling_shape{ static_cast<btConvexShape*>( reinterpret_cast<Bullet_collision_shape*>(shape)->get_bullet_collision_shape() ), scale } { } } // namespace erhe::physics
C++
CL
c1a81008d057420dba348ea8178767b4b5f86c0882fd1bc78aa106c436b346c2
#pragma once #include <unordered_map> #include <map> #include <string> #include <vector> #include <iostream> #include "glm/glm.hpp" #include "include.h" #include "input.h" //Included bellow //#include "inputdata.h" //Forward declaration namespace Tea { class InputManager { public: /* "InputManager" handles all input events and changes them to bools stored in a special kind of input. These can be accessed via getInput() which returns the appropriate data. Each input has a name and that name is used to get relevent information about it. Multiple keys can have the same name and will have shared data. But a single key CANNOT have multiple names. */ // Updates the input, this progresses inputs from // pressed to down and sutch static void update(); // Returns true if it can read it, false otherwise static bool readInputMap(const std::string& path = "input.map"); // Saves the input map to disk as the specified file static bool writeInputMap(const std::string& path = ""); // Returns the mouse position static glm::vec2 getMousePos() { return _mousePos; } // Returns information associated to a input name static float getInput(const std::string& name) { return _inputData[name]; } // Gets the name for the specified key // (Note: Internally the engine keeps track of they // keys, which are determined by they keys. // It is not recomented to use this for user input.) static std::string getName(const std::string& key) { return _inputMap[key]; } // Checks if a named input has the specified state, it's // a replacement for writing it in an if statement. static bool hasInputState(const std::string& name, InputState state) { return getInput(name) == state; } // Adds a named input which the specified information static void addInput(unsigned int device, unsigned int button, unsigned int mods, unsigned int axis, const std::string& name); // A wrapper for the other function which takes "Input" // instead of constructing it static void addInput(Input data, const std::string& name = 0); private: // All these functions are to make the code more readable // they are all part of handleing events but split up // to move things out of the switch statement that is // allready to big to be easily read static void keyEvent(InputType type, unsigned int key, unsigned int mods); static void mouseEvent(InputType type, unsigned int button); static void controllerEvent(InputType type, unsigned int which, unsigned int button = -1); static void mouseMove(float x, float y); static void axisEvent(unsigned int which, unsigned int axis, short value); // The path that the input.map was read from. static std::string _path; // A hashmap to hold all the inputs. // Each raw input has a translation into a input name. // <device:axis:button:mods> <name> static std::unordered_map<std::string, std::string> _inputMap; // Each input name is linked to a float. (To support axies on controllers via the same interface) // <name> <value> static std::unordered_map<std::string, float> _inputData; // Mouse position, I know, who would have figured? static glm::vec2 _mousePos; // If there are any controllers connnected, they are handled here // The engine does some interesting things with slotting controllers // in in this list where they fit static std::vector<SDL_GameController*> _controllers; // A map that maps each controller to an ID, and reuses them. static std::vector<short> _controllerMap; }; }
C++
CL
fa66994f2324e26fbe999dcb38b0745092148df1c56641be7bd420843c45d51e
/* * 2015_Canyon_Rescue_Robotics.ino * * Created on: Apr 10, 2015 * Author: Seth Itow */ #include "config.h" #include <SPI.h> #include <WiFi.h> #include <SoftwareSerial.h> #include <HardwareSerial.h> #include <Adafruit_GPS.h> #include <Servo.h> #include <PID_v1.h> #include <SD.h> #include <Adafruit_VC0706.h> #include "RelativePositionController.h" #include "FlightController.h" #include "VictimLoggerController.h" bool usingInterrupt = true; //configuration flag for GPS library SoftwareSerial gpsSerial(GPS_SERIAL_RX_PIN,GPS_SERIAL_TX_PIN); //Rx pin, Tx pin Adafruit_GPS GPS(&gpsSerial); //Instantiate GPS library object RelativePositionController relativePosition;// = new RelativePositionController(); //Instantiate relative position controller FlightController flight(&relativePosition); //Instantiate flight controller VictimLoggerController victimLogger(&relativePosition); //state machine state enumeration enum FlightModeEnum {WAIT_FOR_TRIGGER, ARM,TAKE_OFF, FLY_TO_BUCKET,RECORD_PHOTO_AND_COORDINATES, SET_NEXT_BUCKET,RETURN_TO_CENTER, LAND,DISARM, EMERGENCY_STOP}; FlightModeEnum flightMode = WAIT_FOR_TRIGGER; // set initial state //variables for bucket coordinate calculation extern int bucketIndex = 0; //declared in VictimLoggerController double bucketPolarTheta = 0; double bucketPolarRadius = 10; double targetBucketX; double targetBucketY; void setup() { //set up serial debugging Serial.begin(9600); //inialize GPS GPS.begin(9600); GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA); GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); //set home position for relative calculations relativePosition.setHomePosition(GPS.latitude,GPS.longitude, GPS.altitude); } // Special timer stuff for GPS library SIGNAL(TIMER0_COMPA_vect) { char c = GPS.read(); } void useInterrupt(boolean v) { if (v) { // Timer0 is already used for millis() - we'll just interrupt somewhere // in the middle and call the "Compare A" function above OCR0A = 0xAF; TIMSK0 |= _BV(OCIE0A); usingInterrupt = true; } else { // do not call the interrupt function COMPA anymore TIMSK0 &= ~_BV(OCIE0A); usingInterrupt = false; } } uint32_t timer = millis(); //timer requred for GPS library // The loop function is called in an endless loop void loop() { // ---------- Update GPS object if (GPS.newNMEAreceived()) { if (!GPS.parse(GPS.lastNMEA())) // this also sets the newNMEAreceived() flag to false return; // we can fail to parse a sentence in which case we should just wait for another } if (timer > millis()) timer = millis(); // ---------- Update Relative position relativePosition.updateRelativePosition(GPS.latitudeDegrees,GPS.longitudeDegrees,GPS.altitude); // ---------- Beginning of state machine switch(flightMode) { case WAIT_FOR_TRIGGER: if(digitalRead(AUTOPILOT_ACTIVE)){ flightMode = ARM; } break; case ARM: flight.arm(); delay(5000); //delay for 5 seconds flightMode = TAKE_OFF; //go to next state break; case TAKE_OFF: if(abs(flight.goToAltitude(SEARCH_ALTITUDE))<Z_MAX_ERROR){ flightMode=SET_NEXT_BUCKET; } else{ //do nothing } break; case SET_NEXT_BUCKET: //8 buckets around each ring, 45 degrees apart //4 rings, 10 feet apart. //first bucket shall be to the right bucketIndex++; bucketPolarTheta = 45 * (bucketIndex-1)%9; if(bucketPolarTheta==0){ bucketPolarRadius = bucketPolarRadius+10; } if(bucketPolarRadius == 50){ flightMode = RETURN_TO_CENTER; break; } targetBucketX = bucketPolarRadius * cos(bucketPolarTheta); targetBucketY = bucketPolarRadius * sin(bucketPolarTheta); flightMode = FLY_TO_BUCKET; break; case FLY_TO_BUCKET: if(abs(flight.goToPosition(targetBucketX,targetBucketY))<XY_MAX_ERROR){ flightMode=RECORD_PHOTO_AND_COORDINATES; } else{ //do nothing } break; case RECORD_PHOTO_AND_COORDINATES: //magic happnens flightMode = SET_NEXT_BUCKET; break; case RETURN_TO_CENTER: if(abs(flight.goToPosition(0,0))<XY_MAX_ERROR){ flightMode=LAND; } else{ //do nothing } break; case LAND: if(abs(flight.goToAltitude(0))<Z_MAX_ERROR){ flightMode=SET_NEXT_BUCKET; } else{ //do nothing } break; case DISARM: flight.disarm(); delay(5000); //delay for 5 seconds flightMode = EMERGENCY_STOP; //go to next state break; case EMERGENCY_STOP: //do nothing break; } }
C++
CL
35cc1a9087c8726e318b5bbfbb14460a665b5bd568370480fd01874fee440dae
// // Created by cecix on 18/05/19. // #include <string> #include <Box2D/Collision/Shapes/b2PolygonShape.h> #include <Box2D/Dynamics/b2Fixture.h> #include <Box2D/Dynamics/b2World.h> #include <iostream> #include "Chell.h" #include "movements/MoveRight.h" #include "movements/Stop.h" #include "movements/MoveLeft.h" #include "../../editor/stage/object/Chell.h" #include "Rock.h" #include "MetalBlock.h" #include "DiagonalMetalBlock.h" #include "BlueShot.h" #include "EnergyBall.h" #include "Button.h" #include "EnergyBar.h" #include "OrangeShot.h" Chell::Chell(b2Body* body): Entity(CHELL_NAME, body), dynamic(body) { this->actual_movement = new Stop(body); this->actual_state = IDLE; body->SetUserData(this); chell_is_on_floor = true; dead = false; rock = nullptr; orange_portal = nullptr; blue_portal = nullptr; blue_portal_to_teleport = nullptr; orange_portal_to_teleport = nullptr; winner = false; pintool = nullptr; //Setting the category and mask bits b2Fixture* fixture = body->GetFixtureList(); b2Filter filter = fixture->GetFilterData(); filter.categoryBits = 0x0011; filter.maskBits = 0xFF0F; fixture->SetFilterData(filter); } void Chell::handleCollision(Entity* entity) { const std::string& type = entity->getType(); if (type == ACID_NAME || type == EB_NAME) { die(); if (type == EB_NAME) { dynamic_cast<EnergyBall*>(entity)->die(); } } if (type == ROCK_NAME) { Rock* rock = dynamic_cast<Rock*>(entity); float y_chell = getVerticalPosition(); float y_rock = rock->getVerticalPosition(); float vy_rock = rock->getVerticalVelocity(); if (y_rock > y_chell && vy_rock == 0 && ! rock->isGrabbed()) { die(); } } if (type == PORTAL_NAME) { Portal* portal = dynamic_cast<Portal*>(entity); Coordinate* target = portal->getTarget(); if (target != nullptr) teleport(target, portal->getPortalType()); } if (type == CAKE_NAME) { win(); } if (type == BUTTON_NAME) { Button* button = dynamic_cast<Button*>(entity); float y_button = button->getVerticalPosition(); float y_chell = getVerticalPosition(); if (y_chell > y_button) button->activate(); } if (type == BLUE_SHOT_NAME) { dynamic_cast<BlueShot*>(entity)->die(); } if (type == ORANGE_SHOT_NAME) { dynamic_cast<OrangeShot*>(entity)->die(); } chell_is_on_floor = type == METAL_BLOCK_NAME || type == ROCK_BLOCK_NAME || type == DIAGONAL_METAL_BLOCK_NAME || type == FLOOR_NAME || type == ROCK_NAME || type == BUTTON_NAME || type == ET_NAME || type == ER_NAME; } void Chell::teleport(Coordinate* coordinate, Direction type) { this->dynamic.teleport(coordinate, type, false); } void Chell::die() { this->actual_state = DEAD; dead = true; } void Chell::win() { this->actual_state = WINNER; winner = true; } bool Chell::isDead() { return dead; } bool Chell::hasWon() { return winner; } void Chell::grabRock(Rock* rock) { if (this->rock || rock == nullptr) return; Coordinate coord(getHorizontalPosition(), getVerticalPosition()); rock->elevate(coord); this->rock = rock; } void Chell::downloadRock() { if (! rock) return; rock->downloadToEarth(); rock = nullptr; } void Chell::onFloor(bool onFloor) { chell_is_on_floor = onFloor; } void Chell::moveRight() { if (dead || winner) return; destroyActualMovement(); this->actual_movement = new MoveRight(body); if (chell_is_on_floor) this->actual_state = MOVING_RIGHT; if (this->rock != nullptr) { Coordinate coord(getHorizontalPosition(), getVerticalPosition()); rock->moveRight(coord); } } void Chell::moveLeft() { if (dead || winner) return; destroyActualMovement(); this->actual_movement = new MoveLeft(body); if (chell_is_on_floor) this->actual_state = MOVING_LEFT; if (this->rock != nullptr) { Coordinate coord(getHorizontalPosition(), getVerticalPosition()); rock->moveLeft(coord); } } void Chell::releaseRock() { if (rock == nullptr) return; rock->release(); rock = nullptr; } void Chell::stop() { if (dead || winner) return; destroyActualMovement(); this->actual_movement = new Stop(body); if (! chell_is_on_floor) { this->actual_state = JUMPING; } else { this->actual_state = IDLE; body->SetLinearVelocity(b2Vec2(0, 0)); } if (this->rock) rock->stop(); } void Chell::destroyActualMovement() { delete this->actual_movement; } void Chell::update() { chell_is_on_floor = inGround(); if (chell_is_on_floor && actual_state == JUMPING){ this->stop(); } if (chell_is_on_floor && ! isDead()) this->dynamic.handleCollisions(); this->actual_movement->move(gameConfiguration.chellForce); } void Chell::jump() { if (dead || winner) return; bool resul = this->dynamic.jump(chell_is_on_floor); if (resul) { actual_state = JUMPING; chell_is_on_floor = false; } } bool Chell::inGround() { float epsilon = pow(10, -7); bool chell_is_still = body->GetLinearVelocity().y < epsilon && body->GetLinearVelocity().y > -epsilon; if (chell_is_still) dynamic.handleCollisions(); return chell_is_on_floor; } ChellState Chell::getState() { return actual_state; } void Chell::removePortals() { delete blue_portal; delete blue_portal_to_teleport; delete orange_portal; delete orange_portal_to_teleport; this->blue_portal = nullptr; this->blue_portal_to_teleport = nullptr; this->orange_portal = nullptr; this->orange_portal_to_teleport = nullptr; } void Chell::addOrangePortal(PortalHolder* portal, Coordinate* to_teleport) { delete orange_portal; delete orange_portal_to_teleport; orange_portal = portal; orange_portal_to_teleport = to_teleport; } void Chell::addBluePortal(PortalHolder* portal, Coordinate* to_teleport) { delete blue_portal; delete blue_portal_to_teleport; blue_portal = portal; blue_portal_to_teleport = to_teleport; } PortalHolder* Chell::getBluePortal() { return blue_portal; } PortalHolder* Chell::getOrangePortal() { return orange_portal; } Coordinate* Chell::getBluePortalToTeleport() { return blue_portal_to_teleport; } Coordinate* Chell::getOrangePortalToTeleport() { return orange_portal_to_teleport; } void Chell::addPinTool(PinTool* pintool) { this->pintool = pintool; } PinTool* Chell::getPinTool() { return pintool; } Chell::~Chell() { destroyActualMovement(); delete orange_portal; delete blue_portal; delete orange_portal_to_teleport; delete blue_portal_to_teleport; }
C++
CL
8eb335c59cc7e55a30e759cf8b69fdf78ea8756c88fe9a8173de4879668f6505
/* Copyright (c) 2010, Matt Berger All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the University of Utah nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef RANGEIMAGE_HH #define RANGEIMAGE_HH #include "../modeling/Vector3.h" #include <string> #include <iostream> #include <stdio.h> using namespace std; class RangeImage { public: RangeImage(int _resX, int _resY); ~RangeImage(); bool isValidPoint(int _x, int _y); Vector3 getRangePoint(int _x, int _y); Vector3 getRangeNormal(int _x, int _y); void setRangePoint(int _x, int _y, Vector3 _point); void dump_to_ply(string _filename); int xRes(); int yRes(); private: int x_res, y_res; Vector3* all_points; bool* valid_hits; }; #endif
C++
CL
a5e040556f79851135b8f86b7acaa93cef5765cdc0706e960d68cf705e385bbe
/*Andres Gomez 2021*/ #include <Arduino.h> #include <stdint.h> #include "SCMD.h" //Librerias proporcionadas por el fabricante del componente de forma gratuita en la misma pagina de venta del mismo. #include "SCMD_config.h" #include "Wire.h" //Libreria incluida en Arduino para conexion I2C. #define LEDPIN PC13 //Se define la variable LEDPIN (Utilidad en el debugging). SCMD myMotorDriver; //Definicion de la variable myMotorDriver, de la classe SCMD definida por la libreria. SCMD myMotorDriver2; void setup() { Serial.begin(115200); //Inicializacion del bus serie. while(!Serial) { Serial.print("..."); //Espera hasta que se complete el proceso anterior. }; Serial.print("\n"); pinMode(LEDPIN, OUTPUT); delay(500); Serial.println("Starting sketch."); //Utilidad en el proceso del debugging. myMotorDriver.settings.commInterface = I2C_MODE; //Conexion del componente mediante I2C. myMotorDriver.settings.I2CAddress = 0x5D; //Definicion de la direccion I2C del esclavo. Esta depende del patron que muestra (por defecto o modificado) en su parte trasera. En este caso 1000 corresponde a 0x61. myMotorDriver2.settings.commInterface = I2C_MODE; //Conexion y definicion de la direccion del segundo driver. myMotorDriver2.settings.I2CAddress = 0x61; //Para 1100 delay(500); Wire.begin(); //Inicializacion del bus I2C. Serial.print("Read ID = 0x"); Serial.println(myMotorDriver.begin(), HEX); //Devuelve la ID del controlador, a la par que lo inicia. Serial.println(myMotorDriver2.begin(), HEX); //Devuelve la ID del controlador, a la par que lo inicia. while (myMotorDriver.begin() != 0xA9){ Serial.println("ID mismatch, trying again."); //Si la ID no coincide con 0xA9, se entrara en este bucle. Probablemente no se saldra de el sin arreglar previamente el hardware. delay(50); } while (myMotorDriver2.begin() != 0xA9){ Serial.println("ID mismatch, trying again."); //Si la ID no coincide con 0xA9, se entrara en este bucle. Probablemente no se saldra de el sin arreglar previamente el hardware. delay(50); } Serial.println("ID matches 0xA9"); Serial.println("Waiting for ready"); //Comentarios para ayudar en el debugging. while( myMotorDriver.ready() == false); //Bucle que obliga al componente a estar listo mediante la funcion ready() antes de seguir. while( myMotorDriver2.ready() == false); Serial.println("Done!"); while ( myMotorDriver.busy()); //Bucle similar al anterior, si no funciona la funcion busy() no se puede continuar. myMotorDriver.enable(); while ( myMotorDriver2.busy()); //Bucle similar al anterior, si no funciona la funcion busy() no se puede continuar. myMotorDriver2.enable(); Serial.println(); } void loop() { Serial.println("Now using the resistance."); digitalWrite(LEDPIN, 1); //El led se activa cuando gira en un sentido y se apaga cuando lo hace en el otro o simplemente no permite el paso de la corriente. Es una funcion meramente estetica y que pierde el sentido cuando se trabaja con mas de una carga. myMotorDriver2.setDrive(0, 1, 150); //Funciona igual que llamando al driver 1. El 0 es el A y el 1 el B. En contra de la informacion que puede leerse en la libreria, el valor del motor asignado es o 0 o 1, y no de 0 a 32. myMotorDriver.setDrive(1, 1, 120); delay(500); }
C++
CL
0ad09702205fc6f8507e00258937dbdb5ed845306ab7073b6dd660325a336ff0
#include <iostream> #include <unistd.h> #include <cstring> #include <csignal> #include <boost/program_options.hpp> #include <boost/filesystem/path.hpp> #include <boost/filesystem.hpp> #include "server.h" namespace po = boost::program_options; namespace fs = boost::filesystem; int main(int argc, char* argv[]) { fs::path data_path; po::options_description desc("Allowed options"); std::string addr; unsigned short port; desc.add_options() ("help,h", "produce help message") ("dir,d", po::value<fs::path>(&data_path), "path to data for server") ("addr,a", po::value<std::string>(&addr)->default_value("127.0.0.1"), "addr of server") ("port,p", po::value<unsigned short>(&port)->default_value(8081), "port for server"); po::variables_map vm; try { po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); } catch (std::exception) { std::cout << desc; return EXIT_FAILURE; } if (vm.count("help")) { std::cout << desc << std::endl; return EXIT_SUCCESS; } if (! vm.count("dir") || ! fs::is_directory(data_path)) { std::cerr << "Path must be specified" << std::endl; std::cout << desc << std::endl; return EXIT_FAILURE; } try { http_server::HttpServer server(addr, port, data_path); std::cout << "Start listen" << std::endl; server.StartListen(); std::string stop; while(stop != "stop"){ std::cin >> stop; } std::cout << "Stop listen" << std::endl; server.CloseServer(); } catch (const std::runtime_error& ex) { std::cerr << "Error when try start server: " << ex.what() << std::endl; } }
C++
CL
4dea9179e63ff2ea81b62a3c6e10f25766f4759e6ec77a29dc71079a0621ae66
// Copyright 2021 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "driver_loader.h" #include <fidl/fuchsia.io/cpp/wire.h> #include <lib/fdio/directory.h> #include <lib/fidl/llcpp/connect_service.h> #include <sched.h> #include <unistd.h> #include <zircon/threads.h> #include <thread> #include <variant> #include <fbl/unique_fd.h> #include "coordinator.h" #include "src/devices/bin/driver_manager/manifest_parser.h" #include "src/devices/lib/log/log.h" DriverLoader::~DriverLoader() { if (system_loading_thread_) { system_loading_thread_->join(); } } void DriverLoader::StartSystemLoadingThread(Coordinator* coordinator) { if (system_loading_thread_) { LOGF(ERROR, "DriverLoader: StartLoadingThread cannot be called twice!\n"); return; } system_loading_thread_ = std::thread([coordinator]() { fbl::unique_fd fd(open("/system", O_RDONLY)); if (fd.get() < 0) { LOGF(WARNING, "Unable to open '/system', system drivers are disabled"); return; } fbl::DoublyLinkedList<std::unique_ptr<Driver>> drivers; auto driver_added = [&drivers](Driver* drv, const char* version) { std::unique_ptr<Driver> driver(drv); LOGF(INFO, "Adding driver '%s' '%s'", driver->name.data(), driver->libname.data()); if (load_vmo(driver->libname.data(), &driver->dso_vmo)) { LOGF(ERROR, "Driver '%s' '%s' could not cache DSO", driver->name.data(), driver->libname.data()); } // De-prioritize drivers that are "fallback". if (driver->fallback) { drivers.push_back(std::move(driver)); } else { drivers.push_front(std::move(driver)); } }; find_loadable_drivers(coordinator->boot_args(), "/system/driver", driver_added); async::PostTask(coordinator->dispatcher(), [coordinator = coordinator, drivers = std::move(drivers)]() mutable { coordinator->AddAndBindDrivers(std::move(drivers)); coordinator->BindFallbackDrivers(); }); }); constexpr char name[] = "driver-loader-thread"; zx_object_set_property(native_thread_get_zx_handle(system_loading_thread_->native_handle()), ZX_PROP_NAME, name, sizeof(name)); } const Driver* DriverLoader::LibnameToDriver(std::string_view libname) const { for (const auto& drv : driver_index_drivers_) { if (libname.compare(drv.libname) == 0) { return &drv; } } return nullptr; } void DriverLoader::WaitForBaseDrivers(fit::callback<void()> callback) { // TODO(dgilhooley): Change this back to an ERROR once DriverIndex is used in all tests. if (!driver_index_.is_valid()) { LOGF(INFO, "%s: DriverIndex is not initialized", __func__); return; } driver_index_->WaitForBaseDrivers( [this, callback = std::move(callback)]( fidl::WireUnownedResult<fdf::DriverIndex::WaitForBaseDrivers>& result) mutable { if (!result.ok()) { // Since IsolatedDevmgr doesn't use the ComponentFramework, DriverIndex can be // closed before DriverManager during tests, which would mean we would see // a ZX_ERR_PEER_CLOSED. if (result.status() == ZX_ERR_PEER_CLOSED) { LOGF(WARNING, "Connection to DriverIndex closed during WaitForBaseDrivers."); } else { LOGF(ERROR, "Failed to connect to DriverIndex: %s", result.error().FormatDescription().c_str()); } return; } include_fallback_drivers_ = true; callback(); }); } const Driver* DriverLoader::LoadDriverUrl(const std::string& driver_url) { // Check if we've already loaded this driver. If we have then return it. auto driver = LibnameToDriver(driver_url); if (driver != nullptr) { return driver; } // We've never seen the driver before so add it, then return it. auto fetched_driver = base_resolver_->FetchDriver(driver_url); if (fetched_driver.is_error()) { LOGF(ERROR, "Error fetching driver: %s: %d", driver_url.data(), fetched_driver.error_value()); return nullptr; } driver_index_drivers_.push_back(std::move(fetched_driver.value())); return &driver_index_drivers_.back(); } bool DriverLoader::MatchesLibnameDriverIndex(const std::string& driver_url, std::string_view libname) { if (libname.compare(driver_url) == 0) { return true; } auto result = GetPathFromUrl(driver_url); if (result.is_error()) { return false; } return result.value().compare(libname) == 0; } std::vector<const Driver*> DriverLoader::MatchDeviceDriverIndex(const fbl::RefPtr<Device>& dev, const MatchDeviceConfig& config) { if (!driver_index_.is_valid()) { return std::vector<const Driver*>(); } bool autobind = config.libname.empty(); fidl::Arena allocator; auto& props = dev->props(); auto& str_props = dev->str_props(); fidl::VectorView<fdf::wire::NodeProperty> fidl_props(allocator, props.size() + str_props.size() + 2); size_t index = 0; fidl_props[index++] = fdf::wire::NodeProperty(allocator) .set_key(allocator, fdf::wire::NodePropertyKey::WithIntValue(BIND_PROTOCOL)) .set_value(allocator, fdf::wire::NodePropertyValue::WithIntValue(dev->protocol_id())); fidl_props[index++] = fdf::wire::NodeProperty(allocator) .set_key(allocator, fdf::wire::NodePropertyKey::WithIntValue(BIND_AUTOBIND)) .set_value(allocator, fdf::wire::NodePropertyValue::WithIntValue(autobind)); for (size_t i = 0; i < props.size(); i++) { fidl_props[index++] = fdf::wire::NodeProperty(allocator) .set_key(allocator, fdf::wire::NodePropertyKey::WithIntValue(props[i].id)) .set_value(allocator, fdf::wire::NodePropertyValue::WithIntValue(props[i].value)); } for (size_t i = 0; i < str_props.size(); i++) { auto prop = fdf::wire::NodeProperty(allocator).set_key( allocator, fdf::wire::NodePropertyKey::WithStringValue(allocator, allocator, str_props[i].key)); if (std::holds_alternative<uint32_t>(str_props[i].value)) { prop.set_value(allocator, fdf::wire::NodePropertyValue::WithIntValue( std::get<uint32_t>(str_props[i].value))); } else if (std::holds_alternative<std::string>(str_props[i].value)) { prop.set_value(allocator, fdf::wire::NodePropertyValue::WithStringValue( allocator, allocator, std::get<std::string>(str_props[i].value))); } else if (std::holds_alternative<bool>(str_props[i].value)) { prop.set_value(allocator, fdf::wire::NodePropertyValue::WithBoolValue( std::get<bool>(str_props[i].value))); } fidl_props[index++] = std::move(prop); } return MatchPropertiesDriverIndex(fidl_props, config); } std::vector<const Driver*> DriverLoader::MatchPropertiesDriverIndex( fidl::VectorView<fdf::wire::NodeProperty> props, const MatchDeviceConfig& config) { std::vector<const Driver*> matched_drivers; std::vector<const Driver*> matched_fallback_drivers; if (!driver_index_.is_valid()) { return matched_drivers; } fidl::Arena allocator; fdf::wire::NodeAddArgs args(allocator); args.set_properties(allocator, std::move(props)); auto result = driver_index_->MatchDriversV1_Sync(std::move(args)); if (!result.ok()) { if (result.status() != ZX_OK) { LOGF(ERROR, "DriverIndex::MatchDriversV1 failed: %d", result.status()); return matched_drivers; } } // If there's no driver to match then DriverIndex will return ZX_ERR_NOT_FOUND. if (result->result.is_err()) { if (result->result.err() != ZX_ERR_NOT_FOUND) { LOGF(ERROR, "DriverIndex: MatchDriversV1 returned error: %d", result->result.err()); } return matched_drivers; } const auto& drivers = result->result.response().drivers; for (auto driver : drivers) { if (!driver.has_driver_url()) { LOGF(ERROR, "DriverIndex: MatchDriver response did not have a driver_url"); continue; } std::string driver_url(driver.driver_url().get()); auto loaded_driver = LoadDriverUrl(driver_url); if (!loaded_driver) { continue; } if (config.only_return_base_and_fallback_drivers) { if (IsFuchsiaBootScheme(driver_url) && !loaded_driver->fallback) { continue; } } if (config.libname.empty() || MatchesLibnameDriverIndex(driver_url, config.libname)) { if (loaded_driver->fallback) { if (include_fallback_drivers_ || !config.libname.empty()) { matched_fallback_drivers.push_back(loaded_driver); } } else { matched_drivers.push_back(loaded_driver); } } } matched_drivers.insert(matched_drivers.end(), matched_fallback_drivers.begin(), matched_fallback_drivers.end()); return matched_drivers; } std::vector<const Driver*> DriverLoader::GetAllDriverIndexDrivers() { std::vector<const Driver*> drivers; auto driver_index_client = service::Connect<fuchsia_driver_development::DriverIndex>(); if (driver_index_client.is_error()) { LOGF(WARNING, "Failed to connect to fuchsia_driver_development::DriverIndex\n"); return drivers; } auto endpoints = fidl::CreateEndpoints<fuchsia_driver_development::DriverInfoIterator>(); if (endpoints.is_error()) { LOGF(ERROR, "fidl::CreateEndpoints failed: %s\n", endpoints.status_string()); return drivers; } auto driver_index = fidl::BindSyncClient(std::move(*driver_index_client)); auto info_result = driver_index.GetDriverInfo(fidl::VectorView<fidl::StringView>(), std::move(endpoints->server)); // There are still some environments where we can't connect to DriverIndex. if (info_result.status() != ZX_OK) { LOGF(INFO, "DriverIndex:GetDriverInfo failed: %d\n", info_result.status()); return drivers; } auto iterator = fidl::BindSyncClient(std::move(endpoints->client)); for (;;) { auto next_result = iterator.GetNext(); if (!next_result.ok()) { // This is likely a pipelined error from the GetDriverInfo call above. We unfortunately // cannot read the epitaph without using an async call. LOGF(ERROR, "DriverInfoIterator.GetNext failed: %s\n", next_result.FormatDescription().c_str()); break; } if (next_result->drivers.count() == 0) { // When we receive 0 responses, we are done iterating. break; } for (auto driver : next_result->drivers) { if (!driver.has_url()) { continue; } std::string url(driver.url().data(), driver.url().size()); const Driver* drv = LoadDriverUrl(url); if (drv) { drivers.push_back(drv); } } } return drivers; }
C++
CL
4f3ba04e71e86bf0d002735ad73a2d18f8bf20b4f076510e1ebb3506691c2a97
/* * SuperDrive.h * * Created on: Jan 18, 2018 * Author: jonah */ #ifndef SRC_AUTON_SUPERDRIVE_H_ #define SRC_AUTON_SUPERDRIVE_H_ //Includes //Team302 includes #include <subsys/chassis/DragonChassis.h> #include <auton/IPrimitive.h> class SuperDrive : public IPrimitive { public: void Init(PrimitiveParams* params) override; void Run() override; bool IsDone() override; void SlowDown(); bool ReachedTargetSpeed(); // float GetAccelDecelTime(); const float GYRO_CORRECTION_CONSTANT = 6; //2.3 const float INCHES_PER_SECOND_SECOND = 120; //120 const float MIN_SPEED_SLOWDOWN = 13; protected: //TODO: why is this protected? SuperDrive(); virtual ~SuperDrive() = default; private: //TODO: figure out where to get PID params const float PROPORTIONAL_COEFF = 12.0; //16 const float INTREGRAL_COEFF = 0; const float DERIVATIVE_COEFF = 0.0; //.16 const float FEET_FORWARD_COEFF = 0.0; DragonChassis* m_chassis; float m_targetSpeed; float m_currentSpeed; float m_speedOffset; float m_leftSpeed; float m_rightSpeed; float m_currentHeading; float m_startHeading; bool m_slowingDown; bool m_reachedTargetSpeed; float m_accelDecelTime; float m_currentTime; float m_minSpeedSlowdown; }; #endif /* SRC_AUTON_SUPERDRIVE_H_ */
C++
CL
c90274aaa915ff0ee00b4a4fd4b0d89ce101252ca8d3ece705438a0181862b2d
#ifndef ___Win32Network___ #define ___Win32Network___ #include "INetwork.h" #include "NetAddress.h" #ifdef WIN32 #include <winsock2.h> #endif namespace mray{ namespace network{ typedef ulong NetID; typedef long long TIME_Stamp; #define MAX_DGRAM_SIZE 1500 enum ESocketOption { ESO_NONBLOCK, ESO_SOCKOPT_BROADCAST, ESO_SOCKOPT_RCVBUF, ESO_SOCKOPT_SNDBUF }; enum ESocketWait { ESW_NONE = (1 << 0), ESW_SEND = (1 << 1), ESW_RECEIVE = (1 << 2) }; enum EProtoType{ EPT_TCP, EPT_UDP }; class Win32Network:public INetwork { const int SYNC_NUMBER; void checkForError(); public: Win32Network(); virtual~Win32Network(); int getSyncNumber(); static void CreateAddress(const NetAddress&addr,sockaddr_in& ret); virtual IUDPClient* createUDPClient(); void closeSocket(SOCKET s); void shutdownSocket(SOCKET s); NetAddress getSockAddr(SOCKET s); static void toSockaddr(const NetAddress &addr,sockaddr*sAddr); void toAddress(const sockaddr*sAddr,NetAddress &addr); static bool inner_getHostAddress(const char*name,NetAddress &addr); bool getHostAddress(const char*name,NetAddress &addr); bool getHostIP(const NetAddress &addr,char*name,int maxLen); bool getHostName(const NetAddress &addr,char*name,int maxLen); static bool setSocketOption(SOCKET s,ESocketOption option,int val); static bool enableBroadcast(SOCKET s,bool enable); //get all ip addresses for this pc int getLocalIPs(char ipLst[8][16]); ulong getLocalAddress(); int getSocketPort(SOCKET s); bool getSocketAddress(SOCKET s,sockaddr_in&out); static bool inner_connect(SOCKET s,const NetAddress&addr); static int inner_receivefrom(SOCKET s,void*data,int len, NetAddress * fromAddress,int flags=0); //condition : composition of ESocketWait enum wich we want to check for //return : composition of ESocketWait enum as result of the test static int wait(SOCKET s,uint timeout,int condition); }; } } #endif
C++
CL
a70b1479b9abca3fa174cfcd6eda68577d1c109a6b667e751e62d6f31b2558b1
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QSettings> #include <QCloseEvent> #include <QDirModel> #include <QDir> #include <QModelIndex> #include <QTime> #include "filemanagement.h" #include "clientmanagement.h" #include "settingdialog.h" #include "qrcodedialog.h" #include "deviceinfo.h" #include "log.h" namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private: Ui::MainWindow *ui; //QrcodeDialog *dialog; SettingDialog *settingDialog; ClientManagement *clientManagement; QDirModel *fileModel; FileManagement *fileManagement; void readSettings(); void writeSettings(); void initFileTreeView(); Log* log; protected: void closeEvent(QCloseEvent *event); public slots: void on_actionOptions_triggered(); void updateFileTreeView(); void showLog(quint8 logType, QVariant logContent); void showLog(QString l); private slots: void on_actionShowLog_changed(); }; #endif // MAINWINDOW_H
C++
CL
1c05d1d5bde5279a40f38467ba05b1724c9bb612210718a91c6c7c767396e823
// CParams.cpp: 实现文件 // #include "pch.h" #include "cpphwfinal.h" #include "CParams.h" #include <opencv2/opencv.hpp> #include <opencv2/imgproc/types_c.h> #include <opencv2/core.hpp> #include <opencv2/highgui.hpp> using namespace cv; using namespace std; // CParams IMPLEMENT_DYNCREATE(CParams, CFormView) CParams::CParams() : CFormView(IDD_FORMVIEW) { } CParams::~CParams() { } void CParams::DoDataExchange(CDataExchange* pDX) { CFormView::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CParams, CFormView) ON_BN_CLICKED(IDC_BUTTON1, &CParams::OnBnClickedButton1) ON_BN_CLICKED(IDC_BUTTON2, &CParams::OnBnClickedButton2) ON_BN_CLICKED(IDC_BUTTON3, &CParams::OnBnClickedButton3) ON_BN_CLICKED(IDC_BUTTON4, &CParams::OnBnClickedButton4) ON_BN_CLICKED(IDC_BUTTON5, &CParams::OnBnClickedButton5) ON_BN_CLICKED(IDC_BUTTON6, &CParams::OnBnClickedButton6) ON_BN_CLICKED(IDC_BUTTON7, &CParams::OnBnClickedButton7) ON_BN_CLICKED(IDC_BUTTON8, &CParams::OnBnClickedButton8) END_MESSAGE_MAP() // CParams 诊断 #ifdef _DEBUG void CParams::AssertValid() const { CFormView::AssertValid(); } #ifndef _WIN32_WCE void CParams::Dump(CDumpContext& dc) const { CFormView::Dump(dc); } #endif #endif //_DEBUG // CParams 消息处理程序 CString strFilePath; string cvname; Mat img; Mat grayimg; Mat hist; Mat dftresult; Mat Gauss; Mat cannyedge; Mat sobeledge; Mat lapedge; bool canny_flag = false; bool sobel_flag = false; bool laplacian_flag = false; void CImage2Mat(CImage& cimage, Mat& mat); void Mat2CImage(Mat& mat, CImage& cimage); void CParams::OnBnClickedButton1() //读取并打开图片 { // TODO: 在此添加控件通知处理程序代码 //选择图片 CFileDialog fileDlg(TRUE, _T("png"), NULL, 0, _T("image Files(*.bmp; *.jpg;*.png)|*.JPG;*.PNG;*.BMP|All Files (*.*) |*.*||"), this); //打开文件选择窗体 if (fileDlg.DoModal() == IDCANCEL) return; //如果点击“取消”按钮,直接退出 //获取图片路径(包含名称) strFilePath = fileDlg.GetPathName();//绝对路径 cvname = CStringA(strFilePath); //判断路径不为空 if (strFilePath == _T("")) { return; } //使用CImage的Load、Draw函数显示图像 CImage image; image.Load(strFilePath); img = imread(cvname); } void CParams::OnBnClickedButton2() { // TODO: 在此添加控件通知处理程序代码 cvtColor(img, grayimg, CV_RGB2GRAY); } void CImage2Mat(CImage &cimage, Mat &mat) //CImage转换为opencvMat { // TODO: 在此处添加实现代码. if (true == cimage.IsNull()) { return; } int nChannels = cimage.GetBPP() / 8; if ((1 != nChannels) && (3 != nChannels)) { return; } int nWidth = cimage.GetWidth(); int nHeight = cimage.GetHeight(); //重建mat if (1 == nChannels) { mat.create(nHeight, nWidth, CV_8UC1); } else if (3 == nChannels) { mat.create(nHeight, nWidth, CV_8UC3); } //拷贝数据 uchar* pucRow; //指向数据区的行指针 uchar* pucImage = (uchar*)cimage.GetBits(); //指向数据区的指针 int nStep = cimage.GetPitch(); //每行的字节数,注意这个返回值有正有负 for (int nRow = 0; nRow < nHeight; nRow++) { pucRow = (mat.ptr<uchar>(nRow)); for (int nCol = 0; nCol < nWidth; nCol++) { if (1 == nChannels) { pucRow[nCol] = *(pucImage + nRow * nStep + nCol); } else if (3 == nChannels) { for (int nCha = 0; nCha < 3; nCha++) { pucRow[nCol * 3 + nCha] = *(pucImage + nRow * nStep + nCol * 3 + nCha); } } } } } void Mat2CImage(Mat& mat, CImage& cimage) //opencvmat转换为CImage输出 { // TODO: 在此处添加实现代码. if (0 == mat.total()) { return; } int nChannels = mat.channels(); if ((1 != nChannels) && (3 != nChannels)) { return; } int nWidth = mat.cols; int nHeight = mat.rows; //重建cimage cimage.Destroy(); cimage.Create(nWidth, nHeight, 8 * nChannels); //拷贝数据 uchar* pucRow; //指向数据区的行指针 uchar* pucImage = (uchar*)cimage.GetBits(); //指向数据区的指针 int nStep = cimage.GetPitch(); //每行的字节数,注意这个返回值有正有负 if (1 == nChannels) //对于单通道的图像需要初始化调色板 { RGBQUAD* rgbquadColorTable; int nMaxColors = 256; rgbquadColorTable = new RGBQUAD[nMaxColors]; cimage.GetColorTable(0, nMaxColors, rgbquadColorTable); for (int nColor = 0; nColor < nMaxColors; nColor++) { rgbquadColorTable[nColor].rgbBlue = (uchar)nColor; rgbquadColorTable[nColor].rgbGreen = (uchar)nColor; rgbquadColorTable[nColor].rgbRed = (uchar)nColor; } cimage.SetColorTable(0, nMaxColors, rgbquadColorTable); delete[]rgbquadColorTable; } for (int nRow = 0; nRow < nHeight; nRow++) { pucRow = (mat.ptr<uchar>(nRow)); for (int nCol = 0; nCol < nWidth; nCol++) { if (1 == nChannels) { *(pucImage + nRow * nStep + nCol) = pucRow[nCol]; } else if (3 == nChannels) { for (int nCha = 0; nCha < 3; nCha++) { *(pucImage + nRow * nStep + nCol * 3 + nCha) = pucRow[nCol * 3 + nCha]; } } } } } void CParams::OnBnClickedButton3() { // TODO: 在此添加控件通知处理程序代码 Mat matRGB[3]; split(img, matRGB); int Channels[] = { 0 }; int nHistSize[] = { 256 }; float range[] = { 0, 255 }; const float* fHistRanges[] = { range }; // 计算直方图 Mat histR, histG, histB; calcHist(&matRGB[0], 1, Channels, Mat(), histB, 1, nHistSize, fHistRanges, true, false); calcHist(&matRGB[1], 1, Channels, Mat(), histG, 1, nHistSize, fHistRanges, true, false); calcHist(&matRGB[2], 1, Channels, Mat(), histR, 1, nHistSize, fHistRanges, true, false); // 创建直方图画布 int nHistWidth = 400; int nHistHeight = 300; int nBinWidth = cvRound((double)nHistWidth / nHistSize[0]); Mat matHistImage(nHistHeight, nHistWidth, CV_8UC3, Scalar(255, 255, 255)); // 直方图归一化 normalize(histB, histB, 0.0, matHistImage.rows, NORM_MINMAX, -1, Mat()); normalize(histG, histG, 0.0, matHistImage.rows, NORM_MINMAX, -1, Mat()); normalize(histR, histR, 0.0, matHistImage.rows, NORM_MINMAX, -1, Mat()); for (int i = 1; i < nHistSize[0]; i++) { line(matHistImage, Point(nBinWidth * (i - 1), nHistHeight - cvRound(histB.at<float>(i - 1))), Point(nBinWidth * (i), nHistHeight - cvRound(histB.at<float>(i))), Scalar(255, 0, 0), 2, 8, 0); line(matHistImage, Point(nBinWidth * (i - 1), nHistHeight - cvRound(histG.at<float>(i - 1))), Point(nBinWidth * (i), nHistHeight - cvRound(histG.at<float>(i))), Scalar(0, 255, 0), 2, 8, 0); line(matHistImage, Point(nBinWidth * (i - 1), nHistHeight - cvRound(histR.at<float>(i - 1))), Point(nBinWidth * (i), nHistHeight - cvRound(histR.at<float>(i))), Scalar(0, 0, 255), 2, 8, 0); } hist = matHistImage; } void CParams::OnBnClickedButton4() { // TODO: 在此添加控件通知处理程序代码 Mat padded; //以0填充输入图像矩阵 int m = getOptimalDFTSize(grayimg.rows); int n = getOptimalDFTSize(grayimg.cols); //填充输入图像I,输入矩阵为padded,上方和左方不做填充处理 copyMakeBorder(grayimg, padded, 0, m - grayimg.rows, 0, n - grayimg.cols, BORDER_CONSTANT, Scalar::all(0)); Mat planes[] = { Mat_<float>(padded), Mat::zeros(padded.size(),CV_32F) }; Mat complexI; merge(planes, 2, complexI); //将planes融合合并成一个多通道数组complexI dft(complexI, complexI); //进行傅里叶变换 //计算幅值,转换到对数尺度(logarithmic scale) //=> log(1 + sqrt(Re(DFT(I))^2 + Im(DFT(I))^2)) split(complexI, planes); //planes[0] = Re(DFT(I),planes[1] = Im(DFT(I)) //即planes[0]为实部,planes[1]为虚部 magnitude(planes[0], planes[1], planes[0]); //planes[0] = magnitude Mat magI = planes[0]; magI += Scalar::all(1); log(magI, magI); //转换到对数尺度(logarithmic scale) //如果有奇数行或列,则对频谱进行裁剪 magI = magI(Rect(0, 0, magI.cols & -2, magI.rows & -2)); //重新排列傅里叶图像中的象限,使得原点位于图像中心 int cx = magI.cols / 2; int cy = magI.rows / 2; Mat q0(magI, Rect(0, 0, cx, cy)); //左上角图像划定ROI区域 Mat q1(magI, Rect(cx, 0, cx, cy)); //右上角图像 Mat q2(magI, Rect(0, cy, cx, cy)); //左下角图像 Mat q3(magI, Rect(cx, cy, cx, cy)); //右下角图像 //变换左上角和右下角象限 Mat tmp; q0.copyTo(tmp); q3.copyTo(q0); tmp.copyTo(q3); //变换右上角和左下角象限 q1.copyTo(tmp); q2.copyTo(q1); tmp.copyTo(q2); //归一化处理,用0-1之间的浮点数将矩阵变换为可视的图像格式 normalize(magI, magI, 0, 1, CV_MINMAX); imwrite("fft.jpg", magI * 256); dftresult = magI; } void CParams::OnBnClickedButton5() { // TODO: 在此添加控件通知处理程序代码 GaussianBlur(img, Gauss, Size(5, 5), 3, 3); GaussianBlur(Gauss, Gauss, Size(5, 5), 3, 3); /*image.Destroy(); pWnd->ReleaseDC(pDc);*/ } void CParams::OnBnClickedButton6() { // TODO: 在此添加控件通知处理程序代码 Canny(grayimg, cannyedge, 30, 80); canny_flag = true; sobel_flag = false; laplacian_flag = false; } void CParams::OnBnClickedButton7() { // TODO: 在此添加控件通知处理程序代码 Mat x_edgeImg, y_edgeImg, abs_x_edgeImg, abs_y_edgeImg; /*****先对x方向进行边缘检测********/ //因为Sobel求出来的结果有正负,8位无符号表示不全,故用16位有符号表示 Sobel(grayimg, x_edgeImg, CV_16S, 1, 0, 3, 1, 1, BORDER_DEFAULT); convertScaleAbs(x_edgeImg, abs_x_edgeImg);//将16位有符号转化为8位无符号 /*****再对y方向进行边缘检测********/ Sobel(grayimg, y_edgeImg, CV_16S, 0, 1, 3, 1, 1, BORDER_DEFAULT); convertScaleAbs(y_edgeImg, abs_y_edgeImg); addWeighted(abs_x_edgeImg, 0.5, abs_y_edgeImg, 0.5, 0, sobeledge); canny_flag = false; sobel_flag = true; laplacian_flag = false; } void CParams::OnBnClickedButton8() { // TODO: 在此添加控件通知处理程序代码 Laplacian(grayimg, lapedge, CV_16S, 5, 1, 0, BORDER_DEFAULT); convertScaleAbs(lapedge, lapedge); canny_flag = false; sobel_flag = false; laplacian_flag =true; } void CParams::OnDraw(CDC* /*pDC*/) { // TODO: 在此添加专用代码和/或调用基类 CImage image; if (!img.empty()) { image.Load(strFilePath); //获取控件的矩形 CRect rectControl; //控件矩形对象 CWnd* pWnd = GetDlgItem(IDC_IMG); //Picture Control的ID为IDC_IMAGE pWnd->GetClientRect(&rectControl); //以控件为画布,在其上画图 CDC* pDc = GetDlgItem(IDC_IMG)->GetDC(); SetStretchBltMode(pDc->m_hDC, STRETCH_HALFTONE);//绘图前必须调用此函数(设置缩放模式),否则失真严重 //画图(以下两种方法都可) //image.StretchBlt(pDc->m_hDC, rectPicture, SRCCOPY); //将图片绘制到Picture控件表示的矩形区域 image.Draw(pDc->m_hDC, rectControl); //将图片绘制到Picture控件表示的矩形区域 } if (!grayimg.empty()) { Mat2CImage(grayimg, image); //获取控件的矩形 CRect rectControl; //控件矩形对象 CWnd* pWnd = GetDlgItem(IDC_IMG2); //Picture Control的ID为IDC_IMAGE pWnd->GetClientRect(&rectControl); //以控件为画布,在其上画图 CDC* pDc = GetDlgItem(IDC_IMG2)->GetDC(); SetStretchBltMode(pDc->m_hDC, STRETCH_HALFTONE);//绘图前必须调用此函数(设置缩放模式),否则失真严重 //画图(以下两种方法都可) //image.StretchBlt(pDc->m_hDC, rectPicture, SRCCOPY); //将图片绘制到Picture控件表示的矩形区域 image.Draw(pDc->m_hDC, rectControl); //将图片绘制到Picture控件表示的矩形区域 } if (!hist.empty()) { Mat2CImage(hist, image); CRect rectControl; //控件矩形对象 CWnd* pWnd = GetDlgItem(IDC_IMG3); //Picture Control的ID为IDC_IMAGE pWnd->GetClientRect(&rectControl); //以控件为画布,在其上画图 CDC* pDc = GetDlgItem(IDC_IMG3)->GetDC(); SetStretchBltMode(pDc->m_hDC, STRETCH_HALFTONE);//绘图前必须调用此函数(设置缩放模式),否则失真严重 //画图(以下两种方法都可) //image.StretchBlt(pDc->m_hDC, rectPicture, SRCCOPY); //将图片绘制到Picture控件表示的矩形区域 image.Draw(pDc->m_hDC, rectControl); //将图片绘制到Picture控件表示的矩形区域 } if (!dftresult.empty()) { Mat dftres = imread("fft.jpg"); Mat2CImage(dftres, image); CRect rectControl; //控件矩形对象 CWnd* pWnd = GetDlgItem(IDC_IMG4); //Picture Control的ID为IDC_IMAGE pWnd->GetClientRect(&rectControl); //以控件为画布,在其上画图 CDC* pDc = GetDlgItem(IDC_IMG4)->GetDC(); SetStretchBltMode(pDc->m_hDC, STRETCH_HALFTONE);//绘图前必须调用此函数(设置缩放模式),否则失真严重 //画图(以下两种方法都可) //image.StretchBlt(pDc->m_hDC, rectPicture, SRCCOPY); //将图片绘制到Picture控件表示的矩形区域 image.Draw(pDc->m_hDC, rectControl); //将图片绘制到Picture控件表示的矩形区域 } if (!Gauss.empty()) { Mat2CImage(Gauss, image); CRect rectControl; //控件矩形对象 CWnd* pWnd = GetDlgItem(IDC_IMG5); //Picture Control的ID为IDC_IMAGE pWnd->GetClientRect(&rectControl); //以控件为画布,在其上画图 CDC* pDc = GetDlgItem(IDC_IMG5)->GetDC(); SetStretchBltMode(pDc->m_hDC, STRETCH_HALFTONE);//绘图前必须调用此函数(设置缩放模式),否则失真严重 //画图(以下两种方法都可) //image.StretchBlt(pDc->m_hDC, rectPicture, SRCCOPY); //将图片绘制到Picture控件表示的矩形区域 image.Draw(pDc->m_hDC, rectControl); //将图片绘制到Picture控件表示的矩形区域 } if ((!cannyedge.empty()) && canny_flag) { Mat2CImage(cannyedge, image); CRect rectControl; //控件矩形对象 CWnd* pWnd = GetDlgItem(IDC_IMG6); //Picture Control的ID为IDC_IMAGE pWnd->GetClientRect(&rectControl); //以控件为画布,在其上画图 CDC* pDc = GetDlgItem(IDC_IMG6)->GetDC(); SetStretchBltMode(pDc->m_hDC, STRETCH_HALFTONE);//绘图前必须调用此函数(设置缩放模式),否则失真严重 //画图(以下两种方法都可) //image.StretchBlt(pDc->m_hDC, rectPicture, SRCCOPY); //将图片绘制到Picture控件表示的矩形区域 image.Draw(pDc->m_hDC, rectControl); //将图片绘制到Picture控件表示的矩形区域 } if ((!sobeledge.empty()) && sobel_flag) { Mat2CImage(sobeledge, image); CRect rectControl; //控件矩形对象 CWnd* pWnd = GetDlgItem(IDC_IMG6); //Picture Control的ID为IDC_IMAGE pWnd->GetClientRect(&rectControl); //以控件为画布,在其上画图 CDC* pDc = GetDlgItem(IDC_IMG6)->GetDC(); SetStretchBltMode(pDc->m_hDC, STRETCH_HALFTONE);//绘图前必须调用此函数(设置缩放模式),否则失真严重 //画图(以下两种方法都可) //image.StretchBlt(pDc->m_hDC, rectPicture, SRCCOPY); //将图片绘制到Picture控件表示的矩形区域 image.Draw(pDc->m_hDC, rectControl); //将图片绘制到Picture控件表示的矩形区域 } if ((!lapedge.empty()) && laplacian_flag) { Mat2CImage(lapedge, image); CRect rectControl; //控件矩形对象 CWnd* pWnd = GetDlgItem(IDC_IMG6); //Picture Control的ID为IDC_IMAGE pWnd->GetClientRect(&rectControl); //以控件为画布,在其上画图 CDC* pDc = GetDlgItem(IDC_IMG6)->GetDC(); SetStretchBltMode(pDc->m_hDC, STRETCH_HALFTONE);//绘图前必须调用此函数(设置缩放模式),否则失真严重 //画图(以下两种方法都可) //image.StretchBlt(pDc->m_hDC, rectPicture, SRCCOPY); //将图片绘制到Picture控件表示的矩形区域 image.Draw(pDc->m_hDC, rectControl); //将图片绘制到Picture控件表示的矩形区域 } }
C++
CL
c4de9ad55142db1d49a391bbe9971f762065d418b9157203c83c17b6ddd5504d
// // Created by leleyu on 2019-04-08. // #ifndef GRAPH_INTERFACE_COMMONS_H #define GRAPH_INTERFACE_COMMONS_H // convert primitives between java object and c++ object // strings #define DEFINE_STRING(_jstring) \ const char* jstring##_cstr_ptr = env->GetStringUTFChars(_jstring, NULL); \ std::string _jstring##_cstr(jstring##_cstr_ptr); #define RELEASE_STRING(_jstring) \ env->ReleaseStringUTFChars(_jstring, jstring##_cstr_ptr); // arrays #define DEFINE_PRIMITIVE_ARRAY(_jarray) \ void* _jarray##_cptr = env->GetPrimitiveArrayCritical(_jarray, &is_copy); #define RELEASE_PRIMITIVE_ARRAY(_jarray) \ env->ReleasePrimitiveArrayCritical(_jarray, _jarray##_cptr, 0); #define DEFINE_MODEL_PTR(MODEL_TYPE, jptr) \ auto* ptr = reinterpret_cast<MODEL_TYPE*>(jptr); #define DEFINE_TORCH_TENSOR_ARRAY(_jarray, type) \ auto _jarray##_option = torch::TensorOptions().dtype(type).requires_grad(false); \ auto _jarray##_tensor = torch::from_blob(_jarray##_cptr, {env->GetArrayLength(_jarray)}, _jarray##_option); #define DEFINE_TORCH_TENSOR_ARRAY_GRAD(_jarray, type) \ auto _jarray##_option = torch::TensorOptions().dtype(type).requires_grad(true);\ auto _jarray##_tensor = torch::from_blob(_jarray##_cptr, {env->GetArrayLength(_jarray)}, _jarray##_option); #define DEFINE_TORCH_TENSOR_SCALA(_jprimitive, type) \ auto _jprimitive##_option = torch::TensorOptions().dtype(type).requires_grad(false);\ auto _jprimitive##_tensor = torch::from_blob(&_jprimitive, {1}, _jprimitive##_option); #define DEFINE_TORCH_TENSOR_SCALA_GRAD(_jprimitive, type) \ auto _jprimitive##_option = torch::TensorOptions().dtype(type).requires_grad(true);\ auto _jprimitive##_tensor = torch::from_blob(&_jprimitive, {1}, _jprimitive##_option); #define DEFINE_JFLOATARRAY(_carray_ptr, len) \ jfloatArray _carray_ptr##_jarray = env->NewFloatArray(len); \ env->SetFloatArrayRegion(_carray_ptr##_jarray, 0, len, reinterpret_cast<float*>(_carray_ptr)); #define DEFINE_PRIMITIVE_ARRAYS4(jarray1, jarray2, jarray3, jarray4) \ DEFINE_PRIMITIVE_ARRAY(jarray1);\ DEFINE_PRIMITIVE_ARRAY(jarray2);\ DEFINE_PRIMITIVE_ARRAY(jarray3);\ DEFINE_PRIMITIVE_ARRAY(jarray4); #define DEFINE_PRIMITIVE_ARRAYS5(jarray1, jarray2, jarray3, jarray4, jarray5) \ DEFINE_PRIMITIVE_ARRAYS4(jarray1, jarray2, jarray3, jarray4); \ DEFINE_PRIMITIVE_ARRAY(jarray5); #define DEFINE_PRIMITIVE_ARRAYS6(jarray1, jarray2, jarray3, jarray4, jarray5, jarray6) \ DEFINE_PRIMITIVE_ARRAYS5(jarray1, jarray2, jarray3, jarray4, jarray5); \ DEFINE_PRIMITIVE_ARRAY(jarray6); #define RELEASE_PRIMITIVE_ARRAYS4(jarray1, jarray2, jarray3, jarray4) \ RELEASE_PRIMITIVE_ARRAY(jarray1);\ RELEASE_PRIMITIVE_ARRAY(jarray2);\ RELEASE_PRIMITIVE_ARRAY(jarray3);\ RELEASE_PRIMITIVE_ARRAY(jarray4); #define RELEASE_PRIMITIVE_ARRAYS5(jarray1, jarray2, jarray3, jarray4, jarray5) \ RELEASE_PRIMITIVE_ARRAYS4(jarray1, jarray2, jarray3, jarray4) \ RELEASE_PRIMITIVE_ARRAY(jarray5); #define RELEASE_PRIMITIVE_ARRAYS6(jarray1, jarray2, jarray3, jarray4, jarray5, jarray6) \ RELEASE_PRIMITIVE_ARRAYS5(jarray1, jarray2, jarray3, jarray4, jarray5);\ RELEASE_PRIMITIVE_ARRAY(jarray6); #define DEFINE_EMBEDDINGS(jinput_embeddings, embedding_dim) \ auto length = env->GetArrayLength(jinput_embeddings); \ assert(length % embedding_dim == 0); \ auto size = length / embedding_dim; \ auto input_embeddings = torch::from_blob(jinput_embeddings##_cptr, {size, embedding_dim}); #define DEFINE_GRAPH_STRUCTURE(jnodes, jneighbors, jmax_neighbor) \ auto* cinodes = static_cast<int32_t*>(jnodes_##cptr); \ auto* cineighbors = static_cast<int32_t*>(jneighbors_##cptr); \ std::vector<int32_t> nodes(cinodes, cinodes + env->GetArrayLength(jnodes)); \ std::vector<int32_t> neighbors(cineighbors, cineighbors + env->GetArrayLength(jneighbors)); \ angel::graph::SubGraph sub_graph(nodes, neighbors, jmax_neighbor); // define torch tensors #define TORCH_OPTION_INT64 \ (torch::TensorOptions().dtype(torch::kInt64).requires_grad(false)) #define TORCH_OPTION_INT32 \ (torch::TensorOptions().dtype(torch::kInt32).requires_grad(false)) #define TORCH_OPTION_FLOAT \ (torch::TensorOptions().requires_grad(false)) #define DEFINE_ZEROS_DIM2_INT64(_name, dim1, dim2) \ auto _name = torch::zeros({dim1, dim2}, TORCH_OPTION_INT64); #define DEFINE_ZEROS_DIM2_FLOAT(_name, dim1, dim2) \ auto _name = torch::zeros({dim1, dim2}, TORCH_OPTION_FLOAT); #define DEFINE_ZEROS_DIM1_INT64(_name, dim1) \ auto _name = torch::zeros({dim1}, TORCH_OPTION_INT64); #define DEFINE_ZEROS_DIM1_INT32(_name, dim1) \ auto _name = torch::zeros({dim1}, TORCH_OPTION_INT32); #define DEFINE_ACCESSOR_DIM1_INT64(_tensor) \ auto _tensor##_acr = _tensor.accessor<int64_t, 1>(); #define DEFINE_ACCESSOR_DIM1_INT32(_tensor) \ auto _tensor##_acr = _tensor.accessor<int32_t, 1>(); #define DEFINE_ACCESSOR_DIM2_INT64(_tensor) \ auto _tensor##_acr = _tensor.accessor<int64_t, 2>(); #define DEFINE_ACCESSOR_DIM2_FLOAT(_tensor) \ auto _tensor##_acr = _tensor.accessor<float, 2>(); #endif //GRAPH_INTERFACE_COMMONS_H
C++
CL
9b1dbf7b0f0d09053431600e19b6b83dcfc0e7693d5f646b915fd9d6133631cf
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- // ScreenResource.ccfor Blackbox - an X11 Window manager // Copyright (c) 2001 - 2005 Sean 'Shaleh' Perry <shaleh@debian.org> // Copyright (c) 1997 - 2000, 2002 - 2005 // Bradley T Hughes <bhughes at trolltech.com> // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. #include "ScreenResource.hh" #include "Screen.hh" #include "Slit.hh" #include "Toolbar.hh" #include <Menu.hh> #include <Resource.hh> #include <assert.h> #include <string.h> // HACK BEGINS void ScreenResource::setToolbarAutoHide(bool kk) { _toolbarOptions.auto_hide = kk; } // HACK ENDS static const int iconify_width = 9; static const int iconify_height = 9; static const unsigned char iconify_bits[] = { 0x00, 0x00, 0x82, 0x00, 0xc6, 0x00, 0x6c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00, 0x00, 0xff, 0x01, 0xff, 0x01 }; static const int maximize_width = 9; static const int maximize_height = 9; static const unsigned char maximize_bits[] = { 0xff, 0x01, 0xff, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xff, 0x01 }; static const int restore_width = 9; static const int restore_height = 9; static const unsigned char restore_bits[] = { 0xf8, 0x01, 0xf8, 0x01, 0x08, 0x01, 0x3f, 0x01, 0x3f, 0x01, 0xe1, 0x01, 0x21, 0x00, 0x21, 0x00, 0x3f, 0x00 }; static const int close_width = 9; static const int close_height = 9; static const unsigned char close_bits[] = { 0x83, 0x01, 0xc7, 0x01, 0xee, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xee, 0x00, 0xc7, 0x01, 0x83, 0x01 }; void ScreenResource::save(bt::Resource& res, BScreen* screen) { char rc_string[128]; char *placement = (char *) 0; unsigned int number = screen->screenNumber(); switch (_slitOptions.placement) { case Slit::TopLeft: placement = "TopLeft"; break; case Slit::CenterLeft: placement = "CenterLeft"; break; case Slit::BottomLeft: placement = "BottomLeft"; break; case Slit::TopCenter: placement = "TopCenter"; break; case Slit::BottomCenter: placement = "BottomCenter"; break; case Slit::TopRight: placement = "TopRight"; break; case Slit::BottomRight: placement = "BottomRight"; break; case Slit::CenterRight: default: placement = "CenterRight"; break; } sprintf(rc_string, "session.screen%u.slit.placement", number); res.write(rc_string, placement); sprintf(rc_string, "session.screen%u.slit.direction", number); res.write(rc_string, (_slitOptions.direction == Slit::Horizontal) ? "Horizontal" : "Vertical"); sprintf(rc_string, "session.screen%u.slit.onTop", number); res.write(rc_string, _slitOptions.always_on_top); sprintf(rc_string, "session.screen%u.slit.autoHide", number); res.write(rc_string, _slitOptions.auto_hide); sprintf(rc_string, "session.screen%u.enableToolbar", number); res.write(rc_string, _toolbarOptions.enabled); sprintf(rc_string, "session.screen%u.toolbar.onTop", number); res.write(rc_string, _toolbarOptions.always_on_top); sprintf(rc_string, "session.screen%u.toolbar.autoHide", number); res.write(rc_string, _toolbarOptions.auto_hide); switch (_toolbarOptions.placement) { case Toolbar::TopLeft: placement = "TopLeft"; break; case Toolbar::BottomLeft: placement = "BottomLeft"; break; case Toolbar::TopCenter: placement = "TopCenter"; break; case Toolbar::TopRight: placement = "TopRight"; break; case Toolbar::BottomRight: placement = "BottomRight"; break; case Toolbar::BottomCenter: default: placement = "BottomCenter"; break; } sprintf(rc_string, "session.screen%u.toolbar.placement", number); res.write(rc_string, placement); sprintf(rc_string, "session.screen%u.workspaces", number); res.write(rc_string, workspace_count); std::vector<bt::ustring>::const_iterator it = workspace_names.begin(), end = workspace_names.end(); bt::ustring save_string = *it++; for (; it != end; ++it) { save_string += ','; save_string += *it; } sprintf(rc_string, "session.screen%u.workspaceNames", number); res.write(rc_string, bt::toLocale(save_string).c_str()); // these options can not be modified at runtime currently sprintf(rc_string, "session.screen%u.toolbar.widthPercent", number); res.write(rc_string, _toolbarOptions.width_percent); sprintf(rc_string, "session.screen%u.strftimeFormat", number); res.write(rc_string, _toolbarOptions.strftime_format.c_str()); } void ScreenResource::load(bt::Resource& res, unsigned int screen) { char name_lookup[128], class_lookup[128]; std::string str; // toolbar settings sprintf(name_lookup, "session.screen%u.enableToolbar", screen); sprintf(class_lookup, "Session.screen%u.enableToolbar", screen); _toolbarOptions.enabled = res.read(name_lookup, class_lookup, true); sprintf(name_lookup, "session.screen%u.toolbar.widthPercent", screen); sprintf(class_lookup, "Session.screen%u.Toolbar.WidthPercent", screen); _toolbarOptions.width_percent = res.read(name_lookup, class_lookup, 66); sprintf(name_lookup, "session.screen%u.toolbar.placement", screen); sprintf(class_lookup, "Session.screen%u.Toolbar.Placement", screen); str = res.read(name_lookup, class_lookup, "BottomCenter"); if (! strcasecmp(str.c_str(), "TopLeft")) _toolbarOptions.placement = Toolbar::TopLeft; else if (! strcasecmp(str.c_str(), "BottomLeft")) _toolbarOptions.placement = Toolbar::BottomLeft; else if (! strcasecmp(str.c_str(), "TopCenter")) _toolbarOptions.placement = Toolbar::TopCenter; else if (! strcasecmp(str.c_str(), "TopRight")) _toolbarOptions.placement = Toolbar::TopRight; else if (! strcasecmp(str.c_str(), "BottomRight")) _toolbarOptions.placement = Toolbar::BottomRight; else _toolbarOptions.placement = Toolbar::BottomCenter; sprintf(name_lookup, "session.screen%u.toolbar.onTop", screen); sprintf(class_lookup, "Session.screen%u.Toolbar.OnTop", screen); _toolbarOptions.always_on_top = res.read(name_lookup, class_lookup, false); sprintf(name_lookup, "session.screen%u.toolbar.autoHide", screen); sprintf(class_lookup, "Session.screen%u.Toolbar.autoHide", screen); _toolbarOptions.auto_hide = res.read(name_lookup, class_lookup, false); sprintf(name_lookup, "session.screen%u.strftimeFormat", screen); sprintf(class_lookup, "Session.screen%u.StrftimeFormat", screen); _toolbarOptions.strftime_format = res.read(name_lookup, class_lookup, "%I:%M %p"); // slit settings sprintf(name_lookup, "session.screen%u.slit.placement", screen); sprintf(class_lookup, "Session.screen%u.Slit.Placement", screen); str = res.read(name_lookup, class_lookup, "CenterRight"); if (! strcasecmp(str.c_str(), "TopLeft")) _slitOptions.placement = Slit::TopLeft; else if (! strcasecmp(str.c_str(), "CenterLeft")) _slitOptions.placement = Slit::CenterLeft; else if (! strcasecmp(str.c_str(), "BottomLeft")) _slitOptions.placement = Slit::BottomLeft; else if (! strcasecmp(str.c_str(), "TopCenter")) _slitOptions.placement = Slit::TopCenter; else if (! strcasecmp(str.c_str(), "BottomCenter")) _slitOptions.placement = Slit::BottomCenter; else if (! strcasecmp(str.c_str(), "TopRight")) _slitOptions.placement = Slit::TopRight; else if (! strcasecmp(str.c_str(), "BottomRight")) _slitOptions.placement = Slit::BottomRight; else _slitOptions.placement = Slit::CenterRight; sprintf(name_lookup, "session.screen%u.slit.direction", screen); sprintf(class_lookup, "Session.screen%u.Slit.Direction", screen); str = res.read(name_lookup, class_lookup, "Vertical"); if (! strcasecmp(str.c_str(), "Horizontal")) _slitOptions.direction = Slit::Horizontal; else _slitOptions.direction = Slit::Vertical; sprintf(name_lookup, "session.screen%u.slit.onTop", screen); sprintf(class_lookup, "Session.screen%u.Slit.OnTop", screen); _slitOptions.always_on_top = res.read(name_lookup, class_lookup, false); sprintf(name_lookup, "session.screen%u.slit.autoHide", screen); sprintf(class_lookup, "Session.screen%u.Slit.AutoHide", screen); _slitOptions.auto_hide = res.read(name_lookup, class_lookup, false); // general screen settings sprintf(name_lookup, "session.screen%u.workspaces", screen); sprintf(class_lookup, "Session.screen%u.Workspaces", screen); workspace_count = res.read(name_lookup, class_lookup, 4); if (! workspace_names.empty()) workspace_names.clear(); sprintf(name_lookup, "session.screen%u.workspaceNames", screen); sprintf(class_lookup, "Session.screen%u.WorkspaceNames", screen); bt::ustring ustr = bt::toUnicode(res.read(name_lookup, class_lookup)); if (!ustr.empty()) { bt::ustring::const_iterator it = ustr.begin(); const bt::ustring::const_iterator end = ustr.end(); for (;;) { const bt::ustring::const_iterator i = std::find(it, end, static_cast<bt::ustring::value_type>(',')); workspace_names.push_back(bt::ustring(it, i)); it = i; if (it == end) break; ++it; } } } void ScreenResource::loadStyle(BScreen* screen, const std::string& style) { const bt::Display& display = screen->blackbox()->display(); unsigned int screen_num = screen->screenNumber(); // use the user selected style bt::Resource res(style); if (!res.valid()) res.load(DEFAULTSTYLE); // load menu style bt::MenuStyle::get(*screen->blackbox(), screen_num)->load(res); // load window style _windowStyle.font.setFontName(res.read("window.font", "Window.Font")); _windowStyle.iconify.load(screen_num, iconify_bits, iconify_width, iconify_height); _windowStyle.maximize.load(screen_num, maximize_bits, maximize_width, maximize_height); _windowStyle.restore.load(screen_num, restore_bits, restore_width, restore_height); _windowStyle.close.load(screen_num, close_bits, close_width, close_height); // focused window style _windowStyle.focus.text = bt::Color::namedColor(display, screen_num, res.read("window.label.focus.textColor", "Window.Label.Focus.TextColor", "black")); _windowStyle.focus.foreground = bt::Color::namedColor(display, screen_num, res.read("window.button.focus.foregroundColor", "Window.Button.Focus.ForegroundColor", res.read("window.button.focus.picColor", "Window.Button.Focus.PicColor", "black"))); _windowStyle.focus.title = bt::textureResource(display, screen_num, res, "window.title.focus", "Window.Title.Focus", "white"); _windowStyle.focus.label = bt::textureResource(display, screen_num, res, "window.label.focus", "Window.Label.Focus", "white"); _windowStyle.focus.button = bt::textureResource(display, screen_num, res, "window.button.focus", "Window.Button.Focus", "white"); _windowStyle.focus.handle = bt::textureResource(display, screen_num, res, "window.handle.focus", "Window.Handle.Focus", "white"); _windowStyle.focus.grip = bt::textureResource(display, screen_num, res, "window.grip.focus", "Window.Grip.Focus", "white"); _windowStyle.focus.frame_border = bt::Color::namedColor(display, screen_num, res.read("window.frame.focus.borderColor", "Window.Frame.Focus.BorderColor", "white")); // unfocused window style _windowStyle.unfocus.text = bt::Color::namedColor(display, screen_num, res.read("window.label.unfocus.textColor", "Window.Label.Unfocus.TextColor", "white")); _windowStyle.unfocus.foreground = bt::Color::namedColor(display, screen_num, res.read("window.button.unfocus.foregroundColor", "Window.Button.Unfocus.ForegroundColor", res.read("window.button.unfocus.picColor", "Window.Button.Unfocus.PicColor", "white"))); _windowStyle.unfocus.title = bt::textureResource(display, screen_num, res, "window.title.unfocus", "Window.Title.Unfocus", "black"); _windowStyle.unfocus.label = bt::textureResource(display, screen_num, res, "window.label.unfocus", "Window.Label.Unfocus", "black"); _windowStyle.unfocus.button = bt::textureResource(display, screen_num, res, "window.button.unfocus", "Window.Button.Unfocus", "black"); _windowStyle.unfocus.handle = bt::textureResource(display, screen_num, res, "window.handle.unfocus", "Window.Handle.Unfocus", "black"); _windowStyle.unfocus.grip = bt::textureResource(display, screen_num, res, "window.grip.unfocus", "Window.Grip.Unfocus", "black"); _windowStyle.unfocus.frame_border = bt::Color::namedColor(display, screen_num, res.read("window.frame.unfocus.borderColor", "Window.Frame.Unfocus.BorderColor", "black")); _windowStyle.pressed = bt::textureResource(display, screen_num, res, "window.button.pressed", "Window.Button.Pressed", "black"); _windowStyle.alignment = bt::alignResource(res, "window.alignment", "Window.Alignment"); _windowStyle.title_margin = res.read("window.title.marginWidth", "Window.Title.MarginWidth", 2); _windowStyle.label_margin = res.read("window.label.marginWidth", "Window.Label.MarginWidth", 2); _windowStyle.button_margin = res.read("window.button.marginWidth", "Window.Button.MarginWidth", 2); _windowStyle.frame_border_width = res.read("window.frame.borderWidth", "Window.Frame.BorderWidth", 1); _windowStyle.handle_height = res.read("window.handleHeight", "Window.HandleHeight", 6); // the height of the titlebar is based upon the height of the font being // used to display the window's title _windowStyle.button_width = std::max(std::max(std::max(std::max(_windowStyle.iconify.width(), _windowStyle.iconify.height()), std::max(_windowStyle.maximize.width(), _windowStyle.maximize.height())), std::max(_windowStyle.restore.width(), _windowStyle.restore.height())), std::max(_windowStyle.close.width(), _windowStyle.close.height())) + ((std::max(_windowStyle.focus.button.borderWidth(), _windowStyle.unfocus.button.borderWidth()) + _windowStyle.button_margin) * 2); _windowStyle.label_height = std::max(bt::textHeight(screen_num, _windowStyle.font) + ((std::max(_windowStyle.focus.label.borderWidth(), _windowStyle.unfocus.label.borderWidth()) + _windowStyle.label_margin) * 2), _windowStyle.button_width); _windowStyle.button_width = std::max(_windowStyle.button_width, _windowStyle.label_height); _windowStyle.title_height = _windowStyle.label_height + ((std::max(_windowStyle.focus.title.borderWidth(), _windowStyle.unfocus.title.borderWidth()) + _windowStyle.title_margin) * 2); _windowStyle.grip_width = (_windowStyle.button_width * 2); _windowStyle.handle_height += (std::max(_windowStyle.focus.handle.borderWidth(), _windowStyle.unfocus.handle.borderWidth()) * 2); // load toolbar style _toolbarStyle.font.setFontName(res.read("toolbar.font", "Toolbar.Font")); _toolbarStyle.toolbar = bt::textureResource(display, screen_num, res, "toolbar", "Toolbar", "white"); _toolbarStyle.slabel = bt::textureResource(display, screen_num, res, "toolbar.label", "Toolbar.Label", "white"); _toolbarStyle.wlabel = bt::textureResource(display, screen_num, res, "toolbar.windowLabel", "Toolbar.Label", "white"); _toolbarStyle.button = bt::textureResource(display, screen_num, res, "toolbar.button", "Toolbar.Button", "white"); _toolbarStyle.pressed = bt::textureResource(display, screen_num, res, "toolbar.button.pressed", "Toolbar.Button.Pressed", "black"); _toolbarStyle.clock = bt::textureResource(display, screen_num, res, "toolbar.clock", "Toolbar.Label", "white"); _toolbarStyle.slabel_text = bt::Color::namedColor(display, screen_num, res.read("toolbar.label.textColor", "Toolbar.Label.TextColor", "black")); _toolbarStyle.wlabel_text = bt::Color::namedColor(display, screen_num, res.read("toolbar.windowLabel.textColor", "Toolbar.Label.TextColor", "black")); _toolbarStyle.clock_text = bt::Color::namedColor(display, screen_num, res.read("toolbar.clock.textColor", "Toolbar.Label.TextColor", "black")); _toolbarStyle.foreground = bt::Color::namedColor(display, screen_num, res.read("toolbar.button.foregroundColor", "Toolbar.Button.ForegroundColor", res.read("toolbar.button.picColor", "Toolbar.Button.PicColor", "black"))); _toolbarStyle.alignment = bt::alignResource(res, "toolbar.alignment", "Toolbar.Alignment"); _toolbarStyle.frame_margin = res.read("toolbar.marginWidth", "Toolbar.MarginWidth", 2); _toolbarStyle.label_margin = res.read("toolbar.label.marginWidth", "Toolbar.Label.MarginWidth", 2); _toolbarStyle.button_margin = res.read("toolbar.button.marginWidth", "Toolbar.Button.MarginWidth", 2); const bt::Bitmap &left = bt::Bitmap::leftArrow(screen_num), &right = bt::Bitmap::rightArrow(screen_num); _toolbarStyle.button_width = std::max(std::max(left.width(), left.height()), std::max(right.width(), right.height())) + ((_toolbarStyle.button.borderWidth() + _toolbarStyle.button_margin) * 2); _toolbarStyle.label_height = std::max(bt::textHeight(screen_num, _toolbarStyle.font) + ((std::max(std::max(_toolbarStyle.slabel.borderWidth(), _toolbarStyle.wlabel.borderWidth()), _toolbarStyle.clock.borderWidth()) + _toolbarStyle.label_margin) * 2), _toolbarStyle.button_width); _toolbarStyle.button_width = std::max(_toolbarStyle.button_width, _toolbarStyle.label_height); _toolbarStyle.toolbar_height = _toolbarStyle.label_height + ((_toolbarStyle.toolbar.borderWidth() + _toolbarStyle.frame_margin) * 2); _toolbarStyle.hidden_height = std::max(_toolbarStyle.toolbar.borderWidth() + _toolbarStyle.frame_margin, 1u); // load slit style _slitStyle.slit = bt::textureResource(display, screen_num, res, "slit", "Slit", _toolbarStyle.toolbar); _slitStyle.margin = res.read("slit.marginWidth", "Slit.MarginWidth", 2); const std::string rc_file = screen->blackbox()->resource().rcFilename(); root_command = bt::Resource(rc_file).read("rootCommand", "RootCommand", res.read("rootCommand", "RootCommand")); // sanity checks bt::Texture flat_black; flat_black.setDescription("flat solid"); flat_black.setColor1(bt::Color(0, 0, 0)); if (_windowStyle.focus.title.texture() == bt::Texture::Parent_Relative) _windowStyle.focus.title = flat_black; if (_windowStyle.unfocus.title.texture() == bt::Texture::Parent_Relative) _windowStyle.unfocus.title = flat_black; if (_windowStyle.focus.handle.texture() == bt::Texture::Parent_Relative) _windowStyle.focus.handle = flat_black; if (_windowStyle.unfocus.handle.texture() == bt::Texture::Parent_Relative) _windowStyle.unfocus.handle = flat_black; if (_windowStyle.focus.grip.texture() == bt::Texture::Parent_Relative) _windowStyle.focus.grip = flat_black; if (_windowStyle.unfocus.grip.texture() == bt::Texture::Parent_Relative) _windowStyle.unfocus.grip = flat_black; if (_toolbarStyle.toolbar.texture() == bt::Texture::Parent_Relative) _toolbarStyle.toolbar = flat_black; if (_slitStyle.slit.texture() == bt::Texture::Parent_Relative) _slitStyle.slit = flat_black; } const bt::ustring ScreenResource::workspaceName(unsigned int i) const { // handle both requests for new workspaces beyond what we started with // and for those that lack a name if (i > workspace_count || i >= workspace_names.size()) return bt::ustring(); return workspace_names[i]; } void ScreenResource::setWorkspaceName(unsigned int i, const bt::ustring &name) { if (i >= workspace_names.size()) { workspace_names.reserve(i + 1); workspace_names.insert(workspace_names.begin() + i, name); } else { workspace_names[i] = name; } }
C++
CL
45b06bdbb2c6451274462f154d2c1471af57be66c31645eb72724940b8968142
#pragma once #include <chrono> #include <ctime> #include <string> namespace timer { struct TimerClock { // Constants static time_t const NULL_TIME = 0; static time_t const MIN_TIME = -2209013206; static time_t const MAX_TIME = 253402271999; // Format a datetime to %Y-%m-%d %H:%M:%S %z static std::string format(time_t dateTime); // Format a duration in seconds as HH:MM:SS static std::string format(std::chrono::seconds duration); // Convert seconds to hours static float toHours(std::chrono::seconds seconds); // Parse a date in %Y-%m-%d format (throws for bad values) static time_t parseDate(const std::string &dateTime); // Parse a month, and optionally year from a string (throws for bad values) static time_t parseMonthYear(const std::string &dateTime); // Find the date of the end of the month for a given value static time_t endOfMonth(const time_t date); }; } // namespace timer
C++
CL
e4485d1b96bc24cf996370794feaf01ae850fbf47ab3a7fe628cf5546246202b
#pragma once #include <SFML/Graphics.hpp> #include <map> enum class eNODE_STATE { NONE = -1, BLANK, WALL, START, END, COUNT }; enum class eNODE_PATH_TYPE { NONE = -1, GRASS, WATER, SAND, COUNT }; class Node { public: Node(sf::Vector2f pos, sf::Vector2f size); Node(sf::Vector2f pos, sf::Vector2f size, eNODE_PATH_TYPE initState, bool wall); ~Node(); /** * @brief Initialices the node with a position and size * @param pos: the position in the world * @param size: the size of the node * @bug No know Bugs */ void Init(sf::Vector2f pos, sf::Vector2f size); /** * @brief Initialices the node with a position, size, state and if it has a wall * @param pos: the position in the world * @param size: the size of the node * @param initState: the initial state of the node * @param wall: has a wall? * @bug No know Bugs */ void Init(sf::Vector2f pos, sf::Vector2f size, eNODE_PATH_TYPE initState, bool wall); /** * @brief Updates the node every frame. * @param window: the window where it is placed. Neded for the mouse position * @bug No know Bugs */ void Update(sf::RenderWindow* window); /** * @brief Renderss the node every frame. * @param window: the window where it is rendered to. * @bug No know Bugs */ void Render(sf::RenderWindow* window); /** * @brief Frees the memory * @bug No know Bugs */ void Destroy(); /** * @brief Changes the state type of the node, and its color or texture * @param state: the new state * @bug No know Bugs */ void ChangeState(eNODE_STATE state); /** * @brief Changes the tile type of the node, and its color or texture * @param type: the new type * @bug No know Bugs */ void ChangeTileType(eNODE_PATH_TYPE type); /** * @brief Changes the temp state type of the node, and its color or texture * @param state: the new temp state * @bug No know Bugs */ void ChangeTempState(eNODE_STATE state); /** * @brief Returns the state type of the node, and its color or texture * @bug No know Bugs */ eNODE_STATE GetState(); /** * @brief Returns the tile type of the node, and its color or texture * @bug No know Bugs */ eNODE_PATH_TYPE GetTileType(); /** * @brief Returns the temp state type of the node, and its color or texture * @bug No know Bugs */ eNODE_STATE GetTempState(); /** * @brief Returns the positions in the world of the node * @bug No know Bugs */ sf::Vector2f GetPosition(); /** * @brief Returns the size of the node * @bug No know Bugs */ sf::Vector2f GetSize(); /** * @brief Sets a new color for the node * @param color: the new color * @bug No know Bugs */ void SetColor(sf::Color color); /** * @brief Sets a new parent for the node * @param parent: the new parent * @bug No know Bugs */ void SetParent(Node* parent); /** * @brief Has the node been searched yet? * @bug No know Bugs */ void Searched(); /** * @brief Restart the search state of the node * @bug No know Bugs */ void RestartSearch(); /** * @brief Restart all the states, walls and search of the node. * @bug No know Bugs */ void RestartAll(); /** * @brief Has to show the lines of the node? * @param active: yes/no * @bug No know Bugs */ void ShowLines(bool active); public: Node* m_up = nullptr; float m_upWeight = 0; Node* m_right = nullptr; float m_rightWeight = 0; Node* m_down = nullptr; float m_downWeight = 0; Node* m_left = nullptr; float m_leftWeight = 0; Node* m_parent = nullptr; float m_parentWeight = 0; bool m_searched = false; int m_facesSeen = 0; float m_ucledianDistance = 0; private: sf::RectangleShape m_shape; sf::RectangleShape m_wall; eNODE_STATE m_state = eNODE_STATE::NONE; eNODE_STATE m_tempSate = eNODE_STATE::BLANK; eNODE_PATH_TYPE m_pathType = eNODE_PATH_TYPE::NONE; static std::map<eNODE_STATE, sf::Color> m_colors; };
C++
CL
3bf84a59bdff6fd3339537027b3b70cecc8c56844a1073d290228e1ed26a68d3
# pragma once # include "Core/ModuleBase.h" # include "Motor.h" namespace Menge { class ModuleMotor : public ModuleBase { public: ModuleMotor(); ~ModuleMotor(); public: MotorPtr createMotor(); public: bool _initialize() override; void _finalize() override; public: void _update( float _time, float _timing ) override; void _render( const RenderObjectState * _state, unsigned int _debugMask ) override; protected: typedef stdex::vector<MotorPtr> TVectorMotors; TVectorMotors m_motors; }; }
C++
CL
f634105269056bcb27a174eb9815b7f1b05507d767838d9d2aad43f3bbd5912b
/** * Hello, this is BjarneClient, a free and open implementation of Accumulo * and big table. This is meant to be the client that accesses Accumulo * and BjarneTable -- the C++ implemenation of Accumulo. Copyright (C) * 2013 -- Marc Delta Poppa @ accumulo.net * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ #include <iostream> #include "Results.h" #include "TypedResults.h" using namespace std; using namespace scanners; int main() { Results<int,ResultBlock<int> > res; res.add(34); res.add(6); res.add(9); res.add(3); Results<int,ResultBlock<int>>::iterator iter = res.begin(); TypedResults<int,float> riter(&iter); TypedResults<float,double> titer(&riter); ///* for (; titer != titer.end(); titer++) { cout << "Value " << (*titer) << endl; } // */ /* for (; riter != riter.end(); riter++) { cout << "Value " << (*riter) << endl; } */ }
C++
CL
7445e2fe0b4b496865a479f4257d8431f6f2386d1c47d1d086b803310956b742
// stdafx.cpp : 只包括标准包含文件的源文件 // chinesechess.pch 将作为预编译头 // stdafx.obj 将包含预编译类型信息 #include "stdafx.h" #include "Managers.h" Managers manager;
C++
CL
0c3acd49ae0e4164182db97cafd67cc3aca0f6ff8ec212ed4719dd552b10a696
#pragma once #include "Master.h" #define SIMPLE_SYSTEM_SLAVE_CONTROL Class_ID(0x7acd61ca, 0x5f954622) namespace SimpleSystem { /*************************** Class Descriptor Related **************************/ ClassDesc2* getSlaveDescriptor(); class SlaveControlClassDesc : public ClassDesc2 { public: int IsPublic() override; void* Create(BOOL loading) override; const wchar_t* ClassName() override; SClass_ID SuperClassID() override; Class_ID ClassID() override; const wchar_t* Category() override; }; /*************************** Class Related ************************************/ //[Controller API Elements](http://help.autodesk.com/view/3DSMAX/2017/ENU/?guid=__files_GUID_5A09D1BA_9881_495B_B9A3_F7C9FAD8B536_htm) //Also check [ISurfPosition Class ](http://help.autodesk.com/view/3DSMAX/2017/ENU/?guid=__cpp_ref_class_i_surf_position_html) class SlaveControl: public Control { public: SlaveControl(bool loading = false); SlaveControl(Master*, int); virtual ~SlaveControl(); SlaveControl(const SlaveControl&); SlaveControl& operator=(const SlaveControl&); void SetID(ULONG); // From Control void Copy(Control* from) override; void GetValue(TimeValue t, void* val, Interval& valid, GetSetMethod method = CTRL_ABSOLUTE) override; void SetValue(TimeValue t, void* val, int commit, GetSetMethod method = CTRL_ABSOLUTE) override; BOOL IsLeaf() override; BOOL CanCopyAnim() override; BOOL IsReplaceable() override; void* GetInterface(ULONG id) override; int NumSubs() override; Animatable* SubAnim(int i) override; MSTR SubAnimName(int i) override; int IsKeyable() override; // From Animatable void GetClassName(MSTR& s) override; Class_ID ClassID() override; SClass_ID SuperClassID() override; void DeleteThis() override; void BeginEditParams(IObjParam* ip, ULONG flags, Animatable* prev) override; void EndEditParams(IObjParam* ip, ULONG flags, Animatable* next) override; // From Reference Target RefTargetHandle Clone(RemapDir& remap) override; int NumRefs() override; RefTargetHandle GetReference(int i) override; protected: void SetReference(int i, RefTargetHandle rtarg) override; RefResult NotifyRefChanged(const Interval& changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate) override; private: Master* master; ULONG id; }; }
C++
CL
82d62a577a2f7876f64b34f4254bcfa6dd6c175c23600211717ae6a75106e73c
/****************************************************************************** # Copyright (c) 2019 Qualcomm Technologies, Inc. # All Rights Reserved. # Confidential and Proprietary - Qualcomm Technologies, Inc. #******************************************************************************/ #pragma once #include <interfaces/QcRilRequestMessage.h> #include "framework/add_message_id.h" /* * Request to update ADN records message on SIM card * @Receiver: PbmModule * * Response: * errorCode : Valid error codes * SUCCESS * GENERIC_FAILURE * responseData : std::shared_ptr<qcril::interfaces::AdnRecordUpdatedResp> */ class QcRilRequestUpdateAdnRecordMessage : public QcRilRequestMessage, public add_message_id<QcRilRequestUpdateAdnRecordMessage> { public: static constexpr const char *MESSAGE_NAME = "QCRIL_EVT_HOOK_UPDATE_ADN_RECORD"; QcRilRequestUpdateAdnRecordMessage() = delete; ~QcRilRequestUpdateAdnRecordMessage() {}; explicit QcRilRequestUpdateAdnRecordMessage( std::shared_ptr<MessageContext> context, const qcril::interfaces::AdnRecordInfo & recordData): QcRilRequestMessage(get_class_message_id(), context) { mName = MESSAGE_NAME; mRecordData = recordData; } const qcril::interfaces::AdnRecordInfo& getRecordData() { return mRecordData; }; virtual string dump() { return QcRilRequestMessage::dump() + "{" + "record id = " + std::to_string(mRecordData.record_id) + ", name = " + mRecordData.name + ", number = " + mRecordData.number + "}"; } private: qcril::interfaces::AdnRecordInfo mRecordData; };
C++
CL
d6002d27287b29c7083e419a3f52f3105c7c67e719ffff6b54fe5185f23b660e
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <memory> #include <utility> #include "base/bind.h" #include "base/command_line.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/run_loop.h" #include "base/unguessable_token.h" #include "content/browser/frame_host/navigation_request_info.h" #include "content/browser/loader/navigation_url_loader.h" #include "content/browser/loader/prefetched_signed_exchange_cache.h" #include "content/browser/loader/resource_dispatcher_host_impl.h" #include "content/browser/loader/test_resource_handler.h" #include "content/browser/loader_delegate_impl.h" #include "content/common/navigation_params.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/navigation_ui_data.h" #include "content/public/browser/resource_context.h" #include "content/public/browser/resource_dispatcher_host_delegate.h" #include "content/public/browser/storage_partition.h" #include "content/public/common/content_switches.h" #include "content/public/test/test_browser_context.h" #include "content/public/test/test_browser_thread_bundle.h" #include "content/test/test_navigation_url_loader_delegate.h" #include "net/base/load_flags.h" #include "net/base/net_errors.h" #include "net/cert/cert_status_flags.h" #include "net/http/http_response_headers.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "net/url_request/redirect_info.h" #include "net/url_request/url_request.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_job_factory_impl.h" #include "net/url_request/url_request_test_job.h" #include "net/url_request/url_request_test_util.h" #include "services/network/public/cpp/features.h" #include "services/network/public/mojom/network_context.mojom.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/origin.h" namespace content { namespace { std::unique_ptr<ResourceHandler> CreateTestResourceHandler( net::URLRequest* request) { return std::make_unique<TestResourceHandler>(); } } // namespace class NavigationURLLoaderTest : public testing::Test { public: NavigationURLLoaderTest() : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP), browser_context_(new TestBrowserContext), host_(base::BindRepeating(&CreateTestResourceHandler), base::ThreadTaskRunnerHandle::Get(), /* enable_resource_scheduler */ true) { host_.SetLoaderDelegate(&loader_delegate_); BrowserContext::EnsureResourceContextInitialized(browser_context_.get()); base::RunLoop().RunUntilIdle(); net::URLRequestContext* request_context = browser_context_->GetRequestContext()->GetURLRequestContext(); // Attach URLRequestTestJob. job_factory_.SetProtocolHandler( "test", net::URLRequestTestJob::CreateProtocolHandler()); request_context->set_job_factory(&job_factory_); } std::unique_ptr<NavigationURLLoader> MakeTestLoader( const GURL& url, NavigationURLLoaderDelegate* delegate) { return CreateTestLoader(url, delegate); } std::unique_ptr<NavigationURLLoader> CreateTestLoader( const GURL& url, NavigationURLLoaderDelegate* delegate) { mojom::BeginNavigationParamsPtr begin_params = mojom::BeginNavigationParams::New( std::string() /* headers */, net::LOAD_NORMAL, false /* skip_service_worker */, blink::mojom::RequestContextType::LOCATION, blink::WebMixedContentContextType::kBlockable, false /* is_form_submission */, false /* was_initiated_by_link_click */, GURL() /* searchable_form_url */, std::string() /* searchable_form_encoding */, GURL() /* client_side_redirect_url */, base::nullopt /* devtools_initiator_info */); CommonNavigationParams common_params; common_params.url = url; common_params.initiator_origin = url::Origin::Create(url); std::unique_ptr<NavigationRequestInfo> request_info( new NavigationRequestInfo(common_params, std::move(begin_params), url, url::Origin::Create(url), true, false, false, -1, false, false, false, false, nullptr, base::UnguessableToken::Create(), base::UnguessableToken::Create())); return NavigationURLLoader::Create( browser_context_->GetResourceContext(), BrowserContext::GetDefaultStoragePartition(browser_context_.get()), std::move(request_info), nullptr, nullptr, nullptr, nullptr, delegate); } // Helper function for fetching the body of a URL to a string. std::string FetchURL(const GURL& url) { net::TestDelegate delegate; net::URLRequestContext* request_context = browser_context_->GetRequestContext()->GetURLRequestContext(); std::unique_ptr<net::URLRequest> request(request_context->CreateRequest( url, net::DEFAULT_PRIORITY, &delegate, TRAFFIC_ANNOTATION_FOR_TESTS)); request->Start(); base::RunLoop().Run(); EXPECT_TRUE(request->status().is_success()); EXPECT_EQ(200, request->response_headers()->response_code()); return delegate.data_received(); } protected: TestBrowserThreadBundle thread_bundle_; net::URLRequestJobFactoryImpl job_factory_; std::unique_ptr<TestBrowserContext> browser_context_; LoaderDelegateImpl loader_delegate_; ResourceDispatcherHostImpl host_; }; // Tests that request failures are propagated correctly. TEST_F(NavigationURLLoaderTest, RequestFailedNoCertError) { TestNavigationURLLoaderDelegate delegate; std::unique_ptr<NavigationURLLoader> loader = MakeTestLoader(GURL("bogus:bogus"), &delegate); // Wait for the request to fail as expected. delegate.WaitForRequestFailed(); EXPECT_EQ(net::ERR_ABORTED, delegate.net_error()); EXPECT_FALSE(delegate.ssl_info().is_valid()); EXPECT_EQ(1, delegate.on_request_handled_counter()); } // Tests that request failures are propagated correctly for a (non-fatal) cert // error: // - |ssl_info| has the expected values. TEST_F(NavigationURLLoaderTest, RequestFailedCertError) { net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_MISMATCHED_NAME); ASSERT_TRUE(https_server.Start()); TestNavigationURLLoaderDelegate delegate; std::unique_ptr<NavigationURLLoader> loader = MakeTestLoader(https_server.GetURL("/"), &delegate); // Wait for the request to fail as expected. delegate.WaitForRequestFailed(); ASSERT_EQ(net::ERR_ABORTED, delegate.net_error()); net::SSLInfo ssl_info = delegate.ssl_info(); EXPECT_TRUE(ssl_info.is_valid()); EXPECT_TRUE( https_server.GetCertificate()->EqualsExcludingChain(ssl_info.cert.get())); EXPECT_EQ(net::ERR_CERT_COMMON_NAME_INVALID, net::MapCertStatusToNetError(ssl_info.cert_status)); EXPECT_FALSE(ssl_info.is_fatal_cert_error); EXPECT_EQ(1, delegate.on_request_handled_counter()); } // Tests that request failures are propagated correctly for a fatal cert error: // - |ssl_info| has the expected values. TEST_F(NavigationURLLoaderTest, RequestFailedCertErrorFatal) { net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_MISMATCHED_NAME); ASSERT_TRUE(https_server.Start()); GURL url = https_server.GetURL("/"); // Set HSTS for the test domain in order to make SSL errors fatal. base::Time expiry = base::Time::Now() + base::TimeDelta::FromDays(1000); bool include_subdomains = false; if (base::FeatureList::IsEnabled(network::features::kNetworkService)) { auto* storage_partition = BrowserContext::GetDefaultStoragePartition(browser_context_.get()); base::RunLoop run_loop; storage_partition->GetNetworkContext()->AddHSTS( url.host(), expiry, include_subdomains, run_loop.QuitClosure()); run_loop.Run(); } else { net::TransportSecurityState* transport_security_state = browser_context_->GetRequestContext() ->GetURLRequestContext() ->transport_security_state(); transport_security_state->AddHSTS(url.host(), expiry, include_subdomains); } TestNavigationURLLoaderDelegate delegate; std::unique_ptr<NavigationURLLoader> loader = MakeTestLoader(url, &delegate); // Wait for the request to fail as expected. delegate.WaitForRequestFailed(); ASSERT_EQ(net::ERR_ABORTED, delegate.net_error()); net::SSLInfo ssl_info = delegate.ssl_info(); EXPECT_TRUE(ssl_info.is_valid()); EXPECT_TRUE( https_server.GetCertificate()->EqualsExcludingChain(ssl_info.cert.get())); EXPECT_EQ(net::ERR_CERT_COMMON_NAME_INVALID, net::MapCertStatusToNetError(ssl_info.cert_status)); EXPECT_TRUE(ssl_info.is_fatal_cert_error); EXPECT_EQ(1, delegate.on_request_handled_counter()); } // Tests that the destroying the loader cancels the request. TEST_F(NavigationURLLoaderTest, CancelOnDestruct) { // Specific to non-NetworkService path. if (base::FeatureList::IsEnabled(network::features::kNetworkService)) return; // Fake a top-level request. Choose a URL which redirects so the request can // be paused before the response comes in. TestNavigationURLLoaderDelegate delegate; std::unique_ptr<NavigationURLLoader> loader = MakeTestLoader( net::URLRequestTestJob::test_url_redirect_to_url_2(), &delegate); // Wait for the request to redirect. delegate.WaitForRequestRedirected(); // Destroy the loader and verify that URLRequestTestJob no longer has anything // paused. loader.reset(); base::RunLoop().RunUntilIdle(); EXPECT_FALSE(net::URLRequestTestJob::ProcessOnePendingMessage()); } // Test that the delegate is not called if OnResponseStarted and destroying the // loader race. TEST_F(NavigationURLLoaderTest, CancelResponseRace) { // Specific to non-NetworkService path. if (base::FeatureList::IsEnabled(network::features::kNetworkService)) return; TestNavigationURLLoaderDelegate delegate; std::unique_ptr<NavigationURLLoader> loader = MakeTestLoader( net::URLRequestTestJob::test_url_redirect_to_url_2(), &delegate); // Wait for the request to redirect. delegate.WaitForRequestRedirected(); // In the same event loop iteration, follow the redirect (allowing the // response to go through) and destroy the loader. loader->FollowRedirect({}, {}, PREVIEWS_OFF); loader.reset(); // Verify the URLRequestTestJob no longer has anything paused and that no // response body was received. base::RunLoop().RunUntilIdle(); EXPECT_FALSE(net::URLRequestTestJob::ProcessOnePendingMessage()); EXPECT_FALSE(delegate.has_url_loader_client_endpoints()); } // Tests that the loader may be canceled by context. TEST_F(NavigationURLLoaderTest, CancelByContext) { // Specific to non-NetworkService path. if (base::FeatureList::IsEnabled(network::features::kNetworkService)) return; TestNavigationURLLoaderDelegate delegate; std::unique_ptr<NavigationURLLoader> loader = MakeTestLoader( net::URLRequestTestJob::test_url_redirect_to_url_2(), &delegate); // Wait for the request to redirect. delegate.WaitForRequestRedirected(); // Cancel all requests. host_.CancelRequestsForContext(browser_context_->GetResourceContext()); // Wait for the request to now be aborted. delegate.WaitForRequestFailed(); EXPECT_EQ(net::ERR_ABORTED, delegate.net_error()); EXPECT_EQ(1, delegate.on_request_handled_counter()); } // Tests that the request stays alive as long as the URLLoaderClient endpoints // are not destructed. TEST_F(NavigationURLLoaderTest, OwnedByHandle) { // Specific to non-NetworkService path. if (base::FeatureList::IsEnabled(network::features::kNetworkService)) return; // Fake a top-level request to a URL whose body does not load immediately. TestNavigationURLLoaderDelegate delegate; std::unique_ptr<NavigationURLLoader> loader = MakeTestLoader(net::URLRequestTestJob::test_url_2(), &delegate); // Wait for the response to come back. delegate.WaitForResponseStarted(); // Proceed with the response. loader->ProceedWithResponse(); // Release the URLLoaderClient endpoints. delegate.ReleaseURLLoaderClientEndpoints(); base::RunLoop().RunUntilIdle(); // Verify that URLRequestTestJob no longer has anything paused. EXPECT_FALSE(net::URLRequestTestJob::ProcessOnePendingMessage()); } } // namespace content
C++
CL
5303dae533d50582cbd0188f4854210649ae1d2cf4d318f625e7b5b23ba7103b
#pragma once #include "FoliageGroup.h" DECLARE_DELEGATE_OneParam(FTileTaskResultDelegate, FTileTaskResult); class LANDSCAPE_1_API FCalculateTileTask : public FNonAbandonableTask { friend class FAutoDeleteAsyncTask<FCalculateTileTask>; public: FCalculateTileTask(FVector location, int tileIndex, TArray<FFoliageGroup> groups, float tileSize, uint32 seed, FTileTaskResultDelegate taskResultDelegate) { Location = location; TileIndex = tileIndex; Groups = groups; TileSize = tileSize; Seed = seed; TaskResultDelegate = taskResultDelegate; } protected: FVector Location; int TileIndex; TArray<FFoliageGroup> Groups; float TileSize; uint32 Seed; FTileTaskResultDelegate TaskResultDelegate; void DoWork(); FORCEINLINE TStatId GetStatId() const { RETURN_QUICK_DECLARE_CYCLE_STAT(FCalculateTileTask, STATGROUP_ThreadPoolAsyncTasks); } private: float GetFallOffSpawnChance(FFoliageGroupSpawnNoise& noise, float noiseValue); FItemSpawnSpace CalculateSpawnSpace(GridArrayType& collisionGrid, int size, int x, int y, int spacing); void Spawn(GridArrayType& collisionGrid, int size, int x, int y, int width); };
C++
CL
5663e095c5fb617d9a19f1482f343b7846502a6b3521a400e5ee2ddde90be9a0
/* /* !@ MIT License Copyright (c) 2020 Skylicht Technology CO., LTD Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the Rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. This file is part of the "Skylicht Engine". https://github.com/skylicht-lab/skylicht-engine !# */ #pragma once #include "SkylichtEngine.h" #include "Editor/Space/CSpace.h" #include "Editor/Components/CComponentEditor.h" #include "Editor/AssetEditor/CAssetEditor.h" #include "Editor/EntityData/CEntityDataEditor.h" #include "Editor/GUIEditor/CGUIEditor.h" #include "Reactive/CSubject.h" #include "Reactive/CObserver.h" #include "CAddComponentController.h" namespace Skylicht { namespace Editor { class CSpaceProperty : public CSpace { public: struct SGroup { CComponentEditor* Owner; CAssetEditor* AssetOwner; CEntityDataEditor* EntityDataOwner; CGUIEditor* GUIEditorOwner; GUI::CBase* GroupUI; SGroup() { Owner = NULL; AssetOwner = NULL; GroupUI = NULL; EntityDataOwner = NULL; GUIEditorOwner = NULL; } }; protected: GUI::CBase* m_content; GUI::CIcon* m_icon; GUI::CLabel* m_label; GUI::CButton* m_labelButton; GUI::CMenu* m_addComponentMenu; CAddComponentController* m_addComponentController; GUI::CMenu* m_componentContextMenu; GUI::CMenuItem* m_menuUp; GUI::CMenuItem* m_menuDown; GUI::CMenuItem* m_menuRemove; CComponentEditor* m_menuContextEditor; std::vector<SGroup*> m_groups; std::vector<CComponentEditor*> m_releaseComponents; std::wstring m_tempName; public: CSpaceProperty(GUI::CWindow* window, CEditor* editor); virtual ~CSpaceProperty(); void OnComponentCommand(GUI::CBase* base); virtual void update(); virtual void refresh(); void addNumberInput(GUI::CBoxLayout* boxLayout, const wchar_t* name, CSubject<float>* value, float step); void addNumberInput(GUI::CBoxLayout* boxLayout, const wchar_t* name, CSubject<int>* value, int step = 1); void addNumberInput(GUI::CBoxLayout* boxLayout, const wchar_t* name, CSubject<u32>* value, int step = 1); void addTextBox(GUI::CBoxLayout* boxLayout, const wchar_t* name, CSubject<std::wstring>* value); void addNumberTextBox(GUI::CBoxLayout* boxLayout, const wchar_t* name, CSubject<int>* value); void addCheckBox(GUI::CBoxLayout* boxLayout, const wchar_t* name, CSubject<bool>* value); void addComboBox(GUI::CBoxLayout* boxLayout, const wchar_t* name, CSubject<std::wstring>* value, const std::vector<std::wstring>& listValue); void addSlider(GUI::CBoxLayout* boxLayout, const wchar_t* name, CSubject<float>* value, float min, float max); void addColorPicker(GUI::CBoxLayout* boxLayout, const wchar_t* name, CSubject<SColor>* value); void addInputFile(GUI::CBoxLayout* boxLayout, const wchar_t* name, CSubject<std::string>* value, const std::vector<std::string>& exts); void addInputFolder(GUI::CBoxLayout* boxLayout, const wchar_t* name, CSubject<std::string>* value); GUI::CImageButton* addInputTextureFile(GUI::CBoxLayout* boxLayout, const wchar_t* name, CSubject<std::string>* value); GUI::CLabel* addLabel(GUI::CBoxLayout* boxLayout, const wchar_t* label, GUI::ETextAlign align = GUI::TextCenter); GUI::CButton* addButton(GUI::CBoxLayout* boxLayout, const wchar_t* label); GUI::CDropdownBox* addDropBox(GUI::CBoxLayout* boxLayout, const wchar_t* name, const std::wstring& value); GUI::CCollapsibleGroup* addSubGroup(GUI::CBoxLayout* boxLayout); inline void setLabel(const wchar_t* label) { m_label->setString(label); m_label->setHidden(false); m_labelButton->setHidden(true); } inline GUI::CButton* setButtonLabel(const wchar_t* label) { m_labelButton->setLabel(label); m_labelButton->setHidden(false); m_labelButton->sizeToContents(); m_label->setHidden(true); m_icon->setHidden(true); return m_labelButton; } inline void setIcon(GUI::ESystemIcon icon) { m_icon->setIcon(icon); m_icon->setHidden(false); } GUI::CCollapsibleGroup* addGroup(const wchar_t* label, CComponentEditor* editor); GUI::CCollapsibleGroup* addGroup(const wchar_t* label, CAssetEditor* editor); GUI::CCollapsibleGroup* addGroup(const wchar_t* label, CEntityDataEditor* editor); GUI::CCollapsibleGroup* addGroup(const wchar_t* label, CGUIEditor* editor); GUI::CCollapsibleGroup* addGroup(const char* label, CComponentEditor* editor); GUI::CCollapsibleGroup* addGroup(const char* label, CAssetEditor* editor); GUI::CCollapsibleGroup* addGroup(const char* label, CEntityDataEditor* editor); GUI::CCollapsibleGroup* addGroup(const char* label, CGUIEditor* editor); GUI::CButton* addButton(const wchar_t* label); void popupComponentMenu(CGameObject* gameObject, GUI::CBase* position); void addComponent(CComponentEditor* editor, CComponentSystem* component, bool autoRelease = false); void addComponent(CComponentEditor* editor, CGameObject* gameobject); void addAsset(CAssetEditor* editor, const char* path); void addEntityData(CEntityDataEditor* editor, IEntityData* entityData); void addGUIEditor(CGUIEditor* editor, CGUIElement* gui); void clearAllGroup(); SGroup* getGroupByLayout(GUI::CBoxLayout* layout); GUI::CBoxLayout* createBoxLayout(GUI::CCollapsibleGroup* group); const wchar_t* getPrettyName(const std::string& paramName); }; } }
C++
CL
a844c443d8e2b8bb8959e45de58b5dae61c9f13890cd72fa35c9ae1c9574a673
#define __DEBUG_MODULE_IN_USE__ CIC_DEVICEDESCRIPTIONS_CPP #include "stdhdrs.h" // @doc /********************************************************************** * * @module DeviceDescriptions.cpp | * * Tables for parsing HID on specific devices * * History * ---------------------------------------------------------- * Mitchell S. Dernis Original * * (c) 1986-1998 Microsoft Corporation. All right reserved. * * **********************************************************************/ using namespace ControlItemConst; #define HID_USAGE_RESERVED (static_cast<USAGE>(0)) // // Freestyle Pro - Modifier Table // MODIFIER_ITEM_DESC rgFSModifierItems[] = { { HID_USAGE_PAGE_BUTTON, (USAGE)10, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 6, ControlItemConst::ucReportTypeInput, 0}, { ControlItemConst::HID_VENDOR_PAGE, ControlItemConst::HID_VENDOR_TILT_SENSOR, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 0, ControlItemConst::ucReportTypeInput, 0} }; MODIFIER_DESC_TABLE FSModifierDescTable = { 2, 1, rgFSModifierItems}; // // Freestyle Pro - Axes range table // AXES_RANGE_TABLE FSAxesRangeTable = { -512L, 0L, 511L, -512L, 0L, 511L, -256L, 256L, -256L, 256L}; // // Freestyle Pro - List of ControlItemDesc // RAW_CONTROL_ITEM_DESC rgFSControlItems[] = { {1L, usButton, HID_USAGE_PAGE_BUTTON, 1, HID_USAGE_GENERIC_POINTER, HID_USAGE_PAGE_GENERIC, 1, 4, &FSModifierDescTable, (USAGE)1, (USAGE)4, 0L, 0L}, {2L, usButton, HID_USAGE_PAGE_BUTTON, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 1, 6, &FSModifierDescTable, (USAGE)5, (USAGE)9, 0L, 0L}, {3L, usPOV, HID_USAGE_PAGE_GENERIC, 1, HID_USAGE_GENERIC_POINTER, HID_USAGE_PAGE_GENERIC, 4, 1, &FSModifierDescTable, HID_USAGE_GENERIC_HATSWITCH, HID_USAGE_RESERVED, 0L, 7L}, {4L, usPropDPAD, HID_USAGE_PAGE_GENERIC, 1, HID_USAGE_GENERIC_POINTER, HID_USAGE_PAGE_GENERIC, 10, 1, &FSModifierDescTable, HID_USAGE_GENERIC_X, HID_USAGE_GENERIC_Y, (LONG)&FSAxesRangeTable, 0L}, {5L, usThrottle, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 6, 1, &FSModifierDescTable, HID_USAGE_GENERIC_SLIDER, HID_USAGE_RESERVED, -32L, 31L} }; // // Precision Pro - Modifier Table // MODIFIER_ITEM_DESC rgPPModifierItems[] = { { HID_USAGE_PAGE_BUTTON, (USAGE)9, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 5, ControlItemConst::ucReportTypeInput, 0} }; MODIFIER_DESC_TABLE PPModifierDescTable = { 1, 1, rgPPModifierItems}; // // Precision Pro - Axes range table // AXES_RANGE_TABLE PPAxesRangeTable = { -512L, 0L, 511L, -512L, 0L, 511L, -256L, 256L, -256L, 256L}; // // Precision Pro - List of ControlItemDesc // RAW_CONTROL_ITEM_DESC rgPPControlItems[] = { {1L, usButton, HID_USAGE_PAGE_BUTTON, 1, HID_USAGE_GENERIC_POINTER, HID_USAGE_PAGE_GENERIC, 1, 4, &PPModifierDescTable, (USAGE)1, (USAGE)4, 0L, 0L}, {2L, usButton, HID_USAGE_PAGE_BUTTON, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 1, 5, &PPModifierDescTable, (USAGE)5, (USAGE)8, 0L, 0L}, {3L, usPOV, HID_USAGE_PAGE_GENERIC, 1, HID_USAGE_GENERIC_POINTER, HID_USAGE_PAGE_GENERIC, 4, 1, &PPModifierDescTable, HID_USAGE_GENERIC_HATSWITCH, HID_USAGE_RESERVED, 0L, 7L}, {4L, usAxes, HID_USAGE_PAGE_GENERIC, 1, HID_USAGE_GENERIC_POINTER, HID_USAGE_PAGE_GENERIC, 10, 1, &PPModifierDescTable, HID_USAGE_GENERIC_X, HID_USAGE_GENERIC_Y, (LONG)&PPAxesRangeTable, 0L}, {5L, usRudder, HID_USAGE_PAGE_GENERIC, 1, HID_USAGE_GENERIC_POINTER, HID_USAGE_PAGE_GENERIC, 6, 1, &PPModifierDescTable, HID_USAGE_GENERIC_RZ, HID_USAGE_RESERVED, -32L, 31L}, {6L, usThrottle, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 7, 1, &PPModifierDescTable, HID_USAGE_GENERIC_SLIDER, HID_USAGE_RESERVED, -64L, 63L} }; // // Zorro - Modifier Table // MODIFIER_ITEM_DESC rgZRModifierItems[] = { { HID_USAGE_PAGE_BUTTON, (USAGE)9, 0, HID_USAGE_GENERIC_GAMEPAD, HID_USAGE_PAGE_GENERIC, 9, ControlItemConst::ucReportTypeInput, 0}, { ControlItemConst::HID_VENDOR_PAGE, ControlItemConst::HID_VENDOR_PROPDPAD_MODE, 0, HID_USAGE_GENERIC_GAMEPAD, HID_USAGE_PAGE_GENERIC, 1, ControlItemConst::ucReportTypeInput, 0}, { ControlItemConst::HID_VENDOR_PAGE, ControlItemConst::HID_VENDOR_PROPDPAD_SWITCH, 2, 0, ControlItemConst::HID_VENDOR_PAGE, 1, ControlItemConst::ucReportTypeFeatureRW, 0} }; MODIFIER_DESC_TABLE ZRModifierDescTable = { 3, 1, rgZRModifierItems}; // // Zorro - Axes range table // AXES_RANGE_TABLE ZRAxesRangeTable = { -128L, 0L, 127L, -128L, 0L, 127L, -64L, 64L, -64L, 64L}; // // Zorro - List of ControlItemDesc // RAW_CONTROL_ITEM_DESC rgZRControlItems[] = { {1L, usButton, HID_USAGE_PAGE_BUTTON, 0, HID_USAGE_GENERIC_GAMEPAD, HID_USAGE_PAGE_GENERIC, 1, 9, &ZRModifierDescTable, (USAGE)1, (USAGE)8, 0L, 0L}, {2L, usPropDPAD, HID_USAGE_PAGE_GENERIC, 1, HID_USAGE_GENERIC_POINTER, HID_USAGE_PAGE_GENERIC, 8, 1, &ZRModifierDescTable, HID_USAGE_GENERIC_X, HID_USAGE_GENERIC_Y, (LONG)&ZRAxesRangeTable, 0L} }; // // Zulu - Modifier Table // MODIFIER_ITEM_DESC rgZLModifierItems[] = { { HID_USAGE_PAGE_BUTTON, (USAGE)9, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 9, ControlItemConst::ucReportTypeInput, 0} }; MODIFIER_DESC_TABLE ZLModifierDescTable = { 1, 1, rgZLModifierItems}; // // Zulu - Axes range table // AXES_RANGE_TABLE ZLAxesRangeTable = { -512L, 0L, 511L, -512L, 0L, 511L, -256L, 256L, -256L, 256L}; // // Zulu - List of ControlItemDesc // RAW_CONTROL_ITEM_DESC rgZLControlItems[] = { {1L, usButton, HID_USAGE_PAGE_BUTTON, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 1, 9, &ZLModifierDescTable, (USAGE)1, (USAGE)8, 0L, 0L}, {2L, usPOV, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 4, 1, &ZLModifierDescTable, HID_USAGE_GENERIC_HATSWITCH, HID_USAGE_RESERVED, 0L, 7L}, {3L, usAxes, HID_USAGE_PAGE_GENERIC, 1, HID_USAGE_GENERIC_POINTER, HID_USAGE_PAGE_GENERIC, 10, 1, &ZLModifierDescTable, HID_USAGE_GENERIC_X, HID_USAGE_GENERIC_Y, (LONG)&ZLAxesRangeTable, 0L}, {4L, usZoneIndicator, ControlItemConst::HID_VENDOR_PAGE, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 1, 2, &ZLModifierDescTable, HID_VENDOR_ZONE_INDICATOR_X, HID_USAGE_RESERVED, 0x00000003, 0L} }; // // ZepLite - Modifier Table // MODIFIER_ITEM_DESC rgZPLModifierItems[] = { { ControlItemConst::HID_VENDOR_PAGE, ControlItemConst::HID_VENDOR_PEDALS_PRESENT, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 1, ControlItemConst::ucReportTypeInput, 0} }; MODIFIER_DESC_TABLE ZPLModifierDescTable = { 1, 0, rgZPLModifierItems}; // // ZepLite - List of ControlItemDesc // RAW_CONTROL_ITEM_DESC rgZPLControlItems[] = { {1L, usButton, HID_USAGE_PAGE_BUTTON, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 1, 8, &ZPLModifierDescTable, (USAGE)1, (USAGE)8, 0L, 0L}, {2L, usPedal, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 6, 1, &ZPLModifierDescTable, HID_USAGE_GENERIC_Y, HID_USAGE_RESERVED, 0L, 63L}, {3L, usPedal, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 6, 1, &ZPLModifierDescTable, HID_USAGE_GENERIC_RZ, HID_USAGE_RESERVED, 0L, 63L}, {4L, usWheel, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 10, 1, &ZPLModifierDescTable, HID_USAGE_GENERIC_X, HID_USAGE_RESERVED, -512L, 511L}, }; // // SparkyZep - Modifier Table // MODIFIER_ITEM_DESC rgSZPModifierItems[] = { { ControlItemConst::HID_VENDOR_PAGE, ControlItemConst::HID_VENDOR_PEDALS_PRESENT, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 1, ControlItemConst::ucReportTypeInput, 1} }; MODIFIER_DESC_TABLE SZPModifierDescTable = { 1, 0, rgSZPModifierItems}; // // SparkyZep - List of ControlItemDesc // RAW_CONTROL_ITEM_DESC rgSZPControlItems[] = { {1L, usButton, HID_USAGE_PAGE_BUTTON, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 1, 8, &SZPModifierDescTable, (USAGE)1, (USAGE)8, 0L, 0L}, {2L, usPedal, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 6, 1, &SZPModifierDescTable, HID_USAGE_GENERIC_Y, HID_USAGE_RESERVED, 0L, 63L}, {3L, usPedal, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 6, 1, &SZPModifierDescTable, HID_USAGE_GENERIC_RZ, HID_USAGE_RESERVED, 0L, 63L}, {4L, usWheel, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 10, 1, &SZPModifierDescTable, HID_USAGE_GENERIC_X, HID_USAGE_RESERVED, -512L, 511L}, {5L, usForceMap,HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 0, 0, &SZPModifierDescTable, 0, 0, 0L, 10000L} }; // // Tilt 2.0 TT2 // // // Mothra MOH // // // Mothra - Axes range table // AXES_RANGE_TABLE MOHAxesRangeTable = { 0L, 128L, 255L, 0L, 128L, 255L, 64L, 192L, 64L, 192L}; // // Mothra - List of ControlItemDesc // RAW_CONTROL_ITEM_DESC rgMOHControlItems[] = { {1L, usButton, HID_USAGE_PAGE_BUTTON, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 1, 8, NULL, (USAGE)1, (USAGE)8, 0L, 0L}, {2L, usAxes, HID_USAGE_PAGE_GENERIC, 1, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 8, 2, NULL, HID_USAGE_GENERIC_X, HID_USAGE_GENERIC_Y, (LONG)&MOHAxesRangeTable, 0L}, {3L, usRudder, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 8, 1, NULL, HID_USAGE_GENERIC_RZ, HID_USAGE_RESERVED, 0L, 255L}, {4L, usPOV, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_POINTER, HID_USAGE_PAGE_GENERIC, 4, 1, NULL, HID_USAGE_GENERIC_HATSWITCH, HID_USAGE_RESERVED, 0L, 7L}, {5L, usThrottle, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 7, 1, NULL, HID_USAGE_GENERIC_SLIDER, HID_USAGE_RESERVED, 0L, 255L} }; // // Godzilla GOD // Ungraciously ripped from Mothra! // TODO: The force feedback stuff needs to be added by MCOILL // // Godzilla - Axes range table // AXES_RANGE_TABLE GODAxesRangeTable = { -512L, 0L, 511L, -512L, 0L, 511L, -256L, 256L, -256L, 256L}; // // Godzilla - List of ControlItemDesc // RAW_CONTROL_ITEM_DESC rgGODControlItems[] = { {1L, usButton, HID_USAGE_PAGE_BUTTON, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 1, 8, NULL, (USAGE)1, (USAGE)8, 0L, 0L}, {2L, usAxes, HID_USAGE_PAGE_GENERIC, 1, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 10, 2, NULL, HID_USAGE_GENERIC_X, HID_USAGE_GENERIC_Y, (LONG)&GODAxesRangeTable, 0L}, {3L, usRudder, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 6, 1, NULL, HID_USAGE_GENERIC_RZ, HID_USAGE_RESERVED, -32L, 31L}, {4L, usPOV, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_POINTER, HID_USAGE_PAGE_GENERIC, 4, 1, NULL, HID_USAGE_GENERIC_HATSWITCH, HID_USAGE_RESERVED, 0L, 7L}, {5L, usThrottle, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 7, 1, NULL, HID_USAGE_GENERIC_SLIDER, HID_USAGE_RESERVED, 0L, 127L}, {6L, usForceMap, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 0, 0, NULL, 0, 0, 0L, 10000L } }; // // Attila - Modifier Table ATT // // There are three shift buttons. MODIFIER_ITEM_DESC rgATTModifierItems[] = { { HID_USAGE_PAGE_BUTTON, (USAGE) 9, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 15, ControlItemConst::ucReportTypeInput, 0}, { HID_USAGE_PAGE_BUTTON, (USAGE)10, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 15, ControlItemConst::ucReportTypeInput, 0}, { HID_USAGE_PAGE_BUTTON, (USAGE)11, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 15, ControlItemConst::ucReportTypeInput, 0} }; MODIFIER_DESC_TABLE ATTModifierDescTable = { 3, 3, rgATTModifierItems}; // // Attila - Axes range table // // These may need changes. I found this in the control panel calibration window. DUALZONE_RANGE_TABLE ATTXYZoneRangeTable = { { -512L, -512L }, { 0L, 0L }, { 511L, 511L}, {70L, 70L} }; DUALZONE_RANGE_TABLE ATTRudderZoneRangeTable = { {-512L, 0L}, { 0L, 0L}, { 511L, 0L }, {70L, 0L} }; // // Attila - List of ControlItemDesc // RAW_CONTROL_ITEM_DESC rgATTControlItems[] = { {1L, usButton, HID_USAGE_PAGE_BUTTON, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 1, 15, &ATTModifierDescTable, (USAGE)1, (USAGE)6, 0L, 0L}, {2L, usButton, HID_USAGE_PAGE_BUTTON, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 1, 15, NULL, (USAGE)7, (USAGE)8, 0L, 0L}, {3L, usButton, HID_USAGE_PAGE_BUTTON, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 1, 15, NULL, (USAGE)0xC, (USAGE)0xC, 0L, 0L}, {4L, usDualZoneIndicator, HID_USAGE_PAGE_GENERIC, 1, HID_USAGE_GENERIC_POINTER, HID_USAGE_PAGE_GENERIC, 10, 1, 0, HID_USAGE_GENERIC_X, HID_USAGE_GENERIC_Y, (LONG)&ATTXYZoneRangeTable, 8L}, {5L, usDualZoneIndicator, HID_USAGE_PAGE_GENERIC, 1, HID_USAGE_GENERIC_POINTER, HID_USAGE_PAGE_GENERIC, 10, 1, 0, HID_USAGE_GENERIC_RZ, 0, (LONG)&ATTRudderZoneRangeTable, 2L}, {6L, usButtonLED, HID_USAGE_PAGE_LED, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 2, 6, &ATTModifierDescTable, USAGE(1), USAGE(ucReportTypeFeatureRW), ULONG((0 << 24) | (1 << 16) | (ControlItemConst::LED_DEFAULT_MODE_CORRESPOND_ON << 8) | (0)), 0 }, {7L, usProfileSelectors, HID_USAGE_PAGE_BUTTON, 0, HID_USAGE_GENERIC_JOYSTICK, HID_USAGE_PAGE_GENERIC, 1, 15, NULL, (USAGE)0xD, (USAGE)0xF, (ULONG)2, (ULONG)0 } }; #undef HID_USAGE_RESERVED // // List of supported devices // //NEWDEVICE DEVICE_CONTROLS_DESC DeviceControlsDescList[] = { {0x045E000E, 5, rgFSControlItems, &FSModifierDescTable}, //Freestyle Pro (USB) {0x045E0008, 6, rgPPControlItems, &PPModifierDescTable}, //Precision Pro (USB) {0x045E0026, 2, rgZRControlItems, &ZRModifierDescTable}, //Zorro {0x045E0028, 4, rgZLControlItems, &ZLModifierDescTable}, //Zulu {0x045E001A, 4, rgZPLControlItems, &ZPLModifierDescTable}, //Zep Lite {0x045E0034, 5, rgSZPControlItems, &SZPModifierDescTable}, //SparkyZep // {0x045Effff, 0, NULL, NULL}, //Tilt2 Dev11 TT2 {0x045E0038, 5, rgMOHControlItems, NULL}, //Mothra Dev12 MOH {0x045E001B, 6, rgGODControlItems, NULL}, //Godzilla Dev13 GOD {0x045E0033, 7, rgATTControlItems, &ATTModifierDescTable}, //Attila Dev14 ATT {0x00000000, 0, 0x00000000} };
C++
CL
ea8c699d23a0c70198da4224078f85486abca68e6c976dd8a684ddafc257899a
#include <rppi_fused_functions.h> #include <rppdefs.h> #include <iostream> #include "rppi_validate.hpp" #ifdef HIP_COMPILE #include <hip/rpp_hip_common.hpp> #include "hip/hip_declarations.hpp" #include "hip/hip_declarations_inline.hpp" #elif defined(OCL_COMPILE) #include <cl/rpp_cl_common.hpp> #include "cl/cl_declarations.hpp" #endif //backend #include <stdio.h> #include <iostream> #include <fstream> #include <chrono> using namespace std::chrono; #include "cpu/host_fused_functions.hpp" RppStatus color_twist_helper(RppiChnFormat chn_format, Rpp32u num_of_channels, RPPTensorDataType in_tensor_type, RPPTensorDataType out_tensor_type, Rpp8u outputFormatToggle, RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { RppiROI roiPoints; bool is_padded = true; RPPTensorFunctionMetaData tensor_info(chn_format, in_tensor_type, out_tensor_type, num_of_channels, (bool)outputFormatToggle); RppiSize maxDstSize = maxSrcSize; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_dstMaxSize(maxDstSize, rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), num_of_channels, tensor_info._in_format, is_padded); get_dstBatchIndex(rpp::deref(rppHandle), num_of_channels, tensor_info._out_format, is_padded); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch_tensor( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), tensor_info); } #elif defined(HIP_COMPILE) { if (in_tensor_type == RPPTensorDataType::U8) { color_twist_hip_batch_tensor<Rpp8u, Rpp8u>( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), tensor_info); } else if (in_tensor_type == RPPTensorDataType::FP16) { color_twist_hip_batch_tensor<Rpp16f, Rpp16f>( static_cast<Rpp16f *>(srcPtr), static_cast<Rpp16f *>(dstPtr), rpp::deref(rppHandle), tensor_info); } else if (in_tensor_type == RPPTensorDataType::FP32) { color_twist_hip_batch_tensor<Rpp32f, Rpp32f>( static_cast<Rpp32f *>(srcPtr), static_cast<Rpp32f *>(dstPtr), rpp::deref(rppHandle), tensor_info); } else if (in_tensor_type == RPPTensorDataType::I8) { color_twist_hip_batch_tensor<Rpp8s, Rpp8s>( static_cast<Rpp8s *>(srcPtr), static_cast<Rpp8s *>(dstPtr), rpp::deref(rppHandle), tensor_info); } } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, rppHandle_t rppHandle) { #ifdef OCL_COMPILE { color_twist_cl( static_cast<cl_mem>(srcPtr), srcSize, static_cast<cl_mem>(dstPtr), alpha, beta, hueShift, saturationFactor, RPPI_CHN_PLANAR, 1, rpp::deref(rppHandle)); } #elif defined(HIP_COMPILE) { color_twist_hip( static_cast<Rpp8u *>(srcPtr), srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, RPPI_CHN_PLANAR, 1, rpp::deref(rppHandle)); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_ROI_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 1, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchSS_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 1, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchDS_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 1, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchPS_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 1, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchSD_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 1, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchDD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 1, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp8u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, RPPTensorDataType::U8, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_u8_pln1_batchSS_ROIS_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 1, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchDS_ROIS_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 1, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchPS_ROIS_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 1, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchSD_ROIS_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 1, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchDD_ROIS_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 1, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchPD_ROIS_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 1, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchSS_ROID_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 1, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchDS_ROID_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 1, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchPS_ROID_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 1, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchSD_ROID_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 1, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchDD_ROID_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 1, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchPD_ROID_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 1, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 1); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, rppHandle_t rppHandle) { #ifdef OCL_COMPILE { color_twist_cl( static_cast<cl_mem>(srcPtr), srcSize, static_cast<cl_mem>(dstPtr), alpha, beta, hueShift, saturationFactor, RPPI_CHN_PLANAR, 1, rpp::deref(rppHandle)); } #elif defined(HIP_COMPILE) { color_twist_hip( static_cast<Rpp8u *>(srcPtr), srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, RPPI_CHN_PLANAR, 1, rpp::deref(rppHandle)); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_ROI_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchSS_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchDS_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchPS_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchSD_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchDD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, RPPTensorDataType::U8, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_u8_pln3_batchSS_ROIS_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchDS_ROIS_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchPS_ROIS_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchSD_ROIS_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchDD_ROIS_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchPD_ROIS_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchSS_ROID_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchDS_ROID_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchPS_ROID_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchSD_ROID_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchDD_ROID_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchPD_ROID_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PLANAR); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PLANAR, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, rppHandle_t rppHandle) { #ifdef OCL_COMPILE { color_twist_cl( static_cast<cl_mem>(srcPtr), srcSize, static_cast<cl_mem>(dstPtr), alpha, beta, hueShift, saturationFactor, RPPI_CHN_PACKED, 3, rpp::deref(rppHandle)); } #elif defined(HIP_COMPILE) { color_twist_hip( static_cast<Rpp8u *>(srcPtr), srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, RPPI_CHN_PACKED, 3, rpp::deref(rppHandle)); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_ROI_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PACKED); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchSS_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PACKED); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchDS_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PACKED); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchPS_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PACKED); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchSD_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PACKED); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchDD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PACKED); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, RPPTensorDataType::U8, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_u8_pkd3_batchSS_ROIS_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PACKED); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchDS_ROIS_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PACKED); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchPS_ROIS_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PACKED); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchSD_ROIS_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PACKED); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchDD_ROIS_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PACKED); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchPD_ROIS_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PACKED); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchSS_ROID_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PACKED); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchDS_ROID_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PACKED); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchPS_ROID_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PACKED); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchSD_ROID_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PACKED); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchDD_ROID_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PACKED); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchPD_ROID_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_roi(roiPoints, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), 3, RPPI_CHN_PACKED); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { color_twist_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #elif defined(HIP_COMPILE) { color_twist_hip_batch( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), RPPI_CHN_PACKED, 3); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_color_twist_f16_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::FP16, RPPTensorDataType::FP16, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_f16_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::FP16, RPPTensorDataType::FP16, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_f16_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::FP16, RPPTensorDataType::FP16, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_f32_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::FP32, RPPTensorDataType::FP32, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_f32_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::FP32, RPPTensorDataType::FP32, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_f32_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::FP32, RPPTensorDataType::FP32, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_i8_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::I8, RPPTensorDataType::I8, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_i8_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::I8, RPPTensorDataType::I8, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_i8_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::I8, RPPTensorDataType::I8, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, nbatchSize, rppHandle)); } RppStatus color_twist_host_helper(RppiChnFormat chn_format, Rpp32u num_of_channels, RPPTensorDataType tensor_type, RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); if (tensor_type == RPPTensorDataType::U8) { color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } else if (tensor_type == RPPTensorDataType::FP16) { color_twist_f16_host_batch<Rpp16f>( static_cast<Rpp16f *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp16f *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } else if (tensor_type == RPPTensorDataType::FP32) { color_twist_f32_host_batch<Rpp32f>( static_cast<Rpp32f *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp32f *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } else if (tensor_type == RPPTensorDataType::I8) { color_twist_i8_host_batch<Rpp8s>( static_cast<Rpp8s *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8s *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, rppHandle_t rppHandle) { color_twist_host( static_cast<Rpp8u *>(srcPtr), srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_ROI_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_srcSize(srcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchSS_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_srcSize(srcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchDS_host(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchPS_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchSD_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_srcSize(srcSize, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchDD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_u8_pln1_batchSS_ROIS_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_srcSize(srcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchDS_ROIS_host(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchPS_ROIS_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchSD_ROIS_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_srcSize(srcSize, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchDD_ROIS_host(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchPD_ROIS_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchSS_ROID_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_srcSize(srcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchDS_ROID_host(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchPS_ROID_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchSD_ROID_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_srcSize(srcSize, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchDD_ROID_host(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln1_batchPD_ROID_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, rppHandle_t rppHandle) { color_twist_host( static_cast<Rpp8u *>(srcPtr), srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_ROI_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_srcSize(srcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchSS_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_srcSize(srcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchDS_host(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchPS_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchSD_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_srcSize(srcSize, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchDD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_u8_pln3_batchSS_ROIS_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_srcSize(srcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchDS_ROIS_host(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchPS_ROIS_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchSD_ROIS_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_srcSize(srcSize, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchDD_ROIS_host(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchPD_ROIS_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchSS_ROID_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_srcSize(srcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchDS_ROID_host(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchPS_ROID_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchSD_ROID_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_srcSize(srcSize, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchDD_ROID_host(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pln3_batchPD_ROID_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, rppHandle_t rppHandle) { color_twist_host( static_cast<Rpp8u *>(srcPtr), srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_ROI_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_srcSize(srcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchSS_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_srcSize(srcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchDS_host(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchPS_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchSD_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_srcSize(srcSize, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchDD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; RppiROI roiPoints; roiPoints.x = 0; roiPoints.y = 0; roiPoints.roiHeight = 0; roiPoints.roiWidth = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_u8_pkd3_batchSS_ROIS_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_srcSize(srcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchDS_ROIS_host(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchPS_ROIS_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchSD_ROIS_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_srcSize(srcSize, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchDD_ROIS_host(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchPD_ROIS_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_roi(roiPoints, rpp::deref(rppHandle)); copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchSS_ROID_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_srcSize(srcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchDS_ROID_host(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, srcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchPS_ROID_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f alpha, Rpp32f beta, Rpp32f hueShift, Rpp32f saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); copy_param_float(alpha, rpp::deref(rppHandle), paramIndex++); copy_param_float(beta, rpp::deref(rppHandle), paramIndex++); copy_param_float(hueShift, rpp::deref(rppHandle), paramIndex++); copy_param_float(saturationFactor, rpp::deref(rppHandle), paramIndex++); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[0].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[1].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[2].floatmem, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.floatArr[3].floatmem, roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchSD_ROID_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_srcSize(srcSize, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchDD_ROID_host(RppPtr_t srcPtr, RppiSize *srcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, srcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_u8_pkd3_batchPD_ROID_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, RppiROI *roiPoints, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); color_twist_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), alpha, beta, hueShift, saturationFactor, roiPoints, 0, rpp::deref(rppHandle).GetBatchSize(), RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus rppi_color_twist_f16_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_f16_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_f32_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_f32_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_i8_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_color_twist_i8_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, Rpp32f *alpha, Rpp32f *beta, Rpp32f *hueShift, Rpp32f *saturationFactor, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (color_twist_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, alpha, beta, hueShift, saturationFactor, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_pln1_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, RppiSize dstSize, Rpp32u crop_pos_x, Rpp32u crop_pos_y, Rpp32f mean, Rpp32f std_dev, Rpp32u mirrorFlag, Rpp32u outputFormatToggle, rppHandle_t rppHandle) { #ifdef OCL_COMPILE { crop_mirror_normalize_cl( static_cast<cl_mem>(srcPtr), srcSize, static_cast<cl_mem>(dstPtr), dstSize, mean, std_dev, crop_pos_x, crop_pos_y, mirrorFlag, outputFormatToggle, RPPI_CHN_PLANAR, 1, rpp::deref(rppHandle)); } #elif defined(HIP_COMPILE) { crop_mirror_normalize_hip( static_cast<Rpp8u *>(srcPtr), srcSize, static_cast<Rpp8u *>(dstPtr), dstSize, mean, std_dev, crop_pos_x, crop_pos_y, mirrorFlag, outputFormatToggle, RPPI_CHN_PLANAR, 1, rpp::deref(rppHandle)); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_crop_mirror_normalize_u8_pln3_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, RppiSize dstSize, Rpp32u crop_pos_x, Rpp32u crop_pos_y, Rpp32f mean, Rpp32f std_dev, Rpp32u mirrorFlag, Rpp32u outputFormatToggle, rppHandle_t rppHandle) { #ifdef OCL_COMPILE { crop_mirror_normalize_cl( static_cast<cl_mem>(srcPtr), srcSize, static_cast<cl_mem>(dstPtr), dstSize, mean, std_dev, crop_pos_x, crop_pos_y, mirrorFlag, outputFormatToggle, RPPI_CHN_PLANAR, 3, rpp::deref(rppHandle)); } #elif defined(HIP_COMPILE) { crop_mirror_normalize_hip( static_cast<Rpp8u *>(srcPtr), srcSize, static_cast<Rpp8u *>(dstPtr), dstSize, mean, std_dev, crop_pos_x, crop_pos_y, mirrorFlag, outputFormatToggle, RPPI_CHN_PLANAR, 3, rpp::deref(rppHandle)); } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_crop_mirror_normalize_u8_pkd3_gpu(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, RppiSize dstSize, Rpp32u crop_pos_x, Rpp32u crop_pos_y, Rpp32f mean, Rpp32f std_dev, Rpp32u mirrorFlag, Rpp32u outputFormatToggle, rppHandle_t rppHandle) { #ifdef OCL_COMPILE { crop_mirror_normalize_cl( static_cast<cl_mem>(srcPtr), srcSize, static_cast<cl_mem>(dstPtr), dstSize, mean, std_dev, crop_pos_x, crop_pos_y, mirrorFlag, outputFormatToggle, RPPI_CHN_PACKED, 3, rpp::deref(rppHandle)); } #elif defined(HIP_COMPILE) { crop_mirror_normalize_hip( static_cast<Rpp8u *>(srcPtr), srcSize, static_cast<Rpp8u *>(dstPtr), dstSize, mean, std_dev, crop_pos_x, crop_pos_y, mirrorFlag, outputFormatToggle, RPPI_CHN_PACKED, 3, rpp::deref(rppHandle)); } #endif //BACKEND return RPP_SUCCESS; } RppStatus crop_mirror_normalize_helper(RppiChnFormat chn_format, Rpp32u num_of_channels, RPPTensorDataType in_tensor_type, RPPTensorDataType out_tensor_type, RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; bool is_padded = true; RPPTensorFunctionMetaData tensor_info(chn_format, in_tensor_type, out_tensor_type, num_of_channels, (bool)outputFormatToggle); copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_dstSize(dstSize, rpp::deref(rppHandle)); copy_dstMaxSize(maxDstSize, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), num_of_channels, tensor_info._in_format, is_padded); get_dstBatchIndex(rpp::deref(rppHandle), num_of_channels, tensor_info._out_format, is_padded); copy_param_uint(crop_pos_x, rpp::deref(rppHandle), paramIndex++); copy_param_uint(crop_pos_y, rpp::deref(rppHandle), paramIndex++); copy_param_float(mean, rpp::deref(rppHandle), paramIndex++); copy_param_float(std_dev, rpp::deref(rppHandle), paramIndex++); copy_param_uint(mirrorFlag, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { crop_mirror_normalize_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), tensor_info); } #elif defined(HIP_COMPILE) { if (in_tensor_type == RPPTensorDataType::U8) { if (out_tensor_type == RPPTensorDataType::U8) { crop_mirror_normalize_hip_batch_tensor<Rpp8u, Rpp8u>( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), tensor_info); } else if (out_tensor_type == RPPTensorDataType::FP16) { crop_mirror_normalize_hip_batch_tensor<Rpp8u, Rpp16f>( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp16f *>(dstPtr), rpp::deref(rppHandle), tensor_info); } else if (out_tensor_type == RPPTensorDataType::FP32) { crop_mirror_normalize_hip_batch_tensor<Rpp8u, Rpp32f>( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp32f *>(dstPtr), rpp::deref(rppHandle), tensor_info); } else if (out_tensor_type == RPPTensorDataType::I8) { crop_mirror_normalize_hip_batch_tensor<Rpp8u, Rpp8s>( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8s *>(dstPtr), rpp::deref(rppHandle), tensor_info); } } else if (in_tensor_type == RPPTensorDataType::FP16) { crop_mirror_normalize_hip_batch_tensor<Rpp16f, Rpp16f>( static_cast<Rpp16f *>(srcPtr), static_cast<Rpp16f *>(dstPtr), rpp::deref(rppHandle), tensor_info); } else if (in_tensor_type == RPPTensorDataType::FP32) { crop_mirror_normalize_hip_batch_tensor<Rpp32f, Rpp32f>( static_cast<Rpp32f *>(srcPtr), static_cast<Rpp32f *>(dstPtr), rpp::deref(rppHandle), tensor_info); } else if (in_tensor_type == RPPTensorDataType::I8) { crop_mirror_normalize_hip_batch_tensor<Rpp8s, Rpp8s>( static_cast<Rpp8s *>(srcPtr), static_cast<Rpp8s *>(dstPtr), rpp::deref(rppHandle), tensor_info); } } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_crop_mirror_normalize_u8_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_f32_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::FP32, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_f16_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::FP16, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_f32_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::FP32, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_f16_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::FP16, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_f32_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::FP32, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_f16_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::FP16, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_i8_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::I8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_i8_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::I8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_i8_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::I8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_i8_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_i8_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_i8_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_f32_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_f32_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_f32_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_f16_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_f16_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_f16_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *std_dev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, std_dev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_pln1_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, RppiSize dstSize, Rpp32u crop_pos_x, Rpp32u crop_pos_y, Rpp32f mean, Rpp32f stdDev, Rpp32u mirrorFlag, Rpp32u outputFormatToggle, rppHandle_t rppHandle) { crop_mirror_normalize_host( static_cast<Rpp8u *>(srcPtr), srcSize, static_cast<Rpp8u *>(dstPtr), dstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, RPPI_CHN_PLANAR, 1); return RPP_SUCCESS; } RppStatus rppi_crop_mirror_normalize_u8_pln3_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, RppiSize dstSize, Rpp32u crop_pos_x, Rpp32u crop_pos_y, Rpp32f mean, Rpp32f stdDev, Rpp32u mirrorFlag, Rpp32u outputFormatToggle, rppHandle_t rppHandle) { crop_mirror_normalize_host( static_cast<Rpp8u *>(srcPtr), srcSize, static_cast<Rpp8u *>(dstPtr), dstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, RPPI_CHN_PLANAR, 3); return RPP_SUCCESS; } RppStatus rppi_crop_mirror_normalize_u8_pkd3_host(RppPtr_t srcPtr, RppiSize srcSize, RppPtr_t dstPtr, RppiSize dstSize, Rpp32u crop_pos_x, Rpp32u crop_pos_y, Rpp32f mean, Rpp32f stdDev, Rpp32u mirrorFlag, Rpp32u outputFormatToggle, rppHandle_t rppHandle) { crop_mirror_normalize_host( static_cast<Rpp8u *>(srcPtr), srcSize, static_cast<Rpp8u *>(dstPtr), dstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, RPPI_CHN_PACKED, 3); return RPP_SUCCESS; } RppStatus crop_mirror_normalize_host_helper(RppiChnFormat chn_format, Rpp32u num_of_channels, RPPTensorDataType tensorInType, RPPTensorDataType tensorOutType, RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); copy_host_maxDstSize(maxDstSize, rpp::deref(rppHandle)); if (tensorInType == RPPTensorDataType::U8) { if (tensorOutType == RPPTensorDataType::U8) { crop_mirror_normalize_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } else if (tensorOutType == RPPTensorDataType::FP16) { crop_mirror_normalize_u8_f_host_batch<Rpp8u, Rpp16f>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp16f *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } else if (tensorOutType == RPPTensorDataType::FP32) { crop_mirror_normalize_u8_f_host_batch<Rpp8u, Rpp32f>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp32f *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } else if (tensorOutType == RPPTensorDataType::I8) { crop_mirror_normalize_u8_i8_host_batch( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8s *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } } else if (tensorInType == RPPTensorDataType::FP16) { crop_mirror_normalize_f16_host_batch( static_cast<Rpp16f *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp16f *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } else if (tensorInType == RPPTensorDataType::FP32) { crop_mirror_normalize_f32_host_batch( static_cast<Rpp32f *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp32f *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } else if (tensorInType == RPPTensorDataType::I8) { crop_mirror_normalize_host_batch<Rpp8s>( static_cast<Rpp8s *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8s *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } return RPP_SUCCESS; } RppStatus rppi_crop_mirror_normalize_u8_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_f16_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::FP16, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_f16_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::FP16, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_f16_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::FP16, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_f32_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::FP32, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_f32_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::FP32, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_f32_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::FP32, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_f16_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_f16_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_f16_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_f32_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_f32_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_f32_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_i8_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::I8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_i8_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::I8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_i8_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::I8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_i8_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_i8_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_mirror_normalize_u8_i8_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32f *mean, Rpp32f *stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_mirror_normalize_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, mean, stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus crop_helper(RppiChnFormat chn_format, Rpp32u num_of_channels, RPPTensorDataType in_tensor_type, RPPTensorDataType out_tensor_type, RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { RPPTensorFunctionMetaData tensor_info(chn_format, in_tensor_type, out_tensor_type, num_of_channels, (bool)outputFormatToggle); Rpp32u paramIndex = 0; bool is_padded = true; copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_dstSize(dstSize, rpp::deref(rppHandle)); copy_dstMaxSize(maxDstSize, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), num_of_channels, tensor_info._in_format, is_padded); get_dstBatchIndex(rpp::deref(rppHandle), num_of_channels, tensor_info._out_format, is_padded); copy_param_uint(crop_pos_x, rpp::deref(rppHandle), paramIndex++); copy_param_uint(crop_pos_y, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { crop_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), tensor_info); } #elif defined(HIP_COMPILE) { if (in_tensor_type == RPPTensorDataType::U8) { if (out_tensor_type == RPPTensorDataType::U8) { crop_hip_batch_tensor<Rpp8u, Rpp8u>( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), tensor_info); } else if (out_tensor_type == RPPTensorDataType::FP16) { crop_hip_batch_tensor<Rpp8u, Rpp16f>( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp16f *>(dstPtr), rpp::deref(rppHandle), tensor_info); } else if (out_tensor_type == RPPTensorDataType::FP32) { crop_hip_batch_tensor<Rpp8u, Rpp32f>( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp32f *>(dstPtr), rpp::deref(rppHandle), tensor_info); } else if (out_tensor_type == RPPTensorDataType::I8) { crop_hip_batch_tensor<Rpp8u, Rpp8s>( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8s *>(dstPtr), rpp::deref(rppHandle), tensor_info); } } else if (in_tensor_type == RPPTensorDataType::FP16) { crop_hip_batch_tensor<Rpp16f, Rpp16f>( static_cast<Rpp16f *>(srcPtr), static_cast<Rpp16f *>(dstPtr), rpp::deref(rppHandle), tensor_info); } else if (in_tensor_type == RPPTensorDataType::FP32) { crop_hip_batch_tensor<Rpp32f, Rpp32f>( static_cast<Rpp32f *>(srcPtr), static_cast<Rpp32f *>(dstPtr), rpp::deref(rppHandle), tensor_info); } else if (in_tensor_type == RPPTensorDataType::I8) { crop_hip_batch_tensor<Rpp8s, Rpp8s>( static_cast<Rpp8s *>(srcPtr), static_cast<Rpp8s *>(dstPtr), rpp::deref(rppHandle), tensor_info); } } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_crop_u8_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_f16_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::FP16, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_f16_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::FP16, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_f16_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::FP16, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_f32_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::FP32, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_f32_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::FP32, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_f32_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::FP32, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_i8_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::I8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_i8_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::I8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_i8_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::I8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_i8_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_i8_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_i8_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_f32_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_f32_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_f32_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_f16_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_f16_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_f16_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u output_format_toggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, output_format_toggle, nbatchSize, rppHandle)); } RppStatus crop_host_helper(RppiChnFormat chn_format, Rpp32u num_of_channels, RPPTensorDataType tensorInType, RPPTensorDataType tensorOutType, RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); copy_host_maxDstSize(maxDstSize, rpp::deref(rppHandle)); if (tensorInType == RPPTensorDataType::U8) { if (tensorOutType == RPPTensorDataType::U8) { crop_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } else if (tensorOutType == RPPTensorDataType::FP16) { crop_host_u_f_batch<Rpp8u, Rpp16f>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp16f *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } else if (tensorOutType == RPPTensorDataType::FP32) { crop_host_u_f_batch<Rpp8u, Rpp32f>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp32f *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } else if (tensorOutType == RPPTensorDataType::I8) { crop_host_u_i_batch<Rpp8u, Rpp8s>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8s *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } } else if (tensorInType == RPPTensorDataType::FP16) { crop_host_batch<Rpp16f>( static_cast<Rpp16f *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp16f *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } else if (tensorInType == RPPTensorDataType::FP32) { crop_host_batch<Rpp32f>( static_cast<Rpp32f *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp32f *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } else if (tensorInType == RPPTensorDataType::I8) { crop_host_batch<Rpp8s>( static_cast<Rpp8s *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8s *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } return RPP_SUCCESS; } RppStatus rppi_crop_u8_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_f16_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::FP16, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_f16_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::FP16, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_f16_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::FP16, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_f32_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::FP32, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_f32_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::FP32, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_f32_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::FP32, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_f16_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_f16_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_f16_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_f32_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_f32_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_f32_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_i8_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::I8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_i8_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::I8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_i8_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::I8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_i8_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_i8_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_crop_u8_i8_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *crop_pos_x, Rpp32u *crop_pos_y, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (crop_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, crop_pos_x, crop_pos_y, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus resize_crop_mirror_helper( RppiChnFormat chn_format, Rpp32u num_of_channels, RPPTensorDataType in_tensor_type, RPPTensorDataType out_tensor_type, Rpp32u outputFormatToggle, RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; bool is_padded = true; RPPTensorFunctionMetaData tensor_info(chn_format, in_tensor_type, out_tensor_type, num_of_channels, (bool)outputFormatToggle); copy_srcSize(srcSize, rpp::deref(rppHandle)); copy_srcMaxSize(maxSrcSize, rpp::deref(rppHandle)); copy_dstSize(dstSize, rpp::deref(rppHandle)); copy_dstMaxSize(maxDstSize, rpp::deref(rppHandle)); get_srcBatchIndex(rpp::deref(rppHandle), num_of_channels, tensor_info._in_format, is_padded); get_dstBatchIndex(rpp::deref(rppHandle), num_of_channels, tensor_info._out_format, is_padded); copy_param_uint(xRoiBegin, rpp::deref(rppHandle), paramIndex++); copy_param_uint(xRoiEnd, rpp::deref(rppHandle), paramIndex++); copy_param_uint(yRoiBegin, rpp::deref(rppHandle), paramIndex++); copy_param_uint(yRoiEnd, rpp::deref(rppHandle), paramIndex++); copy_param_uint(mirrorFlag, rpp::deref(rppHandle), paramIndex++); #ifdef OCL_COMPILE { resize_crop_mirror_cl_batch( static_cast<cl_mem>(srcPtr), static_cast<cl_mem>(dstPtr), rpp::deref(rppHandle), tensor_info); } #elif defined(HIP_COMPILE) { if (in_tensor_type == RPPTensorDataType::U8) { resize_crop_mirror_hip_batch_tensor<Rpp8u, Rpp8u>( static_cast<Rpp8u *>(srcPtr), static_cast<Rpp8u *>(dstPtr), rpp::deref(rppHandle), tensor_info); } else if (in_tensor_type == RPPTensorDataType::FP16) { resize_crop_mirror_hip_batch_tensor<Rpp16f, Rpp16f>( static_cast<Rpp16f *>(srcPtr), static_cast<Rpp16f *>(dstPtr), rpp::deref(rppHandle), tensor_info); } else if (in_tensor_type == RPPTensorDataType::FP32) { resize_crop_mirror_hip_batch_tensor<Rpp32f, Rpp32f>( static_cast<Rpp32f *>(srcPtr), static_cast<Rpp32f *>(dstPtr), rpp::deref(rppHandle), tensor_info); } else if (in_tensor_type == RPPTensorDataType::I8) { resize_crop_mirror_hip_batch_tensor<Rpp8s, Rpp8s>( static_cast<Rpp8s *>(srcPtr), static_cast<Rpp8s *>(dstPtr), rpp::deref(rppHandle), tensor_info); } } #endif //BACKEND return RPP_SUCCESS; } RppStatus rppi_resize_crop_mirror_u8_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, RPPTensorDataType::U8, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, yRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_u8_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, RPPTensorDataType::U8, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_u8_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, RPPTensorDataType::U8, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_i8_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::I8, RPPTensorDataType::I8, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, yRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_i8_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::I8, RPPTensorDataType::I8, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_i8_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::I8, RPPTensorDataType::I8, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_f16_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::FP16, RPPTensorDataType::FP16, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_f16_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::FP16, RPPTensorDataType::FP16, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_f16_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::FP16, RPPTensorDataType::FP16, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_f32_pln1_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::FP32, RPPTensorDataType::FP32, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_f32_pln3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::FP32, RPPTensorDataType::FP32, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_f32_pkd3_batchPD_gpu(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::FP32, RPPTensorDataType::FP32, outputFormatToggle, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, nbatchSize, rppHandle)); } RppStatus resize_crop_mirror_host_helper( RppiChnFormat chn_format, Rpp32u num_of_channels, RPPTensorDataType tensor_type, RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); copy_host_maxDstSize(maxDstSize, rpp::deref(rppHandle)); if (tensor_type == RPPTensorDataType::U8) { resize_crop_mirror_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } else if (tensor_type == RPPTensorDataType::FP16) { resize_crop_mirror_f16_host_batch( static_cast<Rpp16f *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp16f *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } else if (tensor_type == RPPTensorDataType::FP32) { resize_crop_mirror_f32_host_batch( static_cast<Rpp32f *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp32f *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } else if (tensor_type == RPPTensorDataType::I8) { resize_crop_mirror_host_batch<Rpp8s>( static_cast<Rpp8s *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8s *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } return RPP_SUCCESS; } RppStatus rppi_resize_crop_mirror_u8_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_u8_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag,Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_u8_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_f16_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_f16_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_f16_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::FP16, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_f32_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_f32_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_f32_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_i8_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_i8_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_resize_crop_mirror_i8_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32u *xRoiBegin, Rpp32u *xRoiEnd, Rpp32u *yRoiBegin, Rpp32u *yRoiEnd, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_crop_mirror_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::I8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, xRoiBegin, xRoiEnd, yRoiBegin, yRoiEnd, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus resize_mirror_normalize_host_helper( RppiChnFormat chn_format, Rpp32u num_of_channels, RPPTensorDataType tensor_type, RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32f *batch_mean, Rpp32f *batch_stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { Rpp32u paramIndex = 0; copy_host_maxSrcSize(maxSrcSize, rpp::deref(rppHandle)); copy_host_maxDstSize(maxDstSize, rpp::deref(rppHandle)); if (tensor_type == RPPTensorDataType::U8) { resize_mirror_normalize_host_batch<Rpp8u>( static_cast<Rpp8u *>(srcPtr), srcSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, static_cast<Rpp8u *>(dstPtr), dstSize, rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, batch_mean, batch_stdDev, mirrorFlag, outputFormatToggle, rpp::deref(rppHandle).GetBatchSize(), chn_format, num_of_channels); } // else if (tensor_type == RPPTensorDataType::FP32) // { // resize_mirror_normalize_f32_host_batch( // static_cast<Rpp32f *>(srcPtr), // srcSize, // rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxSrcSize, // static_cast<Rpp32f *>(dstPtr), // dstSize, // rpp::deref(rppHandle).GetInitHandle()->mem.mcpu.maxDstSize, // batch_mean, batch_stdDev, // mirrorFlag, // outputFormatToggle, // rpp::deref(rppHandle).GetBatchSize(), // chn_format, num_of_channels); // } return RPP_SUCCESS; } RppStatus rppi_resize_mirror_normalize_u8_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32f *batch_mean, Rpp32f *batch_stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_mirror_normalize_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, batch_mean, batch_stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_resize_mirror_normalize_u8_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32f *batch_mean, Rpp32f *batch_stdDev, Rpp32u *mirrorFlag,Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_mirror_normalize_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, batch_mean, batch_stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } RppStatus rppi_resize_mirror_normalize_u8_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32f *batch_mean, Rpp32f *batch_stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) { return (resize_mirror_normalize_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::U8, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, batch_mean, batch_stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); } // RppStatus // rppi_resize_mirror_normalize_f32_pln1_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32f *batch_mean, Rpp32f *batch_stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) // { // return (resize_mirror_normalize_host_helper(RPPI_CHN_PLANAR, 1, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, batch_mean, batch_stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); // } // RppStatus // rppi_resize_mirror_normalize_f32_pln3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32f *batch_mean, Rpp32f *batch_stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) // { // return (resize_mirror_normalize_host_helper(RPPI_CHN_PLANAR, 3, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, batch_mean, batch_stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); // } // RppStatus // rppi_resize_mirror_normalize_f32_pkd3_batchPD_host(RppPtr_t srcPtr, RppiSize *srcSize, RppiSize maxSrcSize, RppPtr_t dstPtr, RppiSize *dstSize, RppiSize maxDstSize, Rpp32f *batch_mean, Rpp32f *batch_stdDev, Rpp32u *mirrorFlag, Rpp32u outputFormatToggle, Rpp32u nbatchSize, rppHandle_t rppHandle) // { // return (resize_mirror_normalize_host_helper(RPPI_CHN_PACKED, 3, RPPTensorDataType::FP32, srcPtr, srcSize, maxSrcSize, dstPtr, dstSize, maxDstSize, batch_mean, batch_stdDev, mirrorFlag, outputFormatToggle, nbatchSize, rppHandle)); // }
C++
CL
0f43b3090eda1cf52db395eb4e18bfa36ba4afcba25eedaf74cf3c871912dcfa
// -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- // $Id$ // // Copyright 2010-2014 Christoph Mayer // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // #ifndef _FFT_RESULT_HPP_cm101026_ #define _FFT_RESULT_HPP_cm101026_ #include <string> #include <sstream> #include <fstream> #include <deque> #include <boost/lexical_cast.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> #include <boost/weak_ptr.hpp> #include "network/protocol.hpp" #include "gen_filename.hpp" #include "processor/result.hpp" #include "station_info.hpp" namespace Result { class Base : public gen_filename, public processor::result_base { public: typedef boost::shared_ptr<Base> sptr; typedef boost::shared_ptr<Base> Handle; typedef boost::weak_ptr<Base> WeakHandle; typedef std::deque<Handle> HandleVector; typedef std::complex<float> complex_type; Base(std::string name, ptime time) : processor::result_base(name, time) , posEndTime_(0) {} virtual ~Base() {} virtual std::string toString() const { return name(); } ptime time() const { return approx_ptime(); } virtual void updateTime(ptime t) {} // is overwritten by Result::Calibration void push_back(const Handle& h) { handles_.push_back(h); } const Base* getLatest() const { return handles_.empty() ? this : handles_.back().get(); } void clear() { handles_.clear(); } // dump data void dumpToFile(std::string path, std::string tag, std::string s) const { const station_info si(s, lineBreak()); boost::filesystem::fstream *ofs(0); ofs = dumpSingle(ofs, path, tag, this, si); for (auto const& h : handles_) ofs = dumpSingle(ofs, path, tag, h.get(), si); updateTimeTag(*ofs, posEndTime_, getLatest()->makeTimeLabel()); delete ofs; } template<typename BROADCASTER> void dumpToBC(std::string path, std::string tag, boost::shared_ptr<BROADCASTER> bc, std::string s) { const station_info si(s, lineBreak()); dumpToBCSingle(path, tag, bc, this, si); for (auto const& h : handles_) dumpToBCSingle(path, tag, bc, h.get(), si); } template<typename BROADCASTER> void dumpToBCSingle(std::string path, std::string tag, boost::shared_ptr<BROADCASTER> bc, Base* h, const station_info& si) { std::ostringstream sHeader; sHeader << si; h->dump_header(sHeader); const std::string sh(sHeader.str()); std::ostringstream sData; h->dump_data(sData); const std::string sd(sData.str()); bc->bc_data(h->time(), tag, h->format(), sd, sh); } boost::filesystem::fstream* dumpSingle(boost::filesystem::fstream* ofs, std::string path, std::string tag, const Base* h, const station_info& si) const { const boost::filesystem::path p(gen_file_path(path, tag, h->time())); const bool file_exists(boost::filesystem::exists(p)); if (not file_exists) { if (ofs) { delete ofs; ofs= NULL; } boost::filesystem::fstream lofs(p, std::ios::out); lofs << si; h->dumpHeaderToFile(lofs) << h->lineBreak(); } if (!ofs) { findPositionOfEndTime(p); ofs = new boost::filesystem::fstream(p, std::ios::in | std::ios::out); ofs->seekp(0, std::ios::end); } h->dumpDataToFile(*ofs) << h->lineBreak(); return ofs; } protected: virtual std::string lineBreak() const { return "\n"; } // virtual string context dump header and data virtual std::ostream& dump_header(std::ostream& os) const { return os << "# Time_UTC "; } virtual std::ostream& dump_data(std::ostream& os) const { return os; } // file context dump: virtual boost::filesystem::fstream& dumpHeaderToFile(boost::filesystem::fstream& os) const { std::string timeLabel(makeTimeLabel()); os << "# StartTime = " << timeLabel << " [UTC]" << lineBreak(); posEndTime_ = os.tellg() + std::streamoff(14); os << "# EndTime = " << timeLabel << " [UTC]" << lineBreak(); std::ostringstream oss; dump_header(oss); os << oss.str(); return os; } virtual boost::filesystem::fstream& dumpDataToFile(boost::filesystem::fstream& os) const { os << makeTimeLabel() << " "; std::ostringstream oss; dump_data(oss); os << oss.str(); return os; } virtual void updateTimeTag(boost::filesystem::fstream& os, std::ostream::streampos pos, std::string timeTag) const { os.seekp(pos, std::ios::beg); os << timeTag; os.seekp(0, std::ios::end); } virtual std::string format() const { return "TXT_0000"; } protected: // std::string name_; // ptime time_; private: std::string makeTimeLabel() const { std::stringstream oss; oss.imbue(std::locale(oss.getloc(), new boost::posix_time::time_facet("%Y-%m-%d %H:%M:%S.%f"))); oss << time(); return oss.str(); } void findPositionOfEndTime(const boost::filesystem::path& p) const { boost::filesystem::ifstream ifs(p); std::string line; std::ostream::streampos pos(0); while (std::getline(ifs, line)) { if (line[0] != '#') break; if (std::string(line, 2, 9) == "EndTime ") posEndTime_ = pos + std::streamoff(14); pos += line.size() + 1; } } mutable std::ostream::streampos posEndTime_; // collected results mutable HandleVector handles_; } ; } // namespace Result #endif // _FFT_RESULT_HPP_cm101026_
C++
CL
64bd4b36ec817be55ec73bf9b2ba23ea33aa879a14b30fbf4bc4ab8954139a4a
// Copyright (c) 2015-2016 Vittorio Romeo // License: Academic Free License ("AFL") v. 3.0 // AFL License page: http://opensource.org/licenses/AFL-3.0 // http://vittorioromeo.info | vittorio.romeo@outlook.com // Adapted from: // https://github.com/isocpp/CppCoreGuidelines/issues/353 #pragma once #include <vrm/core/config/names.hpp> #include <vrm/core/utility_macros.hpp> #include <vrm/core/casts/polymorphic.hpp> #include <vrm/core/type_traits/nothrow.hpp> VRM_CORE_NAMESPACE { namespace impl { template <typename TFunctionToCall> struct static_if_result final : TFunctionToCall { template <typename TFFwd> VRM_CORE_ALWAYS_INLINE constexpr static_if_result( TFFwd&& f) noexcept : TFunctionToCall(FWD(f)) { } template <typename TF> VRM_CORE_ALWAYS_INLINE constexpr auto& else_(TF&&) noexcept { // Ignore everything, we found a result. return *this; } template <typename TF> VRM_CORE_ALWAYS_INLINE constexpr auto& then(TF&&) noexcept { // Ignore everything, we found a result. return *this; } template <typename TPredicate> VRM_CORE_ALWAYS_INLINE constexpr auto& else_if(TPredicate) noexcept { // Ignore everything, we found a result. return *this; } }; template <typename TF> VRM_CORE_ALWAYS_INLINE constexpr auto make_static_if_result( TF&& f) noexcept { return static_if_result<TF>{FWD(f)}; } } } VRM_CORE_NAMESPACE_END
C++
CL
424e2091d9037fa48a88aeb76dd69ce3a3bb314634e5fdda99ec5bf2df9cef67
#ifndef HEMERA_COMMONOPERATIONS_H #define HEMERA_COMMONOPERATIONS_H #include <HemeraCore/Global> #include <HemeraCore/Operation> #include <QtDBus/QDBusPendingCall> class QJsonDocument; class QDBusObjectPath; class QProcess; namespace Hemera { class HEMERA_QT5_SDK_EXPORT SequentialOperation : public Hemera::Operation { Q_OBJECT Q_DISABLE_COPY(SequentialOperation) Q_PRIVATE_SLOT(d, void finishedOp(Hemera::Operation *)) public: enum SequenceOption { NoSequenceOptions = 0, ContinueOnFailure = 1 }; Q_DECLARE_FLAGS(SequenceOptions, SequenceOption) Q_FLAGS(SequenceOptions) Q_ENUM(SequenceOption) explicit SequentialOperation(const QList<Hemera::Operation*> &sequence, QObject *parent = nullptr); explicit SequentialOperation(const QList<Hemera::Operation*> &sequence, const QList<Hemera::Operation*> &revertSequence, QObject *parent = nullptr); explicit SequentialOperation(const QList<Hemera::Operation*> &sequence, const QList<Hemera::Operation*> &revertSequence, SequenceOptions options, ExecutionOptions execOptions = NoOptions, QObject *parent = nullptr); virtual ~SequentialOperation(); bool isRunningCleanup() const; bool hasCleanupSucceeded() const; Q_SIGNALS: void stepFinished(Hemera::Operation *op); void stepFailed(Hemera::Operation *op); void cleanupStarted(); void cleanupSucceeded(); void cleanupFailed(Hemera::Operation *failedStep); protected Q_SLOTS: virtual void startImpl() Q_DECL_OVERRIDE Q_DECL_FINAL; private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT CompositeOperation : public Hemera::Operation { Q_OBJECT Q_DISABLE_COPY(CompositeOperation) public: enum CompositeOption { NoCompositeOptions = 0, DontAbortOnFailure = 1 }; Q_DECLARE_FLAGS(CompositeOptions, CompositeOption) Q_FLAGS(CompositeOptions) Q_ENUM(CompositeOption) explicit CompositeOperation(const QList<Hemera::Operation*> &operations, QObject *parent = nullptr); explicit CompositeOperation(const QList<Hemera::Operation*> &operations, CompositeOptions options, ExecutionOptions execOptions = NoOptions, QObject *parent = nullptr); virtual ~CompositeOperation(); protected Q_SLOTS: virtual void startImpl() Q_DECL_OVERRIDE Q_DECL_FINAL; private: class Private; Private * const d; }; /** * QProcess should be an already configured, not started QProcess instance, ready to be started * with start() (with no arguments). */ class HEMERA_QT5_SDK_EXPORT ProcessOperation : public Hemera::Operation { Q_OBJECT Q_DISABLE_COPY(ProcessOperation) public: explicit ProcessOperation(QProcess *process, QObject *parent = nullptr); virtual ~ProcessOperation(); QProcess *process() const; protected Q_SLOTS: virtual void startImpl() Q_DECL_OVERRIDE Q_DECL_FINAL; private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT FailureOperation : public Hemera::Operation { Q_OBJECT Q_DISABLE_COPY(FailureOperation) public: explicit FailureOperation(const QString &errorName, const QString &errorMessage, QObject *parent = nullptr); virtual ~FailureOperation(); protected Q_SLOTS: virtual void startImpl() Q_DECL_OVERRIDE Q_DECL_FINAL; private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT SuccessOperation : public Hemera::Operation { Q_OBJECT Q_DISABLE_COPY(SuccessOperation) public: explicit SuccessOperation(QObject *parent = nullptr); virtual ~SuccessOperation(); protected Q_SLOTS: virtual void startImpl() Q_DECL_OVERRIDE Q_DECL_FINAL; private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT DBusVoidOperation : public Hemera::Operation { Q_OBJECT Q_DISABLE_COPY(DBusVoidOperation) public: explicit DBusVoidOperation(const QDBusPendingCall &call, QObject *parent = nullptr); virtual ~DBusVoidOperation(); protected Q_SLOTS: virtual void startImpl() Q_DECL_OVERRIDE Q_DECL_FINAL; private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT ObjectOperation : public Hemera::Operation { Q_OBJECT Q_DISABLE_COPY(ObjectOperation) Q_PROPERTY(QObject * result READ result) public: virtual ~ObjectOperation(); virtual QObject *result() const = 0; protected: explicit ObjectOperation(QObject *parent = nullptr); private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT VariantOperation : public Hemera::Operation { Q_OBJECT Q_DISABLE_COPY(VariantOperation) Q_PROPERTY(QVariant result READ result) public: virtual ~VariantOperation(); virtual QVariant result() const = 0; protected: explicit VariantOperation(QObject *parent = nullptr); private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT DBusVariantOperation : public Hemera::VariantOperation { Q_OBJECT Q_DISABLE_COPY(DBusVariantOperation) Q_PROPERTY(QVariant result READ result) public: DBusVariantOperation(const QDBusPendingCall &call, QObject *parent = nullptr); virtual ~DBusVariantOperation(); virtual QVariant result() const override; protected Q_SLOTS: virtual void startImpl() Q_DECL_OVERRIDE Q_DECL_FINAL; private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT VariantMapOperation : public Hemera::Operation { Q_OBJECT Q_DISABLE_COPY(VariantMapOperation) Q_PROPERTY(QVariantMap result READ result) public: virtual ~VariantMapOperation(); virtual QVariantMap result() const = 0; protected: explicit VariantMapOperation(QObject *parent = nullptr); private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT DBusVariantMapOperation : public Hemera::VariantMapOperation { Q_OBJECT Q_DISABLE_COPY(DBusVariantMapOperation) Q_PROPERTY(QVariantMap result READ result) public: DBusVariantMapOperation(const QDBusPendingCall &call, QObject *parent = nullptr); virtual ~DBusVariantMapOperation(); virtual QVariantMap result() const override; protected Q_SLOTS: virtual void startImpl() Q_DECL_OVERRIDE Q_DECL_FINAL; private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT BoolOperation : public Hemera::Operation { Q_OBJECT Q_DISABLE_COPY(BoolOperation) Q_PROPERTY(bool result READ result) public: virtual ~BoolOperation(); virtual bool result() const = 0; protected: BoolOperation(QObject *parent = nullptr); private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT DBusBoolOperation : public Hemera::BoolOperation { Q_OBJECT Q_DISABLE_COPY(DBusBoolOperation) Q_PROPERTY(bool result READ result) public: DBusBoolOperation(const QDBusPendingCall &call, QObject *parent = nullptr); virtual ~DBusBoolOperation(); virtual bool result() const override; protected Q_SLOTS: virtual void startImpl() Q_DECL_OVERRIDE Q_DECL_FINAL; private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT UIntOperation : public Hemera::Operation { Q_OBJECT Q_DISABLE_COPY(UIntOperation) Q_PROPERTY(uint result READ result) public: virtual ~UIntOperation(); virtual uint result() const = 0; protected: UIntOperation(QObject *parent = nullptr); private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT DBusUIntOperation : public Hemera::UIntOperation { Q_OBJECT Q_DISABLE_COPY(DBusUIntOperation) Q_PROPERTY(uint result READ result) public: DBusUIntOperation(const QDBusPendingCall &call, QObject *parent = nullptr); virtual ~DBusUIntOperation(); virtual uint result() const override; protected Q_SLOTS: virtual void startImpl() Q_DECL_OVERRIDE Q_DECL_FINAL; private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT ByteArrayOperation : public Hemera::Operation { Q_OBJECT Q_DISABLE_COPY(ByteArrayOperation) Q_PROPERTY(QByteArray result READ result) public: virtual ~ByteArrayOperation(); virtual QByteArray result() const = 0; protected: ByteArrayOperation(QObject *parent = nullptr); private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT DBusByteArrayOperation : public Hemera::ByteArrayOperation { Q_OBJECT Q_DISABLE_COPY(DBusByteArrayOperation) Q_PROPERTY(QByteArray result READ result) public: DBusByteArrayOperation(const QDBusPendingCall &call, QObject *parent = nullptr); virtual ~DBusByteArrayOperation(); virtual QByteArray result() const override; protected Q_SLOTS: virtual void startImpl() Q_DECL_OVERRIDE Q_DECL_FINAL; private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT SSLCertificateOperation : public Hemera::Operation { Q_OBJECT Q_DISABLE_COPY(SSLCertificateOperation) Q_PROPERTY(QByteArray privateKey READ privateKey) Q_PROPERTY(QByteArray certificate READ certificate) public: virtual ~SSLCertificateOperation(); virtual QByteArray privateKey() const = 0; virtual QByteArray certificate() const = 0; protected: SSLCertificateOperation(QObject *parent = nullptr); private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT DBusSSLCertificateOperation : public Hemera::SSLCertificateOperation { Q_OBJECT Q_DISABLE_COPY(DBusSSLCertificateOperation) Q_PROPERTY(QByteArray privateKey READ privateKey) Q_PROPERTY(QByteArray certificate READ certificate) public: DBusSSLCertificateOperation(const QDBusPendingCall &call, QObject *parent = nullptr); virtual ~DBusSSLCertificateOperation(); virtual QByteArray privateKey() const override; virtual QByteArray certificate() const override; protected Q_SLOTS: virtual void startImpl() override final; private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT StringOperation : public Hemera::Operation { Q_OBJECT Q_DISABLE_COPY(StringOperation) Q_PROPERTY(QString result READ result) public: virtual ~StringOperation(); virtual QString result() const = 0; protected: StringOperation(QObject *parent = nullptr); private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT DBusStringOperation : public Hemera::StringOperation { Q_OBJECT Q_DISABLE_COPY(DBusStringOperation) Q_PROPERTY(QString result READ result) public: DBusStringOperation(const QDBusPendingCall &call, QObject *parent = nullptr); virtual ~DBusStringOperation(); virtual QString result() const override; protected Q_SLOTS: virtual void startImpl() Q_DECL_OVERRIDE Q_DECL_FINAL; private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT StringListOperation : public Hemera::Operation { Q_OBJECT Q_DISABLE_COPY(StringListOperation) Q_PROPERTY(QStringList result READ result) public: virtual ~StringListOperation(); virtual QStringList result() const = 0; protected: StringListOperation(QObject *parent = nullptr); private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT DBusStringListOperation : public Hemera::StringListOperation { Q_OBJECT Q_DISABLE_COPY(DBusStringListOperation) Q_PROPERTY(QStringList result READ result) public: DBusStringListOperation(const QDBusPendingCall &call, QObject *parent = nullptr); virtual ~DBusStringListOperation(); virtual QStringList result() const override; protected Q_SLOTS: virtual void startImpl() Q_DECL_OVERRIDE Q_DECL_FINAL; private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT JsonOperation : public Hemera::Operation { Q_OBJECT Q_DISABLE_COPY(JsonOperation) Q_PROPERTY(QJsonDocument result READ result) public: virtual ~JsonOperation(); virtual QJsonDocument result() const = 0; protected: JsonOperation(QObject *parent = nullptr); private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT DBusJsonOperation : public Hemera::JsonOperation { Q_OBJECT Q_DISABLE_COPY(DBusJsonOperation) Q_PROPERTY(QJsonDocument result READ result) public: DBusJsonOperation(const QDBusPendingCall &call, QObject *parent = nullptr); virtual ~DBusJsonOperation(); QJsonDocument result() const; protected Q_SLOTS: virtual void startImpl() Q_DECL_OVERRIDE Q_DECL_FINAL; private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT DBusObjectPathOperation : public Hemera::Operation { Q_OBJECT Q_DISABLE_COPY(DBusObjectPathOperation ) Q_PROPERTY(QDBusObjectPath result READ result) public: DBusObjectPathOperation (const QDBusPendingCall &call, QObject *parent = nullptr); virtual ~DBusObjectPathOperation (); QDBusObjectPath result() const; protected Q_SLOTS: virtual void startImpl() Q_DECL_OVERRIDE Q_DECL_FINAL; private: class Private; Private * const d; }; class HEMERA_QT5_SDK_EXPORT UrlOperation : public Hemera::Operation { Q_OBJECT Q_DISABLE_COPY(UrlOperation) Q_PROPERTY(QUrl result READ result) public: virtual ~UrlOperation(); virtual QUrl result() const = 0; protected: UrlOperation(QObject *parent = nullptr); private: class Private; Private * const d; }; } #endif // HEMERA_DBUSVOIDOPERATION_H
C++
CL
657747d0136ccb0909008128f789bebcd00275889fe66a7ff84893dda8d3a457
// Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved. // http://getmoai.com #ifndef MOAIVECTORTESSELATOR_H #define MOAIVECTORTESSELATOR_H #include <moai-sim/MOAIRegion.h> #include <moai-sim/MOAIVectorUtil.h> class MOAIIndexBuffer; class MOAIVectorShape; class MOAIVertexBuffer; class SafeTesselator; //================================================================// // MOAIVectorTesselator //================================================================// /** @lua MOAIVectorTessalator @text Convert vector primitives into triangles. */ class MOAIVectorTesselator : public MOAILuaObject { private: enum { VERTEX_SIZE = 16, }; ZLLeanStack < MOAIVectorShape*, 64 > mDirectory; // TODO: should use a chunked array or something ZLLeanStack < MOAIVectorShape*, 16 > mShapeStack; // TODO: ditto ZLLeanStack < ZLVec2D, 32 > mVertexStack; bool mPolyClosed; ZLMemStream mIdxStream; ZLMemStream mVtxStream; float mDepthBias; float mDepthOffset; MOAIVectorStyle mStyle; bool mVerbose; ZLLeanStack < ZLAffine2D, 16 > mMatrixStack; size_t mVtxExtraSize; ZLLeanArray < void* > mVtxExtras; bool mGenerateMask; SafeTesselator mMaskTesselator; MOAILuaSharedPtr < MOAIRegion > mMask; //----------------------------------------------------------------// static int _clearTransforms ( lua_State* L ); static int _drawingToWorld ( lua_State* L ); static int _drawingToWorldVec ( lua_State* L ); static int _finish ( lua_State* L ); static int _getMask ( lua_State* L ); static int _getTransform ( lua_State* L ); static int _getTriangles ( lua_State* L ); static int _pushBezierVertices ( lua_State* L ); static int _pushCombo ( lua_State* L ); static int _pushEllipse ( lua_State* L ); static int _pushPoly ( lua_State* L ); static int _pushRect ( lua_State* L ); static int _pushRotate ( lua_State* L ); static int _pushScale ( lua_State* L ); static int _pushSkew ( lua_State* L ); static int _pushTransform ( lua_State* L ); static int _pushTranslate ( lua_State* L ); static int _pushVertex ( lua_State* L ); static int _reserveVertexExtras ( lua_State* L ); static int _setCapStyle ( lua_State* L ); static int _setCircleResolution ( lua_State* L ); static int _setDepthBias ( lua_State* L ); static int _setExtrude ( lua_State* L ); static int _setFillColor ( lua_State* L ); static int _setFillStyle ( lua_State* L ); static int _setFillExtra ( lua_State* L ); static int _setJoinStyle ( lua_State* L ); static int _setLightColor ( lua_State* L ); static int _setLightCurve ( lua_State* L ); static int _setLightVec ( lua_State* L ); static int _setLineColor ( lua_State* L ); static int _setLineStyle ( lua_State* L ); static int _setLineWidth ( lua_State* L ); static int _setMiterLimit ( lua_State* L ); static int _setPolyClosed ( lua_State* L ); static int _setShadowColor ( lua_State* L ); static int _setShadowCurve ( lua_State* L ); static int _setStrokeColor ( lua_State* L ); static int _setStrokeDepthBias ( lua_State* L ); static int _setStrokeExtra ( lua_State* L ); static int _setStrokeStyle ( lua_State* L ); static int _setStrokeWidth ( lua_State* L ); static int _setVerbose ( lua_State* L ); static int _setVertexExtra ( lua_State* L ); static int _setWindingRule ( lua_State* L ); static int _worldToDrawing ( lua_State* L ); static int _worldToDrawingVec ( lua_State* L ); //----------------------------------------------------------------// u32 PushShape ( MOAIVectorShape* shape ); int Tesselate (); void WriteVertex ( float x, float y, float z, u32 color, u32 vertexExtraID ); public: DECL_LUA_FACTORY ( MOAIVectorTesselator ) GET_SET ( MOAIVectorStyle&, Style, mStyle ) GET_SET ( bool, Verbose, mVerbose ) GET_SET ( bool, PolyClosed, mPolyClosed ) GET_SET ( float, DepthBias, mDepthBias ) //----------------------------------------------------------------// void Clear (); void ClearTransforms (); u32 CountVertices (); int Finish ( bool generateMask ); SafeTesselator* GetMaskTesselator (); void GetTriangles ( MOAIVertexBuffer& vtxBuffer, MOAIIndexBuffer& idxBuffer ); MOAIVectorTesselator (); ~MOAIVectorTesselator (); void PopTransform (); void PushBezierVertices ( const ZLVec2D& p0, const ZLVec2D& p1, const ZLVec2D& p2, const ZLVec2D& p3 ); void PushCombo (); void PushEllipse ( float x, float y, float xRad, float yRad ); void PushPoly ( ZLVec2D* vertices, u32 total, bool closed ); void PushRect ( float xMin, float yMin, float xMax, float yMax ); void PushRotate ( float x, float y, float r ); void PushScale ( float x, float y ); void PushSkew ( float yx, float xy ); void PushTransform ( const ZLAffine2D& transform ); void PushTransform ( float a, float b, float c, float d, float tx, float ty ); void PushTranslate ( float x, float y); void PushVertex ( float x, float y ); void RegisterLuaClass ( MOAILuaState& state ); void RegisterLuaFuncs ( MOAILuaState& state ); void ReserveVertexExtras ( u32 total, size_t size ); void SetVertexExtra ( u32 idx, void* extra, size_t size ); void WriteContourIndices ( SafeTesselator* tess, u32 base ); void WriteSkirt ( SafeTesselator* tess, const MOAIVectorStyle& style, const ZLColorVec& fillColor, u32 vertexExtraID ); void WriteTriangleIndices ( SafeTesselator* tess, u32 base ); void WriteVertices ( SafeTesselator* tess, float z, u32 color, u32 vertexExtraID ); }; #endif
C++
CL
f0389e550fefda1bcee8a31d860cab600854f235e6c3f716f9fcd6a0b4ee5cea
/* * Author: Harry * Email: khchanak@cse.ust.hk */ #include "yoo_alg.h" /* * The implementation of joinless colocation mining algorithm. */ fsi_set_t** joinless_mining(data_t* data_v, int numOfObj, int numOfFea) { unordered_map<FEA_TYPE, vector<obj_set_t*>*> SN; fsi_set_t** result; //storing overall result fsi_set_t* fsi_set_cur; //prev = L_{k-1}, cur = L_{k} fsi_t *fsi_v1, *fsi_v2, *fsi_v3; FEA_TYPE fea_v1; B_KEY_TYPE sup; int i; //Initialize the structure for storing L_1, L_2, ..., L_{|F|} result = (fsi_set_t**)malloc(numOfFea * sizeof(fsi_set_t*)); memset(result, 0, numOfFea * sizeof(fsi_set_t*)); /*s*/ stat_v.memory_v += numOfFea * sizeof(fsi_set_t*); if (stat_v.memory_v > stat_v.memory_max) stat_v.memory_max = stat_v.memory_v; /*s*/ SN = gen_star_neighborhoods(data_v); /*s*/ for (auto it = SN.begin(); it != SN.end(); ++it) stat_v.memory_v += it->second->size() * sizeof(obj_set_t*); if (stat_v.memory_v > stat_v.memory_max) stat_v.memory_max = stat_v.memory_v; /*s*/ #ifndef WIN32 struct rusage query_sta, query_end; float sys_t, usr_t, usr_t_sum = 0; GetCurTime(&query_sta); #endif //L_1 result[0] = const_L1_apriori(); #ifndef WIN32 GetCurTime(&query_end); GetTime(&query_sta, &query_end, &usr_t, &sys_t); printf("L_1 time:%0.5lf\n", usr_t); GetCurTime(&query_sta); #endif //L_(i+1) for (i = 1; i < numOfFea; i++) { fsi_v1 = result[i - 1]->head->next; if (fsi_v1 == NULL) break; fsi_set_cur = alloc_fsi_set(); while (fsi_v1->next != NULL) { fsi_v2 = fsi_v1->next; while (fsi_v2 != NULL) { //join step. if ((fea_v1 = join_check(fsi_v1, fsi_v2)) != -1) { fsi_v3 = add_fsi(fsi_v1, fea_v1); //prune step. if (i > 1 && !all_subesets_exist(result[i - 1], fsi_v3)) { /*s*/ stat_v.memory_v -= sizeof(fsi_t) + fsi_v3->fea_n * sizeof(FEA_TYPE); /*s*/ release_fsi(fsi_v3); fsi_v2 = fsi_v2->next; continue; } //---------------------------- check_star_instance(fsi_v3, SN); if (fsi_v3->fea_n > 2) { if (cost_tag == 1) //participation based sup = comp_PI(fsi_v3, NULL); else //fraction based sup = comp_sup(fsi_v3, NULL); if (sup < min_sup) { //fsi_v3 is not a frequent pattern for (auto i = fsi_v3->obj_set_list_v->begin(); i != fsi_v3->obj_set_list_v->end(); ++i) release_obj_set(*i); /*s*/ stat_v.memory_v -= fsi_v3->obj_set_list_v->size() * sizeof(obj_set_t*); /*s*/ delete (fsi_v3->obj_set_list_v); release_fsi(fsi_v3); fsi_v2 = fsi_v2->next; continue; } filter_clique_instance(fsi_v3, result[i - 1], fsi_v3->obj_set_list_v); } //count step. if (cost_tag == 1) //participation based sup = comp_PI(fsi_v3, NULL); else //fraction based sup = comp_sup(fsi_v3, NULL); //---------------------------- if (sup >= min_sup) add_fsi_set_entry(fsi_set_cur, fsi_v3); else { //fsi_v3 is not a frequent pattern for (auto i = fsi_v3->obj_set_list_v->begin(); i != fsi_v3->obj_set_list_v->end(); ++i) release_obj_set(*i); /*s*/ stat_v.memory_v -= fsi_v3->obj_set_list_v->size() * sizeof(obj_set_t*); stat_v.memory_v -= sizeof(fsi_t) + fsi_v3->fea_n * sizeof(FEA_TYPE); /*s*/ delete (fsi_v3->obj_set_list_v); release_fsi(fsi_v3); } } fsi_v2 = fsi_v2->next; } fsi_v1 = fsi_v1->next; } #ifndef WIN32 GetCurTime(&query_end); GetTime(&query_sta, &query_end, &usr_t, &sys_t); printf("L_%d\ttime:%0.5lf\t fsi_n:%d\n", i + 1, usr_t, fsi_set_cur->fsi_n); GetCurTime(&query_sta); #endif /*t*/ //print out each level for debug if (debug_mode) { printf("L_%d\n", i + 1); int cnt = 0; fsi_t* fsi_v = fsi_set_cur->head->next; while (fsi_v != NULL) { print_fsi(fsi_v, stdout); fsi_v = fsi_v->next; cnt++; } } //printf("L_%d: %d\n",i+1, fsi_set_cur->fsi_n); result[i] = fsi_set_cur; } return result; } //generate a set of feature f_i star neighborhood unordered_map<FEA_TYPE, vector<obj_set_t*>*> gen_star_neighborhoods(data_t* data_v) { unordered_map<FEA_TYPE, vector<obj_set_t*>*> SN; vector<obj_set_t*>* temp; k_node_t* k_head; disk_t* disk_v; loc_t* loc_v; obj_set_t* obj_set_v; obj_t* obj_v; k_head = collect_keywords_bst(IF_v); //for each object for (int i = 0; i < data_v->obj_n; i++) { //------ FEA_TYPE fea = data_v->obj_v[i].fea; bst_node_t* bst_node_v = bst_search(IF_v, fea); if(bst_node_v !=NULL){ double n = bst_node_v->p_list_obj->obj_n; if(n<fea_highest_freq*min_sup){ continue; } } //---- obj_v = &data_v->obj_v[i]; //find all objects in range D(o,d) loc_v = get_obj_loc(obj_v); disk_v = alloc_disk(IRTree_v.dim); set_disk(disk_v, loc_v, dist_thr); obj_set_v = range_query(disk_v); // printf("i:%d\tobj_v:%d\n",i,obj_v->id); temp = new vector<obj_set_t*>(); /*s*/ stat_v.memory_v += sizeof(vector<obj_set_t*>); if (stat_v.memory_v > stat_v.memory_max) stat_v.memory_max = stat_v.memory_v; /*s*/ gen_one_star_neighborhood(obj_v, obj_set_v, temp); auto got = SN.find(obj_v->fea); if (got == SN.end()) //if the obj_set_list for this feature is not exist yet { SN.insert({ data_v->obj_v[i].fea, temp }); } else { //copy temp to the end of corresponding list in SN got->second->insert(got->second->end(), temp->begin(), temp->end()); delete (temp); } release_disk(disk_v); release_obj_set(obj_set_v); release_loc(loc_v); } release_k_list(k_head); return SN; } /* * generate one star neighborhood and insert into temp * obj in @obj_set_v with fea > obj_v->fea are included in the star neighborhood * @obj_v is the first (i.e, head->next) element in S_0 * */ void gen_one_star_neighborhood(obj_t* obj_v, obj_set_t* obj_set_v, vector<obj_set_t*>* temp) { obj_set_t* S_0; obj_node_t* obj_node_v; //Initialize the S_0. S_0 = alloc_obj_set(); obj_node_v = obj_set_v->head->next; while (obj_node_v != NULL) { if (obj_node_v->obj_v->fea > obj_v->fea) add_obj_set_entry(obj_node_v->obj_v, S_0); obj_node_v = obj_node_v->next; } add_obj_set_entry(obj_v, S_0); temp->push_back(S_0); return; } /* * 1. Find all row instances of fsi_v * (based on the materialized star instances @SN and by filtering technique) * 2. Result stored in fsi_v->obj_set_list_v */ void check_star_instance(fsi_t* fsi_v, unordered_map<FEA_TYPE, vector<obj_set_t*>*> SN) { vector<obj_set_t *> *obj_set_list_v, *obj_set_list_temp; obj_set_t* obj_set_v; bst_t* inverted_list; psi_t* psi_v; // if(fsi_v->fea_n==3) // { // print_fsi(fsi_v, stdout); // } //finding star neighborhoods with the first feature in fsi_v auto got = SN.find(fsi_v->feaset[0]); if (got == SN.end()) { printf("feature %d not found!! exiting.\n", fsi_v->feaset[0]); exit(-1); } //all star neigbhorhoods with first object having fsi_v->feaset[0] obj_set_list_v = got->second; psi_v = fsi_to_psi(fsi_v, fsi_v->feaset[0]); //excluding the first one //------------------------------------------------------------------------- //for each star neighborhood for (auto i = obj_set_list_v->begin(); i != obj_set_list_v->end(); ++i) { obj_set_v = *i; inverted_list = const_IF(obj_set_v, psi_v); //generate star instances obj_set_list_temp = filter_star_instance(obj_set_v->head->next->obj_v, inverted_list); release_IF(inverted_list); /*t*/ // for (auto j = obj_set_list_temp->begin(); j != obj_set_list_v->end(); ++j) // print_obj_set(*j, stdout); /*t*/ //append obj_set_list_temp to fsi_v->obj_set_list_v for k+1 to filter clique instance if (fsi_v->obj_set_list_v == NULL) { fsi_v->obj_set_list_v = obj_set_list_temp; } else { //copy the obj_set_list_temp to the end of fsi_v->obj_set_list_v fsi_v->obj_set_list_v->insert(fsi_v->obj_set_list_v->end(), obj_set_list_temp->begin(), obj_set_list_temp->end()); delete (obj_set_list_temp); } } release_psi(psi_v); return; } /* * generate star instances * @obj_v: first object in the instance * @inverted_list: generated from the corresponding star neighborhood * return @obj_set_list_v: start instances each involves @obj_v */ vector<obj_set_t*>* filter_star_instance(obj_t* obj_v, bst_t* inverted_list) { vector<obj_set_t*>* obj_set_list_v; obj_set_t* S_0; S_0 = alloc_obj_set(); add_obj_set_entry(obj_v, S_0); obj_set_list_v = new vector<obj_set_t*>(); /*s*/ stat_v.memory_v += sizeof(vector<obj_set_t*>); if (stat_v.memory_v > stat_v.memory_max) stat_v.memory_max = stat_v.memory_v; /*s*/ filter_star_instance_sub(inverted_list, S_0, obj_set_list_v); /*s*/ stat_v.memory_v += obj_set_list_v->size() * sizeof(obj_set_t*) + sizeof(vector<obj_set_t*>*); if (stat_v.memory_v > stat_v.memory_max) stat_v.memory_max = stat_v.memory_v; /*s*/ release_obj_set(S_0); return obj_set_list_v; } /* * The sub-procedure * */ void filter_star_instance_sub(bst_t* IF_v, obj_set_t* S_0, vector<obj_set_t*>* obj_set_list_v) { obj_t* obj_v; bst_node_t* bst_node_v; obj_node_t* obj_node_v; bst_node_list_t* bst_node_list_v; if (IF_v->node_n == 0) { obj_set_t* S; S = copy_obj_set(S_0); obj_set_list_v->push_back(S); return; } bst_node_v = IF_v->root; obj_node_v = bst_node_v->p_list_obj->head->next; while (obj_node_v != NULL) { //Pick an object. obj_v = obj_node_v->obj_v; //Update the IF_v. bst_node_list_v = update_IF_obj(IF_v, obj_v); //Update the S_0. //obj_v is added at the first place of S_0. add_obj_set_entry(obj_v, S_0); //Sub-procedure. filter_star_instance_sub(IF_v, S_0, obj_set_list_v); //Restore the S_0. remove_obj_set_entry(S_0); //Restore the IF_v. restore_IF_bst_node_list(IF_v, bst_node_list_v); release_bst_node_list(bst_node_list_v); //Try the next object candidate. obj_node_v = obj_node_v->next; } return; } //for each obj_set_v in fsi_cur->obj_set_list_v, check clique instance for objects except the one with fsi_cur->feaset[0] //remove it from the list if not clique //checking can be done by searching C_k-1 void filter_clique_instance(fsi_t* fsi_cur, fsi_set_t* fsi_set_v, vector<obj_set_t*>* obj_set_list_v) { fsi_t* fsi_v; obj_node_t* obj_node_temp; //------------------------- //first we find the corresponding fsi // e.g., fsi_cur = {A, B, C}; fsi_v = {B, C} fsi_v = fsi_set_v->head->next; while (fsi_v != NULL) { //if(fsi_cur->fea[1-] == fsi_v->fea[] if (memcmp(&fsi_cur->feaset[1], fsi_v->feaset, (fsi_v->fea_n) * sizeof(FEA_TYPE)) == 0) break; fsi_v = fsi_v->next; } //fsi_v == correspodning fsi || NULL if (fsi_v == NULL) { printf("fsi_v not found!! exiting\n"); print_fsi(fsi_v, stdout); exit(-1); } //------------------- //second we check whether obj_set_v (i) exist in fsi_v->obj_set_list-v for (auto i = obj_set_list_v->begin(); i != obj_set_list_v->end(); /*++i*/) { bool tag = false; for (auto j = fsi_v->obj_set_list_v->begin(); j != fsi_v->obj_set_list_v->end(); ++j) { if (check_obj_set_equal(*i, *j, fsi_cur->feaset[0])) { tag = true; break; } } if (!tag) //not exist { //remove current obj_set_v from obj_set_list_v release_obj_set(*i); obj_set_list_v->erase(i); } else { //the current object set is clique i++; } } } /* * check whether two object sets contain the same set of objects * obj with fea in v1 is not checked */ bool check_obj_set_equal(obj_set_t* v1, obj_set_t* v2, FEA_TYPE fea) { obj_node_t *obj_node_v1, *obj_node_v2; if (v1->obj_n - 1 != v2->obj_n) { printf("error!\n"); print_obj_set(v1, stdout); print_obj_set(v2, stdout); exit(-1); } obj_node_v1 = v1->head->next; while (obj_node_v1 != NULL) { if (obj_node_v1->obj_v->fea == fea) { obj_node_v1 = obj_node_v1->next; continue; } bool tag = false; obj_node_v2 = v2->head->next; while (obj_node_v2 != NULL) { if (obj_node_v1->obj_v == obj_node_v2->obj_v) { tag = true; break; } obj_node_v2 = obj_node_v2->next; } if (!tag) return false; obj_node_v1 = obj_node_v1->next; } return true; } /* * Output: @sup = sup(C) */ B_KEY_TYPE comp_PI(fsi_t* fsi_v, obj_set_t* O) { double participation_index, participation_ratio; obj_node_t* obj_node_v; obj_set_t* obj_set_v; participation_index = INFINITY; //for each feature f in C for (int i = 0; i < fsi_v->fea_n; i++) { participation_ratio = 0; if (O != NULL) //L1 obj_set_v = O; else //L_k //the corresponding inverted list in IF obj_set_v = ((bst_node_t*)bst_search(IF_v, fsi_v->feaset[i]))->p_list_obj; obj_node_v = obj_set_v->head->next; //for each object o with the feature f while (obj_node_v != NULL) { if (obj_exist(fsi_v->obj_set_list_v, obj_node_v->obj_v)) { participation_ratio += 1; } obj_node_v = obj_node_v->next; } participation_ratio = participation_ratio / (double)obj_set_v->obj_n; if (participation_ratio <= participation_index) participation_index = participation_ratio; } fsi_v->sup = participation_index; return participation_index; } /* * Output: @sup = sup(C) */ B_KEY_TYPE comp_sup(fsi_t* fsi_v, obj_set_t* O) { B_KEY_TYPE sup, sup_C_f; obj_node_t* obj_node_v; obj_set_t* obj_set_v; loc_t* loc_v; disk_t* disk_v; sup = INFINITY; sup_C_f = 0; //for each feature f in C for (int i = 0; i < fsi_v->fea_n; i++) { sup_C_f = 0; if (O != NULL) //L1 obj_node_v = O->head->next; else //L_k //the corresponding inverted list in IF obj_node_v = ((bst_node_t*)bst_search(IF_v, fsi_v->feaset[i]))->p_list_obj->head->next; //for each object o with the feature f while (obj_node_v != NULL) { if (obj_exist(fsi_v->obj_set_list_v, obj_node_v->obj_v)) { sup_C_f += min_frac_receive(fsi_v, obj_node_v->obj_v); if (sup_C_f > sup) { // stat_v.S4_sum++; break; } } obj_node_v = obj_node_v->next; } if (sup_C_f <= sup) sup = sup_C_f; } sup = sup / fea_highest_freq; fsi_v->sup = sup; return sup; } // check whether the object @obj_v exist in any of the object set in @obj_set_list_v bool obj_exist(vector<obj_set_t*>* obj_set_list_v, obj_t* obj_v) { obj_node_t* obj_node_v; for (auto i = obj_set_list_v->begin(); i < obj_set_list_v->end(); i++) { obj_node_v = (*i)->head->next; while (obj_node_v != NULL) { if (obj_node_v->obj_v == obj_v) return true; obj_node_v = obj_node_v->next; } } return false; }
C++
CL
66ec5d108a41167007d578258f83a52bf05d0096089afe045afa6149aaba9b9e
#include "easehts/unittest.h" #include "easehts/pileup.h" #include "easehts/sam_bam_reader.h" #include "easehts/sam_bam_record.h" #include <gtest/gtest.h> using namespace ncic::easehts; typedef struct TraverseData { BAMIndexReader* reader; } TraverseData; int fun(void *data, bam1_t *b) { TraverseData& traverse_data = *(TraverseData*)data; while (traverse_data.reader->HasNext(b)) { return 0; } return -1; } TEST(Next, PileupTraverse) { TEST_FILE("pileup/mpileup.1.bam", filename); BAMIndexReader reader(filename); TraverseData data; data.reader = &reader; PileupTraverse traverse(fun, &data); int count = 0; while (traverse.HasNext()) { ReadBackedRawPileup plp = traverse.Next(); if (count == 0) { EXPECT_EQ(plp.Size(), 5); } count ++; //printf("contig:%d pos:%d count:%d\n", plp.GetContigId(), // plp.GetPos(), plp.Size()); } EXPECT_EQ(traverse.Next().Size(), 0); EXPECT_EQ(count, 4101); } TEST(MutectBam, NormalPileupTraverse) { TEST_FILE("localtestdata/middle/MG225_normal_sorted_X.bam", filename); BAMIndexReader reader(filename); reader.SetRegion(22, 15482483-3000, 15482603+3000); TraverseData data; data.reader = &reader; PileupTraverse traverse(fun, &data); while (traverse.HasNext()) { ReadBackedRawPileup plp = traverse.Next(); if (plp.GetPos() == 15482483) { EXPECT_EQ(plp.Size(), 158); break; } } } TEST(MutectBam, TumorPileupTraverse) { TEST_FILE("localtestdata/middle/MG225_tumor_sorted_X.bam", filename); BAMIndexReader reader(filename); reader.SetRegion(22, 15482483-3000, 15482603+3000); TraverseData data; data.reader = &reader; PileupTraverse traverse(fun, &data); while (traverse.HasNext()) { ReadBackedRawPileup plp = traverse.Next(); if (plp.GetPos() == 15482483) { EXPECT_EQ(plp.Size(), 266); break; } } }
C++
CL
7d20bccb2b7e446801e7c972e02c862d83636a3f592e85ddb925256e72151c1f
#pragma once #ifndef _mapAddedPolyMesh_Header #define _mapAddedPolyMesh_Header /*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Class tnbLib::mapAddedPolyMesh Description Class containing mesh-to-mesh mapping information after a mesh addition where we add a mesh ('added mesh') to an old mesh, creating a new mesh. We store mapping from the old to the new mesh and from the added mesh to the new mesh. Note: Might need some more access functions or maybe some zone maps? SourceFiles mapAddedPolyMesh.C \*---------------------------------------------------------------------------*/ #include <labelList.hxx> // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace tnbLib { class mapPolyMesh; /*---------------------------------------------------------------------------*\ Class mapAddedPolyMesh Declaration \*---------------------------------------------------------------------------*/ class mapAddedPolyMesh { // Private Data //- Old mesh points/face/cells label nOldPoints_; label nOldFaces_; label nOldCells_; //- Added mesh points/faces/cells label nAddedPoints_; label nAddedFaces_; label nAddedCells_; //- From old mesh points to new points labelList oldPointMap_; //- From old mesh faces to new faces labelList oldFaceMap_; //- From old mesh cells to new cells labelList oldCellMap_; //- From added mesh points to new points labelList addedPointMap_; //- From added mesh faces to new faces labelList addedFaceMap_; //- From added mesh cells to new cells labelList addedCellMap_; //- Original mesh to new mesh patch map. -1 for deleted patches. labelList oldPatchMap_; //- Added mesh to new mesh patch map. -1 for deleted patches. labelList addedPatchMap_; //- Original patch sizes on old mesh labelList oldPatchSizes_; //- Original patch starts labelList oldPatchStarts_; public: // Constructors //- Construct from components FoamBase_EXPORT mapAddedPolyMesh ( const label nOldPoints, const label nOldFaces, const label nOldCells, const label nAddedPoints, const label nAddedFaces, const label nAddedCells, const labelList& oldPointMap, const labelList& oldFaceMap, const labelList& oldCellMap, const labelList& addedPointMap, const labelList& addedFaceMap, const labelList& addedCellMap, const labelList& oldPatchMap, const labelList& addedPatchMap, const labelList& oldPatchSizes, const labelList& oldPatchStarts ); // Member Functions // Access // Old mesh data label nOldPoints() const { return nOldPoints_; } label nOldFaces() const { return nOldFaces_; } label nOldCells() const { return nOldCells_; } //- From old mesh point/face/cell to new mesh point/face/cell. const labelList& oldPointMap() const { return oldPointMap_; } const labelList& oldFaceMap() const { return oldFaceMap_; } const labelList& oldCellMap() const { return oldCellMap_; } //- From old patch index to new patch index or -1 if patch // not present (since 0 size) const labelList& oldPatchMap() const { return oldPatchMap_; } //- Return list of the old patch sizes const labelList& oldPatchSizes() const { return oldPatchSizes_; } //- Return list of the old patch start labels const labelList& oldPatchStarts() const { return oldPatchStarts_; } //- Number of old internal faces label nOldInternalFaces() const { return oldPatchStarts_[0]; } // Added mesh data label nAddedPoints() const { return nAddedPoints_; } label nAddedFaces() const { return nAddedFaces_; } label nAddedCells() const { return nAddedCells_; } //- From added mesh point/face/cell to new mesh point/face/cell. const labelList& addedPointMap() const { return addedPointMap_; } const labelList& addedFaceMap() const { return addedFaceMap_; } const labelList& addedCellMap() const { return addedCellMap_; } //- From added mesh patch index to new patch index or -1 if // patch not present (since 0 size) const labelList& addedPatchMap() const { return addedPatchMap_; } // Edit void updateMesh(const mapPolyMesh&) { NotImplemented; } }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace tnbLib // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif // !_mapAddedPolyMesh_Header
C++
CL
edc8fcb21620e73b87a05181f7457a860f4d6a5529bc55927326b99c1e8d2810
#ifndef GM_INSTANCE_HPP #define GM_INSTANCE_HPP #include <map> #include <set> #include <string> #include <vector> #include <iostream> #include <fstream> #include <boost/bimap.hpp> #include <boost/iostreams/filtering_streambuf.hpp> #include <boost/iostreams/device/file_descriptor.hpp> #include <boost/archive/xml_iarchive.hpp> #include <boost/archive/xml_oarchive.hpp> #include <boost/archive/binary_iarchive.hpp> #include <boost/archive/binary_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> #include <boost/serialization/vector.hpp> #include <boost/serialization/set.hpp> #include <boost/serialization/string.hpp> #include <boost/serialization/map.hpp> namespace graphmod{ class Instance : public std::map<std::string, std::vector<int> >{ public: std::vector<int> get(std::string); std::string str() const; private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version){ ar & boost::serialization::make_nvp("mapint", boost::serialization::base_object<std::map<std::string, std::vector<int> > >(*this)); } }; } #endif
C++
CL
aa03f314e01ed0250b326ce9ded2c8366f9aa641fcf01edd91aab680f561e557
//////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2011 Angelo Coppi (coppi dot angelo at virgilio dot it ) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. //////////////////////////////////////////////////////////////////////////////// // Author : Angelo Coppi (coppi dot angelo at virgilio dot it ) // History: // Created on 12 Nov 2011 //////////////////////////////////////////////////////////////////////////////// #include <stdio.h> #include <string.h> #include <string> #include <sstream> #ifdef USE_LINUX #include <termios.h> #include <fcntl.h> #include <sys/ioctl.h> #include <unistd.h> #endif #include "../inc/IPort.h" #include "../inc/CBasePort.h" #include "../inc/CPort.h" #include "../inc/ILogger.h" #include "../inc/ISoftware.h" #include "../inc/IHardware.h" #include "../inc/ICommPort.h" #include "../inc/IDevice.h" #include "../inc/CGenericDevice.h" #include "../inc/CDefaultDevice.h" #include "../inc/IBlock.h" #include "../inc/CBaseBlock.h" namespace device { void CBaseBlock::Initialize(void) { device = device::CGenericDevice::getDevice(); if (device != NULL) { software = device->GetAvaiableSoftware(); logger = device->GetAvaiableLogger(); hardware = device->GetAvaiableHardware(); } } }
C++
CL
e13ebbad0598ac62adba6e32f1b191af869b2b360205275c6bb895c5d636f2ea
#pragma once #include <algorithm> #include <execution> namespace vm { inline size_t NextID() { static size_t ID = 0; return ID++; } template<class T> inline size_t GetTypeID() { static size_t typeID = NextID(); return typeID; } template<class T, class U> constexpr void ValidateBaseClass() { static_assert(std::is_base_of<T, U>::value, "ValidateBaseClass<T, U>(): \"T is not the base class of U\" assertion"); } template<class T> void ForEachParallel(const std::vector<T>& container, void(*func)(T)) { if (container.size() > 3) { std::for_each(std::execution::par_unseq, container.begin(), container.end(), func); } else { for (auto& elem : container) func(elem); } } class BaseBehaviour { public: virtual ~BaseBehaviour() {} virtual void Init() {} virtual void Update(double delta) {} virtual void Draw() {} virtual void FixedUpdate() {} virtual void OnGUI() {} virtual void OnEnable() {} virtual void OnDisable() {} virtual void Destroy() {} }; }
C++
CL
9c7e7f06546e061143e75215f33f059c41ffa1f7fe80221198b0cf3c52b1861b
/* * AtuContract.h * * Created on: Feb 2, 2015 * Author: jasonlin */ #ifndef ATUCONTRACT_H_ #define ATUCONTRACT_H_ #include <tr1/unordered_map> #include <vector> #include <string> #include <boost/algorithm/string.hpp> using std::vector; using std::string; using std::tr1::unordered_map; namespace atu { typedef struct { string m_exchange; int m_buyOrSell; int m_ratio; string m_productCode; } AtuComboLeg; class AtuContract { public: string m_productCode; string get(string p_key); bool isCombo(); vector<AtuComboLeg> getComboLegs(); string set(string p_key, string p_value); private: unordered_map<string, string> m_keyValContractDetails; }; } #endif /* CONTRACT_H_ */
C++
CL
ca84985b32584683c152dc7f3989f8e4dcac81992f8f9cdf37692c55eaf31608
// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- #ifndef __gnu_javax_crypto_cipher_DES__ #define __gnu_javax_crypto_cipher_DES__ #pragma interface #include <gnu/javax/crypto/cipher/BaseCipher.h> #include <gcj/array.h> extern "Java" { namespace gnu { namespace javax { namespace crypto { namespace cipher { class DES; } } } } } class gnu::javax::crypto::cipher::DES : public ::gnu::javax::crypto::cipher::BaseCipher { public: DES (); static void adjustParity (jbyteArray, jint); static jboolean isParityAdjusted (jbyteArray, jint); static jboolean isWeak (jbyteArray); static jboolean isSemiWeak (jbyteArray); static jboolean isPossibleWeak (jbyteArray); private: static void desFunc (jbyteArray, jint, jbyteArray, jint, jintArray); public: virtual ::java::lang::Object *clone (); virtual ::java::util::Iterator *blockSizes (); virtual ::java::util::Iterator *keySizes (); virtual ::java::lang::Object *makeKey (jbyteArray, jint); virtual void encrypt (jbyteArray, jint, jbyteArray, jint, ::java::lang::Object *, jint); virtual void decrypt (jbyteArray, jint, jbyteArray, jint, ::java::lang::Object *, jint); static const jint BLOCK_SIZE = 8L; static const jint KEY_SIZE = 8L; private: static jintArray SP1; static jintArray SP2; static jintArray SP3; static jintArray SP4; static jintArray SP5; static jintArray SP6; static jintArray SP7; static jintArray SP8; static jbyteArray PARITY; static jbyteArray ROTARS; static jbyteArray PC1; static jbyteArray PC2; public: static JArray<jbyteArray> * WEAK_KEYS; static JArray<jbyteArray> * SEMIWEAK_KEYS; static JArray<jbyteArray> * POSSIBLE_WEAK_KEYS; friend class gnu_javax_crypto_cipher_DES$Context; static ::java::lang::Class class$; }; #endif /* __gnu_javax_crypto_cipher_DES__ */
C++
CL
382036f6ef9bd1553e34f404393ab67175c5f11c8bcc227423567af429086972
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "GameFramework/Controller.h" #include "BaseController.generated.h" /** * */ UCLASS() class BASE_MP_UE4_API ABaseController : public AController { GENERATED_BODY() };
C++
CL
f14f601ce1330d26f13dfd242e5a0bdb16c806b5ab810723fd1010ed21decc0b
// // Created by julian on 14.01.19. // #ifndef ROSBRIDGECLIENT_SERVICE_CALL_IMPL_H #define ROSBRIDGECLIENT_SERVICE_CALL_IMPL_H #include <rbc/service/service_call.h> #include <rbc/utils/deserializer.h> using namespace rbc::srv; template<typename T> ServiceCall<T>::ServiceCall(std::string name, const std::vector<T> &args) : name(name), args(args), response() {} template<typename T> ServiceCall<T>::ServiceCall(const web::json::value &response_json, std::string response_name) : name(), args(), response() { const auto &msg = response_json.at(U("values")); name = response_json.at(U("service")).as_string(); // checks if response is from service not being online try { const auto &resp_str = msg.as_string(); if (resp_str.find("does not exist") != resp_str.npos) { std::cerr << "Your service server is not online! returning\n"; return; } } catch (const std::exception &e) // just as an example: because msg.as_string() can fail when receiving a double // we now know it must be from service and the desired value { // tries to get value from service response try { response = static_cast<T>(msg.at(U(response_name)).as_double()); } catch (std::exception &e) { std::cerr << "Can't get service response: " << e.what() << "\n"; std::cerr << "Are you calling service too often? ros_bridge doesn't like that\n"; response = -1000; } } } #endif //ROSBRIDGECLIENT_SERVICE_CALL_IMPL_H
C++
CL
7b34ce964c21e57e6968b149d9713ded93f119597aea263ace319c79026f2ad6
// ============================================================== // RTL generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2017.2 // Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved. // // =========================================================== #include "sha256.h" #include "AESL_pkg.h" using namespace std; namespace ap_rtl { const sc_logic sha256::ap_const_logic_1 = sc_dt::Log_1; const sc_logic sha256::ap_const_logic_0 = sc_dt::Log_0; const sc_lv<10> sha256::ap_ST_fsm_state1 = "1"; const sc_lv<10> sha256::ap_ST_fsm_state2 = "10"; const sc_lv<10> sha256::ap_ST_fsm_state3 = "100"; const sc_lv<10> sha256::ap_ST_fsm_state4 = "1000"; const sc_lv<10> sha256::ap_ST_fsm_state5 = "10000"; const sc_lv<10> sha256::ap_ST_fsm_state6 = "100000"; const sc_lv<10> sha256::ap_ST_fsm_state7 = "1000000"; const sc_lv<10> sha256::ap_ST_fsm_state8 = "10000000"; const sc_lv<10> sha256::ap_ST_fsm_state9 = "100000000"; const sc_lv<10> sha256::ap_ST_fsm_state10 = "1000000000"; const sc_lv<32> sha256::ap_const_lv32_0 = "00000000000000000000000000000000"; const int sha256::C_S_AXI_DATA_WIDTH = "100000"; const sc_lv<32> sha256::ap_const_lv32_1 = "1"; const sc_lv<1> sha256::ap_const_lv1_1 = "1"; const sc_lv<32> sha256::ap_const_lv32_2 = "10"; const sc_lv<1> sha256::ap_const_lv1_0 = "0"; const sc_lv<32> sha256::ap_const_lv32_5 = "101"; const sc_lv<32> sha256::ap_const_lv32_8 = "1000"; const sc_lv<32> sha256::ap_const_lv32_3 = "11"; const sc_lv<7> sha256::ap_const_lv7_0 = "0000000"; const sc_lv<32> sha256::ap_const_lv32_6 = "110"; const sc_lv<6> sha256::ap_const_lv6_0 = "000000"; const sc_lv<32> sha256::ap_const_lv32_7 = "111"; const sc_lv<32> sha256::ap_const_lv32_9 = "1001"; const sc_lv<32> sha256::ap_const_lv32_4 = "100"; const sc_lv<32> sha256::ap_const_lv32_40 = "1000000"; const bool sha256::ap_const_boolean_0 = false; const sc_lv<32> sha256::ap_const_lv32_6A09E667 = "1101010000010011110011001100111"; const sc_lv<32> sha256::ap_const_lv32_BB67AE85 = "10111011011001111010111010000101"; const sc_lv<32> sha256::ap_const_lv32_3C6EF372 = "111100011011101111001101110010"; const sc_lv<32> sha256::ap_const_lv32_A54FF53A = "10100101010011111111010100111010"; const sc_lv<32> sha256::ap_const_lv32_510E527F = "1010001000011100101001001111111"; const sc_lv<32> sha256::ap_const_lv32_9B05688C = "10011011000001010110100010001100"; const sc_lv<32> sha256::ap_const_lv32_1F83D9AB = "11111100000111101100110101011"; const sc_lv<32> sha256::ap_const_lv32_5BE0CD19 = "1011011111000001100110100011001"; const sc_lv<32> sha256::ap_const_lv32_1F = "11111"; const sc_lv<26> sha256::ap_const_lv26_0 = "00000000000000000000000000"; const sc_lv<7> sha256::ap_const_lv7_40 = "1000000"; const sc_lv<7> sha256::ap_const_lv7_1 = "1"; const sc_lv<32> sha256::ap_const_lv32_FFFFFFC0 = "11111111111111111111111111000000"; const sc_lv<6> sha256::ap_const_lv6_1 = "1"; const sc_lv<6> sha256::ap_const_lv6_20 = "100000"; const bool sha256::ap_const_boolean_1 = true; sha256::sha256(sc_module_name name) : sc_module(name), mVcdFile(0) { sha256_AXILiteS_s_axi_U = new sha256_AXILiteS_s_axi<C_S_AXI_AXILITES_ADDR_WIDTH,C_S_AXI_AXILITES_DATA_WIDTH>("sha256_AXILiteS_s_axi_U"); sha256_AXILiteS_s_axi_U->AWVALID(s_axi_AXILiteS_AWVALID); sha256_AXILiteS_s_axi_U->AWREADY(s_axi_AXILiteS_AWREADY); sha256_AXILiteS_s_axi_U->AWADDR(s_axi_AXILiteS_AWADDR); sha256_AXILiteS_s_axi_U->WVALID(s_axi_AXILiteS_WVALID); sha256_AXILiteS_s_axi_U->WREADY(s_axi_AXILiteS_WREADY); sha256_AXILiteS_s_axi_U->WDATA(s_axi_AXILiteS_WDATA); sha256_AXILiteS_s_axi_U->WSTRB(s_axi_AXILiteS_WSTRB); sha256_AXILiteS_s_axi_U->ARVALID(s_axi_AXILiteS_ARVALID); sha256_AXILiteS_s_axi_U->ARREADY(s_axi_AXILiteS_ARREADY); sha256_AXILiteS_s_axi_U->ARADDR(s_axi_AXILiteS_ARADDR); sha256_AXILiteS_s_axi_U->RVALID(s_axi_AXILiteS_RVALID); sha256_AXILiteS_s_axi_U->RREADY(s_axi_AXILiteS_RREADY); sha256_AXILiteS_s_axi_U->RDATA(s_axi_AXILiteS_RDATA); sha256_AXILiteS_s_axi_U->RRESP(s_axi_AXILiteS_RRESP); sha256_AXILiteS_s_axi_U->BVALID(s_axi_AXILiteS_BVALID); sha256_AXILiteS_s_axi_U->BREADY(s_axi_AXILiteS_BREADY); sha256_AXILiteS_s_axi_U->BRESP(s_axi_AXILiteS_BRESP); sha256_AXILiteS_s_axi_U->ACLK(ap_clk); sha256_AXILiteS_s_axi_U->ARESET(ap_rst_n_inv); sha256_AXILiteS_s_axi_U->ACLK_EN(ap_var_for_const0); sha256_AXILiteS_s_axi_U->ap_start(ap_start); sha256_AXILiteS_s_axi_U->interrupt(interrupt); sha256_AXILiteS_s_axi_U->ap_ready(ap_ready); sha256_AXILiteS_s_axi_U->ap_done(ap_done); sha256_AXILiteS_s_axi_U->ap_idle(ap_idle); sha256_AXILiteS_s_axi_U->data_address0(data_address0); sha256_AXILiteS_s_axi_U->data_ce0(data_ce0); sha256_AXILiteS_s_axi_U->data_q0(data_q0); sha256_AXILiteS_s_axi_U->base_offset(base_offset); sha256_AXILiteS_s_axi_U->bytes(bytes); sha256_AXILiteS_s_axi_U->digest_address0(digest_address0); sha256_AXILiteS_s_axi_U->digest_ce0(digest_ce0); sha256_AXILiteS_s_axi_U->digest_we0(digest_we0); sha256_AXILiteS_s_axi_U->digest_d0(seg_buf_q0); seg_buf_U = new sha256_seg_buf("seg_buf_U"); seg_buf_U->clk(ap_clk); seg_buf_U->reset(ap_rst_n_inv); seg_buf_U->address0(seg_buf_address0); seg_buf_U->ce0(seg_buf_ce0); seg_buf_U->we0(seg_buf_we0); seg_buf_U->d0(seg_buf_d0); seg_buf_U->q0(seg_buf_q0); seg_buf_U->address1(grp_sha256_final_fu_268_hash_address1); seg_buf_U->ce1(seg_buf_ce1); seg_buf_U->we1(seg_buf_we1); seg_buf_U->d1(grp_sha256_final_fu_268_hash_d1); sha256ctx_data_U = new sha256_sha256ctx_bkb("sha256ctx_data_U"); sha256ctx_data_U->clk(ap_clk); sha256ctx_data_U->reset(ap_rst_n_inv); sha256ctx_data_U->address0(sha256ctx_data_address0); sha256ctx_data_U->ce0(sha256ctx_data_ce0); sha256ctx_data_U->we0(sha256ctx_data_we0); sha256ctx_data_U->d0(sha256ctx_data_d0); sha256ctx_data_U->q0(sha256ctx_data_q0); sha256ctx_data_U->address1(sha256ctx_data_address1); sha256ctx_data_U->ce1(sha256ctx_data_ce1); sha256ctx_data_U->we1(sha256ctx_data_we1); sha256ctx_data_U->d1(grp_sha256_final_fu_268_ctx_data_d1); sha256ctx_data_U->q1(sha256ctx_data_q1); grp_sha256_final_fu_268 = new sha256_final("grp_sha256_final_fu_268"); grp_sha256_final_fu_268->ap_clk(ap_clk); grp_sha256_final_fu_268->ap_rst(ap_rst_n_inv); grp_sha256_final_fu_268->ap_start(grp_sha256_final_fu_268_ap_start); grp_sha256_final_fu_268->ap_done(grp_sha256_final_fu_268_ap_done); grp_sha256_final_fu_268->ap_idle(grp_sha256_final_fu_268_ap_idle); grp_sha256_final_fu_268->ap_ready(grp_sha256_final_fu_268_ap_ready); grp_sha256_final_fu_268->ctx_data_address0(grp_sha256_final_fu_268_ctx_data_address0); grp_sha256_final_fu_268->ctx_data_ce0(grp_sha256_final_fu_268_ctx_data_ce0); grp_sha256_final_fu_268->ctx_data_we0(grp_sha256_final_fu_268_ctx_data_we0); grp_sha256_final_fu_268->ctx_data_d0(grp_sha256_final_fu_268_ctx_data_d0); grp_sha256_final_fu_268->ctx_data_q0(sha256ctx_data_q0); grp_sha256_final_fu_268->ctx_data_address1(grp_sha256_final_fu_268_ctx_data_address1); grp_sha256_final_fu_268->ctx_data_ce1(grp_sha256_final_fu_268_ctx_data_ce1); grp_sha256_final_fu_268->ctx_data_we1(grp_sha256_final_fu_268_ctx_data_we1); grp_sha256_final_fu_268->ctx_data_d1(grp_sha256_final_fu_268_ctx_data_d1); grp_sha256_final_fu_268->ctx_data_q1(sha256ctx_data_q1); grp_sha256_final_fu_268->ctx_datalen_read(reg_465); grp_sha256_final_fu_268->ctx_bitlen_0_read(reg_471); grp_sha256_final_fu_268->p_read3(reg_477); grp_sha256_final_fu_268->p_read1(reg_483); grp_sha256_final_fu_268->p_read2(reg_489); grp_sha256_final_fu_268->p_read4(reg_495); grp_sha256_final_fu_268->p_read5(reg_501); grp_sha256_final_fu_268->p_read6(reg_507); grp_sha256_final_fu_268->p_read7(reg_513); grp_sha256_final_fu_268->p_read8(reg_519); grp_sha256_final_fu_268->p_read9(reg_525); grp_sha256_final_fu_268->hash_address0(grp_sha256_final_fu_268_hash_address0); grp_sha256_final_fu_268->hash_ce0(grp_sha256_final_fu_268_hash_ce0); grp_sha256_final_fu_268->hash_we0(grp_sha256_final_fu_268_hash_we0); grp_sha256_final_fu_268->hash_d0(grp_sha256_final_fu_268_hash_d0); grp_sha256_final_fu_268->hash_address1(grp_sha256_final_fu_268_hash_address1); grp_sha256_final_fu_268->hash_ce1(grp_sha256_final_fu_268_hash_ce1); grp_sha256_final_fu_268->hash_we1(grp_sha256_final_fu_268_hash_we1); grp_sha256_final_fu_268->hash_d1(grp_sha256_final_fu_268_hash_d1); grp_sha256_update_fu_287 = new sha256_update("grp_sha256_update_fu_287"); grp_sha256_update_fu_287->ap_clk(ap_clk); grp_sha256_update_fu_287->ap_rst(ap_rst_n_inv); grp_sha256_update_fu_287->ap_start(grp_sha256_update_fu_287_ap_start); grp_sha256_update_fu_287->ap_done(grp_sha256_update_fu_287_ap_done); grp_sha256_update_fu_287->ap_idle(grp_sha256_update_fu_287_ap_idle); grp_sha256_update_fu_287->ap_ready(grp_sha256_update_fu_287_ap_ready); grp_sha256_update_fu_287->ctx_data_address0(grp_sha256_update_fu_287_ctx_data_address0); grp_sha256_update_fu_287->ctx_data_ce0(grp_sha256_update_fu_287_ctx_data_ce0); grp_sha256_update_fu_287->ctx_data_we0(grp_sha256_update_fu_287_ctx_data_we0); grp_sha256_update_fu_287->ctx_data_d0(grp_sha256_update_fu_287_ctx_data_d0); grp_sha256_update_fu_287->ctx_data_q0(sha256ctx_data_q0); grp_sha256_update_fu_287->ctx_data_address1(grp_sha256_update_fu_287_ctx_data_address1); grp_sha256_update_fu_287->ctx_data_ce1(grp_sha256_update_fu_287_ctx_data_ce1); grp_sha256_update_fu_287->ctx_data_q1(sha256ctx_data_q1); grp_sha256_update_fu_287->ctx_datalen_read(grp_sha256_update_fu_287_ctx_datalen_read); grp_sha256_update_fu_287->p_read1(grp_sha256_update_fu_287_p_read1); grp_sha256_update_fu_287->p_read2(grp_sha256_update_fu_287_p_read2); grp_sha256_update_fu_287->p_read3(grp_sha256_update_fu_287_p_read3); grp_sha256_update_fu_287->p_read4(grp_sha256_update_fu_287_p_read4); grp_sha256_update_fu_287->p_read5(grp_sha256_update_fu_287_p_read5); grp_sha256_update_fu_287->p_read6(grp_sha256_update_fu_287_p_read6); grp_sha256_update_fu_287->p_read7(grp_sha256_update_fu_287_p_read7); grp_sha256_update_fu_287->p_read8(grp_sha256_update_fu_287_p_read8); grp_sha256_update_fu_287->p_read9(grp_sha256_update_fu_287_p_read9); grp_sha256_update_fu_287->p_read10(grp_sha256_update_fu_287_p_read10); grp_sha256_update_fu_287->data_address0(grp_sha256_update_fu_287_data_address0); grp_sha256_update_fu_287->data_ce0(grp_sha256_update_fu_287_data_ce0); grp_sha256_update_fu_287->data_q0(seg_buf_q0); grp_sha256_update_fu_287->len(grp_sha256_update_fu_287_len); grp_sha256_update_fu_287->ap_return_0(grp_sha256_update_fu_287_ap_return_0); grp_sha256_update_fu_287->ap_return_1(grp_sha256_update_fu_287_ap_return_1); grp_sha256_update_fu_287->ap_return_2(grp_sha256_update_fu_287_ap_return_2); grp_sha256_update_fu_287->ap_return_3(grp_sha256_update_fu_287_ap_return_3); grp_sha256_update_fu_287->ap_return_4(grp_sha256_update_fu_287_ap_return_4); grp_sha256_update_fu_287->ap_return_5(grp_sha256_update_fu_287_ap_return_5); grp_sha256_update_fu_287->ap_return_6(grp_sha256_update_fu_287_ap_return_6); grp_sha256_update_fu_287->ap_return_7(grp_sha256_update_fu_287_ap_return_7); grp_sha256_update_fu_287->ap_return_8(grp_sha256_update_fu_287_ap_return_8); grp_sha256_update_fu_287->ap_return_9(grp_sha256_update_fu_287_ap_return_9); grp_sha256_update_fu_287->ap_return_10(grp_sha256_update_fu_287_ap_return_10); SC_METHOD(thread_ap_clk_no_reset_); dont_initialize(); sensitive << ( ap_clk.pos() ); SC_METHOD(thread_ap_CS_fsm_state1); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state10); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state2); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state3); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state4); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state5); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state6); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state7); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state8); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_CS_fsm_state9); sensitive << ( ap_CS_fsm ); SC_METHOD(thread_ap_block_state5_on_subcall_done); sensitive << ( icmp_reg_855 ); sensitive << ( grp_sha256_update_fu_287_ap_done ); SC_METHOD(thread_ap_done); sensitive << ( ap_CS_fsm_state9 ); sensitive << ( exitcond_fu_735_p2 ); SC_METHOD(thread_ap_idle); sensitive << ( ap_start ); sensitive << ( ap_CS_fsm_state1 ); SC_METHOD(thread_ap_ready); sensitive << ( ap_CS_fsm_state9 ); sensitive << ( exitcond_fu_735_p2 ); SC_METHOD(thread_ap_rst_n_inv); sensitive << ( ap_rst_n ); SC_METHOD(thread_data_address0); sensitive << ( ap_CS_fsm_state3 ); sensitive << ( ap_CS_fsm_state6 ); sensitive << ( sum_cast_fu_660_p1 ); sensitive << ( sum2_cast_fu_720_p1 ); SC_METHOD(thread_data_ce0); sensitive << ( ap_CS_fsm_state3 ); sensitive << ( ap_CS_fsm_state6 ); SC_METHOD(thread_digest_address0); sensitive << ( i_2_cast3_reg_950 ); sensitive << ( ap_CS_fsm_state10 ); SC_METHOD(thread_digest_ce0); sensitive << ( ap_CS_fsm_state10 ); SC_METHOD(thread_digest_we0); sensitive << ( ap_CS_fsm_state10 ); SC_METHOD(thread_exitcond4_fu_694_p2); sensitive << ( n_load_reg_845 ); sensitive << ( i_1_cast_fu_690_p1 ); sensitive << ( ap_CS_fsm_state6 ); SC_METHOD(thread_exitcond5_fu_633_p2); sensitive << ( ap_CS_fsm_state3 ); sensitive << ( i9_reg_235 ); SC_METHOD(thread_exitcond_fu_735_p2); sensitive << ( ap_CS_fsm_state9 ); sensitive << ( i_2_reg_257 ); SC_METHOD(thread_grp_sha256_final_fu_268_ap_start); sensitive << ( ap_reg_grp_sha256_final_fu_268_ap_start ); SC_METHOD(thread_grp_sha256_update_fu_287_ap_start); sensitive << ( ap_reg_grp_sha256_update_fu_287_ap_start ); SC_METHOD(thread_grp_sha256_update_fu_287_ctx_datalen_read); sensitive << ( reg_465 ); sensitive << ( icmp_reg_855 ); sensitive << ( sha256ctx_datalen_lo_1_reg_895 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_grp_sha256_update_fu_287_len); sensitive << ( n_load_reg_845 ); sensitive << ( icmp_reg_855 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_grp_sha256_update_fu_287_p_read1); sensitive << ( reg_471 ); sensitive << ( icmp_reg_855 ); sensitive << ( sha256ctx_bitlen_0_1_reg_900 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_grp_sha256_update_fu_287_p_read10); sensitive << ( reg_525 ); sensitive << ( icmp_reg_855 ); sensitive << ( sha256ctx_state_7_2_2_reg_945 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_grp_sha256_update_fu_287_p_read2); sensitive << ( reg_477 ); sensitive << ( icmp_reg_855 ); sensitive << ( sha256ctx_bitlen_1_1_reg_905 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_grp_sha256_update_fu_287_p_read3); sensitive << ( reg_483 ); sensitive << ( icmp_reg_855 ); sensitive << ( sha256ctx_state_0_2_2_reg_910 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_grp_sha256_update_fu_287_p_read4); sensitive << ( reg_489 ); sensitive << ( icmp_reg_855 ); sensitive << ( sha256ctx_state_1_2_2_reg_915 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_grp_sha256_update_fu_287_p_read5); sensitive << ( reg_495 ); sensitive << ( icmp_reg_855 ); sensitive << ( sha256ctx_state_2_2_2_reg_920 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_grp_sha256_update_fu_287_p_read6); sensitive << ( reg_501 ); sensitive << ( icmp_reg_855 ); sensitive << ( sha256ctx_state_3_2_2_reg_925 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_grp_sha256_update_fu_287_p_read7); sensitive << ( reg_507 ); sensitive << ( icmp_reg_855 ); sensitive << ( sha256ctx_state_4_2_2_reg_930 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_grp_sha256_update_fu_287_p_read8); sensitive << ( reg_513 ); sensitive << ( icmp_reg_855 ); sensitive << ( sha256ctx_state_5_2_2_reg_935 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_grp_sha256_update_fu_287_p_read9); sensitive << ( reg_519 ); sensitive << ( icmp_reg_855 ); sensitive << ( sha256ctx_state_6_2_2_reg_940 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_i9_cast5_fu_629_p1); sensitive << ( i9_reg_235 ); SC_METHOD(thread_i9_cast6_fu_625_p1); sensitive << ( i9_reg_235 ); SC_METHOD(thread_i_1_cast4_fu_686_p1); sensitive << ( i_1_reg_246 ); SC_METHOD(thread_i_1_cast_fu_690_p1); sensitive << ( i_1_reg_246 ); SC_METHOD(thread_i_2_cast3_fu_730_p1); sensitive << ( i_2_reg_257 ); SC_METHOD(thread_i_7_fu_639_p2); sensitive << ( i9_reg_235 ); SC_METHOD(thread_i_8_fu_699_p2); sensitive << ( i_1_reg_246 ); SC_METHOD(thread_i_fu_741_p2); sensitive << ( i_2_reg_257 ); SC_METHOD(thread_icmp_fu_619_p2); sensitive << ( ap_CS_fsm_state2 ); sensitive << ( tmp_fu_603_p2 ); sensitive << ( tmp_97_fu_609_p4 ); SC_METHOD(thread_n_1_fu_665_p2); sensitive << ( n_load_reg_845 ); SC_METHOD(thread_seg_buf_address0); sensitive << ( icmp_reg_855 ); sensitive << ( i9_cast5_reg_859 ); sensitive << ( i_1_cast_reg_877 ); sensitive << ( i_2_cast3_fu_730_p1 ); sensitive << ( ap_CS_fsm_state9 ); sensitive << ( grp_sha256_final_fu_268_hash_address0 ); sensitive << ( grp_sha256_update_fu_287_data_address0 ); sensitive << ( ap_CS_fsm_state4 ); sensitive << ( ap_CS_fsm_state7 ); sensitive << ( ap_CS_fsm_state8 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_seg_buf_ce0); sensitive << ( icmp_reg_855 ); sensitive << ( ap_CS_fsm_state9 ); sensitive << ( grp_sha256_final_fu_268_hash_ce0 ); sensitive << ( grp_sha256_update_fu_287_data_ce0 ); sensitive << ( ap_CS_fsm_state4 ); sensitive << ( ap_CS_fsm_state7 ); sensitive << ( ap_CS_fsm_state8 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_seg_buf_ce1); sensitive << ( grp_sha256_final_fu_268_hash_ce1 ); sensitive << ( ap_CS_fsm_state8 ); SC_METHOD(thread_seg_buf_d0); sensitive << ( data_q0 ); sensitive << ( grp_sha256_final_fu_268_hash_d0 ); sensitive << ( ap_CS_fsm_state4 ); sensitive << ( ap_CS_fsm_state7 ); sensitive << ( ap_CS_fsm_state8 ); SC_METHOD(thread_seg_buf_we0); sensitive << ( grp_sha256_final_fu_268_hash_we0 ); sensitive << ( ap_CS_fsm_state4 ); sensitive << ( ap_CS_fsm_state7 ); sensitive << ( ap_CS_fsm_state8 ); SC_METHOD(thread_seg_buf_we1); sensitive << ( grp_sha256_final_fu_268_hash_we1 ); sensitive << ( ap_CS_fsm_state8 ); SC_METHOD(thread_seg_offset_1_fu_675_p2); sensitive << ( seg_offset_fu_152 ); SC_METHOD(thread_sha256ctx_data_address0); sensitive << ( icmp_reg_855 ); sensitive << ( grp_sha256_final_fu_268_ctx_data_address0 ); sensitive << ( grp_sha256_update_fu_287_ctx_data_address0 ); sensitive << ( ap_CS_fsm_state8 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_sha256ctx_data_address1); sensitive << ( icmp_reg_855 ); sensitive << ( grp_sha256_final_fu_268_ctx_data_address1 ); sensitive << ( grp_sha256_update_fu_287_ctx_data_address1 ); sensitive << ( ap_CS_fsm_state8 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_sha256ctx_data_ce0); sensitive << ( icmp_reg_855 ); sensitive << ( grp_sha256_final_fu_268_ctx_data_ce0 ); sensitive << ( grp_sha256_update_fu_287_ctx_data_ce0 ); sensitive << ( ap_CS_fsm_state8 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_sha256ctx_data_ce1); sensitive << ( icmp_reg_855 ); sensitive << ( grp_sha256_final_fu_268_ctx_data_ce1 ); sensitive << ( grp_sha256_update_fu_287_ctx_data_ce1 ); sensitive << ( ap_CS_fsm_state8 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_sha256ctx_data_d0); sensitive << ( icmp_reg_855 ); sensitive << ( grp_sha256_final_fu_268_ctx_data_d0 ); sensitive << ( grp_sha256_update_fu_287_ctx_data_d0 ); sensitive << ( ap_CS_fsm_state8 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_sha256ctx_data_we0); sensitive << ( icmp_reg_855 ); sensitive << ( grp_sha256_final_fu_268_ctx_data_we0 ); sensitive << ( grp_sha256_update_fu_287_ctx_data_we0 ); sensitive << ( ap_CS_fsm_state8 ); sensitive << ( ap_CS_fsm_state5 ); SC_METHOD(thread_sha256ctx_data_we1); sensitive << ( grp_sha256_final_fu_268_ctx_data_we1 ); sensitive << ( ap_CS_fsm_state8 ); SC_METHOD(thread_sum2_cast_fu_720_p1); sensitive << ( sum2_fu_714_p2 ); SC_METHOD(thread_sum2_fu_714_p2); sensitive << ( tmp_98_fu_710_p1 ); sensitive << ( tmp2_fu_705_p2 ); SC_METHOD(thread_sum_cast_fu_660_p1); sensitive << ( sum_fu_654_p2 ); SC_METHOD(thread_sum_fu_654_p2); sensitive << ( tmp_99_fu_650_p1 ); sensitive << ( tmp1_fu_645_p2 ); SC_METHOD(thread_tmp1_fu_645_p2); sensitive << ( tmp_96_reg_839 ); sensitive << ( i9_cast6_fu_625_p1 ); SC_METHOD(thread_tmp2_fu_705_p2); sensitive << ( tmp_96_reg_839 ); sensitive << ( i_1_cast4_fu_686_p1 ); SC_METHOD(thread_tmp_96_fu_531_p1); sensitive << ( base_offset ); SC_METHOD(thread_tmp_97_fu_609_p4); sensitive << ( n_fu_104 ); SC_METHOD(thread_tmp_98_fu_710_p1); sensitive << ( seg_offset_fu_152 ); SC_METHOD(thread_tmp_99_fu_650_p1); sensitive << ( seg_offset_fu_152 ); SC_METHOD(thread_tmp_fu_603_p2); sensitive << ( ap_CS_fsm_state2 ); sensitive << ( n_fu_104 ); SC_METHOD(thread_ap_NS_fsm); sensitive << ( ap_start ); sensitive << ( ap_CS_fsm ); sensitive << ( ap_CS_fsm_state1 ); sensitive << ( ap_CS_fsm_state2 ); sensitive << ( tmp_fu_603_p2 ); sensitive << ( ap_CS_fsm_state3 ); sensitive << ( exitcond5_fu_633_p2 ); sensitive << ( icmp_fu_619_p2 ); sensitive << ( ap_CS_fsm_state6 ); sensitive << ( exitcond4_fu_694_p2 ); sensitive << ( ap_CS_fsm_state9 ); sensitive << ( exitcond_fu_735_p2 ); sensitive << ( grp_sha256_final_fu_268_ap_done ); sensitive << ( ap_CS_fsm_state8 ); sensitive << ( ap_CS_fsm_state5 ); sensitive << ( ap_block_state5_on_subcall_done ); SC_THREAD(thread_hdltv_gen); sensitive << ( ap_clk.pos() ); SC_THREAD(thread_ap_var_for_const0); ap_CS_fsm = "0000000001"; ap_reg_grp_sha256_final_fu_268_ap_start = SC_LOGIC_0; ap_reg_grp_sha256_update_fu_287_ap_start = SC_LOGIC_0; static int apTFileNum = 0; stringstream apTFilenSS; apTFilenSS << "sha256_sc_trace_" << apTFileNum ++; string apTFn = apTFilenSS.str(); mVcdFile = sc_create_vcd_trace_file(apTFn.c_str()); mVcdFile->set_time_unit(1, SC_PS); if (1) { #ifdef __HLS_TRACE_LEVEL_PORT__ sc_trace(mVcdFile, ap_clk, "(port)ap_clk"); sc_trace(mVcdFile, ap_rst_n, "(port)ap_rst_n"); sc_trace(mVcdFile, s_axi_AXILiteS_AWVALID, "(port)s_axi_AXILiteS_AWVALID"); sc_trace(mVcdFile, s_axi_AXILiteS_AWREADY, "(port)s_axi_AXILiteS_AWREADY"); sc_trace(mVcdFile, s_axi_AXILiteS_AWADDR, "(port)s_axi_AXILiteS_AWADDR"); sc_trace(mVcdFile, s_axi_AXILiteS_WVALID, "(port)s_axi_AXILiteS_WVALID"); sc_trace(mVcdFile, s_axi_AXILiteS_WREADY, "(port)s_axi_AXILiteS_WREADY"); sc_trace(mVcdFile, s_axi_AXILiteS_WDATA, "(port)s_axi_AXILiteS_WDATA"); sc_trace(mVcdFile, s_axi_AXILiteS_WSTRB, "(port)s_axi_AXILiteS_WSTRB"); sc_trace(mVcdFile, s_axi_AXILiteS_ARVALID, "(port)s_axi_AXILiteS_ARVALID"); sc_trace(mVcdFile, s_axi_AXILiteS_ARREADY, "(port)s_axi_AXILiteS_ARREADY"); sc_trace(mVcdFile, s_axi_AXILiteS_ARADDR, "(port)s_axi_AXILiteS_ARADDR"); sc_trace(mVcdFile, s_axi_AXILiteS_RVALID, "(port)s_axi_AXILiteS_RVALID"); sc_trace(mVcdFile, s_axi_AXILiteS_RREADY, "(port)s_axi_AXILiteS_RREADY"); sc_trace(mVcdFile, s_axi_AXILiteS_RDATA, "(port)s_axi_AXILiteS_RDATA"); sc_trace(mVcdFile, s_axi_AXILiteS_RRESP, "(port)s_axi_AXILiteS_RRESP"); sc_trace(mVcdFile, s_axi_AXILiteS_BVALID, "(port)s_axi_AXILiteS_BVALID"); sc_trace(mVcdFile, s_axi_AXILiteS_BREADY, "(port)s_axi_AXILiteS_BREADY"); sc_trace(mVcdFile, s_axi_AXILiteS_BRESP, "(port)s_axi_AXILiteS_BRESP"); sc_trace(mVcdFile, interrupt, "(port)interrupt"); #endif #ifdef __HLS_TRACE_LEVEL_INT__ sc_trace(mVcdFile, ap_rst_n_inv, "ap_rst_n_inv"); sc_trace(mVcdFile, ap_start, "ap_start"); sc_trace(mVcdFile, ap_done, "ap_done"); sc_trace(mVcdFile, ap_idle, "ap_idle"); sc_trace(mVcdFile, ap_CS_fsm, "ap_CS_fsm"); sc_trace(mVcdFile, ap_CS_fsm_state1, "ap_CS_fsm_state1"); sc_trace(mVcdFile, ap_ready, "ap_ready"); sc_trace(mVcdFile, data_address0, "data_address0"); sc_trace(mVcdFile, data_ce0, "data_ce0"); sc_trace(mVcdFile, data_q0, "data_q0"); sc_trace(mVcdFile, base_offset, "base_offset"); sc_trace(mVcdFile, bytes, "bytes"); sc_trace(mVcdFile, digest_address0, "digest_address0"); sc_trace(mVcdFile, digest_ce0, "digest_ce0"); sc_trace(mVcdFile, digest_we0, "digest_we0"); sc_trace(mVcdFile, reg_465, "reg_465"); sc_trace(mVcdFile, ap_CS_fsm_state2, "ap_CS_fsm_state2"); sc_trace(mVcdFile, tmp_fu_603_p2, "tmp_fu_603_p2"); sc_trace(mVcdFile, ap_CS_fsm_state3, "ap_CS_fsm_state3"); sc_trace(mVcdFile, exitcond5_fu_633_p2, "exitcond5_fu_633_p2"); sc_trace(mVcdFile, reg_471, "reg_471"); sc_trace(mVcdFile, reg_477, "reg_477"); sc_trace(mVcdFile, reg_483, "reg_483"); sc_trace(mVcdFile, reg_489, "reg_489"); sc_trace(mVcdFile, reg_495, "reg_495"); sc_trace(mVcdFile, reg_501, "reg_501"); sc_trace(mVcdFile, reg_507, "reg_507"); sc_trace(mVcdFile, reg_513, "reg_513"); sc_trace(mVcdFile, reg_519, "reg_519"); sc_trace(mVcdFile, reg_525, "reg_525"); sc_trace(mVcdFile, tmp_96_fu_531_p1, "tmp_96_fu_531_p1"); sc_trace(mVcdFile, tmp_96_reg_839, "tmp_96_reg_839"); sc_trace(mVcdFile, n_load_reg_845, "n_load_reg_845"); sc_trace(mVcdFile, icmp_fu_619_p2, "icmp_fu_619_p2"); sc_trace(mVcdFile, icmp_reg_855, "icmp_reg_855"); sc_trace(mVcdFile, i9_cast5_fu_629_p1, "i9_cast5_fu_629_p1"); sc_trace(mVcdFile, i9_cast5_reg_859, "i9_cast5_reg_859"); sc_trace(mVcdFile, i_7_fu_639_p2, "i_7_fu_639_p2"); sc_trace(mVcdFile, i_7_reg_867, "i_7_reg_867"); sc_trace(mVcdFile, i_1_cast_fu_690_p1, "i_1_cast_fu_690_p1"); sc_trace(mVcdFile, i_1_cast_reg_877, "i_1_cast_reg_877"); sc_trace(mVcdFile, ap_CS_fsm_state6, "ap_CS_fsm_state6"); sc_trace(mVcdFile, i_8_fu_699_p2, "i_8_fu_699_p2"); sc_trace(mVcdFile, i_8_reg_885, "i_8_reg_885"); sc_trace(mVcdFile, exitcond4_fu_694_p2, "exitcond4_fu_694_p2"); sc_trace(mVcdFile, sha256ctx_datalen_lo_1_reg_895, "sha256ctx_datalen_lo_1_reg_895"); sc_trace(mVcdFile, sha256ctx_bitlen_0_1_reg_900, "sha256ctx_bitlen_0_1_reg_900"); sc_trace(mVcdFile, sha256ctx_bitlen_1_1_reg_905, "sha256ctx_bitlen_1_1_reg_905"); sc_trace(mVcdFile, sha256ctx_state_0_2_2_reg_910, "sha256ctx_state_0_2_2_reg_910"); sc_trace(mVcdFile, sha256ctx_state_1_2_2_reg_915, "sha256ctx_state_1_2_2_reg_915"); sc_trace(mVcdFile, sha256ctx_state_2_2_2_reg_920, "sha256ctx_state_2_2_2_reg_920"); sc_trace(mVcdFile, sha256ctx_state_3_2_2_reg_925, "sha256ctx_state_3_2_2_reg_925"); sc_trace(mVcdFile, sha256ctx_state_4_2_2_reg_930, "sha256ctx_state_4_2_2_reg_930"); sc_trace(mVcdFile, sha256ctx_state_5_2_2_reg_935, "sha256ctx_state_5_2_2_reg_935"); sc_trace(mVcdFile, sha256ctx_state_6_2_2_reg_940, "sha256ctx_state_6_2_2_reg_940"); sc_trace(mVcdFile, sha256ctx_state_7_2_2_reg_945, "sha256ctx_state_7_2_2_reg_945"); sc_trace(mVcdFile, i_2_cast3_fu_730_p1, "i_2_cast3_fu_730_p1"); sc_trace(mVcdFile, i_2_cast3_reg_950, "i_2_cast3_reg_950"); sc_trace(mVcdFile, ap_CS_fsm_state9, "ap_CS_fsm_state9"); sc_trace(mVcdFile, i_fu_741_p2, "i_fu_741_p2"); sc_trace(mVcdFile, i_reg_958, "i_reg_958"); sc_trace(mVcdFile, exitcond_fu_735_p2, "exitcond_fu_735_p2"); sc_trace(mVcdFile, seg_buf_address0, "seg_buf_address0"); sc_trace(mVcdFile, seg_buf_ce0, "seg_buf_ce0"); sc_trace(mVcdFile, seg_buf_we0, "seg_buf_we0"); sc_trace(mVcdFile, seg_buf_d0, "seg_buf_d0"); sc_trace(mVcdFile, seg_buf_q0, "seg_buf_q0"); sc_trace(mVcdFile, seg_buf_ce1, "seg_buf_ce1"); sc_trace(mVcdFile, seg_buf_we1, "seg_buf_we1"); sc_trace(mVcdFile, sha256ctx_data_address0, "sha256ctx_data_address0"); sc_trace(mVcdFile, sha256ctx_data_ce0, "sha256ctx_data_ce0"); sc_trace(mVcdFile, sha256ctx_data_we0, "sha256ctx_data_we0"); sc_trace(mVcdFile, sha256ctx_data_d0, "sha256ctx_data_d0"); sc_trace(mVcdFile, sha256ctx_data_q0, "sha256ctx_data_q0"); sc_trace(mVcdFile, sha256ctx_data_address1, "sha256ctx_data_address1"); sc_trace(mVcdFile, sha256ctx_data_ce1, "sha256ctx_data_ce1"); sc_trace(mVcdFile, sha256ctx_data_we1, "sha256ctx_data_we1"); sc_trace(mVcdFile, sha256ctx_data_q1, "sha256ctx_data_q1"); sc_trace(mVcdFile, grp_sha256_final_fu_268_ap_start, "grp_sha256_final_fu_268_ap_start"); sc_trace(mVcdFile, grp_sha256_final_fu_268_ap_done, "grp_sha256_final_fu_268_ap_done"); sc_trace(mVcdFile, grp_sha256_final_fu_268_ap_idle, "grp_sha256_final_fu_268_ap_idle"); sc_trace(mVcdFile, grp_sha256_final_fu_268_ap_ready, "grp_sha256_final_fu_268_ap_ready"); sc_trace(mVcdFile, grp_sha256_final_fu_268_ctx_data_address0, "grp_sha256_final_fu_268_ctx_data_address0"); sc_trace(mVcdFile, grp_sha256_final_fu_268_ctx_data_ce0, "grp_sha256_final_fu_268_ctx_data_ce0"); sc_trace(mVcdFile, grp_sha256_final_fu_268_ctx_data_we0, "grp_sha256_final_fu_268_ctx_data_we0"); sc_trace(mVcdFile, grp_sha256_final_fu_268_ctx_data_d0, "grp_sha256_final_fu_268_ctx_data_d0"); sc_trace(mVcdFile, grp_sha256_final_fu_268_ctx_data_address1, "grp_sha256_final_fu_268_ctx_data_address1"); sc_trace(mVcdFile, grp_sha256_final_fu_268_ctx_data_ce1, "grp_sha256_final_fu_268_ctx_data_ce1"); sc_trace(mVcdFile, grp_sha256_final_fu_268_ctx_data_we1, "grp_sha256_final_fu_268_ctx_data_we1"); sc_trace(mVcdFile, grp_sha256_final_fu_268_ctx_data_d1, "grp_sha256_final_fu_268_ctx_data_d1"); sc_trace(mVcdFile, grp_sha256_final_fu_268_hash_address0, "grp_sha256_final_fu_268_hash_address0"); sc_trace(mVcdFile, grp_sha256_final_fu_268_hash_ce0, "grp_sha256_final_fu_268_hash_ce0"); sc_trace(mVcdFile, grp_sha256_final_fu_268_hash_we0, "grp_sha256_final_fu_268_hash_we0"); sc_trace(mVcdFile, grp_sha256_final_fu_268_hash_d0, "grp_sha256_final_fu_268_hash_d0"); sc_trace(mVcdFile, grp_sha256_final_fu_268_hash_address1, "grp_sha256_final_fu_268_hash_address1"); sc_trace(mVcdFile, grp_sha256_final_fu_268_hash_ce1, "grp_sha256_final_fu_268_hash_ce1"); sc_trace(mVcdFile, grp_sha256_final_fu_268_hash_we1, "grp_sha256_final_fu_268_hash_we1"); sc_trace(mVcdFile, grp_sha256_final_fu_268_hash_d1, "grp_sha256_final_fu_268_hash_d1"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ap_start, "grp_sha256_update_fu_287_ap_start"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ap_done, "grp_sha256_update_fu_287_ap_done"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ap_idle, "grp_sha256_update_fu_287_ap_idle"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ap_ready, "grp_sha256_update_fu_287_ap_ready"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ctx_data_address0, "grp_sha256_update_fu_287_ctx_data_address0"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ctx_data_ce0, "grp_sha256_update_fu_287_ctx_data_ce0"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ctx_data_we0, "grp_sha256_update_fu_287_ctx_data_we0"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ctx_data_d0, "grp_sha256_update_fu_287_ctx_data_d0"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ctx_data_address1, "grp_sha256_update_fu_287_ctx_data_address1"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ctx_data_ce1, "grp_sha256_update_fu_287_ctx_data_ce1"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ctx_datalen_read, "grp_sha256_update_fu_287_ctx_datalen_read"); sc_trace(mVcdFile, grp_sha256_update_fu_287_p_read1, "grp_sha256_update_fu_287_p_read1"); sc_trace(mVcdFile, grp_sha256_update_fu_287_p_read2, "grp_sha256_update_fu_287_p_read2"); sc_trace(mVcdFile, grp_sha256_update_fu_287_p_read3, "grp_sha256_update_fu_287_p_read3"); sc_trace(mVcdFile, grp_sha256_update_fu_287_p_read4, "grp_sha256_update_fu_287_p_read4"); sc_trace(mVcdFile, grp_sha256_update_fu_287_p_read5, "grp_sha256_update_fu_287_p_read5"); sc_trace(mVcdFile, grp_sha256_update_fu_287_p_read6, "grp_sha256_update_fu_287_p_read6"); sc_trace(mVcdFile, grp_sha256_update_fu_287_p_read7, "grp_sha256_update_fu_287_p_read7"); sc_trace(mVcdFile, grp_sha256_update_fu_287_p_read8, "grp_sha256_update_fu_287_p_read8"); sc_trace(mVcdFile, grp_sha256_update_fu_287_p_read9, "grp_sha256_update_fu_287_p_read9"); sc_trace(mVcdFile, grp_sha256_update_fu_287_p_read10, "grp_sha256_update_fu_287_p_read10"); sc_trace(mVcdFile, grp_sha256_update_fu_287_data_address0, "grp_sha256_update_fu_287_data_address0"); sc_trace(mVcdFile, grp_sha256_update_fu_287_data_ce0, "grp_sha256_update_fu_287_data_ce0"); sc_trace(mVcdFile, grp_sha256_update_fu_287_len, "grp_sha256_update_fu_287_len"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ap_return_0, "grp_sha256_update_fu_287_ap_return_0"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ap_return_1, "grp_sha256_update_fu_287_ap_return_1"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ap_return_2, "grp_sha256_update_fu_287_ap_return_2"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ap_return_3, "grp_sha256_update_fu_287_ap_return_3"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ap_return_4, "grp_sha256_update_fu_287_ap_return_4"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ap_return_5, "grp_sha256_update_fu_287_ap_return_5"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ap_return_6, "grp_sha256_update_fu_287_ap_return_6"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ap_return_7, "grp_sha256_update_fu_287_ap_return_7"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ap_return_8, "grp_sha256_update_fu_287_ap_return_8"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ap_return_9, "grp_sha256_update_fu_287_ap_return_9"); sc_trace(mVcdFile, grp_sha256_update_fu_287_ap_return_10, "grp_sha256_update_fu_287_ap_return_10"); sc_trace(mVcdFile, i9_reg_235, "i9_reg_235"); sc_trace(mVcdFile, ap_CS_fsm_state4, "ap_CS_fsm_state4"); sc_trace(mVcdFile, i_1_reg_246, "i_1_reg_246"); sc_trace(mVcdFile, ap_CS_fsm_state7, "ap_CS_fsm_state7"); sc_trace(mVcdFile, i_2_reg_257, "i_2_reg_257"); sc_trace(mVcdFile, ap_CS_fsm_state8, "ap_CS_fsm_state8"); sc_trace(mVcdFile, ap_CS_fsm_state10, "ap_CS_fsm_state10"); sc_trace(mVcdFile, ap_reg_grp_sha256_final_fu_268_ap_start, "ap_reg_grp_sha256_final_fu_268_ap_start"); sc_trace(mVcdFile, ap_reg_grp_sha256_update_fu_287_ap_start, "ap_reg_grp_sha256_update_fu_287_ap_start"); sc_trace(mVcdFile, ap_CS_fsm_state5, "ap_CS_fsm_state5"); sc_trace(mVcdFile, sum_cast_fu_660_p1, "sum_cast_fu_660_p1"); sc_trace(mVcdFile, sum2_cast_fu_720_p1, "sum2_cast_fu_720_p1"); sc_trace(mVcdFile, n_fu_104, "n_fu_104"); sc_trace(mVcdFile, n_1_fu_665_p2, "n_1_fu_665_p2"); sc_trace(mVcdFile, sha256ctx_datalen_fu_108, "sha256ctx_datalen_fu_108"); sc_trace(mVcdFile, ap_block_state5_on_subcall_done, "ap_block_state5_on_subcall_done"); sc_trace(mVcdFile, sha256ctx_bitlen_0_2_fu_112, "sha256ctx_bitlen_0_2_fu_112"); sc_trace(mVcdFile, sha256ctx_bitlen_1_2_fu_116, "sha256ctx_bitlen_1_2_fu_116"); sc_trace(mVcdFile, sha256ctx_state_0_2_fu_120, "sha256ctx_state_0_2_fu_120"); sc_trace(mVcdFile, sha256ctx_state_1_2_fu_124, "sha256ctx_state_1_2_fu_124"); sc_trace(mVcdFile, sha256ctx_state_2_2_fu_128, "sha256ctx_state_2_2_fu_128"); sc_trace(mVcdFile, sha256ctx_state_3_2_fu_132, "sha256ctx_state_3_2_fu_132"); sc_trace(mVcdFile, sha256ctx_state_4_2_fu_136, "sha256ctx_state_4_2_fu_136"); sc_trace(mVcdFile, sha256ctx_state_5_2_fu_140, "sha256ctx_state_5_2_fu_140"); sc_trace(mVcdFile, sha256ctx_state_6_2_fu_144, "sha256ctx_state_6_2_fu_144"); sc_trace(mVcdFile, sha256ctx_state_7_2_fu_148, "sha256ctx_state_7_2_fu_148"); sc_trace(mVcdFile, seg_offset_fu_152, "seg_offset_fu_152"); sc_trace(mVcdFile, seg_offset_1_fu_675_p2, "seg_offset_1_fu_675_p2"); sc_trace(mVcdFile, tmp_97_fu_609_p4, "tmp_97_fu_609_p4"); sc_trace(mVcdFile, i9_cast6_fu_625_p1, "i9_cast6_fu_625_p1"); sc_trace(mVcdFile, tmp_99_fu_650_p1, "tmp_99_fu_650_p1"); sc_trace(mVcdFile, tmp1_fu_645_p2, "tmp1_fu_645_p2"); sc_trace(mVcdFile, sum_fu_654_p2, "sum_fu_654_p2"); sc_trace(mVcdFile, i_1_cast4_fu_686_p1, "i_1_cast4_fu_686_p1"); sc_trace(mVcdFile, tmp_98_fu_710_p1, "tmp_98_fu_710_p1"); sc_trace(mVcdFile, tmp2_fu_705_p2, "tmp2_fu_705_p2"); sc_trace(mVcdFile, sum2_fu_714_p2, "sum2_fu_714_p2"); sc_trace(mVcdFile, ap_NS_fsm, "ap_NS_fsm"); #endif } mHdltvinHandle.open("sha256.hdltvin.dat"); mHdltvoutHandle.open("sha256.hdltvout.dat"); } sha256::~sha256() { if (mVcdFile) sc_close_vcd_trace_file(mVcdFile); mHdltvinHandle << "] " << endl; mHdltvoutHandle << "] " << endl; mHdltvinHandle.close(); mHdltvoutHandle.close(); delete sha256_AXILiteS_s_axi_U; delete seg_buf_U; delete sha256ctx_data_U; delete grp_sha256_final_fu_268; delete grp_sha256_update_fu_287; } void sha256::thread_ap_var_for_const0() { ap_var_for_const0 = ap_const_logic_1; } void sha256::thread_ap_clk_no_reset_() { if ( ap_rst_n_inv.read() == ap_const_logic_1) { ap_CS_fsm = ap_ST_fsm_state1; } else { ap_CS_fsm = ap_NS_fsm.read(); } if ( ap_rst_n_inv.read() == ap_const_logic_1) { ap_reg_grp_sha256_final_fu_268_ap_start = ap_const_logic_0; } else { if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state2.read()) && esl_seteq<1,1,1>(tmp_fu_603_p2.read(), ap_const_lv1_1))) { ap_reg_grp_sha256_final_fu_268_ap_start = ap_const_logic_1; } else if (esl_seteq<1,1,1>(ap_const_logic_1, grp_sha256_final_fu_268_ap_ready.read())) { ap_reg_grp_sha256_final_fu_268_ap_start = ap_const_logic_0; } } if ( ap_rst_n_inv.read() == ap_const_logic_1) { ap_reg_grp_sha256_update_fu_287_ap_start = ap_const_logic_0; } else { if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, exitcond5_fu_633_p2.read())) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state6.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, exitcond4_fu_694_p2.read())))) { ap_reg_grp_sha256_update_fu_287_ap_start = ap_const_logic_1; } else if (esl_seteq<1,1,1>(ap_const_logic_1, grp_sha256_update_fu_287_ap_ready.read())) { ap_reg_grp_sha256_update_fu_287_ap_start = ap_const_logic_0; } } if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state2.read()) && esl_seteq<1,1,1>(tmp_fu_603_p2.read(), ap_const_lv1_0) && esl_seteq<1,1,1>(icmp_fu_619_p2.read(), ap_const_lv1_0))) { i9_reg_235 = ap_const_lv7_0; } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state4.read())) { i9_reg_235 = i_7_reg_867.read(); } if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state2.read()) && esl_seteq<1,1,1>(tmp_fu_603_p2.read(), ap_const_lv1_0) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_fu_619_p2.read()))) { i_1_reg_246 = ap_const_lv6_0; } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state7.read())) { i_1_reg_246 = i_8_reg_885.read(); } if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state10.read())) { i_2_reg_257 = i_reg_958.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state8.read()) && esl_seteq<1,1,1>(grp_sha256_final_fu_268_ap_done.read(), ap_const_logic_1))) { i_2_reg_257 = ap_const_lv6_0; } if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state6.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, exitcond4_fu_694_p2.read()))) { n_fu_104 = ap_const_lv32_0; } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, exitcond5_fu_633_p2.read()))) { n_fu_104 = n_1_fu_665_p2.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1))) { n_fu_104 = bytes.read(); } if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0))) { seg_offset_fu_152 = seg_offset_1_fu_675_p2.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1))) { seg_offset_fu_152 = ap_const_lv32_0; } if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read()) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)))) { sha256ctx_bitlen_0_2_fu_112 = grp_sha256_update_fu_287_ap_return_1.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1))) { sha256ctx_bitlen_0_2_fu_112 = ap_const_lv32_0; } if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read()) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)))) { sha256ctx_bitlen_1_2_fu_116 = grp_sha256_update_fu_287_ap_return_2.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1))) { sha256ctx_bitlen_1_2_fu_116 = ap_const_lv32_0; } if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read()) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)))) { sha256ctx_datalen_fu_108 = grp_sha256_update_fu_287_ap_return_0.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1))) { sha256ctx_datalen_fu_108 = ap_const_lv32_0; } if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read()) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)))) { sha256ctx_state_0_2_fu_120 = grp_sha256_update_fu_287_ap_return_3.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1))) { sha256ctx_state_0_2_fu_120 = ap_const_lv32_6A09E667; } if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read()) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)))) { sha256ctx_state_1_2_fu_124 = grp_sha256_update_fu_287_ap_return_4.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1))) { sha256ctx_state_1_2_fu_124 = ap_const_lv32_BB67AE85; } if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read()) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)))) { sha256ctx_state_2_2_fu_128 = grp_sha256_update_fu_287_ap_return_5.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1))) { sha256ctx_state_2_2_fu_128 = ap_const_lv32_3C6EF372; } if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read()) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)))) { sha256ctx_state_3_2_fu_132 = grp_sha256_update_fu_287_ap_return_6.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1))) { sha256ctx_state_3_2_fu_132 = ap_const_lv32_A54FF53A; } if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read()) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)))) { sha256ctx_state_4_2_fu_136 = grp_sha256_update_fu_287_ap_return_7.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1))) { sha256ctx_state_4_2_fu_136 = ap_const_lv32_510E527F; } if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read()) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)))) { sha256ctx_state_5_2_fu_140 = grp_sha256_update_fu_287_ap_return_8.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1))) { sha256ctx_state_5_2_fu_140 = ap_const_lv32_9B05688C; } if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read()) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)))) { sha256ctx_state_6_2_fu_144 = grp_sha256_update_fu_287_ap_return_9.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1))) { sha256ctx_state_6_2_fu_144 = ap_const_lv32_1F83D9AB; } if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read()) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0)))) { sha256ctx_state_7_2_fu_148 = grp_sha256_update_fu_287_ap_return_10.read(); } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1))) { sha256ctx_state_7_2_fu_148 = ap_const_lv32_5BE0CD19; } if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { i9_cast5_reg_859 = i9_cast5_fu_629_p1.read(); i_7_reg_867 = i_7_fu_639_p2.read(); } if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state6.read())) { i_1_cast_reg_877 = i_1_cast_fu_690_p1.read(); i_8_reg_885 = i_8_fu_699_p2.read(); } if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state9.read())) { i_2_cast3_reg_950 = i_2_cast3_fu_730_p1.read(); i_reg_958 = i_fu_741_p2.read(); } if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state2.read()) && esl_seteq<1,1,1>(tmp_fu_603_p2.read(), ap_const_lv1_0))) { icmp_reg_855 = icmp_fu_619_p2.read(); } if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state2.read())) { n_load_reg_845 = n_fu_104.read(); } if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state2.read()) && esl_seteq<1,1,1>(tmp_fu_603_p2.read(), ap_const_lv1_1)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, exitcond5_fu_633_p2.read())))) { reg_465 = sha256ctx_datalen_fu_108.read(); reg_471 = sha256ctx_bitlen_0_2_fu_112.read(); reg_477 = sha256ctx_bitlen_1_2_fu_116.read(); reg_483 = sha256ctx_state_0_2_fu_120.read(); reg_489 = sha256ctx_state_1_2_fu_124.read(); reg_495 = sha256ctx_state_2_2_fu_128.read(); reg_501 = sha256ctx_state_3_2_fu_132.read(); reg_507 = sha256ctx_state_4_2_fu_136.read(); reg_513 = sha256ctx_state_5_2_fu_140.read(); reg_519 = sha256ctx_state_6_2_fu_144.read(); reg_525 = sha256ctx_state_7_2_fu_148.read(); } if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state6.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, exitcond4_fu_694_p2.read()))) { sha256ctx_bitlen_0_1_reg_900 = sha256ctx_bitlen_0_2_fu_112.read(); sha256ctx_bitlen_1_1_reg_905 = sha256ctx_bitlen_1_2_fu_116.read(); sha256ctx_datalen_lo_1_reg_895 = sha256ctx_datalen_fu_108.read(); sha256ctx_state_0_2_2_reg_910 = sha256ctx_state_0_2_fu_120.read(); sha256ctx_state_1_2_2_reg_915 = sha256ctx_state_1_2_fu_124.read(); sha256ctx_state_2_2_2_reg_920 = sha256ctx_state_2_2_fu_128.read(); sha256ctx_state_3_2_2_reg_925 = sha256ctx_state_3_2_fu_132.read(); sha256ctx_state_4_2_2_reg_930 = sha256ctx_state_4_2_fu_136.read(); sha256ctx_state_5_2_2_reg_935 = sha256ctx_state_5_2_fu_140.read(); sha256ctx_state_6_2_2_reg_940 = sha256ctx_state_6_2_fu_144.read(); sha256ctx_state_7_2_2_reg_945 = sha256ctx_state_7_2_fu_148.read(); } if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1))) { tmp_96_reg_839 = tmp_96_fu_531_p1.read(); } } void sha256::thread_ap_CS_fsm_state1() { ap_CS_fsm_state1 = ap_CS_fsm.read()[0]; } void sha256::thread_ap_CS_fsm_state10() { ap_CS_fsm_state10 = ap_CS_fsm.read()[9]; } void sha256::thread_ap_CS_fsm_state2() { ap_CS_fsm_state2 = ap_CS_fsm.read()[1]; } void sha256::thread_ap_CS_fsm_state3() { ap_CS_fsm_state3 = ap_CS_fsm.read()[2]; } void sha256::thread_ap_CS_fsm_state4() { ap_CS_fsm_state4 = ap_CS_fsm.read()[3]; } void sha256::thread_ap_CS_fsm_state5() { ap_CS_fsm_state5 = ap_CS_fsm.read()[4]; } void sha256::thread_ap_CS_fsm_state6() { ap_CS_fsm_state6 = ap_CS_fsm.read()[5]; } void sha256::thread_ap_CS_fsm_state7() { ap_CS_fsm_state7 = ap_CS_fsm.read()[6]; } void sha256::thread_ap_CS_fsm_state8() { ap_CS_fsm_state8 = ap_CS_fsm.read()[7]; } void sha256::thread_ap_CS_fsm_state9() { ap_CS_fsm_state9 = ap_CS_fsm.read()[8]; } void sha256::thread_ap_block_state5_on_subcall_done() { ap_block_state5_on_subcall_done = ((esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0) && esl_seteq<1,1,1>(ap_const_logic_0, grp_sha256_update_fu_287_ap_done.read())) || (esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read()) && esl_seteq<1,1,1>(ap_const_logic_0, grp_sha256_update_fu_287_ap_done.read()))); } void sha256::thread_ap_done() { if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state9.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, exitcond_fu_735_p2.read()))) { ap_done = ap_const_logic_1; } else { ap_done = ap_const_logic_0; } } void sha256::thread_ap_idle() { if ((esl_seteq<1,1,1>(ap_const_logic_0, ap_start.read()) && esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()))) { ap_idle = ap_const_logic_1; } else { ap_idle = ap_const_logic_0; } } void sha256::thread_ap_ready() { if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state9.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, exitcond_fu_735_p2.read()))) { ap_ready = ap_const_logic_1; } else { ap_ready = ap_const_logic_0; } } void sha256::thread_ap_rst_n_inv() { ap_rst_n_inv = (sc_logic) (~ap_rst_n.read()); } void sha256::thread_data_address0() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state6.read())) { data_address0 = (sc_lv<8>) (sum2_cast_fu_720_p1.read()); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read())) { data_address0 = (sc_lv<8>) (sum_cast_fu_660_p1.read()); } else { data_address0 = "XXXXXXXX"; } } void sha256::thread_data_ce0() { if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state6.read()))) { data_ce0 = ap_const_logic_1; } else { data_ce0 = ap_const_logic_0; } } void sha256::thread_digest_address0() { digest_address0 = (sc_lv<5>) (i_2_cast3_reg_950.read()); } void sha256::thread_digest_ce0() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state10.read())) { digest_ce0 = ap_const_logic_1; } else { digest_ce0 = ap_const_logic_0; } } void sha256::thread_digest_we0() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state10.read())) { digest_we0 = ap_const_logic_1; } else { digest_we0 = ap_const_logic_0; } } void sha256::thread_exitcond4_fu_694_p2() { exitcond4_fu_694_p2 = (!i_1_cast_fu_690_p1.read().is_01() || !n_load_reg_845.read().is_01())? sc_lv<1>(): sc_lv<1>(i_1_cast_fu_690_p1.read() == n_load_reg_845.read()); } void sha256::thread_exitcond5_fu_633_p2() { exitcond5_fu_633_p2 = (!i9_reg_235.read().is_01() || !ap_const_lv7_40.is_01())? sc_lv<1>(): sc_lv<1>(i9_reg_235.read() == ap_const_lv7_40); } void sha256::thread_exitcond_fu_735_p2() { exitcond_fu_735_p2 = (!i_2_reg_257.read().is_01() || !ap_const_lv6_20.is_01())? sc_lv<1>(): sc_lv<1>(i_2_reg_257.read() == ap_const_lv6_20); } void sha256::thread_grp_sha256_final_fu_268_ap_start() { grp_sha256_final_fu_268_ap_start = ap_reg_grp_sha256_final_fu_268_ap_start.read(); } void sha256::thread_grp_sha256_update_fu_287_ap_start() { grp_sha256_update_fu_287_ap_start = ap_reg_grp_sha256_update_fu_287_ap_start.read(); } void sha256::thread_grp_sha256_update_fu_287_ctx_datalen_read() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read())) { if (esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())) { grp_sha256_update_fu_287_ctx_datalen_read = sha256ctx_datalen_lo_1_reg_895.read(); } else if (esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) { grp_sha256_update_fu_287_ctx_datalen_read = reg_465.read(); } else { grp_sha256_update_fu_287_ctx_datalen_read = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } else { grp_sha256_update_fu_287_ctx_datalen_read = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void sha256::thread_grp_sha256_update_fu_287_len() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read())) { if (esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())) { grp_sha256_update_fu_287_len = n_load_reg_845.read(); } else if (esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) { grp_sha256_update_fu_287_len = ap_const_lv32_40; } else { grp_sha256_update_fu_287_len = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } else { grp_sha256_update_fu_287_len = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void sha256::thread_grp_sha256_update_fu_287_p_read1() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read())) { if (esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())) { grp_sha256_update_fu_287_p_read1 = sha256ctx_bitlen_0_1_reg_900.read(); } else if (esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) { grp_sha256_update_fu_287_p_read1 = reg_471.read(); } else { grp_sha256_update_fu_287_p_read1 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } else { grp_sha256_update_fu_287_p_read1 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void sha256::thread_grp_sha256_update_fu_287_p_read10() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read())) { if (esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())) { grp_sha256_update_fu_287_p_read10 = sha256ctx_state_7_2_2_reg_945.read(); } else if (esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) { grp_sha256_update_fu_287_p_read10 = reg_525.read(); } else { grp_sha256_update_fu_287_p_read10 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } else { grp_sha256_update_fu_287_p_read10 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void sha256::thread_grp_sha256_update_fu_287_p_read2() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read())) { if (esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())) { grp_sha256_update_fu_287_p_read2 = sha256ctx_bitlen_1_1_reg_905.read(); } else if (esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) { grp_sha256_update_fu_287_p_read2 = reg_477.read(); } else { grp_sha256_update_fu_287_p_read2 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } else { grp_sha256_update_fu_287_p_read2 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void sha256::thread_grp_sha256_update_fu_287_p_read3() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read())) { if (esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())) { grp_sha256_update_fu_287_p_read3 = sha256ctx_state_0_2_2_reg_910.read(); } else if (esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) { grp_sha256_update_fu_287_p_read3 = reg_483.read(); } else { grp_sha256_update_fu_287_p_read3 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } else { grp_sha256_update_fu_287_p_read3 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void sha256::thread_grp_sha256_update_fu_287_p_read4() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read())) { if (esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())) { grp_sha256_update_fu_287_p_read4 = sha256ctx_state_1_2_2_reg_915.read(); } else if (esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) { grp_sha256_update_fu_287_p_read4 = reg_489.read(); } else { grp_sha256_update_fu_287_p_read4 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } else { grp_sha256_update_fu_287_p_read4 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void sha256::thread_grp_sha256_update_fu_287_p_read5() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read())) { if (esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())) { grp_sha256_update_fu_287_p_read5 = sha256ctx_state_2_2_2_reg_920.read(); } else if (esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) { grp_sha256_update_fu_287_p_read5 = reg_495.read(); } else { grp_sha256_update_fu_287_p_read5 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } else { grp_sha256_update_fu_287_p_read5 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void sha256::thread_grp_sha256_update_fu_287_p_read6() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read())) { if (esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())) { grp_sha256_update_fu_287_p_read6 = sha256ctx_state_3_2_2_reg_925.read(); } else if (esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) { grp_sha256_update_fu_287_p_read6 = reg_501.read(); } else { grp_sha256_update_fu_287_p_read6 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } else { grp_sha256_update_fu_287_p_read6 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void sha256::thread_grp_sha256_update_fu_287_p_read7() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read())) { if (esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())) { grp_sha256_update_fu_287_p_read7 = sha256ctx_state_4_2_2_reg_930.read(); } else if (esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) { grp_sha256_update_fu_287_p_read7 = reg_507.read(); } else { grp_sha256_update_fu_287_p_read7 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } else { grp_sha256_update_fu_287_p_read7 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void sha256::thread_grp_sha256_update_fu_287_p_read8() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read())) { if (esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())) { grp_sha256_update_fu_287_p_read8 = sha256ctx_state_5_2_2_reg_935.read(); } else if (esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) { grp_sha256_update_fu_287_p_read8 = reg_513.read(); } else { grp_sha256_update_fu_287_p_read8 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } else { grp_sha256_update_fu_287_p_read8 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void sha256::thread_grp_sha256_update_fu_287_p_read9() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read())) { if (esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())) { grp_sha256_update_fu_287_p_read9 = sha256ctx_state_6_2_2_reg_940.read(); } else if (esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) { grp_sha256_update_fu_287_p_read9 = reg_519.read(); } else { grp_sha256_update_fu_287_p_read9 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } else { grp_sha256_update_fu_287_p_read9 = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } } void sha256::thread_i9_cast5_fu_629_p1() { i9_cast5_fu_629_p1 = esl_zext<32,7>(i9_reg_235.read()); } void sha256::thread_i9_cast6_fu_625_p1() { i9_cast6_fu_625_p1 = esl_zext<10,7>(i9_reg_235.read()); } void sha256::thread_i_1_cast4_fu_686_p1() { i_1_cast4_fu_686_p1 = esl_zext<10,6>(i_1_reg_246.read()); } void sha256::thread_i_1_cast_fu_690_p1() { i_1_cast_fu_690_p1 = esl_zext<32,6>(i_1_reg_246.read()); } void sha256::thread_i_2_cast3_fu_730_p1() { i_2_cast3_fu_730_p1 = esl_zext<32,6>(i_2_reg_257.read()); } void sha256::thread_i_7_fu_639_p2() { i_7_fu_639_p2 = (!i9_reg_235.read().is_01() || !ap_const_lv7_1.is_01())? sc_lv<7>(): (sc_biguint<7>(i9_reg_235.read()) + sc_biguint<7>(ap_const_lv7_1)); } void sha256::thread_i_8_fu_699_p2() { i_8_fu_699_p2 = (!i_1_reg_246.read().is_01() || !ap_const_lv6_1.is_01())? sc_lv<6>(): (sc_biguint<6>(i_1_reg_246.read()) + sc_biguint<6>(ap_const_lv6_1)); } void sha256::thread_i_fu_741_p2() { i_fu_741_p2 = (!i_2_reg_257.read().is_01() || !ap_const_lv6_1.is_01())? sc_lv<6>(): (sc_biguint<6>(i_2_reg_257.read()) + sc_biguint<6>(ap_const_lv6_1)); } void sha256::thread_icmp_fu_619_p2() { icmp_fu_619_p2 = (!tmp_97_fu_609_p4.read().is_01() || !ap_const_lv26_0.is_01())? sc_lv<1>(): sc_lv<1>(tmp_97_fu_609_p4.read() == ap_const_lv26_0); } void sha256::thread_n_1_fu_665_p2() { n_1_fu_665_p2 = (!n_load_reg_845.read().is_01() || !ap_const_lv32_FFFFFFC0.is_01())? sc_lv<32>(): (sc_biguint<32>(n_load_reg_845.read()) + sc_bigint<32>(ap_const_lv32_FFFFFFC0)); } void sha256::thread_seg_buf_address0() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state9.read())) { seg_buf_address0 = (sc_lv<6>) (i_2_cast3_fu_730_p1.read()); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state7.read())) { seg_buf_address0 = (sc_lv<6>) (i_1_cast_reg_877.read()); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state4.read())) { seg_buf_address0 = (sc_lv<6>) (i9_cast5_reg_859.read()); } else if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())))) { seg_buf_address0 = grp_sha256_update_fu_287_data_address0.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state8.read())) { seg_buf_address0 = grp_sha256_final_fu_268_hash_address0.read(); } else { seg_buf_address0 = (sc_lv<6>) ("XXXXXX"); } } void sha256::thread_seg_buf_ce0() { if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state9.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state4.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state7.read()))) { seg_buf_ce0 = ap_const_logic_1; } else if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())))) { seg_buf_ce0 = grp_sha256_update_fu_287_data_ce0.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state8.read())) { seg_buf_ce0 = grp_sha256_final_fu_268_hash_ce0.read(); } else { seg_buf_ce0 = ap_const_logic_0; } } void sha256::thread_seg_buf_ce1() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state8.read())) { seg_buf_ce1 = grp_sha256_final_fu_268_hash_ce1.read(); } else { seg_buf_ce1 = ap_const_logic_0; } } void sha256::thread_seg_buf_d0() { if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state4.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state7.read()))) { seg_buf_d0 = data_q0.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state8.read())) { seg_buf_d0 = grp_sha256_final_fu_268_hash_d0.read(); } else { seg_buf_d0 = "XXXXXXXX"; } } void sha256::thread_seg_buf_we0() { if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state4.read()) || esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state7.read()))) { seg_buf_we0 = ap_const_logic_1; } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state8.read())) { seg_buf_we0 = grp_sha256_final_fu_268_hash_we0.read(); } else { seg_buf_we0 = ap_const_logic_0; } } void sha256::thread_seg_buf_we1() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state8.read())) { seg_buf_we1 = grp_sha256_final_fu_268_hash_we1.read(); } else { seg_buf_we1 = ap_const_logic_0; } } void sha256::thread_seg_offset_1_fu_675_p2() { seg_offset_1_fu_675_p2 = (!seg_offset_fu_152.read().is_01() || !ap_const_lv32_40.is_01())? sc_lv<32>(): (sc_biguint<32>(seg_offset_fu_152.read()) + sc_biguint<32>(ap_const_lv32_40)); } void sha256::thread_sha256ctx_data_address0() { if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())))) { sha256ctx_data_address0 = grp_sha256_update_fu_287_ctx_data_address0.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state8.read())) { sha256ctx_data_address0 = grp_sha256_final_fu_268_ctx_data_address0.read(); } else { sha256ctx_data_address0 = (sc_lv<6>) ("XXXXXX"); } } void sha256::thread_sha256ctx_data_address1() { if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())))) { sha256ctx_data_address1 = grp_sha256_update_fu_287_ctx_data_address1.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state8.read())) { sha256ctx_data_address1 = grp_sha256_final_fu_268_ctx_data_address1.read(); } else { sha256ctx_data_address1 = (sc_lv<6>) ("XXXXXX"); } } void sha256::thread_sha256ctx_data_ce0() { if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())))) { sha256ctx_data_ce0 = grp_sha256_update_fu_287_ctx_data_ce0.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state8.read())) { sha256ctx_data_ce0 = grp_sha256_final_fu_268_ctx_data_ce0.read(); } else { sha256ctx_data_ce0 = ap_const_logic_0; } } void sha256::thread_sha256ctx_data_ce1() { if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())))) { sha256ctx_data_ce1 = grp_sha256_update_fu_287_ctx_data_ce1.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state8.read())) { sha256ctx_data_ce1 = grp_sha256_final_fu_268_ctx_data_ce1.read(); } else { sha256ctx_data_ce1 = ap_const_logic_0; } } void sha256::thread_sha256ctx_data_d0() { if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())))) { sha256ctx_data_d0 = grp_sha256_update_fu_287_ctx_data_d0.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state8.read())) { sha256ctx_data_d0 = grp_sha256_final_fu_268_ctx_data_d0.read(); } else { sha256ctx_data_d0 = "XXXXXXXX"; } } void sha256::thread_sha256ctx_data_we0() { if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(icmp_reg_855.read(), ap_const_lv1_0)) || (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_reg_855.read())))) { sha256ctx_data_we0 = grp_sha256_update_fu_287_ctx_data_we0.read(); } else if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state8.read())) { sha256ctx_data_we0 = grp_sha256_final_fu_268_ctx_data_we0.read(); } else { sha256ctx_data_we0 = ap_const_logic_0; } } void sha256::thread_sha256ctx_data_we1() { if (esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state8.read())) { sha256ctx_data_we1 = grp_sha256_final_fu_268_ctx_data_we1.read(); } else { sha256ctx_data_we1 = ap_const_logic_0; } } void sha256::thread_sum2_cast_fu_720_p1() { sum2_cast_fu_720_p1 = esl_zext<32,10>(sum2_fu_714_p2.read()); } void sha256::thread_sum2_fu_714_p2() { sum2_fu_714_p2 = (!tmp_98_fu_710_p1.read().is_01() || !tmp2_fu_705_p2.read().is_01())? sc_lv<10>(): (sc_biguint<10>(tmp_98_fu_710_p1.read()) + sc_biguint<10>(tmp2_fu_705_p2.read())); } void sha256::thread_sum_cast_fu_660_p1() { sum_cast_fu_660_p1 = esl_zext<32,10>(sum_fu_654_p2.read()); } void sha256::thread_sum_fu_654_p2() { sum_fu_654_p2 = (!tmp_99_fu_650_p1.read().is_01() || !tmp1_fu_645_p2.read().is_01())? sc_lv<10>(): (sc_biguint<10>(tmp_99_fu_650_p1.read()) + sc_biguint<10>(tmp1_fu_645_p2.read())); } void sha256::thread_tmp1_fu_645_p2() { tmp1_fu_645_p2 = (!tmp_96_reg_839.read().is_01() || !i9_cast6_fu_625_p1.read().is_01())? sc_lv<10>(): (sc_biguint<10>(tmp_96_reg_839.read()) + sc_biguint<10>(i9_cast6_fu_625_p1.read())); } void sha256::thread_tmp2_fu_705_p2() { tmp2_fu_705_p2 = (!tmp_96_reg_839.read().is_01() || !i_1_cast4_fu_686_p1.read().is_01())? sc_lv<10>(): (sc_biguint<10>(tmp_96_reg_839.read()) + sc_biguint<10>(i_1_cast4_fu_686_p1.read())); } void sha256::thread_tmp_96_fu_531_p1() { tmp_96_fu_531_p1 = base_offset.read().range(10-1, 0); } void sha256::thread_tmp_97_fu_609_p4() { tmp_97_fu_609_p4 = n_fu_104.read().range(31, 6); } void sha256::thread_tmp_98_fu_710_p1() { tmp_98_fu_710_p1 = seg_offset_fu_152.read().range(10-1, 0); } void sha256::thread_tmp_99_fu_650_p1() { tmp_99_fu_650_p1 = seg_offset_fu_152.read().range(10-1, 0); } void sha256::thread_tmp_fu_603_p2() { tmp_fu_603_p2 = (!n_fu_104.read().is_01() || !ap_const_lv32_0.is_01())? sc_lv<1>(): sc_lv<1>(n_fu_104.read() == ap_const_lv32_0); } void sha256::thread_ap_NS_fsm() { switch (ap_CS_fsm.read().to_uint64()) { case 1 : if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state1.read()) && esl_seteq<1,1,1>(ap_start.read(), ap_const_logic_1))) { ap_NS_fsm = ap_ST_fsm_state2; } else { ap_NS_fsm = ap_ST_fsm_state1; } break; case 2 : if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state2.read()) && esl_seteq<1,1,1>(tmp_fu_603_p2.read(), ap_const_lv1_0) && esl_seteq<1,1,1>(ap_const_lv1_1, icmp_fu_619_p2.read()))) { ap_NS_fsm = ap_ST_fsm_state6; } else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state2.read()) && esl_seteq<1,1,1>(tmp_fu_603_p2.read(), ap_const_lv1_0) && esl_seteq<1,1,1>(icmp_fu_619_p2.read(), ap_const_lv1_0))) { ap_NS_fsm = ap_ST_fsm_state3; } else { ap_NS_fsm = ap_ST_fsm_state8; } break; case 4 : if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state3.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, exitcond5_fu_633_p2.read()))) { ap_NS_fsm = ap_ST_fsm_state5; } else { ap_NS_fsm = ap_ST_fsm_state4; } break; case 8 : ap_NS_fsm = ap_ST_fsm_state3; break; case 16 : if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state5.read()) && esl_seteq<1,1,1>(ap_block_state5_on_subcall_done.read(), ap_const_boolean_0))) { ap_NS_fsm = ap_ST_fsm_state2; } else { ap_NS_fsm = ap_ST_fsm_state5; } break; case 32 : if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state6.read()) && esl_seteq<1,1,1>(ap_const_lv1_0, exitcond4_fu_694_p2.read()))) { ap_NS_fsm = ap_ST_fsm_state7; } else { ap_NS_fsm = ap_ST_fsm_state5; } break; case 64 : ap_NS_fsm = ap_ST_fsm_state6; break; case 128 : if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state8.read()) && esl_seteq<1,1,1>(grp_sha256_final_fu_268_ap_done.read(), ap_const_logic_1))) { ap_NS_fsm = ap_ST_fsm_state9; } else { ap_NS_fsm = ap_ST_fsm_state8; } break; case 256 : if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state9.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, exitcond_fu_735_p2.read()))) { ap_NS_fsm = ap_ST_fsm_state1; } else { ap_NS_fsm = ap_ST_fsm_state10; } break; case 512 : ap_NS_fsm = ap_ST_fsm_state9; break; default : ap_NS_fsm = (sc_lv<10>) ("XXXXXXXXXX"); break; } } void sha256::thread_hdltv_gen() { const char* dump_tv = std::getenv("AP_WRITE_TV"); if (!(dump_tv && string(dump_tv) == "on")) return; wait(); mHdltvinHandle << "[ " << endl; mHdltvoutHandle << "[ " << endl; int ap_cycleNo = 0; while (1) { wait(); const char* mComma = ap_cycleNo == 0 ? " " : ", " ; mHdltvinHandle << mComma << "{" << " \"ap_rst_n\" : \"" << ap_rst_n.read() << "\" "; mHdltvinHandle << " , " << " \"s_axi_AXILiteS_AWVALID\" : \"" << s_axi_AXILiteS_AWVALID.read() << "\" "; mHdltvoutHandle << mComma << "{" << " \"s_axi_AXILiteS_AWREADY\" : \"" << s_axi_AXILiteS_AWREADY.read() << "\" "; mHdltvinHandle << " , " << " \"s_axi_AXILiteS_AWADDR\" : \"" << s_axi_AXILiteS_AWADDR.read() << "\" "; mHdltvinHandle << " , " << " \"s_axi_AXILiteS_WVALID\" : \"" << s_axi_AXILiteS_WVALID.read() << "\" "; mHdltvoutHandle << " , " << " \"s_axi_AXILiteS_WREADY\" : \"" << s_axi_AXILiteS_WREADY.read() << "\" "; mHdltvinHandle << " , " << " \"s_axi_AXILiteS_WDATA\" : \"" << s_axi_AXILiteS_WDATA.read() << "\" "; mHdltvinHandle << " , " << " \"s_axi_AXILiteS_WSTRB\" : \"" << s_axi_AXILiteS_WSTRB.read() << "\" "; mHdltvinHandle << " , " << " \"s_axi_AXILiteS_ARVALID\" : \"" << s_axi_AXILiteS_ARVALID.read() << "\" "; mHdltvoutHandle << " , " << " \"s_axi_AXILiteS_ARREADY\" : \"" << s_axi_AXILiteS_ARREADY.read() << "\" "; mHdltvinHandle << " , " << " \"s_axi_AXILiteS_ARADDR\" : \"" << s_axi_AXILiteS_ARADDR.read() << "\" "; mHdltvoutHandle << " , " << " \"s_axi_AXILiteS_RVALID\" : \"" << s_axi_AXILiteS_RVALID.read() << "\" "; mHdltvinHandle << " , " << " \"s_axi_AXILiteS_RREADY\" : \"" << s_axi_AXILiteS_RREADY.read() << "\" "; mHdltvoutHandle << " , " << " \"s_axi_AXILiteS_RDATA\" : \"" << s_axi_AXILiteS_RDATA.read() << "\" "; mHdltvoutHandle << " , " << " \"s_axi_AXILiteS_RRESP\" : \"" << s_axi_AXILiteS_RRESP.read() << "\" "; mHdltvoutHandle << " , " << " \"s_axi_AXILiteS_BVALID\" : \"" << s_axi_AXILiteS_BVALID.read() << "\" "; mHdltvinHandle << " , " << " \"s_axi_AXILiteS_BREADY\" : \"" << s_axi_AXILiteS_BREADY.read() << "\" "; mHdltvoutHandle << " , " << " \"s_axi_AXILiteS_BRESP\" : \"" << s_axi_AXILiteS_BRESP.read() << "\" "; mHdltvoutHandle << " , " << " \"interrupt\" : \"" << interrupt.read() << "\" "; mHdltvinHandle << "}" << std::endl; mHdltvoutHandle << "}" << std::endl; ap_cycleNo++; } } }
C++
CL
2d95f1cc3dd4a7e7dea0547375ee7fcddff3805e439d0b601d09e9109fcdc1a1
//+--------------------------------------------------------------------------- // // Microsoft Forms // Copyright (C) Microsoft Corporation, 1994-1996 // // File: tdraw.cxx // // Contents: CTable and related classes. // //---------------------------------------------------------------------------- #include <headers.hxx> #ifndef X_FORMKRNL_HXX_ #define X_FORMKRNL_HXX_ #include <formkrnl.hxx> #endif #ifndef X_TABLE_HXX_ #define X_TABLE_HXX_ #include "table.hxx" #endif #ifndef X_DOWNLOAD_HXX_ #define X_DOWNLOAD_HXX_ #include <download.hxx> #endif #ifndef X_OTHRGUID_H_ #define X_OTHRGUID_H_ #include <othrguid.h> #endif #ifndef X_BINDER_HXX_ #define X_BINDER_HXX_ #include <binder.hxx> #endif #ifndef X_LTABLE_HXX_ #define X_LTABLE_HXX_ #include "ltable.hxx" #endif #ifndef X_LTROW_HXX_ #define X_LTROW_HXX_ #include "ltrow.hxx" #endif #ifndef X_LTCELL_HXX_ #define X_LTCELL_HXX_ #include "ltcell.hxx" #endif #ifndef X_DISPDEFS_HXX_ #define X_DISPDEFS_HXX_ #include "dispdefs.hxx" #endif MtDefine(CTableDrawSiteList_aryElements_pv, Locals, "CTable::DrawSiteList aryElements::_pv") MtDefine(CTable_pBorderInfoCellDefault, CTable, "CTable::_pBorderInfoCellDefault") ExternTag(tagTableRecalc); WORD s_awEdgesFromTableFrame[htmlFrameborder+1] = { BF_RECT, // not set case, use all edges 0, BF_TOP, BF_BOTTOM, BF_TOP | BF_BOTTOM, BF_LEFT, BF_RIGHT, BF_LEFT | BF_RIGHT, BF_RECT, BF_RECT }; WORD s_awEdgesFromTableRules[htmlRulesall+1] = { BF_RECT, // not set case, use all edges 0, 0, BF_TOP | BF_BOTTOM, BF_LEFT | BF_RIGHT, BF_RECT, }; //+--------------------------------------------------------------------------- // // Member: CTableCell::GetBorderInfo // // Synopsis: fill out border information // //---------------------------------------------------------------------------- DWORD CTableCell::GetBorderInfo(CDocInfo * pdci, CBorderInfo *pborderinfo, BOOL fAll) { return Layout()->GetCellBorderInfo(pdci, pborderinfo, fAll); } //+--------------------------------------------------------------------------- // // Member: CTable::GetBorderInfo // // Synopsis: fill out border information // //---------------------------------------------------------------------------- DWORD CTable::GetBorderInfo(CDocInfo * pdci, CBorderInfo *pborderinfo, BOOL fAll) { return Layout()->GetTableBorderInfo(pdci, pborderinfo, fAll); }
C++
CL
6fa67d2bd45e4990ed7f2311368bf369155aa272501a54c2b599af13a2023955
// // (C) Copyright 1998-2006 by Autodesk, Inc. // // Permission to use, copy, modify, and distribute this software in // object code form for any purpose and without fee is hereby granted, // provided that the above copyright notice appears in all copies and // that both that copyright notice and the limited warranty and // restricted rights notice below appear in all supporting // documentation. // // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE // UNINTERRUPTED OR ERROR FREE. // // Use, duplication, or disclosure by the U.S. Government is subject to // restrictions set forth in FAR 52.227-19 (Commercial Computer // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) // (Rights in Technical Data and Computer Software), as applicable. // // #include "StdAfx.h" #if defined(_DEBUG) && !defined(AC_FULL_DEBUG) #error _DEBUG should not be defined except in internal Adesk debug builds #endif #include "ArxDbgUiTdcLongTrans.h" #include "ArxDbgUtils.h" #include "ArxDbgUiDlgDxf.h" #include "ArxDbgUiTdmDatabase.h" #include "ArxDbgUiDlgReactors.h" #include "ArxDbgUiDlgXdata.h" #include "ArxDbgUiTdmEditor.h" #include "ArxDbgUiTdmIdMap.h" #include "ArxDbgReferenceFiler.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif /**************************************************************************** ** ** ArxDbgUiTdcLongTrans::ArxDbgUiTdcLongTrans ** ** **jma ** *************************************/ ArxDbgUiTdcLongTrans::ArxDbgUiTdcLongTrans(AcDbLongTransaction* lt) : m_longTrans(lt) { //{{AFX_DATA_INIT(ArxDbgUiTdcLongTrans) //}}AFX_DATA_INIT } /**************************************************************************** ** ** ArxDbgUiTdcLongTrans::DoDataExchange ** ** **jma ** *************************************/ void ArxDbgUiTdcLongTrans::DoDataExchange(CDataExchange* pDX) { ArxDbgUiTdcDbObjectBase::DoDataExchange(pDX); //{{AFX_DATA_MAP(ArxDbgUiTdcLongTrans) DDX_Control(pDX, ARXDBG_LC_VALUES, m_dataList); DDX_Control(pDX, ARXDBG_TREE_OBJS, m_tblTree); //}}AFX_DATA_MAP } ///////////////////////////////////////////////////////////////////////////// // ArxDbgUiTdcLongTrans message map BEGIN_MESSAGE_MAP(ArxDbgUiTdcLongTrans, ArxDbgUiTdcDbObjectBase) //{{AFX_MSG_MAP(ArxDbgUiTdcLongTrans) ON_NOTIFY(TVN_SELCHANGED, ARXDBG_TREE_OBJS, OnSelchangedSymtabs) ON_BN_CLICKED(ARXDBG_BN_DATABASE, OnDatabase) ON_BN_CLICKED(ARXDBG_BN_IDMAP, OnShowIdMap) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // ArxDbgUiTdcLongTrans message handlers /**************************************************************************** ** ** ArxDbgUiTdcLongTrans::OnInitDialog ** ** **jma ** *************************************/ BOOL ArxDbgUiTdcLongTrans::OnInitDialog() { ArxDbgUiTdcDbObjectBase::OnInitDialog(); HTREEITEM treeItem; treeItem = addOneTreeItem(_T("Long Transaction"), m_longTrans->objectId(), TVI_ROOT); m_tblTree.SelectItem(treeItem); // make this one the currently selected one buildColumns(m_dataList); displayCurrent(0); // disable IdMap button if there isn't one. AcDbIdMapping* idMap = m_longTrans->activeIdMap(); if (idMap == NULL) ArxDbgUtils::enableDlgItem(this, ARXDBG_BN_IDMAP, FALSE); return TRUE; } /**************************************************************************** ** ** ArxDbgUiTdcLongTrans::displayCurrent ** ** **jma ** *************************************/ void ArxDbgUiTdcLongTrans::displayCurrent(int index) { // remove any previous entries m_fieldStrList.RemoveAll(); m_valueStrList.RemoveAll(); ASSERT((index >= 0) && (index < m_objIdList.length())); m_currentObjId = m_objIdList[index]; // TBD: index is ignored right now because we only have one item CString str; setExtensionButtons(m_longTrans); display(m_longTrans); drawPropsList(m_dataList); } /**************************************************************************** ** ** ArxDbgUiTdcLongTrans::OnSelchangedSymtabs ** ** **jma ** *************************************/ void ArxDbgUiTdcLongTrans::OnSelchangedSymtabs(NMHDR* pNMHDR, LRESULT* pResult) { NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; displayCurrent(static_cast<int>(pNMTreeView->itemNew.lParam)); *pResult = 0; } /**************************************************************************** ** ** ArxDbgUiTdcLongTrans::addOneTreeItem ** ** **jma ** *************************************/ HTREEITEM ArxDbgUiTdcLongTrans::addOneTreeItem(LPCTSTR name, const AcDbObjectId& objId, HTREEITEM parent, bool sort) { m_objIdList.append(objId); // keep track of the objectId for each entry int index = m_objIdList.length() - 1; ASSERT(index >= 0); TV_ITEM tvItem; TV_INSERTSTRUCT tvInsert; tvItem.mask = TVIF_TEXT | TVIF_PARAM; tvItem.pszText = const_cast<TCHAR*>(name); tvItem.cchTextMax = lstrlen(name); tvItem.lParam = (LPARAM)index; //index of AcDbObjectId tvInsert.item = tvItem; if (sort) tvInsert.hInsertAfter = TVI_SORT; else tvInsert.hInsertAfter = TVI_LAST; tvInsert.hParent = parent; return m_tblTree.InsertItem(&tvInsert); } /**************************************************************************** ** ** ArxDbgUiTdcLongTrans::OnDxf ** ** **jma ** *************************************/ void ArxDbgUiTdcLongTrans::OnDxf() { Acad::ErrorStatus es = m_longTrans->downgradeOpen(); if (es == Acad::eOk) { ArxDbgUiDlgDxf dbox(this, m_longTrans); dbox.DoModal(); es = m_longTrans->upgradeOpen(); if (es != Acad::eOk) ArxDbgUtils::rxErrorAlert(es); } else ArxDbgUtils::rxErrorAlert(es); } /**************************************************************************** ** ** ArxDbgUiTdcLongTrans::OnExtdict ** ** **jma ** *************************************/ void ArxDbgUiTdcLongTrans::OnExtdict() { AcDbObjectId extDictId = m_longTrans->extensionDictionary(); ArxDbgUiTdmDatabase dbox(extDictId, this, _T("Extension Dictionary")); dbox.DoModal(); } /**************************************************************************** ** ** ArxDbgUiTdcLongTrans::OnReactors ** ** **jma ** *************************************/ void ArxDbgUiTdcLongTrans::OnReactors() { ArxDbgUiDlgReactors dbox(this, m_longTrans); dbox.DoModal(); } /**************************************************************************** ** ** ArxDbgUiTdcLongTrans::OnXdata ** ** **jma ** *************************************/ void ArxDbgUiTdcLongTrans::OnXdata() { ArxDbgUiDlgXdata dbox(this, m_longTrans); dbox.DoModal(); } /**************************************************************************** ** ** ArxDbgUiTdcLongTrans::OnDatabase ** ** **jma ** *************************************/ void ArxDbgUiTdcLongTrans::OnDatabase() { AcDbDatabase* db = m_longTrans->database(); if (db != NULL) { ArxDbgUiTdmDatabase dbox(db, this, _T("Database For Object")); dbox.DoModal(); } else { ASSERT(0); // button should have been disabled! } } /**************************************************************************** ** ** ArxDbgUiTdcLongTrans::OnDocument ** ** **jma ** *************************************/ void ArxDbgUiTdcLongTrans::OnDocument() { AcDbDatabase* db = m_longTrans->database(); AcApDocument* doc = acDocManager->document(db); if (doc) { ArxDbgUiTdmEditor dbox(this, doc); dbox.DoModal(); } else { ASSERT(0); // this button should have been disabled! } } /**************************************************************************** ** ** ArxDbgUiTdcLongTrans::getReferencedObjects ** ** **jma ** *************************************/ bool ArxDbgUiTdcLongTrans::getReferencedObjects(AcDbObjectIdArray& hardPointerIds, AcDbObjectIdArray& softPointerIds, AcDbObjectIdArray& hardOwnershipIds, AcDbObjectIdArray& softOwnershipIds) { ArxDbgReferenceFiler filer; m_longTrans->dwgOut(&filer); hardPointerIds = filer.m_hardPointerIds; softPointerIds = filer.m_softPointerIds; hardOwnershipIds = filer.m_hardOwnershipIds; softOwnershipIds = filer.m_softOwnershipIds; return true; } /**************************************************************************** ** ** ArxDbgUiTdcLongTrans::OnShowIdMap ** ** **jma ** *************************************/ void ArxDbgUiTdcLongTrans::OnShowIdMap() { AcDbIdMapping* idMap = m_longTrans->activeIdMap(); if (idMap) { ArxDbgUiTdmIdMap dbox(idMap, this); dbox.DoModal(); } else { ASSERT(0); // this button should have been disabled! } }
C++
CL
e452ec4429de0b16685eb8a629d24304583316a691e289dec74f2ec9ca2309ae
#pragma once #include <memory> #include <vector> #include "../linearAlgebra.h" struct Joint { // initial pose transform relative to parent joint - this is the "from" transform Transform2f unposedTransform_local; // initial pose transform relative to origin Transform2f unposedTransform_global; // final pose transform relative to parent joint - the "to" transform Transform2f posedTransform_local; // final pose transform relative to world Transform2f posedTransform_global; // to transform from -> to // we do globalUnposeTransform.inverse() * globalPosedTransform Transform2f unposedToCurrentTransform_global; typedef std::shared_ptr<Joint> P_Joint; typedef std::vector<P_Joint> VP_Joints; VP_Joints children; }; typedef std::shared_ptr<Joint> P_Joint; typedef std::vector<P_Joint> VP_Joints;
C++
CL
a26053fe491fceab4861f2228648c49201e13ad26741a2a42074c7164fc39114
#ifndef DATEFORMATDELEGATE_H #define DATEFORMATDELEGATE_H /**************** * copy from tutorial, spreadsheetdelegate.h * *****************/ #include <QStyledItemDelegate> #include <QDate> #include <QDateTimeEdit> #include <QDebug> class DateFormatDelegate : public QStyledItemDelegate { Q_OBJECT public: explicit DateFormatDelegate(QObject * parent = 0); //virtual QString displayText(const QVariant &value, const QLocale &locale) const; QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; void setEditorData(QWidget *editor, const QModelIndex &index) const override; void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override; signals: public slots: }; #endif // DATEFORMATDELEGATE_H
C++
CL
6d251c92b483e666ce026dfe135476b3f722d206ca88bf3409039f691257d41b
#include "stdafx.h" #include "DoPAR.h" const float inv_sqrt_2pi = 0.398942280401433f; // operating files systems long FileLength(const string& FName) { ifstream InF(FName.c_str(), ios::in | ios::binary); if (!InF) return 0; InF.seekg(0, InF.end); long Length = InF.tellg() / sizeof(char); InF.seekg(0, InF.beg); InF.close(); return Length; } bool fileExists(const string& name) { struct stat buffer; return (stat(name.c_str(), &buffer) == 0); } bool Write(const string FPathName, vector<uchar> Data) { if (FPathName.size() == 0) return false; if (Data.size() == 0) return false; int i(1); string tempFPathName2D = FPathName; while (fileExists(tempFPathName2D) == true) { tempFPathName2D = FPathName.substr(0, FPathName.find('.')) + "_" + to_string(i) + ".RAW"; i++; } ofstream OFile(tempFPathName2D.c_str(), ios::binary | ios::ate); if (!OFile) { cout << endl << "!OFile"; return false; } unsigned __int64 FSize = Data.size(); const long BlockSize = sizeof(char)*iSTEPLENGTH; char* Buffer = new char[sizeof(char)*iSTEPLENGTH]; long Steps = FSize / iSTEPLENGTH; long RemainNum = FSize % iSTEPLENGTH; long idx, DataIdx = 0; for (idx = 0; idx < Steps; ++idx) { for (int i = 0; i < iSTEPLENGTH; ++i) Buffer[i] = Data[DataIdx++]; if (!OFile.write(reinterpret_cast<char *>(Buffer), BlockSize)) { delete[] Buffer; return false; } } delete[] Buffer; if (RemainNum > 0) { char* Buff = new char[sizeof(char)*RemainNum]; for (int i = 0; i < RemainNum; ++i) Buff[i] = Data[DataIdx++]; if (!OFile.write(reinterpret_cast<char *>(Buff), sizeof(char)*RemainNum)) { delete[] Buff; return false; } delete[] Buff; } OFile.close(); return true; } bool GetNextRowParameters(short Cno, vector<string>& ValidParStr, vector<string>& ParV) { if ((unsigned short)Cno >= ValidParStr.size()) { cout << endl << "Wrong arguments!"; char ch; cin >> ch; exit(0); } ParV.clear(); string TmpS = ""; for (unsigned long Idx = 0; Idx < ValidParStr[Cno].size(); ++Idx) { if (ValidParStr[Cno][Idx] == ',' || ValidParStr[Cno][Idx] == ' ' || ValidParStr[Cno][Idx] == '\n') { if (TmpS.size() > 0) { ParV.push_back(TmpS); } TmpS = ""; } else { TmpS += ValidParStr[Cno][Idx]; } } //for(long InIdx=0; InIdx<LineLst1[LNidx].size(); ++InIdx) if (TmpS.size() > 0) { ParV.push_back(TmpS); } return true; } bool iFileExistYN(const string& PFileName) { struct stat stFileInfo; int intStat = stat(PFileName.c_str(), &stFileInfo); if (intStat != 0) return false; return true; } bool ReadTxtFiles(const string PFName, vector<string>& ResLines) { { vector<string> LineLst; ResLines.swap(LineLst); } ifstream FIn(PFName.c_str()); if (!FIn) { //cout << endl; //cout << endl <<" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"; //cout << endl<< " Failed to open file '" << PFName.c_str() << "' !"; //cout << endl << " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"; //cout << endl; //cout << endl << "Press any key to quit ..."; return false; } string Sline; while (getline(FIn, Sline)) ResLines.push_back(Sline); FIn.close(); return true; }; void showMat(const cv::String& winname, const cv::Mat& mat) {// Show a Mat object quickly. For testing purposes only. assert(!mat.empty()); cv::namedWindow(winname); cv::imshow(winname, mat); cv::waitKey(0); cv::destroyWindow(winname); } vector<uchar> MatToVec_8UTouchar(Mat mat) { vector<uchar> array; if (mat.isContinuous()) { array.assign(mat.datastart, mat.dataend); } else { for (int i = 0; i < mat.rows; ++i) { array.insert(array.end(), mat.ptr<uchar>(i), mat.ptr<uchar>(i) + mat.cols); } } return array; } vector<float> MatToVec_8UTofloat(Mat mat) { vector<uchar> array; if (mat.isContinuous()) { array.assign(mat.datastart, mat.dataend); } else { for (int i = 0; i < mat.rows; ++i) { array.insert(array.end(), mat.ptr<uchar>(i), mat.ptr<uchar>(i) + mat.cols); } } vector<float> array_float(array.begin(), array.end()); return array_float; } vector<float> MatToVec_16UTofloat(Mat mat) { vector<ushort> array; if (mat.isContinuous()) { array.assign((ushort*)mat.datastart, (ushort*)mat.dataend); } else { for (int i = 0; i < mat.rows; ++i) { array.insert(array.end(), mat.ptr<ushort>(i), mat.ptr<ushort>(i) + mat.cols); } } vector<float> array_float(array.begin(), array.end()); return array_float; } Mat VecToMat_ucharTo8U(vector<uchar> vec, int rows) { // vector to Mat, need the same data type! return Mat(vec, true).reshape(1, rows); } Mat VecToMat_floatTo8U(vector<float> vec, int rows) { // vector to Mat, need the same data type! vector<uchar> vec_uchar(vec.begin(), vec.end()); return Mat(vec_uchar, true).reshape(1, rows); } Mat VecToMat_floatTo16U(vector<float> vec, int rows) { // vector to Mat, need the same data type! vector<unsigned short> vec_unsignedshort(vec.begin(), vec.end()); return Mat(vec_unsignedshort, true).reshape(1, rows); } // index convert size_idx convertIndexANN_TIs(int level, size_idx index, size_idx TIsize_, size_idx blockSize_) { //convert ANNSearch_nearest_x_index to index_TIs size_idx tin, i, j, height, bias, ANNTIsize; height = TIsize_ - blockSize_ + 1; ANNTIsize = height *height; bias = blockSize_ / 2; tin = index / ANNTIsize; index %= ANNTIsize; i = index / height + bias; j = index % height + bias; return (tin*TIsize_*TIsize_ + i*TIsize_ + j); } size_idx trim(size_idx SIZE, size_idx index) { //Toroidal if (index < 0) index += SIZE; return index % SIZE; } template<typename T> void idxToCoord(T idx, T dimension, T &i, T &j, T &k) { k = idx % dimension; j = (idx / dimension) % dimension; i = idx / (dimension*dimension); } template<typename T> void TIsToRegular(T idx_TIs, T TIsize2d_, T &idx_regular, T &TInum) { idx_regular = idx_TIs % TIsize2d_; TInum = idx_TIs / TIsize2d_; //if (TInum < 0 || TInum >= MultiTIsNum) { // printf("\nTIsToRegular: idx%d, TInum%d", idx_TIs, TInum); // _getch(); //} } //!read multiple TIs bool ReadMultipleTIs(vector<string> &filelist, string inputfilename, string key) { string prefix, filename; int inputnum; if (inputfilename.rfind(key) != string::npos) { prefix = inputfilename.substr(0, inputfilename.rfind(key) + 2); inputnum = atoi(inputfilename.substr(inputfilename.rfind(key) + 2, inputfilename.rfind('.')).c_str()); for (int num = 0; num < 100; num++) { filename = prefix + to_string(num) + ".png"; if (fileExists(filename) && num!=inputnum) { filelist.push_back(filename); cout << endl << filename; } else if (!fileExists(filename) && num < inputnum) { cout << endl << filename <<" not found, quit"; _getch(); return false; } } } return true; } void LoadtoMat(vector<Mat> &Matlist, vector<string> FNlist, bool croprectangleYN = true) { //Load address to Mat; crop if not square; Matlist.reserve(FNlist.size()); Mat tempmat; for (int i = 0; i < FNlist.size(); i++) { tempmat = cv::imread(FNlist[i], CV_LOAD_IMAGE_ANYDEPTH); if (tempmat.cols != tempmat.rows) { cout << endl << "cols != rows, crop to square"; int mindim = min(tempmat.cols, tempmat.rows); Mat cropedMat = tempmat(Rect(0, 0, mindim, mindim)); cropedMat.copyTo(tempmat); } if (i > 0 && !(Matlist[i - 1].cols == tempmat.cols && Matlist[i - 1].rows == tempmat.rows)) { cout << endl << "Multiple TIs size not equal, quit"; _getch(); exit(0); } Matlist.push_back(tempmat); } } bool checkTIbinary(vector<Mat> Matlist) { //check TI is grayscale or binary Mat maskMat; bool allbinary = true; for (int i = 0; i < Matlist.size(); i++) { inRange(Matlist[i], 255, 255, maskMat); if (countNonZero(maskMat) != countNonZero(Matlist[i])) { allbinary = false; break; } } return allbinary; } // init vector template<typename T> void initPermutation(T dimension, bool sim2D, vector<T>& permutationlist) { // random permutation (precomputed) T Size = dimension * dimension * dimension; if (sim2D) Size = dimension * dimension; permutationlist.clear(); permutationlist.resize(Size); for (T i = 0; i <Size; ++i) { permutationlist[i] = i; } } DoPAR::DoPAR(){ } DoPAR::~DoPAR(){ } void DoPAR::cleardata() { for (int level = 0; level < MULTIRES - 1; ++level) { m_volume[level].clear(); //m_exemplar_x[level].clear(); m_exemplar_y[level].clear(); m_exemplar_z[level].clear(); KCoherence_x[level].clear(); KCoherence_y[level].clear(); KCoherence_z[level].clear(); isUnchanged_x[level].clear(); isUnchanged_y[level].clear(); isUnchanged_z[level].clear(); nearestIdx_x[level].clear(); nearestIdx_y[level].clear(); nearestIdx_z[level].clear(); nearestWeight_x[level].clear(); nearestWeight_y[level].clear(); nearestWeight_z[level].clear(); Origin_x[level].clear(); Origin_y[level].clear(); Origin_z[level].clear(); IndexHis_x[level].clear(); IndexHis_y[level].clear(); IndexHis_z[level].clear(); PosHis[level].clear(); SelectedPos[level].clear(); m_volume[level].shrink_to_fit(); //m_exemplar_x[level].shrink_to_fit(); m_exemplar_y[level].shrink_to_fit(); m_exemplar_z[level].shrink_to_fit(); KCoherence_x[level].shrink_to_fit(); KCoherence_y[level].shrink_to_fit(); KCoherence_z[level].shrink_to_fit(); isUnchanged_x[level].shrink_to_fit(); isUnchanged_y[level].shrink_to_fit(); isUnchanged_z[level].shrink_to_fit(); nearestIdx_x[level].shrink_to_fit(); nearestIdx_y[level].shrink_to_fit(); nearestIdx_z[level].shrink_to_fit(); nearestWeight_x[level].shrink_to_fit(); nearestWeight_y[level].shrink_to_fit(); nearestWeight_z[level].shrink_to_fit(); Origin_x[level].shrink_to_fit(); Origin_y[level].shrink_to_fit(); Origin_z[level].shrink_to_fit(); IndexHis_x[level].shrink_to_fit(); IndexHis_y[level].shrink_to_fit(); IndexHis_z[level].shrink_to_fit(); PosHis[level].shrink_to_fit(); SelectedPos[level].shrink_to_fit(); } m_permutation.clear(); m_permutation.shrink_to_fit(); } void DoPAR::GetStarted(string CurExeFile, int TIseries) { ReadRunPar_series(CurExeFile, TIseries); DoANNOptimization(TIseries); if (batchYN) for (batchsequenceNo = 1; batchsequenceNo < batchsequenceMax; batchsequenceNo++){ ReadRunPar_series(CurExeFile, TIseries); DoANNOptimization(TIseries); } } // ================ read parameters ========== void DoPAR::ReadRunPar_series(string CurExeFile, int TIseries) { cout << endl << "==========================================="; cout << endl << "Set up your running parameters... Series:" << TIseries; cout << endl << "==========================================="; string tempoutputfilename; string tempoutputformat; string parametername; string Path; vector<string> ResLines; {//Read setup file string tmpstr, name; iCGetDirFileName(CurExeFile, Path, name); string PFName = Path + "PAR_Setup.DAT";//!changed to series vector<string> TmpLines; if (!ReadTxtFiles(PFName, TmpLines)) { cout << endl; cout << endl << " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"; cout << endl << " Failed to open file '" << PFName.c_str() << "' !"; cout << endl << " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"; cout << endl; cout << endl << "Press any key to quit ..."; _getch(); exit(0); } for (unsigned long Row = 0; Row < TmpLines.size(); Row++) { string::size_type Posidx = TmpLines[Row].find("//"); if (Posidx != string::npos) { continue; } else { Posidx = TmpLines[Row].find("/*"); if (Posidx != string::npos) continue; } ResLines.push_back(TmpLines[Row]); } //for(int Row=0; Row < LineLst.size(); Row++) if (ResLines.size() == 0) { cout << endl << " ============================================================"; cout << endl << " Failed to open PAR-GO_Setup.DAT in current working directory !"; cout << endl << " ============================================================"; cout << endl << " Press any key to quit...."; _getch(); exit(0); } }//Read setup file short Row(-1); vector<string> ParV; ///////////////////////// check random seed if (useRandomSeed) { //cout << endl << "use Random Seed"; srand((unsigned)time(NULL)); std::random_device rd; std::mt19937 mersennetwistergenerator(rd()); } else { cout << endl << "use Fixed Seed = 0"; srand(0); std::mt19937 mersennetwistergenerator(0); } //uniform_real_distribution<double> probabilitydistribution(0.0, 1.0); ///////////////////////// Number of realizations GetNextRowParameters(++Row, ResLines, ParV); if (ParV.size() > 0) { if (ParV.size() > 0) NumRealization = atoi(ParV[0].c_str()); } // for release version, set parameters fixed HisEqYN = true; PatternEntropyAnalysisYN = false; GetNextRowParameters(++Row, ResLines, ParV); if (ParV.size() > 0) { useRandomSeed = true; int c = 0; if (ParV.size() > c) { if (atoi(ParV[c].c_str()) == 0) KeepParameterNameYN = false; else KeepParameterNameYN = true; c++; } if (ParV.size() > c) { if (atoi(ParV[c].c_str()) == 0) PrintDMYN = false; else PrintDMYN = true; c++;} if (ParV.size() > c) { if (atoi(ParV[c].c_str()) == 0) PrintHisYN = false; else PrintHisYN = true; c++;} if (ParV.size() > c) { if (atoi(ParV[c].c_str()) == 0) outputmultilevelYN = false; else outputmultilevelYN = true; c++; } if (ParV.size() > c) { if (atoi(ParV[c].c_str()) == 0) outputiterationYN = false; else outputiterationYN = true; c++; } } GetNextRowParameters(++Row, ResLines, ParV); if (ParV.size() > 0) { useRandomSeed = true; int c = 0; //if (ParV.size() > c) {FixedLayerDir = atoi(ParV[c].c_str()) - 1; c++;} //if (ParV.size() > c) { if (atoi(ParV[c].c_str()) == 0) MultipleTIsYN = false; else MultipleTIsYN = true; c++; } if (ParV.size() > c) { factorIndex = atof(ParV[c].c_str()); c++; } if (ParV.size() > c) { factorPos = atof(ParV[c].c_str()); c++; } if (ParV.size() > c) { factorC = atof(ParV[c].c_str()); c++; if (factorC < 0.001f) ColorHis_ON = false; } } // read temp blockSize GetNextRowParameters(++Row, ResLines, ParV); tempblockSize.clear(); for (int c = 0; c < ParV.size(); c++){ if (atoi(ParV[c].c_str()) == -1){ blockSizeconfigYN = false; break; } blockSizeconfigYN = true; tempblockSize.push_back(atoi(ParV[c].c_str())); } //// read temp maxiteration //GetNextRowParameters(++Row, ResLines, ParV); //tempMAXITERATION.clear(); //for (int c = 0; c < ParV.size(); c++){ // MAXITERATIONconfigYN = true; // tempMAXITERATION.push_back(atoi(ParV[c].c_str())); //} if (Row >= ResLines.size() - 1) { printf("\nFinish series, quit."); _getch(); exit(0); } //!jump, according to series num for (int i = 0; i < TIseries; i++) Row+=3; ///////////////////////// Working directory if (Row >= ResLines.size()-1) { printf("\nFinish series, quit."); _getch(); exit(0); } workpath = ResLines[++Row]; if (workpath.back() != '\\') workpath += '\\'; ///////////////////////// Specify training images in XY, XZ and YZ-plane if (ResLines.size() > ++Row) { vector<string> ParV; GetNextRowParameters(Row, ResLines, ParV); if (MultipleTIsYN == false) { FNameXY.clear(); FNameXZ.clear(); FNameYZ.clear(); } if (ParV.size() > 0) { if (ParV.size() > 0) { if (batchYN == false && ParV[0].back() == '*') { batchYN = true; MultipleTIsYN = false; batchFileList_XY.clear(); //batchFileList_XZ.clear(); batchFileList_YZ.clear(); batchsequenceNo = 0; //std::string strSearch = "C:\\Users\\dell\\Downloads\\FractureZone_8x\\FractureZone*"; std::string strSearch = workpath + ParV[0]; WIN32_FIND_DATAA ffd; HANDLE hFind = FindFirstFileA(strSearch.c_str(), &ffd); do{ batchFileList_XY.push_back(ffd.cFileName); } while (FindNextFileA(hFind, &ffd) != 0); batchsequenceMax = batchFileList_XY.size(); } if (batchYN) ParV[0] = batchFileList_XY[batchsequenceNo]; //FNameXY.push_back(workpath + batchFileList_XY[batchsequenceNo]); FNameXY.push_back(workpath + ParV[0]); if (!fileExists(FNameXY[0])) { cout << endl << "Cannot find: " << endl << FNameXY[0]; _getch(); exit(0); } else cout << endl << "XY" << endl << FNameXY[0]; if (MultipleTIsYN) ReadMultipleTIs(FNameXY, FNameXY[0], "XY"); } if (ParV.size() > 1) { if (batchYN && ParV[1].back() == '*') { batchFileList_XZ.clear(); std::string strSearch = workpath + ParV[1]; WIN32_FIND_DATAA ffd; HANDLE hFind = FindFirstFileA(strSearch.c_str(), &ffd); do{ batchFileList_XZ.push_back(ffd.cFileName); } while (FindNextFileA(hFind, &ffd) != 0); if (batchsequenceMax != batchFileList_XZ.size()){ cout << endl << "batch size XY != XZ, quit"; _getch(); exit(0); } } if (batchYN) ParV[1] = batchFileList_XZ[batchsequenceNo]; FNameXZ.push_back(workpath + ParV[1]); if (!fileExists(FNameXZ[0])) { cout << endl << "Cannot find: " << endl << FNameXZ[0]; _getch(); exit(0); } else cout << endl << "XZ" << endl << FNameXZ[0]; if (MultipleTIsYN) ReadMultipleTIs(FNameXZ, FNameXZ[0], "XZ"); } if (ParV.size() > 2) { if (batchYN && ParV[2].back() == '*') { batchFileList_YZ.clear(); std::string strSearch = workpath + ParV[2]; WIN32_FIND_DATAA ffd; HANDLE hFind = FindFirstFileA(strSearch.c_str(), &ffd); do{ batchFileList_YZ.push_back(ffd.cFileName); } while (FindNextFileA(hFind, &ffd) != 0); if (batchsequenceMax != batchFileList_YZ.size()){ cout << endl << "batch size XY/XZ != YZ, quit"; _getch(); exit(0); } } if (batchYN) ParV[2] = batchFileList_YZ[batchsequenceNo]; FNameYZ.push_back(workpath + ParV[2]); if (!fileExists(FNameYZ[0])) { cout << endl << "Cannot find: " << endl << FNameYZ[0]; _getch(); exit(0); } else cout << endl << "YZ" << endl << FNameYZ[0]; if (MultipleTIsYN) ReadMultipleTIs(FNameYZ, FNameYZ[0], "YZ"); } if (FNameXY.size() != FNameYZ.size() || FNameXY.size() != FNameXZ.size()) { cout << endl << "Multiple TIs num not the same" << endl << FNameYZ[0]; _getch(); exit(0); } else if (MultipleTIsYN && FNameXY.size()>1) { MultiTIsNum = FNameXY.size(); cout << endl << "Multiple TIs num=" << MultiTIsNum; } } } ///////////////////////// read 3D model name outputpath = ""; if (ResLines.size() > ++Row) { vector<string> ParV; GetNextRowParameters(Row, ResLines, ParV); if (ParV.size() > 0) { if (ParV.size() > 0) modelFilename3D = outputpath + ParV[0]; } //////seperate filename and format auto idx = ParV[0].rfind('.'); if (idx != std::string::npos) tempoutputformat = ParV[0].substr(idx); //no extension tempoutputfilename = ParV[0].substr(0, ParV[0].rfind('.') == string::npos ? ParV[0].length() : ParV[0].rfind('.')); cout << endl << "1 tempoutputfilename=" << tempoutputfilename; /////2d simulation if (tempoutputformat == ".png") { cout << endl << "2D simulation ON, just use the first (set of) TI."; SIM2D_YN = true; } if (batchYN){ if (tempoutputfilename.back() == '*') tempoutputfilename = tempoutputfilename.substr(0, tempoutputfilename.find('*')); cout << endl << "Enable batch processing"; //ParV[0] = batchFileList_XY[batchsequenceNo]; cout << endl << "batchFileList_XY[batchsequenceNo]=" << batchFileList_XY[batchsequenceNo]; tempoutputfilename += batchFileList_XY[batchsequenceNo].substr(0, batchFileList_XY[batchsequenceNo].find('.')); cout << endl << "2 tempoutputfilename=" << tempoutputfilename; } //optional parameter: output size if (ParV.size() > 1) { outputsizeatlastlevel = atoi(ParV[1].c_str()); } } outputfilename = tempoutputfilename; if (SIM2D_YN) FixedLayerDir = -1; if (FixedLayerDir >= 0 && FixedLayerDir < 3) { cout << endl << "enable fixed layer, modify directional weight: " << "1.0-->" << DirectionalWeight; } parameterstring = ""; if (MultiTIsNum > 1 && MultipleTIsYN) parameterstring += "_TI" + to_string(MultiTIsNum); //if (DMtransformYN && HisEqYN) parameterstring += "Eq" + to_string((int)HisEqYN); //parameterstring += "DM" + to_string((int)DMtransformYN); if (KeepParameterNameYN) parameterstring += "_I" + to_string((int)factorIndex) + "P" + to_string((int)factorPos) + "C" + to_string((int)factorC); if (FixedLayerDir > -1 && FixedLayerDir < 3) parameterstring += "Fix" + to_string(FixedLayerDir) + "W" + to_string((int)(100 * DirectionalWeight)); } // ================ load 2D TIs ========== void DoPAR::initTIbasedparameters(vector<Mat>& XY, vector<Mat>& XZ, vector<Mat>& YZ) { //already checked X,Y,Z TIs same num,size int dimension = XY[0].cols; ////based on Output dimension (not TI), choose multi-level parameters if (outputsizeatlastlevel == 0) outputsizeatlastlevel = dimension; MULTIRES = ceil(1e-5 + log2(outputsizeatlastlevel / 32.0)); if (outputsizeatlastlevel < 40) { cout << endl << "Output size < 40, too small!"; _getch(); exit(0); } else if (outputsizeatlastlevel > 600) { cout << endl << "Output size > 600, too big!"; _getch(); exit(0); } cout << endl << "TI dimension=" << dimension <<" Output dimension="<< outputsizeatlastlevel << " MULTIRES=" << MULTIRES; if (dimension < 128) { cout << endl << "for small TI, test just using one level"; MULTIRES = 1; blockSize = { 8 }; MAXITERATION = { 25 }; } if (PatternEntropyAnalysisYN) { cout << endl << "Pattern Entropy Analysis, one level"; MULTIRES = 1; blockSize = { 12 }; MAXITERATION = { 3 }; } else { ANNerror.resize(MULTIRES, 0.0); blockSize.resize(MULTIRES); MAXITERATION.resize(MULTIRES); vector<int> defaultblockSize = {8, 8, 6, 6, 6}; vector<int> defaultMAXITERATION = {32, 16, 8, 4, 2}; vector<double> defaultANNerror = {0.0, 0.0, 0.5, 1.0, 2.0}; if (MULTIRES < 3 || MULTIRES>5) { cout << endl << "MULTIRES not right, quit"; _getch(); exit(0); } string parameterstring_blocksize = "_"; for (int l = 0; l < MULTIRES; l++){ if (blockSizeconfigYN) blockSize[l] = tempblockSize[l]; else blockSize[l] = defaultblockSize[l]; parameterstring_blocksize += to_string(blockSize[l]); if (MAXITERATIONconfigYN) MAXITERATION[l] = tempMAXITERATION[l]; else MAXITERATION[l] = defaultMAXITERATION[l]; ANNerror[l] = defaultANNerror[l]; } if (KeepParameterNameYN) parameterstring += parameterstring_blocksize; } //crop to fit multi-level int multileveltimes = pow(2, MULTIRES - 1); if (dimension % multileveltimes != 0) { dimension = dimension / multileveltimes * multileveltimes; cout << endl << "TIs are croped to " << dimension << " to fit multi-grid"; for (int n = 0; n < XY.size(); n++) { Mat tempMat; XY[n](Rect(0, 0, dimension, dimension)).copyTo(tempMat); tempMat.copyTo(XY[n]); XZ[n](Rect(0, 0, dimension, dimension)).copyTo(tempMat); tempMat.copyTo(XZ[n]); YZ[n](Rect(0, 0, dimension, dimension)).copyTo(tempMat); tempMat.copyTo(YZ[n]); } } //! add additional space, later will crop to original size, to deal with Toroidal problem if (cropYN) outputsizeatlastlevel += pow(2, MULTIRES - 1) * blockSize[0]; // allocate TIsize, OUTsize TIsize.resize(MULTIRES); TIsize[MULTIRES - 1] = XY[0].cols; OUTsize.resize(MULTIRES); OUTsize[MULTIRES - 1] = outputsizeatlastlevel; m_volume.resize(MULTIRES); } bool DoPAR::loadExemplar() { //////exemplar_x --> YZ, exemplar_y --> ZX, exemplar_z --> XY //////using imagej, XY slice is XY, ememplar_z //////ZX slice can be attained by: 1. reslice top + flip virtical 2. then rotate 90 degrees left //////YZ slice is done by: reslice left //------in imagej: //exemplar_x -> XY //exemplar_y -> XZ //exemplar_z -> YZ //------------ Load Mat --------------------- vector<Mat> MatlistXY, MatlistXZ, MatlistYZ; LoadtoMat(MatlistXY, FNameXY); LoadtoMat(MatlistXZ, FNameXZ); LoadtoMat(MatlistYZ, FNameYZ); for (int s = 0; s < FNameXY.size(); s++) { //check X,Y,Z TI dimension equal if (!(MatlistXY[s].rows == MatlistXZ[s].rows && MatlistXY[s].rows == MatlistYZ[s].rows && MatlistXY[s].cols == MatlistXZ[s].cols && MatlistXY[s].cols == MatlistYZ[s].cols)) { cout << endl << "X,Y,Z TIs dimension not equal, quit"; _getch(); exit(0); } //check X,Y,Z TI the same or not, if yes need to switch row,col if (FNameXY[s] == FNameXZ[s] && FNameXY[s] == FNameYZ[s]) { cout << endl << "Same TI for XYZ, flip 2nd TI by switching X,Y: "<< FNameXY[s]; flip(MatlistXZ[s], MatlistXZ[s], 0); flip(MatlistXZ[s], MatlistXZ[s], 1); } } // check TI is grayscale or binary if (checkTIbinary(MatlistXY) && checkTIbinary(MatlistXZ) && checkTIbinary(MatlistYZ)) { cout << endl << "TI(s) binary, enable distance map transformation"; DMtransformYN = true; } else { cout << endl << "==== TI(s) NOT binary, disable distance map transformation===="; //cout << endl << "Not recommended to use greyscale TI, continue??"; //_getch(); DMtransformYN = false; HisEqYN = false; // change to 8-bit TI for (int n = 0; n < MultiTIsNum; n++){ MatlistXY[n].convertTo(MatlistXY[n], CV_8U); MatlistXZ[n].convertTo(MatlistXZ[n], CV_8U); MatlistYZ[n].convertTo(MatlistYZ[n], CV_8U); } cout << endl << "==== Greyscale TI convert to 8-bit ===="; if (PrintDMYN) { string tempfn = FNameXY[0].substr(0, FNameXY[0].rfind('.') == string::npos ? FNameXY[0].length() : FNameXY[0].rfind('.')); imwrite(tempfn + "_8bit.png", MatlistXY[0]); if (FNameXY[0] != FNameXZ[0]) { tempfn = FNameXZ[0].substr(0, FNameXZ[0].rfind('.') == string::npos ? FNameXZ[0].length() : FNameXZ[0].rfind('.')); imwrite(FNameXZ[0] + "_8bit.png", MatlistXZ[0]); } if (FNameXY[0] != FNameYZ[0]) { tempfn = FNameYZ[0].substr(0, FNameYZ[0].rfind('.') == string::npos ? FNameYZ[0].length() : FNameYZ[0].rfind('.')); imwrite(FNameYZ[0] + "_8bit.png", MatlistYZ[0]); } } } //------------ decide parameters based on TI dimension initTIbasedparameters(MatlistXY, MatlistXZ, MatlistYZ); //------------ Assign vectors --------------------- allocateVectors(); //------------ DM transform, Mat to vector!--------------------- invertpaddingDMtransform(MatlistXY, MatlistXZ, MatlistYZ, TIs_XY[MULTIRES-1], TIs_XZ[MULTIRES - 1], TIs_YZ[MULTIRES - 1]); //cout << endl << " max_element= " << *max_element(TIs_XY[MULTIRES - 1][0].begin(), TIs_XY[MULTIRES - 1][0].end()); _getch(); //------------ multi-level resize ----------------- if (MULTIRES > 1) { cout << endl << "use Lancoz filter to resize."; //tested: better than Gaussian and INTER_AREA for (int l = MULTIRES - 2; l >= 0; --l) { for (int n = 0; n < MultiTIsNum; n++) { Mat next_XY, next_XZ, next_YZ; double ratio = pow(0.5, (MULTIRES - 1 - l)); resize(MatlistXY[n], next_XY, Size(), ratio, ratio, INTER_LANCZOS4); resize(MatlistXZ[n], next_XZ, Size(), ratio, ratio, INTER_LANCZOS4); resize(MatlistYZ[n], next_YZ, Size(), ratio, ratio, INTER_LANCZOS4); // convert mat to vector TIs_XY[l][n] = MatToVec_16UTofloat(next_XY); TIs_XZ[l][n] = MatToVec_16UTofloat(next_XZ); TIs_YZ[l][n] = MatToVec_16UTofloat(next_YZ); //imwrite("L"+to_string(l)+".png", next_XY); } } } //------------ histogram equalization ----------------- Solid_Upper_noeq = Solid_Upper[MULTIRES - 1]; Pore_Lower_noeq = Pore_Lower[MULTIRES - 1]; if (DMtransformYN && HisEqYN) { cout << endl << "apply histogram equalization"; for (int l = MULTIRES - 1; l >= 0; --l) { equalizeHistograms(l, TIs_XY[l], TIs_XZ[l], TIs_YZ[l]); } } if (DMtransformYN) { computeporosityrequired(); } //------------ Analyze PCA,Pattern entropy,Generate DM TI ----------------- analyze(); //Mat temp = VecToMat_floatTo8U(TIs_XZ[MULTIRES - 1][MultiTIsNum-1], TIsize[MULTIRES - 1]); //tested:right //imwrite("eqL2.png", temp); _getch(); return true; } // ================ allocation ========== void DoPAR::allocateVectors() { //TIs, m_volume TIs_XY.resize(MULTIRES); TIs_XZ.resize(MULTIRES); TIs_YZ.resize(MULTIRES); for (int level = MULTIRES - 1; level >= 0; --level) { TIsize[level] = TIsize[MULTIRES - 1] / pow(2, MULTIRES - 1 - level); OUTsize[level] = OUTsize[MULTIRES - 1] / pow(2, MULTIRES - 1 - level); if (SIM2D_YN) m_volume[level].resize(OUTsize[level] * OUTsize[level]); else m_volume[level].resize(OUTsize[level] * OUTsize[level] * OUTsize[level]); TIs_XY[level].resize(MultiTIsNum); TIs_XZ[level].resize(MultiTIsNum); TIs_YZ[level].resize(MultiTIsNum); long ti2dsize = TIsize[level] * TIsize[level]; for (int i = 0; i < MultiTIsNum; i++) { TIs_XY[level][i].resize(ti2dsize, 0); TIs_XZ[level][i].resize(ti2dsize, 0); TIs_YZ[level][i].resize(ti2dsize, 0); } } //DMap Solid_Upper.resize(MULTIRES); Pore_Upper.resize(MULTIRES); Pore_Lower.resize(MULTIRES); porosity_required.resize(MULTIRES); //K-coherence isUnchanged_x.resize(MULTIRES); isUnchanged_y.resize(MULTIRES); isUnchanged_z.resize(MULTIRES); nearestIdx_x.resize(MULTIRES); nearestIdx_y.resize(MULTIRES); nearestIdx_z.resize(MULTIRES); nearestWeight_x.resize(MULTIRES); nearestWeight_y.resize(MULTIRES); nearestWeight_z.resize(MULTIRES); Origin_x.resize(MULTIRES); Origin_y.resize(MULTIRES); Origin_z.resize(MULTIRES); //Histogram IndexHis_x.resize(MULTIRES); IndexHis_y.resize(MULTIRES); IndexHis_z.resize(MULTIRES); PosHis.resize(MULTIRES); SelectedPos.resize(MULTIRES); avgIndexHis.resize(MULTIRES); avgPosHis.resize(MULTIRES); ColorHis_exemplar.resize(MULTIRES); ColorHis_synthesis.resize(MULTIRES); for (int level = 0; level < MULTIRES; ++level) { size_idx Soutput = OUTsize[level] * OUTsize[level] * OUTsize[level]; if (SIM2D_YN) Soutput = OUTsize[level] * OUTsize[level]; isUnchanged_x[level].assign(Soutput, false); isUnchanged_y[level].assign(Soutput, false); isUnchanged_z[level].assign(Soutput, false); nearestIdx_x[level].assign(Soutput, -1); nearestIdx_y[level].assign(Soutput, -1); nearestIdx_z[level].assign(Soutput, -1); nearestWeight_x[level].assign(Soutput, min_dist); nearestWeight_y[level].assign(Soutput, min_dist); nearestWeight_z[level].assign(Soutput, min_dist); Origin_x[level].assign(Soutput, -1); Origin_y[level].assign(Soutput, -1); Origin_z[level].assign(Soutput, -1); SelectedPos[level].assign(Soutput, -1); size_idx Sti = TIsize[level] * TIsize[level]; //PosHis size=3*TI PosHis[level].assign(Sti * 3, 0); //sparse grid IndexHis IndexHis_x[level].assign(Sti * 0.25, 0); IndexHis_y[level].assign(Sti * 0.25, 0); IndexHis_z[level].assign(Sti * 0.25, 0); } } bool DoPAR::loadVolume() { cout << endl << "Use Random initial."; InitRandomVolume(0); return true; } //randomly assign Origin & color void DoPAR::InitRandomVolume(int level) { size_idx OUTsize_ = OUTsize[level]; size_idx OUTsize2d_ = OUTsize_* OUTsize_; size_idx blockSize_ = blockSize[level]; size_idx TIsize_ = TIsize[level]; size_idx TIsize2d_ = TIsize_* TIsize_; size_idx Size = OUTsize2d_* OUTsize_; if (SIM2D_YN) Size = OUTsize2d_; uniform_int_distribution<> distr(0, (TIsize2d_ * MultiTIsNum) - 1); // define the range [a,b] vector<size_idx> randomidx2d_TIs(3), TIn(3), idx2d(3); for (size_idx xyz = 0; xyz < Size; ++xyz) { randomidx2d_TIs[0] = distr(mersennetwistergenerator); randomidx2d_TIs[1] = distr(mersennetwistergenerator); randomidx2d_TIs[2] = distr(mersennetwistergenerator); Origin_x[level][xyz] = randomidx2d_TIs[0]; isUnchanged_x[level][xyz] = false; TIn[0] = randomidx2d_TIs[0] / TIsize2d_; idx2d[0] = randomidx2d_TIs[0] % TIsize2d_; if (SIM2D_YN) m_volume[level][xyz] = TIs_XY[level][TIn[0]][idx2d[0]]; if (!SIM2D_YN) { Origin_y[level][xyz] = randomidx2d_TIs[1]; isUnchanged_y[level][xyz] = false; TIn[1] = randomidx2d_TIs[1] / TIsize2d_; idx2d[1] = randomidx2d_TIs[1] % TIsize2d_; Origin_z[level][xyz] = randomidx2d_TIs[2]; isUnchanged_z[level][xyz] = false; TIn[2] = randomidx2d_TIs[2] / TIsize2d_; idx2d[2] = randomidx2d_TIs[2] % TIsize2d_; m_volume[level][xyz] = round( (TIs_XY[level][TIn[0]][idx2d[0]] + TIs_XZ[level][TIn[1]][idx2d[1]] + TIs_YZ[level][TIn[2]][idx2d[2]]) / 3.0); } //if (Origin_x[level][xyz] >= MultiTIsNum*TIsize2d_ || Origin_y[level][xyz] >= MultiTIsNum*TIsize2d_ || Origin_z[level][xyz] >= MultiTIsNum*TIsize2d_) { // printf("origin %d %d %d", Origin_x[level][xyz], Origin_y[level][xyz], Origin_z[level][xyz]); //} } } // ============== distance map =============== void binaryChar(vector<short>& DMap, vector<char>& Binarised, short threshold = 110) { //input vector<short> DMap //output vector<char>Binarised for (long i = 0; i < DMap.size(); i++) { if (DMap[i] <= threshold) Binarised[i] = 0; else Binarised[i] = 1; } } void binaryUchar(vector<short>& DMap, vector<uchar>& Binarised, short threshold) { //input vector<short> DMap //output vector<uchar>Binarised for (long i = 0; i < DMap.size(); i++) { if (DMap[i] <= threshold) Binarised[i] = 0; else Binarised[i] = 255; } } void binaryUchar(vector<uchar>& model, short threshold) { for (size_idx i = 0; i < model.size(); i++) { if (model[i] <= threshold) model[i] = 0; else model[i] = 255; } } vector<unsigned short> BarDMap(short tSx, short tSy, short tSz, vector<char>& OImg) { //(1) tSx, tSy, tSz: 3 dimensions of image OImg // tSz = 1 - for a 2D image, otherwise tSz >=3 //(2) OImg is a binary image, <= 0 for solid, > 0 for pores int Sx(3), Sy(3), Sz(3), SizeXY, Size; if (tSx > 3) Sx = tSx; if (tSy > 3) Sy = tSy; if (tSz > 0) Sz = tSz; SizeXY = Sx*Sy; Size = SizeXY*Sz; vector<unsigned short> DMap; if (OImg.size() != Size) { cout << "Distance Transfromation Error: The size of original image is wrong !" << endl; cout << OImg.size() << " != " << Size << endl; cout << "Dimensions: (8) " << Sx << "x" << Sy << "x" << Sz << endl; return DMap; } vector<long> ForeIdxV(27, 0); vector<long> Gx(27, 0), G2x(27, 0), AbsGx(27, 0), AbsVal(27); vector<long> Gy(27, 0), G2y(27, 0), AbsGy(27, 0); vector<long> Gz(27, 0), G2z(29, 0), AbsGz(27, 0); //The difference of relative coordination of current voxel and its 26-neighbours { //Initialize constant parameters for (long CNum = 0, k = -1; k < 2; ++k) { for (long j = -1; j < 2; ++j) { for (long i = -1; i < 2; ++i) { Gx[CNum] = -i; G2x[CNum] = 2 * Gx[CNum]; Gy[CNum] = -j; G2y[CNum] = 2 * Gy[CNum]; Gz[CNum] = -k; G2z[CNum] = 2 * Gz[CNum]; AbsGx[CNum] = abs(Gx[CNum]); AbsGy[CNum] = abs(Gy[CNum]); AbsGz[CNum] = abs(Gz[CNum]); AbsVal[CNum] = AbsGx[CNum] + AbsGy[CNum] + AbsGz[CNum]; ForeIdxV[CNum++] = i + j*Sx + k*SizeXY; } } } } //Initialize constant parameters DMap.resize(Size, 0); unsigned short MaxDistV = 65500; { //Initialize DMap and clear up OImg for (long idx = 0; idx < Size; ++idx) if (OImg[idx] > 0) DMap[idx] = MaxDistV; } //Initialize DMap and clear up OImg vector<_XyzStrType> TgtImg(Size); //coordinates (x,y,z) ///@~@ short x, y, z, i, j, k, CNum; long idx, NIdx, CurVal; _XyzStrType TVal; TVal.x = 0; TVal.y = 0; TVal.z = 0; //cout<<" scanning forwards..."; for (idx = -1, z = 0; z < Sz; ++z) { //if (z % 100 == 0) cout << "*"; for (y = 0; y < Sy; ++y) { for (x = 0; x < Sx; ++x) { //if(++JCnt >= JStepNum) {JCnt=0; cout<<".";} if (DMap[++idx] < 1) { TgtImg[idx] = TVal; } else { for (CNum = -1, k = z - 1; k < z + 2; ++k) { if (k < 0 || k >= Sz) { CNum += 9; continue; } for (j = y - 1; j < y + 2; ++j) { if (j < 0 || j >= Sy) { CNum += 3; continue; } for (i = x - 1; i < x + 2; ++i) { ++CNum; if (i < 0 || i >= Sx) continue; if (CNum > 12) goto BarJump1; NIdx = idx + ForeIdxV[CNum]; if (DMap[NIdx] == MaxDistV) continue; CurVal = AbsVal[CNum] + G2x[CNum] * TgtImg[NIdx].x + G2y[CNum] * TgtImg[NIdx].y + G2z[CNum] * TgtImg[NIdx].z + DMap[NIdx]; if (CurVal < DMap[idx]) { DMap[idx] = CurVal; TgtImg[idx].x = TgtImg[NIdx].x + Gx[CNum]; TgtImg[idx].y = TgtImg[NIdx].y + Gy[CNum]; TgtImg[idx].z = TgtImg[NIdx].z + Gz[CNum]; } //if(CurVal < DMap[idx]) } } } BarJump1:; } } } } //cout<<" scanning backwards..."; for (idx = Size, z = Sz - 1; z >= 0; --z) { //if (z % 100 == 0) cout << "."; for (y = Sy - 1; y >= 0; --y) { for (x = Sx - 1; x >= 0; --x) { //if(++JCnt >= JStepNum) {JCnt=0; cout<<".";} if (DMap[--idx] <= 0) continue; for (CNum = 27, k = z + 1; k > z - 2; --k) { if (k < 0 || k >= Sz) { CNum -= 9; continue; } for (j = y + 1; j > y - 2; --j) { if (j < 0 || j >= Sy) { CNum -= 3; continue; } for (i = x + 1; i > x - 2; --i) { --CNum; if (i < 0 || i >= Sx) continue; if (CNum < 14) goto BarJump2; NIdx = idx + ForeIdxV[CNum]; CurVal = AbsVal[CNum] + G2x[CNum] * TgtImg[NIdx].x + G2y[CNum] * TgtImg[NIdx].y + G2z[CNum] * TgtImg[NIdx].z + DMap[NIdx]; if (CurVal < DMap[idx]) { DMap[idx] = CurVal; TgtImg[idx].x = TgtImg[NIdx].x + Gx[CNum]; TgtImg[idx].y = TgtImg[NIdx].y + Gy[CNum]; TgtImg[idx].z = TgtImg[NIdx].z + Gz[CNum]; } } } } BarJump2:; } } } return DMap; } vector<short> GetDMap(short Sx, short Sy, short Sz, vector<char>& OImg, char DM_Type, bool DisValYN) { ////(0) Sz = 1: for 2D image ////(1) OImg: <= 0 for solid, > 0 for pores ////(2) DM_Type = 0: for solid phase, //// DM_Type = 1: for pore phase, //// DM_Type = 2: for both solid and pore phase, ////(3) DisValYN: Reture type - distance value if DisValYN = ture, otherwise return sequence number //(TEXSIZE_, TEXSIZE_, 1, tempchar, 2, false) if (DM_Type != 0 && DM_Type != 1) DM_Type = 2; vector<short> DMap; if (DM_Type == 1 || DM_Type == 2) { vector<unsigned short> tDMap; tDMap = BarDMap(Sx, Sy, Sz, OImg); DMap.resize(tDMap.size(), 0); unsigned short MaxDis(1); for (long idx = 0; idx < tDMap.size(); ++idx) { if (tDMap[idx] < 1) continue; if (tDMap[idx] > 32760L) DMap[idx] = 32761L; else DMap[idx] = tDMap[idx]; if (DMap[idx] > MaxDis) MaxDis = DMap[idx]; } tDMap.clear(); if (!DisValYN) { vector<bool> UsedYN(MaxDis + 1, false); for (long idx = 0; idx < DMap.size(); ++idx) { if (DMap[idx] > 0) { UsedYN[DMap[idx]] = true; } } vector<long> DisSeq(MaxDis + 1, -1); long ID(0); for (long ij = 1; ij < UsedYN.size(); ++ij) { if (UsedYN[ij]) DisSeq[ij] = ++ID; } for (long idx = 0; idx < DMap.size(); ++idx) { if (DMap[idx] > 0) { DMap[idx] = DisSeq[DMap[idx]]; } } } }//DM_Type == 1 || DM_Type == 2 if (DM_Type == 0 || DM_Type == 2) { vector<char> OD; OD.resize(OImg.size(), 0); for (long idx = 0; idx < OImg.size(); ++idx) { if (OImg[idx] <= 0) { OD[idx] = 1; } } vector<unsigned short> tDMap; tDMap = BarDMap(Sx, Sy, Sz, OD); if (DMap.size() == 0) { DMap.resize(tDMap.size(), 0); } unsigned short MaxDis(1); for (long idx = 0; idx < tDMap.size(); ++idx) { if (tDMap[idx] < 1) continue; if (tDMap[idx] > 32760L) DMap[idx] = -32761L; else DMap[idx] = -1L * tDMap[idx]; if (-DMap[idx] > MaxDis) MaxDis = -DMap[idx]; } tDMap.clear(); if (!DisValYN) { vector<bool> UsedYN(MaxDis + 1, false); for (long idx = 0; idx < DMap.size(); ++idx) { if (DMap[idx] < 0) { UsedYN[-DMap[idx]] = true; } } vector<long> DisSeq(MaxDis + 1, -1); long ID(0); for (long ij = 1; ij < UsedYN.size(); ++ij) { if (UsedYN[ij]) DisSeq[ij] = ++ID; } for (long idx = 0; idx < DMap.size(); ++idx) { if (DMap[idx] < 0) { DMap[idx] = -DisSeq[-DMap[idx]]; } } } }//DM_Type == 1 || DM_Type == 2 //if (true){//get Euclidean distance instead of squared distance // for (long idx = 0; idx < DMap.size(); ++idx) { // DMap[idx] = (DMap[idx] / abs(DMap[idx])) * round(sqrt(abs(DMap[idx]))); // } //} return DMap; } vector<short> DoPAR::GetDMap_Euclidean(vector<float>& vect, short dimension) { assert(vect.size() == dimension*dimension); vector<short> vecshort(vect.begin(), vect.end()); vector<char> vecchar(vect.size()); binaryChar(vecshort, vecchar); vecshort = GetDMap(dimension, dimension, 1, vecchar, 2, true); if (PrintDMYN) {// Print DM_pore, DM_solid vector<short> tempshort; tempshort = GetDMap(dimension, dimension, 1, vecchar, 1, true); vector<unsigned short> DM_p(tempshort.begin(), tempshort.end()); tempshort = GetDMap(dimension, dimension, 1, vecchar, 0, true); transform(tempshort.begin(), tempshort.end(), tempshort.begin(), std::bind2nd(std::multiplies<short>(), -1)); vector<unsigned short> DM_s(tempshort.begin(), tempshort.end()); Mat Mat_DM_p, Mat_DM_s; Mat_DM_p = Mat(dimension, dimension, CV_16UC1); Mat_DM_s = Mat(dimension, dimension, CV_16UC1); Mat_DM_p = Mat(DM_p, true).reshape(1, Mat_DM_p.rows); // vector to mat, need the same data type! Mat_DM_s = Mat(DM_s, true).reshape(1, Mat_DM_s.rows); string tempfn = FNameXY[0].substr(0, FNameXY[0].rfind('.') == string::npos ? FNameXY[0].length() : FNameXY[0].rfind('.')); string name_p = tempfn + "_DM_p.png", name_s = tempfn + "_DM_s.png"; while (fileExists(name_p) == false) { imwrite(name_p, Mat_DM_p); } while (fileExists(name_s) == false) { imwrite(name_s, Mat_DM_s); } } return vecshort; } void DoPAR::transformDMs(vector<vector<size_color> >& listXY, vector<vector<size_color> >& listXZ, vector<vector<size_color> >& listYZ) { //input lists of vector<size_color>, output DM transformed lists of vector<size_color> int TIsize_ = sqrt(listXY[0].size()); assert(TIsize_ == TIsize[MULTIRES - 1]); vector<vector<short> > DMlist_XY(listXY.size()), DMlist_XZ(listXZ.size()), DMlist_YZ(listYZ.size()); short minall(65534), maxall(0), min_XY(65534), min_XZ(65534), min_YZ(65534), max_XY(0), max_XZ(0), max_YZ(0); // get vector<short>DM for (int i = 0; i < MultiTIsNum; i++) { //!changed, not euclidean, still squared distance DMlist_XY[i] = GetDMap_Euclidean(listXY[i], TIsize_); DMlist_XZ[i] = GetDMap_Euclidean(listXZ[i], TIsize_); DMlist_YZ[i] = GetDMap_Euclidean(listYZ[i], TIsize_); // get min, max min_XY = min(min_XY, *min_element(DMlist_XY[i].begin(), DMlist_XY[i].end())); max_XY = max(max_XY, *max_element(DMlist_XY[i].begin(), DMlist_XY[i].end())); min_XZ = min(min_XZ, *min_element(DMlist_XZ[i].begin(), DMlist_XZ[i].end())); max_XZ = max(max_XZ, *max_element(DMlist_XZ[i].begin(), DMlist_XZ[i].end())); min_YZ = min(min_YZ, *min_element(DMlist_YZ[i].begin(), DMlist_YZ[i].end())); max_YZ = max(max_YZ, *max_element(DMlist_YZ[i].begin(), DMlist_YZ[i].end())); } // calculate DM range if (!HisEqYN) { minall = max(min_XY, max(min_XZ, min_YZ)); maxall = min(max_XY, min(max_XZ, max_YZ)); } else { minall = min(min_XY, min(min_XZ, min_YZ)); maxall = max(max_XY, max(max_XZ, max_YZ)); } cout << endl << "DM value range: " << minall << " to " << maxall; double scale = 1.0; // shift short to 0-255 and assign to size_color //if (maxall - minall > 255) { // cout << endl << "resize value range to 0-255!"; // scale = 255.0 / (maxall - minall); //} for (int n = 0; n < MultiTIsNum; n++) { for (long i = 0; i < TIsize_*TIsize_; i++) { if (DMlist_XY[n][i] < 0) DMlist_XY[n][i] = scale * (max(0, DMlist_XY[n][i] - minall) + 1); else DMlist_XY[n][i] = scale * (min(DMlist_XY[n][i] - minall, maxall - minall)); if (DMlist_XZ[n][i] < 0) DMlist_XZ[n][i] = scale * (max(0, DMlist_XZ[n][i] - minall) + 1); else DMlist_XZ[n][i] = scale * (min(DMlist_XZ[n][i] - minall, maxall - minall)); if (DMlist_YZ[n][i] < 0) DMlist_YZ[n][i] = scale * (max(0, DMlist_YZ[n][i] - minall) + 1); else DMlist_YZ[n][i] = scale * (min(DMlist_YZ[n][i] - minall, maxall - minall)); } // convert vector<short> to vector<size_color> listXY[n] = vector<size_color>(DMlist_XY[n].begin(), DMlist_XY[n].end()); listXZ[n] = vector<size_color>(DMlist_XZ[n].begin(), DMlist_XZ[n].end()); listYZ[n] = vector<size_color>(DMlist_YZ[n].begin(), DMlist_YZ[n].end()); } // update Solid_Upper[MULTIRES-1] = -minall * scale; Pore_Upper[MULTIRES - 1] = (maxall - minall) * scale; //total bins Pore_Lower[MULTIRES - 1] = Solid_Upper[MULTIRES - 1] + 1; printf("\nSolid_Upper= %d,Pore_Upper= %d,Pore_Lower= %d", Solid_Upper[MULTIRES - 1], Pore_Upper[MULTIRES - 1], Pore_Lower[MULTIRES - 1]); // print DM_combined if (PrintDMYN) { vector<unsigned short> DM_c(DMlist_XY[0].begin(), DMlist_XY[0].end()); Mat Mat_DM_c = Mat(TIsize_, TIsize_, CV_16UC1); Mat_DM_c = Mat(DM_c, true).reshape(1, Mat_DM_c.rows); string tempfn = FNameXY[0].substr(0, FNameXY[0].rfind('.') == string::npos ? FNameXY[0].length() : FNameXY[0].rfind('.')); string name_c = tempfn + "_DM_c.png"; while (fileExists(name_c) == false) { imwrite(name_c, Mat_DM_c); } } } void DoPAR::invertpaddingDMtransform(vector<Mat>& XY, vector<Mat>& XZ, vector<Mat>& YZ, vector<vector<size_color> >& TIsXY, vector<vector<size_color> >& TIsXZ, vector<vector<size_color> >& TIsYZ) { // input Mat lists; output invert padded DM transformed vector lists vector<vector<size_color> > paddedTIs_x(MultiTIsNum), paddedTIs_y(MultiTIsNum), paddedTIs_z(MultiTIsNum); int dimension = XY[0].cols; int padded_TIsize = dimension + 2; //--------- add invert padding border to vector lists for (int n = 0; n < MultiTIsNum; n++) { copyMakeBorder(XY[n], XY[n], 1, 1, 1, 1, BORDER_REPLICATE); copyMakeBorder(XZ[n], XZ[n], 1, 1, 1, 1, BORDER_REPLICATE); copyMakeBorder(YZ[n], YZ[n], 1, 1, 1, 1, BORDER_REPLICATE); // mat to vector paddedTIs_x[n].resize(padded_TIsize*padded_TIsize); paddedTIs_y[n].resize(padded_TIsize*padded_TIsize); paddedTIs_z[n].resize(padded_TIsize*padded_TIsize); paddedTIs_x[n] = MatToVec_8UTofloat(XY[n]); paddedTIs_y[n] = MatToVec_8UTofloat(XZ[n]); paddedTIs_z[n] = MatToVec_8UTofloat(YZ[n]); // invert border for (int x = 0; x < padded_TIsize; x++) { int idx1 = x, idx2 = (padded_TIsize - 1)*padded_TIsize + x; paddedTIs_x[n][idx1] = (255 - paddedTIs_x[n][idx1]); paddedTIs_x[n][idx2] = (255 - paddedTIs_x[n][idx2]); paddedTIs_y[n][idx1] = (255 - paddedTIs_y[n][idx1]); paddedTIs_y[n][idx2] = (255 - paddedTIs_y[n][idx2]); paddedTIs_z[n][idx1] = (255 - paddedTIs_z[n][idx1]); paddedTIs_z[n][idx2] = (255 - paddedTIs_z[n][idx2]); } for (int y = 0; y < padded_TIsize; y++) { int idx1 = y*padded_TIsize, idx2 = (padded_TIsize - 1) + y*padded_TIsize; paddedTIs_x[n][idx1] = (255 - paddedTIs_x[n][idx1]); paddedTIs_x[n][idx2] = (255 - paddedTIs_x[n][idx2]); paddedTIs_y[n][idx1] = (255 - paddedTIs_y[n][idx1]); paddedTIs_y[n][idx2] = (255 - paddedTIs_y[n][idx2]); paddedTIs_z[n][idx1] = (255 - paddedTIs_z[n][idx1]); paddedTIs_z[n][idx2] = (255 - paddedTIs_z[n][idx2]); } } //---------- Distance map transformation if (DMtransformYN) transformDMs(paddedTIs_x, paddedTIs_y, paddedTIs_z); //cout << endl << " max_element= " << *max_element(paddedTIs_x[0].begin(), paddedTIs_x[0].end()); _getch(); //---------- vector to Mat, then crop, then Mat to vector again Mat tempmat, tempcropped; for (int n = 0; n < MultiTIsNum; n++) { // vector to Mat, need the same data type! tempmat = VecToMat_floatTo16U(paddedTIs_x[n], padded_TIsize); // crop Mat tempcropped = tempmat(Rect(1, 1, dimension, dimension)); tempcropped.copyTo(XY[n]); // Mat to vector TIsXY[n] = MatToVec_16UTofloat(XY[n]); //cout << endl << " max_element= " << *max_element(TIsXY[n].begin(), TIsXY[n].end()); _getch(); //XZ tempmat = VecToMat_floatTo16U(paddedTIs_y[n], padded_TIsize); tempcropped = tempmat(Rect(1, 1, dimension, dimension)); tempcropped.copyTo(XZ[n]); TIsXZ[n] = MatToVec_16UTofloat(XZ[n]); //YZ tempmat = VecToMat_floatTo16U(paddedTIs_z[n], padded_TIsize); tempcropped = tempmat(Rect(1, 1, dimension, dimension)); tempcropped.copyTo(YZ[n]); TIsYZ[n] = MatToVec_16UTofloat(YZ[n]); } //imwrite("16U.png", XY[0]); _getch(); } void DoPAR::equalizeHistograms(int level, vector<vector<size_color>>& TI_XY, vector<vector<size_color>>& TI_XZ, vector<vector<size_color>>& TI_YZ) { long TI2dsize = TI_XY[0].size(), total = TI2dsize *MultiTIsNum; if (!SIM2D_YN) total *=3; // Compute accumulate histogram unsigned short maxv(0); vector<long> hist; for (int n = 0; n < MultiTIsNum; n++) { maxv = (unsigned short)*max_element(TI_XY[n].begin(), TI_XY[n].end()); if (!SIM2D_YN) maxv = max(maxv, (unsigned short)max(*max_element(TI_XZ[n].begin(), TI_XZ[n].end()), *max_element(TI_YZ[n].begin(), TI_YZ[n].end()))); hist.resize(maxv+1, 0); for (long i = 0; i < TI2dsize; ++i) { hist[TI_XY[n][i]]++; if (SIM2D_YN) continue; hist[TI_XZ[n][i]]++; hist[TI_YZ[n][i]]++; } } // Compute scale //int n_bins = maxv + 1; cout<< endl << "level=" <<level <<" maxv= " << maxv; double scale; scale = min(255.0, maxv*1.0) / total; Pore_Upper[level] = min((short)255, (short)maxv); // Build LUT from accumulate histrogram vector<short> lut(maxv+1, 0); long sum = 0; for (int i = 0; i <= maxv; ++i) { sum += hist[i]; //round((sum - hist[0])/(total-hist[0])*(bins-1)); //here hist[0]=0 lut[i] = min(Pore_Upper[level], (short)round(sum * scale)); // the value is saturated in range [0, max_val] } // equalization without press for (int n = 0; n < MultiTIsNum; n++) { for (long i = 0; i < TI2dsize; ++i) { TI_XY[n][i] = lut[TI_XY[n][i]]; if (SIM2D_YN) continue; TI_XZ[n][i] = lut[TI_XZ[n][i]]; TI_YZ[n][i] = lut[TI_YZ[n][i]]; } } // update Solid_Upper[level] = lut[Solid_Upper_noeq]; Pore_Lower[level] = lut[Pore_Lower_noeq]; // Print DM_equalized if (PrintDMYN) { vector<unsigned short> DM_eq(TI_XY[0].begin(), TI_XY[0].end()); Mat Mat_DM_eq = Mat(TIsize[level], TIsize[level], CV_16UC1); Mat_DM_eq = Mat(DM_eq, true).reshape(1, Mat_DM_eq.rows); string tempfn = FNameXY[0].substr(0, FNameXY[0].rfind('.') == string::npos ? FNameXY[0].length() : FNameXY[0].rfind('.')); string name_eq = tempfn + "_DM_eq.png"; while (fileExists(name_eq) == false) { imwrite(name_eq, Mat_DM_eq); } } } // ================ analysis =========== void DoPAR::computeporosityrequired() { for (int l = MULTIRES - 1; l >= 0; --l) { long porecount(0); auto solidup = Solid_Upper[MULTIRES - 1]; for (int n = 0; n < MultiTIsNum; n++) { porecount += count_if(TIs_XY[l][n].begin(), TIs_XY[l][n].end(), [solidup](short i) {return i> solidup; }); if (!SIM2D_YN) { porecount += count_if(TIs_XZ[l][n].begin(), TIs_XZ[l][n].end(), [solidup](short i) {return i> solidup; }); porecount += count_if(TIs_YZ[l][n].begin(), TIs_YZ[l][n].end(), [solidup](short i) {return i> solidup; }); } } if (SIM2D_YN) porosity_required[l] = porecount*1.0f / (TIs_XY[l][0].size()); else porosity_required[l] = porecount*1.0f / (3 * TIs_XY[l][0].size()); if (HisEqYN || l == MULTIRES - 1) cout << endl << "level" << l << " Solid_Upper=" << (int)Solid_Upper[l] << " Pore_Lower=" << (int)Pore_Lower[l] << " porosity=" << porosity_required[l]; } } void DoPAR::analyze() { //if (PrintDMYN) testPCA(); if (PatternEntropyAnalysisYN) { //double entropy; //if (!DMtransformYN) cout << endl << "noDM:"; //else cout << endl << "DM:"; //for (int templatesize = 4; templatesize < 34; templatesize += 2) { // if (!DMtransformYN) { // patternentropyanalysis(templatesize, matyz, entropy); // } // else { // Mat DM1; // if (HisEqYN) { //DM 8UC1, uchar // vector<uchar> tmpchar; // DM1 = Mat(TIsize[MULTIRES - 1], TIsize[MULTIRES - 1], CV_8UC1); // tmpchar = vector<uchar>(m_exemplar_x[MULTIRES - 1].begin(), m_exemplar_x[MULTIRES - 1].end()); // DM1 = Mat(tmpchar, true).reshape(1, DM1.rows); // } // else { //DM 32FC1, float. matchTemplate only accept 8U or 32F // vector<float> tempfloat; // DM1 = Mat(TIsize[MULTIRES - 1], TIsize[MULTIRES - 1], CV_32FC1); // tempfloat = vector<float>(m_exemplar_x[MULTIRES - 1].begin(), m_exemplar_x[MULTIRES - 1].end()); // DM1 = Mat(tempfloat, true).reshape(1, DM1.rows); // } // patternentropyanalysis(templatesize, DM1, entropy); // } //} //_getch(); } } void DoPAR::patternentropyanalysis(int templatesize, Mat &exemplar, double &entropy) { //compute pattern entropy for given template,TI int Width = exemplar.cols; int Height = exemplar.rows; //initial Mat countmask = Mat::zeros(Height - templatesize + 1, Width - templatesize + 1, CV_8UC1); vector<long> patterncount, patternloc; patterncount.reserve((Width - templatesize)*(Height - templatesize)); patternloc.reserve((Width - templatesize)*(Height - templatesize)); long totalcount(0); entropy = 0; float threshval = 4.0f; //build pattern database for (int y = 0; y < Height - templatesize + 1; y++) { //if (y % (Height / 10) == 0)cout << "."; #pragma omp parallel for schedule(static) for (int x = 0; x < Width - templatesize + 1; x++) { //skip if (countmask.at<uchar>(y, x) != 0) continue; //template matching Mat matchdst; //32-bit, (H-h+1, W-w+1) Mat tempmat = exemplar(Rect(x, y, templatesize, templatesize)); matchTemplate(exemplar, tempmat, matchdst, TM_SQDIFF); //build database Mat dstmask; long tempcount; if (matchdst.at<float>(y, x) < -threshval || matchdst.at<float>(y, x) > threshval) { threshval = abs(matchdst.at<float>(y, x)); } inRange(matchdst, -threshval, threshval, dstmask); //dstmask 255&0 tempcount = countNonZero(dstmask); #pragma omp critical (patternanalysis) { //check again, due to OpenMP if (countmask.at<uchar>(y, x) == 0) { patterncount.push_back(tempcount); patternloc.push_back(y*Width + x); totalcount += tempcount; countmask.setTo(1, dstmask); } } } //#pragma omp parallel for schedule(static) } if (patterncount.size() != patternloc.size()) { cout << endl << "error:patterncount.size!=patternloc.size"; _getch(); exit(0); } long tempsize = (Height - templatesize + 1)*(Width - templatesize + 1); Mat tempmat; inRange(countmask, 2, tempsize, tempmat); if (countNonZero(tempmat)>0) { cout << endl << "error:countmask has >1:" << countNonZero(tempmat); } if (countNonZero(countmask)< tempsize) { cout << endl << "error:countmask has 0: " << tempsize - countNonZero(countmask); } //compute entropy for (int i = 0; i < patterncount.size(); i++) { double pi = patterncount[i] * 1.0 / totalcount; entropy -= pi * log(pi); } cout << endl << "template:" << templatesize << " entropy= " << entropy << " pattern count= " << patterncount.size(); } //void DoPAR::testPCA() { // //test PCA TI and back-project // int level = MULTIRES - 1; // const int TIsize_ = TIsize[level]; // int N = 5; //11*11,256->246 // int D_NEIGHBOR = (1 + 2 * N)*(1 + 2 * N); // double PCA_RATIO_VARIANCE = 0.99; // // cout << endl << "input PCA_RATIO:"; // cin >> PCA_RATIO_VARIANCE; // if (PCA_RATIO_VARIANCE>1.0) { cout << endl << "wrong value, use 99%"; PCA_RATIO_VARIANCE = 0.99; } // if (PCA_RATIO_VARIANCE <= 0) { cout << endl << "no PCA"; return; } // int MINDIMS = 2; // int MAXDIMS = 20; // cout << endl << "input MINDIMS, MAXDIMS:"; // cin >> MINDIMS >> MAXDIMS; // if (MINDIMS < 2) { cout << endl << "MINDIMS<2, use 2"; MINDIMS = 2; } // if (MAXDIMS > D_NEIGHBOR) { cout << endl << "MINDIMS<D_NEIGHBOR, use D_NEIGHBOR"; MAXDIMS = D_NEIGHBOR; } // // // int sizeneighbor = D_NEIGHBOR * (TIsize_ - 2 * N) * (TIsize_ - 2 * N); // vector<size_color> m_neighbor_x(sizeneighbor, 0), m_neighbor_y(sizeneighbor, 0), m_neighbor_z(sizeneighbor, 0); // CvMat* mp_neighbor_pca_average_x(NULL); CvMat* mp_neighbor_pca_average_y(NULL); CvMat* mp_neighbor_pca_average_z(NULL); // CvMat* mp_neighbor_pca_projected_x(NULL); CvMat* mp_neighbor_pca_projected_y(NULL); CvMat* mp_neighbor_pca_projected_z(NULL); // CvMat* mp_neighbor_pca_eigenvec_x(NULL); CvMat* mp_neighbor_pca_eigenvec_y(NULL); CvMat* mp_neighbor_pca_eigenvec_z(NULL); // // int numData = (TIsize_ - 2 * N) * (TIsize_ - 2 * N); // CvMat* p_source_x = cvCreateMat(numData, D_NEIGHBOR, CV_32F); //rows='area' numData, cols=dimension (Neighbour size) // CvMat* p_source_y = cvCreateMat(numData, D_NEIGHBOR, CV_32F); // CvMat* p_source_z = cvCreateMat(numData, D_NEIGHBOR, CV_32F); // int row = 0; // for (int v = N; v < TIsize_ - N; ++v) { // for (int u = N; u < TIsize_ - N; ++u) { // int col = 0; // for (int dv = -N; dv <= N; ++dv) { // for (int du = -N; du <= N; ++du) { // ANNidx index = (TIsize_ * (v + dv) + u + du); // cvmSet(p_source_x, row, col, m_exemplar_x[level][index]); //set p_source_x(row,col) to m_examplar_x(idx) // cvmSet(p_source_y, row, col, m_exemplar_y[level][index]); // cvmSet(p_source_z, row, col, m_exemplar_z[level][index]); // // m_neighbor_x[D_NEIGHBOR * row + col] = m_exemplar_x[level][index]; // m_neighbor_y[D_NEIGHBOR * row + col] = m_exemplar_y[level][index]; // m_neighbor_z[D_NEIGHBOR * row + col] = m_exemplar_z[level][index]; // ++col; // } // } // ++row; // } // } // // // PCA calculation (obtain all eigenvectors of the input covariance matrix) // ////////每一行表示一个样本 // //////CvMat* pData = cvCreateMat( 总的样本数, 每个样本的维数, CV_32FC1 ); // if (mp_neighbor_pca_average_x != NULL) cvReleaseMat(&mp_neighbor_pca_average_x); // if (mp_neighbor_pca_average_y != NULL) cvReleaseMat(&mp_neighbor_pca_average_y); // if (mp_neighbor_pca_average_z != NULL) cvReleaseMat(&mp_neighbor_pca_average_z); // //CvMat* pMean = cvCreateMat(1, 样本的维数, CV_32FC1); // mp_neighbor_pca_average_x = cvCreateMat(1, D_NEIGHBOR, CV_32F); // mp_neighbor_pca_average_y = cvCreateMat(1, D_NEIGHBOR, CV_32F); // mp_neighbor_pca_average_z = cvCreateMat(1, D_NEIGHBOR, CV_32F); // //pEigVals中的每个数表示一个特征值 // //CvMat* pEigVals = cvCreateMat(1, min(总的样本数,样本的维数), CV_32FC1); // CvMat* p_eigenValues_x = cvCreateMat(1, D_NEIGHBOR, CV_32F); // CvMat* p_eigenValues_y = cvCreateMat(1, D_NEIGHBOR, CV_32F); // CvMat* p_eigenValues_z = cvCreateMat(1, D_NEIGHBOR, CV_32F); // //每一行表示一个特征向量 // //CvMat* pEigVecs = cvCreateMat( min(总的样本数,样本的维数), 样本的维数, CV_32FC1); // CvMat* p_eigenVectors_all_x = cvCreateMat(D_NEIGHBOR, D_NEIGHBOR, CV_32F); // CvMat* p_eigenVectors_all_y = cvCreateMat(D_NEIGHBOR, D_NEIGHBOR, CV_32F); // CvMat* p_eigenVectors_all_z = cvCreateMat(D_NEIGHBOR, D_NEIGHBOR, CV_32F); // //PCA处理,计算出平均向量pMean,特征值pEigVals和特征向量pEigVecs // //cvCalcPCA(pData, pMean, pEigVals, pEigVecs, CV_PCA_DATA_AS_ROW); // //now have better function //PCA pca(data, mean, PCA::DATA_AS_ROW, 0.95); // cvCalcPCA(p_source_x, mp_neighbor_pca_average_x, p_eigenValues_x, p_eigenVectors_all_x, CV_PCA_DATA_AS_ROW); // cvCalcPCA(p_source_y, mp_neighbor_pca_average_y, p_eigenValues_y, p_eigenVectors_all_y, CV_PCA_DATA_AS_ROW); // cvCalcPCA(p_source_z, mp_neighbor_pca_average_z, p_eigenValues_z, p_eigenVectors_all_z, CV_PCA_DATA_AS_ROW); // // Decide amount of dimensionality reduction // double contribution_total_x = 0; // double contribution_total_y = 0; // double contribution_total_z = 0; // for (int i = 0; i < D_NEIGHBOR; ++i) { // contribution_total_x += cvmGet(p_eigenValues_x, 0, i); // contribution_total_y += cvmGet(p_eigenValues_y, 0, i); // contribution_total_z += cvmGet(p_eigenValues_z, 0, i); // } // // int dimPCA_x = 0; // int dimPCA_y = 0; // int dimPCA_z = 0; // // double contribution_acc_x = 0; // double contribution_acc_y = 0; // double contribution_acc_z = 0; // for (int i = 0; i < D_NEIGHBOR; ++i) { // double ratio_x = contribution_acc_x / contribution_total_x; // double ratio_y = contribution_acc_y / contribution_total_y; // double ratio_z = contribution_acc_z / contribution_total_z; // if (ratio_x < PCA_RATIO_VARIANCE || dimPCA_x < MINDIMS) { // contribution_acc_x += cvmGet(p_eigenValues_x, 0, i); // ++dimPCA_x; // } // if (ratio_y < PCA_RATIO_VARIANCE) { // contribution_acc_y += cvmGet(p_eigenValues_y, 0, i); // ++dimPCA_y; // } // if (ratio_z < PCA_RATIO_VARIANCE) { // contribution_acc_z += cvmGet(p_eigenValues_z, 0, i); // ++dimPCA_z; // } // if (PCA_RATIO_VARIANCE <= ratio_x && PCA_RATIO_VARIANCE <= ratio_y && PCA_RATIO_VARIANCE <= ratio_z // && dimPCA_x >= MINDIMS) break; // if (dimPCA_x >= MAXDIMS) break; // } // // cout << endl; // printf("PCA reduction (x): %d -> %d\n", D_NEIGHBOR, dimPCA_x); // printf("PCA reduction (y): %d -> %d\n", D_NEIGHBOR, dimPCA_y); // printf("PCA reduction (z): %d -> %d\n", D_NEIGHBOR, dimPCA_z); // // // // Trim total eigenvectors into partial eigenvectors // if (mp_neighbor_pca_eigenvec_x != NULL) cvReleaseMat(&mp_neighbor_pca_eigenvec_x); // if (mp_neighbor_pca_eigenvec_y != NULL) cvReleaseMat(&mp_neighbor_pca_eigenvec_y); // if (mp_neighbor_pca_eigenvec_z != NULL) cvReleaseMat(&mp_neighbor_pca_eigenvec_z); // mp_neighbor_pca_eigenvec_x = cvCreateMat(dimPCA_x, D_NEIGHBOR, CV_32F); // mp_neighbor_pca_eigenvec_y = cvCreateMat(dimPCA_y, D_NEIGHBOR, CV_32F); // mp_neighbor_pca_eigenvec_z = cvCreateMat(dimPCA_z, D_NEIGHBOR, CV_32F); // memcpy(mp_neighbor_pca_eigenvec_x->data.fl, p_eigenVectors_all_x->data.fl, sizeof(ANNcoord)* dimPCA_x * D_NEIGHBOR); // memcpy(mp_neighbor_pca_eigenvec_y->data.fl, p_eigenVectors_all_y->data.fl, sizeof(ANNcoord)* dimPCA_y * D_NEIGHBOR); // memcpy(mp_neighbor_pca_eigenvec_z->data.fl, p_eigenVectors_all_z->data.fl, sizeof(ANNcoord)* dimPCA_z * D_NEIGHBOR); // // PCA projection // //CvMat* pResult = cvCreateMat( 总的样本数, PCA变换后的样本维数(即主成份的数目)?, CV_32FC1 ); // if (mp_neighbor_pca_projected_x != NULL) cvReleaseMat(&mp_neighbor_pca_projected_x); // if (mp_neighbor_pca_projected_y != NULL) cvReleaseMat(&mp_neighbor_pca_projected_y); // if (mp_neighbor_pca_projected_z != NULL) cvReleaseMat(&mp_neighbor_pca_projected_z); // //选出前P个特征向量(主成份),然后投影,结果保存在pResult中,pResult中包含了P个系数 // //CvMat* pResult = cvCreateMat( 总的样本数, PCA变换后的样本维数(即主成份的数目)?, CV_32FC1 ); // mp_neighbor_pca_projected_x = cvCreateMat(numData, dimPCA_x, CV_32F); // mp_neighbor_pca_projected_y = cvCreateMat(numData, dimPCA_y, CV_32F); // mp_neighbor_pca_projected_z = cvCreateMat(numData, dimPCA_z, CV_32F); // //cvProjectPCA( pData, pMean, pEigVecs, pResult ); // cvProjectPCA(p_source_x, mp_neighbor_pca_average_x, mp_neighbor_pca_eigenvec_x, mp_neighbor_pca_projected_x); // cvProjectPCA(p_source_y, mp_neighbor_pca_average_y, mp_neighbor_pca_eigenvec_y, mp_neighbor_pca_projected_y); // cvProjectPCA(p_source_z, mp_neighbor_pca_average_z, mp_neighbor_pca_eigenvec_z, mp_neighbor_pca_projected_z); // // //============ TEST TI PCA backproject result // if (true) { // CvMat* backproject_x = cvCreateMat(numData, D_NEIGHBOR, CV_32F); // cvBackProjectPCA(mp_neighbor_pca_projected_x, mp_neighbor_pca_average_x, mp_neighbor_pca_eigenvec_x, backproject_x); // Mat backprojectMat_x = cvarrToMat(backproject_x); // Mat PCAbackprojectDM1 = Mat(TIsize_ - 2 * N, TIsize_ - 2 * N, CV_8UC1); // // CvMat* backproject_y = cvCreateMat(numData, D_NEIGHBOR, CV_32F); // cvBackProjectPCA(mp_neighbor_pca_projected_y, mp_neighbor_pca_average_y, mp_neighbor_pca_eigenvec_y, backproject_y); // Mat backprojectMat_y = cvarrToMat(backproject_y); // Mat PCAbackprojectDM2 = Mat(TIsize_ - 2 * N, TIsize_ - 2 * N, CV_8UC1); // // CvMat* backproject_z = cvCreateMat(numData, D_NEIGHBOR, CV_32F); // cvBackProjectPCA(mp_neighbor_pca_projected_z, mp_neighbor_pca_average_z, mp_neighbor_pca_eigenvec_z, backproject_z); // Mat backprojectMat_z = cvarrToMat(backproject_z); // Mat PCAbackprojectDM3 = Mat(TIsize_ - 2 * N, TIsize_ - 2 * N, CV_8UC1); // // int row = 0; // int cols = ((2 * N + 1)*(2 * N + 1) - 1) * 0.5; // // for (int v = 0; v < TIsize_ - 2 * N; ++v) { // for (int u = 0; u < TIsize_ - 2 * N; ++u) { // int tempv = backprojectMat_x.at<ANNcoord>(row, cols); // if (tempv < 0) tempv = 0; else if (tempv > 255) tempv = 255; // PCAbackprojectDM1.at<uchar>(v, u) = tempv; // // tempv = backprojectMat_y.at<ANNcoord>(row, cols); // if (tempv < 0) tempv = 0; else if (tempv > 255) tempv = 255; // PCAbackprojectDM2.at<uchar>(v, u) = tempv; // // tempv = backprojectMat_z.at<ANNcoord>(row, cols); // if (tempv < 0) tempv = 0; else if (tempv > 255) tempv = 255; // PCAbackprojectDM3.at<uchar>(v, u) = tempv; // // ++row; // } // } // // imwrite("PCA_TI1.png", PCAbackprojectDM1); // if (!(FNameXY == FNameXZ && FNameXY == FNameYZ)) imwrite("PCA_TI2.png", PCAbackprojectDM2); // if (!(FNameXY == FNameXZ && FNameXY == FNameYZ)) imwrite("PCA_TI3.png", PCAbackprojectDM3); // cvReleaseMat(&backproject_x); // cvReleaseMat(&backproject_y); // cvReleaseMat(&backproject_z); // cout << endl << "PCA back projected image outputed."; // } // // // release CV matrices // cvReleaseMat(&p_source_x); // cvReleaseMat(&p_source_y); // cvReleaseMat(&p_source_z); // cvReleaseMat(&p_eigenValues_x); // cvReleaseMat(&p_eigenValues_y); // cvReleaseMat(&p_eigenValues_z); // cvReleaseMat(&p_eigenVectors_all_x); // cvReleaseMat(&p_eigenVectors_all_y); // cvReleaseMat(&p_eigenVectors_all_z); //} // =========== main procedures ============= void DoPAR::init() { // load TI if (!loadExemplar()) return; // init ColorHis if (ColorHis_ON) initColorHis_exemplar(); colorweight.resize(MULTIRES); indexweight.resize(MULTIRES); posweight.resize(MULTIRES); for (int i = 0; i < MULTIRES; i++) { // colorweight colorweight[i] = factorC / (OUTsize[i] * OUTsize[i] * OUTsize[i] / ColorHis_BinNum); //colorweight[i] = factorC * 1.0f; // indexweight, posweight //~TI_ avgIndexHis[i] = ceil((1.0f * OUTsize[i] * (OUTsize[i] * 0.5) * (OUTsize[i] * 0.5)) / ((TIsize[i] * 0.5 - blockSize[i] * 0.5 + 1)*(TIsize[i] * 0.5 - blockSize[i] * 0.5 + 1))); if (SIM2D_YN) avgIndexHis[i] = ceil(MultiTIsNum* (1.0f * (OUTsize[i] * 0.5) * (OUTsize[i] * 0.5)) / ((TIsize[i] * 0.5 - blockSize[i] * 0.5 + 1)*(TIsize[i] * 0.5 - blockSize[i] * 0.5 + 1))); //indexweight[i] = factorIndex / avgIndexHis[i]; indexweight[i] = factorIndex * 1.0f; //~1/3 TI_ avgPosHis[i] = ceil((OUTsize[i] * OUTsize[i] * OUTsize[i]) / ((TIsize[i] - 2)*(TIsize[i] - 2)) / 3.0); if (SIM2D_YN) avgPosHis[i] = ceil(MultiTIsNum* (OUTsize[i] * OUTsize[i]) / ((TIsize[i] - 2)*(TIsize[i] - 2))); //posweight[i] = factorPos / avgPosHis[i]; posweight[i] = factorPos * 1.0f; cout << endl << "level "<< i << " colorweight=" << colorweight[i] << " indexweight=" << indexweight[i] << " posweight=" << posweight[i]; } // K-Coherence computeKCoherence_MultipleTIs(); // load Model if (!loadVolume()) return; } void DoPAR::DoANNOptimization(int TIseries) { time_t StartTime; time(&StartTime); unsigned long t1, t2, t3; init(); for (int numsim = 0; numsim < NumRealization; ++numsim) { cout << endl << "Realization : " << numsim + 1 << "========================================"; if (numsim > 0) { allocateVectors(); InitRandomVolume(0); } for (int curlevel = 0; curlevel < MULTIRES; curlevel++) { cout << endl << "=============level: " << curlevel << "==============="; FIRSTRUN = true; initPermutation(OUTsize[curlevel], SIM2D_YN, m_permutation); for (int loop = 0; loop < MAXITERATION[curlevel]; loop++) { shuffle(m_permutation.begin(), m_permutation.end(), mersennetwistergenerator); if (loop % (int)ceil(MAXITERATION[curlevel] * 0.5) == 0) cout << endl << "iteration: " << loop; //the first run on level0 should be started by search if (curlevel == 0 && loop == 0) searchVolume(curlevel, loop); //if (true) continue; t1 = GetTickCount(); optimizeVolume(curlevel, loop); t2 = GetTickCount(); if (loop % (int)ceil(MAXITERATION[curlevel] * 0.5) == 0) cout << endl << "optmize: " << (t2 - t1) / 1000.0 << " s"; if (searchVolume(curlevel, loop)) { cout << endl << "converged, skip to next level."; break; } t3 = GetTickCount(); if (loop % (int)ceil(MAXITERATION[curlevel] * 0.5) == 0) cout << endl << "search: " << (t3 - t2) / 1000.0 << " s"; if (curlevel == MULTIRES - 1 && loop == MAXITERATION[curlevel] - 1) optimizeVolume(curlevel, loop); //do one optimization after the last search if ((curlevel == MULTIRES - 1 || outputmultilevelYN) && outputiterationYN && (loop % (int)ceil(MAXITERATION[curlevel] * 0.25) == 0)) { outputmodel(curlevel); } } if (curlevel == MULTIRES - 1 || outputmultilevelYN) {// ouput model & histogram outputmodel(curlevel); } if (curlevel < MULTIRES - 1) {// level up upsampleVolume(curlevel); FIRSTRUN = true; } } } time_t NewTime; time(&NewTime); cout << endl << "Total reconstruction time: " << unsigned long(NewTime - StartTime) << " s (" << unsigned long(NewTime - StartTime) / 60 << " min)"; cleardata(); } void DoPAR::upsampleVolume(int level) { // update nearestIdx & IndexHis for next level // color does not matter bool minimumsampleYN = true; if (factorIndex == 0 && factorPos == 0) minimumsampleYN = false; size_idx OUTsize_ = OUTsize[level]; size_idx Sx = OUTsize_; if (SIM2D_YN) Sx = 1; size_idx TIsize_ = TIsize[level]; size_idx blockSize_ = blockSize[level]; size_idx TIsize2d_ = TIsize_*TIsize_; size_idx OUTsize2d_ = OUTsize_*OUTsize_; size_idx OUTsize3d_ = Sx * OUTsize2d_; size_idx doubleOUTsize_ = 2 * OUTsize_; size_idx doubleOUTsize2d_ = 4 * OUTsize2d_; size_idx doubleTIsize_ = 2 * TIsize_; //X for (size_idx i = 0; i < Sx; ++i) { size_idx iSyz = i*OUTsize2d_; size_idx sumidx_di = 2 * i * doubleOUTsize2d_; //(2 * i)*(2 * Sy)*(2 * Sz) for (size_idx j = 0; j < OUTsize_; j += GRID) { //sparse grid size_idx jSz = j*OUTsize_; size_idx sumidx_dj = 2 * j * doubleOUTsize_; //(2 * j)*(2 * Sz) for (size_idx k = 0; k < OUTsize_; k += GRID) { //sparse grid size_idx idx3d = iSyz + jSz + k; size_idx nidx2d = nearestIdx_x[level][idx3d]; size_idx rnidx2d; //random upsample if (!minimumsampleYN) { rnidx2d = KCoherence_x[level][nidx2d][(rand() % (COHERENCENUM))]; } else { //minimum upsample //!tested: better vector<long> Indexhiscomparelist(COHERENCENUM); int minidx = 0; for (int n = 0; n < COHERENCENUM; n++) { Indexhiscomparelist[n] = IndexHis_x[level][sparseIdx_TIs(level, KCoherence_x[level][nidx2d][n])]; if (Indexhiscomparelist[n] < Indexhiscomparelist[minidx]) minidx = n; } rnidx2d = KCoherence_x[level][nidx2d][minidx]; IndexHis_x[level][sparseIdx_TIs(level, rnidx2d)]++; } size_idx coordx = nidx2d / TIsize_; size_idx coordy = nidx2d % TIsize_; size_idx rcoordx = rnidx2d / TIsize_; size_idx rcoordy = rnidx2d % TIsize_; //!! no need to change for TIs coordx *= 2; coordy *= 2; rcoordx *= 2; rcoordy *= 2; nidx2d = coordx*doubleTIsize_ + coordy; //new doubled nidx2d & rnidx2d rnidx2d = rcoordx*doubleTIsize_ + rcoordy; size_idx didx3d = sumidx_di + sumidx_dj + 2 * k; //doubled didx3d setNearestIndex(level + 1, nearestIdx_x[level + 1], nearestWeight_x[level + 1], IndexHis_x[level + 1] , didx3d, nidx2d, 1.0f); //[di][dj][dk] [coordx][coordy] setNearestIndex(level + 1, nearestIdx_x[level + 1], nearestWeight_x[level + 1], IndexHis_x[level + 1] , didx3d + GRID*doubleOUTsize_, nidx2d + GRID*doubleTIsize_, 1.0f); //[di][dj+GRID][dk] [coordx+GRID][coordy] setNearestIndex(level + 1, nearestIdx_x[level + 1], nearestWeight_x[level + 1], IndexHis_x[level + 1] , didx3d + GRID, nidx2d + GRID, 1.0f); //[di][dj][dk+GRID] [coordx][coordy+GRID] setNearestIndex(level + 1, nearestIdx_x[level + 1], nearestWeight_x[level + 1], IndexHis_x[level + 1] , didx3d + GRID*doubleOUTsize_ + GRID, nidx2d + GRID*doubleTIsize_ + GRID, 1.0f);//[di][dj+GRID][dk+GRID] [coordx+GRID][coordy+GRID] if (!SIM2D_YN) { didx3d += doubleOUTsize2d_; setNearestIndex(level + 1, nearestIdx_x[level + 1], nearestWeight_x[level + 1], IndexHis_x[level + 1] , didx3d, rnidx2d, 1.0f); //[di+1][dj][dk] [rcoordx][rcoordy] setNearestIndex(level + 1, nearestIdx_x[level + 1], nearestWeight_x[level + 1], IndexHis_x[level + 1] , didx3d + GRID*doubleOUTsize_, rnidx2d + GRID*doubleTIsize_, 1.0f); //[di+1][dj+GRID][dk] [rcoordx+GRID][rcoordy] setNearestIndex(level + 1, nearestIdx_x[level + 1], nearestWeight_x[level + 1], IndexHis_x[level + 1] , didx3d + GRID, rnidx2d + GRID, 1.0f); //[di+1][dj][dk+GRID] [rcoordx][rcoordy+GRID] setNearestIndex(level + 1, nearestIdx_x[level + 1], nearestWeight_x[level + 1], IndexHis_x[level + 1] , didx3d + GRID*doubleOUTsize_ + GRID, rnidx2d + GRID*doubleTIsize_ + GRID, 1.0f); //[di+1][dj+GRID][dk+GRID] [rcoordx+GRID][rcoordy+GRID] } } } }//X if (!SIM2D_YN) { //Y for (size_idx j = 0; j < OUTsize_; ++j) { size_idx jSz = j*OUTsize_; size_idx sumidx_dj = 2 * j * doubleOUTsize_; for (size_idx i = 0; i < OUTsize_; i += GRID) { //sparse grid size_idx iSyz = i*OUTsize2d_; size_idx sumidx_di = 2 * i * doubleOUTsize2d_; for (size_idx k = 0; k < OUTsize_; k += GRID) { //sparse grid size_idx idx3d = iSyz + jSz + k; size_idx nidx2d = nearestIdx_y[level][idx3d]; size_idx rnidx2d; ////random upsample if (!minimumsampleYN) { rnidx2d = KCoherence_y[level][nidx2d][(rand() % (COHERENCENUM))]; } else { //minimum upsample vector<long> Indexhiscomparelist(COHERENCENUM); int minidx = 0; for (int n = 0; n < COHERENCENUM; n++) { Indexhiscomparelist[n] = IndexHis_y[level][sparseIdx_TIs(level, KCoherence_y[level][nidx2d][n])]; if (Indexhiscomparelist[n] < Indexhiscomparelist[minidx]) minidx = n; } rnidx2d = KCoherence_y[level][nidx2d][minidx]; IndexHis_y[level][sparseIdx_TIs(level, rnidx2d)]++; } size_idx coordx = nidx2d / TIsize_; size_idx coordy = nidx2d % TIsize_; size_idx rcoordx = rnidx2d / TIsize_; size_idx rcoordy = rnidx2d % TIsize_; coordx *= 2; coordy *= 2; rcoordx *= 2; rcoordy *= 2; nidx2d = coordx*doubleTIsize_ + coordy; //new doubled nidx2d & rnidx2d rnidx2d = rcoordx*doubleTIsize_ + rcoordy; size_idx didx3d = sumidx_di + sumidx_dj + 2 * k; //doubled didx3d setNearestIndex(level + 1, nearestIdx_y[level + 1], nearestWeight_y[level + 1], IndexHis_y[level + 1] , didx3d, nidx2d, 1.0f); //[di][dj][dk] [coordx][coordy] setNearestIndex(level + 1, nearestIdx_y[level + 1], nearestWeight_y[level + 1], IndexHis_y[level + 1] , didx3d + GRID*doubleOUTsize2d_, nidx2d + GRID*doubleTIsize_, 1.0f); //[di+GRID][dj][dk] [coordx+GRID][coordy] setNearestIndex(level + 1, nearestIdx_y[level + 1], nearestWeight_y[level + 1], IndexHis_y[level + 1] , didx3d + GRID, nidx2d + GRID, 1.0f); //[di][dj][dk+GRID] [coordx][coordy+GRID] setNearestIndex(level + 1, nearestIdx_y[level + 1], nearestWeight_y[level + 1], IndexHis_y[level + 1] , didx3d + GRID*doubleOUTsize2d_ + GRID, nidx2d + GRID*doubleTIsize_ + GRID, 1.0f); //[di+GRID][dj][dk+GRID] [coordx+GRID][coordy+GRID] didx3d += doubleOUTsize_; setNearestIndex(level + 1, nearestIdx_y[level + 1], nearestWeight_y[level + 1], IndexHis_y[level + 1] , didx3d, rnidx2d, 1.0f); //[di][dj+1][dk] [rcoordx][rcoordy] setNearestIndex(level + 1, nearestIdx_y[level + 1], nearestWeight_y[level + 1], IndexHis_y[level + 1] , didx3d + GRID*doubleOUTsize2d_, rnidx2d + GRID*doubleTIsize_, 1.0f); //[di+GRID][dj+1][dk] [rcoordx+GRID][rcoordy] setNearestIndex(level + 1, nearestIdx_y[level + 1], nearestWeight_y[level + 1], IndexHis_y[level + 1] , didx3d + GRID, rnidx2d + GRID, 1.0f); //[di][dj+1][dk+GRID] [rcoordx][rcoordy+GRID] setNearestIndex(level + 1, nearestIdx_y[level + 1], nearestWeight_y[level + 1], IndexHis_y[level + 1] , didx3d + GRID*doubleOUTsize2d_ + GRID, rnidx2d + GRID*doubleTIsize_ + GRID, 1.0f); //[di+GRID][dj+1][dk+GRID] [rcoordx+GRID][rcoordy+GRID] } } }//Y //Z for (size_idx k = 0; k < OUTsize_; ++k) { for (size_idx i = 0; i < OUTsize_; i += GRID) { //sparse grid size_idx iSyz = i*OUTsize2d_; size_idx sumidx_di = 2 * i * doubleOUTsize2d_; for (size_idx j = 0; j < OUTsize_; j += GRID) { //sparse grid size_idx jSz = j*OUTsize_; size_idx sumidx_dj = 2 * j * doubleOUTsize_; size_idx idx3d = iSyz + jSz + k; size_idx nidx2d = nearestIdx_z[level][idx3d]; size_idx rnidx2d; ////random upsample if (!minimumsampleYN) { rnidx2d = KCoherence_z[level][nidx2d][(rand() % (COHERENCENUM))]; } else { //minimum upsample vector<long> Indexhiscomparelist(COHERENCENUM); int minidx = 0; for (int n = 0; n < COHERENCENUM; n++) { Indexhiscomparelist[n] = IndexHis_z[level][sparseIdx_TIs(level, KCoherence_z[level][nidx2d][n])]; if (Indexhiscomparelist[n] < Indexhiscomparelist[minidx]) minidx = n; } rnidx2d = KCoherence_z[level][nidx2d][minidx]; IndexHis_z[level][sparseIdx_TIs(level, rnidx2d)]++; } size_idx coordx = nidx2d / TIsize_; size_idx coordy = nidx2d % TIsize_; size_idx rcoordx = rnidx2d / TIsize_; size_idx rcoordy = rnidx2d % TIsize_; coordx *= 2; coordy *= 2; rcoordx *= 2; rcoordy *= 2; nidx2d = coordx*doubleTIsize_ + coordy; //new doubled nidx2d & rnidx2d rnidx2d = rcoordx*doubleTIsize_ + rcoordy; size_idx didx3d = sumidx_di + sumidx_dj + 2 * k; //doubled didx3d setNearestIndex(level + 1, nearestIdx_z[level + 1], nearestWeight_z[level + 1], IndexHis_z[level + 1] , didx3d, nidx2d, 1.0f); //[di][dj][dk] [coordx][coordy] setNearestIndex(level + 1, nearestIdx_z[level + 1], nearestWeight_z[level + 1], IndexHis_z[level + 1] , didx3d + GRID*doubleOUTsize2d_, nidx2d + GRID*doubleTIsize_, 1.0f); //[di+GRID][dj][dk] [coordx+GRID][coordy] setNearestIndex(level + 1, nearestIdx_z[level + 1], nearestWeight_z[level + 1], IndexHis_z[level + 1] , didx3d + GRID*doubleOUTsize_, nidx2d + GRID, 1.0f); //[di][dj+GRID][dk] [coordx][coordy+GRID] setNearestIndex(level + 1, nearestIdx_z[level + 1], nearestWeight_z[level + 1], IndexHis_z[level + 1] , didx3d + GRID*doubleOUTsize2d_ + GRID*doubleOUTsize_, nidx2d + GRID*doubleTIsize_ + GRID, 1.0f); //[di+GRID][dj+GRID][dk] [coordx+GRID][coordy+GRID] didx3d += 1; setNearestIndex(level + 1, nearestIdx_z[level + 1], nearestWeight_z[level + 1], IndexHis_z[level + 1] , didx3d, rnidx2d, 1.0f); //[di][dj][dk+1] [rcoordx][rcoordy] setNearestIndex(level + 1, nearestIdx_z[level + 1], nearestWeight_z[level + 1], IndexHis_z[level + 1] , didx3d + GRID*doubleOUTsize2d_, rnidx2d + GRID*doubleTIsize_, 1.0f); //[di+GRID][dj][dk+1] [rcoordx+GRID][rcoordy] setNearestIndex(level + 1, nearestIdx_z[level + 1], nearestWeight_z[level + 1], IndexHis_z[level + 1] , didx3d + GRID*doubleOUTsize_, rnidx2d + GRID, 1.0f); //[di][dj+GRID][dk+1] [rcoordx][rcoordy+GRID] setNearestIndex(level + 1, nearestIdx_z[level + 1], nearestWeight_z[level + 1], IndexHis_z[level + 1] , didx3d + GRID*doubleOUTsize2d_ + GRID*doubleOUTsize_, rnidx2d + GRID*doubleTIsize_ + GRID, 1.0f); //[di+GRID][dj+GRID][dk+1] [rcoordx+GRID][rcoordy+GRID] } } }//Z }//if(!SIM2D_YN) cout << endl << "upsampled from " << level << " to " << level + 1; } bool DoPAR::setNearestIndex(int level, vector<size_idx>& nearestIdx, vector<size_dist>& nearestWeight, vector<size_hiscount>&IndexHis, size_idx idx3d, size_idx newNearestIdx, size_dist dis) { // only used in upsampling //update IndexHis & NearestIndex, store EuDis^-0.6 -- search step size_idx TIsize_ = TIsize[level]; size_idx formerNearestIdx = nearestIdx[idx3d]; nearestWeight[idx3d] = 1.0f / dis; if (formerNearestIdx == newNearestIdx) return true; nearestIdx[idx3d] = newNearestIdx; //update nearestIdx if (formerNearestIdx < TIsize_ * TIsize_ && formerNearestIdx >= 0) { size_idx sparsedFormerNearestIdx = sparseIdx_TIs(level, formerNearestIdx); //update IndexHis sparse grid if (IndexHis[sparsedFormerNearestIdx] > 0) IndexHis[sparsedFormerNearestIdx]--; } IndexHis[sparseIdx_TIs(level, newNearestIdx)]++; //update IndexHis sparse grid return false; } // =========== K-coherence precompute ============= void DoPAR::computeKCoherence_MultipleTIs() { cout << endl << "K=" << COHERENCENUM << " compute K-coherence..."; unsigned long time_start = clock(); KCoherence_x.resize(MULTIRES); KCoherence_y.resize(MULTIRES); KCoherence_z.resize(MULTIRES); // check KC multiTIs usage is uniform or not vector<vector<long>> KCusage_TIs_x(MULTIRES), KCusage_TIs_y(MULTIRES), KCusage_TIs_z(MULTIRES); for (int level = 0; level < MULTIRES; ++level) { size_idx TIsize_ = TIsize[level]; size_idx TIsize2d_ = TIsize_*TIsize_; size_idx blockSize_ = blockSize[level]; size_idx width = TIsize_ - blockSize_ + 1; size_idx height = TIsize_ - blockSize_ + 1; size_idx maxSize2d = TIsize_ * height; size_idx dim = blockSize_ * blockSize_; size_idx bias = blockSize_ * 0.5; cout << endl << "level: " << level << " Template size="<< blockSize_ << " Dimension=" << dim; size_idx numData = width * height * MultiTIsNum; size_idx KCoherenceSize = TIsize2d_ * MultiTIsNum; KCusage_TIs_x[level].resize(MultiTIsNum); KCusage_TIs_y[level].resize(MultiTIsNum); KCusage_TIs_z[level].resize(MultiTIsNum); KCoherence_x[level].resize(KCoherenceSize); KCoherence_y[level].resize(KCoherenceSize); KCoherence_z[level].resize(KCoherenceSize); // ----------- add template to p_source_x [numData][dim] ANNpointArray p_source_x, p_source_y, p_source_z; p_source_x = annAllocPts(numData, dim); //rows='area' numData, cols=dimension (Neighbour size) p_source_y = annAllocPts(numData, dim); p_source_z = annAllocPts(numData, dim); size_idx row = 0; for (int tin = 0; tin < MultiTIsNum; tin++) { for (size_idx i = 0; i < width; ++i) { for (size_idx j = 0; j < height; ++j) { size_idx col = 0; size_idx index0 = TIsize_ * i + j; for (size_idx m = 0; m <blockSize_; ++m) { for (size_idx n = 0; n <blockSize_; ++n) { size_idx index = index0 + m * TIsize_ + n; //[i+m][j+n] p_source_x[row][col] = TIs_XY[level][tin][index]; if (!SIM2D_YN) { p_source_y[row][col] = TIs_XZ[level][tin][index]; p_source_z[row][col] = TIs_YZ[level][tin][index]; } ++col; } } ++row; } } } // ----------- build ANNkd_tree ANNkd_tree* kdTree_x; ANNkd_tree* kdTree_y; ANNkd_tree* kdTree_z; kdTree_x = new ANNkd_tree(p_source_x, numData, dim); kdTree_y = new ANNkd_tree(p_source_y, numData, dim); kdTree_z = new ANNkd_tree(p_source_z, numData, dim); // ----------- ANNkd_tree search #pragma omp parallel { for (int tin = 0; tin < MultiTIsNum; tin++) { #pragma omp for nowait schedule(static) for (size_idx idx = 0; idx < maxSize2d; idx++) { if (idx%TIsize_ >= width) continue; ANNpoint queryPt_x, queryPt_y, queryPt_z; queryPt_x = annAllocPt(dim); queryPt_y = annAllocPt(dim); queryPt_z = annAllocPt(dim); ANNidxArray ann_index_x = new size_idx[COHERENCENUM]; ANNidxArray ann_index_y = new size_idx[COHERENCENUM]; ANNidxArray ann_index_z = new size_idx[COHERENCENUM]; ANNdistArray ann_dist_x = new size_dist[COHERENCENUM]; ANNdistArray ann_dist_y = new size_dist[COHERENCENUM]; ANNdistArray ann_dist_z = new size_dist[COHERENCENUM]; // load query pattern long num = 0; for (size_idx m = 0; m < blockSize_; ++m) { for (size_idx n = 0; n < blockSize_; ++n) { size_idx index = idx + TIsize_ * m + n; //[i+m][j+n] queryPt_x[num] = TIs_XY[level][tin][index]; if (!SIM2D_YN) { queryPt_y[num] = TIs_XZ[level][tin][index]; queryPt_z[num] = TIs_YZ[level][tin][index]; } num++; } } // ANNsearch kdTree_x->annkSearch(queryPt_x, COHERENCENUM, ann_index_x, ann_dist_x, ANNerror[level]); if (!SIM2D_YN) { kdTree_y->annkSearch(queryPt_y, COHERENCENUM, ann_index_y, ann_dist_y, ANNerror[level]); kdTree_z->annkSearch(queryPt_z, COHERENCENUM, ann_index_z, ann_dist_z, ANNerror[level]); } // Set K-Coherence shifted to same range of TI_index size_idx shift_TIs = tin*TIsize2d_; size_idx bias_TIindex = (idx + bias*TIsize_ + bias) + shift_TIs; KCoherence_x[level][bias_TIindex].resize(COHERENCENUM); KCoherence_y[level][bias_TIindex].resize(COHERENCENUM); KCoherence_z[level][bias_TIindex].resize(COHERENCENUM); for (int k = 0; k < COHERENCENUM; ++k) { KCoherence_x[level][bias_TIindex][k] = convertIndexANN_TIs(level, ann_index_x[k], TIsize_, blockSize_); if (!SIM2D_YN) { KCoherence_y[level][bias_TIindex][k] = convertIndexANN_TIs(level, ann_index_y[k], TIsize_, blockSize_); KCoherence_z[level][bias_TIindex][k] = convertIndexANN_TIs(level, ann_index_z[k], TIsize_, blockSize_); } //count KC multiTIs usage auto TIsn = KCoherence_x[level][bias_TIindex][k] / TIsize2d_; long& usageaddr_x = KCusage_TIs_x[level][TIsn]; #pragma omp atomic usageaddr_x++; if (!SIM2D_YN) { TIsn = KCoherence_y[level][bias_TIindex][k] / TIsize2d_; long& usageaddr_y = KCusage_TIs_y[level][TIsn]; #pragma omp atomic usageaddr_y++; TIsn = KCoherence_z[level][bias_TIindex][k] / TIsize2d_; long& usageaddr_z = KCusage_TIs_z[level][TIsn]; #pragma omp atomic usageaddr_z++; } } // release annDeallocPt(queryPt_x); annDeallocPt(queryPt_y); annDeallocPt(queryPt_z); delete[] ann_index_x; delete[] ann_index_y; delete[] ann_index_z; delete[] ann_dist_x; delete[] ann_dist_y; delete[] ann_dist_z; }//#pragma omp for nowait schedule(static) } }// #pragma omp parallel //release annClose(); delete kdTree_x; delete kdTree_y; delete kdTree_z; annDeallocPts(p_source_x); annDeallocPts(p_source_y); annDeallocPts(p_source_z); // check KC multiTIs usage is uniform or not if (MultiTIsNum > 1) { vector<double> KCusageratio_TIs_x(MultiTIsNum), KCusageratio_TIs_y(MultiTIsNum), KCusageratio_TIs_z(MultiTIsNum); long total = accumulate(KCusage_TIs_x[level].begin(), KCusage_TIs_x[level].end(), 0); cout << fixed; for (int s = 0; s < MultiTIsNum; s++) { KCusageratio_TIs_x[s] = 100.0 * KCusage_TIs_x[level][s] / total; KCusageratio_TIs_y[s] = 100.0 * KCusage_TIs_y[level][s] / total; KCusageratio_TIs_z[s] = 100.0 * KCusage_TIs_z[level][s] / total; cout << endl << setprecision(1) << "KC usage TI(" << s << "): X " << KCusageratio_TIs_x[s] << " Y " << KCusageratio_TIs_y[s] << " Z " << KCusageratio_TIs_z[s]; } } } long time_end = clock(); cout << endl << "done. clocks = " << (time_end - time_start) / CLOCKS_PER_SEC << " s"; } // ================ search (M-step) =============== bool DoPAR::searchVolume(int level, int loop) { bool enhancelowindexYN = false; //if (level<1 && factorIndex>0 &&loop> MAXITERATION[level] / 2) enhancelowindexYN = true; // const bool isUnchanged = true; size_idx OUTsize_ = OUTsize[level]; size_idx TIsize_ = TIsize[level]; size_idx blockSize_ = blockSize[level]; size_idx TIsize2d_ = TIsize_*TIsize_; size_idx OUTsize2d_ = OUTsize_*OUTsize_; size_idx Size = OUTsize2d_*OUTsize_; if (SIM2D_YN) Size = OUTsize2d_; size_idx start = blockSize_ * 0.5; //-cstart<=x<=cend size_idx end = (blockSize_ - 1) * 0.5; size_idx cstart(start), cend(end); size_idx poshisadd[3] = { 0, TIsize2d_, TIsize2d_ * 2 }; //AssignFixedLayer(level, FixedLayerDir); #pragma omp parallel { //XY #pragma omp for nowait schedule(static) for (size_idx i2 = 0; i2 < Size; ++i2) { int ori = 0; size_idx idx = m_permutation[i2]; size_idx i, j, k; idxToCoord(idx, OUTsize_, i, j, k); // check skip if (j % GRID != 0 || k % GRID != 0) continue; if (isUnchangedBlock(level, 0, i, j, k)) continue; // temp size_idx iSyz = OUTsize2d_ * i, jSz = j * OUTsize_; size_idx bestTIIdx_regular, bestIdx_TIs; size_hiscount besthis(0); size_dist minError(max_dist), minDis(max_dist); vector<size_idx> compareIdx; int compareNum = 0; compareIdx.reserve(blockSize_ * blockSize_ * COHERENCENUM); vector<size_color> current_pattern(blockSize_*blockSize_); // Load current pattern size_idx tempindex = 0, VCurIdx, index2; for (size_idx du = -start; du <= end; ++du) { VCurIdx = iSyz + OUTsize_ * trim(OUTsize_, j + du); for (size_idx dv = -start; dv <= end; ++dv) { index2 = VCurIdx + trim(OUTsize_, k + dv); current_pattern[tempindex++] = m_volume[level][index2]; } } // get 3didx for (size_idx u = -cstart; u <= cend; ++u) { size_idx sumidx_posx, temp3didx; sumidx_posx = iSyz + trim(OUTsize_, j + u)*OUTsize_; for (size_idx v = -cstart; v <= cend; ++v) { temp3didx = sumidx_posx + trim(OUTsize_, k + v); size_idx temporigin_Idxregular, temporigin_TInum, tempTIidx_TIs; tempTIidx_TIs = Origin_x[level][temp3didx]; TIsToRegular(tempTIidx_TIs, TIsize2d_, temporigin_Idxregular, temporigin_TInum); size_idx eposx = (temporigin_Idxregular / TIsize_) - u; size_idx eposy = (temporigin_Idxregular % TIsize_) - v; // boundary check if (!(eposx >= start && eposx < TIsize_ - end && eposy >= start && eposy < TIsize_ - end)) continue; tempTIidx_TIs = tempTIidx_TIs - (u*TIsize_ + v); //origin - (u,v) for (int l = 0; l < COHERENCENUM; ++l) { // get KCoherence size_idx temp2didx_TIs = KCoherence_x[level][tempTIidx_TIs][l]; size_idx temp2didx_Idxregular, temp2didx_TInum; TIsToRegular(temp2didx_TIs, TIsize2d_, temp2didx_Idxregular, temp2didx_TInum); // check duplicate int p = 0; for (; p < compareNum; ++p) { if (compareIdx[p] == temp2didx_TIs) break; }if (p < compareNum) continue; // calc square distance size_dist curDis = getFullDistance(level, TIs_XY[level][temp2didx_TInum], temp2didx_Idxregular, current_pattern); // calc his weight size_dist curhis = IndexHis_x[level][sparseIdx_TIs(level, temp2didx_TIs)]; // IndexHis sparse grid size_dist tempHisDiff = max(0.0f, 1.0f*(curhis - avgIndexHis[level])); // manual control indexhis //if (tempHisDiff > IndexHisManualControl*avgIndexHis[level]) curError = max_dist; if (enhancelowindexYN && (curhis < avgIndexHis[level])) { tempHisDiff = 1.0f*(curhis - avgIndexHis[level]); } size_dist IndexHisWeight = 1.0f + indexweight[level] * tempHisDiff; size_dist curError = IndexHisWeight * curDis; // keep minError if (curError < minError) { minError = curError; minDis = curDis; bestIdx_TIs = temp2didx_TIs; besthis = curhis; } else if (curError - minError < 1e-8) { // if Error same, first compare IndexHis if (curhis < besthis) { minDis = curDis; bestIdx_TIs = temp2didx_TIs; besthis = curhis; } else if (curhis == besthis && !FIRSTRUN) { if (PosHis[level][temp2didx_Idxregular + poshisadd[ori]] < PosHis[level][bestIdx_TIs%TIsize2d_ + poshisadd[ori]]) bestIdx_TIs = temp2didx_TIs; } } compareNum++; compareIdx.push_back(temp2didx_TIs); } } } // get bestTIIdx if (fabs(max_dist - minError) > 1.0f) { nearestWeight_x[level][idx] = 1.0f / minDis; } else { bestTIIdx_regular = getRandomNearestIndex(level, IndexHis_x[level]); bestIdx_TIs = (rand() % MultiTIsNum) * TIsize2d_ + bestTIIdx_regular; nearestWeight_x[level][idx] = 1e-3f; } // update nearestIdx size_idx formerNearestIdx = nearestIdx_x[level][idx]; if (formerNearestIdx != bestIdx_TIs) { nearestIdx_x[level][idx] = bestIdx_TIs; //if (bestIdx_TIs < 0 || bestIdx_TIs >= MultiTIsNum*TIsize2d_) { // printf("\nsearch: idx%d bestIdx_TIs%d", idx, bestIdx_TIs); // _getch(); //} // update indexhis if (formerNearestIdx < MultiTIsNum * TIsize2d_ && formerNearestIdx >= 0) { size_hiscount& addressFormerNearestIdx = IndexHis_x[level][sparseIdx_TIs(level, formerNearestIdx)]; if (addressFormerNearestIdx > 0) #pragma omp atomic addressFormerNearestIdx--; } size_hiscount& addressbestTIIdx = IndexHis_x[level][sparseIdx_TIs(level, bestIdx_TIs)]; #pragma omp atomic addressbestTIIdx++; isUnchanged = false; } }//for (size_idx i2 = 0; i2 < Size; ++i2) { //XZ #pragma omp for nowait schedule(static) for (size_idx i2 = 0; i2 < Size; ++i2) { int ori = 1; if (SIM2D_YN && ori != 0) continue; size_idx idx = m_permutation[i2]; size_idx i, j, k; idxToCoord(idx, OUTsize_, i, j, k); // check skip if (ori == 0 && (j % GRID != 0 || k % GRID != 0)) continue; else if (ori == 1 && (i % GRID != 0 || k % GRID != 0)) continue; else if (ori == 2 && (i % GRID != 0 || j % GRID != 0)) continue; if (isUnchangedBlock(level, ori, i, j, k)) continue; // temp size_idx iSyz = OUTsize2d_ * i, jSz = j * OUTsize_; size_idx bestTIIdx_regular, bestIdx_TIs; size_hiscount besthis(0); size_dist minError(max_dist), minDis(max_dist); vector<size_idx> compareIdx; int compareNum = 0; compareIdx.reserve(blockSize_ * blockSize_ * COHERENCENUM); vector<size_color> current_pattern(blockSize_*blockSize_); // Load current pattern size_idx tempindex = 0, VCurIdx, index2; for (size_idx du = -start; du <= end; ++du) { VCurIdx = OUTsize2d_ * trim(OUTsize_, i + du) + jSz; for (size_idx dv = -start; dv <= end; ++dv) { index2 = VCurIdx + trim(OUTsize_, k + dv); current_pattern[tempindex++] = m_volume[level][index2]; } } // get 3didx for (size_idx u = -cstart; u <= cend; ++u) { size_idx sumidx_posx, temp3didx; sumidx_posx = trim(OUTsize_, i + u)*OUTsize2d_ + jSz; for (size_idx v = -cstart; v <= cend; ++v) { temp3didx = sumidx_posx + trim(OUTsize_, k + v); size_idx temporigin_Idxregular, temporigin_TInum, tempTIidx_TIs; tempTIidx_TIs = Origin_y[level][temp3didx]; TIsToRegular(tempTIidx_TIs, TIsize2d_, temporigin_Idxregular, temporigin_TInum); size_idx eposx = (temporigin_Idxregular / TIsize_) - u; size_idx eposy = (temporigin_Idxregular % TIsize_) - v; // boundary check if (!(eposx >= start && eposx < TIsize_ - end && eposy >= start && eposy < TIsize_ - end)) continue; tempTIidx_TIs = tempTIidx_TIs - (u*TIsize_ + v); //origin - (u,v) for (int l = 0; l < COHERENCENUM; ++l) { // get KCoherence size_idx temp2didx_TIs = KCoherence_y[level][tempTIidx_TIs][l]; size_idx temp2didx_Idxregular, temp2didx_TInum; TIsToRegular(temp2didx_TIs, TIsize2d_, temp2didx_Idxregular, temp2didx_TInum); // check duplicate int p = 0; for (; p < compareNum; ++p) { if (compareIdx[p] == temp2didx_TIs) break; }if (p < compareNum) continue; // calc square distance size_dist curDis = getFullDistance(level, TIs_XZ[level][temp2didx_TInum], temp2didx_Idxregular, current_pattern); // calc his weight size_hiscount curhis = IndexHis_y[level][sparseIdx_TIs(level, temp2didx_TIs)]; // IndexHis sparse grid size_hiscount tempHisDiff = max(0.0f, 1.0f*(curhis - avgIndexHis[level])); // manual control indexhis //if (tempHisDiff > IndexHisManualControl*avgIndexHis[level]) curError = max_dist; if (enhancelowindexYN && (curhis < avgIndexHis[level])) { tempHisDiff = 1.0f*(curhis - avgIndexHis[level]); } size_dist IndexHisWeight = 1.0f + indexweight[level] * tempHisDiff; size_dist curError = IndexHisWeight * curDis; // keep minError if (curError < minError) { minError = curError; minDis = curDis; bestIdx_TIs = temp2didx_TIs; besthis = curhis; } else if (curError - minError < 10e-9) { // if Error same, first compare IndexHis if (curhis < besthis) { minDis = curDis; bestIdx_TIs = temp2didx_TIs; besthis = curhis; } else if (curhis == besthis && !FIRSTRUN) { if (PosHis[level][temp2didx_Idxregular + poshisadd[ori]] < PosHis[level][bestIdx_TIs%TIsize2d_ + poshisadd[ori]]) bestIdx_TIs = temp2didx_TIs; } } compareNum++; compareIdx.push_back(temp2didx_TIs); } } } // get bestTIIdx if (fabs(max_dist - minError) > 1.0f) { nearestWeight_y[level][idx] = 1.0f / minDis; } else { bestTIIdx_regular = getRandomNearestIndex(level, IndexHis_y[level]); bestIdx_TIs = (rand() % MultiTIsNum) * TIsize2d_ + bestTIIdx_regular; nearestWeight_y[level][idx] = 1e-3f; } // update nearestIdx size_idx formerNearestIdx = nearestIdx_y[level][idx]; if (formerNearestIdx != bestIdx_TIs) { nearestIdx_y[level][idx] = bestIdx_TIs; // update indexhis if (formerNearestIdx < MultiTIsNum * TIsize2d_ && formerNearestIdx >= 0) { size_hiscount& addressFormerNearestIdx = IndexHis_y[level][sparseIdx_TIs(level, formerNearestIdx)]; if (addressFormerNearestIdx > 0) #pragma omp atomic addressFormerNearestIdx--; } size_hiscount& addressbestTIIdx = IndexHis_y[level][sparseIdx_TIs(level, bestIdx_TIs)]; #pragma omp atomic addressbestTIIdx++; isUnchanged = false; } }//for (size_idx i2 = 0; i2 < Size; ++i2) { //YZ #pragma omp for nowait schedule(static) for (size_idx i2 = 0; i2 < Size; ++i2) { int ori = 2; if (SIM2D_YN && ori != 0) continue; size_idx idx = m_permutation[i2]; size_idx i, j, k; idxToCoord(idx, OUTsize_, i, j, k); // check skip if (ori == 0 && (j % GRID != 0 || k % GRID != 0)) continue; else if (ori == 1 && (i % GRID != 0 || k % GRID != 0)) continue; else if (ori == 2 && (i % GRID != 0 || j % GRID != 0)) continue; if (isUnchangedBlock(level, ori, i, j, k)) continue; // temp size_idx iSyz = OUTsize2d_ * i, jSz = j * OUTsize_; size_idx bestTIIdx_regular, bestIdx_TIs; size_hiscount besthis(0); size_dist minError(max_dist), minDis(max_dist); vector<size_idx> compareIdx; int compareNum = 0; compareIdx.reserve(blockSize_ * blockSize_ * COHERENCENUM); vector<size_color> current_pattern(blockSize_*blockSize_); // Load current pattern size_idx tempindex = 0, VCurIdx, index2; for (size_idx du = -start; du <= end; ++du) { VCurIdx = OUTsize2d_ * trim(OUTsize_, i + du) + k; for (size_idx dv = -start; dv <= end; ++dv) { index2 = VCurIdx + OUTsize_ * trim(OUTsize_, j + dv); current_pattern[tempindex++] = m_volume[level][index2]; } } // get 3didx for (size_idx u = -cstart; u <= cend; ++u) { size_idx sumidx_posx, temp3didx; sumidx_posx = trim(OUTsize_, i + u)*OUTsize2d_ + k; for (size_idx v = -cstart; v <= cend; ++v) { temp3didx = sumidx_posx + trim(OUTsize_, j + v)*OUTsize_; size_idx temporigin_Idxregular, temporigin_TInum, tempTIidx_TIs; tempTIidx_TIs = Origin_z[level][temp3didx]; TIsToRegular(tempTIidx_TIs, TIsize2d_, temporigin_Idxregular, temporigin_TInum); size_idx eposx = (temporigin_Idxregular / TIsize_) - u; size_idx eposy = (temporigin_Idxregular % TIsize_) - v; // boundary check if (!(eposx >= start && eposx < TIsize_ - end && eposy >= start && eposy < TIsize_ - end)) continue; tempTIidx_TIs = tempTIidx_TIs - (u*TIsize_ + v); //origin - (u,v) for (int l = 0; l < COHERENCENUM; ++l) { // get KCoherence size_idx temp2didx_TIs = KCoherence_z[level][tempTIidx_TIs][l]; size_idx temp2didx_Idxregular, temp2didx_TInum; TIsToRegular(temp2didx_TIs, TIsize2d_, temp2didx_Idxregular, temp2didx_TInum); // check duplicate int p = 0; for (; p < compareNum; ++p) { if (compareIdx[p] == temp2didx_TIs) break; }if (p < compareNum) continue; // calc square distance size_dist curDis = getFullDistance(level, TIs_YZ[level][temp2didx_TInum], temp2didx_Idxregular, current_pattern); // calc his weight size_hiscount curhis = IndexHis_z[level][sparseIdx_TIs(level, temp2didx_TIs)]; // IndexHis sparse grid size_hiscount tempHisDiff = max(0.0f, 1.0f*(curhis - avgIndexHis[level])); // manual control indexhis //if (tempHisDiff > IndexHisManualControl*avgIndexHis[level]) curError = max_dist; if (enhancelowindexYN && (curhis < avgIndexHis[level])) { tempHisDiff = 1.0f*(curhis - avgIndexHis[level]); } size_dist IndexHisWeight = 1.0f + indexweight[level] * tempHisDiff; size_dist curError = IndexHisWeight * curDis; // keep minError if (curError < minError) { minError = curError; minDis = curDis; bestIdx_TIs = temp2didx_TIs; besthis = curhis; } else if (curError - minError < 10e-9) { // if Error same, first compare IndexHis if (curhis < besthis) { minDis = curDis; bestIdx_TIs = temp2didx_TIs; besthis = curhis; } else if (curhis == besthis && !FIRSTRUN) { if (PosHis[level][temp2didx_Idxregular + poshisadd[ori]] < PosHis[level][bestIdx_TIs%TIsize2d_ + poshisadd[ori]]) bestIdx_TIs = temp2didx_TIs; } } compareNum++; compareIdx.push_back(temp2didx_TIs); } } } // get bestTIIdx if (fabs(max_dist - minError) > 1.0f) { nearestWeight_z[level][idx] = 1.0f / minDis; } else { bestTIIdx_regular = getRandomNearestIndex(level, IndexHis_z[level]); bestIdx_TIs = (rand() % MultiTIsNum) * TIsize2d_ + bestTIIdx_regular; nearestWeight_z[level][idx] = 1e-3f; } // update nearestIdx size_idx formerNearestIdx = nearestIdx_z[level][idx]; if (formerNearestIdx != bestIdx_TIs) { nearestIdx_z[level][idx] = bestIdx_TIs; // update indexhis if (formerNearestIdx < MultiTIsNum * TIsize2d_ && formerNearestIdx >= 0) { size_hiscount& addressFormerNearestIdx = IndexHis_z[level][sparseIdx_TIs(level, formerNearestIdx)]; if (addressFormerNearestIdx > 0) #pragma omp atomic addressFormerNearestIdx--; } size_hiscount& addressbestTIIdx = IndexHis_z[level][sparseIdx_TIs(level, bestIdx_TIs)]; #pragma omp atomic addressbestTIIdx++; isUnchanged = false; } }//for (size_idx i2 = 0; i2 < Size; ++i2) { }//#pragma omp parallel return isUnchanged; } //size_dist DoPAR::getFullDistance(int level, vector<size_color>& exemplar, size_idx idx2d, CvMat * dataMat) { // //2d square distance // size_dist sum = 0.0f; // size_idx R = static_cast<size_idx>(blockSize[level] * 0.5); // size_idx n = 0; // size_idx Sx = TIsize[level]; // size_idx tempIdx; // size_dist dif; // size_idx x = idx2d / Sx, y = idx2d % Sx; // //[R,Sx-R+1) [R,Sx-R] // if (x - R< 0 || x + R > Sx || y - R<0 || y + R> Sx) { // printf("\ngetFullDistance() boundary"); // _getch(); // exit(0); // } // // for (size_idx i = -R; i < R; ++i) { // tempIdx = idx2d + i*Sx; // for (size_idx j = -R; j < R; ++j) { // dif = exemplar[tempIdx + j] - cvmGet(dataMat, 0, n++); // sum += (dif * dif); // } // } // return (sum < min_dist) ? min_dist : sum; //} template<typename T> size_dist DoPAR::getFullDistance(int level, vector<T>& TI, size_idx idx2d, vector<T>& pattern) { //2d square distance size_idx TIsize_ = TIsize[level], TIsize2d_ = TIsize_*TIsize_, R = blockSize[level]/2; size_dist sum(0), dif; size_idx x = idx2d / TIsize_, y = idx2d % TIsize_, tempIdx, n(0); for (size_idx i = -R; i < R; ++i) { tempIdx = idx2d + i*TIsize_; for (size_idx j = -R; j < R; ++j) { dif = TI[tempIdx + j] - pattern[n++]; sum += (dif * dif); } } return (sum < min_dist) ? min_dist : sum; } template<typename T> size_dist DoPAR::getFullDistance_TIs(int level, vector<vector<T>>& TIs, size_idx idx2d_TIs, vector<T>& pattern) { //2d square distance size_idx TIsize_ = TIsize[level], TIsize2d_ = TIsize_*TIsize_, R = blockSize[level]/2; size_idx idx2d = idx2d_TIs % TIsize2d_, TInum = idx2d_TIs / TIsize2d_; size_dist sum(0), dif; size_idx x = idx2d / TIsize_, y = idx2d % TIsize_, tempIdx, n(0); for (size_idx i = -R; i < R; ++i) { tempIdx = idx2d + i*TIsize_; for (size_idx j = -R; j < R; ++j) { dif = TIs[TInum][tempIdx + j] - pattern[n++]; sum += (dif * dif); } } return (sum < min_dist) ? min_dist : sum; } size_idx DoPAR::getRandomNearestIndex(int level, vector<size_hiscount>& IndexHis) { // get minimum nearest index size_idx TEXSIZE_h = TIsize[level]/2; size_idx start = 5, end = TEXSIZE_h - 5; if (end <= start) { start = 3; end = TEXSIZE_h - 3; } //size_idx start = 3, end = TEXSIZE_h - 3; size_idx coordx, coordy, tempidx, tempidxj; size_hiscount minVal = LONG_MAX, curVal = 0; for (size_idx i = start; i < end; i += GRID){ tempidx = i* TEXSIZE_h; for (size_idx j = start; j < end; j += GRID){ tempidxj = tempidx + j; //!!IndexHis is sparsed curVal = IndexHis[tempidxj] + IndexHis[tempidxj + TEXSIZE_h] + IndexHis[tempidxj + 1] + IndexHis[tempidxj + TEXSIZE_h + 1]; if (curVal < minVal) { coordx = i; coordy = j; minVal = curVal; } } } //cout << endl << "(i,j)=" << coordx << "," << coordy; coordx *= 2; coordy *= 2; coordx += rand() % 4; coordy += rand() % 4; return (coordx*TIsize[level] + coordy); } bool DoPAR::isUnchangedBlock(int level, int direction, size_idx i, size_idx j, size_idx k) { // look up all neighbourhood in m_volume[i][j][k], check if all is unchanged (if anyone has changed (isUnchanged_==false), return false) const size_idx Sz = OUTsize[level]; const size_idx jSz = j*Sz; const size_idx Syz = OUTsize[level] * OUTsize[level]; const size_idx iSyz = i*Syz; size_idx start = static_cast<size_idx>(blockSize[level] * 0.5); //4 //4 //3 //3 size_idx end = static_cast<size_idx>((blockSize[level] - 1) * 0.5); //3 //3 //2 //2 if (level > 0 && end>1) { start -= 1; //4 //3 //2 //2 end -= 1; //3 //2 //1 //1 } size_idx tempidx; switch (direction){ case(0) : // X for (size_idx tj = j - start; tj <= j + end; ++tj){ tempidx = iSyz + trim(Sz, tj) * Sz; for (size_idx tk = k - start; tk <= k + end; ++tk){ if (!isUnchanged_x[level][tempidx + trim(Sz, tk)]) //[i][tj][tk] return false; } } break; case(1) : // Y for (int ti = i - start; ti <= i + end; ++ti){ tempidx = trim(Sz, ti) * Syz + jSz; for (int tk = k - start; tk <= k + end; ++tk){ if (!isUnchanged_y[level][tempidx + trim(Sz, tk)]) //[ti][j][tk] return false; } } break; case(2) : // Z for (int ti = i - start; ti <= i + end; ++ti){ tempidx = trim(Sz, ti) * Syz + k; for (int tj = j - start; tj <= j + end; ++tj){ if (!isUnchanged_z[level][tempidx + trim(Sz, tj)*Sz]) //[ti][tj][k] return false; } } break; } return true; } // ================ optimization (E-step) ========= void DoPAR::optimizeVolume(int level, int loop) { //bool offsetYN = false; bool enhancelowposYN = false; //if (level < 1 && factorPos>0 && loop > MAXITERATION[level] / 2) enhancelowposYN = true; // const size_idx OUTsize_ = OUTsize[level]; size_idx TIsize_ = TIsize[level]; size_idx blockSize_ = blockSize[level]; size_idx TIsize2d_ = TIsize_*TIsize_; size_idx OUTsize2d_ = OUTsize_*OUTsize_; size_idx Size = OUTsize_*OUTsize_*OUTsize_; if (SIM2D_YN) Size = OUTsize2d_; size_idx SizePosHis = 3 * TIsize2d_; if (SIM2D_YN) SizePosHis = TIsize2d_; size_idx candSize = (blockSize_ / GRID) * (blockSize_ / GRID); //candidate has sparse grid size_idx start = (blockSize_ / (2 * GRID)) + 1; size_idx end = start; size_idx s1 = -blockSize_ * 0.5; size_idx e1 = (blockSize_ - 1) * 0.5; size_idx poshisadd[3] = { 0, TIsize2d_, TIsize2d_ * 2 }; #pragma omp parallel for schedule(static) for (size_idx i2 = 0; i2 < Size; ++i2) { size_idx idx = m_permutation[i2]; //[i][j][k] size_idx i, j, k; idxToCoord(idx, OUTsize_, i, j, k); size_idx iSyz = i*OUTsize2d_, jSz = j*OUTsize_; size_dist weight_acc(FLT_MIN), minweight(max_dist); size_color color_acc = 0.0f, color_avg = 0.0f; size_idx tempx0ori[3] = { (j / GRID) * GRID , (i / GRID) * GRID , (i / GRID) * GRID }; size_idx tempy0ori[3] = { (k / GRID) * GRID , (k / GRID) * GRID , (j / GRID) * GRID }; //discrete solver vector<size_color> colorCand_x(0), colorCand_y(0), colorCand_z(0); colorCand_x.reserve(candSize); colorCand_y.reserve(candSize); colorCand_z.reserve(candSize); vector<size_idx> posCand_x(0), posCand_y(0), posCand_z(0); posCand_x.reserve(candSize); posCand_y.reserve(candSize); posCand_z.reserve(candSize); vector<size_idx> posCand_tinum_x(0), posCand_tinum_y(0), posCand_tinum_z(0); posCand_tinum_x.reserve(candSize); posCand_tinum_y.reserve(candSize); posCand_tinum_z.reserve(candSize); //XY { bool allcontinue(true); int ori = 0; if (SIM2D_YN && ori != 0) continue; for (size_idx l = start; l >= -end; --l) { size_idx tempx = tempx0ori[ori] + l * GRID; size_idx deltaxori[3] = { j - tempx , i - tempx , i - tempx }; size_idx sumidx_tempx, tempidx3d; sumidx_tempx = iSyz + trim(OUTsize_, tempx)*OUTsize_; for (size_idx h = start; h >= -end; --h) { size_idx tempy = tempy0ori[ori] + h * GRID; size_idx deltayori[3] = { k - tempy , k - tempy , j - tempy }; if (deltaxori[ori] < s1 || deltaxori[ori] > e1 || deltayori[ori] < s1 || deltayori[ori] > e1) continue; tempidx3d = sumidx_tempx + trim(OUTsize_, tempy); // get nearestidx_TIs size_idx tempnearestidx_TIs = nearestIdx_x[level][tempidx3d]; size_dist tempnearestweight = nearestWeight_x[level][tempidx3d]; size_idx tempnearestidx_Idxregular, tempnearestidx_TInum; TIsToRegular(tempnearestidx_TIs, TIsize2d_, tempnearestidx_Idxregular, tempnearestidx_TInum); // shift tempnearestidx_Idxregular size_idx coordx = tempnearestidx_Idxregular / TIsize_ + deltaxori[ori]; size_idx coordy = tempnearestidx_Idxregular % TIsize_ + deltayori[ori]; if (coordx < 0 || coordy < 0 || coordx >= TIsize_ || coordy >= TIsize_) continue; allcontinue = false; // get nearestidx2d, color size_idx tempnearestidx_shifted = TIsize_ * coordx + coordy; size_color tempcolor = TIs_XY[level][tempnearestidx_TInum][tempnearestidx_shifted]; size_dist weightc(max_dist), weightp(max_dist); // PosHis weight size_idx tempPosIdx = tempnearestidx_shifted + poshisadd[ori]; size_dist tempHisDiff = max(0.0f, 1.0f*(PosHis[level][tempPosIdx] - avgPosHis[level])); if (enhancelowposYN && (PosHis[level][tempPosIdx] < avgPosHis[level])) { tempHisDiff = PosHis[level][tempPosIdx] - avgPosHis[level]; } weightp = 1.0f / (1.0f + tempHisDiff * posweight[level]); // Color weight if (ColorHis_ON && !FIRSTRUN && factorC>0) { //size_dist coloroffset = max(0.0f, 1.0f * (tempcolor - Solid_Upper[level]) / (Pore_Lower[level] - Solid_Upper[level])); //if (!offsetYN) coloroffset = min(coloroffset, 1.0f); //size_dist tempColorHisDiff = max(0.0f, coloroffset *(poretotal_synthesis - poretotal_required) / poretotal_required); //weightc = 1.0f / (1.0f + tempColorHisDiff * factorC); size_dist tempColorHisDiff = max(0.0f, 1.0f*(ColorHis_synthesis[level][floor(colorhis_compressratio* tempcolor)] - ColorHis_exemplar[level][floor(colorhis_compressratio* tempcolor)])); weightc = 1.0f / (1.0f + tempColorHisDiff * colorweight[level]); } minweight = min(weightc, weightp); // discrete solver colorCand_x.push_back(tempcolor); posCand_x.push_back(tempnearestidx_shifted); posCand_tinum_x.push_back(tempnearestidx_TInum); //// modify weight according to fix layer if (FixedLayerDir > 0 && FixedLayerDir < 3 && FixedLayerDir != ori) minweight *= DirectionalWeight; // accumulate color size_dist weight = tempnearestweight * minweight; //min max limit weight = min(weight, 10.0f); weight = max(weight, 0.02f); color_acc += weight * tempcolor; weight_acc += weight; } } //if (allcontinue) { // printf("\n allcontinue_x: idx=%d, i=%d j=%d k=%d, permutation=%d, outsize=%d", idx, i, j, k, m_permutation[i2], OUTsize_); // idxToCoord(idx, OUTsize_, i, j, k); // printf("\nidx=%d, i=%d j=%d k=%d", idx, i, j, k); // _getch(); //} //if (posCand_x.size() == 0) { // printf("\n posCand_x.size()=0"); // _getch(); //} }//XY //XZ { bool allcontinue(true); int ori = 1; if (!SIM2D_YN) for (size_idx l = start; l >= -end; --l) { size_idx tempx = tempx0ori[ori] + l * GRID; size_idx deltaxori[3] = { j - tempx , i - tempx , i - tempx }; size_idx sumidx_tempx, tempidx3d; sumidx_tempx = trim(OUTsize_, tempx)*OUTsize2d_ + jSz; for (size_idx h = start; h >= -end; --h) { size_idx tempy = tempy0ori[ori] + h * GRID; size_idx deltayori[3] = { k - tempy , k - tempy , j - tempy }; if (deltaxori[ori] < s1 || deltaxori[ori] > e1 || deltayori[ori] < s1 || deltayori[ori] > e1) continue; tempidx3d = sumidx_tempx + trim(OUTsize_, tempy); // get nearestidx_TIs size_idx tempnearestidx_TIs = nearestIdx_y[level][tempidx3d]; size_dist tempnearestweight = nearestWeight_y[level][tempidx3d]; size_idx tempnearestidx_Idxregular, tempnearestidx_TInum; TIsToRegular(tempnearestidx_TIs, TIsize2d_, tempnearestidx_Idxregular, tempnearestidx_TInum); // shift tempnearestidx_Idxregular size_idx coordx = tempnearestidx_Idxregular / TIsize_ + deltaxori[ori]; size_idx coordy = tempnearestidx_Idxregular % TIsize_ + deltayori[ori]; if (coordx < 0 || coordy < 0 || coordx >= TIsize_ || coordy >= TIsize_) continue; allcontinue = false; // get nearestidx2d, color size_idx tempnearestidx_shifted = TIsize_ * coordx + coordy; size_color tempcolor = TIs_XZ[level][tempnearestidx_TInum][tempnearestidx_shifted]; size_dist weightc(max_dist), weightp(max_dist); // PosHis weight size_idx tempPosIdx = tempnearestidx_shifted + poshisadd[ori]; size_dist tempHisDiff = max(0.0f, 1.0f*(PosHis[level][tempPosIdx] - avgPosHis[level])); if (enhancelowposYN && (PosHis[level][tempPosIdx] < avgPosHis[level])) { tempHisDiff = 1.0f*(PosHis[level][tempPosIdx] - avgPosHis[level]); } weightp = 1.0f / (1.0f + tempHisDiff * posweight[level]); // Color weight if (ColorHis_ON && !FIRSTRUN && factorC>0) { //size_dist coloroffset = max(0.0f, 1.0f * (tempcolor - Solid_Upper[level]) / (Pore_Lower[level] - Solid_Upper[level])); //if (!offsetYN) coloroffset = min(coloroffset, 1.0f); //size_dist tempColorHisDiff = max(0.0f, coloroffset *(poretotal_synthesis - poretotal_required) / poretotal_required); //weightc = 1.0f / (1.0f + tempColorHisDiff * factorC); size_dist tempColorHisDiff = max(0.0f, 1.0f*(ColorHis_synthesis[level][floor(colorhis_compressratio* tempcolor)] - ColorHis_exemplar[level][floor(colorhis_compressratio* tempcolor)])); weightc = 1.0f / (1.0f + tempColorHisDiff * colorweight[level]); } minweight = min(weightc, weightp); // discrete solver colorCand_y.push_back(tempcolor); posCand_y.push_back(tempnearestidx_shifted); posCand_tinum_y.push_back(tempnearestidx_TInum); //// modify weight according to fix layer if (FixedLayerDir > 0 && FixedLayerDir < 3 && FixedLayerDir != ori) minweight *= DirectionalWeight; // accumulate color size_dist weight = tempnearestweight * minweight; //min max limit weight = min(weight, 10.0f); weight = max(weight, 0.02f); color_acc += weight * tempcolor; weight_acc += weight; } } //if (allcontinue) { // printf("\n allcontinue_y: idx=%d, i=%d j=%d k=%d, permutation=%d, outsize=%d", idx, i, j, k, m_permutation[i2], OUTsize_); // idxToCoord(idx, OUTsize_, i, j, k); // printf("\nidx=%d, i=%d j=%d k=%d", idx, i, j, k); // _getch(); //} //if (posCand_y.size() == 0) { // printf("\n posCand_y.size()=0"); // _getch(); //} }//XZ //YZ { bool allcontinue(true); int ori = 2; if (!SIM2D_YN) for (size_idx l = start; l >= -end; --l) { size_idx tempx = tempx0ori[ori] + l * GRID; size_idx deltaxori[3] = { j - tempx , i - tempx , i - tempx }; size_idx sumidx_tempx, tempidx3d; sumidx_tempx = trim(OUTsize_, tempx)*OUTsize2d_ + k; for (size_idx h = start; h >= -end; --h) { size_idx tempy = tempy0ori[ori] + h * GRID; size_idx deltayori[3] = { k - tempy , k - tempy , j - tempy }; if (deltaxori[ori] < s1 || deltaxori[ori] > e1 || deltayori[ori] < s1 || deltayori[ori] > e1) continue; tempidx3d = sumidx_tempx + trim(OUTsize_, tempy)*OUTsize_; // get nearestidx_TIs size_idx tempnearestidx_TIs = nearestIdx_z[level][tempidx3d]; size_dist tempnearestweight = nearestWeight_z[level][tempidx3d]; size_idx tempnearestidx_Idxregular, tempnearestidx_TInum; TIsToRegular(tempnearestidx_TIs, TIsize2d_, tempnearestidx_Idxregular, tempnearestidx_TInum); // shift tempnearestidx_Idxregular size_idx coordx = tempnearestidx_Idxregular / TIsize_ + deltaxori[ori]; size_idx coordy = tempnearestidx_Idxregular % TIsize_ + deltayori[ori]; if (coordx < 0 || coordy < 0 || coordx >= TIsize_ || coordy >= TIsize_) continue; allcontinue = false; // get nearestidx2d, color size_idx tempnearestidx_shifted = TIsize_ * coordx + coordy; size_color tempcolor = TIs_YZ[level][tempnearestidx_TInum][tempnearestidx_shifted]; size_dist weightc(max_dist), weightp(max_dist); // PosHis weight size_idx tempPosIdx = tempnearestidx_shifted + poshisadd[ori]; size_dist tempHisDiff = max(0.0f, 1.0f*(PosHis[level][tempPosIdx] - avgPosHis[level])); if (enhancelowposYN && (PosHis[level][tempPosIdx] < avgPosHis[level])) { tempHisDiff = 1.0f*(PosHis[level][tempPosIdx] - avgPosHis[level]); } weightp = 1.0f / (1.0f + tempHisDiff * posweight[level]); // Color weight if (ColorHis_ON && !FIRSTRUN && factorC>0) { //size_dist coloroffset = max(0.0f, 1.0f * (tempcolor - Solid_Upper[level]) / (Pore_Lower[level] - Solid_Upper[level])); //if (!offsetYN) coloroffset = min(coloroffset, 1.0f); //size_dist tempColorHisDiff = max(0.0f, coloroffset *(poretotal_synthesis - poretotal_required) / poretotal_required); //weightc = 1.0f / (1.0f + tempColorHisDiff * factorC); size_dist tempColorHisDiff = max(0.0f, 1.0f*(ColorHis_synthesis[level][floor(colorhis_compressratio* tempcolor)] - ColorHis_exemplar[level][floor(colorhis_compressratio* tempcolor)])); weightc = 1.0f / (1.0f + tempColorHisDiff * colorweight[level]); } minweight = min(weightc, weightp); // discrete solver colorCand_z.push_back(tempcolor); posCand_z.push_back(tempnearestidx_shifted); posCand_tinum_z.push_back(tempnearestidx_TInum); //// modify weight according to fix layer if (FixedLayerDir > 0 && FixedLayerDir < 3 && FixedLayerDir != ori) minweight *= DirectionalWeight; // accumulate color size_dist weight = tempnearestweight * minweight; //min max limit weight = min(weight, 10.0f); weight = max(weight, 0.02f); color_acc += weight * tempcolor; weight_acc += weight; } } //if (allcontinue) { // printf("\n allcontinue_z: idx=%d, i=%d j=%d k=%d, permutation=%d, outsize=%d", idx, i, j, k, m_permutation[i2], OUTsize_); // idxToCoord(idx, OUTsize_, i, j, k); // printf("\nidx=%d, i=%d j=%d k=%d", idx, i, j, k); // _getch(); //} //if (posCand_z.size() == 0) { // printf("\n posCand_z.size()=0"); // _getch(); //} }//YZ // least solver color_avg = 1.0f * color_acc / weight_acc; // discrete solver size_dist minDis_x(10e7), minDis_y(10e7), minDis_z(10e7); size_idx closestIdx_x(0), closestIdx_y(0), closestIdx_z(0), closestIdx_tinum_x(0), closestIdx_tinum_y(0), closestIdx_tinum_z(0); int bestorder(0); // pointers vector<size_hiscount> *indexhis[3] = { &IndexHis_x[level], &IndexHis_y[level], &IndexHis_z[level] }; vector<size_idx> *origin[3] = { &Origin_x[level], &Origin_y[level], &Origin_z[level] }; vector<bool> *isunchanged[3] = { &isUnchanged_x[level], &isUnchanged_y[level], &isUnchanged_z[level] }; size_dist *mindis[3] = { &minDis_x, &minDis_y , &minDis_z }; size_idx *closestidx[3] = { &closestIdx_x , &closestIdx_y , &closestIdx_z }; size_idx *closestidx_tinum[3] = { &closestIdx_tinum_x, &closestIdx_tinum_y, &closestIdx_tinum_z }; vector<size_color> *colorcand[3] = { &colorCand_x , &colorCand_y, &colorCand_z }; vector<size_idx> *poscand[3] = { &posCand_x , &posCand_y, &posCand_z }; vector<size_idx> *poscand_tinum[3] = { &posCand_tinum_x , &posCand_tinum_y, &posCand_tinum_z }; // update origin, isUnchangeblock (add tempnearestidx_TInum) for (int ori = 0; ori < 3; ori++) { if (SIM2D_YN && ori != 0) continue; bestorder = 0; for (int s = 0; s < (*poscand[ori]).size(); s++) { size_dist tempColorDiff = fabs((*colorcand[ori])[s] - color_avg); if (tempColorDiff < *mindis[ori]) { *mindis[ori] = tempColorDiff; bestorder = s; } else if (tempColorDiff - *mindis[ori] < 1e-5) { //if colordiff same, compare PosHis, then IndexHis if (PosHis[level][(*poscand[ori])[s] + poshisadd[ori]] < PosHis[level][(*poscand[ori])[bestorder] + poshisadd[ori]]) bestorder = s; else if (PosHis[level][(*poscand[ori])[s] + poshisadd[ori]] == PosHis[level][(*poscand[ori])[bestorder] + poshisadd[ori]] && (*indexhis[ori])[sparseIdx_TIs(level, (*poscand[ori])[s])] < (*indexhis[ori])[sparseIdx_TIs(level, bestorder)]) bestorder = s; } } *closestidx[ori] = (*poscand[ori])[bestorder]; *closestidx_tinum[ori] = (*poscand_tinum[ori])[bestorder]; // add tempnearestidx_TInum to update origin, isUnchangeblock size_idx closestidx_TIs = *closestidx[ori] + (*closestidx_tinum[ori]) * TIsize2d_; if ((*origin[ori])[idx] != closestidx_TIs) { (*origin[ori])[idx] = closestidx_TIs; (*isunchanged[ori])[idx] = false; } else (*isunchanged[ori])[idx] = true; //if ((*origin[ori])[idx] >= MultiTIsNum*TIsize2d_) { // printf("\noptimize: origin[%d][%d]=%d, close[ti%d][idx%d] best[%d]", ori, idx, (*origin[ori])[idx], (*poscand_tinum[ori])[bestorder], (*poscand[ori])[bestorder], bestorder); // _getch(); //} }//for (int ori = 0; ori < 3; ori++) // update color, pos size_color newcolor(0); size_idx newPos(0); //PosHis size = 3TI if (minDis_x <= minDis_y && minDis_x < minDis_z) { if (closestIdx_tinum_x >= MultiTIsNum || closestIdx_tinum_x < 0 || closestIdx_x<0 || closestIdx_x>=TIsize2d_) { printf("\nclosestIdx_tinum_x= %d, closestIdx_x= %d", closestIdx_tinum_x, closestIdx_x); } newcolor = TIs_XY[level][closestIdx_tinum_x][closestIdx_x]; newPos = closestIdx_x; // TI*0+Pos_x } else if (minDis_y <= minDis_z && minDis_y < minDis_x) { if (closestIdx_tinum_y >= MultiTIsNum || closestIdx_tinum_y < 0 || closestIdx_y<0 || closestIdx_y >= TIsize2d_) { printf("\nclosestIdx_tinum_y= %d, closestIdx_y= %d", closestIdx_tinum_y, closestIdx_y); } newcolor = TIs_XZ[level][closestIdx_tinum_y][closestIdx_y]; newPos = TIsize2d_ + closestIdx_y; // TI*1+Pos_y } else if (minDis_z <= minDis_x && minDis_z < minDis_y) { if (closestIdx_tinum_z >= MultiTIsNum || closestIdx_tinum_z < 0 || closestIdx_z<0 || closestIdx_z >= TIsize2d_) { printf("\nclosestIdx_tinum_z= %d, closestIdx_z= %d", closestIdx_tinum_z, closestIdx_z); } newcolor = TIs_YZ[level][closestIdx_tinum_z][closestIdx_z]; newPos = TIsize2d_ * 2 + closestIdx_z; // TI*2+Pos_z } else { // if minDis_z==minDis_y==minDis_x rand. if (closestIdx_tinum_x >= MultiTIsNum || closestIdx_tinum_x < 0 || closestIdx_x<0 || closestIdx_x >= TIsize2d_) { printf("\nclosestIdx_tinum_x= %d, closestIdx_x= %d", closestIdx_tinum_x, closestIdx_x); } if (closestIdx_tinum_y >= MultiTIsNum || closestIdx_tinum_y < 0 || closestIdx_y<0 || closestIdx_y >= TIsize2d_) { printf("\nclosestIdx_tinum_y= %d, closestIdx_y= %d", closestIdx_tinum_y, closestIdx_y); } if (closestIdx_tinum_z >= MultiTIsNum || closestIdx_tinum_z < 0 || closestIdx_z<0 || closestIdx_z >= TIsize2d_) { printf("\nclosestIdx_tinum_z= %d, closestIdx_z= %d", closestIdx_tinum_z, closestIdx_z); } switch (rand() % 3){ case(0) : newcolor = TIs_XY[level][closestIdx_tinum_x][closestIdx_x]; newPos = closestIdx_x; break; case(1) : newcolor = TIs_XZ[level][closestIdx_tinum_y][closestIdx_y]; newPos = TIsize2d_ + closestIdx_y; break; case(2) : newcolor = TIs_YZ[level][closestIdx_tinum_z][closestIdx_z]; newPos = TIsize2d_ * 2 + closestIdx_z; break; } } // update poshis size_idx formerPos = SelectedPos[level][idx]; size_hiscount& addressformerPos = PosHis[level][formerPos]; if (formerPos < SizePosHis && formerPos >= 0 && addressformerPos>0) #pragma omp atomic addressformerPos--; size_hiscount& addressnewPos = PosHis[level][newPos]; #pragma omp atomic addressnewPos++; // update SelectedPos SelectedPos[level][idx] = newPos; //update colorhis if (ColorHis_ON && !FIRSTRUN) { // if (m_volume[level][idx] <= Solid_Upper[level] && newcolor > Solid_Upper[level]) //#pragma omp atomic // poretotal_synthesis++; // else if (m_volume[level][idx] > Solid_Upper[level] && newcolor <= Solid_Upper[level]) // if (poretotal_synthesis>0) //#pragma omp atomic // poretotal_synthesis--; size_hiscount& addressfomerColor = ColorHis_synthesis[level][floor(colorhis_compressratio* m_volume[level][idx])]; // update ColorHis if (addressfomerColor>0) #pragma omp atomic addressfomerColor--; size_hiscount& addressnewColor = ColorHis_synthesis[level][floor(colorhis_compressratio* newcolor)]; #pragma omp atomic addressnewColor++; } // update m_volume m_volume[level][idx] = newcolor; }//for (size_idx i2 = 0; i2 < Size; ++i2) //if (!FIRSTRUN && ColorHis_ON && (HisEqYN || level == MULTIRES-1) && poretotal_required>0) // printf("loss=%d ", 100*(poretotal_synthesis - poretotal_required) / poretotal_required); if (FIRSTRUN) { if (ColorHis_ON) initColorHis_synthesis(level); FIRSTRUN = false; } } // ========= Color Histogram for optimize step ======= void DoPAR::initColorHis_exemplar() { for (int level = 0; level < MULTIRES; level++) { size_idx Size2d = TIsize[level] * TIsize[level]; size_idx Size3d = TIsize[level] * TIsize[level] * TIsize[level]; ColorHis_exemplar[level].resize(ColorHis_BinNum, 0); for (int n = 0; n < MultiTIsNum; n++) { vector<size_color>* p[3] = { &TIs_XY[level][n], &TIs_XZ[level][n], &TIs_YZ[level][n] }; for (int ori = 0; ori < 3; ++ori) { for (size_idx i = 0; i < Size2d; ++i) { size_color c = (*p[ori])[i]; ColorHis_exemplar[level][floor(c*colorhis_compressratio)] ++; } } } int actualBinNum = 0; for (int bin = 0; bin < ColorHis_BinNum; bin++) { if (ColorHis_exemplar[level][bin] >0) actualBinNum++; } cout << endl << "actualBinNum at level"<< level <<" = " << actualBinNum << " / "<< ColorHis_BinNum; //!!!need to rescale to fit ColorHis_synthesis!!! float factor = Size3d*1.0f / (3 * Size2d * MultiTIsNum); for (int bin = 0; bin < ColorHis_BinNum; bin++) { ColorHis_exemplar[level][bin] = ceil(ColorHis_exemplar[level][bin]*factor); if (ColorHis_exemplar[level][bin]>0) ColorHis_exemplar[level][bin] -= 1; //similar to IndexHis,PosHis } } } void DoPAR::initColorHis_synthesis(int level) { ColorHis_synthesis[level].resize(ColorHis_BinNum, 0L); size_idx Size3d = OUTsize[level] * OUTsize[level] * OUTsize[level]; for (size_idx i = 0; i < Size3d; i++) { ColorHis_synthesis[level][floor(m_volume[level][i]*colorhis_compressratio)]++; } } // ================ output ==================== void DoPAR::crop3Dmodel(int level, int cropl, vector<uchar>&model) { assert(pow(model.size(), 1.0 / 3.0) == OUTsize[level]); size_idx OUTsize_ = OUTsize[level], idx, tempidxi, tempidxij; size_idx Sx = 1; if (!SIM2D_YN) Sx = OUTsize_; size_idx croppedsize = (OUTsize_ - 2 * cropl)*(OUTsize_ - 2 * cropl)*max(1L, Sx - 2 * cropl); vector<uchar> tempoutput; tempoutput.resize(croppedsize); size_idx n = 0; for (int i = 0; i < Sx; i++) { if (!SIM2D_YN && (i<cropl || i>Sx - cropl - 1)) continue; tempidxi = i* OUTsize_*OUTsize_; for (int j = 0; j < OUTsize_; j++) { if (j<cropl || j>OUTsize_ - cropl - 1) continue; tempidxij = tempidxi + j * OUTsize_; for (int k = 0; k < OUTsize_; k++) { if (k<cropl || k>OUTsize_ - cropl - 1) continue; idx = tempidxij + k; tempoutput[n++] = model[idx]; } } } assert(n == croppedsize); swap(tempoutput, model); } void DoPAR::outputmodel(int level) { // Print Histogram if (PrintHisYN && level == MULTIRES - 1) writeHistogram(level); //!! Crop model vector<uchar> tempUchar(m_volume[level].begin(), m_volume[level].end()); string tempoutputfilename; size_idx OUTsize_ = OUTsize[level]; if (cropYN && level == MULTIRES - 1) { int cropl = pow(2, level - 1)* blockSize[0]; crop3Dmodel(level, cropl, tempUchar); OUTsize_ = OUTsize_ - 2 * cropl; } // Print model if (SIM2D_YN) { Mat tempM = Mat(OUTsize_, OUTsize_, CV_8UC1); string nonrepeatFPName; if (DMtransformYN) { tempoutputfilename = outputfilename + parameterstring + "_Size" + to_string(OUTsize_) + "DM.png"; int i(1); nonrepeatFPName = tempoutputfilename; while (fileExists(nonrepeatFPName) == true) { nonrepeatFPName = tempoutputfilename.substr(0, tempoutputfilename.find('.')) + "_" + to_string(i) + ".png"; i++; } tempM = Mat(tempUchar, true).reshape(1, tempM.rows); if (KeepParameterNameYN) imwrite(outputpath + nonrepeatFPName, tempM); // binarization binaryUchar(tempUchar, (Solid_Upper[level] + Pore_Lower[level]) / 2); } tempM = Mat(tempUchar, true).reshape(1, tempM.rows); int i = 1; tempoutputfilename = outputfilename + parameterstring + "_Size" + to_string(OUTsize_) + ".png"; nonrepeatFPName = tempoutputfilename; while (fileExists(nonrepeatFPName) == true) { nonrepeatFPName = tempoutputfilename.substr(0, tempoutputfilename.find('.')) + "_" + to_string(i) + ".png"; i++; } imwrite(outputpath + nonrepeatFPName, tempM); } else {//3D if (DMtransformYN) { tempoutputfilename = outputfilename + parameterstring + "_Size" + to_string(OUTsize_) + "DM.RAW"; if (KeepParameterNameYN) Write(outputpath + tempoutputfilename, tempUchar); // binarization binaryUchar(tempUchar, (Solid_Upper[level] + Pore_Lower[level]) / 2); } if (level == MULTIRES - 1) tempoutputfilename = outputfilename + parameterstring + ".RAW"; else tempoutputfilename = outputfilename + parameterstring + "_Size" + to_string(OUTsize_) + ".RAW"; Write(outputpath + tempoutputfilename, tempUchar); } cout << endl << "Output@" << outputpath + tempoutputfilename << " size=" << OUTsize_; } void DoPAR::writeHistogram(int level) { size_idx OUTsize_ = OUTsize[level]; size_idx TIsize_ = TIsize[level]; size_idx blockSize_ = blockSize[level]; size_idx TIsize2d_ = TIsize_*TIsize_; size_idx OUTsize2d_ = OUTsize_*OUTsize_; size_idx Sx = OUTsize_; if (SIM2D_YN) Sx = 1; int cropedIndexHisStartX = blockSize_ * 0.25; int cropedIndexHisWidth = TIsize_ / 2 - blockSize_ / 2 + 1; int cropedIndexHisStartY = blockSize_ * 0.25; int cropedIndexHisHeight = TIsize_ / 2 - blockSize_ / 2 + 1; int cropedPosHisStartX = 1; int cropedPosHisWidth = TIsize_ - 2; int cropedPosHisStartY = 1; int cropedPosHisHeight = TIsize_ - 2; if (true) { cropedIndexHisStartX = 0; cropedIndexHisWidth = TIsize_ / 2; cropedIndexHisStartY = 0; cropedIndexHisHeight = TIsize_ / 2; cropedPosHisStartX = 0; cropedPosHisWidth = TIsize_; cropedPosHisStartY = 0; cropedPosHisHeight = TIsize_; } size_idx idx_i, idx_j, idx3d, idx2d; Mat tempMat; ostringstream name; string outputMainFileName = outputfilename.substr(0, outputfilename.find('.')); unsigned short deltaIndexCount(1), deltaPosCount(1); vector<unsigned short> Index_x, Index_y, Index_z; Index_x.resize(TIsize2d_, 0); Index_y.resize(TIsize2d_, 0); Index_z.resize(TIsize2d_, 0); vector<unsigned short> pos_x, pos_y, pos_z; pos_x.resize(TIsize2d_, 0); pos_y.resize(TIsize2d_, 0); pos_z.resize(TIsize2d_, 0); // -----------indexhis name.str(""); tempMat = Mat(TIsize_ * 0.5, TIsize_ * 0.5, CV_16UC1); vector<unsigned short> tempIHx = vector<unsigned short>(IndexHis_x[level].begin(), IndexHis_x[level].end()); tempMat = Mat(tempIHx, true).reshape(1, tempMat.rows); Mat cropedIndexHisMat_x = tempMat(Rect(cropedIndexHisStartX, cropedIndexHisStartY, cropedIndexHisWidth, cropedIndexHisHeight)); name << outputMainFileName << "_x" << "_IndexHis_L" << level << ".png"; string tempname = name.str(); int i(1); while (fileExists(tempname) == true) { tempname = tempname.substr(0, tempname.find('.')) + "_" + to_string(i) + ".png"; i++; } if (SIM2D_YN) imwrite(tempname, cropedIndexHisMat_x); //must be unsigned [short]! if (!SIM2D_YN) { name.str(""); tempMat = Mat(TIsize_ * 0.5, TIsize_ * 0.5, CV_16UC1); vector<unsigned short> tempIHy = vector<unsigned short>(IndexHis_y[level].begin(), IndexHis_y[level].end()); tempMat = Mat(tempIHy, true).reshape(1, tempMat.rows); Mat cropedIndexHisMat_y = tempMat(Rect(cropedIndexHisStartX, cropedIndexHisStartY, cropedIndexHisWidth, cropedIndexHisHeight)); //name << outputMainFileName << "_y" << "_IndexHis_L" << level << ".png"; //tempname = name.str(); //i = 1; //while (fileExists(tempname) == true) { // tempname = tempname.substr(0, tempname.find('.')) + "_" + to_string(i) + ".png"; // i++; //} //imwrite(name.str(), cropedIndexHisMat_y); name.str(""); tempMat = Mat(TIsize_ * 0.5, TIsize_ * 0.5, CV_16UC1); vector<unsigned short> tempIHz = vector<unsigned short>(IndexHis_z[level].begin(), IndexHis_z[level].end()); tempMat = Mat(tempIHz, true).reshape(1, tempMat.rows); Mat cropedIndexHisMat_z = tempMat(Rect(cropedIndexHisStartX, cropedIndexHisStartY, cropedIndexHisWidth, cropedIndexHisHeight)); //name << outputMainFileName << "_z" << "_IndexHis_L" << level << ".png"; //tempname = name.str(); //i = 1; //while (fileExists(tempname) == true) { // tempname = tempname.substr(0, tempname.find('.')) + "_" + to_string(i) + ".png"; // i++; //} //imwrite(name.str(), cropedIndexHisMat_z); name.str(""); name << outputMainFileName << parameterstring << "_L" << level << "_IndexHis_merged.png"; tempname = name.str(); i = 1; while (fileExists(tempname) == true) { tempname = tempname.substr(0, tempname.find('.')) + "_" + to_string(i) + ".png"; i++; } tempMat = (cropedIndexHisMat_x + cropedIndexHisMat_y + cropedIndexHisMat_z) / 3; //! crop enlarged output model! if (cropYN) { int cropl = pow(2, level - 1)* blockSize[0]; int cropped = OUTsize_ - 2 * cropl; tempMat *= 1.0*(cropped*cropped*cropped) / (OUTsize_*OUTsize_*OUTsize_); } imwrite(name.str(), tempMat); } // -----------poshis int cropl = pow(2, level - 1)* blockSize[0]; for (size_idx i = 0; i < Sx; i += 1) { //PosHis not sparsed //! crop enlarged output model! if (cropYN) if (i<cropl || i>OUTsize_ - cropl - 1) continue; idx_i = i*OUTsize2d_; for (size_idx j = 0; j < OUTsize_; j += 1) { if (cropYN) if (j<cropl || j>OUTsize_ - cropl - 1) continue; idx_j = j*OUTsize_; for (size_idx k = 0; k < OUTsize_; k += 1) { if (cropYN) if (k<cropl || k>OUTsize_ - cropl - 1) continue; idx3d = idx_i + idx_j + k; idx2d = SelectedPos[level][idx3d]; if (idx2d < TIsize2d_) { pos_x[idx2d] += deltaPosCount; //X } else if (idx2d < 2 * TIsize2d_) { pos_y[idx2d - TIsize2d_] += deltaPosCount; //Y } else if (idx2d < 3 * TIsize2d_) { pos_z[idx2d - 2 * TIsize2d_] += deltaPosCount; //Z } } } } name.str(""); tempMat = Mat(TIsize_, TIsize_, CV_16UC1); tempMat = Mat(pos_x, true).reshape(1, tempMat.rows); Mat cropedPosHisMat_x = tempMat(Rect(cropedPosHisStartX, cropedPosHisStartY, cropedPosHisWidth, cropedPosHisHeight)); name << outputMainFileName << "_x" << "_PosHis_L" << level << ".png"; tempname = name.str(); i = 1; while (fileExists(tempname) == true) { tempname = tempname.substr(0, tempname.find('.')) + "_" + to_string(i) + ".png"; i++; } if (SIM2D_YN/* || (FNameXY == FNameXZ && FNameXY == FNameYZ)*/) imwrite(tempname, cropedPosHisMat_x); if (!SIM2D_YN/* && !(FNameXY == FNameXZ && FNameXY == FNameYZ)*/) { name.str(""); tempMat = Mat(TIsize_, TIsize_, CV_16UC1); tempMat = Mat(pos_y, true).reshape(1, tempMat.rows); Mat cropedPosHisMat_y = tempMat(Rect(cropedPosHisStartX, cropedPosHisStartY, cropedPosHisWidth, cropedPosHisHeight)); //name << outputMainFileName << "_y" << "_PosHis_L" << level << ".png"; //tempname = name.str(); //i = 1; //while (fileExists(tempname) == true) { // tempname = tempname.substr(0, tempname.find('.')) + "_" + to_string(i) + ".png"; // i++; //} //imwrite(name.str(), cropedPosHisMat_y); name.str(""); tempMat = Mat(TIsize_, TIsize_, CV_16UC1); tempMat = Mat(pos_z, true).reshape(1, tempMat.rows); Mat cropedPosHisMat_z = tempMat(Rect(cropedPosHisStartX, cropedPosHisStartY, cropedPosHisWidth, cropedPosHisHeight)); //name << outputMainFileName << "_z" << "_PosHis_L" << level << ".png"; //tempname = name.str(); //i = 1; //while (fileExists(tempname) == true) { // tempname = tempname.substr(0, tempname.find('.')) + "_" + to_string(i) + ".png"; // i++; //} //imwrite(name.str(), cropedPosHisMat_z); name.str(""); tempMat = (cropedPosHisMat_x + cropedPosHisMat_y + cropedPosHisMat_z); name << outputMainFileName << parameterstring << "_L" << level << "_PosHis_merged.png"; tempname = name.str(); i = 1; while (fileExists(tempname) == true) { tempname = tempname.substr(0, tempname.find('.')) + "_" + to_string(i) + ".png"; i++; } imwrite(name.str(), tempMat); } cout << endl << "croped Histograms are plotted."; }
C++
CL
ff790cbc8cef6ef96be7657d0db5df34a2c03214467efd6526c8c03cd2beef68
/** \file glow2.cpp * \brief A series-parallel-series of switches should be closed for a light * bulb to glow. * * \details Same logic as glow.cpp but it introduces some standard algorithms * although it still is not as efficient as glow.cpp. Also have range- * based for loops which are superior in that the indexes are unnecessary. * Reads somewhat logically because following the end of each loop is check * for "all_of" in the case of serial switches and "any_of" in the case of * parallel switches. The breaks in the interior serial and parallel loops * save a great deal of time especially as the number of switches per layer * increases. The deque was introduced because the vector<bool> is a special * bit-oriented implementation that cannot be set as reference in the range- * based for loop. */ // glow2.cpp #include <random> #include <iostream> #include <algorithm> #include <deque> #include <val/montecarlo/Chronology.h> class Switches { public: std::deque<bool> switch_closed; public: explicit Switches(long nr_switches) { for ( int ix = 0; ix < nr_switches; ++ix ) switch_closed.push_back(false); } }; int main(int argc, char* argv[]) { if ( argc != 3 ) { std::cout << "usage: ./a <nr_switches_per_layer> <prob_closed>\n"; return 1; } long nr_switch_per_layer = std::strtol(argv[1], nullptr, 10); double prob_switch_closed = std::strtod(argv[2], nullptr); int nr_trials = 1'000'000; int nr_glows = 0; std::default_random_engine dre; std::uniform_real_distribution<double> uniform_dist_over_1(0.0,1.0); Switches exterior_series_switches(nr_switch_per_layer); Switches parallel_switches(nr_switch_per_layer); Switches interior_series_switches(nr_switch_per_layer); StopWatch sw; for ( int i = 0; i < nr_trials; ++i ) { for ( bool& exterior_switch : exterior_series_switches.switch_closed ) // series { for ( bool& parallel_switch : parallel_switches.switch_closed ) // parallel { for (bool& interior_switch : interior_series_switches.switch_closed ) { auto switch_instance = uniform_dist_over_1(dre); interior_switch = switch_instance <= prob_switch_closed; if ( !interior_switch ) break; } parallel_switch = std::all_of(interior_series_switches.switch_closed.begin(), interior_series_switches.switch_closed.end(), [](bool val) { return val; } ); if ( parallel_switch ) break; // break because it is a parallel component } exterior_switch = std::any_of(parallel_switches.switch_closed.begin(), parallel_switches.switch_closed.end(), [](bool val) { return val; } ); } if ( std::all_of(exterior_series_switches.switch_closed.begin(), exterior_series_switches.switch_closed.end(), [](bool val) { return val;} ) ) ++nr_glows; } std::cout << "number of times that light glows = " << nr_glows << '\n'; std::cout << "prob of light glowing = " << static_cast<double>(nr_glows) / static_cast<double>(nr_trials) << '\n'; sw.stop(); return 0; }
C++
CL
d8716352383addc3383c818eabeaae5125438744ce94e77fcf7cdae2809c7594
#ifndef MINIMIZEFCNAXIALVECTOR_CALCULATE_PENALTY_TERM_H #define MINIMIZEFCNAXIALVECTOR_CALCULATE_PENALTY_TERM_H void MinimizeFCNAxialVector::calculate_penalty_term(double& penalty_term_ret, const std::vector<double> &param) const { // penalty terms section double penalty_term = 0.0; // loop over all the parameters std::map<int, file_parameter>::iterator it{g_pg.file_params.begin()}; for(; it != g_pg.file_params.end(); ++ it) { int paramNumberInt = -1; int paramNumber = it->second.paramNumber; bool paramEnabled = it->second.paramEnabled; bool paramEnabledP1 = it->second.paramEnabledP1; bool paramEnabledP2 = it->second.paramEnabledP2; double paramInitValue = it->second.paramInitValue; double paramInitError = it->second.paramInitError; double paramConstraintValue = it->second.paramConstraintValue; double paramConstraintError = it->second.paramConstraintError; int paramConstraintMode = it->second.paramConstraintMode; // stop it crashing // (below) if(paramEnabled == false) { continue; } // ignore parameter if it is of background type and FORCE_BKG_HARD // is set if(FORCE_BKG_HARD == true) { if(paramNumber > 1) { continue; } } paramNumberInt = g_pg.ExtToIntParamNumberMap.at(paramNumber); if(debuglevel >= 5) { std::cout << "paramNumber=" << paramNumber << " -> " << paramNumberInt << std::endl; } if(paramEnabled == true) { if((paramEnabledP1 == true) || (paramEnabledP2 == true)) { // do nothing } else { // not enabled continue; } } else { // not enabled continue; } if(paramConstraintMode == MODE_CONSTRAINT_SOFT) { if(debuglevel >= 6) { std::cout << "soft" << std::endl; } // do nothing } else if(paramConstraintMode == MODE_CONSTRAINT_FREE) { //-- ndf; if(debuglevel >= 6) { std::cout << "free" << std::endl; } continue; } else if(paramConstraintMode == MODE_CONSTRAINT_HARD) { if(debuglevel >= 6) { std::cout << "hard" << std::endl; } continue; } else { std::cout << "ERROR: Invalid value for paramNumber=" << paramNumber << ", paramConstraintMode=" << paramConstraintMode << std::endl; } // this parameter is from minuit internal and thus is in minuit // internal units (not Bq) // have to convert to Bq units double param_value = param.at(paramNumberInt); // TODO this might break if we try to fit P1 seperatly and P2 seperatly double activity_value_Bq = paramInitValue; // convert to Bq // multiply by the initial value // activity_value_Bq should really be called param_initial_value //double activity_value_Bq = 0.0; //double tmp_err; //get_paramInitValueError(thePhase, i, activity_value_Bq, tmp_err); double value = param_value * activity_value_Bq; //double penalty = std::pow((param_value - constraint) / error, 2.0); double penalty = 0.0; // TODO /* if(EMODE == 1) { // data } else if(EMODE == 2) { // MC } else if(EMODE == 3) { // quadrature } */ penalty = std::pow((value - paramConstraintValue) / paramConstraintError, 2.0); if(debuglevel >= 5) { //std::cout << "j=" << j << std::endl; std::cout << "paramNumber=" << paramNumber << " value=" << value << " param_value=" << param_value << " paramConstraintValue=" << paramConstraintValue << " paramConstraintError=" << paramConstraintError << " penalty=" << penalty << std::endl; } // TODO: is this the correct error term? // error on constraint rather than error on current fit value? penalty_term += penalty; } penalty_term_ret = penalty_term; } #endif // MINIMIZEFCNAXIALVECTOR_CALCULATE_PENALTY_TERM_H
C++
CL
d3bd5a7cc62601a78154eb60cb43dbd11dd5c0e0cf65075f51f84b5b400b8e3a
/** * Adobe Experience Manager OSGI config (AEM) API * Swagger AEM OSGI is an OpenAPI specification for Adobe Experience Manager (AEM) OSGI Configurations API * * OpenAPI spec version: 1.0.0-pre.0 * Contact: opensource@shinesolutions.com * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ /* * OAIComAdobeFdFpConfigFormsPortalDraftsandSubmissionConfigServiceProperties.h * * */ #ifndef OAIComAdobeFdFpConfigFormsPortalDraftsandSubmissionConfigServiceProperties_H_ #define OAIComAdobeFdFpConfigFormsPortalDraftsandSubmissionConfigServiceProperties_H_ #include <QJsonObject> #include "OAIOAIConfigNodePropertyArray.h" #include "OAIOAIConfigNodePropertyString.h" #include "OAIObject.h" namespace OpenAPI { class OAIComAdobeFdFpConfigFormsPortalDraftsandSubmissionConfigServiceProperties: public OAIObject { public: OAIComAdobeFdFpConfigFormsPortalDraftsandSubmissionConfigServiceProperties(); OAIComAdobeFdFpConfigFormsPortalDraftsandSubmissionConfigServiceProperties(QString json); ~OAIComAdobeFdFpConfigFormsPortalDraftsandSubmissionConfigServiceProperties(); void init(); void cleanup(); QString asJson () override; QJsonObject asJsonObject() override; void fromJsonObject(QJsonObject json) override; OAIComAdobeFdFpConfigFormsPortalDraftsandSubmissionConfigServiceProperties* fromJson(QString jsonString) override; OAIConfigNodePropertyArray* getPortalOutboxes(); void setPortalOutboxes(OAIConfigNodePropertyArray* portal_outboxes); OAIConfigNodePropertyString* getDraftDataService(); void setDraftDataService(OAIConfigNodePropertyString* draft_data_service); OAIConfigNodePropertyString* getDraftMetadataService(); void setDraftMetadataService(OAIConfigNodePropertyString* draft_metadata_service); OAIConfigNodePropertyString* getSubmitDataService(); void setSubmitDataService(OAIConfigNodePropertyString* submit_data_service); OAIConfigNodePropertyString* getSubmitMetadataService(); void setSubmitMetadataService(OAIConfigNodePropertyString* submit_metadata_service); OAIConfigNodePropertyString* getPendingSignDataService(); void setPendingSignDataService(OAIConfigNodePropertyString* pending_sign_data_service); OAIConfigNodePropertyString* getPendingSignMetadataService(); void setPendingSignMetadataService(OAIConfigNodePropertyString* pending_sign_metadata_service); virtual bool isSet() override; private: OAIConfigNodePropertyArray* portal_outboxes; bool m_portal_outboxes_isSet; OAIConfigNodePropertyString* draft_data_service; bool m_draft_data_service_isSet; OAIConfigNodePropertyString* draft_metadata_service; bool m_draft_metadata_service_isSet; OAIConfigNodePropertyString* submit_data_service; bool m_submit_data_service_isSet; OAIConfigNodePropertyString* submit_metadata_service; bool m_submit_metadata_service_isSet; OAIConfigNodePropertyString* pending_sign_data_service; bool m_pending_sign_data_service_isSet; OAIConfigNodePropertyString* pending_sign_metadata_service; bool m_pending_sign_metadata_service_isSet; }; } #endif /* OAIComAdobeFdFpConfigFormsPortalDraftsandSubmissionConfigServiceProperties_H_ */
C++
CL
5cdf8428caec12f20f7c340693e7e79ceb2760721d46f774f7a0ade8e3b5c3cd
/****************************************************************************** * This file is part of the TouchGFX 4.9.3 distribution. * Copyright (C) 2017 Draupner Graphics A/S <http://www.touchgfx.com>. ****************************************************************************** * This is licensed software. Any use hereof is restricted by and subject to * the applicable license terms. For further information see "About/Legal * Notice" in TouchGFX Designer or in your TouchGFX installation directory. *****************************************************************************/ #ifndef COLOR_HPP #define COLOR_HPP #include <touchgfx/hal/Types.hpp> #include <touchgfx/hal/HAL.hpp> #include <touchgfx/lcd/LCD.hpp> namespace touchgfx { /** * @class Color Color.hpp touchgfx/Color.hpp * * @brief Contains functionality for color conversion. * * Contains functionality for color conversion. */ class Color { public: /** * @fn static colortype Color::getColorFrom24BitRGB(uint8_t red, uint8_t green, uint8_t blue); * * @brief Generates a color representation to be used on the LCD, based on 24 bit RGB values. * Depending on your chosen color bit depth, the color will be interpreted * internally as either a 16 bit or 24 bit color value. * * Generates a color representation to be used on the LCD, based on 24 bit RGB * values. Depending on your chosen color bit depth, the color will be interpreted * internally as either a 16 bit or 24 bit color value. This function can be safely * used regardless of whether your application is configured for 16 or 24 bit colors. * * @param red Value of the red part (0-255). * @param green Value of the green part (0-255). * @param blue Value of the blue part (0-255). * * @return The color, encoded in a 16- or 24-bit representation depending on LCD color depth. */ static colortype getColorFrom24BitRGB(uint8_t red, uint8_t green, uint8_t blue); /** * @fn static inline uint8_t Color::getRedColor(colortype color) * * @brief Gets the red color part of a color. * * Gets the red color part of a color. As this function must work for all color depths, it can be somewhat slow if used in speed critical sections. Consider finding the color in another way, if possible. * * @param color The color value. * * @return The red part of the color. */ static inline uint8_t getRedColor(colortype color) { uint8_t bitDepth = HAL::lcd().bitDepth(); return bitDepth == 16 ? ((color & 0xF800) >> 8) : bitDepth == 24 ? ((color.getColor32() >> 16) & 0xFF) : bitDepth == 4 ? ((color & 0xF) * 0x11) : bitDepth == 2 ? ((color & 0x3) * 0x55) : 0; } /** * @fn static inline uint8_t Color::getGreenColor(colortype color) * * @brief Gets the green color part of a color. * * Gets the green color part of a color. As this function must work for all color depths, it can be somewhat slow if used in speed critical sections. Consider finding the color in another way, if possible. * * @param color The 16 bit color value. * * @return The green part of the color. */ static inline uint8_t getGreenColor(colortype color) { uint8_t bitDepth = HAL::lcd().bitDepth(); return bitDepth == 16 ? ((color & 0x07E0) >> 3) : bitDepth == 24 ? ((color.getColor32() >> 8) & 0xFF) : bitDepth == 4 ? ((color & 0xF) * 0x11) : bitDepth == 2 ? ((color & 0x3) * 0x55) : 0; } /** * @fn static inline uint8_t Color::getBlueColor(colortype color) * * @brief Gets the blue color part of a color. * * Gets the blue color part of a color. As this function must work for all color depths, it can be somewhat slow if used in speed critical sections. Consider finding the color in another way, if possible. * * @param color The 16 bit color value. * * @return The blue part of the color. */ static inline uint8_t getBlueColor(colortype color) { uint8_t bitDepth = HAL::lcd().bitDepth(); return bitDepth == 16 ? ((color & 0x001F) << 3) : bitDepth == 24 ? (color.getColor32() & 0xFF) : bitDepth == 4 ? ((color & 0xF) * 0x11) : bitDepth == 2 ? ((color & 0x3) * 0x55) : 0; } }; } // namespace touchgfx #endif // COLOR_HPP
C++
CL
1ced220f755ba92bb57441a54a6696eece298c0bf73ae25fca6343f2d93c7def
#include <sstream> #include <bitio/bitio.h> #include <hzip_core/utils/utils.h> #include "blob.h" HZ_MState::HZ_MState() { alg = hzcodec::algorithms::UNCOMPRESSED; } uint64_t HZ_MState::size() const { return data.size(); } bool HZ_MState::is_empty() const { return alg == hzcodec::algorithms::UNCOMPRESSED; } uint64_t HZ_BlobHeader::size() const { return raw.size(); } rainman::ptr<uint8_t> HZ_Params::to_byte_array() { std::vector<bin_t> bins; bins.push_back(bin_t{.obj=params.size(), .n=64}); for (const auto &param: params) { bins.push_back(bin_t{.obj=param.first.length(), .n=64}); for (const char &c : param.first) { bins.push_back(bin_t{.obj=static_cast<uint64_t>(c), .n=8}); } bins.push_back(bin_t{.obj=param.second.length(), .n=64}); for (const char &c : param.second) { bins.push_back(bin_t{.obj=static_cast<uint64_t>(c), .n=8}); } } return hz_vecbin_to_raw(bins); } HZ_Params HZ_Params::from_byte_array(const rainman::ptr<uint8_t> &raw) { auto obj = HZ_Params(); auto stream = bitio::stream(raw.pointer(), raw.size()); uint64_t params_size = stream.read(64); for (uint64_t i = 0; i < params_size; i++) { uint64_t str_len = stream.read(64); std::stringstream sstream; for (uint64_t j = 0; j < str_len; j++) { sstream << static_cast<char>(stream.read(8)); } std::string key = sstream.str(); str_len = stream.read(64); sstream = std::stringstream(); for (uint64_t j = 0; j < str_len; j++) { sstream << static_cast<char>(stream.read(8)); } std::string value = sstream.str(); obj.params[key] = value; } return obj; } template<> std::string HZ_Params::get(const std::string &key, const std::string &default_value) { if (!params.contains(key)) { return default_value; } return params[key]; } template<> uint64_t HZ_Params::get(const std::string &key, const std::string &default_value) { if (!params.contains(key)) { return std::stoull(default_value); } return std::stoull(params[key]); } template<> int64_t HZ_Params::get(const std::string &key, const std::string &default_value) { if (!params.contains(key)) { return std::stoll(default_value); } return std::stoll(params[key]); } void HZ_Blob::evaluate(const rainman::ptr<uint8_t> &original_data) { status = size < o_size; if (!status) { data = original_data; size = o_size; // Destroy mstate if compression fails. // Replace it with a mstate with algorithm = UNCOMPRESSED if (!mstate->is_empty()) { mstate = rainman::ptr<HZ_MState>(); } } }
C++
CL
bacad29e40a441b43e83b669c309115d3af21d4d12412bf5cabbaacd68a6a340
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #pragma once #ifndef QUERYOBJECT_H #define QUERYOBJECT_H #include "TodaySchema.h" namespace graphql::today::object { class Query : public service::Object { protected: explicit Query(); public: virtual service::FieldResult<std::shared_ptr<service::Object>> getNode(service::FieldParams&& params, response::IdType&& idArg) const; virtual service::FieldResult<std::shared_ptr<AppointmentConnection>> getAppointments(service::FieldParams&& params, std::optional<response::IntType>&& firstArg, std::optional<response::Value>&& afterArg, std::optional<response::IntType>&& lastArg, std::optional<response::Value>&& beforeArg) const; virtual service::FieldResult<std::shared_ptr<TaskConnection>> getTasks(service::FieldParams&& params, std::optional<response::IntType>&& firstArg, std::optional<response::Value>&& afterArg, std::optional<response::IntType>&& lastArg, std::optional<response::Value>&& beforeArg) const; virtual service::FieldResult<std::shared_ptr<FolderConnection>> getUnreadCounts(service::FieldParams&& params, std::optional<response::IntType>&& firstArg, std::optional<response::Value>&& afterArg, std::optional<response::IntType>&& lastArg, std::optional<response::Value>&& beforeArg) const; virtual service::FieldResult<std::vector<std::shared_ptr<Appointment>>> getAppointmentsById(service::FieldParams&& params, std::vector<response::IdType>&& idsArg) const; virtual service::FieldResult<std::vector<std::shared_ptr<Task>>> getTasksById(service::FieldParams&& params, std::vector<response::IdType>&& idsArg) const; virtual service::FieldResult<std::vector<std::shared_ptr<Folder>>> getUnreadCountsById(service::FieldParams&& params, std::vector<response::IdType>&& idsArg) const; virtual service::FieldResult<std::shared_ptr<NestedType>> getNested(service::FieldParams&& params) const; virtual service::FieldResult<response::StringType> getUnimplemented(service::FieldParams&& params) const; virtual service::FieldResult<std::vector<std::shared_ptr<Expensive>>> getExpensive(service::FieldParams&& params) const; private: std::future<response::Value> resolveNode(service::ResolverParams&& params); std::future<response::Value> resolveAppointments(service::ResolverParams&& params); std::future<response::Value> resolveTasks(service::ResolverParams&& params); std::future<response::Value> resolveUnreadCounts(service::ResolverParams&& params); std::future<response::Value> resolveAppointmentsById(service::ResolverParams&& params); std::future<response::Value> resolveTasksById(service::ResolverParams&& params); std::future<response::Value> resolveUnreadCountsById(service::ResolverParams&& params); std::future<response::Value> resolveNested(service::ResolverParams&& params); std::future<response::Value> resolveUnimplemented(service::ResolverParams&& params); std::future<response::Value> resolveExpensive(service::ResolverParams&& params); std::future<response::Value> resolve_typename(service::ResolverParams&& params); std::future<response::Value> resolve_schema(service::ResolverParams&& params); std::future<response::Value> resolve_type(service::ResolverParams&& params); std::shared_ptr<introspection::Schema> _schema; }; } /* namespace graphql::today::object */ #endif // QUERYOBJECT_H
C++
CL
244261504ea046cf3257fd25fd265ec445b1bc4dab49e483065a2440ee65deb6
/* * Copyright (c) 2018 IOTA Stiftung * https://github.com/iotaledger/entangled * * Refer to the LICENSE file for licensing information */ #ifndef CPPCLIENT_MESSAGES_H_ #define CPPCLIENT_MESSAGES_H_ #include <nonstd/optional.hpp> #include <string> #include <vector> namespace cppclient { struct GetTransactionsToApproveResponse { std::string trunkTransaction; std::string branchTransaction; uint32_t duration; }; struct GetNodeInfoResponse { std::string appName; std::string appVersion; uint32_t jreAvailableProcessors; uint64_t jreFreeMemory; std::string jreVersion; uint64_t jreMaxMemory; uint64_t jreTotalMemory; std::string latestMilestone; uint32_t latestMilestoneIndex; std::string latestSolidSubtangleMilestone; uint32_t latestSolidSubtangleMilestoneIndex; uint32_t neighbors; uint32_t packetsQueueSize; std::chrono::time_point<std::chrono::system_clock> time; uint32_t tips; uint32_t transactionsToRequest; }; struct GetInclusionStatesResponse { std::vector<bool> states; }; struct WereAddressesSpentFromResponse { std::vector<bool> states; }; } // namespace cppclient #endif // CPPCLIENT_MESSAGES_H_
C++
CL
e94cfb770f01bcac5b8d7682ff94253f6a9cd7bb28082e6c9fd08d14ba586359
#ifndef MAINUSERGUI_H #define MAINUSERGUI_H #include <QWidget> #include <QtSerialPort/qserialport.h> #include <QMessageBox> #include "tiva_remotelink.h" #include <qwt_plot_curve.h> #include <qwt_plot_grid.h> #include "remotelink_messages.h" namespace Ui { class MainUserGUI; } class MainUserGUI : public QWidget { Q_OBJECT public: explicit MainUserGUI(QWidget *parent = 0); ~MainUserGUI(); private slots: // slots privados asociados mediante "connect" en el constructor void cambiaLEDs(); void tivaStatusChanged(int status,QString message); void messageReceived(uint8_t type, QByteArray datos); //Slots asociados por nombre void on_runButton_clicked(); void on_serialPortComboBox_currentIndexChanged(const QString &arg1); void on_pushButton_clicked(); void on_colorWheel_colorChanged(const QColor &arg1); void on_Knob_valueChanged(double value); void on_ADCButton_clicked(); void on_pingButton_clicked(); void on_comboBox_currentIndexChanged(int index); void on_pushButton_2_clicked(); void on_comboBox_2_currentIndexChanged(int index); void on_comboBox_3_currentIndexChanged(int index); void on_factor_promediado_currentIndexChanged(int index); void on_Muestreo_toggled(bool checked); void on_Frecuencia_valueChanged(double value); void on_Resolucion_currentIndexChanged(int index); void on_checkBox_toggled(bool checked); void on_comboBox_4_currentIndexChanged(int index); private: // funciones privadas void processError(const QString &s); void activateRunButton(); void resetGrafica(); private: //Componentes privados Ui::MainUserGUI *ui; int transactionCount; QMessageBox ventanaPopUp; TivaRemoteLink tiva; //Objeto para gestionar la comunicacion de mensajes con el microcontrolador //SEMANA2: Para las graficas double xVal[512]; //valores eje X double yVal[6][512]; //valores ejes Y QwtPlotCurve *Channels[6]; //Curvas QwtPlotGrid *m_Grid; //Cuadricula int posicion; int pos_osc; }; #endif // GUIPANEL_H
C++
CL
928676d12144a738d4e4c2797d98e60ad1d648e9c87c6382e7201bd640a72b8c
/********************************************************************** * * GEOS - Geometry Engine Open Source * http://geos.osgeo.org * * Copyright (C) 2005-2006 Refractions Research Inc. * Copyright (C) 2001-2002 Vivid Solutions Inc. * * This is free software; you can redistribute and/or modify it under * the terms of the GNU Lesser General Public Licence as published * by the Free Software Foundation. * See the COPYING file for more information. * **********************************************************************/ #ifndef GEOS_GEOM_H #define GEOS_GEOM_H /** \mainpage GEOS - Geometry Engine Open Source * * \section intro_sec Introduction * * Geometry Engine Open Source is a C++ port of the Java Topology Suite * released under the LGPL license. * It has interfaces for C++, C and python (though swig). * * \section getstart_sec Getting Started * * The recommended low-level interface to the GEOS library * is the simplified \ref c_iface. This will ensure stability of the * API and the ABI of the library during performance improvements * that will likely change classes definitions. * * If you don't care about adapting/rebuilding your client code * you can still use the \ref cpp_iface. */ /** \page c_iface C wrapper interface * * \section Overview * * This is the preferred access method for GEOS. * * It is designed to keep binary compatibility across releases. * * \section Usage * * In order to use the C-API of geos you must link your code against * libgeos_c.so and include the geos_c.h header file, which also contain * function-level documentation. * */ /** \page cpp_iface C++ interface * * \section Overview * * Main class is geos::geom::Geometry, from which all geometry types * derive. * * Construction and destruction of Geometries is done * using geos::geom::GeometryFactory. * * You'll feed it geos::geom::CoordinateSequence * for base geometries or vectors of geometries for collections. * * If you need to construct geometric shaped geometries, you * can use geos::geom::GeometricShapeFactory. * * GEOS version info (as a string) can be obtained using * geos::geom::geosversion(). The JTS version this release has been * ported from is available throu geos::geom::jtsport(). * * \section io_sect Input / Output * * For WKT input/output you can use geos::io::WKTReader and geos::io::WKTWriter * * For WKB input/output you can use geos::io::WKBReader and geos::io::WKBWriter * * \section exc_sect Exceptions * * Internal exceptions are thrown as instances geos::util::GEOSException or * derived classes. GEOSException derives from std::exception. * * Note that prior to version 3.0.0, GEOSException were thrown by * pointer, and did not derive from std::exception. * */ namespace geos { /// Contains the <CODE>Geometry</CODE> interface hierarchy and supporting classes. // /// The Java Topology Suite (JTS) is a Java API that implements a core /// set of spatial data operations using an explicit precision model /// and robust geometric algorithms. JTS is int ended to be used in the /// development of applications that support the validation, cleaning, /// integration and querying of spatial datasets. /// /// JTS attempts to implement the OpenGIS Simple Features Specification /// (SFS) as accurately as possible. In some cases the SFS is unclear /// or omits a specification; in this case J TS attempts to choose /// a reasonable and consistent alternative. Differences from and /// elaborations of the SFS are documented in this specification. /// /// <h2>Package Specification</h2> /// /// - Java Topology Suite Technical Specifications /// - <A HREF="http://www.opengis.org/techno/specs.htm"> /// OpenGIS Simple Features Specification for SQL</A> /// namespace geom { // geos::geom } // namespace geos::geom } // namespace geos #include <geos/geom/Coordinate.h> #include <geos/geom/CoordinateArraySequence.h> #include <geos/geom/CoordinateArraySequenceFactory.h> #include <geos/geom/CoordinateFilter.h> #include <geos/geom/CoordinateSequence.h> #include <geos/geom/CoordinateSequenceFactory.h> #include <geos/geom/Dimension.h> #include <geos/geom/Envelope.h> #include <geos/geom/Geometry.h> #include <geos/geom/GeometryCollection.h> #include <geos/geom/GeometryComponentFilter.h> #include <geos/geom/GeometryFactory.h> #include <geos/geom/GeometryFilter.h> #include <geos/geom/LineString.h> #include <geos/geom/LinearRing.h> #include <geos/geom/MultiLineString.h> #include <geos/geom/MultiPoint.h> #include <geos/geom/MultiPolygon.h> #include <geos/geom/Point.h> #include <geos/geom/Polygon.h> #include <geos/geom/PrecisionModel.h> #include <geos/geom/LineSegment.h> #include <geos/geom/IntersectionMatrix.h> #include <geos/geom/Location.h> //#include <geos/geom/Triangle.h> #ifdef __GNUC__ #warning *** DEPRECATED: You are using deprecated header geom.h. Please, update your sources according to new layout of GEOS headers and namespaces #endif using namespace geos::geom; #endif // ndef GEOS_GEOM_H
C++
CL
41158dd716b7c34758ddc638d785d839677cf5e24ce0463886e26ed2b02d00cb
#include "boost/container_hash/hash.hpp" #include <algorithm> #include <benchmark/benchmark.h> #include <iostream> #include <iterator> #include <random> #include <stdexcept> #include <cstdlib> #define XXH_INLINE_ALL #include "xxhash.h" #include "farmhash.h" #include "farmhash.cc" #include "aquahash.h" #include "interface.h" #include "utils.h" #include "test_utils.h" #include "clhash.h" #include "wyhash.h" const std::string test_string = generate_random_string(); // std::hash benchmark void std_hash_string(benchmark::State &state) { std::hash<std::string> h; for (auto _ : state) { benchmark::DoNotOptimize(h(test_string)); } } BENCHMARK(std_hash_string); // boost::hash void boost_hash_string(benchmark::State &state) { boost::hash<std::string> h; for (auto _ : state) { benchmark::DoNotOptimize(h(test_string)); } } BENCHMARK(boost_hash_string); // xxHash void xxhash_string(benchmark::State &state) { unsigned long long const seed = 0; for (auto _ : state) { benchmark::DoNotOptimize(XXH64(test_string.data(), test_string.size(), seed)); } } // Register the function as a benchmark BENCHMARK(xxhash_string); // FarmHash void farmhash_string(benchmark::State &state) { for (auto _ : state) { benchmark::DoNotOptimize(util::Hash64(test_string.data(), test_string.size())); } } BENCHMARK(farmhash_string); // clhash benchmark void clhash_string(benchmark::State &state) { util::CLHash clhash; for (auto _ : state) { benchmark::DoNotOptimize(clhash(test_string.data(), test_string.size())); } } BENCHMARK(clhash_string); // AquaHash const __m128i seed = _mm_setzero_si128(); void aquahash_string(benchmark::State &state) { for (auto _ : state) { benchmark::DoNotOptimize(AquaHash::Hash((const uint8_t*)test_string.data(), test_string.size(), seed)); } } BENCHMARK(aquahash_string); void aquahash64_string(benchmark::State &state) { aquahash::hash<std::string> h; for (auto _ : state) { benchmark::DoNotOptimize(h(test_string)); } } BENCHMARK(aquahash64_string); void wyhash_string(benchmark::State &state) { uint64_t seed = 0; for (auto _ : state) { benchmark::DoNotOptimize(wyhash(test_string.data(), test_string.size(), seed)); } } BENCHMARK(wyhash_string); BENCHMARK_MAIN();
C++
CL
b456781a27577dfcccb2810bf791dac1c767e7c15914bc6d38fd170e9644f2b5
#ifndef TUW_AIRSKIN_NODELET_H #define TUW_AIRSKIN_NODELET_H #include <nodelet/nodelet.h> #include <ros/ros.h> #include <tuw_i2c/I2C_Master.h> #include <tuw_airskin/AirSkinPad.h> #include <tuw_airskin_msgs/AirskinInfo.h> #include <tuw_airskin_msgs/AirskinColors.h> #include <tuw_airskin_msgs/AirskinPressures.h> #include <tf/transform_listener.h> namespace tuw { class AirSkinNodelet : public nodelet::Nodelet { public: virtual void onInit(); void run(); private: ros::NodeHandle nh_; ros::NodeHandle n_; ros::Publisher pub_info_; ros::Publisher pub_pressures_; ros::Publisher pub_contact_; ros::Subscriber sub_colors_; std::string device_file_name_; std::string frame_id_; double contact_treshold_; bool auto_calibration_; std::vector<int> pressures_min_; std::vector<int> pressures_max_; std::shared_ptr<I2C_Master> i2c_master_; std::vector<std::shared_ptr<AirSkinPad> > pads_; ros::Timer timer_; std_msgs::Bool contact_; tuw_airskin_msgs::AirskinInfo airskin_info_; tuw_airskin_msgs::AirskinPressures airskin_pressures_; void timerCallback(const ros::TimerEvent& event); void colorsCallback(const tuw_airskin_msgs::AirskinColors::ConstPtr& colors); tf::TransformListener tf_listener_; }; } #endif // TUW_AIRSKIN_NODELET_H
C++
CL
02f6e6e2b0c23679a1d9bb268ffacc4ad0e987b2bab3eb4382481abe992f0943
//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// #include "Components/BsCRenderable.h" #include "Private/RTTI/BsCRenderableRTTI.h" #include "Scene/BsSceneObject.h" #include "Mesh/BsMesh.h" #include "Material/BsMaterial.h" #include "Components/BsCAnimation.h" #include "Math/BsBounds.h" #include "Scene/BsSceneManager.h" namespace bs { CRenderable::CRenderable() { setName("Renderable"); setFlag(ComponentFlag::AlwaysRun, true); } CRenderable::CRenderable(const HSceneObject& parent) :Component(parent) { setName("Renderable"); setFlag(ComponentFlag::AlwaysRun, true); } void CRenderable::setMesh(HMesh mesh) { mInternal->setMesh(mesh); if (mAnimation != nullptr) mAnimation->_updateBounds(false); } void CRenderable::onInitialized() { // If mInternal already exists this means this object was deserialized, // so all we need to do is initialize it. if (mInternal != nullptr) mInternal->initialize(); else mInternal = Renderable::create(); gSceneManager()._bindActor(mInternal, sceneObject()); mAnimation = SO()->getComponent<CAnimation>(); if (mAnimation != nullptr) { _registerAnimation(mAnimation); mAnimation->_registerRenderable(static_object_cast<CRenderable>(mThisHandle)); } } Bounds CRenderable::getBounds() const { mInternal->_updateState(*SO()); return mInternal->getBounds(); } bool CRenderable::calculateBounds(Bounds& bounds) { bounds = getBounds(); return true; } void CRenderable::_registerAnimation(const HAnimation& animation) { mAnimation = animation; if (mInternal != nullptr) { mInternal->setAnimation(animation->_getInternal()); // Need to update transform because animated renderables handle local transforms through bones, so it // shouldn't be included in the renderable's transform. mInternal->_updateState(*SO(), true); } } void CRenderable::_unregisterAnimation() { mAnimation = nullptr; if(mInternal != nullptr) { mInternal->setAnimation(nullptr); // Need to update transform because animated renderables handle local transforms through bones, so it // shouldn't be included in the renderable's transform. mInternal->_updateState(*SO(), true); } } void CRenderable::update() { } void CRenderable::onDestroyed() { if (mAnimation != nullptr) mAnimation->_unregisterRenderable(); gSceneManager()._unbindActor(mInternal); mInternal->destroy(); } RTTITypeBase* CRenderable::getRTTIStatic() { return CRenderableRTTI::instance(); } RTTITypeBase* CRenderable::getRTTI() const { return CRenderable::getRTTIStatic(); } }
C++
CL
44d48bc60194501a3721851aa9f5b1efb5801fbada7614d81f295828a7f2f331