code
stringlengths
3
1.01M
repo_name
stringlengths
5
116
path
stringlengths
3
311
language
stringclasses
30 values
license
stringclasses
15 values
size
int64
3
1.01M
// Copyright 2019-2020 CERN and copyright holders of ALICE O2. // See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. // All rights not expressly granted are reserved. // // This software is distributed under the terms of the GNU General Public // License v3 (GPL Version 3), copied verbatim in the file "COPYING". // // In applying this license CERN does not waive the privileges and immunities // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. #ifndef DETECTOR_CALIB_TIMESLOTCALIB_H_ #define DETECTOR_CALIB_TIMESLOTCALIB_H_ /// @brief Processor for the multiple time slots calibration #include "DetectorsCalibration/TimeSlot.h" #include <deque> #include <gsl/gsl> #include <limits> namespace o2 { namespace calibration { template <typename Input, typename Container> class TimeSlotCalibration { using Slot = TimeSlot<Container>; public: TimeSlotCalibration() = default; virtual ~TimeSlotCalibration() = default; uint64_t getMaxSlotsDelay() const { return mMaxSlotsDelay; } void setMaxSlotsDelay(uint64_t v) { mMaxSlotsDelay = v; } uint64_t getSlotLength() const { return mSlotLength; } void setSlotLength(uint64_t v) { mSlotLength = v < 1 ? 1 : v; } uint64_t getCheckIntervalInfiniteSlot() const { return mCheckIntervalInfiniteSlot; } void setCheckIntervalInfiniteSlot(uint64_t v) { mCheckIntervalInfiniteSlot = v; } uint64_t getCheckDeltaIntervalInfiniteSlot() const { return mCheckDeltaIntervalInfiniteSlot; } void setCheckDeltaIntervalInfiniteSlot(uint64_t v) { mCheckDeltaIntervalInfiniteSlot = v < 1 ? mCheckIntervalInfiniteSlot : v; } // if the delta is 0, we ignore it TFType getFirstTF() const { return mFirstTF; } void setFirstTF(TFType v) { mFirstTF = v; } void setUpdateAtTheEndOfRunOnly() { mUpdateAtTheEndOfRunOnly = kTRUE; } int getNSlots() const { return mSlots.size(); } Slot& getSlotForTF(TFType tf); Slot& getSlot(int i) { return (Slot&)mSlots.at(i); } const Slot& getSlot(int i) const { return (Slot&)mSlots.at(i); } const Slot& getLastSlot() const { return (Slot&)mSlots.back(); } const Slot& getFirstSlot() const { return (Slot&)mSlots.front(); } template <typename DATA> bool process(TFType tf, const DATA& data); virtual bool process(TFType tf, const gsl::span<const Input> data); virtual void checkSlotsToFinalize(TFType tf, int maxDelay = 0); virtual void finalizeOldestSlot(); // Methods to be implemented by the derived user class // implement and call this method te reset the output slots once they are not needed virtual void initOutput() = 0; // process the time slot container and add results to the output virtual void finalizeSlot(Slot& slot) = 0; // create new time slot in the beginning or the end of the slots pool virtual Slot& emplaceNewSlot(bool front, TFType tstart, TFType tend) = 0; // check if the slot has enough data to be finalized virtual bool hasEnoughData(const Slot& slot) const = 0; virtual void print() const; protected: auto& getSlots() { return mSlots; } private: TFType tf2SlotMin(TFType tf) const; std::deque<Slot> mSlots; TFType mLastClosedTF = 0; TFType mFirstTF = 0; TFType mMaxSeenTF = 0; // largest TF processed uint64_t mSlotLength = 1; uint64_t mMaxSlotsDelay = 3; bool mUpdateAtTheEndOfRunOnly = false; uint64_t mCheckIntervalInfiniteSlot = 1; // will be used if the TF length is INFINITE_TF_int64 to decide // when to check if to call the finalize; otherwise it is called // at every new TF; note that this is an approximation, // since TFs come in async order TFType mLastCheckedTFInfiniteSlot = 0; // will be used if the TF length is INFINITE_TF_int64 to book-keep // the last TF at which we tried to calibrate uint64_t mCheckDeltaIntervalInfiniteSlot = 1; // will be used if the TF length is INFINITE_TF_int64 when // the check on the statistics returned false, to determine // after how many TF to check again. bool mWasCheckedInfiniteSlot = false; // flag to know whether the statistics of the infinite slot was already checked ClassDef(TimeSlotCalibration, 1); }; //_________________________________________________ template <typename Input, typename Container> template <typename DATA> bool TimeSlotCalibration<Input, Container>::process(TFType tf, const DATA& data) { // process current TF int maxDelay = mMaxSlotsDelay * mSlotLength; if (!mUpdateAtTheEndOfRunOnly) { // if you update at the end of run only, then you accept everything if (tf < mLastClosedTF || (!mSlots.empty() && getLastSlot().getTFStart() > tf + maxDelay)) { // ignore TF; note that if you have only 1 timeslot // which is INFINITE_TF wide, then maxDelay // does not matter: you won't accept TFs from the past, // so the first condition will be used LOG(info) << "Ignoring TF " << tf << ", mLastClosedTF = " << mLastClosedTF; return false; } } auto& slotTF = getSlotForTF(tf); slotTF.getContainer()->fill(data); if (tf > mMaxSeenTF) { mMaxSeenTF = tf; // keep track of the most recent TF processed } if (!mUpdateAtTheEndOfRunOnly) { // if you update at the end of run only, you don't check at every TF which slots can be closed // check if some slots are done checkSlotsToFinalize(tf, maxDelay); } return true; } //_________________________________________________ template <typename Input, typename Container> bool TimeSlotCalibration<Input, Container>::process(TFType tf, const gsl::span<const Input> data) { // process current TF int maxDelay = mMaxSlotsDelay * mSlotLength; if (!mUpdateAtTheEndOfRunOnly) { // if you update at the end of run only, then you accept everything if (tf < mLastClosedTF || (!mSlots.empty() && getLastSlot().getTFStart() > tf + maxDelay)) { // ignore TF; note that if you have only 1 timeslot // which is INFINITE_TF wide, then maxDelay // does not matter: you won't accept TFs from the past, // so the first condition will be used LOG(info) << "Ignoring TF " << tf << ", mLastClosedTF = " << mLastClosedTF; return false; } } auto& slotTF = getSlotForTF(tf); slotTF.getContainer()->fill(data); if (tf > mMaxSeenTF) { mMaxSeenTF = tf; // keep track of the most recent TF processed } if (!mUpdateAtTheEndOfRunOnly) { // if you update at the end of run only, you don't check at every TF which slots can be closed // check if some slots are done checkSlotsToFinalize(tf, maxDelay); } return true; } //_________________________________________________ template <typename Input, typename Container> void TimeSlotCalibration<Input, Container>::checkSlotsToFinalize(TFType tf, int maxDelay) { // Check which slots can be finalized, provided the newly arrived TF is tf constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; constexpr int64_t INFINITE_TF_int64 = std::numeric_limits<long>::max() - 1; // this is used to define the end // of the slot in case it is "std::numeric_limits<long>::max()" // long (so we need to subtract 1) // if we have one slot only which is INFINITE_TF_int64 long, and we are not at the end of run (tf != INFINITE_TF), // we need to check if we got enough statistics, and if so, redefine the slot if (mSlots.size() == 1 && mSlots[0].getTFEnd() == INFINITE_TF_int64) { uint64_t checkInterval = mCheckIntervalInfiniteSlot + mLastCheckedTFInfiniteSlot; if (mWasCheckedInfiniteSlot) { checkInterval = mCheckDeltaIntervalInfiniteSlot + mLastCheckedTFInfiniteSlot; } if (tf >= checkInterval || tf == INFINITE_TF) { LOG(debug) << "mMaxSeenTF = " << mMaxSeenTF << ", mLastCheckedTFInfiniteSlot = " << mLastCheckedTFInfiniteSlot << ", checkInterval = " << checkInterval << ", mSlots[0].getTFStart() = " << mSlots[0].getTFStart(); if (tf == INFINITE_TF) { LOG(info) << "End of run reached, trying to calibrate what we have, if we have enough statistics"; } else { LOG(info) << "Calibrating as soon as we have enough statistics:"; LOG(info) << "Update interval passed (" << checkInterval << "), checking slot for " << mSlots[0].getTFStart() << " <= TF <= " << mSlots[0].getTFEnd(); } mLastCheckedTFInfiniteSlot = tf; if (hasEnoughData(mSlots[0])) { mWasCheckedInfiniteSlot = false; mSlots[0].setTFStart(mLastClosedTF); mSlots[0].setTFEnd(mMaxSeenTF); LOG(info) << "Finalizing slot for " << mSlots[0].getTFStart() << " <= TF <= " << mSlots[0].getTFEnd(); finalizeSlot(mSlots[0]); // will be removed after finalization mLastClosedTF = mSlots[0].getTFEnd() + 1; // will not accept any TF below this mSlots.erase(mSlots.begin()); // creating a new slot if we are not at the end of run if (tf != INFINITE_TF) { LOG(info) << "Creating new slot for " << mLastClosedTF << " <= TF <= " << INFINITE_TF_int64; emplaceNewSlot(true, mLastClosedTF, INFINITE_TF_int64); } } else { LOG(info) << "Not enough data to calibrate"; mWasCheckedInfiniteSlot = true; } } else { LOG(debug) << "Not trying to calibrate: either not at EoS, or update interval not passed"; } } else { // check if some slots are done for (auto slot = mSlots.begin(); slot != mSlots.end();) { //if (maxDelay == 0 || (slot->getTFEnd() + maxDelay) < tf) { if ((slot->getTFEnd() + maxDelay) < tf) { if (hasEnoughData(*slot)) { LOG(debug) << "Finalizing slot for " << slot->getTFStart() << " <= TF <= " << slot->getTFEnd(); finalizeSlot(*slot); // will be removed after finalization } else if ((slot + 1) != mSlots.end()) { LOG(info) << "Merging underpopulated slot " << slot->getTFStart() << " <= TF <= " << slot->getTFEnd() << " to slot " << (slot + 1)->getTFStart() << " <= TF <= " << (slot + 1)->getTFEnd(); (slot + 1)->mergeToPrevious(*slot); } else { LOG(info) << "Discard underpopulated slot " << slot->getTFStart() << " <= TF <= " << slot->getTFEnd(); break; // slot has no enough stat. and there is no other slot to merge it to } mLastClosedTF = slot->getTFEnd() + 1; // will not accept any TF below this LOG(info) << "closing slot " << slot->getTFStart() << " <= TF <= " << slot->getTFEnd(); slot = mSlots.erase(slot); } else { break; // all following slots will be even closer to the new TF } } } } //_________________________________________________ template <typename Input, typename Container> void TimeSlotCalibration<Input, Container>::finalizeOldestSlot() { // Enforce finalization and removal of the oldest slot if (mSlots.empty()) { LOG(warning) << "There are no slots defined"; return; } finalizeSlot(mSlots.front()); mLastClosedTF = mSlots.front().getTFEnd() + 1; // do not accept any TF below this mSlots.erase(mSlots.begin()); } //________________________________________ template <typename Input, typename Container> inline TFType TimeSlotCalibration<Input, Container>::tf2SlotMin(TFType tf) const { // returns the min TF of the slot to which "tf" belongs if (tf < mFirstTF) { throw std::runtime_error("invalide TF"); } if (mUpdateAtTheEndOfRunOnly) { return mFirstTF; } return TFType((tf - mFirstTF) / mSlotLength) * mSlotLength + mFirstTF; } //_________________________________________________ template <typename Input, typename Container> TimeSlot<Container>& TimeSlotCalibration<Input, Container>::getSlotForTF(TFType tf) { LOG(debug) << "Getting slot for TF " << tf; if (mUpdateAtTheEndOfRunOnly) { if (!mSlots.empty() && mSlots.back().getTFEnd() < tf) { mSlots.back().setTFEnd(tf); } else if (mSlots.empty()) { emplaceNewSlot(true, mFirstTF, tf); } return mSlots.back(); } if (!mSlots.empty() && mSlots.front().getTFStart() > tf) { // we need to add a slot to the beginning auto tfmn = tf2SlotMin(mSlots.front().getTFStart() - 1); // min TF of the slot corresponding to a TF smaller than the first seen auto tftgt = tf2SlotMin(tf); // min TF of the slot to which the TF "tf" would belong while (tfmn >= tftgt) { LOG(info) << "Adding new slot for " << tfmn << " <= TF <= " << tfmn + mSlotLength - 1; emplaceNewSlot(true, tfmn, tfmn + mSlotLength - 1); if (!tfmn) { break; } tfmn = tf2SlotMin(mSlots.front().getTFStart() - 1); } return mSlots[0]; } for (auto it = mSlots.begin(); it != mSlots.end(); it++) { auto rel = (*it).relateToTF(tf); if (rel == 0) { return (*it); } } // need to add in the end auto tfmn = mSlots.empty() ? tf2SlotMin(tf) : tf2SlotMin(mSlots.back().getTFEnd() + 1); do { LOG(info) << "Adding new slot for " << tfmn << " <= TF <= " << tfmn + mSlotLength - 1; emplaceNewSlot(false, tfmn, tfmn + mSlotLength - 1); tfmn = tf2SlotMin(mSlots.back().getTFEnd() + 1); } while (tf > mSlots.back().getTFEnd()); return mSlots.back(); } //_________________________________________________ template <typename Input, typename Container> void TimeSlotCalibration<Input, Container>::print() const { for (int i = 0; i < getNSlots(); i++) { LOG(info) << "Slot #" << i << " of " << getNSlots(); getSlot(i).print(); } } } // namespace calibration } // namespace o2 #endif
noferini/AliceO2
Detectors/Calibration/include/DetectorsCalibration/TimeSlotCalibration.h
C
gpl-3.0
14,616
/* Copyright (C) 2003-2013 Runtime Revolution Ltd. This file is part of LiveCode. LiveCode is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v3 as published by the Free Software Foundation. LiveCode 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 LiveCode. If not see <http://www.gnu.org/licenses/>. */ #include "prefix.h" #include "globdefs.h" #include "filedefs.h" #include "objdefs.h" #include "parsedef.h" #include "packed.h" #include "bitmapeffectblur.h" //////////////////////////////////////////////////////////////////////////////// // This is the MCBitmapEffectBlur opaque type definition. Its implemented as a // C++ interface. // struct MCBitmapEffectBlur { // We make the destructor virtual, although cleanup should happen in Finalize. virtual ~MCBitmapEffectBlur(void) {} // This method is called by BlurBegin after its setup the common state. virtual bool Initialize(const MCBitmapEffectBlurParameters& params, const MCRectangle& input_rect, const MCRectangle& output_rect, uint32_t *src_pixels, uint32_t src_stride) = 0; // This method is called by BlurContinue to produce the next scanline. virtual void Process(uint8_t *mask) = 0; // This method is called by BlurEnd to finish a blur. virtual void Finalize(void) = 0; }; //////////////////////////////////////////////////////////////////////////////// // The factory method is defined at the bottom of the file, after the various // blur implementations :o) static bool MCBitmapEffectBlurFactory(MCBitmapEffectFilter type, MCBitmapEffectBlur*& r_blur); bool MCBitmapEffectBlurBegin(const MCBitmapEffectBlurParameters& p_params, const MCRectangle& p_input_rect, const MCRectangle& p_output_rect, uint32_t *p_src_pixels, uint32_t p_src_stride, MCBitmapEffectBlurRef& r_blur) { MCBitmapEffectBlur *t_blur; if (!MCBitmapEffectBlurFactory(p_params.filter, t_blur)) return false; if (!t_blur -> Initialize(p_params, p_input_rect, p_output_rect, p_src_pixels, p_src_stride)) { delete t_blur; return false; } r_blur = t_blur; return true; } void MCBitmapEffectBlurContinue(MCBitmapEffectBlurRef blur, uint8_t *mask) { blur -> Process(mask); } void MCBitmapEffectBlurEnd(MCBitmapEffectBlurRef blur) { blur -> Finalize(); delete blur; } //////////////////////////////////////////////////////////////////////////////// // This is the (original) naive gaussian blur implementation. Note that the // state is indirected through a separate structure because it was refactored // from differently structured code. This is largely irrelevant though, since // we want to replace it with a faster version based on the fact the Gaussian // convoluton filter is separable :o) struct MCBitmapEffectGaussianBlurState { int32_t radius; uint32_t *kernel; uint32_t *pixels; uint32_t stride; int32_t width; int32_t height; int32_t left, top, right, bottom; int32_t y; }; struct MCBitmapEffectGaussianBlur: public MCBitmapEffectBlur { bool Initialize(const MCBitmapEffectBlurParameters& params, const MCRectangle& input_rect, const MCRectangle& output_rect, uint32_t *src_pixels, uint32_t src_stride); void Process(uint8_t *mask); void Finalize(void); MCBitmapEffectGaussianBlurState state; }; static inline float _gaussian_value(int32_t i, float r) { float x; x = 3 * (i + 1) / r; return (float)exp(-x * x / 2.); } static inline float _gaussian_function(int32_t i, float r) { return (float) (_gaussian_value(i, r) * 3 / (sqrt(2 * M_PI) * r)); } static float *MCBitmapEffectComputeGaussianKernel(uint4 r) { uint4 t_width; t_width = r * 2 + 1; float *lk; lk = new float[t_width]; if (lk == NULL) return NULL; for(uint4 i = 0; i < r + 1; i++) { float v; v = _gaussian_value(i, float(r)); lk[i] = v; lk[t_width - 1 - i] = v; } return lk; } static uint32_t *MCBitmapEffectComputeBlurKernel(uint4 r) { uint4 t_width; t_width = r * 2 + 1; float *lk; lk = MCBitmapEffectComputeGaussianKernel(r); float *k, t_sum; k = new float[t_width * t_width]; t_sum = 0.0; for(uint4 i = 0; i < t_width; i++) for(uint4 j = 0; j < t_width; j++) { float v; v = lk[i] * lk[j]; k[i * t_width + j] = 1.0f - v; t_sum += 1.0f - v; } uint32_t *ik; ik = new uint32_t[t_width * t_width]; for(uint4 i = 0; i < t_width; i++) for(uint4 j = 0; j < t_width; j++) ik[i * t_width + j] = (uint32_t)(k[i * t_width + j] * 0x1000000 / t_sum); delete[] lk; delete[] k; return ik; } bool MCBitmapEffectGaussianBlur::Initialize(const MCBitmapEffectBlurParameters& params, const MCRectangle& input_rect, const MCRectangle& output_rect, uint32_t *src_pixels, uint32_t src_stride) { state . radius = params . radius; if (params . radius != 0) state . kernel = MCBitmapEffectComputeBlurKernel(params . radius); else state . kernel = 0; state . width = output_rect . width; state . height = output_rect . height; state . left = input_rect . x - output_rect . x; state . top = input_rect . y - output_rect . y; state . right = state . left + input_rect . width; state . bottom = state . top + input_rect . height; state . pixels = src_pixels; state . stride = src_stride; state . y = 0; return true; } void MCBitmapEffectGaussianBlur::Process(uint8_t *mask) { if (state . kernel != NULL) { int32_t t_top, t_bottom; t_top = MCU_max(-state . radius, state . top - state . y); t_bottom = MCU_min(state . radius, state . bottom - state . y - 1); int32_t t_vcount; t_vcount = t_bottom - t_top + 1; uint32_t *t_kernel; t_kernel = state . kernel + (state . radius + t_top) * (state . radius * 2 + 1) + state . radius; uint32_t *t_pixels; t_pixels = state . pixels + state . stride * t_top; for(int32_t x = 0; x < state . width; x++) { int32_t t_left, t_right; t_left = MCU_max(-state . radius, state . left - x); t_right = MCU_min(state . radius, state . right - x - 1); int32_t t_hcount; t_hcount = t_right - t_left; uint32_t *t_kernel_ptr; t_kernel_ptr = t_kernel + t_left; uint32_t *t_pixel_ptr; t_pixel_ptr = t_pixels + x + t_left; uint32_t t_alpha; t_alpha = 0; for(int32_t k = t_vcount; k > 0; k--) { for(int32_t j = t_hcount; j >= 0; j--) t_alpha += t_kernel_ptr[j] * (t_pixel_ptr[j] >> 24); t_pixel_ptr += state . stride; t_kernel_ptr += state . radius * 2 + 1; } mask[x] = t_alpha >> 24; } } else { if (state . y >= state . top && state . y < state . bottom) { for(int32_t x = 0; x < state . left; x++) mask[x] = 0; for(int32_t x = state . left; x < MCU_min(state . width, state . right); x++) mask[x] = state . pixels[x] >> 24; for(int32_t x = state . right; x < state . width; x++) mask[x] = 0; } } state . y += 1; state . pixels += state . stride; } void MCBitmapEffectGaussianBlur::Finalize(void) { delete[] state . kernel; } //////////////////////////////////////////////////////////////////////////////// // This is an implementation of the gaussian blur convolution filter, // using the fact that such a filter has the 'separable' property. // // A naive version of this algorithm will require an intermediate buffer the full // size of the output_rect. However, a cleverer version could make do (I believe) // with one of size output_rect . width * (2 * radius + 1). struct MCBitmapEffectFastGaussianBlur: public MCBitmapEffectBlur { bool Initialize(const MCBitmapEffectBlurParameters& params, const MCRectangle& input_rect, const MCRectangle& output_rect, uint32_t *src_pixels, uint32_t src_stride); void Process(uint8_t *mask); void Finalize(void); int32_t radius; uint32_t *kernel; uint32_t *pixels; uint32_t stride; int32_t width; int32_t height; int32_t left, top, right, bottom; int32_t y; uint32_t *buffer; uint32_t buffer_stride; uint32_t buffer_height; uint32_t buffer_nextrow; }; bool MCBitmapEffectFastGaussianBlur::Initialize(const MCBitmapEffectBlurParameters& params, const MCRectangle& input_rect, const MCRectangle& output_rect, uint32_t *src_pixels, uint32_t src_stride) { radius = params . radius; uint32_t t_width; t_width = params.radius * 2 + 1; uint32_t t_spread_radius; t_spread_radius = radius * (255 - params.spread) / 255; if (params . radius != 0) { float *lk = MCBitmapEffectComputeGaussianKernel(t_spread_radius); kernel = new uint32_t[t_width]; float t_sum = 0; for (uint32_t i=0; i<(t_spread_radius * 2 + 1); i++) { lk[i] = 1.0f - lk[i]; t_sum += lk[i]; } for (uint32_t i=0; i<t_spread_radius; i++) { kernel[i] = (uint32_t) (lk[i] * 0x10000 / t_sum); kernel[t_width - i - 1] = kernel[i]; } for (uint32_t i=t_spread_radius; i<t_width - t_spread_radius; i++) kernel[i] = (uint32_t) (lk[t_spread_radius] * 0x10000 / t_sum); // MW-2009-08-24: Memory leak :o) delete lk; } else kernel = 0; width = output_rect . width; height = output_rect . height; left = input_rect . x - output_rect . x; top = input_rect . y - output_rect . y; right = left + input_rect . width; bottom = top + input_rect . height; stride = src_stride; y = 0; buffer_height = t_width; buffer_nextrow = top; buffer = new uint32_t[buffer_height * output_rect.width]; buffer_stride = output_rect.width; if (radius > 0) pixels = src_pixels + stride * buffer_nextrow; else pixels = src_pixels; return true; } void MCBitmapEffectFastGaussianBlur::Process(uint8_t *mask) { if (kernel != NULL) { if (y >= (top - radius) && (y < bottom + radius)) { int32_t t_top, t_bottom; t_top = MCU_max(-radius, top - y); // min offset from kernel midpoint t_bottom = MCU_min(bottom - y - 1, radius); // max offset from kernel midpoint int32_t t_vcount; t_vcount = t_bottom - t_top + 1; uint32_t *t_kernel; t_kernel = kernel + radius; // point to kernel midpoint // calculate any new buffer rows needed for this one for (int32_t t_y = buffer_nextrow; t_y <= t_bottom + y; t_y++) { uint32_t *t_mask = buffer + (buffer_stride * ((t_y + buffer_height) % buffer_height)); for(int32_t x = 0; x < width; x++) { int32_t t_left, t_right; t_left = MCU_max(-radius, left - x); t_right = MCU_min(right - x - 1, radius); int32_t t_hcount; t_hcount = t_right - t_left; uint32_t *t_kernel_ptr; t_kernel_ptr = t_kernel + t_left; uint32_t *t_pixel_ptr; t_pixel_ptr = pixels + x + t_left; uint32_t t_alpha; t_alpha = 0; for(int32_t j = t_hcount; j >= 0; j--) { uint32_t t_weighted = t_kernel_ptr[j] * (t_pixel_ptr[j] >> 24); if ((0xFFFFFFFF - t_alpha) > t_weighted) t_alpha += t_weighted; else t_alpha = 0xFFFFFFFF; } t_mask[x] = t_alpha ; } pixels += stride; } buffer_nextrow = t_bottom + y + 1; uint32_t *t_buffer_end; t_buffer_end = buffer + (buffer_stride * (buffer_height - 1)); uint32_t *t_buffer; t_buffer = buffer + (buffer_stride * ((t_top + y + buffer_height) % buffer_height)); for(int32_t x = 0; x < width; x++) { uint32_t *t_kernel_ptr; t_kernel_ptr = t_kernel + t_top; uint32_t t_alpha; t_alpha = 0; uint32_t *t_buffer_ptr; t_buffer_ptr = t_buffer; int32_t t_y = t_top + y; for (int32_t k = 0; k < t_vcount; k++)//, t_y++) { uint32_t t_weighted = t_kernel_ptr[k] * (t_buffer_ptr[x] >> 16); if ((0xFFFFFFFF - t_alpha) > t_weighted) t_alpha += t_weighted; else t_alpha = 0xFFFFFFFF; if (t_buffer_ptr < t_buffer_end) t_buffer_ptr += buffer_stride; else t_buffer_ptr = buffer; } if (t_alpha < 0x1000000) mask[x] = t_alpha >> 16; else mask[x] = 0xFF; } } else { for (int32_t x=0; x < width; x++) mask[x] = 0; } } else { if (y >= top && y < bottom) { int32_t x; x = 0; int32_t t_left, t_right; t_left = MCU_min(width, left); t_right = MCU_min(width, right); for(; x < t_left; x++) mask[x] = 0; for(; x < t_right; x++) mask[x] = pixels[x] >> 24; for(; x < width; x++) mask[x] = 0; } else for(int32_t x = 0; x < width; x++) mask[x] = 0; pixels += stride; } y += 1; } void MCBitmapEffectFastGaussianBlur::Finalize(void) { delete [] kernel; delete [] buffer; } //////////////////////////////////////////////////////////////////////////////// // This is an implementation of a 'box' blur. The algorithm is applied 'passes' // times. 3 passes should give a close approximation to gaussian blur. // // This version of the algorithm uses buffers for each pass totalling // approximately output_rect . width * (2 * radius + passes) struct MCBitmapEffectBoxBlurPassInfo { uint32_t *buffer; int32_t left, top, right, bottom; int32_t radius; int32_t window; int32_t width; uint32_t stride; uint32_t height; uint32_t buffer_height; int32_t buffer_nextrow; int32_t buffer_needrow; }; struct MCBitmapEffectBoxBlur: public MCBitmapEffectBlur { bool Initialize(const MCBitmapEffectBlurParameters& params, const MCRectangle& input_rect, const MCRectangle& output_rect, uint32_t *src_pixels, uint32_t src_stride); void Process(uint8_t *mask); void Finalize(void); //// void CalculateRows(uint32_t p_pass); MCBitmapEffectBoxBlur(uint32_t passes) { m_passes = MCU_max(passes, 1u); } uint32_t m_passes; int32_t y; int32_t width; int32_t height; int32_t top, bottom, left, right; uint32_t *pixels; uint32_t stride; MCBitmapEffectBoxBlurPassInfo *pass_info; uint32_t *row_buffer; uint32_t spread; }; bool MCBitmapEffectBoxBlur::Initialize(const MCBitmapEffectBlurParameters& params, const MCRectangle& input_rect, const MCRectangle& output_rect, uint32_t *src_pixels, uint32_t src_stride) { width = output_rect . width; height = output_rect . height; left = input_rect . x - output_rect . x; top = input_rect . y - output_rect . y; right = left + input_rect . width; bottom = top + input_rect . height; stride = src_stride; int32_t t_radius; t_radius = params.radius; if (width == 0 || height == 0) t_radius = 0; // use the gaussian function (slightly tweaked with *MAGIC NUMBERS*) // to get the scale factor for the spread value spread = (uint32_t)(256 / _gaussian_value(t_radius * params.spread / 160, (float)t_radius)); y = 0; int32_t t_buff_left, t_buff_top, t_buff_right, t_buff_bottom; t_buff_top = -t_radius; t_buff_bottom = height + t_radius; t_buff_left = -t_radius; t_buff_right = width + t_radius; int32_t t_left, t_top, t_right, t_bottom; t_top = top; t_bottom = bottom; t_left = left; t_right = right; // test for input + blur radius overlapping with output if (MCU_min(right, t_buff_right) > MCU_max(left, t_buff_left) && MCU_min(bottom, t_buff_bottom) > MCU_max(top, t_buff_top)) ;// valid, yay! else m_passes = 0; // skip zero-radius passes if (t_radius == 0) m_passes = 0; pass_info = new MCBitmapEffectBoxBlurPassInfo[m_passes]; int32_t t_maxwidth = 0; for (uint32_t i=0; i<m_passes; i++) { MCBitmapEffectBoxBlurPassInfo *t_pass; t_pass = &pass_info[i]; t_pass->radius = (t_radius + (m_passes - i - 1)) / (m_passes - i); t_radius -= t_pass->radius; t_pass->window = t_pass->radius * 2 + 1; t_pass->left = MCU_max(t_left, t_buff_left); t_pass->top = MCU_max(t_top, t_buff_top); t_pass->right = MCU_min(t_right, t_buff_right); t_pass->bottom = MCU_min(t_bottom, t_buff_bottom); assert(t_pass->right >= t_pass->left && t_pass->bottom > t_pass->top); // calculate how much buffer space each pass needs // this alg requires an extra zero-ed row at the top // and column to the left t_pass->width = t_pass->right - t_pass->left; t_pass->stride = t_pass->width + 1; t_pass->height = t_pass->bottom - t_pass->top; t_pass->buffer_height = t_pass->height + 1; t_pass->buffer = new uint32_t[(t_pass->stride) * t_pass->buffer_height]; memset(pass_info[i].buffer, 0, (t_pass->stride) * t_pass->buffer_height * sizeof(uint32_t)); t_pass->buffer_nextrow = t_pass->top; t_pass->buffer_needrow = t_pass->buffer_nextrow - 1; t_maxwidth = MCU_max(t_pass->width, t_maxwidth); t_left -= t_pass->radius; t_right += t_pass->radius; t_top -= t_pass->radius; t_bottom += t_pass->radius; t_buff_left += t_pass->radius; t_buff_top += t_pass->radius; t_buff_right -= t_pass->radius; t_buff_bottom -= t_pass->radius; } row_buffer = new uint32_t[t_maxwidth]; if (m_passes > 0) pixels = src_pixels + stride * pass_info[0].top; else pixels = src_pixels; return true; } void MCBitmapEffectBoxBlur::CalculateRows(uint32_t p_pass) { MCBitmapEffectBoxBlurPassInfo *t_pass = &pass_info[p_pass]; MCBitmapEffectBoxBlurPassInfo *t_prev_pass; if (p_pass > 0) t_prev_pass = &pass_info[p_pass - 1]; uint32_t *t_sum_buffer_row, *t_sum_buffer_prev_row, *t_sum_buffer_final_row; t_sum_buffer_final_row = t_pass->buffer + (t_pass->stride * (t_pass->buffer_height - 1)); int32_t t_nextbufferrow = t_pass->buffer_nextrow - 1; while (t_nextbufferrow < 0) t_nextbufferrow += t_pass->buffer_height; t_sum_buffer_prev_row = t_pass->buffer + (t_pass->stride * (t_nextbufferrow % t_pass->buffer_height)); uint32_t *t_row_buffer; t_row_buffer = row_buffer; for (int32_t t_y = t_pass->buffer_nextrow; t_y <= t_pass->buffer_needrow; t_y++) { // get pointer for the position in our buffer where the new // sum totals will go, and also the position in the buffer of the previous // line if (p_pass != 0) { // fill the temporary row buffer by calculating the blurred pixel // values using the sum buffer from the previous pass int32_t t_top, t_bottom; t_top = MCU_max(-t_prev_pass->radius, t_prev_pass->top - t_y); // min offset from kernel midpoint t_bottom = MCU_min(t_prev_pass->bottom - t_y - 1, t_prev_pass->radius); // max offset from kernel midpoint t_prev_pass->buffer_needrow = t_bottom + t_y ; // calculate the required sum buffer rows for the previous pass CalculateRows(p_pass - 1); uint32_t *t_buff_top, *t_buff_bottom; int32_t t_nextbufferrow = t_y + t_top - 1; while (t_nextbufferrow < 0) t_nextbufferrow += t_prev_pass->buffer_height; t_buff_top = t_prev_pass->buffer + (t_prev_pass->stride * (t_nextbufferrow % t_prev_pass->buffer_height)); t_nextbufferrow = t_y + t_bottom; while (t_nextbufferrow < 0) t_nextbufferrow += t_prev_pass->buffer_height; t_buff_bottom = t_prev_pass->buffer + (t_prev_pass->stride * (t_nextbufferrow % t_prev_pass->buffer_height)); int32_t t_rel_left, t_rel_right; t_rel_left = t_prev_pass->left - t_pass->left; t_rel_right = t_prev_pass->right - t_pass->left; t_buff_top -= t_rel_left; t_buff_bottom -= t_rel_left; t_buff_top += 1; t_buff_bottom += 1; int32_t t_area; t_area = t_prev_pass->window * t_prev_pass->window; for(int32_t x = 0; x < t_pass->width; x++) { // calculate total = p(x-r, y-r) + p(x+r, y+r) - p(x+r, y-r) - p(x-r, y+r) int32_t t_left, t_right; t_left = MCU_max(-t_prev_pass->radius, t_rel_left - x); t_left -= 1; t_right = MCU_min(t_rel_right - x - 1, t_prev_pass->radius); t_row_buffer[x] = (t_buff_top[x + t_left] + t_buff_bottom[x + t_right] - t_buff_top[x + t_right] - t_buff_bottom[x + t_left]) / t_area; } } else { // copy alpha component to byte buffer uint32_t *t_pixel_ptr; t_pixel_ptr = pixels + t_pass->left; pixels += stride; for(int32_t x=0; x<t_pass->width; x++) t_row_buffer[x] = t_pixel_ptr[x] >> 24; } if (t_sum_buffer_prev_row < t_sum_buffer_final_row) t_sum_buffer_row = t_sum_buffer_prev_row + t_pass->stride; else t_sum_buffer_row = t_pass->buffer; // compute cumulative sum for this row using previous sum buffer row and // the temporary row buffer int32_t t_alpha = 0; for(int32_t x = 0; x < t_pass->width; x++) { t_alpha += t_row_buffer[x]; t_alpha += t_sum_buffer_prev_row[x+1]; t_alpha -= t_sum_buffer_prev_row[x - 1 + 1]; t_sum_buffer_row[x+1] = t_alpha; } t_sum_buffer_prev_row = t_sum_buffer_row; } t_pass->buffer_nextrow = t_pass->buffer_needrow + 1; } void MCBitmapEffectBoxBlur::Process(uint8_t *mask) { if (m_passes > 0) { uint32_t t_pass_index; t_pass_index = m_passes - 1; MCBitmapEffectBoxBlurPassInfo *t_pass; t_pass = &pass_info[t_pass_index]; if (y >= (t_pass->top - t_pass->radius) && y < (t_pass->bottom + t_pass->radius)) { int32_t t_top, t_bottom; t_top = MCU_max(-t_pass->radius, t_pass->top - y); // min offset from kernel midpoint t_bottom = MCU_min(t_pass->bottom - y - 1, t_pass->radius); // max offset from kernel midpoint int32_t t_vcount; t_vcount = t_bottom - t_top + 1; t_pass->buffer_needrow = t_bottom + y ; CalculateRows(t_pass_index); uint32_t *t_buff_top, *t_buff_bottom; int32_t t_nextbufferrow = y + t_top - 1; while (t_nextbufferrow < 0) t_nextbufferrow += t_pass->buffer_height; t_buff_top = t_pass->buffer + (t_pass->stride * (t_nextbufferrow % t_pass->buffer_height)); t_nextbufferrow = y + t_bottom; while (t_nextbufferrow < 0) t_nextbufferrow += t_pass->buffer_height; t_buff_bottom = t_pass->buffer + (t_pass->stride * (t_nextbufferrow % t_pass->buffer_height)); assert(t_buff_top[0] == 0 && t_buff_bottom[0] == 0); t_buff_top -= t_pass->left; t_buff_bottom -= t_pass->left; t_buff_top += 1; t_buff_bottom += 1; int32_t t_area; t_area = t_pass->window * t_pass->window; int32_t x; x = 0; int32_t t_sleft, t_sright; t_sleft = t_pass->left - t_pass->radius; t_sright = MCU_min(width, t_pass->right + t_pass->radius + 1); // MW_2012-04-05: [[ Bug 10146 ]] It is possible for spread to be 0, if it is // then the mask is all 0xff. // calculate minimum sum for which sum * spread / area // is greater than the maximum value int32_t t_max_val; if (spread != 0) t_max_val = 0x100 * t_area * 256 / spread; else t_max_val = 0; for(; x < t_sleft; x++) mask[x] = 0; for(; x < t_sright; x++) { // calculate total = p(x-r, y-r) + p(x+r, y+r) - p(x+r, y-r) - p(x-r, y+r) int32_t t_left, t_right; t_left = MCU_max(-t_pass->radius, t_pass->left - x); t_left -= 1; t_right = MCU_min(t_pass->right - x - 1, t_pass->radius); int32_t t_sum; t_sum = t_buff_top[x + t_left] + t_buff_bottom[x + t_right] - t_buff_top[x + t_right] - t_buff_bottom[x + t_left]; if (t_sum <= t_max_val) mask[x] = t_sum * spread / (t_area * 256); else mask[x] = 0xFF; } for(; x < width; x++) mask[x] = 0; } else { for (int32_t x=0; x < width; x++) mask[x] = 0; } } else { if (y >= top && y < bottom) { int32_t x; x = 0; int32_t t_left, t_right; t_left = MCU_min(width, left); t_right = MCU_min(width, right); for(; x < t_left; x++) mask[x] = 0; for(; x < t_right; x++) mask[x] = pixels[x] >> 24; for(; x < width; x++) mask[x] = 0; } else { for (int32_t x=0; x < width; x++) mask[x] = 0; } pixels += stride; } y += 1; } void MCBitmapEffectBoxBlur::Finalize(void) { for (uint32_t i=0; i<m_passes; i++) delete [] pass_info[i].buffer; delete [] row_buffer; delete [] pass_info; } //////////////////////////////////////////////////////////////////////////////// static bool MCBitmapEffectBlurFactory(MCBitmapEffectFilter p_type, MCBitmapEffectBlur*& r_blur) { switch(p_type) { case kMCBitmapEffectFilterFastGaussian: r_blur = new MCBitmapEffectFastGaussianBlur; return true; case kMCBitmapEffectFilterOnePassBox: r_blur = new MCBitmapEffectBoxBlur(1); return true; case kMCBitmapEffectFilterTwoPassBox: r_blur = new MCBitmapEffectBoxBlur(2); return true; case kMCBitmapEffectFilterThreePassBox: r_blur = new MCBitmapEffectBoxBlur(3); return true; default: break; } return false; }
runrevmichael/livecode
engine/src/bitmapeffectblur.cpp
C++
gpl-3.0
24,122
/* * Copyright (C) 2004 Michael Niedermayer <michaelni@gmx.at> * * This file is part of MPlayer. * * MPlayer 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 2 of the License, or * (at your option) any later version. * * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <inttypes.h> #include "mp_msg.h" #include "cpudetect.h" #include "img_format.h" #include "mp_image.h" #include "vf.h" #include "libvo/fastmemcpy.h" #include "libavcodec/avcodec.h" #include "libavutil/eval.h" struct vf_priv_s { char eq[200]; int8_t *qp; int8_t lut[257]; int qp_stride; }; static int config(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ int h= (height+15)>>4; int i; vf->priv->qp_stride= (width+15)>>4; vf->priv->qp= av_malloc(vf->priv->qp_stride*h*sizeof(int8_t)); for(i=-129; i<128; i++){ double const_values[]={ M_PI, M_E, i != -129, i, 0 }; static const char *const_names[]={ "PI", "E", "known", "qp", NULL }; double temp_val; int res; res= av_expr_parse_and_eval(&temp_val, vf->priv->eq, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, NULL); if (res < 0){ mp_msg(MSGT_VFILTER, MSGL_ERR, "qp: Error evaluating \"%s\" \n", vf->priv->eq); return 0; } vf->priv->lut[i+129]= lrintf(temp_val); } return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } static void get_image(struct vf_instance *vf, mp_image_t *mpi){ if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change // ok, we can do pp in-place (or pp disabled): vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, mpi->type, mpi->flags, mpi->w, mpi->h); mpi->planes[0]=vf->dmpi->planes[0]; mpi->stride[0]=vf->dmpi->stride[0]; mpi->width=vf->dmpi->width; if(mpi->flags&MP_IMGFLAG_PLANAR){ mpi->planes[1]=vf->dmpi->planes[1]; mpi->planes[2]=vf->dmpi->planes[2]; mpi->stride[1]=vf->dmpi->stride[1]; mpi->stride[2]=vf->dmpi->stride[2]; } mpi->flags|=MP_IMGFLAG_DIRECT; } static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; int x,y; if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ // no DR, so get a new image! hope we'll get DR buffer: vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE, mpi->w,mpi->h); } dmpi= vf->dmpi; if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h, dmpi->stride[0], mpi->stride[0]); if(mpi->flags&MP_IMGFLAG_PLANAR){ memcpy_pic(dmpi->planes[1], mpi->planes[1], mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, dmpi->stride[1], mpi->stride[1]); memcpy_pic(dmpi->planes[2], mpi->planes[2], mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, dmpi->stride[2], mpi->stride[2]); } } vf_clone_mpi_attributes(dmpi, mpi); dmpi->qscale = vf->priv->qp; dmpi->qstride= vf->priv->qp_stride; if(mpi->qscale){ for(y=0; y<((dmpi->h+15)>>4); y++){ for(x=0; x<vf->priv->qp_stride; x++){ dmpi->qscale[x + dmpi->qstride*y]= vf->priv->lut[ 129 + ((int8_t)mpi->qscale[x + mpi->qstride*y]) ]; } } }else{ int qp= vf->priv->lut[0]; for(y=0; y<((dmpi->h+15)>>4); y++){ for(x=0; x<vf->priv->qp_stride; x++){ dmpi->qscale[x + dmpi->qstride*y]= qp; } } } return vf_next_put_image(vf,dmpi, pts); } static void uninit(struct vf_instance *vf){ if(!vf->priv) return; av_free(vf->priv->qp); vf->priv->qp= NULL; av_free(vf->priv); vf->priv=NULL; } //===========================================================================// static int vf_open(vf_instance_t *vf, char *args){ vf->config=config; vf->put_image=put_image; vf->get_image=get_image; vf->uninit=uninit; vf->priv=av_malloc(sizeof(struct vf_priv_s)); memset(vf->priv, 0, sizeof(struct vf_priv_s)); // avcodec_init(); if (args) strncpy(vf->priv->eq, args, 199); return 1; } const vf_info_t vf_info_qp = { "QP changer", "qp", "Michael Niedermayer", "", vf_open, NULL };
SuperrSonic/WiiMC-SSLC
source/mplayer/libmpcodecs/vf_qp.c
C
gpl-3.0
5,685
#ifndef LOCAL_TIME_DATE_DURATION_OPERATORS_HPP___ #define LOCAL_TIME_DATE_DURATION_OPERATORS_HPP___ /* Copyright (c) 2004 CrystalClear Software, Inc. * Subject to the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or * http://www.boost.org/LICENSE_1_0.txt) * Author: Jeff Garland, Bart Garst * $Date: 2008-02-28 02:51:14 +0800 (周四, 28 二月 2008) $ */ #include "boost/date_time/gregorian/greg_duration_types.hpp" #include "boost/date_time/local_time/local_date_time.hpp" namespace boost { namespace local_time { /*!@file date_duration_operators.hpp Operators for local_date_time and * optional gregorian types. Operators use snap-to-end-of-month behavior. * Further details on this behavior can be found in reference for * date_time/date_duration_types.hpp and documentation for * month and year iterators. */ /*! Adds a months object and a local_date_time. Result will be same * day-of-month as local_date_time unless original day was the last day of month. * see date_time::months_duration for more details */ inline local_date_time operator+(const local_date_time& t, const boost::gregorian::months& m) { return t + m.get_offset(t.utc_time().date()); } /*! Adds a months object to a local_date_time. Result will be same * day-of-month as local_date_time unless original day was the last day of month. * see date_time::months_duration for more details */ inline local_date_time operator+=(local_date_time& t, const boost::gregorian::months& m) { return t += m.get_offset(t.utc_time().date()); } /*! Subtracts a months object and a local_date_time. Result will be same * day-of-month as local_date_time unless original day was the last day of month. * see date_time::months_duration for more details */ inline local_date_time operator-(const local_date_time& t, const boost::gregorian::months& m) { // get_neg_offset returns a negative duration, so we add return t + m.get_neg_offset(t.utc_time().date()); } /*! Subtracts a months object from a local_date_time. Result will be same * day-of-month as local_date_time unless original day was the last day of month. * see date_time::months_duration for more details */ inline local_date_time operator-=(local_date_time& t, const boost::gregorian::months& m) { // get_neg_offset returns a negative duration, so we add return t += m.get_neg_offset(t.utc_time().date()); } // local_date_time & years /*! Adds a years object and a local_date_time. Result will be same * month and day-of-month as local_date_time unless original day was the * last day of month. see date_time::years_duration for more details */ inline local_date_time operator+(const local_date_time& t, const boost::gregorian::years& y) { return t + y.get_offset(t.utc_time().date()); } /*! Adds a years object to a local_date_time. Result will be same * month and day-of-month as local_date_time unless original day was the * last day of month. see date_time::years_duration for more details */ inline local_date_time operator+=(local_date_time& t, const boost::gregorian::years& y) { return t += y.get_offset(t.utc_time().date()); } /*! Subtracts a years object and a local_date_time. Result will be same * month and day-of-month as local_date_time unless original day was the * last day of month. see date_time::years_duration for more details */ inline local_date_time operator-(const local_date_time& t, const boost::gregorian::years& y) { // get_neg_offset returns a negative duration, so we add return t + y.get_neg_offset(t.utc_time().date()); } /*! Subtracts a years object from a local_date_time. Result will be same * month and day-of-month as local_date_time unless original day was the * last day of month. see date_time::years_duration for more details */ inline local_date_time operator-=(local_date_time& t, const boost::gregorian::years& y) { // get_neg_offset returns a negative duration, so we add return t += y.get_neg_offset(t.utc_time().date()); } }} // namespaces #endif // LOCAL_TIME_DATE_DURATION_OPERATORS_HPP___
leejir/darkforce
third_party/boost/boost/date_time/local_time/date_duration_operators.hpp
C++
gpl-3.0
4,335
/* * Copyright (c) 2004, 2006 Hyperic, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SIGAR_PDH_H #define SIGAR_PDH_H /* performance data helpers */ #define PdhFirstObject(block) \ ((PERF_OBJECT_TYPE *)((BYTE *) block + block->HeaderLength)) #define PdhNextObject(object) \ ((PERF_OBJECT_TYPE *)((BYTE *) object + object->TotalByteLength)) #define PdhFirstCounter(object) \ ((PERF_COUNTER_DEFINITION *)((BYTE *) object + object->HeaderLength)) #define PdhNextCounter(counter) \ ((PERF_COUNTER_DEFINITION *)((BYTE *) counter + counter->ByteLength)) #define PdhGetCounterBlock(inst) \ ((PERF_COUNTER_BLOCK *)((BYTE *) inst + inst->ByteLength)) #define PdhFirstInstance(object) \ ((PERF_INSTANCE_DEFINITION *)((BYTE *) object + object->DefinitionLength)) #define PdhNextInstance(inst) \ ((PERF_INSTANCE_DEFINITION *)((BYTE *)inst + inst->ByteLength + \ PdhGetCounterBlock(inst)->ByteLength)) #define PdhInstanceName(inst) \ ((wchar_t *)((BYTE *)inst + inst->NameOffset)) #endif /* SIGAR_PDH_H */
Kiddinglife/gecoengine
thirdparty/sigar/win32/sigar_pdh.h
C
gpl-3.0
1,646
<?php // Text $_['text_title'] = '一律料金'; $_['text_description'] = '配送料(一律料金)';
huylv-hust/opencart
catalog/language/japanese/shipping/flat.php
PHP
gpl-3.0
106
// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2011 Bruno Lalande, Paris, France. // Copyright (c) 2009-2011 Mateusz Loskot, London, UK. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_GEOMETRY_UTIL_PROMOTE_FLOATING_POINT_HPP #define BOOST_GEOMETRY_UTIL_PROMOTE_FLOATING_POINT_HPP #include <boost/mpl/if.hpp> #include <boost/type_traits.hpp> namespace boost { namespace geometry { /*! \brief Meta-function converting, if necessary, to "a floating point" type \details - if input type is integer, type is double - else type is input type \ingroup utility */ template <typename T, typename PromoteIntegerTo = double> struct promote_floating_point { typedef typename boost::mpl::if_ < boost::is_integral<T>, PromoteIntegerTo, T >::type type; }; }} // namespace boost::geometry #endif // BOOST_GEOMETRY_UTIL_PROMOTE_FLOATING_POINT_HPP
beiko-lab/gengis
win32/library3rd/boost_1_47/boost/geometry/util/promote_floating_point.hpp
C++
gpl-3.0
1,394
using UnityEngine; using System.Collections; public class PlayerPrefsManager : MonoBehaviour { const string AUTOPLAY_KEY = "autoplay"; const string AWARD_KEY = "award"; const string EASYMODE_KEY = "easymode"; const string FIREBALLS_KEY = "fireballs"; const string MASTER_VOL_KEY = "master_volume"; // TODO work in progress, not in options_scene const string SPEED_KEY = "speed"; const string TOPSCORE_KEY = "topscore"; const string TRAILS_KEY = "trails"; // Autoplay public static bool GetAutoplay () { if (PlayerPrefs.GetInt (AUTOPLAY_KEY) == 1) return true; else return false; } public static void SetAutoplay (bool set) { if (set) PlayerPrefs.SetInt (AUTOPLAY_KEY, 1); else PlayerPrefs.SetInt (AUTOPLAY_KEY, 0); } // Award public static int GetAward () { return PlayerPrefs.GetInt (AWARD_KEY); } public static void SetAward (int award) { PlayerPrefs.SetInt (AWARD_KEY, award); } // Easy mode public static bool GetEasy () { if (PlayerPrefs.GetInt (EASYMODE_KEY) == 1) return true; else return false; } public static void SetEasy (bool set) { if (set) PlayerPrefs.SetInt (EASYMODE_KEY, 1); else PlayerPrefs.SetInt (EASYMODE_KEY, 0); } // Fireballs public static bool GetFireBalls () { if (PlayerPrefs.GetInt (FIREBALLS_KEY) == 1) return true; else return false; } public static void SetFireBalls (bool set) { if (set) PlayerPrefs.SetInt (FIREBALLS_KEY, 1); else PlayerPrefs.SetInt (FIREBALLS_KEY, 0); } // MasterVolume public static float GetMasterVolume () { return PlayerPrefs.GetFloat (MASTER_VOL_KEY); } public static void SetMasterVolume (float volume) { if (volume >= 0f && volume <= 1f) { PlayerPrefs.SetFloat (MASTER_VOL_KEY, volume); } else {Debug.LogError ("Master volume out of range"); } } // SpeedLimit public static float GetSpeed () { return PlayerPrefs.GetFloat (SPEED_KEY); } public static void SetSpeed (float yorn) { PlayerPrefs.SetFloat (SPEED_KEY, yorn); } // Topscore public static float GetTopscore () { return PlayerPrefs.GetFloat (TOPSCORE_KEY); } public static void SetTopscore (float yorn) { PlayerPrefs.SetFloat (TOPSCORE_KEY, yorn); } // TrippyTrails public static bool GetTrails () { if (PlayerPrefs.GetInt (TRAILS_KEY) == 1) return true; else return false; } public static void SetTrails (bool set) { if (set) PlayerPrefs.SetInt (TRAILS_KEY, 1); else PlayerPrefs.SetInt (TRAILS_KEY, 0); } }
JackDraak/2016Udemy
_BlockBreaker/Assets/Scripts/PlayerPrefsManager.cs
C#
gpl-3.0
2,382
/* * imagen2.h * * Created on: Apr 18, 2012 * Author: hkr */ #ifndef IMAGEN2_H_ #define IMAGEN2_H_ class Imagen{ private: int filas; int columnas; unsigned char** buffer; public: void crear(int,int); int get_filas() const{ //Devuelve el número de filas de m return filas; } inline int get_columnas() const{ //Devuelve el número de columnas de m return columnas; } void set_buffer(int, int, unsigned char); //Hace img(i,j)=v unsigned char get_buffer(int, int) const; //Devuelve img(i,j) void destruir(); //Libera recursos de m bool leer_imagen(const char[]); //Carga imagen en img bool escribir_imagen(const char[]); //Salva img en un archivo }; #endif /* IMAGEN2_H_ */
algui91/MP-PFinal_mp-final
include/imagen2.h
C
gpl-3.0
720
#pragma once #include "definitions.h" namespace nicp { /** * This method scales a depth image to the size specified. * @param dest is where the resized depth image will be saved. * @param src is the source depth image to resize. * @param step is the resize factor. If step is greater than 1 the image will be smaller * (for example in case it's 2 the size of the image will be half the size of the original one). */ void DepthImage_scale(DepthImage &dest, const DepthImage &src, int step, float maxDepthCov = 0.01f); /** * This method scales a depth image to the size specified. * @param dest is where the resized depth image will be saved. * @param src is the source depth image to resize. * @param step is the resize factor. If step is greater than 1 the image will be smaller * (for example in case it's 2 the size of the image will be half the size of the original one). */ void RGBImage_scale(RGBImage &dest, const RGBImage &src, int step); /** * This method converts a float cv::Mat to an unsigned char cv::Mat. * @param dest is where the converted image will be saved. * @param src is the source image to convert. * @param scale is a parameter that for example in the case of a depth image lets to convert * the depth values from a unit measure to another. Here it is assumed by default that the elements have * to be converted from millimeters to meters and so the scale is 1000. */ void DepthImage_convert_32FC1_to_16UC1(cv::Mat &dest, const cv::Mat &src, float scale = 1000.0f); /** * This method converts an unsigned char cv::Mat to a float cv::Mat. * @param dest is where the converted image will be saved. * @param src is the source image to convert. * @param scale is a parameter that for example in the case of a depth image lets to convert * the depth values from a unit measure to another. Here it is assumed by default that the elements have * to be converted from meters to millimeters and so the scale is 0.001. */ void DepthImage_convert_16UC1_to_32FC1(cv::Mat &dest, const cv::Mat &src, float scale = 0.001f); }
ankurhanda/nicp
nicp/nicp/imageutils.h
C
gpl-3.0
2,160
# Copyright (c) 2015-2016 Anish Athalye. Released under GPLv3. import tensorflow as tf import numpy as np import scipy.io import pdb MEAN_PIXEL = np.array([ 123.68 , 116.779, 103.939]) def net(data_path, input_image): layers = ( 'conv1_1', 'relu1_1', 'conv1_2', 'relu1_2', 'pool1', 'conv2_1', 'relu2_1', 'conv2_2', 'relu2_2', 'pool2', 'conv3_1', 'relu3_1', 'conv3_2', 'relu3_2', 'conv3_3', 'relu3_3', 'conv3_4', 'relu3_4', 'pool3', 'conv4_1', 'relu4_1', 'conv4_2', 'relu4_2', 'conv4_3', 'relu4_3', 'conv4_4', 'relu4_4', 'pool4', 'conv5_1', 'relu5_1', 'conv5_2', 'relu5_2', 'conv5_3', 'relu5_3', 'conv5_4', 'relu5_4' ) data = scipy.io.loadmat(data_path) mean = data['normalization'][0][0][0] mean_pixel = np.mean(mean, axis=(0, 1)) weights = data['layers'][0] net = {} current = input_image for i, name in enumerate(layers): kind = name[:4] if kind == 'conv': kernels, bias = weights[i][0][0][0][0] # matconvnet: weights are [width, height, in_channels, out_channels] # tensorflow: weights are [height, width, in_channels, out_channels] kernels = np.transpose(kernels, (1, 0, 2, 3)) bias = bias.reshape(-1) current = _conv_layer(current, kernels, bias) elif kind == 'relu': current = tf.nn.relu(current) elif kind == 'pool': current = _pool_layer(current) net[name] = current assert len(net) == len(layers) return net def _conv_layer(input, weights, bias): conv = tf.nn.conv2d(input, tf.constant(weights), strides=(1, 1, 1, 1), padding='SAME') return tf.nn.bias_add(conv, bias) def _pool_layer(input): return tf.nn.max_pool(input, ksize=(1, 2, 2, 1), strides=(1, 2, 2, 1), padding='SAME') def preprocess(image): return image - MEAN_PIXEL def unprocess(image): return image + MEAN_PIXEL
mgoubran/MeuralPaint
vgg.py
Python
gpl-3.0
1,993
<?php /** * Element type manager class * * @package TorroForms * @since 1.0.0 */ namespace awsmug\Torro_Forms\DB_Objects\Elements\Element_Types; use Leaves_And_Love\Plugin_Lib\Service; use Leaves_And_Love\Plugin_Lib\Traits\Container_Service_Trait; use Leaves_And_Love\Plugin_Lib\Traits\Hook_Service_Trait; use awsmug\Torro_Forms\DB_Objects\Elements\Element_Manager; use awsmug\Torro_Forms\Error; use awsmug\Torro_Forms\Assets; use Leaves_And_Love\Plugin_Lib\Error_Handler; use Leaves_And_Love\Plugin_Lib\Fields\Field_Manager; /** * Manager class for element types. * * @since 1.0.0 * * @method Element_Manager elements() * @method Assets assets() * @method Error_Handler error_handler() */ class Element_Type_Manager extends Service { use Container_Service_Trait, Hook_Service_Trait; /** * Registered element types. * * @since 1.0.0 * @var array */ protected $element_types = array(); /** * Default element types definition. * * @since 1.0.0 * @var array */ protected $default_element_types = array(); /** * The element manager service definition. * * @since 1.0.0 * @static * @var string */ protected static $service_elements = Element_Manager::class; /** * The Assets API service definition. * * @since 1.0.0 * @static * @var string */ protected static $service_assets = Assets::class; /** * Constructor. * * @since 1.0.0 * * @param string $prefix The instance prefix. * @param array $services { * Array of service instances. * * @type Element_Manager $elements The element manager instance. * @type Assets $assets The assets instance. * @type Error_Handler $error_handler The error handler instance. * } */ public function __construct( $prefix, $services ) { $this->set_prefix( $prefix ); $this->set_services( $services ); $this->setup_hooks(); Field_Manager::register_field_type( 'torrochoices', Choices_Field::class ); Field_Manager::register_field_type( 'tel', Tel_Field::class ); $this->default_element_types = array( 'textfield' => Base\Textfield::class, 'textarea' => Base\Textarea::class, 'content' => Base\Content::class, 'dropdown' => Base\Dropdown::class, 'onechoice' => Base\Onechoice::class, 'multiplechoice' => Base\Multiplechoice::class, 'media' => Base\Media::class, 'checkbox' => Base\Checkbox::class, ); } /** * Checks whether a specific element type is registered. * * @since 1.0.0 * * @param string $slug Element type slug. * @return bool True if the element type is registered, false otherwise. */ public function has( $slug ) { return isset( $this->element_types[ $slug ] ); } /** * Returns a specific registered element type. * * @since 1.0.0 * * @param string $slug Element type slug. * @return Element_Type|Error Element type instance, or error object if element type is not registered. */ public function get( $slug ) { if ( ! $this->has( $slug ) ) { /* translators: %s: element type slug */ return new Error( $this->get_prefix() . 'element_type_not_exist', sprintf( __( 'An element type with the slug %s does not exist.', 'torro-forms' ), $slug ), __METHOD__, '1.0.0' ); } return $this->element_types[ $slug ]; } /** * Returns all registered element types. * * @since 1.0.0 * * @return array Associative array of `$slug => $element_type_instance` pairs. */ public function get_all() { return $this->element_types; } /** * Registers a new element type. * * @since 1.0.0 * * @param string $slug Element type slug. * @param string $element_type_class_name Element type class name. * @return bool|Error True on success, error object on failure. */ public function register( $slug, $element_type_class_name ) { if ( ! did_action( 'init' ) ) { /* translators: 1: element type slug, 2: init hookname */ return new Error( $this->get_prefix() . 'element_type_too_early', sprintf( __( 'The element type %1$s cannot be registered before the %2$s hook.', 'torro-forms' ), $slug, '<code>init</code>' ), __METHOD__, '1.0.0' ); } if ( $this->has( $slug ) ) { /* translators: %s: element type slug */ return new Error( $this->get_prefix() . 'element_type_already_exist', sprintf( __( 'An element type with the slug %s already exists.', 'torro-forms' ), $slug ), __METHOD__, '1.0.0' ); } if ( ! class_exists( $element_type_class_name ) ) { /* translators: %s: element type class name */ return new Error( $this->get_prefix() . 'element_type_class_not_exist', sprintf( __( 'The class %s does not exist.', 'torro-forms' ), $element_type_class_name ), __METHOD__, '1.0.0' ); } if ( ! is_subclass_of( $element_type_class_name, Element_Type::class ) ) { /* translators: %s: element type class name */ return new Error( $this->get_prefix() . 'element_type_class_not_allowed', sprintf( __( 'The class %s is not allowed for a element type.', 'torro-forms' ), $element_type_class_name ), __METHOD__, '1.0.0' ); } $this->element_types[ $slug ] = new $element_type_class_name( $this ); return true; } /** * Unregisters a new element type. * * @since 1.0.0 * * @param string $slug Element type slug. * @return bool|Error True on success, error object on failure. */ public function unregister( $slug ) { if ( ! $this->has( $slug ) ) { /* translators: %s: element type slug */ return new Error( $this->get_prefix() . 'element_type_not_exist', sprintf( __( 'An element type with the slug %s does not exist.', 'torro-forms' ), $slug ), __METHOD__, '1.0.0' ); } if ( isset( $this->default_element_types[ $slug ] ) ) { /* translators: %s: element type slug */ return new Error( $this->get_prefix() . 'element_type_is_default', sprintf( __( 'The default element type %s cannot be unregistered.', 'torro-forms' ), $slug ), __METHOD__, '1.0.0' ); } unset( $this->element_types[ $slug ] ); return true; } /** * Registers the default element types. * * The function also executes a hook that should be used by other developers to register their own element types. * * @since 1.0.0 */ protected function register_defaults() { foreach ( $this->default_element_types as $slug => $element_type_class_name ) { $this->register( $slug, $element_type_class_name ); } /** * Fires when the default element types have been registered. * * This action should be used to register custom element types. * * @since 1.0.0 * * @param Element_Type_Manager $element_types Element type manager instance. */ do_action( "{$this->get_prefix()}register_element_types", $this ); } /** * Enqueues form builder scripts for the available element types. * * @since 1.0.0 */ protected function enqueue_admin_scripts() { $services = array( 'ajax' => $this->elements()->ajax(), 'assets' => $this->elements()->assets(), 'error_handler' => $this->elements()->error_handler(), ); $dummy_manager = new Field_Manager( $this->get_prefix() . 'dummy_', $services, array( 'get_value_callback' => '__return_empty_array', 'update_value_callback' => '__return_empty_array', 'name_prefix' => $this->get_prefix() . 'dummy', 'field_required_markup' => '<span class="screen-reader-text">' . _x( '(required)', 'field required indicator', 'torro-forms' ) . '</span><span class="torro-required-indicator" aria-hidden="true">*</span>', 'skip_js_initialization' => true, ) ); $added = array(); foreach ( $this->element_types as $slug => $element_type ) { $fields = $element_type->get_settings_fields(); foreach ( $fields as $field ) { if ( in_array( $field['type'], $added, true ) ) { continue; } $dummy_manager->add( 'dummy_' . $field['type'], $field['type'], array( 'section' => 'main', 'label' => sprintf( 'Dummy %s', $field['type'] ), ) ); $added[] = $field['type']; } } $dummy_manager->enqueue(); } /** * Sets up all action and filter hooks for the service. * * This method must be implemented and then be called from the constructor. * * @since 1.0.0 */ protected function setup_hooks() { $this->actions = array( array( 'name' => 'init', 'callback' => array( $this, 'register_defaults' ), 'priority' => 1, 'num_args' => 0, ), array( 'name' => "{$this->get_prefix()}enqueue_form_builder_scripts", 'callback' => array( $this, 'enqueue_admin_scripts' ), 'priority' => 1, 'num_args' => 0, ), ); } }
awsmug/awesome-forms
src/src/db-objects/elements/element-types/element-type-manager.php
PHP
gpl-3.0
8,678
/* * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood * 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 copyright holders 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 * OWNER 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. */ // modified by Dan Gibson on 05/20/05 to accomidate FASTER // >32 set lengths, using an array of ints w/ 32 bits/int #ifndef __MEM_RUBY_COMMON_SET_HH__ #define __MEM_RUBY_COMMON_SET_HH__ #include <bitset> #include <cassert> #include <iostream> #include "base/logging.hh" #include "mem/ruby/common/TypeDefines.hh" // Change for systems with more than 64 controllers of a particular type. const int NUMBER_BITS_PER_SET = 64; class Set { private: // Number of bits in use in this set. int m_nSize; std::bitset<NUMBER_BITS_PER_SET> bits; public: Set() : m_nSize(0) {} Set(int size) : m_nSize(size) { if (size > NUMBER_BITS_PER_SET) fatal("Number of bits(%d) < size specified(%d). " "Increase the number of bits and recompile.\n", NUMBER_BITS_PER_SET, size); } Set(const Set& obj) : m_nSize(obj.m_nSize), bits(obj.bits) {} ~Set() {} Set& operator=(const Set& obj) { m_nSize = obj.m_nSize; bits = obj.bits; return *this; } void add(NodeID index) { bits.set(index); } /* * This function should set all the bits in the current set that are * already set in the parameter set */ void addSet(const Set& obj) { assert(m_nSize == obj.m_nSize); bits |= obj.bits; } /* * This function clears bits that are =1 in the parameter set */ void remove(NodeID index) { bits.reset(index); } /* * This function clears bits that are =1 in the parameter set */ void removeSet(const Set& obj) { assert(m_nSize == obj.m_nSize); bits &= (~obj.bits); } void clear() { bits.reset(); } /* * this function sets all bits in the set */ void broadcast() { bits.set(); for (int j = m_nSize; j < NUMBER_BITS_PER_SET; ++j) { bits.reset(j); } } /* * This function returns the population count of 1's in the set */ int count() const { return bits.count(); } /* * This function checks for set equality */ bool isEqual(const Set& obj) const { assert(m_nSize == obj.m_nSize); return bits == obj.bits; } // return the logical OR of this set and orSet Set OR(const Set& obj) const { assert(m_nSize == obj.m_nSize); Set r(m_nSize); r.bits = bits | obj.bits; return r; }; // return the logical AND of this set and andSet Set AND(const Set& obj) const { assert(m_nSize == obj.m_nSize); Set r(m_nSize); r.bits = bits & obj.bits; return r; } // Returns true if the intersection of the two sets is empty bool intersectionIsEmpty(const Set& obj) const { std::bitset<NUMBER_BITS_PER_SET> r = bits & obj.bits; return r.none(); } /* * Returns false if a bit is set in the parameter set that is NOT set * in this set */ bool isSuperset(const Set& test) const { assert(m_nSize == test.m_nSize); std::bitset<NUMBER_BITS_PER_SET> r = bits | test.bits; return (r == bits); } bool isSubset(const Set& test) const { return test.isSuperset(*this); } bool isElement(NodeID element) const { return bits.test(element); } /* * this function returns true iff all bits in use are set */ bool isBroadcast() const { return (bits.count() == m_nSize); } bool isEmpty() const { return bits.none(); } NodeID smallestElement() const { for (int i = 0; i < m_nSize; ++i) { if (bits.test(i)) { return i; } } panic("No smallest element of an empty set."); } bool elementAt(int index) const { return bits[index]; } int getSize() const { return m_nSize; } void setSize(int size) { if (size > NUMBER_BITS_PER_SET) fatal("Number of bits(%d) < size specified(%d). " "Increase the number of bits and recompile.\n", NUMBER_BITS_PER_SET, size); m_nSize = size; bits.reset(); } void print(std::ostream& out) const { out << "[Set (" << m_nSize << "): " << bits << "]"; } }; inline std::ostream& operator<<(std::ostream& out, const Set& obj) { obj.print(out); out << std::flush; return out; } #endif // __MEM_RUBY_COMMON_SET_HH__
vineodd/PIMSim
GEM5Simulation/gem5/src/mem/ruby/common/Set.hh
C++
gpl-3.0
6,118
/////////////////////////////////////////////////////////////////////////// // // Copyright (C) Microsoft Corporation. All Rights Reserved. // // File: d3dx9core.h // Content: D3DX core types and functions // /////////////////////////////////////////////////////////////////////////// #include "d3dx9.h" #ifndef __D3DX9CORE_H__ #define __D3DX9CORE_H__ #define D3DX_VERSION 0x0902 #define D3DX_SDK_VERSION 43 #ifdef __cplusplus extern "C" { #endif //__cplusplus BOOL WINAPI D3DXCheckVersion(UINT D3DSdkVersion, UINT D3DXSdkVersion); BOOL WINAPI D3DXDebugMute(BOOL Mute); UINT WINAPI D3DXGetDriverLevel(LPDIRECT3DDEVICE9 pDevice); #ifdef __cplusplus } #endif //__cplusplus typedef interface ID3DXBuffer ID3DXBuffer; typedef interface ID3DXBuffer *LPD3DXBUFFER; // {8BA5FB08-5195-40e2-AC58-0D989C3A0102} DEFINE_GUID(IID_ID3DXBuffer, 0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2); #undef INTERFACE #define INTERFACE ID3DXBuffer DECLARE_INTERFACE_(ID3DXBuffer, IUnknown) { // IUnknown STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; // ID3DXBuffer STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; }; #define D3DXSPRITE_DONOTSAVESTATE (1 << 0) #define D3DXSPRITE_DONOTMODIFY_RENDERSTATE (1 << 1) #define D3DXSPRITE_OBJECTSPACE (1 << 2) #define D3DXSPRITE_BILLBOARD (1 << 3) #define D3DXSPRITE_ALPHABLEND (1 << 4) #define D3DXSPRITE_SORT_TEXTURE (1 << 5) #define D3DXSPRITE_SORT_DEPTH_FRONTTOBACK (1 << 6) #define D3DXSPRITE_SORT_DEPTH_BACKTOFRONT (1 << 7) #define D3DXSPRITE_DO_NOT_ADDREF_TEXTURE (1 << 8) typedef interface ID3DXSprite ID3DXSprite; typedef interface ID3DXSprite *LPD3DXSPRITE; // {BA0B762D-7D28-43ec-B9DC-2F84443B0614} DEFINE_GUID(IID_ID3DXSprite, 0xba0b762d, 0x7d28, 0x43ec, 0xb9, 0xdc, 0x2f, 0x84, 0x44, 0x3b, 0x6, 0x14); #undef INTERFACE #define INTERFACE ID3DXSprite DECLARE_INTERFACE_(ID3DXSprite, IUnknown) { // IUnknown STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; // ID3DXSprite STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; STDMETHOD(GetTransform)(THIS_ D3DXMATRIX *pTransform) PURE; STDMETHOD(SetTransform)(THIS_ CONST D3DXMATRIX *pTransform) PURE; STDMETHOD(SetWorldViewRH)(THIS_ CONST D3DXMATRIX *pWorld, CONST D3DXMATRIX *pView) PURE; STDMETHOD(SetWorldViewLH)(THIS_ CONST D3DXMATRIX *pWorld, CONST D3DXMATRIX *pView) PURE; STDMETHOD(Begin)(THIS_ DWORD Flags) PURE; STDMETHOD(Draw)(THIS_ LPDIRECT3DTEXTURE9 pTexture, CONST RECT *pSrcRect, CONST D3DXVECTOR3 *pCenter, CONST D3DXVECTOR3 *pPosition, D3DCOLOR Color) PURE; STDMETHOD(Flush)(THIS) PURE; STDMETHOD(End)(THIS) PURE; STDMETHOD(OnLostDevice)(THIS) PURE; STDMETHOD(OnResetDevice)(THIS) PURE; }; #ifdef __cplusplus extern "C" { #endif //__cplusplus HRESULT WINAPI D3DXCreateSprite( LPDIRECT3DDEVICE9 pDevice, LPD3DXSPRITE* ppSprite); #ifdef __cplusplus } #endif //__cplusplus typedef struct _D3DXFONT_DESCA { INT Height; UINT Width; UINT Weight; UINT MipLevels; BOOL Italic; BYTE CharSet; BYTE OutputPrecision; BYTE Quality; BYTE PitchAndFamily; CHAR FaceName[LF_FACESIZE]; } D3DXFONT_DESCA, *LPD3DXFONT_DESCA; typedef struct _D3DXFONT_DESCW { INT Height; UINT Width; UINT Weight; UINT MipLevels; BOOL Italic; BYTE CharSet; BYTE OutputPrecision; BYTE Quality; BYTE PitchAndFamily; WCHAR FaceName[LF_FACESIZE]; } D3DXFONT_DESCW, *LPD3DXFONT_DESCW; #ifdef UNICODE typedef D3DXFONT_DESCW D3DXFONT_DESC; typedef LPD3DXFONT_DESCW LPD3DXFONT_DESC; #else typedef D3DXFONT_DESCA D3DXFONT_DESC; typedef LPD3DXFONT_DESCA LPD3DXFONT_DESC; #endif typedef interface ID3DXFont ID3DXFont; typedef interface ID3DXFont *LPD3DXFONT; // {D79DBB70-5F21-4d36-BBC2-FF525C213CDC} DEFINE_GUID(IID_ID3DXFont, 0xd79dbb70, 0x5f21, 0x4d36, 0xbb, 0xc2, 0xff, 0x52, 0x5c, 0x21, 0x3c, 0xdc); #undef INTERFACE #define INTERFACE ID3DXFont DECLARE_INTERFACE_(ID3DXFont, IUnknown) { // IUnknown STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; // ID3DXFont STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9 *ppDevice) PURE; STDMETHOD(GetDescA)(THIS_ D3DXFONT_DESCA *pDesc) PURE; STDMETHOD(GetDescW)(THIS_ D3DXFONT_DESCW *pDesc) PURE; STDMETHOD_(BOOL, GetTextMetricsA)(THIS_ TEXTMETRICA *pTextMetrics) PURE; STDMETHOD_(BOOL, GetTextMetricsW)(THIS_ TEXTMETRICW *pTextMetrics) PURE; STDMETHOD_(HDC, GetDC)(THIS) PURE; STDMETHOD(GetGlyphData)(THIS_ UINT Glyph, LPDIRECT3DTEXTURE9 *ppTexture, RECT *pBlackBox, POINT *pCellInc) PURE; STDMETHOD(PreloadCharacters)(THIS_ UINT First, UINT Last) PURE; STDMETHOD(PreloadGlyphs)(THIS_ UINT First, UINT Last) PURE; STDMETHOD(PreloadTextA)(THIS_ LPCSTR pString, INT Count) PURE; STDMETHOD(PreloadTextW)(THIS_ LPCWSTR pString, INT Count) PURE; STDMETHOD_(INT, DrawTextA)(THIS_ LPD3DXSPRITE pSprite, LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; STDMETHOD_(INT, DrawTextW)(THIS_ LPD3DXSPRITE pSprite, LPCWSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; STDMETHOD(OnLostDevice)(THIS) PURE; STDMETHOD(OnResetDevice)(THIS) PURE; #ifdef __cplusplus #ifdef UNICODE HRESULT GetDesc(D3DXFONT_DESCW *pDesc) { return GetDescW(pDesc); } HRESULT PreloadText(LPCWSTR pString, INT Count) { return PreloadTextW(pString, Count); } #else HRESULT GetDesc(D3DXFONT_DESCA *pDesc) { return GetDescA(pDesc); } HRESULT PreloadText(LPCSTR pString, INT Count) { return PreloadTextA(pString, Count); } #endif #endif //__cplusplus }; #ifndef GetTextMetrics #ifdef UNICODE #define GetTextMetrics GetTextMetricsW #else #define GetTextMetrics GetTextMetricsA #endif #endif #ifndef DrawText #ifdef UNICODE #define DrawText DrawTextW #else #define DrawText DrawTextA #endif #endif #ifdef __cplusplus extern "C" { #endif //__cplusplus HRESULT WINAPI D3DXCreateFontA( LPDIRECT3DDEVICE9 pDevice, INT Height, UINT Width, UINT Weight, UINT MipLevels, BOOL Italic, DWORD CharSet, DWORD OutputPrecision, DWORD Quality, DWORD PitchAndFamily, LPCSTR pFaceName, LPD3DXFONT* ppFont); HRESULT WINAPI D3DXCreateFontW( LPDIRECT3DDEVICE9 pDevice, INT Height, UINT Width, UINT Weight, UINT MipLevels, BOOL Italic, DWORD CharSet, DWORD OutputPrecision, DWORD Quality, DWORD PitchAndFamily, LPCWSTR pFaceName, LPD3DXFONT* ppFont); #ifdef UNICODE #define D3DXCreateFont D3DXCreateFontW #else #define D3DXCreateFont D3DXCreateFontA #endif HRESULT WINAPI D3DXCreateFontIndirectA( LPDIRECT3DDEVICE9 pDevice, CONST D3DXFONT_DESCA* pDesc, LPD3DXFONT* ppFont); HRESULT WINAPI D3DXCreateFontIndirectW( LPDIRECT3DDEVICE9 pDevice, CONST D3DXFONT_DESCW* pDesc, LPD3DXFONT* ppFont); #ifdef UNICODE #define D3DXCreateFontIndirect D3DXCreateFontIndirectW #else #define D3DXCreateFontIndirect D3DXCreateFontIndirectA #endif #ifdef __cplusplus } #endif //__cplusplus typedef struct _D3DXRTS_DESC { UINT Width; UINT Height; D3DFORMAT Format; BOOL DepthStencil; D3DFORMAT DepthStencilFormat; } D3DXRTS_DESC, *LPD3DXRTS_DESC; typedef interface ID3DXRenderToSurface ID3DXRenderToSurface; typedef interface ID3DXRenderToSurface *LPD3DXRENDERTOSURFACE; // {6985F346-2C3D-43b3-BE8B-DAAE8A03D894} DEFINE_GUID(IID_ID3DXRenderToSurface, 0x6985f346, 0x2c3d, 0x43b3, 0xbe, 0x8b, 0xda, 0xae, 0x8a, 0x3, 0xd8, 0x94); #undef INTERFACE #define INTERFACE ID3DXRenderToSurface DECLARE_INTERFACE_(ID3DXRenderToSurface, IUnknown) { // IUnknown STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; // ID3DXRenderToSurface STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; STDMETHOD(GetDesc)(THIS_ D3DXRTS_DESC* pDesc) PURE; STDMETHOD(BeginScene)(THIS_ LPDIRECT3DSURFACE9 pSurface, CONST D3DVIEWPORT9* pViewport) PURE; STDMETHOD(EndScene)(THIS_ DWORD MipFilter) PURE; STDMETHOD(OnLostDevice)(THIS) PURE; STDMETHOD(OnResetDevice)(THIS) PURE; }; #ifdef __cplusplus extern "C" { #endif //__cplusplus HRESULT WINAPI D3DXCreateRenderToSurface( LPDIRECT3DDEVICE9 pDevice, UINT Width, UINT Height, D3DFORMAT Format, BOOL DepthStencil, D3DFORMAT DepthStencilFormat, LPD3DXRENDERTOSURFACE* ppRenderToSurface); #ifdef __cplusplus } #endif //__cplusplus typedef struct _D3DXRTE_DESC { UINT Size; UINT MipLevels; D3DFORMAT Format; BOOL DepthStencil; D3DFORMAT DepthStencilFormat; } D3DXRTE_DESC, *LPD3DXRTE_DESC; typedef interface ID3DXRenderToEnvMap ID3DXRenderToEnvMap; typedef interface ID3DXRenderToEnvMap *LPD3DXRenderToEnvMap; // {313F1B4B-C7B0-4fa2-9D9D-8D380B64385E} DEFINE_GUID(IID_ID3DXRenderToEnvMap, 0x313f1b4b, 0xc7b0, 0x4fa2, 0x9d, 0x9d, 0x8d, 0x38, 0xb, 0x64, 0x38, 0x5e); #undef INTERFACE #define INTERFACE ID3DXRenderToEnvMap DECLARE_INTERFACE_(ID3DXRenderToEnvMap, IUnknown) { // IUnknown STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; // ID3DXRenderToEnvMap STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; STDMETHOD(GetDesc)(THIS_ D3DXRTE_DESC* pDesc) PURE; STDMETHOD(BeginCube)(THIS_ LPDIRECT3DCUBETEXTURE9 pCubeTex) PURE; STDMETHOD(BeginSphere)(THIS_ LPDIRECT3DTEXTURE9 pTex) PURE; STDMETHOD(BeginHemisphere)(THIS_ LPDIRECT3DTEXTURE9 pTexZPos, LPDIRECT3DTEXTURE9 pTexZNeg) PURE; STDMETHOD(BeginParabolic)(THIS_ LPDIRECT3DTEXTURE9 pTexZPos, LPDIRECT3DTEXTURE9 pTexZNeg) PURE; STDMETHOD(Face)(THIS_ D3DCUBEMAP_FACES Face, DWORD MipFilter) PURE; STDMETHOD(End)(THIS_ DWORD MipFilter) PURE; STDMETHOD(OnLostDevice)(THIS) PURE; STDMETHOD(OnResetDevice)(THIS) PURE; }; #ifdef __cplusplus extern "C" { #endif //__cplusplus HRESULT WINAPI D3DXCreateRenderToEnvMap( LPDIRECT3DDEVICE9 pDevice, UINT Size, UINT MipLevels, D3DFORMAT Format, BOOL DepthStencil, D3DFORMAT DepthStencilFormat, LPD3DXRenderToEnvMap* ppRenderToEnvMap); #ifdef __cplusplus } #endif //__cplusplus typedef interface ID3DXLine ID3DXLine; typedef interface ID3DXLine *LPD3DXLINE; // {D379BA7F-9042-4ac4-9F5E-58192A4C6BD8} DEFINE_GUID(IID_ID3DXLine, 0xd379ba7f, 0x9042, 0x4ac4, 0x9f, 0x5e, 0x58, 0x19, 0x2a, 0x4c, 0x6b, 0xd8); #undef INTERFACE #define INTERFACE ID3DXLine DECLARE_INTERFACE_(ID3DXLine, IUnknown) { // IUnknown STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; // ID3DXLine STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; STDMETHOD(Begin)(THIS) PURE; STDMETHOD(Draw)(THIS_ CONST D3DXVECTOR2 *pVertexList, DWORD dwVertexListCount, D3DCOLOR Color) PURE; STDMETHOD(DrawTransform)(THIS_ CONST D3DXVECTOR3 *pVertexList, DWORD dwVertexListCount, CONST D3DXMATRIX* pTransform, D3DCOLOR Color) PURE; STDMETHOD(SetPattern)(THIS_ DWORD dwPattern) PURE; STDMETHOD_(DWORD, GetPattern)(THIS) PURE; STDMETHOD(SetPatternScale)(THIS_ FLOAT fPatternScale) PURE; STDMETHOD_(FLOAT, GetPatternScale)(THIS) PURE; STDMETHOD(SetWidth)(THIS_ FLOAT fWidth) PURE; STDMETHOD_(FLOAT, GetWidth)(THIS) PURE; STDMETHOD(SetAntialias)(THIS_ BOOL bAntialias) PURE; STDMETHOD_(BOOL, GetAntialias)(THIS) PURE; STDMETHOD(SetGLLines)(THIS_ BOOL bGLLines) PURE; STDMETHOD_(BOOL, GetGLLines)(THIS) PURE; STDMETHOD(End)(THIS) PURE; STDMETHOD(OnLostDevice)(THIS) PURE; STDMETHOD(OnResetDevice)(THIS) PURE; }; #ifdef __cplusplus extern "C" { #endif //__cplusplus HRESULT WINAPI D3DXCreateLine( LPDIRECT3DDEVICE9 pDevice, LPD3DXLINE* ppLine); #ifdef __cplusplus } #endif //__cplusplus #endif //__D3DX9CORE_H__
sergiobenrocha2/RetroArch
gfx/include/d3d9/d3dx9core.h
C
gpl-3.0
13,477
// vendor var React = require('react'), $ = require('jquery'), moment = require('moment'), PouchDB = require('pouchdb'), ps = require('../../common/js/pubsub'), cookies = require('../../common/js/cookies'); // pouch plugin // PouchDB.plugin(require('pouchdb-upsert')); // components var Title = require('./components/baseComponents/Title'), Header = require('./components/Header'), Footer = require('./components/Footer'), Question = require('./components/Question'), Note = require('./components/Note'), MultipleChoice = require('./components/MultipleChoice'), Photo = require('./components/Photo'), Location = require('./components/Location'), Facility = require('./components/Facility'), Submit = require('./components/Submit'), Splash = require('./components/Splash'), Loading = require('./components/Loading'), // api services PhotoAPI = require('./api/PhotoAPI'), FacilityTree = require('./api/FacilityAPI'); /* * Create Single Page App with three main components * Header, Content, Footer */ var Application = React.createClass({ getInitialState: function() { // Set up db for photos and facility tree var trees = {}; var surveyDB = new PouchDB(this.props.survey.id, { 'auto_compaction': true }); // loading state, unless there are no facility nodes var init_state = 0; window.surveyDB = surveyDB; // Build initial linked list var questions = this.props.survey.nodes; var first_question = null; questions.forEach(function(node, idx) { var question = node; question.prev = null; question.next = null; if (idx > 0) { question.prev = questions[idx - 1]; } if (idx < questions.length - 1) { question.next = questions[idx + 1]; } if (idx === 0) { first_question = question; } }); this.questions = questions; // // Recursively construct trees // var has_facility_node = this.buildTrees(questions, trees); // if (!has_facility_node) { // init_state = 1; // } // set default lang -- use user pref stored in localStorage, // falling back to survey default if the user pref is not available // for this survey var language = this.props.survey.default_language; if (localStorage['default_language'] && this.props.survey.languages.indexOf(localStorage['default_language']) !== -1) { language = localStorage['default_language']; } // user stuff var logged_in = window.CURRENT_USER !== undefined; if (logged_in) { localStorage['submitter_name'] = window.CURRENT_USER.name; localStorage['submitter_email'] = window.CURRENT_USER.email; } return { showDontKnow: false, showDontKnowBox: false, head: first_question, question: null, headStack: [], //XXX Stack of linked list heads states: { LOADING: 0, SPLASH: 1, QUESTION: 2, SUBMIT: 3 }, language: language, state: init_state, trees: trees, loggedIn: logged_in, hasFacilities: null, db: surveyDB }; }, componentWillMount: function() { var self = this; ps.subscribe('loading:progress', function() { // unused as of this moment, since we can't know the content-length // due to gzipping. }); ps.subscribe('loading:complete', function() { console.log('LOADING COMPLETE'); self.setState({ state: 1 }); }); ps.subscribe('settings:language_changed', function(e, lang) { self.setState({ language: lang }); localStorage['default_language'] = lang; }); // handle revisit:reload_facilities event by flushing existing facilities // and refreshing page. ps.subscribe('revisit:reload_facilities', function() { localStorage.removeItem('facilities'); window.location.reload(); }); }, componentDidMount: function() { // Recursively construct trees var has_facility_node = this.buildTrees(this.questions, this.state.trees), state = has_facility_node ? 0 : 1; if (!has_facility_node) { this.setState({ state: 1 }); } else { this.setState({ hasFacilities: true }); } }, /* * Create Facility Tree object at node id for every facility tree question * Recurse into subnodes if found * * @questions: all nodes at current sub level * @trees: dictionary of question ids and facility trees * * NOTE: facility trees update exact same location in pouchdb (based on bounds of coordinates) * i.e: Multiple trees with same bounds do not increase memory usage (network usage does increase though) */ buildTrees: function(questions, trees) { var self = this, has_facility_node = false; questions = questions || []; questions.forEach(function(node) { if (node.type_constraint === 'facility') { has_facility_node = true; trees[node.id] = new FacilityTree( parseFloat(node.logic.nlat), parseFloat(node.logic.wlng), parseFloat(node.logic.slat), parseFloat(node.logic.elng), window.surveyDB, node.id ); } if (node.sub_surveys) { node.sub_surveys.forEach(function(subs) { has_facility_node = self.buildTrees(subs.nodes, trees); }); } }); return has_facility_node; }, /** * Sets the start time on the survey, to be saved with submission. */ onSurveyStart: function() { console.log('onSurveyStart -- setting start_time'); var surveyID = this.props.survey.id; var survey = JSON.parse(localStorage[surveyID] || '{}'); survey.start_time = new Date().toISOString(); localStorage[surveyID] = JSON.stringify(survey); }, /* * Load next question, updates state of the Application * if next question is not found move to either SPLASH/SUBMIT * * Deals with branching, required and setting up dontknow footer state * Uses refs! (Could be removed) */ onNextButton: function() { var self = this, surveyID = this.props.survey.id, currentState = this.state.state, currentQuestion = this.state.question; // Set up next state var nextQuestion = null, showDontKnow = false, showDontKnowBox = false, state = this.state.states.SPLASH, head = this.state.head, headStack = this.state.headStack; var questionID; console.log('Current Question', currentQuestion); switch (currentState) { case this.state.states.LOADING: nextQuestion = null; showDontKnow = false; showDontKnowBox = false; state = this.state.states.LOADING; //XXX Fire Modal for submitting here this.onSave(); // Reset Survey Linked List head = this.state.headStack[0] || head; while (head.prev) { head = head.prev; } headStack = []; break; // On Submit page and next was pressed case this.state.states.SUBMIT: nextQuestion = null; showDontKnow = false; showDontKnowBox = false; state = this.state.states.SPLASH; //XXX Fire Modal for submitting here this.onSave(); // Reset Survey Linked List head = this.state.headStack[0] || head; while (head.prev) { head = head.prev; } headStack = []; break; // On Splash page and next was pressed case this.state.states.SPLASH: nextQuestion = this.state.head; showDontKnow = nextQuestion.allow_dont_know || false; showDontKnowBox = false; state = this.state.states.QUESTION; this.onSurveyStart(); questionID = nextQuestion.id; if (showDontKnow) { var response = this.refs.footer.getAnswer(questionID); console.log('Footer response:', response); showDontKnowBox = Boolean(response); } break; case this.state.states.QUESTION: // Look into active answers, check if any filled out if question is REQUIRED var required = currentQuestion.required || false, survey, answers; if (required) { questionID = currentQuestion.id; survey = JSON.parse(localStorage[surveyID] || '{}'); answers = (survey[questionID] || []).filter(function(response) { return (response && response.response !== null); }); if (!answers.length) { alert('Valid response is required.'); return; } } // Get answer questionID = currentQuestion.id; survey = JSON.parse(localStorage[surveyID] || '{}'); answers = (survey[questionID] || []).filter(function(response) { return (response && response.response !== null); }); // XXX Confirm response type is answer (instead of dont-know/other) var answer = answers.length && answers[0].response || null; var sub_surveys = currentQuestion.sub_surveys; // If has subsurveys then it can branch if (sub_surveys) { console.log('Subsurveys:', currentQuestion.id, sub_surveys); console.log('Answer:', answer); // Check which subsurvey this answer buckets into var BREAK = false; sub_surveys.forEach(function(sub) { if (BREAK) { return; } console.log('Bucket:', sub.buckets, 'Type:', currentQuestion.type_constraint); // Append all subsurveys to clone of current question, update head, update headStack if in bucket var inBee = self.inBucket(sub.buckets, currentQuestion.type_constraint, answer); if (inBee) { // Clone current element var clone = self.cloneNode(currentQuestion); var temp = clone.next; // link sub nodes // TODO: Deal with repeatable flag here! // XXX: When adding repeat questions make sure to augment the question.id in a repeatable and unique way // XXX: QuestionIDs are used to distinguish/remember questions everywhere, do not reuse IDs! for (var i = 0; i < sub.nodes.length; i++) { if (i === 0) { clone.next = sub.nodes[i]; sub.nodes[i].prev = clone; } else { sub.nodes[i].prev = sub.nodes[i - 1]; } if (i === sub.nodes.length - 1) { sub.nodes[i].next = temp; if (temp) temp.prev = sub.nodes[i]; } else { sub.nodes[i].next = sub.nodes[i + 1]; } } // Always add branchable questions previous state into headStack // This is how we can revert alterations to a branched question headStack.push(currentQuestion); // Find the head var newHead = clone; while (newHead.prev) { newHead = newHead.prev; } head = newHead; // Set current question to CLONE always currentQuestion = clone; BREAK = true; // break } }); } nextQuestion = currentQuestion.next; state = this.state.states.QUESTION; // Set the state to SUBMIT when reach the end of questions if (nextQuestion === null) { nextQuestion = currentQuestion; //Keep track of tail showDontKnow = false; showDontKnowBox = false; state = this.state.states.SUBMIT; break; } // Moving into a valid question showDontKnow = nextQuestion.allow_dont_know || false; showDontKnowBox = false; questionID = nextQuestion.id; if (showDontKnow) { response = this.refs.footer.getAnswer(questionID); console.log('Footer response:', response); showDontKnowBox = Boolean(response); } break; } this.setState({ question: nextQuestion, showDontKnow: showDontKnow, showDontKnowBox: showDontKnowBox, head: head, headStack: headStack, state: state }); return; }, /* * Load prev question, updates state of the Application * if prev question is not found to SPLASH */ onPrevButton: function() { var currentState = this.state.state; var currentQuestion = this.state.question; // Set up next state var nextQuestion = null; var showDontKnow = false; var showDontKnowBox = false; var state = this.state.states.SPLASH; var head = this.state.head; var headStack = this.state.headStack, sub_surveys, newHead, questionID, response; switch (currentState) { // On Submit page and prev was pressed case this.state.states.SUBMIT: nextQuestion = currentQuestion; // Tail was saved in current question // Branching ONLY happens when moving BACK into branchable question // Rare but can happen on question that either leads to submit or more questions sub_surveys = nextQuestion.sub_surveys; if (sub_surveys && headStack.length) { // If he's in the branched stack, pop em off if (headStack[headStack.length - 1].id === nextQuestion.id) { console.log('RESETING', nextQuestion.id, headStack.length); // Reset the nextQuestion to previously unbranched state nextQuestion = headStack.pop(); console.log('RESET', nextQuestion.id, headStack.length); // Find the head newHead = nextQuestion; while (newHead.prev) { newHead = newHead.prev; } head = newHead; } } showDontKnow = currentQuestion.allow_dont_know || false; showDontKnowBox = false; state = this.state.states.QUESTION; questionID = currentQuestion.id; if (showDontKnow) { response = this.refs.footer.getAnswer(questionID); console.log('Footer response:', response); showDontKnowBox = Boolean(response); } break; // On Splash page and prev was pressed (IMPOSSIBLE) case this.state.states.SPLASH: nextQuestion = null; showDontKnowBox = false; showDontKnow = false; state = this.state.states.SPLASH; break; case this.state.states.QUESTION: nextQuestion = currentQuestion.prev; state = this.state.states.QUESTION; // Set the state to SUBMIT when reach the end of questions if (nextQuestion === null) { nextQuestion = currentQuestion; showDontKnow = false; showDontKnowBox = false; state = this.state.states.SPLASH; break; } // Branching ONLY happens when moving BACK into branchable question // ALWAYS undo branched state to maintain survey consitency sub_surveys = nextQuestion.sub_surveys; if (sub_surveys && headStack.length) { // If he's in the branched stack, pop em off if (headStack[headStack.length - 1].id === nextQuestion.id) { console.log('RESETING', nextQuestion.id, headStack.length); // Reset the nextQuestion to previously unbranched state nextQuestion = headStack.pop(); console.log('RESET', nextQuestion.id, headStack.length); // Find the head newHead = nextQuestion; while (newHead.prev) { newHead = newHead.prev; } head = newHead; } } // Moving into a valid question showDontKnow = nextQuestion.allow_dont_know || false; showDontKnowBox = false; questionID = nextQuestion.id; if (showDontKnow) { response = this.refs.footer.getAnswer(questionID); console.log('Footer response:', response); showDontKnowBox = Boolean(response); } break; } this.setState({ question: nextQuestion, showDontKnow: showDontKnow, showDontKnowBox: showDontKnowBox, head: head, headStack: headStack, state: state }); return; }, /* * Check if response is in bucket * * @buckets: Array of buckets (can be ranges in [num,num) form or 'qid' for mc * @type: type of bucket * @resposne: answer to check if in bucket */ inBucket: function(buckets, type, response) { var leftLim, rightLim, inBee, BREAK; if (response === null) return false; switch (type) { case 'integer': case 'decimal': inBee = 1; // Innocent untill proven guilty // Split bucket into four sections, confirm that value in range, otherwise set inBee to false BREAK = false; buckets.forEach(function(bucket) { if (BREAK) { return; } inBee = 1; var left = bucket.split(',')[0]; var right = bucket.split(',')[1]; if (left[0] === '[') { leftLim = parseFloat(left.split('[')[1]); console.log('Inclusive Left', leftLim); if (!isNaN(leftLim)) // Infinity doesnt need to be checked inBee &= (response >= leftLim); } else if (left[0] === '(') { leftLim = parseFloat(left.split('(')[1]); console.log('Exclusive Left', leftLim); if (!isNaN(leftLim)) // Infinity doesnt need to be checked inBee &= (response > leftLim); } else { inBee = 0; } if (right[right.length - 1] === ']') { rightLim = parseFloat(right.split(']')[0]); console.log('Inclusive Right', rightLim); if (!isNaN(rightLim)) // Infinity doesnt need to be checked inBee &= (response <= rightLim); } else if (right[right.length - 1] === ')') { rightLim = parseFloat(right.split(')')[0]); console.log('Exclusive Right', rightLim); if (!isNaN(rightLim)) // Infinity doesnt need to be checked inBee &= (response < rightLim); } else { inBee = 0; // unknown } console.log('Bucket:', bucket, response, inBee); if (inBee) { BREAK = true; //break } }); return inBee; case 'timestamp': // TODO: We need moment.js for this to work properly case 'date': inBee = 1; // Innocent untill proven guilty response = new Date(response); // Convert to date object for comparisons BREAK = false; buckets.forEach(function(bucket) { inBee = 1; if (BREAK) { return; } var left = bucket.split(',')[0]; var right = bucket.split(',')[1]; if (left[0] === '[') { console.log('Inclusive Left'); leftLim = new Date(left.split('[')[1].replace(/\s/, 'T')); if (!isNaN(leftLim)) // Infinity doesnt need to be checked inBee &= (response >= leftLim); } else if (left[0] === '(') { console.log('Exclusive Left'); leftLim = new Date(left.split('(')[1].replace(/\s/, 'T')); if (!isNaN(leftLim)) // Infinity doesnt need to be checked inBee &= (response > leftLim); } else { inBee = 0; } if (right[right.length - 1] === ']') { console.log('Inclusive Right'); rightLim = new Date(right.split(']')[0].replace(/\s/, 'T')); if (!isNaN(rightLim)) // Infinity doesnt need to be checked inBee &= (response <= rightLim); } else if (right[right.length - 1] === ')') { console.log('Exclusive Right'); rightLim = new Date(right.split(')')[0].replace(/\s/, 'T')); if (!isNaN(rightLim)) // Infinity doesnt need to be checked inBee &= (response < rightLim); } else { inBee = 0; // unknown } console.log('Bucket:', bucket, response, inBee); if (inBee) { BREAK = true; //break } return true; }); return inBee; case 'multiple_choice': inBee = 0; buckets.forEach(function(bucket) { inBee |= (bucket === response); console.log('Bucket:', bucket, response, inBee); }); return inBee; default: return false; } }, /* * Clone linked list node, arrays don't need to be cloned, only next/prev ptrs * @node: Current node to clone * @ids: Dictionay reference of currently cloned nodes, prevents recursion going on forever */ cloneNode: function(node, ids) { var self = this; var clone = { next: null, prev: null }; ids = ids || {}; Object.keys(node).forEach(function(key) { if (key !== 'next' && key !== 'prev') { clone[key] = node[key]; } }); // Mutable so next/prev pointers will be visible to all nodes that reference this dictionary ids[node.id] = clone; if (node.next) { var next = ids[node.next.id]; clone.next = next || self.cloneNode(node.next, ids); } if (node.prev) { var prev = ids[node.prev.id]; clone.prev = prev || self.cloneNode(node.prev, ids); } return clone; }, /* * Save active survey into unsynced array */ onSave: function() { var survey = JSON.parse(localStorage[this.props.survey.id] || '{}'); // Get all unsynced surveys var unsynced_surveys = JSON.parse(localStorage['unsynced'] || '{}'); // Get array of unsynced submissions to this survey var unsynced_submissions = unsynced_surveys[this.props.survey.id] || []; // Get array of unsynced photo id's var unsynced_photos = JSON.parse(localStorage['unsynced_photos'] || '[]'); // Get array of unsynced facilities var unsynced_facilities = JSON.parse(localStorage['unsynced_facilities'] || '[]'); // Build new submission var answers = []; var self = this; // Copy active questions into simple list; var questions = []; var head = this.state.head; while (head) { questions.push(head); head = head.next; } questions.forEach(function(question) { var responses = survey[question.id] || []; responses.forEach(function(response) { // Ignore empty responses if (!response || response.response === null) { return true; // continue; } // Photos need to synced independently from survey if (question.type_constraint === 'photo') { unsynced_photos.push({ 'surveyID': self.props.survey.id, 'photoID': response.response, 'questionID': question.id }); } // New facilities need to be stored seperatly from survey if (question.type_constraint === 'facility') { if (response.metadata && response.metadata.is_new) { console.log('Facility:', response); // if self.state.trees.[question.id] exists, the compressed data from Revisit // was successfully downloaded initially var in_tree = false; var tree = self.state.trees[question.id]; if (tree && tree.root) { self.state.trees[question.id] .addFacility(response.response.lat, response.response.lng, response.response); in_tree = true; } else { console.log('Question ' + question.id + '\'s tree does not have a facility root node.'); } unsynced_facilities.push({ 'surveyID': self.props.survey.id, 'facilityData': response.response, 'questionID': question.id, 'in_tree': in_tree }); } } answers.push({ survey_node_id: question.id, response: response, type_constraint: question.type_constraint }); }); }); // Don't record it if there are no answers, will mess up splash if (answers.length === 0) { return; } var submission = { submitter_name: localStorage['submitter_name'] || 'anon', submitter_email: localStorage['submitter_email'] || 'anon@anon.org', survey_id: this.props.survey.id, answers: answers, start_time: survey.start_time || null, save_time: new Date().toISOString(), submission_time: '' // For comparisions during submit ajax callback }; console.log('Submission', submission); // Record new submission into array unsynced_submissions.push(submission); unsynced_surveys[this.props.survey.id] = unsynced_submissions; localStorage['unsynced'] = JSON.stringify(unsynced_surveys); // Store photos localStorage['unsynced_photos'] = JSON.stringify(unsynced_photos); // Store facilities localStorage['unsynced_facilities'] = JSON.stringify(unsynced_facilities); // Wipe active survey localStorage[this.props.survey.id] = JSON.stringify({}); // Wipe location info localStorage['location'] = JSON.stringify({}); }, /* * Loop through unsynced submissions for active survey and POST * Only modifies localStorage on success */ onSubmit: function() { var self = this; // Get all unsynced surveys var unsynced_surveys = JSON.parse(localStorage['unsynced'] || '{}'); // Get array of unsynced submissions to this survey var unsynced_submissions = unsynced_surveys[this.props.survey.id] || []; // Get all unsynced photos. var unsynced_photos = JSON.parse(localStorage['unsynced_photos'] || '[]'); // Get all unsynced facilities var unsynced_facilities = JSON.parse(localStorage['unsynced_facilities'] || '[]'); // Post surveys to Dokomoforms unsynced_submissions.forEach(function(survey) { // Update submit time survey.submission_time = new Date().toISOString(); $.ajax({ url: '/api/v0/surveys/' + survey.survey_id + '/submit', type: 'POST', contentType: 'application/json', processData: false, data: JSON.stringify(survey), headers: { 'X-XSRFToken': cookies.getCookie('_xsrf') }, dataType: 'json', success: function(survey, anything, hey) { console.log('success', anything, hey); // Get all unsynced surveys var unsynced_surveys = JSON.parse(localStorage['unsynced'] || '{}'); // Get array of unsynced submissions to this survey var unsynced_submissions = unsynced_surveys[survey.survey_id] || []; // Find unsynced_submission var idx = -1; unsynced_submissions.forEach(function(usurvey, i) { if (Date(usurvey.save_time) === Date(survey.save_time)) { idx = i; } }); // Not sure what happened, do not update localStorage if (idx === -1) return; unsynced_submissions.splice(idx, 1); unsynced_surveys[survey.survey_id] = unsynced_submissions; localStorage['unsynced'] = JSON.stringify(unsynced_surveys); // Update splash page if still on it if (self.state.state === self.state.states.SPLASH) self.refs.splash.update(); }, error: function(err) { console.log('Failed to post survey', err, survey); } }); console.log('synced submission:', survey); console.log('survey', '/api/v0/surveys/' + survey.survey_id + '/submit'); }); // Post photos to dokomoforms unsynced_photos.forEach(function(photo) { if (photo.surveyID === self.props.survey.id) { PhotoAPI.getBase64(self.state.db, photo.photoID, function(err, base64) { $.ajax({ url: '/api/v0/photos', type: 'POST', contentType: 'application/json', processData: false, data: JSON.stringify({ 'id': photo.photoID, 'mime_type': 'image/png', 'image': base64 }), headers: { 'X-XSRFToken': cookies.getCookie('_xsrf') }, dataType: 'json', success: function(photo) { console.log('Photo success:', photo); var unsynced_photos = JSON.parse(localStorage['unsynced_photos'] || '[]'); // Find photo var idx = -1; unsynced_photos.forEach(function(uphoto, i) { if (uphoto.photoID === photo.id) { idx = i; PhotoAPI.removePhoto(self.state.db, uphoto.photoID, function(err, result) { if (err) { console.log('Couldnt remove from db:', err); return; } console.log('Removed:', result); }); } }); // What?? if (idx === -1) return; console.log(idx, unsynced_photos.length); unsynced_photos.splice(idx, 1); localStorage['unsynced_photos'] = JSON.stringify(unsynced_photos); }, error: function(err) { console.log('Failed to post photo:', err, photo); } }); }); } }); // Post facilities to Revisit unsynced_facilities.forEach(function(facility) { if (facility.surveyID === self.props.survey.id) { self.state.trees[facility.questionID].postFacility(facility.facilityData, // Success function(revisitFacility) { console.log('Successfully posted facility', revisitFacility, facility); var unsynced_facilities = JSON.parse(localStorage['unsynced_facilities'] || '[]'); // Find facility var idx = -1; console.log(idx, unsynced_facilities.length); unsynced_facilities.forEach(function(ufacility, i) { var ufacilityID = ufacility.facilityData.facility_id; var facilityID = facility.facilityData.facility_id; if (ufacilityID === facilityID) { idx = i; } }); // What?? if (idx === -1) return; console.log(idx, unsynced_facilities.length); unsynced_facilities.splice(idx, 1); localStorage['unsynced_facilities'] = JSON.stringify(unsynced_facilities); }, // Error function(err, facility) { console.log('Failed to post facility', err, facility); } ); } }); }, /* * Respond to don't know checkbox event, this is listend to by Application * due to app needing to resize for the increased height of the don't know * region */ onCheckButton: function() { this.setState({ showDontKnowBox: this.state.showDontKnowBox ? false : true, showDontKnow: this.state.showDontKnow }); // Force questions to update if (this.state.state === this.state.states.QUESTION) { this.refs.question.update(); } }, /* * Load the appropiate question based on the nextQuestion state * Loads splash or submit content if state is either SPLASH/SUBMIT */ getContent: function() { var question = this.state.question; var state = this.state.state; var survey = this.props.survey; if (state === this.state.states.QUESTION) { var questionID = question.id; var questionType = question.type_constraint; switch (questionType) { case 'multiple_choice': return ( <MultipleChoice ref='question' key={questionID} question={question} questionType={questionType} language={this.state.language} surveyID={survey.id} disabled={this.state.showDontKnowBox} /> ); case 'photo': return ( <Photo ref='question' key={questionID} question={question} questionType={questionType} language={this.state.language} surveyID={survey.id} disabled={this.state.showDontKnowBox} db={this.state.db} /> ); case 'location': return ( <Location ref='question' key={questionID} question={question} questionType={questionType} language={this.state.language} surveyID={survey.id} disabled={this.state.showDontKnowBox} /> ); case 'facility': return ( <Facility ref='question' key={questionID} question={question} questionType={questionType} language={this.state.language} surveyID={survey.id} disabled={this.state.showDontKnowBox} db={this.state.db} tree={this.state.trees[questionID]} /> ); case 'note': return ( <Note ref='question' key={questionID} question={question} questionType={questionType} language={this.state.language} surveyID={survey.id} disabled={this.state.showDontKnowBox} /> ); default: return ( <Question ref='question' key={questionID} question={question} questionType={questionType} language={this.state.language} surveyID={survey.id} disabled={this.state.showDontKnowBox} /> ); } } else if (state === this.state.states.SUBMIT) { return ( <Submit ref='submit' surveyID={survey.id} loggedIn={this.state.loggedIn} language={this.state.language} /> ); } else { return ( <Splash ref='splash' surveyID={survey.id} surveyTitle={survey.title} language={this.state.language} buttonFunction={this.onSubmit} /> ); } }, /* * Load the appropiate title based on the question and state */ getTitle: function() { var survey = this.props.survey; var question = this.state.question; var state = this.state.state; if (state === this.state.states.QUESTION) { return question.title[this.state.language]; } else if (state === this.state.states.SUBMIT) { return 'Ready to Save?'; } else { return survey.title[this.state.language]; } }, /* * Load the appropiate 'hint' based on the question and state */ getMessage: function() { var survey = this.props.survey; var question = this.state.question; var state = this.state.state; if (state === this.state.states.QUESTION) { return question.hint[this.state.language]; } else if (state === this.state.states.SUBMIT) { return 'If you are satisfied with the answers to all the questions, you can save the survey now.'; } else { return 'version ' + survey.version + ' | last updated ' + moment(survey.last_update_time).format('lll'); } }, /* * Load the appropiate text in the Footer's button based on state */ getButtonText: function() { var state = this.state.state; if (state === this.state.states.QUESTION) { return 'Next Question'; } else if (state === this.state.states.SUBMIT) { return 'Save Survey'; } else { return 'Begin a New Survey'; } }, render: function() { var contentClasses = 'content'; var state = this.state.state; var question = this.state.question; var questionID = question && question.id || -1; var surveyID = this.props.survey.id; // Get current length of survey and question number var number = -1; var length = 0; var head = this.state.head; var loading = null; while (head) { if (head.id === questionID) { number = length; } head = head.next; length++; } // Alter the height of content based on DontKnow state if (this.state.showDontKnow) { contentClasses += ' content-shrunk'; } if (this.state.showDontKnowBox) { contentClasses += ' content-shrunk content-super-shrunk'; } console.log('this.state.state: ', this.state.state, this.state.states.LOADING); if (this.state.state === this.state.states.LOADING) { console.log('loading!'); loading = <Loading message="Please be patient while facility data is downloaded."/>; } return ( <div id='wrapper'> {loading} <Header ref='header' buttonFunction={this.onPrevButton} number={number + 1} total={length + 1} db={this.state.db} surveyID={surveyID} survey={this.props.survey} language={this.state.language} loggedIn={this.state.loggedIn} hasFacilities={this.state.hasFacilities} splash={state === this.state.states.SPLASH}/> <div className={contentClasses}> <Title title={this.getTitle()} message={this.getMessage()} /> {this.getContent()} </div> <Footer ref='footer' showDontKnow={this.state.showDontKnow} showDontKnowBox={this.state.showDontKnowBox} buttonFunction={this.onNextButton} checkBoxFunction={this.onCheckButton} buttonType={state === this.state.states.QUESTION ? 'btn-primary': 'btn-positive'} buttonText={this.getButtonText()} questionID={questionID} surveyID={surveyID} /> </div> ); } }); module.exports = Application;
dokomo-sauce-matrix/dokomoforms
dokomoforms/static/src/survey/js/Application.js
JavaScript
gpl-3.0
47,095
<?php /** * PEAR_Common, the base class for the PEAR Installer * * PHP versions 4 and 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category pear * @package PEAR * @author Stig Bakken <ssb@php.net> * @author Tomas V. V. Cox <cox@idecnet.com> * @author Greg Beaver <cellog@php.net> * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Common.php,v 1.155 2006/03/02 18:14:12 cellog Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 0.1.0 * @deprecated File deprecated since Release 1.4.0a1 */ /** * Include error handling */ require_once 'PEAR.php'; // {{{ constants and globals /** * PEAR_Common error when an invalid PHP file is passed to PEAR_Common::analyzeSourceCode() */ define('PEAR_COMMON_ERROR_INVALIDPHP', 1); define('_PEAR_COMMON_PACKAGE_NAME_PREG', '[A-Za-z][a-zA-Z0-9_]+'); define('PEAR_COMMON_PACKAGE_NAME_PREG', '/^' . _PEAR_COMMON_PACKAGE_NAME_PREG . '$/'); // this should allow: 1, 1.0, 1.0RC1, 1.0dev, 1.0dev123234234234, 1.0a1, 1.0b1, 1.0pl1 define('_PEAR_COMMON_PACKAGE_VERSION_PREG', '\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?'); define('PEAR_COMMON_PACKAGE_VERSION_PREG', '/^' . _PEAR_COMMON_PACKAGE_VERSION_PREG . '$/i'); // XXX far from perfect :-) define('_PEAR_COMMON_PACKAGE_DOWNLOAD_PREG', '(' . _PEAR_COMMON_PACKAGE_NAME_PREG . ')(-([.0-9a-zA-Z]+))?'); define('PEAR_COMMON_PACKAGE_DOWNLOAD_PREG', '/^' . _PEAR_COMMON_PACKAGE_DOWNLOAD_PREG . '$/'); define('_PEAR_CHANNELS_NAME_PREG', '[A-Za-z][a-zA-Z0-9\.]+'); define('PEAR_CHANNELS_NAME_PREG', '/^' . _PEAR_CHANNELS_NAME_PREG . '$/'); // this should allow any dns or IP address, plus a path - NO UNDERSCORES ALLOWED define('_PEAR_CHANNELS_SERVER_PREG', '[a-zA-Z0-9\-]+(?:\.[a-zA-Z0-9\-]+)*(\/[a-zA-Z0-9\-]+)*'); define('PEAR_CHANNELS_SERVER_PREG', '/^' . _PEAR_CHANNELS_SERVER_PREG . '$/i'); define('_PEAR_CHANNELS_PACKAGE_PREG', '(' ._PEAR_CHANNELS_SERVER_PREG . ')\/(' . _PEAR_COMMON_PACKAGE_NAME_PREG . ')'); define('PEAR_CHANNELS_PACKAGE_PREG', '/^' . _PEAR_CHANNELS_PACKAGE_PREG . '$/i'); define('_PEAR_COMMON_CHANNEL_DOWNLOAD_PREG', '(' . _PEAR_CHANNELS_NAME_PREG . ')::(' . _PEAR_COMMON_PACKAGE_NAME_PREG . ')(-([.0-9a-zA-Z]+))?'); define('PEAR_COMMON_CHANNEL_DOWNLOAD_PREG', '/^' . _PEAR_COMMON_CHANNEL_DOWNLOAD_PREG . '$/'); /** * List of temporary files and directories registered by * PEAR_Common::addTempFile(). * @var array */ $GLOBALS['_PEAR_Common_tempfiles'] = array(); /** * Valid maintainer roles * @var array */ $GLOBALS['_PEAR_Common_maintainer_roles'] = array('lead','developer','contributor','helper'); /** * Valid release states * @var array */ $GLOBALS['_PEAR_Common_release_states'] = array('alpha','beta','stable','snapshot','devel'); /** * Valid dependency types * @var array */ $GLOBALS['_PEAR_Common_dependency_types'] = array('pkg','ext','php','prog','ldlib','rtlib','os','websrv','sapi'); /** * Valid dependency relations * @var array */ $GLOBALS['_PEAR_Common_dependency_relations'] = array('has','eq','lt','le','gt','ge','not', 'ne'); /** * Valid file roles * @var array */ $GLOBALS['_PEAR_Common_file_roles'] = array('php','ext','test','doc','data','src','script'); /** * Valid replacement types * @var array */ $GLOBALS['_PEAR_Common_replacement_types'] = array('php-const', 'pear-config', 'package-info'); /** * Valid "provide" types * @var array */ $GLOBALS['_PEAR_Common_provide_types'] = array('ext', 'prog', 'class', 'function', 'feature', 'api'); /** * Valid "provide" types * @var array */ $GLOBALS['_PEAR_Common_script_phases'] = array('pre-install', 'post-install', 'pre-uninstall', 'post-uninstall', 'pre-build', 'post-build', 'pre-configure', 'post-configure', 'pre-setup', 'post-setup'); // }}} /** * Class providing common functionality for PEAR administration classes. * @category pear * @package PEAR * @author Stig Bakken <ssb@php.net> * @author Tomas V. V. Cox <cox@idecnet.com> * @author Greg Beaver <cellog@php.net> * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version Release: 1.4.9 * @link http://pear.php.net/package/PEAR * @since Class available since Release 1.4.0a1 * @deprecated This class will disappear, and its components will be spread * into smaller classes, like the AT&T breakup, as of Release 1.4.0a1 */ class PEAR_Common extends PEAR { // {{{ properties /** stack of elements, gives some sort of XML context */ var $element_stack = array(); /** name of currently parsed XML element */ var $current_element; /** array of attributes of the currently parsed XML element */ var $current_attributes = array(); /** assoc with information about a package */ var $pkginfo = array(); /** * User Interface object (PEAR_Frontend_* class). If null, * the log() method uses print. * @var object */ var $ui = null; /** * Configuration object (PEAR_Config). * @var object */ var $config = null; var $current_path = null; /** * PEAR_SourceAnalyzer instance * @var object */ var $source_analyzer = null; /** * Flag variable used to mark a valid package file * @var boolean * @access private */ var $_validPackageFile; // }}} // {{{ constructor /** * PEAR_Common constructor * * @access public */ function PEAR_Common() { parent::PEAR(); $this->config = &PEAR_Config::singleton(); $this->debug = $this->config->get('verbose'); } // }}} // {{{ destructor /** * PEAR_Common destructor * * @access private */ function _PEAR_Common() { // doesn't work due to bug #14744 //$tempfiles = $this->_tempfiles; $tempfiles =& $GLOBALS['_PEAR_Common_tempfiles']; while ($file = array_shift($tempfiles)) { if (@is_dir($file)) { if (!class_exists('System')) { require_once 'System.php'; } System::rm(array('-rf', $file)); } elseif (file_exists($file)) { unlink($file); } } } // }}} // {{{ addTempFile() /** * Register a temporary file or directory. When the destructor is * executed, all registered temporary files and directories are * removed. * * @param string $file name of file or directory * * @return void * * @access public */ function addTempFile($file) { if (!class_exists('PEAR_Frontend')) { require_once 'PEAR/Frontend.php'; } PEAR_Frontend::addTempFile($file); } // }}} // {{{ mkDirHier() /** * Wrapper to System::mkDir(), creates a directory as well as * any necessary parent directories. * * @param string $dir directory name * * @return bool TRUE on success, or a PEAR error * * @access public */ function mkDirHier($dir) { $this->log(2, "+ create dir $dir"); if (!class_exists('System')) { require_once 'System.php'; } return System::mkDir(array('-p', $dir)); } // }}} // {{{ log() /** * Logging method. * * @param int $level log level (0 is quiet, higher is noisier) * @param string $msg message to write to the log * * @return void * * @access public * @static */ function log($level, $msg, $append_crlf = true) { if ($this->debug >= $level) { if (!class_exists('PEAR_Frontend')) { require_once 'PEAR/Frontend.php'; } $ui = &PEAR_Frontend::singleton(); if (is_a($ui, 'PEAR_Frontend')) { $ui->log($msg, $append_crlf); } else { print "$msg\n"; } } } // }}} // {{{ mkTempDir() /** * Create and register a temporary directory. * * @param string $tmpdir (optional) Directory to use as tmpdir. * Will use system defaults (for example * /tmp or c:\windows\temp) if not specified * * @return string name of created directory * * @access public */ function mkTempDir($tmpdir = '') { if ($tmpdir) { $topt = array('-t', $tmpdir); } else { $topt = array(); } $topt = array_merge($topt, array('-d', 'pear')); if (!class_exists('System')) { require_once 'System.php'; } if (!$tmpdir = System::mktemp($topt)) { return false; } $this->addTempFile($tmpdir); return $tmpdir; } // }}} // {{{ setFrontendObject() /** * Set object that represents the frontend to be used. * * @param object Reference of the frontend object * @return void * @access public */ function setFrontendObject(&$ui) { $this->ui = &$ui; } // }}} // {{{ infoFromTgzFile() /** * Returns information about a package file. Expects the name of * a gzipped tar file as input. * * @param string $file name of .tgz file * * @return array array with package information * * @access public * @deprecated use PEAR_PackageFile->fromTgzFile() instead * */ function infoFromTgzFile($file) { $packagefile = &new PEAR_PackageFile($this->config); $pf = &$packagefile->fromTgzFile($file, PEAR_VALIDATE_NORMAL); if (PEAR::isError($pf)) { $errs = $pf->getUserinfo(); if (is_array($errs)) { foreach ($errs as $error) { $e = $this->raiseError($error['message'], $error['code'], null, null, $error); } } return $pf; } return $this->_postProcessValidPackagexml($pf); } // }}} // {{{ infoFromDescriptionFile() /** * Returns information about a package file. Expects the name of * a package xml file as input. * * @param string $descfile name of package xml file * * @return array array with package information * * @access public * @deprecated use PEAR_PackageFile->fromPackageFile() instead * */ function infoFromDescriptionFile($descfile) { $packagefile = &new PEAR_PackageFile($this->config); $pf = &$packagefile->fromPackageFile($descfile, PEAR_VALIDATE_NORMAL); if (PEAR::isError($pf)) { $errs = $pf->getUserinfo(); if (is_array($errs)) { foreach ($errs as $error) { $e = $this->raiseError($error['message'], $error['code'], null, null, $error); } } return $pf; } return $this->_postProcessValidPackagexml($pf); } // }}} // {{{ infoFromString() /** * Returns information about a package file. Expects the contents * of a package xml file as input. * * @param string $data contents of package.xml file * * @return array array with package information * * @access public * @deprecated use PEAR_PackageFile->fromXmlstring() instead * */ function infoFromString($data) { $packagefile = &new PEAR_PackageFile($this->config); $pf = &$packagefile->fromXmlString($data, PEAR_VALIDATE_NORMAL, false); if (PEAR::isError($pf)) { $errs = $pf->getUserinfo(); if (is_array($errs)) { foreach ($errs as $error) { $e = $this->raiseError($error['message'], $error['code'], null, null, $error); } } return $pf; } return $this->_postProcessValidPackagexml($pf); } // }}} /** * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 * @return array */ function _postProcessValidPackagexml(&$pf) { if (is_a($pf, 'PEAR_PackageFile_v2')) { // sort of make this into a package.xml 1.0-style array // changelog is not converted to old format. $arr = $pf->toArray(true); $arr = array_merge($arr, $arr['old']); unset($arr['old']); unset($arr['xsdversion']); unset($arr['contents']); unset($arr['compatible']); unset($arr['channel']); unset($arr['uri']); unset($arr['dependencies']); unset($arr['phprelease']); unset($arr['extsrcrelease']); unset($arr['extbinrelease']); unset($arr['bundle']); unset($arr['lead']); unset($arr['developer']); unset($arr['helper']); unset($arr['contributor']); $arr['filelist'] = $pf->getFilelist(); $this->pkginfo = $arr; return $arr; } else { $this->pkginfo = $pf->toArray(); return $this->pkginfo; } } // {{{ infoFromAny() /** * Returns package information from different sources * * This method is able to extract information about a package * from a .tgz archive or from a XML package definition file. * * @access public * @param string Filename of the source ('package.xml', '<package>.tgz') * @return string * @deprecated use PEAR_PackageFile->fromAnyFile() instead */ function infoFromAny($info) { if (is_string($info) && file_exists($info)) { $packagefile = &new PEAR_PackageFile($this->config); $pf = &$packagefile->fromAnyFile($info, PEAR_VALIDATE_NORMAL); if (PEAR::isError($pf)) { $errs = $pf->getUserinfo(); if (is_array($errs)) { foreach ($errs as $error) { $e = $this->raiseError($error['message'], $error['code'], null, null, $error); } } return $pf; } return $this->_postProcessValidPackagexml($pf); } return $info; } // }}} // {{{ xmlFromInfo() /** * Return an XML document based on the package info (as returned * by the PEAR_Common::infoFrom* methods). * * @param array $pkginfo package info * * @return string XML data * * @access public * @deprecated use a PEAR_PackageFile_v* object's generator instead */ function xmlFromInfo($pkginfo) { $config = &PEAR_Config::singleton(); $packagefile = &new PEAR_PackageFile($config); $pf = &$packagefile->fromArray($pkginfo); $gen = &$pf->getDefaultGenerator(); return $gen->toXml(PEAR_VALIDATE_PACKAGING); } // }}} // {{{ validatePackageInfo() /** * Validate XML package definition file. * * @param string $info Filename of the package archive or of the * package definition file * @param array $errors Array that will contain the errors * @param array $warnings Array that will contain the warnings * @param string $dir_prefix (optional) directory where source files * may be found, or empty if they are not available * @access public * @return boolean * @deprecated use the validation of PEAR_PackageFile objects */ function validatePackageInfo($info, &$errors, &$warnings, $dir_prefix = '') { $config = &PEAR_Config::singleton(); $packagefile = &new PEAR_PackageFile($config); PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); if (strpos($info, '<?xml') !== false) { $pf = &$packagefile->fromXmlString($info, PEAR_VALIDATE_NORMAL, ''); } else { $pf = &$packagefile->fromAnyFile($info, PEAR_VALIDATE_NORMAL); } PEAR::staticPopErrorHandling(); if (PEAR::isError($pf)) { $errs = $pf->getUserinfo(); if (is_array($errs)) { foreach ($errs as $error) { if ($error['level'] == 'error') { $errors[] = $error['message']; } else { $warnings[] = $error['message']; } } } return false; } return true; } // }}} // {{{ buildProvidesArray() /** * Build a "provides" array from data returned by * analyzeSourceCode(). The format of the built array is like * this: * * array( * 'class;MyClass' => 'array('type' => 'class', 'name' => 'MyClass'), * ... * ) * * * @param array $srcinfo array with information about a source file * as returned by the analyzeSourceCode() method. * * @return void * * @access public * */ function buildProvidesArray($srcinfo) { $file = basename($srcinfo['source_file']); $pn = ''; if (isset($this->_packageName)) { $pn = $this->_packageName; } $pnl = strlen($pn); foreach ($srcinfo['declared_classes'] as $class) { $key = "class;$class"; if (isset($this->pkginfo['provides'][$key])) { continue; } $this->pkginfo['provides'][$key] = array('file'=> $file, 'type' => 'class', 'name' => $class); if (isset($srcinfo['inheritance'][$class])) { $this->pkginfo['provides'][$key]['extends'] = $srcinfo['inheritance'][$class]; } } foreach ($srcinfo['declared_methods'] as $class => $methods) { foreach ($methods as $method) { $function = "$class::$method"; $key = "function;$function"; if ($method{0} == '_' || !strcasecmp($method, $class) || isset($this->pkginfo['provides'][$key])) { continue; } $this->pkginfo['provides'][$key] = array('file'=> $file, 'type' => 'function', 'name' => $function); } } foreach ($srcinfo['declared_functions'] as $function) { $key = "function;$function"; if ($function{0} == '_' || isset($this->pkginfo['provides'][$key])) { continue; } if (!strstr($function, '::') && strncasecmp($function, $pn, $pnl)) { $warnings[] = "in1 " . $file . ": function \"$function\" not prefixed with package name \"$pn\""; } $this->pkginfo['provides'][$key] = array('file'=> $file, 'type' => 'function', 'name' => $function); } } // }}} // {{{ analyzeSourceCode() /** * Analyze the source code of the given PHP file * * @param string Filename of the PHP file * @return mixed * @access public */ function analyzeSourceCode($file) { if (!function_exists("token_get_all")) { return false; } if (!defined('T_DOC_COMMENT')) { define('T_DOC_COMMENT', T_COMMENT); } if (!defined('T_INTERFACE')) { define('T_INTERFACE', -1); } if (!defined('T_IMPLEMENTS')) { define('T_IMPLEMENTS', -1); } if (!$fp = @fopen($file, "r")) { return false; } if (function_exists('file_get_contents')) { fclose($fp); $contents = file_get_contents($file); } else { $contents = fread($fp, filesize($file)); fclose($fp); } $tokens = token_get_all($contents); /* for ($i = 0; $i < sizeof($tokens); $i++) { @list($token, $data) = $tokens[$i]; if (is_string($token)) { var_dump($token); } else { print token_name($token) . ' '; var_dump(rtrim($data)); } } */ $look_for = 0; $paren_level = 0; $bracket_level = 0; $brace_level = 0; $lastphpdoc = ''; $current_class = ''; $current_interface = ''; $current_class_level = -1; $current_function = ''; $current_function_level = -1; $declared_classes = array(); $declared_interfaces = array(); $declared_functions = array(); $declared_methods = array(); $used_classes = array(); $used_functions = array(); $extends = array(); $implements = array(); $nodeps = array(); $inquote = false; $interface = false; for ($i = 0; $i < sizeof($tokens); $i++) { if (is_array($tokens[$i])) { list($token, $data) = $tokens[$i]; } else { $token = $tokens[$i]; $data = ''; } if ($inquote) { if ($token != '"') { continue; } else { $inquote = false; continue; } } switch ($token) { case T_WHITESPACE: continue; case ';': if ($interface) { $current_function = ''; $current_function_level = -1; } break; case '"': $inquote = true; break; case T_CURLY_OPEN: case T_DOLLAR_OPEN_CURLY_BRACES: case '{': $brace_level++; continue 2; case '}': $brace_level--; if ($current_class_level == $brace_level) { $current_class = ''; $current_class_level = -1; } if ($current_function_level == $brace_level) { $current_function = ''; $current_function_level = -1; } continue 2; case '[': $bracket_level++; continue 2; case ']': $bracket_level--; continue 2; case '(': $paren_level++; continue 2; case ')': $paren_level--; continue 2; case T_INTERFACE: $interface = true; case T_CLASS: if (($current_class_level != -1) || ($current_function_level != -1)) { PEAR::raiseError("Parser error: invalid PHP found in file \"$file\"", PEAR_COMMON_ERROR_INVALIDPHP); return false; } case T_FUNCTION: case T_NEW: case T_EXTENDS: case T_IMPLEMENTS: $look_for = $token; continue 2; case T_STRING: if (version_compare(zend_version(), '2.0', '<')) { if (in_array(strtolower($data), array('public', 'private', 'protected', 'abstract', 'interface', 'implements', 'throw') )) { PEAR::raiseError('Error: PHP5 token encountered in ' . $file . 'packaging should be done in PHP 5'); return false; } } if ($look_for == T_CLASS) { $current_class = $data; $current_class_level = $brace_level; $declared_classes[] = $current_class; } elseif ($look_for == T_INTERFACE) { $current_interface = $data; $current_class_level = $brace_level; $declared_interfaces[] = $current_interface; } elseif ($look_for == T_IMPLEMENTS) { $implements[$current_class] = $data; } elseif ($look_for == T_EXTENDS) { $extends[$current_class] = $data; } elseif ($look_for == T_FUNCTION) { if ($current_class) { $current_function = "$current_class::$data"; $declared_methods[$current_class][] = $data; } elseif ($current_interface) { $current_function = "$current_interface::$data"; $declared_methods[$current_interface][] = $data; } else { $current_function = $data; $declared_functions[] = $current_function; } $current_function_level = $brace_level; $m = array(); } elseif ($look_for == T_NEW) { $used_classes[$data] = true; } $look_for = 0; continue 2; case T_VARIABLE: $look_for = 0; continue 2; case T_DOC_COMMENT: case T_COMMENT: if (preg_match('!^/\*\*\s!', $data)) { $lastphpdoc = $data; if (preg_match_all('/@nodep\s+(\S+)/', $lastphpdoc, $m)) { $nodeps = array_merge($nodeps, $m[1]); } } continue 2; case T_DOUBLE_COLON: if (!($tokens[$i - 1][0] == T_WHITESPACE || $tokens[$i - 1][0] == T_STRING)) { PEAR::raiseError("Parser error: invalid PHP found in file \"$file\"", PEAR_COMMON_ERROR_INVALIDPHP); return false; } $class = $tokens[$i - 1][1]; if (strtolower($class) != 'parent') { $used_classes[$class] = true; } continue 2; } } return array( "source_file" => $file, "declared_classes" => $declared_classes, "declared_interfaces" => $declared_interfaces, "declared_methods" => $declared_methods, "declared_functions" => $declared_functions, "used_classes" => array_diff(array_keys($used_classes), $nodeps), "inheritance" => $extends, "implements" => $implements, ); } // }}} // {{{ betterStates() /** * Return an array containing all of the states that are more stable than * or equal to the passed in state * * @param string Release state * @param boolean Determines whether to include $state in the list * @return false|array False if $state is not a valid release state */ function betterStates($state, $include = false) { static $states = array('snapshot', 'devel', 'alpha', 'beta', 'stable'); $i = array_search($state, $states); if ($i === false) { return false; } if ($include) { $i--; } return array_slice($states, $i + 1); } // }}} // {{{ detectDependencies() function detectDependencies($any, $status_callback = null) { if (!function_exists("token_get_all")) { return false; } if (PEAR::isError($info = $this->infoFromAny($any))) { return $this->raiseError($info); } if (!is_array($info)) { return false; } $deps = array(); $used_c = $decl_c = $decl_f = $decl_m = array(); foreach ($info['filelist'] as $file => $fa) { $tmp = $this->analyzeSourceCode($file); $used_c = @array_merge($used_c, $tmp['used_classes']); $decl_c = @array_merge($decl_c, $tmp['declared_classes']); $decl_f = @array_merge($decl_f, $tmp['declared_functions']); $decl_m = @array_merge($decl_m, $tmp['declared_methods']); $inheri = @array_merge($inheri, $tmp['inheritance']); } $used_c = array_unique($used_c); $decl_c = array_unique($decl_c); $undecl_c = array_diff($used_c, $decl_c); return array('used_classes' => $used_c, 'declared_classes' => $decl_c, 'declared_methods' => $decl_m, 'declared_functions' => $decl_f, 'undeclared_classes' => $undecl_c, 'inheritance' => $inheri, ); } // }}} // {{{ getUserRoles() /** * Get the valid roles for a PEAR package maintainer * * @return array * @static */ function getUserRoles() { return $GLOBALS['_PEAR_Common_maintainer_roles']; } // }}} // {{{ getReleaseStates() /** * Get the valid package release states of packages * * @return array * @static */ function getReleaseStates() { return $GLOBALS['_PEAR_Common_release_states']; } // }}} // {{{ getDependencyTypes() /** * Get the implemented dependency types (php, ext, pkg etc.) * * @return array * @static */ function getDependencyTypes() { return $GLOBALS['_PEAR_Common_dependency_types']; } // }}} // {{{ getDependencyRelations() /** * Get the implemented dependency relations (has, lt, ge etc.) * * @return array * @static */ function getDependencyRelations() { return $GLOBALS['_PEAR_Common_dependency_relations']; } // }}} // {{{ getFileRoles() /** * Get the implemented file roles * * @return array * @static */ function getFileRoles() { return $GLOBALS['_PEAR_Common_file_roles']; } // }}} // {{{ getReplacementTypes() /** * Get the implemented file replacement types in * * @return array * @static */ function getReplacementTypes() { return $GLOBALS['_PEAR_Common_replacement_types']; } // }}} // {{{ getProvideTypes() /** * Get the implemented file replacement types in * * @return array * @static */ function getProvideTypes() { return $GLOBALS['_PEAR_Common_provide_types']; } // }}} // {{{ getScriptPhases() /** * Get the implemented file replacement types in * * @return array * @static */ function getScriptPhases() { return $GLOBALS['_PEAR_Common_script_phases']; } // }}} // {{{ validPackageName() /** * Test whether a string contains a valid package name. * * @param string $name the package name to test * * @return bool * * @access public */ function validPackageName($name) { return (bool)preg_match(PEAR_COMMON_PACKAGE_NAME_PREG, $name); } // }}} // {{{ validPackageVersion() /** * Test whether a string contains a valid package version. * * @param string $ver the package version to test * * @return bool * * @access public */ function validPackageVersion($ver) { return (bool)preg_match(PEAR_COMMON_PACKAGE_VERSION_PREG, $ver); } // }}} // {{{ downloadHttp() /** * Download a file through HTTP. Considers suggested file name in * Content-disposition: header and can run a callback function for * different events. The callback will be called with two * parameters: the callback type, and parameters. The implemented * callback types are: * * 'setup' called at the very beginning, parameter is a UI object * that should be used for all output * 'message' the parameter is a string with an informational message * 'saveas' may be used to save with a different file name, the * parameter is the filename that is about to be used. * If a 'saveas' callback returns a non-empty string, * that file name will be used as the filename instead. * Note that $save_dir will not be affected by this, only * the basename of the file. * 'start' download is starting, parameter is number of bytes * that are expected, or -1 if unknown * 'bytesread' parameter is the number of bytes read so far * 'done' download is complete, parameter is the total number * of bytes read * 'connfailed' if the TCP connection fails, this callback is called * with array(host,port,errno,errmsg) * 'writefailed' if writing to disk fails, this callback is called * with array(destfile,errmsg) * * If an HTTP proxy has been configured (http_proxy PEAR_Config * setting), the proxy will be used. * * @param string $url the URL to download * @param object $ui PEAR_Frontend_* instance * @param object $config PEAR_Config instance * @param string $save_dir (optional) directory to save file in * @param mixed $callback (optional) function/method to call for status * updates * * @return string Returns the full path of the downloaded file or a PEAR * error on failure. If the error is caused by * socket-related errors, the error object will * have the fsockopen error code available through * getCode(). * * @access public * @deprecated in favor of PEAR_Downloader::downloadHttp() */ function downloadHttp($url, &$ui, $save_dir = '.', $callback = null) { if (!class_exists('PEAR_Downloader')) { require_once 'PEAR/Downloader.php'; } return PEAR_Downloader::downloadHttp($url, $ui, $save_dir, $callback); } // }}} /** * @param string $path relative or absolute include path * @return boolean * @static */ function isIncludeable($path) { if (file_exists($path) && is_readable($path)) { return true; } $ipath = explode(PATH_SEPARATOR, ini_get('include_path')); foreach ($ipath as $include) { $test = realpath($include . DIRECTORY_SEPARATOR . $path); if (file_exists($test) && is_readable($test)) { return true; } } return false; } } require_once 'PEAR/Config.php'; require_once 'PEAR/PackageFile.php'; ?>
syboor/openimsce
openims/libs/pear/PEAR/Common.php
PHP
gpl-3.0
35,700
# Copyright (C) 2009-2010 Sergey Koposov # This file is part of astrolibpy # # astrolibpy 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. # # astrolibpy 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 astrolibpy. If not, see <http://www.gnu.org/licenses/>. import numpy, re def from_hex(arr, delim=':'): r=re.compile('\s*(\-?)(.+)%s(.+)%s(.+)'%(delim,delim)) ret=[] for a in arr: m = r.search(a) sign = m.group(1)=='-' if sign: sign=-1 else: sign=1 i1 = int(m.group(2)) i2 = int(m.group(3)) i3 = float(m.group(4)) val = sign*(int(i1)+int(i2)/60.+(float(i3))/3600.) ret.append(val) return numpy.array(ret)
segasai/astrolibpy
my_utils/from_hex.py
Python
gpl-3.0
1,118
local rotationName = "Dub" --------------- --- Toggles --- --------------- local function createToggles() -- Rotation Button RotationModes = { [1] = { mode = "Auto", value = 1 , overlay = "Automatic Rotation", tip = "Swaps between Single and Multiple based on number of targets in range.", highlight = 1, icon = br.player.spell.bladeDance}, [2] = { mode = "Mult", value = 2 , overlay = "Multiple Target Rotation", tip = "Multiple target rotation used.", highlight = 0, icon = br.player.spell.bladeDance}, [3] = { mode = "Sing", value = 3 , overlay = "Single Target Rotation", tip = "Single target rotation used.", highlight = 0, icon = br.player.spell.chaosStrike}, [4] = { mode = "Off", value = 4 , overlay = "DPS Rotation Disabled", tip = "Disable DPS Rotation", highlight = 0, icon = br.player.spell.spectralSight} }; CreateButton("Rotation",1,0) -- Cooldown Button CooldownModes = { [1] = { mode = "Auto", value = 1 , overlay = "Cooldowns Automated", tip = "Automatic Cooldowns - Boss Detection.", highlight = 1, icon = br.player.spell.metamorphosis}, [2] = { mode = "On", value = 1 , overlay = "Cooldowns Enabled", tip = "Cooldowns used regardless of target.", highlight = 0, icon = br.player.spell.metamorphosis}, [3] = { mode = "Off", value = 3 , overlay = "Cooldowns Disabled", tip = "No Cooldowns will be used.", highlight = 0, icon = br.player.spell.metamorphosis} }; CreateButton("Cooldown",2,0) -- Defensive Button DefensiveModes = { [1] = { mode = "On", value = 1 , overlay = "Defensive Enabled", tip = "Includes Defensive Cooldowns.", highlight = 1, icon = br.player.spell.demonSpikes}, [2] = { mode = "Off", value = 2 , overlay = "Defensive Disabled", tip = "No Defensives will be used.", highlight = 0, icon = br.player.spell.demonSpikes} }; CreateButton("Defensive",3,0) -- Interrupt Button InterruptModes = { [1] = { mode = "On", value = 1 , overlay = "Interrupts Enabled", tip = "Includes Basic Interrupts.", highlight = 1, icon = br.player.spell.consumeMagic}, [2] = { mode = "Off", value = 2 , overlay = "Interrupts Disabled", tip = "No Interrupts will be used.", highlight = 0, icon = br.player.spell.consumeMagic} }; CreateButton("Interrupt",4,0) -- Mover MoverModes = { [1] = { mode = "On", value = 2 , overlay = "Auto Movement Enabled", tip = "Will Cast Movement Abilities.", highlight = 1, icon = br.player.spell.infernalStrike}, [2] = { mode = "Off", value = 1 , overlay = "Auto Movement Disabled", tip = "Will NOT Cast Movement Abilities", highlight = 0, icon = br.player.spell.infernalStrike} }; CreateButton("Mover",5,0) end --------------- --- OPTIONS --- --------------- local function createOptions() local optionTable local function rotationOptions() local section -- General Options section = br.ui:createSection(br.ui.window.profile, "General") -- APL br.ui:createDropdownWithout(section, "APL Mode", {"|cffFFFFFFSimC"}, 1, "|cffFFFFFFSet APL Mode to use.") -- Dummy DPS Test br.ui:createSpinner(section, "DPS Testing", 5, 5, 60, 5, "|cffFFFFFFSet to desired time for test in minuts. Min: 5 / Max: 60 / Interval: 5") -- Pre-Pull Timer br.ui:createSpinner(section, "Pre-Pull Timer", 5, 1, 10, 1, "|cffFFFFFFSet to desired time to start Pre-Pull (DBM Required). Min: 1 / Max: 10 / Interval: 1") -- Eye Beam Targets br.ui:createSpinner(section, "Eye Beam Targets", 3, 1, 10, 1, "|cffFFBB00Number of Targets to use at.") br.ui:checkSectionState(section) -- Cooldown Options section = br.ui:createSection(br.ui.window.profile, "Cooldowns") -- Agi Pot br.ui:createCheckbox(section,"Agi-Pot") -- Flask / Crystal br.ui:createCheckbox(section,"Flask / Crystal") -- Legendary Ring br.ui:createCheckbox(section,"Legendary Ring") -- Racial br.ui:createCheckbox(section,"Racial") -- Trinkets br.ui:createCheckbox(section,"Trinkets") -- Metamorphosis br.ui:createCheckbox(section,"Metamorphosis") br.ui:checkSectionState(section) -- Defensive Options section = br.ui:createSection(br.ui.window.profile, "Defensive") -- Healthstone br.ui:createSpinner(section, "Pot/Stoned", 60, 0, 100, 5, "|cffFFFFFFHealth Percent to Cast At") -- Heirloom Neck br.ui:createSpinner(section, "Heirloom Neck", 60, 0, 100, 5, "|cffFFBB00Health Percentage to use at."); -- Blur br.ui:createSpinner(section, "Blur", 50, 0, 100, 5, "|cffFFBB00Health Percentage to use at.") -- Darkness br.ui:createSpinner(section, "Darkness", 30, 0, 100, 5, "|cffFFBB00Health Percentage to use at.") -- Chaos Nova br.ui:createSpinner(section, "Chaos Nova - HP", 30, 0, 100, 5, "|cffFFBB00Health Percentage to use at.") br.ui:createSpinner(section, "Chaos Nova - AoE", 3, 1, 10, 1, "|cffFFBB00Number of Targets to use at.") br.ui:checkSectionState(section) -- Interrupt Options section = br.ui:createSection(br.ui.window.profile, "Interrupts") -- Consume Magic br.ui:createCheckbox(section, "Consume Magic") -- Chaos Nova br.ui:createCheckbox(section, "Chaos Nova") -- Interrupt Percentage br.ui:createSpinner(section, "Interrupt At", 0, 0, 95, 5, "|cffFFFFFFCast Percent to Cast At") br.ui:checkSectionState(section) -- Toggle Key Options section = br.ui:createSection(br.ui.window.profile, "Toggle Keys") -- Single/Multi Toggle br.ui:createDropdown(section, "Rotation Mode", br.dropOptions.Toggle, 4) -- Cooldown Key Toggle br.ui:createDropdown(section, "Cooldown Mode", br.dropOptions.Toggle, 3) -- Defensive Key Toggle br.ui:createDropdown(section, "Defensive Mode", br.dropOptions.Toggle, 6) -- Interrupts Key Toggle br.ui:createDropdown(section, "Interrupt Mode", br.dropOptions.Toggle, 6) -- Mover Key Toggle br.ui:createDropdown(section, "Mover Mode", br.dropOptions.Toggle, 6) -- Pause Toggle br.ui:createDropdown(section, "Pause Mode", br.dropOptions.Toggle, 6) br.ui:checkSectionState(section) end optionTable = {{ [1] = "Rotation Options", [2] = rotationOptions, }} return optionTable end ---------------- --- ROTATION --- ---------------- local function runRotation() if br.timer:useTimer("debugVengeance", math.random(0.15,0.3)) then --Print("Running: "..rotationName) --------------- --- Toggles --- --------------- UpdateToggle("Rotation",0.25) UpdateToggle("Cooldown",0.25) UpdateToggle("Defensive",0.25) UpdateToggle("Interrupt",0.25) UpdateToggle("Mover",0.25) -------------- --- Locals --- -------------- local addsExist = false local addsIn = 999 local artifact = br.player.artifact local buff = br.player.buff local canFlask = canUse(br.player.flask.wod.agilityBig) local cast = br.player.cast local castable = br.player.cast.debug local combatTime = getCombatTime() local cd = br.player.cd local charges = br.player.charges local deadMouse = UnitIsDeadOrGhost("mouseover") local deadtar, attacktar, hastar, playertar = deadtar or UnitIsDeadOrGhost("target"), attacktar or UnitCanAttack("target", "player"), hastar or GetObjectExists("target"), UnitIsPlayer("target") local debuff = br.player.debuff local enemies = enemies or {} local falling, swimming, flying, moving = getFallTime(), IsSwimming(), IsFlying(), GetUnitSpeed("player")>0 local flaskBuff = getBuffRemain("player",br.player.flask.wod.buff.agilityBig) local friendly = friendly or UnitIsFriend("target", "player") local gcd = br.player.gcd local hasMouse = GetObjectExists("mouseover") local healPot = getHealthPot() local inCombat = br.player.inCombat local inInstance = br.player.instance=="party" local inRaid = br.player.instance=="raid" local lastSpell = lastSpellCast local level = br.player.level local lootDelay = getOptionValue("LootDelay") local lowestHP = br.friend[1].unit local mode = br.player.mode local moveIn = 999 -- local multidot = (useCleave() or br.player.mode.rotation ~= 3) local perk = br.player.perk local php = br.player.health local playerMouse = UnitIsPlayer("mouseover") local power, powmax, powgen, powerDeficit = br.player.power.amount.pain, br.player.power.pain.max, br.player.power.regen, br.player.power.pain.deficit local pullTimer = br.DBM:getPulltimer() local racial = br.player.getRacial() local recharge = br.player.recharge local solo = br.player.instance=="none" local spell = br.player.spell local talent = br.player.talent local ttd = getTTD local ttm = br.player.power.ttm local units = units or {} units.dyn5 = br.player.units(5) enemies.yards5 = br.player.enemies(5) enemies.yards20 = br.player.enemies(20) if leftCombat == nil then leftCombat = GetTime() end if profileStop == nil then profileStop = false end if talent.chaosCleave then chaleave = 1 else chaleave = 0 end if talent.prepared then prepared = 1 else prepared = 0 end if lastSpell == spell.vengefulRetreat then vaulted = true else vaulted = false end -------------------- --- Action Lists --- -------------------- -- Action List - Extras local function actionList_Extras() -- Dummy Test if isChecked("DPS Testing") then if GetObjectExists("target") then if getCombatTime() >= (tonumber(getOptionValue("DPS Testing"))*60) and isDummy() then StopAttack() ClearTarget() Print(tonumber(getOptionValue("DPS Testing")) .." Minute Dummy Test Concluded - Profile Stopped") profileStop = true end end end -- End Dummy Test end -- End Action List - Extras -- Action List - Defensive local function actionList_Defensive() if useDefensive() then -- Pot/Stoned if isChecked("Pot/Stoned") and php <= getOptionValue("Pot/Stoned") and inCombat and (hasHealthPot() or hasItem(5512)) then if canUse(5512) then useItem(5512) elseif canUse(129196) then --Legion Healthstone useItem(129196) elseif canUse(healPot) then useItem(healPot) end end -- Heirloom Neck if isChecked("Heirloom Neck") and php <= getOptionValue("Heirloom Neck") then if hasEquiped(122668) then if GetItemCooldown(122668)==0 then useItem(122668) end end end -- Blur if isChecked("Blur") and php <= getOptionValue("Blur") and inCombat then if cast.blur() then return end end -- Darkness if isChecked("Darkness") and php <= getOptionValue("Darkness") and inCombat then if cast.darkness() then return end end -- Chaos Nova if isChecked("Chaos Nova - HP") and php <= getValue("Chaos Nova - HP") and inCombat and #enemies.yards5 > 0 then if cast.chaosNova() then return end end if isChecked("Chaos Nova - AoE") and #enemies.yards5 >= getValue("Chaos Nova - AoE") then if cast.chaosNova() then return end end end -- End Defensive Toggle end -- End Action List - Defensive -- Action List - Interrupts local function actionList_Interrupts() if useInterrupts() then -- Consume Magic if isChecked("Consume Magic") then for i=1, #enemies.yards20 do thisUnit = enemies.yards20[i] if canInterrupt(thisUnit,getOptionValue("Interrupt At")) then if cast.consumeMagic(thisUnit) then return end end end end end -- End useInterrupts check end -- End Action List - Interrupts -- Action List - Single Target local function actionList_SingleTarget() end -- End Action List - Single Target -- Action List - MultiTarget local function actionList_MultiTarget() end -- End Action List - Multi Target -- Action List - Cooldowns local function actionList_Cooldowns() if useCDs() and getDistance(units.dyn5) < 5 then end -- End useCDs check end -- End Action List - Cooldowns -- Action List - PreCombat local function actionList_PreCombat() if not inCombat and not (IsFlying() or IsMounted()) then -- Flask / Crystal -- flask,type=flask_of_the_seventh_demon if isChecked("Flask / Crystal") then if inRaid and canFlask and flaskBuff==0 and not UnitBuffID("player",188033) then useItem(br.player.flask.wod.agilityBig) return true end if flaskBuff==0 then if not UnitBuffID("player",188033) and canUse(118922) then --Draenor Insanity Crystal useItem(118922) return true end if not UnitBuffID("player",193456) and not UnitBuffID("player",188033) and canUse(129192) then -- Gaze of the Legion useItem(129192) return true end end end if isChecked("Pre-Pull Timer") and pullTimer <= getOptionValue("Pre-Pull Timer") then end -- End Pre-Pull if GetObjectExists("target") and not UnitIsDeadOrGhost("target") and UnitCanAttack("target", "player") and getDistance("target") < 5 then -- Start Attack StartAttack() end end -- End No Combat end -- End Action List - PreCombat --------------------- --- Begin Profile --- --------------------- -- Profile Stop | Pause if not inCombat and not hastar and profileStop==true then profileStop = false elseif (inCombat and profileStop==true) or pause() or mode.rotation==4 then return true else ----------------------- --- Extras Rotation --- ----------------------- if actionList_Extras() then return end -------------------------- --- Defensive Rotation --- -------------------------- if actionList_Defensive() then return end ------------------------------ --- Out of Combat Rotation --- ------------------------------ if actionList_PreCombat() then return end -------------------------- --- In Combat Rotation --- -------------------------- if inCombat and profileStop==false and GetObjectExists(units.dyn5) and not UnitIsDeadOrGhost(units.dyn5) and UnitCanAttack(units.dyn5, "player") then ------------------------------ --- In Combat - Interrupts --- ------------------------------ if actionList_Interrupts() then return end --------------------------- --- SimulationCraft APL --- --------------------------- -- Print(cast.sigilofFlame()) -- if true then return end -- actions=auto_attack if getDistance(units.dyn5) < 5 then StartAttack() end if isChecked("Trinkets") and getDistance("target") < 5 then if canUse(13) then useItem(13) end if canUse(14) and getNumEnemies("player",12) >= 1 then useItem(14) end end -- actions+=/fiery_brand,if=buff.demon_spikes.down&buff.metamorphosis.down --TODO -- if power >= 30 and php <= 60 and soulAmount() >= 1 then -- if cast.soulCleave() then return end -- end -- actions+=/demon_spikes,if=charges=2|buff.demon_spikes.down&!dot.fiery_brand.ticking&buff.metamorphosis.down if ( recharge.demonSpikes <= 6 and charges.demonSpikes >= 1) and hasThreat() and not buff.exists.demonSpikes and not debuff.fieryBrand and not buff.exists.metamorphosis then if cast.demonSpikes() then return end end -- actions+=/empower_wards,if=debuff.casting.up -- actions+=/infernal_strike,if=!sigil_placed&!in_flight&remains-travel_time-delay<0.3*duration&artifact.fiery_demise.enabled&dot.fiery_brand.ticking -- actions+=/infernal_strike,if=!sigil_placed&!in_flight&remains-travel_time-delay<0.3*duration&(!artifact.fiery_demise.enabled|(max_charges-charges_fractional)*recharge_time<cooldown.fiery_brand.remains+5)&(cooldown.sigil_of_flame.remains>7|charges=2) if recharge.infernalStrike <= 2 and getDistance("target") < 5 then if cast.infernalStrike("player") then return end end -- actions+=/spirit_bomb,if=debuff.frailty.down if not UnitDebuffID("target",224509) then if cast.spiritBomb("target") then return end end -- actions+=/soul_carver,if=dot.fiery_brand.ticking if cast.soulCarver() then return end -- if UnitDebuffID("target",207744) then -- if cast.soulCarver() then return end -- end -- actions+=/immolation_aura,if=pain<=80 if power <= 80 and getDistance("target") < 5 then if cast.immolationAura() then return end end -- actions+=/felblade,if=pain<=70 if power <= 70 then if cast.felblade() then return end end -- actions+=/soul_barrier -- actions+=/soul_cleave,if=soul_fragments=5 if soulAmount() == 5 and power >= 30 then if cast.soulCleave() then return end end -- actions+=/metamorphosis,if=buff.demon_spikes.down&!dot.fiery_brand.ticking&buff.metamorphosis.down&incoming_damage_5s>health.max*0.70 -- actions+=/fel_devastation,if=incoming_damage_5s>health.max*0.70 if cast.felDevastation() then dub.felDevastation = false; return end -- actions+=/soul_cleave,if=incoming_damage_5s>=health.max*0.70 if power >= 30 and php <= 70 then if cast.soulCleave() then return end end -- actions+=/fel_eruption -- actions+=/sigil_of_flame,if=remains-delay<=0.3*duration if not isMoving("target") and getTimeToDie() > 10 then if cast.sigilofFlame("target") then return end end -- actions+=/fracture,if=pain>=80&soul_fragments<4&incoming_damage_4s<=health.max*0.20 -- actions+=/soul_cleave,if=pain>=80 if power >= 80 then if cast.soulCleave() then return end end -- actions+=/shear if power < 80 then if cast.shear() then return end end if getDistance("target") > 5 then if cast.throwGlaive("target") then return end end end --End In Combat end --End Rotation Logic end -- End Timer end -- End runRotation local id = 581 if br.rotations[id] == nil then br.rotations[id] = {} end tinsert(br.rotations[id],{ name = rotationName, toggles = createToggles, options = createOptions, run = runRotation, })
qj739/BadRotations
Rotations/Demon Hunter/Vengeance/VengeanceDub.lua
Lua
gpl-3.0
21,919
<h3>Message log</h3> <div> <!--<rl-editable-message-log service="messageLog.messageService"></rl-editable-message-log>--> </div>
TheOriginalJosh/TypeScript-Angular-Components
bootstrapper/messageLog/messageLogNg1Test.html
HTML
gpl-3.0
130
package fragment; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.deaspostudios.devchats.R; import com.google.firebase.database.ChildEventListener; import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; import java.util.List; import Widgets.DividerItemDecoration; import Widgets.ItemClickSupport; import adapter.Items_forums; import adapter.RecyclerAdapterTopic; import ui.TopicActivity; import static com.deaspostudios.devchats.MainActivity.mUserEmail; /** * A simple {@link Fragment} subclass. * Activities that contain this fragment must implement the * {@link topic.OnFragmentInteractionListener} interface * to handle interaction events. * Use the {@link topic#newInstance} factory method to * create an instance of this fragment. */ public class topic extends Fragment implements SwipeRefreshLayout.OnRefreshListener { // TODO: Rename parameter arguments, choose names that match // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER private static final String ARG_PARAM1 = "param1"; private static final String ARG_PARAM2 = "param2"; public static List<Items_forums> topics; public static RecyclerAdapterTopic topicsAdapter; //firebase database instances public static FirebaseDatabase tFirebaseDatabase; public static DatabaseReference tDatabaseReference; private static ChildEventListener tChildEventListener; private static SwipeRefreshLayout swipeRefreshLayout; //adapters for topics private RecyclerView recyclerView; // TODO: Rename and change types of parameters private String mParam1; private String mParam2; private OnFragmentInteractionListener mListener; public topic() { // Required empty public constructor } /** * Use this factory method to create a new instance of * this fragment using the provided parameters. * * @param param1 Parameter 1. * @param param2 Parameter 2. * @return A new instance of fragment topic. */ // TODO: Rename and change types and number of parameters public static topic newInstance(String param1, String param2) { topic fragment = new topic(); Bundle args = new Bundle(); args.putString(ARG_PARAM1, param1); args.putString(ARG_PARAM2, param2); fragment.setArguments(args); return fragment; } public static void attachTopicDatabaseListener() { if (swipeRefreshLayout != null) { swipeRefreshLayout.setRefreshing(true); } if (tChildEventListener == null) { tChildEventListener = new ChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot, String s) { Items_forums items_forums = dataSnapshot.getValue(Items_forums.class); topics.add(items_forums); topicsAdapter.notifyDataSetChanged(); } @Override public void onChildChanged(DataSnapshot dataSnapshot, String s) { } @Override public void onChildRemoved(DataSnapshot dataSnapshot) { Items_forums items_forums = dataSnapshot.getValue(Items_forums.class); topics.remove(items_forums); topicsAdapter.notifyDataSetChanged(); } @Override public void onChildMoved(DataSnapshot dataSnapshot, String s) { } @Override public void onCancelled(DatabaseError databaseError) { } }; tDatabaseReference.addChildEventListener(tChildEventListener); } topicsAdapter.notifyDataSetChanged(); if (swipeRefreshLayout != null) { swipeRefreshLayout.setRefreshing(false); } } public static void detachTopicDatabaseListener() { if (tChildEventListener != null) { tDatabaseReference.removeEventListener(tChildEventListener); tChildEventListener = null; } } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); } } @Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_topic, container, false); getActivity().getWindow().setBackgroundDrawable(getResources().getDrawable(R.drawable.background)); //initializes swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout_topic); recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view_topic); //mMessageListView.setAdapter(groupsAdapter); RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity().getApplicationContext()); recyclerView.setLayoutManager(layoutManager); recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), LinearLayoutManager.VERTICAL)); recyclerView.setItemAnimator(new DefaultItemAnimator()); //recyclerView.addOnItemTouchListener(); ItemClickSupport.addTo(recyclerView).setOnItemClickListener(new ItemClickSupport.OnItemClickListener() { @Override public void onItemClicked(RecyclerView recyclerView, int position, View v) { Items_forums selectedForum = topics.get(position); if (selectedForum != null) { Intent intent = new Intent(getActivity(), TopicActivity.class); String forumId = selectedForum.getForum_id(); String forumName = selectedForum.getTopic_name(); String currentUserMail = mUserEmail; intent.putExtra("forumKey", forumId); intent.putExtra("forumName", forumName); intent.putExtra("usermail", currentUserMail); /** * start activity */ startActivity(intent); } } }); recyclerView.setAdapter(topicsAdapter); swipeRefreshLayout.setOnRefreshListener(this); /** * Showing Swipe Refresh animation on activity create * As animation won't start on onCreate, post runnable is used */ swipeRefreshLayout.post(new Runnable() { @Override public void run() { swipeRefreshLayout.setRefreshing(true); attachTopicDatabaseListener(); } } ); return view; } // TODO: Rename method, update argument and hook method into UI event public void onButtonPressed(Uri uri) { if (mListener != null) { mListener.onFragmentInteraction(uri); } } @Override public void onAttach(Context context) { super.onAttach(context); if (context instanceof OnFragmentInteractionListener) { mListener = (OnFragmentInteractionListener) context; } else { throw new RuntimeException(context.toString() + " must implement OnFragmentInteractionListener"); } } @Override public void onDetach() { super.onDetach(); mListener = null; } @Override public void onStart() { super.onStart(); attachTopicDatabaseListener(); } @Override public void onResume() { super.onResume(); attachTopicDatabaseListener(); } @Override public void onPause() { super.onPause(); } @Override public void onStop() { super.onStop(); /*detachTopicDatabaseListener(); topics.clear(); topicsAdapter.notifyDataSetChanged();*/ } @Override public void onRefresh() { attachTopicDatabaseListener(); } /** * This interface must be implemented by activities that contain this * fragment to allow an interaction in this fragment to be communicated * to the activity and potentially other fragments contained in that * activity. * <p> * See the Android Training lesson <a href= * "http://developer.android.com/training/basics/fragments/communicating.html" * >Communicating with Other Fragments</a> for more information. */ public interface OnFragmentInteractionListener { // TODO: Update argument type and name void onFragmentInteraction(Uri uri); } }
Fshem/developers-chat
app/src/main/java/fragment/topic.java
Java
gpl-3.0
9,561
<?php /* * This file is part of Totara LMS * * Copyright (C) 2010 onwards Totara Learning Solutions LTD * * 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/>. * * @author Alastair Munro <alastair.munro@totaralms.com> * @package totara * @subpackage customfield */ defined('MOODLE_INTERNAL') || die(); $plugin->version = 2014050500; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2012120305; // Requires this Moodle version. $plugin->cron = 0; // Period for cron to check this module (secs). $plugin->component = 'totara_question'; // To check on upgrade, that module sits in correct place.
totara/seedlings
totara/question/version.php
PHP
gpl-3.0
1,251
using System.Linq; using NLog; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Instrumentation.Sentry; namespace NzbDrone.Common.Instrumentation { public class InitializeLogger { private readonly IOsInfo _osInfo; public InitializeLogger(IOsInfo osInfo) { _osInfo = osInfo; } public void Initialize() { var sentryTarget = LogManager.Configuration.AllTargets.OfType<SentryTarget>().FirstOrDefault(); if (sentryTarget != null) { sentryTarget.UpdateScope(_osInfo); } } } }
Radarr/Radarr
src/NzbDrone.Common/Instrumentation/InitializeLogger.cs
C#
gpl-3.0
632
#include "proxysql.h" #include "cpp.h" extern MySQL_Authentication *GloMyAuth; extern MySQL_Threads_Handler *GloMTH; #ifdef max_allowed_packet #undef max_allowed_packet #endif #ifdef DEBUG static void __dump_pkt(const char *func, unsigned char *_ptr, unsigned int len) { if (GloVars.global.gdbg==0) return; if (GloVars.global.gdbg_lvl[PROXY_DEBUG_MYSQL_PROTOCOL].verbosity < 8 ) return; unsigned int i; fprintf(stderr,"DUMP %d bytes FROM %s\n", len, func); for(i = 0; i < len; i++) { if(isprint(_ptr[i])) fprintf(stderr,"%c", _ptr[i]); else fprintf(stderr,"."); if (i>0 && (i%16==15 || i==len-1)) { unsigned int j; if (i%16!=15) { j=15-i%16; while (j--) fprintf(stderr," "); } fprintf(stderr," --- "); for (j=(i==len-1 ? ((int)(i/16))*16 : i-15 ) ; j<=i; j++) { fprintf(stderr,"%02x ", _ptr[j]); } fprintf(stderr,"\n"); } } fprintf(stderr,"\n\n"); } #endif double proxy_my_rnd(struct rand_struct *rand_st) { rand_st->seed1= (rand_st->seed1*3+rand_st->seed2) % rand_st->max_value; rand_st->seed2= (rand_st->seed1+rand_st->seed2+33) % rand_st->max_value; return (((double) rand_st->seed1) / rand_st->max_value_dbl); } void proxy_create_random_string(char *to, uint length, struct rand_struct *rand_st) { uint i; for (i=0; i<length ; i++) { *to= (char) (proxy_my_rnd(rand_st) * 94 + 33); to++; } *to= '\0'; } static inline int write_encoded_length(unsigned char *p, uint64_t val, uint8_t len, char prefix) { if (len==1) { *p=(char)val; return 1; } *p=prefix; p++; memcpy(p,&val,len-1); return len; } static inline int write_encoded_length_and_string(unsigned char *p, uint64_t val, uint8_t len, char prefix, char *string) { int l=write_encoded_length(p,val,len,prefix); if (val) { memcpy(p+l,string,val); } return l+val; } void proxy_compute_sha1_hash_multi(uint8 *digest, const char *buf1, int len1, const char *buf2, int len2) { PROXY_TRACE(); SHA_CTX sha1_context; SHA1_Init(&sha1_context); SHA1_Update(&sha1_context, buf1, len1); SHA1_Update(&sha1_context, buf2, len2); SHA1_Final(digest, &sha1_context); } void proxy_compute_sha1_hash(uint8 *digest, const char *buf, int len) { PROXY_TRACE(); SHA_CTX sha1_context; SHA1_Init(&sha1_context); SHA1_Update(&sha1_context, buf, len); SHA1_Final(digest, &sha1_context); } void proxy_compute_two_stage_sha1_hash(const char *password, size_t pass_len, uint8 *hash_stage1, uint8 *hash_stage2) { proxy_compute_sha1_hash(hash_stage1, password, pass_len); proxy_compute_sha1_hash(hash_stage2, (const char *) hash_stage1, SHA_DIGEST_LENGTH); } void proxy_my_crypt(char *to, const uchar *s1, const uchar *s2, uint len) { const uint8 *s1_end= s1 + len; while (s1 < s1_end) *to++= *s1++ ^ *s2++; } void proxy_scramble(char *to, const char *message, const char *password) { uint8 hash_stage1[SHA_DIGEST_LENGTH]; uint8 hash_stage2[SHA_DIGEST_LENGTH]; /* Two stage SHA1 hash of the password. */ proxy_compute_two_stage_sha1_hash(password, strlen(password), hash_stage1, hash_stage2); /* create crypt string as sha1(message, hash_stage2) */; proxy_compute_sha1_hash_multi((uint8 *) to, message, SCRAMBLE_LENGTH, (const char *) hash_stage2, SHA_DIGEST_LENGTH); proxy_my_crypt(to, (const uchar *) to, hash_stage1, SCRAMBLE_LENGTH); } typedef union _4bytes_t { unsigned char data[4]; uint32_t i; } _4bytes_t; unsigned int CPY3(unsigned char *ptr) { _4bytes_t buf; // memcpy(buf.data, pkt, 3); buf.i=*(uint32_t *)ptr; buf.data[3]=0; // unsigned char _cpy3buf[4]; // _cpy3buf[3]=0; // unsigned int ret=*(unsigned int *)_cpy3buf; return buf.i; } // see http://dev.mysql.com/doc/internals/en/integer.html#packet-Protocol::LengthEncodedInteger /* arguments to pass: * pointer to the field * poiter to the variable to store the length * returns the bytes length of th field */ uint8_t mysql_decode_length(unsigned char *ptr, uint64_t *len) { if (*ptr <= 0xfb) { if (len) { *len = CPY1(ptr); }; return 1; } if (*ptr == 0xfc) { if (len) { *len = CPY2(ptr+1); }; return 3; } if (*ptr == 0xfd) { if (len) { *len = CPY3(ptr+1); }; return 4; } if (*ptr == 0xfe) { if (len) { *len = CPY8(ptr+1); }; return 9; } return 0; // never reaches here } static uint8_t mysql_encode_length(uint64_t len, char *hd) { if (len < 251) return 1; if (len < 65536) { if (hd) { *hd=0xfc; }; return 3; } if (len < 16777216) { if (hd) { *hd=0xfd; }; return 4; } if (hd) { *hd=0xfe; } return 9; } enum MySQL_response_type mysql_response(unsigned char *pkt, unsigned int length) { unsigned char c=*pkt; switch (c) { case 0: // proxy_debug(PROXY_DEBUG_MYSQL_COM, 6, "Packet OK_Packet\n"); return OK_Packet; case 0xff: // proxy_debug(PROXY_DEBUG_MYSQL_COM, 6, "Packet ERR_Packet\n"); return ERR_Packet; case 0xfe: if (length < 9) { //proxy_debug(PROXY_DEBUG_MYSQL_COM, 6, "Packet EOF_Packet\n"); return EOF_Packet; } default: //proxy_debug(PROXY_DEBUG_MYSQL_COM, 6, "Packet UNKNOWN_Packet\n"); return UNKNOWN_Packet; } } int pkt_com_query(unsigned char *pkt, unsigned int length) { unsigned char buf[length]; memcpy(buf,pkt+1, length-1); buf[length-1]='\0'; proxy_debug(PROXY_DEBUG_MYSQL_PROTOCOL,1,"Query: %s\n", buf); return PKT_PARSED; } int pkt_ok(unsigned char *pkt, unsigned int length, MySQL_Protocol *mp) { if (length < 7) return PKT_ERROR; uint64_t affected_rows; uint64_t insert_id; #ifdef DEBUG uint16_t warns; #endif /* DEBUG */ unsigned char msg[length]; unsigned int p=0; int rc; pkt++; p++; rc=mysql_decode_length(pkt,&affected_rows); pkt += rc; p+=rc; rc=mysql_decode_length(pkt,&insert_id); pkt += rc; p+=rc; mp->prot_status=CPY2(pkt); pkt+=sizeof(uint16_t); p+=sizeof(uint16_t); #ifdef DEBUG warns=CPY2(pkt); #endif /* DEBUG */ pkt+=sizeof(uint16_t); p+=sizeof(uint16_t); pkt++; p++; if (length>p) { memcpy(msg,pkt,length-p); msg[length-p]=0; } else { msg[0]=0; } proxy_debug(PROXY_DEBUG_MYSQL_PROTOCOL,1,"OK Packet <affected_rows:%u insert_id:%u status:%u warns:%u msg:%s>\n", (uint32_t)affected_rows, (uint32_t)insert_id, (uint16_t)mp->prot_status, (uint16_t)warns, msg); return PKT_PARSED; } int pkt_end(unsigned char *pkt, unsigned int length, MySQL_Protocol *mp) { if(*pkt != 0xFE || length > 5) return PKT_ERROR; #ifdef DEBUG uint16_t warns = 0; #endif /* DEBUG */ if(length > 1) { // 4.1+ pkt++; #ifdef DEBUG warns = CPY2(pkt); #endif /* DEBUG */ pkt += 2; mp->prot_status = CPY2(pkt); /* if((tag->state == STATE_TXT_ROW || tag->state == STATE_BIN_ROW) && status & SERVER_MORE_RESULTS_EXISTS && tag->event != EVENT_END_MULTI_RESULT) return PKT_WRONG_TYPE; } */ } proxy_debug(PROXY_DEBUG_MYSQL_PROTOCOL,1,"End Packet <status:%u warns:%u>\n", mp->prot_status, warns); // if(status & SERVER_MORE_RESULTS_EXISTS) { // proxy_debug(PROXY_DEBUG_MYSQL_PROTOCOL,1,"End Packet <status:%u warns:%u>\n"); // } return PKT_PARSED; } MySQL_Prepared_Stmt_info::MySQL_Prepared_Stmt_info(unsigned char *pkt, unsigned int length) { pkt += 5; statement_id = CPY4(pkt); pkt += sizeof(uint32_t); num_columns = CPY2(pkt); pkt += sizeof(uint16_t); num_params = CPY2(pkt); pkt += sizeof(uint16_t); pkt++; // reserved_1 warning_count = CPY2(pkt); // fprintf(stderr,"Generating prepared statement with id=%d, cols=%d, params=%d, warns=%d\n", statement_id, num_columns, num_params, warning_count); pending_num_columns=num_columns; pending_num_params=num_params; } void MySQL_Protocol::init(MySQL_Data_Stream **__myds, MySQL_Connection_userinfo *__userinfo, MySQL_Session *__sess) { myds=__myds; userinfo=__userinfo; sess=__sess; current_PreStmt=NULL; // prot_status=0; } //int parse_mysql_pkt(unsigned char *pkt, enum session_states *states, int from_client) { int MySQL_Protocol::parse_mysql_pkt(PtrSize_t *PS_entry, MySQL_Data_Stream *__myds) { unsigned char *pkt=(unsigned char *)PS_entry->ptr; // unsigned int size=PS_entry->size; //myds=__myds; enum mysql_data_stream_status *DSS=&(*myds)->DSS; mysql_hdr hdr; unsigned char cmd; unsigned char *payload; int from=(*myds)->myds_type; // if the packet is from client or server enum MySQL_response_type c; payload=pkt+sizeof(mysql_hdr); memcpy(&hdr,pkt,sizeof(mysql_hdr)); //Copy4B(&hdr,pkt); proxy_debug(PROXY_DEBUG_MYSQL_PROTOCOL,1,"MySQL Packet length=%d, senquence_id=%d, addr=%p\n", hdr.pkt_length, hdr.pkt_id, payload); switch (*DSS) { // client is not connected yet case STATE_NOT_CONNECTED: if (from==MYDS_FRONTEND) { // at this stage we expect a packet from the server, not from client return PKT_ERROR; } break; // client has sent the handshake case STATE_CLIENT_HANDSHAKE: if (from==MYDS_FRONTEND) { // at this stage we expect a packet from the server, not from client return PKT_ERROR; } c=mysql_response(payload, hdr.pkt_length); switch (c) { case OK_Packet: if (pkt_ok(payload, hdr.pkt_length, this)==PKT_PARSED) { *DSS=STATE_SLEEP; return PKT_PARSED; } break; default: return PKT_ERROR; // from the server we expect either an OK or an ERR. Everything else is wrong } break; // connection is idle. Client should be send a command case STATE_SLEEP: // if (!from_client) { // return PKT_ERROR; // } cmd=*payload; switch (cmd) { case MYSQL_COM_QUERY: if (pkt_com_query(payload, hdr.pkt_length)==PKT_PARSED) { //*states=STATE_CLIENT_COM_QUERY; return PKT_PARSED; } break; } //break; default: // TO BE REMOVED: begin if (from==MYDS_FRONTEND) { // at this stage we expect a packet from the server, not from client return PKT_ERROR; } c=mysql_response(payload, hdr.pkt_length); switch (c) { case OK_Packet: if (pkt_ok(payload, hdr.pkt_length, this)==PKT_PARSED) { *DSS=STATE_SLEEP; return PKT_PARSED; } break; case EOF_Packet: pkt_end(payload, hdr.pkt_length, this); break; default: return PKT_ERROR; // from the server we expect either an OK or an ERR. Everything else is wrong } // TO BE REMOVED: end break; } return PKT_ERROR; } static unsigned char protocol_version=10; //static uint16_t server_capabilities=CLIENT_FOUND_ROWS | CLIENT_PROTOCOL_41 | CLIENT_IGNORE_SIGPIPE | CLIENT_TRANSACTIONS | CLIENT_SECURE_CONNECTION | CLIENT_CONNECT_WITH_DB | CLIENT_SSL; //static uint8_t server_language=33; static uint16_t server_status=1; //static char *mysql_server_version = (char *)"5.1.30"; //bool MySQL_Protocol::generate_statistics_response(MySQL_Data_Stream *myds, bool send, void **ptr, unsigned int *len) { bool MySQL_Protocol::generate_statistics_response(bool send, void **ptr, unsigned int *len) { // FIXME : this function generates a not useful string. It is a placeholder for now char buf1[1000]; unsigned long long t1=monotonic_time(); //const char *stats=(char *)"Uptime: 1000 Threads: 1 Questions: 34221015 Slow queries: 0 Opens: 757 Flush tables: 1 Open tables: 185 Queries per second avg: 22.289"; sprintf(buf1,"Uptime: %llu Threads: %d Questions: %llu Slow queries: %llu", (t1-GloVars.global.start_time)/1000/1000, MyHGM->status.client_connections , GloMTH->get_total_queries() , GloMTH->get_slow_queries() ); unsigned char statslen=strlen(buf1); mysql_hdr myhdr; myhdr.pkt_id=1; //myhdr.pkt_length=statslen+1; myhdr.pkt_length=statslen; unsigned int size=myhdr.pkt_length+sizeof(mysql_hdr); unsigned char *_ptr=(unsigned char *)l_alloc(size); memcpy(_ptr, &myhdr, sizeof(mysql_hdr)); //Copy4B(_ptr, &myhdr); int l=sizeof(mysql_hdr); //_ptr[l++]=statslen; memcpy(_ptr+l,buf1,statslen); if (send==true) { (*myds)->PSarrayOUT->add((void *)_ptr,size); } if (len) { *len=size; } if (ptr) { *ptr=(void *)_ptr; } #ifdef DEBUG if (dump_pkt) { __dump_pkt(__func__,_ptr,size); } #endif return true; } //bool MySQL_Protocol::generate_pkt_EOF(MySQL_Data_Stream *myds, bool send, void **ptr, unsigned int *len, uint8_t sequence_id, uint16_t warnings, uint16_t status) { bool MySQL_Protocol::generate_pkt_EOF(bool send, void **ptr, unsigned int *len, uint8_t sequence_id, uint16_t warnings, uint16_t status) { mysql_hdr myhdr; myhdr.pkt_id=sequence_id; myhdr.pkt_length=5; unsigned int size=myhdr.pkt_length+sizeof(mysql_hdr); unsigned char *_ptr=(unsigned char *)l_alloc(size); memcpy(_ptr, &myhdr, sizeof(mysql_hdr)); //Copy4B(_ptr, &myhdr); int l=sizeof(mysql_hdr); _ptr[l]=0xfe; l++; memcpy(_ptr+l, &warnings, sizeof(uint16_t)); l+=sizeof(uint16_t); memcpy(_ptr+l, &status, sizeof(uint16_t)); if (send==true) { (*myds)->PSarrayOUT->add((void *)_ptr,size); switch ((*myds)->DSS) { case STATE_COLUMN_DEFINITION: (*myds)->DSS=STATE_EOF1; break; case STATE_ROW: (*myds)->DSS=STATE_EOF2; break; default: assert(0); } } if (len) { *len=size; } if (ptr) { *ptr=(void *)_ptr; } #ifdef DEBUG if (dump_pkt) { __dump_pkt(__func__,_ptr,size); } #endif return true; } //bool MySQL_Protocol::generate_pkt_ERR(MySQL_Data_Stream *myds, bool send, void **ptr, unsigned int *len, uint8_t sequence_id, uint16_t error_code, char *sql_state, char *sql_message) { bool MySQL_Protocol::generate_pkt_ERR(bool send, void **ptr, unsigned int *len, uint8_t sequence_id, uint16_t error_code, char *sql_state, char *sql_message) { mysql_hdr myhdr; uint32_t sql_message_len=( sql_message ? strlen(sql_message) : 0 ); myhdr.pkt_id=sequence_id; myhdr.pkt_length=1+sizeof(uint16_t)+1+5+sql_message_len; unsigned int size=myhdr.pkt_length+sizeof(mysql_hdr); unsigned char *_ptr=(unsigned char *)l_alloc(size); memcpy(_ptr, &myhdr, sizeof(mysql_hdr)); //Copy4B(_ptr, &myhdr); int l=sizeof(mysql_hdr); _ptr[l]=0xff; l++; memcpy(_ptr+l, &error_code, sizeof(uint16_t)); l+=sizeof(uint16_t); _ptr[l]='#'; l++; memcpy(_ptr+l, sql_state, 5); l+=5; if (sql_message) memcpy(_ptr+l, sql_message, sql_message_len); if (send==true) { (*myds)->PSarrayOUT->add((void *)_ptr,size); switch ((*myds)->DSS) { case STATE_CLIENT_HANDSHAKE: case STATE_QUERY_SENT_DS: case STATE_QUERY_SENT_NET: (*myds)->DSS=STATE_ERR; break; default: assert(0); } } if (len) { *len=size; } if (ptr) { *ptr=(void *)_ptr; } #ifdef DEBUG if (dump_pkt) { __dump_pkt(__func__,_ptr,size); } #endif return true; } //bool MySQL_Protocol::generate_pkt_OK(MySQL_Data_Stream *myds, bool send, void **ptr, unsigned int *len, uint8_t sequence_id, unsigned int affected_rows, unsigned int last_insert_id, uint16_t status, uint16_t warnings, char *msg) { bool MySQL_Protocol::generate_pkt_OK(bool send, void **ptr, unsigned int *len, uint8_t sequence_id, unsigned int affected_rows, uint64_t last_insert_id, uint16_t status, uint16_t warnings, char *msg) { char affected_rows_prefix; uint8_t affected_rows_len=mysql_encode_length(affected_rows, &affected_rows_prefix); char last_insert_id_prefix; uint8_t last_insert_id_len=mysql_encode_length(last_insert_id, &last_insert_id_prefix); uint32_t msg_len=( msg ? strlen(msg) : 0 ); char msg_prefix; uint8_t msg_len_len=mysql_encode_length(msg_len, &msg_prefix); mysql_hdr myhdr; myhdr.pkt_id=sequence_id; myhdr.pkt_length=1+affected_rows_len+last_insert_id_len+sizeof(uint16_t)+sizeof(uint16_t)+msg_len; if (msg_len) myhdr.pkt_length+=msg_len_len; unsigned int size=myhdr.pkt_length+sizeof(mysql_hdr); unsigned char *_ptr=(unsigned char *)l_alloc(size); memcpy(_ptr, &myhdr, sizeof(mysql_hdr)); //Copy4B(_ptr, &myhdr); int l=sizeof(mysql_hdr); _ptr[l]=0x00; l++; /* if (affected_rows_len > 1) { _ptr[l]=affected_rows_prefix; l++; } memcpy(_ptr+l, &affected_rows, affected_rows_len); l+=( affected_rows_len > 1 ? affected_rows_len - 1 : 1 ); if (last_insert_id_len > 1) { _ptr[l]=last_insert_id_prefix; l++; } memcpy(_ptr+l, &last_insert_id, last_insert_id_len); l+=( last_insert_id_len > 1 ? last_insert_id_len -1 : 1 ); */ l+=write_encoded_length(_ptr+l, affected_rows, affected_rows_len, affected_rows_prefix); l+=write_encoded_length(_ptr+l, last_insert_id, last_insert_id_len, last_insert_id_prefix); memcpy(_ptr+l, &status, sizeof(uint16_t)); l+=sizeof(uint16_t); memcpy(_ptr+l, &warnings, sizeof(uint16_t)); l+=sizeof(uint16_t); if (msg) { l+=write_encoded_length(_ptr+l, msg_len, msg_len_len, msg_prefix); memcpy(_ptr+l, msg, msg_len); } if (send==true) { (*myds)->PSarrayOUT->add((void *)_ptr,size); switch ((*myds)->DSS) { case STATE_CLIENT_HANDSHAKE: case STATE_QUERY_SENT_DS: case STATE_QUERY_SENT_NET: (*myds)->DSS=STATE_OK; break; default: assert(0); } } if (len) { *len=size; } if (ptr) { *ptr=(void *)_ptr; } #ifdef DEBUG if (dump_pkt) { __dump_pkt(__func__,_ptr,size); } #endif return true; } //bool MySQL_Protocol::generate_pkt_column_count(MySQL_Data_Stream *myds, bool send, void **ptr, unsigned int *len, uint8_t sequence_id, uint64_t count) { bool MySQL_Protocol::generate_pkt_column_count(bool send, void **ptr, unsigned int *len, uint8_t sequence_id, uint64_t count) { char count_prefix=0; uint8_t count_len=mysql_encode_length(count, &count_prefix); mysql_hdr myhdr; myhdr.pkt_id=sequence_id; myhdr.pkt_length=count_len; unsigned int size=myhdr.pkt_length+sizeof(mysql_hdr); unsigned char *_ptr=(unsigned char *)l_alloc(size); memcpy(_ptr, &myhdr, sizeof(mysql_hdr)); //Copy4B(_ptr, &myhdr); int l=sizeof(mysql_hdr); /* if (count_len > 1) { _ptr[l]=count_prefix; l++; } memcpy(_ptr+l, &count, count_len); l+=( count_len > 1 ? count_len -1 : 1 ); */ l+=write_encoded_length(_ptr+l, count, count_len, count_prefix); if (send==true) { (*myds)->PSarrayOUT->add((void *)_ptr,size); } if (len) { *len=size; } if (ptr) { *ptr=(void *)_ptr; } #ifdef DEBUG if (dump_pkt) { __dump_pkt(__func__,_ptr,size); } #endif return true; } //bool MySQL_Protocol::generate_pkt_field(MySQL_Data_Stream *myds, bool send, void **ptr, unsigned int *len, uint8_t sequence_id, char *schema, char *table, char *org_table, char *name, char *org_name, uint16_t charset, uint32_t column_length, uint8_t type, uint16_t flags, uint8_t decimals, bool field_list, uint64_t defvalue_length, char *defvalue) { bool MySQL_Protocol::generate_pkt_field(bool send, void **ptr, unsigned int *len, uint8_t sequence_id, char *schema, char *table, char *org_table, char *name, char *org_name, uint16_t charset, uint32_t column_length, uint8_t type, uint16_t flags, uint8_t decimals, bool field_list, uint64_t defvalue_length, char *defvalue) { char *def=(char *)"def"; uint32_t def_strlen=strlen(def); char def_prefix; uint8_t def_len=mysql_encode_length(def_strlen, &def_prefix); uint32_t schema_strlen=strlen(schema); char schema_prefix; uint8_t schema_len=mysql_encode_length(schema_strlen, &schema_prefix); uint32_t table_strlen=strlen(table); char table_prefix; uint8_t table_len=mysql_encode_length(table_strlen, &table_prefix); uint32_t org_table_strlen=strlen(org_table); char org_table_prefix; uint8_t org_table_len=mysql_encode_length(org_table_strlen, &org_table_prefix); uint32_t name_strlen=strlen(name); char name_prefix; uint8_t name_len=mysql_encode_length(name_strlen, &name_prefix); uint32_t org_name_strlen=strlen(org_name); char org_name_prefix; uint8_t org_name_len=mysql_encode_length(org_name_strlen, &org_name_prefix); char defvalue_length_prefix; uint8_t defvalue_length_len=mysql_encode_length(defvalue_length, &defvalue_length_prefix); mysql_hdr myhdr; myhdr.pkt_id=sequence_id; myhdr.pkt_length = def_len + def_strlen + schema_len + schema_strlen + table_len + table_strlen + org_table_len + org_table_strlen + name_len + name_strlen + org_name_len + org_name_strlen + 1 // filler + sizeof(uint16_t) // charset + sizeof(uint32_t) // column_length + sizeof(uint8_t) // type + sizeof(uint16_t) // flags + sizeof(uint8_t) // decimals + 2; // filler if (field_list) { myhdr.pkt_length += defvalue_length_len + strlen(defvalue); } //else myhdr.pkt_length++; unsigned int size=myhdr.pkt_length+sizeof(mysql_hdr); unsigned char *_ptr=(unsigned char *)l_alloc(size); memcpy(_ptr, &myhdr, sizeof(mysql_hdr)); int l=sizeof(mysql_hdr); l+=write_encoded_length_and_string(_ptr+l, def_strlen, def_len, def_prefix, def); l+=write_encoded_length_and_string(_ptr+l, schema_strlen, schema_len, schema_prefix, schema); l+=write_encoded_length_and_string(_ptr+l, table_strlen, table_len, table_prefix, table); l+=write_encoded_length_and_string(_ptr+l, org_table_strlen, org_table_len, org_table_prefix, org_table); l+=write_encoded_length_and_string(_ptr+l, name_strlen, name_len, name_prefix, name); l+=write_encoded_length_and_string(_ptr+l, org_name_strlen, org_name_len, org_name_prefix, org_name); _ptr[l]=0x0c; l++; memcpy(_ptr+l,&charset,sizeof(uint16_t)); l+=sizeof(uint16_t); memcpy(_ptr+l,&column_length,sizeof(uint32_t)); l+=sizeof(uint32_t); _ptr[l]=type; l++; memcpy(_ptr+l,&flags,sizeof(uint16_t)); l+=sizeof(uint16_t); _ptr[l]=decimals; l++; _ptr[l]=0x00; l++; _ptr[l]=0x00; l++; if (field_list) { l+=write_encoded_length_and_string(_ptr+l, strlen(defvalue), defvalue_length_len, defvalue_length_prefix, defvalue); } //else _ptr[l]=0x00; //else fprintf(stderr,"current deflen=%d, defstrlen=%d, namelen=%d, namestrlen=%d, l=%d\n", def_len, def_strlen, name_len, name_strlen, l); if (send==true) { (*myds)->PSarrayOUT->add((void *)_ptr,size); } if (len) { *len=size; } if (ptr) { *ptr=(void *)_ptr; } #ifdef DEBUG if (dump_pkt) { __dump_pkt(__func__,_ptr,size); } #endif return true; } bool MySQL_Protocol::generate_pkt_row(bool send, void **ptr, unsigned int *len, uint8_t sequence_id, int colnums, unsigned long *fieldslen, char **fieldstxt) { int col=0; int rowlen=0; for (col=0; col<colnums; col++) { rowlen+=( fieldstxt[col] ? fieldslen[col]+mysql_encode_length(fieldslen[col],NULL) : 1 ); } mysql_hdr myhdr; myhdr.pkt_id=sequence_id; myhdr.pkt_length=rowlen; unsigned int size=myhdr.pkt_length+sizeof(mysql_hdr); unsigned char *_ptr=(unsigned char *)l_alloc(size); memcpy(_ptr, &myhdr, sizeof(mysql_hdr)); int l=sizeof(mysql_hdr); for (col=0; col<colnums; col++) { if (fieldstxt[col]) { char length_prefix; uint8_t length_len=mysql_encode_length(fieldslen[col], &length_prefix); l+=write_encoded_length_and_string(_ptr+l,fieldslen[col],length_len, length_prefix, fieldstxt[col]); } else { _ptr[l]=0xfb; l++; } } if (send==true) { (*myds)->PSarrayOUT->add((void *)_ptr,size); } if (len) { *len=size; } if (ptr) { *ptr=(void *)_ptr; } #ifdef DEBUG if (dump_pkt) { __dump_pkt(__func__,_ptr,size); } #endif return true; } uint8_t MySQL_Protocol::generate_pkt_row2(PtrSizeArray *PSarrayOut, unsigned int *len, uint8_t sequence_id, int colnums, unsigned long *fieldslen, char **fieldstxt) { int col=0; unsigned int rowlen=0; uint8_t pkt_sid=sequence_id; for (col=0; col<colnums; col++) { rowlen+=( fieldstxt[col] ? fieldslen[col]+mysql_encode_length(fieldslen[col],NULL) : 1 ); } PtrSize_t pkt; pkt.size=rowlen+sizeof(mysql_hdr); pkt.ptr=l_alloc(pkt.size); int l=sizeof(mysql_hdr); for (col=0; col<colnums; col++) { if (fieldstxt[col]) { char length_prefix; uint8_t length_len=mysql_encode_length(fieldslen[col], &length_prefix); l+=write_encoded_length_and_string((unsigned char *)pkt.ptr+l,fieldslen[col],length_len, length_prefix, fieldstxt[col]); } else { char *_ptr=(char *)pkt.ptr; _ptr[l]=0xfb; l++; } } if (pkt.size < (0xFFFFFF+sizeof(mysql_hdr))) { mysql_hdr myhdr; myhdr.pkt_id=pkt_sid; myhdr.pkt_length=rowlen; memcpy(pkt.ptr, &myhdr, sizeof(mysql_hdr)); PSarrayOut->add(pkt.ptr,pkt.size); } else { unsigned int left=pkt.size; unsigned int copied=0; while (left>=(0xFFFFFF+sizeof(mysql_hdr))) { PtrSize_t pkt2; pkt2.size=0xFFFFFF+sizeof(mysql_hdr); pkt2.ptr=l_alloc(pkt2.size); memcpy((char *)pkt2.ptr+sizeof(mysql_hdr), (char *)pkt.ptr+sizeof(mysql_hdr)+copied, 0xFFFFFF); mysql_hdr myhdr; myhdr.pkt_id=pkt_sid; pkt_sid++; myhdr.pkt_length=0xFFFFFF; memcpy(pkt2.ptr, &myhdr, sizeof(mysql_hdr)); PSarrayOut->add(pkt2.ptr,pkt2.size); copied+=0xFFFFFF; left-=0xFFFFFF; } PtrSize_t pkt2; pkt2.size=left; pkt2.ptr=l_alloc(pkt2.size); memcpy((char *)pkt2.ptr+sizeof(mysql_hdr), (char *)pkt.ptr+sizeof(mysql_hdr)+copied, left-sizeof(mysql_hdr)); mysql_hdr myhdr; myhdr.pkt_id=pkt_sid; myhdr.pkt_length=left-sizeof(mysql_hdr); memcpy(pkt2.ptr, &myhdr, sizeof(mysql_hdr)); PSarrayOut->add(pkt2.ptr,pkt2.size); } if (len) { *len=pkt.size+(pkt_sid-sequence_id)*sizeof(mysql_hdr); } if (pkt.size >= (0xFFFFFF+sizeof(mysql_hdr))) { l_free(pkt.size,pkt.ptr); } return pkt_sid; } bool MySQL_Protocol::generate_pkt_auth_switch_request(bool send, void **ptr, unsigned int *len) { proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 7, "Generating auth switch request pkt\n"); mysql_hdr myhdr; myhdr.pkt_id=1; myhdr.pkt_length=1 // fe + (strlen("mysql_native_password")+1) + 20 // scramble + 1; // 00 unsigned int size=myhdr.pkt_length+sizeof(mysql_hdr); unsigned char *_ptr=(unsigned char *)l_alloc0(size); memcpy(_ptr, &myhdr, sizeof(mysql_hdr)); int l; l=sizeof(mysql_hdr); _ptr[l]=0xfe; l++; //0xfe memcpy(_ptr+l,"mysql_native_password",strlen("mysql_native_password")); l+=strlen("mysql_native_password"); _ptr[l]=0x00; l++; memcpy(_ptr+l, (*myds)->myconn->scramble_buff+0, 20); l+=20; _ptr[l]=0x00; //l+=1; //0x00 if (send==true) { (*myds)->PSarrayOUT->add((void *)_ptr,size); (*myds)->DSS=STATE_SERVER_HANDSHAKE; (*myds)->sess->status=CONNECTING_CLIENT; } if (len) { *len=size; } if (ptr) { *ptr=(void *)_ptr; } #ifdef DEBUG if (dump_pkt) { __dump_pkt(__func__,_ptr,size); } #endif return true; } //bool MySQL_Protocol::generate_pkt_initial_handshake(MySQL_Data_Stream *myds, bool send, void **ptr, unsigned int *len) { bool MySQL_Protocol::generate_pkt_initial_handshake(bool send, void **ptr, unsigned int *len, uint32_t *_thread_id) { proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 7, "Generating handshake pkt\n"); mysql_hdr myhdr; myhdr.pkt_id=0; myhdr.pkt_length=sizeof(protocol_version) + (strlen(mysql_thread___server_version)+1) + sizeof(uint32_t) // thread_id + 8 // scramble1 + 1 // 0x00 //+ sizeof(glovars.server_capabilities) //+ sizeof(glovars.server_language) //+ sizeof(glovars.server_status) + sizeof(mysql_thread___server_capabilities) + sizeof(mysql_thread___default_charset) + sizeof(server_status) + 3 // unknown stuff + 10 // filler + 12 // scramble2 + 1 // 0x00 + (strlen("mysql_native_password")+1); unsigned int size=myhdr.pkt_length+sizeof(mysql_hdr); //mypkt->data=g_slice_alloc0(mypkt->length); //mypkt->data=l_alloc0(thrLD->sfp, mypkt->length); unsigned char *_ptr=(unsigned char *)l_alloc0(size); memcpy(_ptr, &myhdr, sizeof(mysql_hdr)); //Copy4B(_ptr, &myhdr); int l; l=sizeof(mysql_hdr); //srand(pthread_self()); //uint32_t thread_id=rand()%100000; uint32_t thread_id=__sync_fetch_and_add(&glovars.thread_id,1); if (_thread_id) *_thread_id=thread_id; //uint32_t thread_id=pthread_self(); rand_struct rand_st; //randominit(&rand_st,rand(),rand()); rand_st.max_value= 0x3FFFFFFFL; rand_st.max_value_dbl=0x3FFFFFFFL; rand_st.seed1=rand()%rand_st.max_value; rand_st.seed2=rand()%rand_st.max_value; memcpy(_ptr+l, &protocol_version, sizeof(protocol_version)); l+=sizeof(protocol_version); memcpy(_ptr+l, mysql_thread___server_version, strlen(mysql_thread___server_version)); l+=strlen(mysql_thread___server_version)+1; memcpy(_ptr+l, &thread_id, sizeof(uint32_t)); l+=sizeof(uint32_t); //#ifdef MARIADB_BASE_VERSION // proxy_create_random_string(myds->myconn->myconn.scramble_buff+0,8,(struct my_rnd_struct *)&rand_st); //#else proxy_create_random_string((*myds)->myconn->scramble_buff+0,8,(struct rand_struct *)&rand_st); //#endif int i; for (i=0;i<8;i++) { if ((*myds)->myconn->scramble_buff[i]==0) { (*myds)->myconn->scramble_buff[i]='a'; } } memcpy(_ptr+l, (*myds)->myconn->scramble_buff+0, 8); l+=8; _ptr[l]=0x00; l+=1; //0x00 if (mysql_thread___have_compress) { mysql_thread___server_capabilities |= CLIENT_COMPRESS; // FIXME: shouldn't be here //(*myds)->myconn->options.compression_min_length=50; } (*myds)->myconn->options.server_capabilities=mysql_thread___server_capabilities; memcpy(_ptr+l,&mysql_thread___server_capabilities, sizeof(mysql_thread___server_capabilities)); l+=sizeof(mysql_thread___server_capabilities); memcpy(_ptr+l,&mysql_thread___default_charset, sizeof(mysql_thread___default_charset)); l+=sizeof(mysql_thread___default_charset); memcpy(_ptr+l,&server_status, sizeof(server_status)); l+=sizeof(server_status); memcpy(_ptr+l,"\x0f\x80\x15",3); l+=3; for (i=0;i<10; i++) { _ptr[l]=0x00; l++; } //filler //create_random_string(mypkt->data+l,12,(struct my_rnd_struct *)&rand_st); l+=12; //#ifdef MARIADB_BASE_VERSION // proxy_create_random_string(myds->myconn->myconn.scramble_buff+8,12,(struct my_rnd_struct *)&rand_st); //#else proxy_create_random_string((*myds)->myconn->scramble_buff+8,12,(struct rand_struct *)&rand_st); //#endif //create_random_string(scramble_buf+8,12,&rand_st); for (i=8;i<20;i++) { if ((*myds)->myconn->scramble_buff[i]==0) { (*myds)->myconn->scramble_buff[i]='a'; } } memcpy(_ptr+l, (*myds)->myconn->scramble_buff+8, 12); l+=12; l+=1; //0x00 memcpy(_ptr+l,"mysql_native_password",strlen("mysql_native_password")); if (send==true) { (*myds)->PSarrayOUT->add((void *)_ptr,size); (*myds)->DSS=STATE_SERVER_HANDSHAKE; (*myds)->sess->status=CONNECTING_CLIENT; } if (len) { *len=size; } if (ptr) { *ptr=(void *)_ptr; } #ifdef DEBUG if (dump_pkt) { __dump_pkt(__func__,_ptr,size); } #endif return true; } //bool MySQL_Protocol::process_pkt_OK(MySQL_Data_Stream *myds, unsigned char *pkt, unsigned int len) { bool MySQL_Protocol::process_pkt_OK(unsigned char *pkt, unsigned int len) { if (len < 11) return false; mysql_hdr hdr; memcpy(&hdr,pkt,sizeof(mysql_hdr)); pkt += sizeof(mysql_hdr); if (*pkt) return false; if (len!=hdr.pkt_length+sizeof(mysql_hdr)) return false; //MYSQL &myc=(*myds)->myconn->myconn; uint64_t affected_rows; uint64_t insert_id; #ifdef DEBUG uint16_t warns; #endif /* DEBUG */ unsigned char msg[len]; unsigned int p=0; int rc; //field_count = (u_int)*pkt++; pkt++; p++; rc=mysql_decode_length(pkt,&affected_rows); pkt += rc; p+=rc; rc=mysql_decode_length(pkt,&insert_id); pkt += rc; p+=rc; prot_status=CPY2(pkt); pkt+=sizeof(uint16_t); p+=sizeof(uint16_t); #ifdef DEBUG warns=CPY2(pkt); #endif /* DEBUG */ pkt+=sizeof(uint16_t); p+=sizeof(uint16_t); pkt++; p++; if (len>p) { memcpy(msg,pkt,len-p); msg[len-p]=0; } else { msg[0]=0; } proxy_debug(PROXY_DEBUG_MYSQL_PROTOCOL,1,"OK Packet <affected_rows:%u insert_id:%u status:%u warns:%u msg:%s>\n", (uint32_t)affected_rows, (uint32_t)insert_id, (uint16_t)prot_status, (uint16_t)warns, msg); return true; } bool MySQL_Protocol::process_pkt_EOF(unsigned char *pkt, unsigned int len) { int ret; mysql_hdr hdr; unsigned char *payload; memcpy(&hdr,pkt,sizeof(mysql_hdr)); payload=pkt+sizeof(mysql_hdr); ret=pkt_end(payload, hdr.pkt_length, this); return ( ret==PKT_PARSED ? true : false ); } //bool MySQL_Protocol::process_pkt_COM_QUERY(MySQL_Data_Stream *myds, unsigned char *pkt, unsigned int len) { bool MySQL_Protocol::process_pkt_COM_QUERY(unsigned char *pkt, unsigned int len) { bool ret=false; unsigned int _len=len-sizeof(mysql_hdr)-1; unsigned char *query=(unsigned char *)l_alloc(_len+1); memcpy(query,pkt+1+sizeof(mysql_hdr),_len); query[_len]=0x00; //printf("%s\n",query); l_free(_len+1,query); ret=true; return ret; } bool MySQL_Protocol::process_pkt_auth_swich_response(unsigned char *pkt, unsigned int len) { bool ret=false; char *password=NULL; if (len!=sizeof(mysql_hdr)+20) { return ret; } mysql_hdr hdr; memcpy(&hdr,pkt,sizeof(mysql_hdr)); int default_hostgroup=-1; bool transaction_persistent; bool _ret_use_ssl=false; unsigned char pass[128]; memset(pass,0,128); pkt+=sizeof(mysql_hdr); memcpy(pass, pkt, 20); char reply[SHA_DIGEST_LENGTH+1]; reply[SHA_DIGEST_LENGTH]='\0'; password=GloMyAuth->lookup((char *)userinfo->username, USERNAME_FRONTEND, &_ret_use_ssl, &default_hostgroup, NULL, NULL, &transaction_persistent, NULL, NULL); // FIXME: add support for default schema and fast forward , issues #255 and #256 if (password==NULL) { ret=false; } else { // if (pass_len==0 && strlen(password)==0) { // ret=true; // } else { proxy_scramble(reply, (*myds)->myconn->scramble_buff, password); if (memcmp(reply, pass, SHA_DIGEST_LENGTH)==0) { ret=true; } // } // if (_ret_use_ssl==true) { // ret=false; // } } return ret; } bool MySQL_Protocol::process_pkt_COM_CHANGE_USER(unsigned char *pkt, unsigned int len) { // FIXME: very buggy function, it doesn't perform any real check bool ret=false; int cur=sizeof(mysql_hdr); unsigned char *user=NULL; char *password=NULL; char *db=NULL; mysql_hdr hdr; memcpy(&hdr,pkt,sizeof(mysql_hdr)); int default_hostgroup=-1; bool transaction_persistent; bool _ret_use_ssl=false; cur++; user=pkt+cur; cur+=strlen((const char *)user); cur++; unsigned char pass_len=pkt[cur]; cur++; unsigned char pass[128]; memset(pass,0,128); //pkt+=sizeof(mysql_hdr); memcpy(pass, pkt+cur, pass_len); char reply[SHA_DIGEST_LENGTH+1]; reply[SHA_DIGEST_LENGTH]='\0'; cur+=pass_len; db=(char *)pkt+cur; password=GloMyAuth->lookup((char *)user, USERNAME_FRONTEND, &_ret_use_ssl, &default_hostgroup, NULL, NULL, &transaction_persistent, NULL, NULL); // FIXME: add support for default schema and fast forward, see issue #255 and #256 (*myds)->sess->default_hostgroup=default_hostgroup; (*myds)->sess->transaction_persistent=transaction_persistent; if (password==NULL) { ret=false; } else { if (pass_len==0 && strlen(password)==0) { ret=true; } else { proxy_scramble(reply, (*myds)->myconn->scramble_buff, password); if (memcmp(reply, pass, SHA_DIGEST_LENGTH)==0) { ret=true; } } if (_ret_use_ssl==true) { // if we reached here, use_ssl is false , but _ret_use_ssl is true // it means that a client is required to use SSL , but it is not ret=false; } } if (userinfo->username) free(userinfo->username); if (userinfo->password) free(userinfo->password); if (ret==true) { //(*myds)->myconn->options.max_allowed_pkt=max_pkt; (*myds)->DSS=STATE_CLIENT_HANDSHAKE; userinfo->username=strdup((const char *)user); userinfo->password=strdup((const char *)password); if (db) userinfo->set_schemaname(db,strlen(db)); } else { // we always duplicate username and password, or crashes happen userinfo->username=strdup((const char *)user); /*if (pass_len) */ userinfo->password=strdup((const char *)""); } //if (password) free(password); if (password) l_free_string(password); return ret; } //bool MySQL_Protocol::process_pkt_handshake_response(MySQL_Data_Stream *myds, unsigned char *pkt, unsigned int len) { bool MySQL_Protocol::process_pkt_handshake_response(unsigned char *pkt, unsigned int len) { bool ret=false; uint8_t charset; uint32_t capabilities; uint32_t max_pkt; uint32_t pass_len; unsigned char *user=NULL; char *db=NULL; unsigned char pass[128]; char *password=NULL; bool use_ssl=false; bool _ret_use_ssl=false; memset(pass,0,128); #ifdef DEBUG unsigned char *_ptr=pkt; #endif mysql_hdr hdr; memcpy(&hdr,pkt,sizeof(mysql_hdr)); //Copy4B(&hdr,pkt); pkt += sizeof(mysql_hdr); capabilities = CPY4(pkt); pkt += sizeof(uint32_t); max_pkt = CPY4(pkt); pkt += sizeof(uint32_t); charset = *(uint8_t *)pkt; pkt += 24; if (len==sizeof(mysql_hdr)+32) { (*myds)->encrypted=true; use_ssl=true; } else { user = pkt; pkt += strlen((char *)user) + 1; pass_len = (capabilities & CLIENT_SECURE_CONNECTION ? *pkt++ : strlen((char *)pkt)); memcpy(pass, pkt, pass_len); pass[pass_len] = 0; pkt += pass_len; db = (capabilities & CLIENT_CONNECT_WITH_DB ? (char *)pkt : NULL); char reply[SHA_DIGEST_LENGTH+1]; reply[SHA_DIGEST_LENGTH]='\0'; int default_hostgroup=-1; char *default_schema=NULL; bool schema_locked; bool transaction_persistent; bool fast_forward; int max_connections; password=GloMyAuth->lookup((char *)user, USERNAME_FRONTEND, &_ret_use_ssl, &default_hostgroup, &default_schema, &schema_locked, &transaction_persistent, &fast_forward, &max_connections); //assert(default_hostgroup>=0); (*myds)->sess->default_hostgroup=default_hostgroup; (*myds)->sess->default_schema=default_schema; // just the pointer is passed (*myds)->sess->schema_locked=schema_locked; (*myds)->sess->transaction_persistent=transaction_persistent; (*myds)->sess->session_fast_forward=fast_forward; (*myds)->sess->user_max_connections=max_connections; if (password==NULL) { ret=false; } else { if (pass_len==0 && strlen(password)==0) { ret=true; } else { proxy_scramble(reply, (*myds)->myconn->scramble_buff, password); if (memcmp(reply, pass, SHA_DIGEST_LENGTH)==0) { ret=true; } } if (_ret_use_ssl==true) { // if we reached here, use_ssl is false , but _ret_use_ssl is true // it means that a client is required to use SSL , but it is not ret=false; } } } proxy_debug(PROXY_DEBUG_MYSQL_PROTOCOL,1,"Handshake (%s auth) <user:\"%s\" pass:\"%s\" scramble:\"%s\" db:\"%s\" max_pkt:%u>, capabilities:%u char:%u, use_ssl:%s\n", (capabilities & CLIENT_SECURE_CONNECTION ? "new" : "old"), user, password, pass, db, max_pkt, capabilities, charset, ((*myds)->encrypted ? "yes" : "no")); assert(sess); assert(sess->client_myds); MySQL_Connection *myconn=sess->client_myds->myconn; assert(myconn); myconn->set_charset(charset); // enable compression if (capabilities & CLIENT_COMPRESS) { if (myconn->options.server_capabilities & CLIENT_COMPRESS) { myconn->options.compression_min_length=50; //myconn->set_status_compression(true); // don't enable this here. It needs to be enabled after the OK is sent } } #ifdef DEBUG if (dump_pkt) { __dump_pkt(__func__,_ptr,len); } #endif if (use_ssl) return true; if (ret==true) { (*myds)->myconn->options.max_allowed_pkt=max_pkt; (*myds)->DSS=STATE_CLIENT_HANDSHAKE; userinfo->username=strdup((const char *)user); userinfo->password=strdup((const char *)password); if (db) userinfo->set_schemaname(db,strlen(db)); } else { // we always duplicate username and password, or crashes happen userinfo->username=strdup((const char *)user); if (pass_len) userinfo->password=strdup((const char *)""); } //if (password) free(password); if (password) l_free_string(password); //l_free(len,pkt); return ret; } MySQL_ResultSet::MySQL_ResultSet(MySQL_Protocol *_myprot, MYSQL_RES *_res, MYSQL *_my) { transfer_started=false; resultset_completed=false; myprot=_myprot; mysql=_my; myds=myprot->get_myds(); sid=myds->pkt_sid+1; PSarrayOUT = new PtrSizeArray(); result=_res; resultset_size=0; num_rows=0; num_fields=mysql_field_count(mysql); PtrSize_t pkt; // immediately generate the first set of packets // columns count myprot->generate_pkt_column_count(false,&pkt.ptr,&pkt.size,sid,num_fields); sid++; PSarrayOUT->add(pkt.ptr,pkt.size); resultset_size+=pkt.size; // columns description for (unsigned int i=0; i<num_fields; i++) { MYSQL_FIELD *field=mysql_fetch_field(result); myprot->generate_pkt_field(false,&pkt.ptr,&pkt.size,sid,field->db,field->table,field->org_table,field->name,field->org_name,field->charsetnr,field->length,field->type,field->flags,field->decimals,false,0,NULL); PSarrayOUT->add(pkt.ptr,pkt.size); resultset_size+=pkt.size; sid++; } // first EOF unsigned int nTrx=myds->sess->NumActiveTransactions(); uint16_t setStatus = (nTrx ? SERVER_STATUS_IN_TRANS : 0 ); if (myds->sess->autocommit) setStatus += SERVER_STATUS_AUTOCOMMIT; myprot->generate_pkt_EOF(false,&pkt.ptr,&pkt.size,sid,0,mysql->server_status|setStatus); sid++; PSarrayOUT->add(pkt.ptr,pkt.size); resultset_size+=pkt.size; } MySQL_ResultSet::~MySQL_ResultSet() { PtrSize_t pkt; if (PSarrayOUT) { while (PSarrayOUT->len) { PSarrayOUT->remove_index_fast(0,&pkt); l_free(pkt.size, pkt.ptr); } delete PSarrayOUT; } } unsigned int MySQL_ResultSet::add_row(MYSQL_ROW row) { unsigned long *lengths=mysql_fetch_lengths(result); unsigned int pkt_length; sid=myprot->generate_pkt_row2(PSarrayOUT, &pkt_length, sid, num_fields, lengths, row); sid++; resultset_size+=pkt_length; num_rows++; return pkt_length; } void MySQL_ResultSet::add_eof() { PtrSize_t pkt; unsigned int nTrx=myds->sess->NumActiveTransactions(); uint16_t setStatus = (nTrx ? SERVER_STATUS_IN_TRANS : 0 ); if (myds->sess->autocommit) setStatus += SERVER_STATUS_AUTOCOMMIT; myprot->generate_pkt_EOF(false,&pkt.ptr,&pkt.size,sid,0,mysql->server_status|setStatus); PSarrayOUT->add(pkt.ptr,pkt.size); sid++; resultset_size+=pkt.size; resultset_completed=true; } bool MySQL_ResultSet::get_resultset(PtrSizeArray *PSarrayFinal) { transfer_started=true; PSarrayFinal->copy_add(PSarrayOUT,0,PSarrayOUT->len); while (PSarrayOUT->len) PSarrayOUT->remove_index(PSarrayOUT->len-1,NULL); return resultset_completed; }
renecannao/proxysql
lib/MySQL_Protocol.cpp
C++
gpl-3.0
41,517
from django.contrib import admin from article.models import Article # Register your models here. admin.site.register(Article)
daimon99/pyer
my_blog/article/admin.py
Python
gpl-3.0
127
/**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL3 included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or (at your option) the GNU General ** Public license version 3 or any later version approved by the KDE Free ** Qt Foundation. The licenses are as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-2.0.html and ** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QFONTENGINE_FT_P_H #define QFONTENGINE_FT_P_H // // W A R N I N G // ------------- // // This file is not part of the Qt API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // #include "private/qfontengine_p.h" #ifndef QT_NO_FREETYPE #include <ft2build.h> #include FT_FREETYPE_H #ifndef Q_OS_WIN #include <unistd.h> #endif #include <qmutex.h> QT_BEGIN_NAMESPACE class QFontEngineFTRawFont; class QFontconfigDatabase; /* * This class represents one font file on disk (like Arial.ttf) and is shared between all the font engines * that show this font file (at different pixel sizes). */ class QFreetypeFace { public: void computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing, QFixed *scalableBitmapScaleFactor); QFontEngine::Properties properties() const; bool getSfntTable(uint tag, uchar *buffer, uint *length) const; static QFreetypeFace *getFace(const QFontEngine::FaceId &face_id, const QByteArray &fontData = QByteArray()); void release(const QFontEngine::FaceId &face_id); // locks the struct for usage. Any read/write operations require locking. void lock() { _lock.lock(); } void unlock() { _lock.unlock(); } FT_Face face; int xsize; // 26.6 int ysize; // 26.6 FT_Matrix matrix; FT_CharMap unicode_map; FT_CharMap symbol_map; enum { cmapCacheSize = 0x200 }; glyph_t cmapCache[cmapCacheSize]; int fsType() const; int getPointInOutline(glyph_t glyph, int flags, quint32 point, QFixed *xpos, QFixed *ypos, quint32 *nPoints); bool isScalableBitmap() const; static void addGlyphToPath(FT_Face face, FT_GlyphSlot g, const QFixedPoint &point, QPainterPath *path, FT_Fixed x_scale, FT_Fixed y_scale); static void addBitmapToPath(FT_GlyphSlot slot, const QFixedPoint &point, QPainterPath *path); private: friend class QFontEngineFT; friend class QtFreetypeData; friend struct QScopedPointerDeleter<QFreetypeFace>; QFreetypeFace() : _lock(QMutex::Recursive) {} ~QFreetypeFace() {} void cleanup(); QAtomicInt ref; QMutex _lock; QByteArray fontData; QFontEngine::Holder hbFace; }; // If this is exported this breaks compilation of the windows // plugin as qfontengine_ft_p.h/.cpp are also compiled there #ifndef Q_OS_WIN class Q_GUI_EXPORT QFontEngineFT : public QFontEngine #else class QFontEngineFT : public QFontEngine #endif { public: /* we don't cache glyphs that are too large anyway, so we can make this struct rather small */ struct Glyph { ~Glyph(); short linearAdvance; unsigned char width; unsigned char height; short x; short y; short advance; signed char format; uchar *data; }; struct GlyphInfo { int linearAdvance; unsigned short width; unsigned short height; short x; short y; short xOff; short yOff; }; struct GlyphAndSubPixelPosition { GlyphAndSubPixelPosition(glyph_t g, QFixed spp) : glyph(g), subPixelPosition(spp) {} bool operator==(const GlyphAndSubPixelPosition &other) const { return glyph == other.glyph && subPixelPosition == other.subPixelPosition; } glyph_t glyph; QFixed subPixelPosition; }; struct QGlyphSet { QGlyphSet(); ~QGlyphSet(); FT_Matrix transformationMatrix; bool outline_drawing; void removeGlyphFromCache(glyph_t index, QFixed subPixelPosition); void clear(); inline bool useFastGlyphData(glyph_t index, QFixed subPixelPosition) const { return (index < 256 && subPixelPosition == 0); } inline Glyph *getGlyph(glyph_t index, QFixed subPixelPosition = 0) const; void setGlyph(glyph_t index, QFixed spp, Glyph *glyph); inline bool isGlyphMissing(glyph_t index) const { return missing_glyphs.contains(index); } inline void setGlyphMissing(glyph_t index) const { missing_glyphs.insert(index); } private: mutable QHash<GlyphAndSubPixelPosition, Glyph *> glyph_data; // maps from glyph index to glyph data mutable QSet<glyph_t> missing_glyphs; mutable Glyph *fast_glyph_data[256]; // for fast lookup of glyphs < 256 mutable int fast_glyph_count; }; QFontEngine::FaceId faceId() const Q_DECL_OVERRIDE; QFontEngine::Properties properties() const Q_DECL_OVERRIDE; QFixed emSquareSize() const Q_DECL_OVERRIDE; bool supportsSubPixelPositions() const Q_DECL_OVERRIDE { return default_hint_style == HintLight || default_hint_style == HintNone; } bool getSfntTableData(uint tag, uchar *buffer, uint *length) const Q_DECL_OVERRIDE; int synthesized() const Q_DECL_OVERRIDE; QFixed ascent() const Q_DECL_OVERRIDE; QFixed capHeight() const Q_DECL_OVERRIDE; QFixed descent() const Q_DECL_OVERRIDE; QFixed leading() const Q_DECL_OVERRIDE; QFixed xHeight() const Q_DECL_OVERRIDE; QFixed averageCharWidth() const Q_DECL_OVERRIDE; qreal maxCharWidth() const Q_DECL_OVERRIDE; QFixed lineThickness() const Q_DECL_OVERRIDE; QFixed underlinePosition() const Q_DECL_OVERRIDE; glyph_t glyphIndex(uint ucs4) const Q_DECL_OVERRIDE; void doKerning(QGlyphLayout *, ShaperFlags) const Q_DECL_OVERRIDE; void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics) Q_DECL_OVERRIDE; bool supportsTransformation(const QTransform &transform) const Q_DECL_OVERRIDE; void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, QPainterPath *path, QTextItem::RenderFlags flags) Q_DECL_OVERRIDE; void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags) Q_DECL_OVERRIDE; bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const Q_DECL_OVERRIDE; glyph_metrics_t boundingBox(const QGlyphLayout &glyphs) Q_DECL_OVERRIDE; glyph_metrics_t boundingBox(glyph_t glyph) Q_DECL_OVERRIDE; glyph_metrics_t boundingBox(glyph_t glyph, const QTransform &matrix) Q_DECL_OVERRIDE; void recalcAdvances(QGlyphLayout *glyphs, ShaperFlags flags) const Q_DECL_OVERRIDE; QImage alphaMapForGlyph(glyph_t g) Q_DECL_OVERRIDE { return alphaMapForGlyph(g, 0); } QImage alphaMapForGlyph(glyph_t, QFixed) Q_DECL_OVERRIDE; QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE; QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE; QImage bitmapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE; glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, QFixed subPixelPosition, const QTransform &matrix, QFontEngine::GlyphFormat format) Q_DECL_OVERRIDE; QImage *lockedAlphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, GlyphFormat neededFormat, const QTransform &t, QPoint *offset) Q_DECL_OVERRIDE; bool hasInternalCaching() const Q_DECL_OVERRIDE { return cacheEnabled; } void unlockAlphaMapForGlyph() Q_DECL_OVERRIDE; void removeGlyphFromCache(glyph_t glyph) Q_DECL_OVERRIDE; int glyphMargin(QFontEngine::GlyphFormat /* format */) Q_DECL_OVERRIDE { return 0; } int glyphCount() const Q_DECL_OVERRIDE; enum Scaling { Scaled, Unscaled }; FT_Face lockFace(Scaling scale = Scaled) const; void unlockFace() const; FT_Face non_locked_face() const; inline bool drawAntialiased() const { return antialias; } inline bool invalid() const { return xsize == 0 && ysize == 0; } inline bool isBitmapFont() const { return defaultFormat == Format_Mono; } inline bool isScalableBitmap() const { return freetype->isScalableBitmap(); } inline Glyph *loadGlyph(uint glyph, QFixed subPixelPosition, GlyphFormat format = Format_None, bool fetchMetricsOnly = false, bool disableOutlineDrawing = false) const { return loadGlyph(cacheEnabled ? &defaultGlyphSet : 0, glyph, subPixelPosition, format, fetchMetricsOnly, disableOutlineDrawing); } Glyph *loadGlyph(QGlyphSet *set, uint glyph, QFixed subPixelPosition, GlyphFormat = Format_None, bool fetchMetricsOnly = false, bool disableOutlineDrawing = false) const; Glyph *loadGlyphFor(glyph_t g, QFixed subPixelPosition, GlyphFormat format, const QTransform &t, bool fetchBoundingBox = false, bool disableOutlineDrawing = false); QGlyphSet *loadGlyphSet(const QTransform &matrix); QFontEngineFT(const QFontDef &fd); virtual ~QFontEngineFT(); bool init(FaceId faceId, bool antiaalias, GlyphFormat defaultFormat = Format_None, const QByteArray &fontData = QByteArray()); bool init(FaceId faceId, bool antialias, GlyphFormat format, QFreetypeFace *freetypeFace); int getPointInOutline(glyph_t glyph, int flags, quint32 point, QFixed *xpos, QFixed *ypos, quint32 *nPoints) Q_DECL_OVERRIDE; void setQtDefaultHintStyle(QFont::HintingPreference hintingPreference); void setDefaultHintStyle(HintStyle style) Q_DECL_OVERRIDE; QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE; Qt::HANDLE handle() const Q_DECL_OVERRIDE; bool initFromFontEngine(const QFontEngineFT *fontEngine); HintStyle defaultHintStyle() const { return default_hint_style; } protected: QFreetypeFace *freetype; mutable int default_load_flags; HintStyle default_hint_style; bool antialias; bool transform; bool embolden; bool obliquen; SubpixelAntialiasingType subpixelType; int lcdFilterType; bool embeddedbitmap; bool cacheEnabled; bool forceAutoHint; private: friend class QFontEngineFTRawFont; friend class QFontconfigDatabase; friend class QBasicFontDatabase; friend class QCoreTextFontDatabase; friend class QFontEngineMultiFontConfig; int loadFlags(QGlyphSet *set, GlyphFormat format, int flags, bool &hsubpixel, int &vfactor) const; bool shouldUseDesignMetrics(ShaperFlags flags) const; QFixed scaledBitmapMetrics(QFixed m) const; glyph_metrics_t scaledBitmapMetrics(const glyph_metrics_t &m) const; GlyphFormat defaultFormat; FT_Matrix matrix; QList<QGlyphSet> transformedGlyphSets; mutable QGlyphSet defaultGlyphSet; QFontEngine::FaceId face_id; int xsize; int ysize; QFixed line_thickness; QFixed underline_position; FT_Size_Metrics metrics; mutable bool kerning_pairs_loaded; QFixed scalableBitmapScaleFactor; }; inline uint qHash(const QFontEngineFT::GlyphAndSubPixelPosition &g) { return (g.glyph << 8) | (g.subPixelPosition * 10).round().toInt(); } inline QFontEngineFT::Glyph *QFontEngineFT::QGlyphSet::getGlyph(glyph_t index, QFixed subPixelPosition) const { if (useFastGlyphData(index, subPixelPosition)) return fast_glyph_data[index]; return glyph_data.value(GlyphAndSubPixelPosition(index, subPixelPosition)); } extern FT_Library qt_getFreetype(); QT_END_NAMESPACE #endif // QT_NO_FREETYPE #endif // QFONTENGINE_FT_P_H
michaelgeschwill/DependencyChaos
deploy/Frameworks/QtGui.framework/Versions/5/Headers/5.8.0/QtGui/private/qfontengine_ft_p.h
C
gpl-3.0
13,532
# Formidable [![Build Status](https://secure.travis-ci.org/felixge/node-formidable.png?branch=master)](http://travis-ci.org/felixge/node-formidable) ## Purpose A node.js module for parsing form data, especially file uploads. ## Current status This module was developed for [Transloadit](http://transloadit.com/), a service focused on uploading and encoding images and videos. It has been battle-tested against hundreds of GB of file uploads from a large variety of clients and is considered production-ready. ## Features * Fast (~500mb/sec), non-buffering multipart parser * Automatically writing file uploads to disk * Low memory footprint * Graceful error handling * Very high test coverage ## Installation This is a low level package, and if you're using a high level framework such as Express, chances are it's already included in it. You can [read this discussion](http://stackoverflow.com/questions/11295554/how-to-disable-express-bodyparser-for-file-uploads-node-js) about how Formidable is integrated with Express. Via [npm](http://github.com/isaacs/npm): ``` npm install formidable@latest ``` Manually: ``` git clone git://github.com/felixge/node-formidable.git formidable vim my.js # var formidable = require('./formidable'); ``` Note: Formidable requires [gently](http://github.com/felixge/node-gently) to run the unit tests, but you won't need it for just using the library. ## Example Parse an incoming file upload. ```javascript var formidable = require('formidable'), http = require('http'), util = require('util'); http.createServer(function(req, res) { if (req.url == '/upload' && req.method.toLowerCase() == 'post') { // parse a file upload var form = new formidable.IncomingForm(); form.parse(req, function(err, fields, files) { res.writeHead(200, {'content-type': 'text/plain'}); res.write('received upload:\n\n'); res.end(util.inspect({fields: fields, files: files})); }); return; } // show a file upload form res.writeHead(200, {'content-type': 'text/html'}); res.end( '<form action="/upload" enctype="multipart/form-data" method="post">'+ '<input type="text" name="title"><br>'+ '<input type="file" name="upload" multiple="multiple"><br>'+ '<input type="submit" value="Upload">'+ '</form>' ); }).listen(8080); ``` ## API ### Formidable.IncomingForm ```javascript var form = new formidable.IncomingForm() ``` Creates a new incoming form. ```javascript form.encoding = 'utf-8'; ``` Sets encoding for incoming form fields. ```javascript form.uploadDir = "/my/dir"; ``` Sets the directory for placing file uploads in. You can move them later on using `fs.rename()`. The default is `os.tmpDir()`. ```javascript form.keepExtensions = false; ``` If you want the files written to `form.uploadDir` to include the extensions of the original files, set this property to `true`. ```javascript form.type ``` Either 'multipart' or 'urlencoded' depending on the incoming request. ```javascript form.maxFieldsSize = 2 * 1024 * 1024; ``` Limits the amount of memory all fields together (except files) can allocate in bytes. If this value is exceeded, an `'error'` event is emitted. The default size is 2MB. ```javascript form.maxFields = 1000; ``` Limits the number of fields that the querystring parser will decode. Defaults to 1000 (0 for unlimited). ```javascript form.hash = false; ``` If you want checksums calculated for incoming files, set this to either `'sha1'` or `'md5'`. ```javascript form.multiples = false; ``` If this option is enabled, when you call `form.parse`, the `files` argument will contain arrays of files for inputs which submit multiple files using the HTML5 `multiple` attribute. ```javascript form.bytesReceived ``` The amount of bytes received for this form so far. ```javascript form.bytesExpected ``` The expected number of bytes in this form. ```javascript form.parse(request, [cb]); ``` Parses an incoming node.js `request` containing form data. If `cb` is provided, all fields and files are collected and passed to the callback: ```javascript form.parse(req, function(err, fields, files) { // ... }); form.onPart(part); ``` You may overwrite this method if you are interested in directly accessing the multipart stream. Doing so will disable any `'field'` / `'file'` events processing which would occur otherwise, making you fully responsible for handling the processing. ```javascript form.onPart = function(part) { part.addListener('data', function() { // ... }); } ``` If you want to use formidable to only handle certain parts for you, you can do so: ```javascript form.onPart = function(part) { if (!part.filename) { // let formidable handle all non-file parts form.handlePart(part); } } ``` Check the code in this method for further inspiration. ### Formidable.File ```javascript file.size = 0 ``` The size of the uploaded file in bytes. If the file is still being uploaded (see `'fileBegin'` event), this property says how many bytes of the file have been written to disk yet. ```javascript file.path = null ``` The path this file is being written to. You can modify this in the `'fileBegin'` event in case you are unhappy with the way formidable generates a temporary path for your files. ```javascript file.name = null ``` The name this file had according to the uploading client. ```javascript file.type = null ``` The mime type of this file, according to the uploading client. ```javascript file.lastModifiedDate = null ``` A date object (or `null`) containing the time this file was last written to. Mostly here for compatibility with the [W3C File API Draft](http://dev.w3.org/2006/webapi/FileAPI/). ```javascript file.hash = null ``` If hash calculation was set, you can read the hex digest out of this var. #### Formidable.File#toJSON() This method returns a JSON-representation of the file, allowing you to `JSON.stringify()` the file which is useful for logging and responding to requests. ### Events #### 'progress' ```javascript form.on('progress', function(bytesReceived, bytesExpected) { }); ``` Emitted after each incoming chunk of data that has been parsed. Can be used to roll your own progress bar. #### 'field' ```javascript form.on('field', function(name, value) { }); ``` #### 'fileBegin' Emitted whenever a field / value pair has been received. ```javascript form.on('fileBegin', function(name, file) { }); ``` #### 'file' Emitted whenever a new file is detected in the upload stream. Use this even if you want to stream the file to somewhere else while buffering the upload on the file system. Emitted whenever a field / file pair has been received. `file` is an instance of `File`. ```javascript form.on('file', function(name, file) { }); ``` #### 'error' Emitted when there is an error processing the incoming form. A request that experiences an error is automatically paused, you will have to manually call `request.resume()` if you want the request to continue firing `'data'` events. ```javascript form.on('error', function(err) { }); ``` #### 'aborted' Emitted when the request was aborted by the user. Right now this can be due to a 'timeout' or 'close' event on the socket. After this event is emitted, an `error` event will follow. In the future there will be a separate 'timeout' event (needs a change in the node core). ```javascript form.on('aborted', function() { }); ``` ##### 'end' ```javascript form.on('end', function() { }); ``` Emitted when the entire request has been received, and all contained files have finished flushing to disk. This is a great place for you to send your response. ## Changelog ### v1.0.14 * Add failing hash tests. (Ben Trask) * Enable hash calculation again (Eugene Girshov) * Test for immediate data events (Tim Smart) * Re-arrange IncomingForm#parse (Tim Smart) ### v1.0.13 * Only update hash if update method exists (Sven Lito) * According to travis v0.10 needs to go quoted (Sven Lito) * Bumping build node versions (Sven Lito) * Additional fix for empty requests (Eugene Girshov) * Change the default to 1000, to match the new Node behaviour. (OrangeDog) * Add ability to control maxKeys in the querystring parser. (OrangeDog) * Adjust test case to work with node 0.9.x (Eugene Girshov) * Update package.json (Sven Lito) * Path adjustment according to eb4468b (Markus Ast) ### v1.0.12 * Emit error on aborted connections (Eugene Girshov) * Add support for empty requests (Eugene Girshov) * Fix name/filename handling in Content-Disposition (jesperp) * Tolerate malformed closing boundary in multipart (Eugene Girshov) * Ignore preamble in multipart messages (Eugene Girshov) * Add support for application/json (Mike Frey, Carlos Rodriguez) * Add support for Base64 encoding (Elmer Bulthuis) * Add File#toJSON (TJ Holowaychuk) * Remove support for Node.js 0.4 & 0.6 (Andrew Kelley) * Documentation improvements (Sven Lito, Andre Azevedo) * Add support for application/octet-stream (Ion Lupascu, Chris Scribner) * Use os.tmpDir() to get tmp directory (Andrew Kelley) * Improve package.json (Andrew Kelley, Sven Lito) * Fix benchmark script (Andrew Kelley) * Fix scope issue in incoming_forms (Sven Lito) * Fix file handle leak on error (OrangeDog) ### v1.0.11 * Calculate checksums for incoming files (sreuter) * Add definition parameters to "IncomingForm" as an argument (Math-) ### v1.0.10 * Make parts to be proper Streams (Matt Robenolt) ### v1.0.9 * Emit progress when content length header parsed (Tim Koschützki) * Fix Readme syntax due to GitHub changes (goob) * Replace references to old 'sys' module in Readme with 'util' (Peter Sugihara) ### v1.0.8 * Strip potentially unsafe characters when using `keepExtensions: true`. * Switch to utest / urun for testing * Add travis build ### v1.0.7 * Remove file from package that was causing problems when installing on windows. (#102) * Fix typos in Readme (Jason Davies). ### v1.0.6 * Do not default to the default to the field name for file uploads where filename="". ### v1.0.5 * Support filename="" in multipart parts * Explain unexpected end() errors in parser better **Note:** Starting with this version, formidable emits 'file' events for empty file input fields. Previously those were incorrectly emitted as regular file input fields with value = "". ### v1.0.4 * Detect a good default tmp directory regardless of platform. (#88) ### v1.0.3 * Fix problems with utf8 characters (#84) / semicolons in filenames (#58) * Small performance improvements * New test suite and fixture system ### v1.0.2 * Exclude node\_modules folder from git * Implement new `'aborted'` event * Fix files in example folder to work with recent node versions * Make gently a devDependency [See Commits](https://github.com/felixge/node-formidable/compare/v1.0.1...v1.0.2) ### v1.0.1 * Fix package.json to refer to proper main directory. (#68, Dean Landolt) [See Commits](https://github.com/felixge/node-formidable/compare/v1.0.0...v1.0.1) ### v1.0.0 * Add support for multipart boundaries that are quoted strings. (Jeff Craig) This marks the beginning of development on version 2.0 which will include several architectural improvements. [See Commits](https://github.com/felixge/node-formidable/compare/v0.9.11...v1.0.0) ### v0.9.11 * Emit `'progress'` event when receiving data, regardless of parsing it. (Tim Koschützki) * Use [W3C FileAPI Draft](http://dev.w3.org/2006/webapi/FileAPI/) properties for File class **Important:** The old property names of the File class will be removed in a future release. [See Commits](https://github.com/felixge/node-formidable/compare/v0.9.10...v0.9.11) ### Older releases These releases were done before starting to maintain the above Changelog: * [v0.9.10](https://github.com/felixge/node-formidable/compare/v0.9.9...v0.9.10) * [v0.9.9](https://github.com/felixge/node-formidable/compare/v0.9.8...v0.9.9) * [v0.9.8](https://github.com/felixge/node-formidable/compare/v0.9.7...v0.9.8) * [v0.9.7](https://github.com/felixge/node-formidable/compare/v0.9.6...v0.9.7) * [v0.9.6](https://github.com/felixge/node-formidable/compare/v0.9.5...v0.9.6) * [v0.9.5](https://github.com/felixge/node-formidable/compare/v0.9.4...v0.9.5) * [v0.9.4](https://github.com/felixge/node-formidable/compare/v0.9.3...v0.9.4) * [v0.9.3](https://github.com/felixge/node-formidable/compare/v0.9.2...v0.9.3) * [v0.9.2](https://github.com/felixge/node-formidable/compare/v0.9.1...v0.9.2) * [v0.9.1](https://github.com/felixge/node-formidable/compare/v0.9.0...v0.9.1) * [v0.9.0](https://github.com/felixge/node-formidable/compare/v0.8.0...v0.9.0) * [v0.9.0](https://github.com/felixge/node-formidable/compare/v0.8.0...v0.9.0) * [v0.9.0](https://github.com/felixge/node-formidable/compare/v0.8.0...v0.9.0) * [v0.9.0](https://github.com/felixge/node-formidable/compare/v0.8.0...v0.9.0) * [v0.9.0](https://github.com/felixge/node-formidable/compare/v0.8.0...v0.9.0) * [v0.9.0](https://github.com/felixge/node-formidable/compare/v0.8.0...v0.9.0) * [v0.9.0](https://github.com/felixge/node-formidable/compare/v0.8.0...v0.9.0) * [v0.9.0](https://github.com/felixge/node-formidable/compare/v0.8.0...v0.9.0) * [v0.1.0](https://github.com/felixge/node-formidable/commits/v0.1.0) ## License Formidable is licensed under the MIT license. ## Ports * [multipart-parser](http://github.com/FooBarWidget/multipart-parser): a C++ parser based on formidable ## Credits * [Ryan Dahl](http://twitter.com/ryah) for his work on [http-parser](http://github.com/ry/http-parser) which heavily inspired multipart_parser.js
tohshige/test
used12_1801_bak/node_modules/formidable/Readme.md
Markdown
gpl-3.0
13,997
/* Copyright (c) 2012-2013 Clint Banzhaf This file is part of "Meridian59 .NET". "Meridian59 .NET" 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. "Meridian59 .NET" 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 "Meridian59 .NET". If not, see http://www.gnu.org/licenses/. */ using System; using System.Text; using System.ComponentModel; using Meridian59.Common.Interfaces; using Meridian59.Common.Constants; using Meridian59.Drawing2D; namespace Meridian59.Data.Models { /// <summary> /// Data of GuildShield /// </summary> [Serializable] public class GuildShieldInfo : IByteSerializable, INotifyPropertyChanged, IClearable, IUpdatable<GuildShieldInfo> { #region Constants protected const byte WHITECOLOR = 9; protected const string DESIGNNOTAVAILABLE = "Design not available"; public const string PROPNAME_GUILDID = "GuildID"; public const string PROPNAME_GUILDNAME = "GuildName"; public const string PROPNAME_COLOR1 = "Color1"; public const string PROPNAME_COLOR2 = "Color2"; public const string PROPNAME_DESIGN = "Design"; public const string PROPNAME_SHIELDS = "Shields"; public const string PROPNAME_EXAMPLEMODEL = "ExampleModel"; #endregion #region INotifyPropertyChanged public event PropertyChangedEventHandler PropertyChanged; protected void RaisePropertyChanged(PropertyChangedEventArgs e) { if (PropertyChanged != null) PropertyChanged(this, e); } #endregion #region IByteSerializable public int ByteLength { get { return guildID.ByteLength + TypeSizes.SHORT + guildName.Length + TypeSizes.BYTE + TypeSizes.BYTE + TypeSizes.BYTE; } } public int WriteTo(byte[] Buffer, int StartIndex=0) { int cursor = StartIndex; cursor += guildID.WriteTo(Buffer, cursor); Array.Copy(BitConverter.GetBytes(Convert.ToUInt16(guildName.Length)), 0, Buffer, cursor, TypeSizes.SHORT); cursor += TypeSizes.SHORT; Array.Copy(Encoding.Default.GetBytes(guildName), 0, Buffer, cursor, guildName.Length); cursor += guildName.Length; Buffer[cursor] = color1; cursor += TypeSizes.BYTE; Buffer[cursor] = color2; cursor += TypeSizes.BYTE; Buffer[cursor] = design; cursor += TypeSizes.BYTE; return cursor - StartIndex; } public int ReadFrom(byte[] Buffer, int StartIndex = 0) { int cursor = StartIndex; guildID = new ObjectID(Buffer, cursor); cursor += guildID.ByteLength; ushort len = BitConverter.ToUInt16(Buffer, cursor); cursor += TypeSizes.SHORT; guildName = Encoding.Default.GetString(Buffer, cursor, len); cursor += len; color1 = Buffer[cursor]; cursor += TypeSizes.BYTE; color2 = Buffer[cursor]; cursor += TypeSizes.BYTE; design = Buffer[cursor]; cursor += TypeSizes.BYTE; return cursor - StartIndex; } public byte[] Bytes { get { byte[] returnValue = new byte[ByteLength]; WriteTo(returnValue); return returnValue; } } #endregion #region Fields protected ObjectID guildID; protected string guildName; protected byte color1; protected byte color2; protected byte design; protected ResourceIDBGF[] shields; protected ObjectBase exampleModel; #endregion #region Properties /// <summary> /// /// </summary> public ObjectID GuildID { get { return guildID; } set { // zero id indicates unclaimed shield // so reset name unless it's set to illegal shield string // for whatever reason the server always sends our own name in this case if (guildID.ID == 0 && (color1 != WHITECOLOR || color2 != WHITECOLOR)) GuildName = String.Empty; if (guildID != value) { guildID = value; RaisePropertyChanged(new PropertyChangedEventArgs(PROPNAME_GUILDID)); } } } /// <summary> /// /// </summary> public string GuildName { get { return guildName; } set { if (guildID.ID == 0 && (color1 != WHITECOLOR || color2 != WHITECOLOR)) { guildName = String.Empty; RaisePropertyChanged(new PropertyChangedEventArgs(PROPNAME_GUILDNAME)); } else if (guildName != value) { guildName = value; RaisePropertyChanged(new PropertyChangedEventArgs(PROPNAME_GUILDNAME)); } } } /// <summary> /// /// </summary> public byte Color1 { get { return color1; } set { if (value == WHITECOLOR && color2 == WHITECOLOR) GuildName = DESIGNNOTAVAILABLE; if (color1 != value) { color1 = value; exampleModel.ColorTranslation = ColorTransformation.GetGuildShieldColor(color1, color2); RaisePropertyChanged(new PropertyChangedEventArgs(PROPNAME_COLOR1)); } } } /// <summary> /// /// </summary> public byte Color2 { get { return color2; } set { if (color1 == WHITECOLOR && value == WHITECOLOR) GuildName = DESIGNNOTAVAILABLE; if (color2 != value) { color2 = value; exampleModel.ColorTranslation = ColorTransformation.GetGuildShieldColor(color1, color2); RaisePropertyChanged(new PropertyChangedEventArgs(PROPNAME_COLOR2)); } } } /// <summary> /// The selected design. /// Note: This is not zero based. First one is '1'. /// </summary> public byte Design { get { return design; } set { if (design != value) { design = value; // update examplemodel if we got a shield for this design if (design > 0 && shields != null && shields.Length > (design-1)) { exampleModel.OverlayFileRID = shields[design-1].Value; exampleModel.OverlayFile = shields[design-1].Name; exampleModel.Resource = shields[design-1].Resource; } RaisePropertyChanged(new PropertyChangedEventArgs(PROPNAME_DESIGN)); } } } /// <summary> /// Not contained in serialization. /// </summary> public ResourceIDBGF[] Shields { get { return shields; } set { if (shields != value) { shields = value; // update examplemodel if we got a shield for this design if (design > 0 && shields != null && shields.Length > (design - 1)) { exampleModel.OverlayFileRID = shields[design - 1].Value; exampleModel.OverlayFile = shields[design - 1].Name; exampleModel.Resource = shields[design - 1].Resource; } RaisePropertyChanged(new PropertyChangedEventArgs(PROPNAME_SHIELDS)); } } } /// <summary> /// /// </summary> public ObjectBase ExampleModel { get { return exampleModel; } set { if (exampleModel != value) { exampleModel = value; RaisePropertyChanged(new PropertyChangedEventArgs(PROPNAME_EXAMPLEMODEL)); } } } #endregion #region Constructors public GuildShieldInfo() { ExampleModel = new ObjectBase(); Clear(false); } public GuildShieldInfo(ObjectID GuildID, string GuildName, byte Color1, byte Color2, byte Design) { ExampleModel = new ObjectBase(); guildID = GuildID; guildName = GuildName; color1 = Color1; color2 = Color2; design = Design; } public GuildShieldInfo(byte[] Buffer, int StartIndex = 0) { ExampleModel = new ObjectBase(); ReadFrom(Buffer, StartIndex); } #endregion #region IClearable public void Clear(bool RaiseChangedEvent) { if (RaiseChangedEvent) { GuildID = new ObjectID(); GuildName = DESIGNNOTAVAILABLE; Color1 = WHITECOLOR; Color2 = WHITECOLOR; Design = 1; } else { guildID = new ObjectID(); guildName = DESIGNNOTAVAILABLE; color1 = WHITECOLOR; color2 = WHITECOLOR; design = 1; // update examplemodel exampleModel.ColorTranslation = ColorTransformation.GetGuildShieldColor(color1, color2); if (design > 0 && shields != null && shields.Length > (design - 1)) { exampleModel.OverlayFileRID = shields[design - 1].Value; exampleModel.OverlayFile = shields[design - 1].Name; exampleModel.Resource = shields[design - 1].Resource; } } } #endregion #region IUpdatable public void UpdateFromModel(GuildShieldInfo Model, bool RaiseChangedEvent) { if (RaiseChangedEvent) { GuildID = Model.GuildID; GuildName = Model.GuildName; Color1 = Model.Color1; Color2 = Model.Color2; Design = Model.Design; } else { guildID = Model.GuildID; guildName = Model.GuildName; color1 = Model.Color1; color2 = Model.Color2; design = Model.Design; // update examplemodel exampleModel.ColorTranslation = ColorTransformation.GetGuildShieldColor(color1, color2); if (design > 0 && shields != null && shields.Length > (design - 1)) { exampleModel.OverlayFileRID = shields[design - 1].Value; exampleModel.OverlayFile = shields[design - 1].Name; exampleModel.Resource = shields[design - 1].Resource; } } } #endregion } }
Daenks/meridian59-dotnet
Meridian59/Data/Models/GuildShieldInfo.cs
C#
gpl-3.0
12,244
/* -*- c++ -*- */ /* * Copyright 2005,2006,2010-2012,2014 Free Software Foundation, Inc. * * This file is part of GNU Radio * * SPDX-License-Identifier: GPL-3.0-or-later * */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "clock_recovery_mm_cc_impl.h" #include <gnuradio/io_signature.h> #include <gnuradio/math.h> #include <gnuradio/prefs.h> #include <iomanip> #include <sstream> #include <stdexcept> namespace gr { namespace digital { static const int FUDGE = 16; clock_recovery_mm_cc::sptr clock_recovery_mm_cc::make( float omega, float gain_omega, float mu, float gain_mu, float omega_relative_limit) { return gnuradio::get_initial_sptr(new clock_recovery_mm_cc_impl( omega, gain_omega, mu, gain_mu, omega_relative_limit)); } clock_recovery_mm_cc_impl::clock_recovery_mm_cc_impl( float omega, float gain_omega, float mu, float gain_mu, float omega_relative_limit) : block("clock_recovery_mm_cc", io_signature::make(1, 1, sizeof(gr_complex)), io_signature::make2(1, 2, sizeof(gr_complex), sizeof(float))), d_mu(mu), d_omega(omega), d_gain_omega(gain_omega), d_omega_relative_limit(omega_relative_limit), d_gain_mu(gain_mu), d_last_sample(0), d_interp(new filter::mmse_fir_interpolator_cc()), d_verbose(prefs::singleton()->get_bool("clock_recovery_mm_cc", "verbose", false)), d_p_2T(0), d_p_1T(0), d_p_0T(0), d_c_2T(0), d_c_1T(0), d_c_0T(0) { if (omega <= 0.0) throw std::out_of_range("clock rate must be > 0"); if (gain_mu < 0 || gain_omega < 0) throw std::out_of_range("Gains must be non-negative"); set_omega(omega); // also sets min and max omega set_inverse_relative_rate(omega); set_history(3); // ensure 2 extra input samples are available enable_update_rate(true); // fixes tag propagation through variable rate block } clock_recovery_mm_cc_impl::~clock_recovery_mm_cc_impl() { delete d_interp; } void clock_recovery_mm_cc_impl::forecast(int noutput_items, gr_vector_int& ninput_items_required) { unsigned ninputs = ninput_items_required.size(); for (unsigned i = 0; i < ninputs; i++) ninput_items_required[i] = (int)ceil((noutput_items * d_omega) + d_interp->ntaps()) + FUDGE; } void clock_recovery_mm_cc_impl::set_omega(float omega) { d_omega = omega; d_omega_mid = omega; d_omega_lim = d_omega_relative_limit * omega; } int clock_recovery_mm_cc_impl::general_work(int noutput_items, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, gr_vector_void_star& output_items) { const gr_complex* in = (const gr_complex*)input_items[0]; gr_complex* out = (gr_complex*)output_items[0]; bool write_foptr = output_items.size() >= 2; int ii = 0; // input index int oo = 0; // output index int ni = ninput_items[0] - d_interp->ntaps() - FUDGE; // don't use more input than this assert(d_mu >= 0.0); assert(d_mu <= 1.0); float mm_val = 0; gr_complex u, x, y; // This loop writes the error to the second output, if it exists if (write_foptr) { float* foptr = (float*)output_items[1]; while (oo < noutput_items && ii < ni) { d_p_2T = d_p_1T; d_p_1T = d_p_0T; d_p_0T = d_interp->interpolate(&in[ii], d_mu); d_c_2T = d_c_1T; d_c_1T = d_c_0T; d_c_0T = slicer_0deg(d_p_0T); fast_cc_multiply(x, d_c_0T - d_c_2T, conj(d_p_1T)); fast_cc_multiply(y, d_p_0T - d_p_2T, conj(d_c_1T)); u = y - x; mm_val = u.real(); out[oo++] = d_p_0T; // limit mm_val mm_val = gr::branchless_clip(mm_val, 1.0); d_omega = d_omega + d_gain_omega * mm_val; d_omega = d_omega_mid + gr::branchless_clip(d_omega - d_omega_mid, d_omega_lim); d_mu = d_mu + d_omega + d_gain_mu * mm_val; ii += (int)floor(d_mu); d_mu -= floor(d_mu); // write the error signal to the second output foptr[oo - 1] = mm_val; if (ii < 0) // clamp it. This should only happen with bogus input ii = 0; } } // This loop does not write to the second output (ugly, but faster) else { while (oo < noutput_items && ii < ni) { d_p_2T = d_p_1T; d_p_1T = d_p_0T; d_p_0T = d_interp->interpolate(&in[ii], d_mu); d_c_2T = d_c_1T; d_c_1T = d_c_0T; d_c_0T = slicer_0deg(d_p_0T); fast_cc_multiply(x, d_c_0T - d_c_2T, conj(d_p_1T)); fast_cc_multiply(y, d_p_0T - d_p_2T, conj(d_c_1T)); u = y - x; mm_val = u.real(); out[oo++] = d_p_0T; // limit mm_val mm_val = gr::branchless_clip(mm_val, 1.0); d_omega = d_omega + d_gain_omega * mm_val; d_omega = d_omega_mid + gr::branchless_clip(d_omega - d_omega_mid, d_omega_lim); d_mu = d_mu + d_omega + d_gain_mu * mm_val; ii += (int)floor(d_mu); d_mu -= floor(d_mu); if (d_verbose) { std::stringstream tmp; tmp << std::setprecision(8) << std::fixed << d_omega << "\t" << d_mu << std::endl; GR_LOG_INFO(d_logger, tmp.str()); } if (ii < 0) // clamp it. This should only happen with bogus input ii = 0; } } if (ii > 0) { assert(ii <= ninput_items[0]); consume_each(ii); } return oo; } } /* namespace digital */ } /* namespace gr */
skoslowski/gnuradio
gr-digital/lib/clock_recovery_mm_cc_impl.cc
C++
gpl-3.0
5,929
<?php /** * @author Oliver de Cramer (oliverde8 at gmail.com) * @copyright GNU GENERAL PUBLIC LICENSE * Version 3, 29 June 2007 * * PHP version 5.3 and above * * LICENSE: 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/}. */ namespace OWeb\utils; use \OWeb\types\NamedClass; abstract class Singleton extends NamedClass{ protected static $instances = array(); static public function getInstance() { $class = get_called_class(); if(!isset(self::$instances[$class])) { self::$instances[$class] = new $class(); } return self::$instances[$class]; } static protected function getInstanceNull(){ $class = get_called_class(); return isset(self::$instances[$class]) ? self::$instances[$class] : null; } static protected function setInstance(Singleton $object){ $class = get_called_class(); self::$instances[$class] = $object; } /** * Force a singleton object to be instanciated with the given instance * Use with care! */ static function forceInstance(Singleton $object, $class = null) { if($class == null) $class = get_class($object); if(!isset(self::$instances[$class])) { self::$instances[$class] = $object; } else { throw new \Exception(sprintf('Object of class %s was previously instanciated', $class)); } } final protected function __clone() {} } ?>
oliverde8/OWeb
v0.3/OWeb_src/OWeb/utils/Singleton.php
PHP
gpl-3.0
1,995
/* * This declarations of the PIC16F1768 MCU. * * This file is part of the GNU PIC library for SDCC, originally * created by Molnar Karoly <molnarkaroly@users.sf.net> 2016. * * This file is generated automatically by the cinc2h.pl, 2016-04-13 17:23:14 UTC. * * SDCC is licensed under the GNU Public license (GPL) v2. Note that * this license covers the code to the compiler and other executables, * but explicitly does not cover any code or objects generated by sdcc. * * For pic device libraries and header files which are derived from * Microchip header (.inc) and linker script (.lkr) files Microchip * requires that "The header files should state that they are only to be * used with authentic Microchip devices" which makes them incompatible * with the GPL. Pic device libraries and header files are located at * non-free/lib and non-free/include directories respectively. * Sdcc should be run with the --use-non-free command line option in * order to include non-free header files and libraries. * * See http://sdcc.sourceforge.net/ for the latest information on sdcc. */ #ifndef __PIC16F1768_H__ #define __PIC16F1768_H__ //============================================================================== // // Register Addresses // //============================================================================== #ifndef NO_ADDR_DEFINES #define INDF0_ADDR 0x0000 #define INDF1_ADDR 0x0001 #define PCL_ADDR 0x0002 #define STATUS_ADDR 0x0003 #define FSR0_ADDR 0x0004 #define FSR0L_ADDR 0x0004 #define FSR0H_ADDR 0x0005 #define FSR1_ADDR 0x0006 #define FSR1L_ADDR 0x0006 #define FSR1H_ADDR 0x0007 #define BSR_ADDR 0x0008 #define WREG_ADDR 0x0009 #define PCLATH_ADDR 0x000A #define INTCON_ADDR 0x000B #define PORTA_ADDR 0x000C #define PORTB_ADDR 0x000D #define PORTC_ADDR 0x000E #define PIR1_ADDR 0x0011 #define PIR2_ADDR 0x0012 #define PIR3_ADDR 0x0013 #define PIR4_ADDR 0x0014 #define TMR0_ADDR 0x0015 #define TMR1_ADDR 0x0016 #define TMR1L_ADDR 0x0016 #define TMR1H_ADDR 0x0017 #define T1CON_ADDR 0x0018 #define T1GCON_ADDR 0x0019 #define T2TMR_ADDR 0x001A #define TMR2_ADDR 0x001A #define PR2_ADDR 0x001B #define T2PR_ADDR 0x001B #define T2CON_ADDR 0x001C #define T2HLT_ADDR 0x001D #define T2CLKCON_ADDR 0x001E #define T2RST_ADDR 0x001F #define TRISA_ADDR 0x008C #define TRISB_ADDR 0x008D #define TRISC_ADDR 0x008E #define PIE1_ADDR 0x0091 #define PIE2_ADDR 0x0092 #define PIE3_ADDR 0x0093 #define PIE4_ADDR 0x0094 #define OPTION_REG_ADDR 0x0095 #define PCON_ADDR 0x0096 #define WDTCON_ADDR 0x0097 #define OSCTUNE_ADDR 0x0098 #define OSCCON_ADDR 0x0099 #define OSCSTAT_ADDR 0x009A #define ADRES_ADDR 0x009B #define ADRESL_ADDR 0x009B #define ADRESH_ADDR 0x009C #define ADCON0_ADDR 0x009D #define ADCON1_ADDR 0x009E #define ADCON2_ADDR 0x009F #define LATA_ADDR 0x010C #define LATB_ADDR 0x010D #define LATC_ADDR 0x010E #define CMOUT_ADDR 0x010F #define CM1CON0_ADDR 0x0110 #define CM1CON1_ADDR 0x0111 #define CM1NSEL_ADDR 0x0112 #define CM1PSEL_ADDR 0x0113 #define CM2CON0_ADDR 0x0114 #define CM2CON1_ADDR 0x0115 #define CM2NSEL_ADDR 0x0116 #define CM2PSEL_ADDR 0x0117 #define CM3CON0_ADDR 0x0118 #define CM3CON1_ADDR 0x0119 #define CM3NSEL_ADDR 0x011A #define CM3PSEL_ADDR 0x011B #define CM4CON0_ADDR 0x011C #define CM4CON1_ADDR 0x011D #define CM4NSEL_ADDR 0x011E #define CM4PSEL_ADDR 0x011F #define ANSELA_ADDR 0x018C #define ANSELB_ADDR 0x018D #define ANSELC_ADDR 0x018E #define PMADR_ADDR 0x0191 #define PMADRL_ADDR 0x0191 #define PMADRH_ADDR 0x0192 #define PMDAT_ADDR 0x0193 #define PMDATL_ADDR 0x0193 #define PMDATH_ADDR 0x0194 #define PMCON1_ADDR 0x0195 #define PMCON2_ADDR 0x0196 #define VREGCON_ADDR 0x0197 #define RC1REG_ADDR 0x0199 #define RCREG_ADDR 0x0199 #define RCREG1_ADDR 0x0199 #define TX1REG_ADDR 0x019A #define TXREG_ADDR 0x019A #define TXREG1_ADDR 0x019A #define SP1BRG_ADDR 0x019B #define SP1BRGL_ADDR 0x019B #define SPBRG_ADDR 0x019B #define SPBRG1_ADDR 0x019B #define SPBRGL_ADDR 0x019B #define SP1BRGH_ADDR 0x019C #define SPBRGH_ADDR 0x019C #define SPBRGH1_ADDR 0x019C #define RC1STA_ADDR 0x019D #define RCSTA_ADDR 0x019D #define RCSTA1_ADDR 0x019D #define TX1STA_ADDR 0x019E #define TXSTA_ADDR 0x019E #define TXSTA1_ADDR 0x019E #define BAUD1CON_ADDR 0x019F #define BAUDCON_ADDR 0x019F #define BAUDCON1_ADDR 0x019F #define BAUDCTL_ADDR 0x019F #define BAUDCTL1_ADDR 0x019F #define WPUA_ADDR 0x020C #define WPUB_ADDR 0x020D #define WPUC_ADDR 0x020E #define SSP1BUF_ADDR 0x0211 #define SSPBUF_ADDR 0x0211 #define SSP1ADD_ADDR 0x0212 #define SSPADD_ADDR 0x0212 #define SSP1MSK_ADDR 0x0213 #define SSPMSK_ADDR 0x0213 #define SSP1STAT_ADDR 0x0214 #define SSPSTAT_ADDR 0x0214 #define SSP1CON_ADDR 0x0215 #define SSP1CON1_ADDR 0x0215 #define SSPCON_ADDR 0x0215 #define SSPCON1_ADDR 0x0215 #define SSP1CON2_ADDR 0x0216 #define SSPCON2_ADDR 0x0216 #define SSP1CON3_ADDR 0x0217 #define SSPCON3_ADDR 0x0217 #define BORCON_ADDR 0x021D #define FVRCON_ADDR 0x021E #define ZCD1CON_ADDR 0x021F #define ODCONA_ADDR 0x028C #define ODCONB_ADDR 0x028D #define ODCONC_ADDR 0x028E #define CCPR1_ADDR 0x0291 #define CCPR1L_ADDR 0x0291 #define CCPR1H_ADDR 0x0292 #define CCP1CON_ADDR 0x0293 #define CCP1CAP_ADDR 0x0294 #define CCPR2_ADDR 0x0298 #define CCPR2L_ADDR 0x0298 #define CCPR2H_ADDR 0x0299 #define CCP2CON_ADDR 0x029A #define CCP2CAP_ADDR 0x029B #define CCPTMRS_ADDR 0x029E #define SLRCONA_ADDR 0x030C #define SLRCONB_ADDR 0x030D #define SLRCONC_ADDR 0x030E #define MD2CON0_ADDR 0x031B #define MD2CON1_ADDR 0x031C #define MD2SRC_ADDR 0x031D #define MD2CARL_ADDR 0x031E #define MD2CARH_ADDR 0x031F #define INLVLA_ADDR 0x038C #define INLVLB_ADDR 0x038D #define INLVLC_ADDR 0x038E #define IOCAP_ADDR 0x0391 #define IOCAN_ADDR 0x0392 #define IOCAF_ADDR 0x0393 #define IOCBP_ADDR 0x0394 #define IOCBN_ADDR 0x0395 #define IOCBF_ADDR 0x0396 #define IOCCP_ADDR 0x0397 #define IOCCN_ADDR 0x0398 #define IOCCF_ADDR 0x0399 #define MD1CON0_ADDR 0x039B #define MD1CON1_ADDR 0x039C #define MD1SRC_ADDR 0x039D #define MD1CARL_ADDR 0x039E #define MD1CARH_ADDR 0x039F #define HIDRVC_ADDR 0x040E #define T4TMR_ADDR 0x0413 #define TMR4_ADDR 0x0413 #define PR4_ADDR 0x0414 #define T4PR_ADDR 0x0414 #define T4CON_ADDR 0x0415 #define T4HLT_ADDR 0x0416 #define T4CLKCON_ADDR 0x0417 #define T4RST_ADDR 0x0418 #define T6TMR_ADDR 0x041A #define TMR6_ADDR 0x041A #define PR6_ADDR 0x041B #define T6PR_ADDR 0x041B #define T6CON_ADDR 0x041C #define T6HLT_ADDR 0x041D #define T6CLKCON_ADDR 0x041E #define T6RST_ADDR 0x041F #define TMR3_ADDR 0x0493 #define TMR3L_ADDR 0x0493 #define TMR3H_ADDR 0x0494 #define T3CON_ADDR 0x0495 #define T3GCON_ADDR 0x0496 #define TMR5_ADDR 0x049A #define TMR5L_ADDR 0x049A #define TMR5H_ADDR 0x049B #define T5CON_ADDR 0x049C #define T5GCON_ADDR 0x049D #define OPA1NCHS_ADDR 0x050F #define OPA1PCHS_ADDR 0x0510 #define OPA1CON_ADDR 0x0511 #define OPA1ORS_ADDR 0x0512 #define OPA2NCHS_ADDR 0x0513 #define OPA2PCHS_ADDR 0x0514 #define OPA2CON_ADDR 0x0515 #define OPA2ORS_ADDR 0x0516 #define DACLD_ADDR 0x0590 #define DAC1CON0_ADDR 0x0591 #define DAC1CON1_ADDR 0x0592 #define DAC1REF_ADDR 0x0592 #define DAC1REFL_ADDR 0x0592 #define DAC1CON2_ADDR 0x0593 #define DAC1REFH_ADDR 0x0593 #define DAC2CON0_ADDR 0x0594 #define DAC2CON1_ADDR 0x0595 #define DAC2REF_ADDR 0x0595 #define DAC2REFL_ADDR 0x0595 #define DAC2CON2_ADDR 0x0596 #define DAC2REFH_ADDR 0x0596 #define DAC3CON0_ADDR 0x0597 #define DAC3CON1_ADDR 0x0598 #define DAC3REF_ADDR 0x0598 #define DAC4CON0_ADDR 0x0599 #define DAC4CON1_ADDR 0x059A #define DAC4REF_ADDR 0x059A #define PWM3DCL_ADDR 0x0617 #define PWM3DCH_ADDR 0x0618 #define PWM3CON_ADDR 0x0619 #define PWM4DCL_ADDR 0x061A #define PWM4DCH_ADDR 0x061B #define PWM4CON_ADDR 0x061C #define COG1PHR_ADDR 0x068D #define COG1PHF_ADDR 0x068E #define COG1BLKR_ADDR 0x068F #define COG1BLKF_ADDR 0x0690 #define COG1DBR_ADDR 0x0691 #define COG1DBF_ADDR 0x0692 #define COG1CON0_ADDR 0x0693 #define COG1CON1_ADDR 0x0694 #define COG1RIS0_ADDR 0x0695 #define COG1RIS1_ADDR 0x0696 #define COG1RSIM0_ADDR 0x0697 #define COG1RSIM1_ADDR 0x0698 #define COG1FIS0_ADDR 0x0699 #define COG1FIS1_ADDR 0x069A #define COG1FSIM0_ADDR 0x069B #define COG1FSIM1_ADDR 0x069C #define COG1ASD0_ADDR 0x069D #define COG1ASD1_ADDR 0x069E #define COG1STR_ADDR 0x069F #define COG2PHR_ADDR 0x070D #define COG2PHF_ADDR 0x070E #define COG2BLKR_ADDR 0x070F #define COG2BLKF_ADDR 0x0710 #define COG2DBR_ADDR 0x0711 #define COG2DBF_ADDR 0x0712 #define COG2CON0_ADDR 0x0713 #define COG2CON1_ADDR 0x0714 #define COG2RIS0_ADDR 0x0715 #define COG2RIS1_ADDR 0x0716 #define COG2RSIM0_ADDR 0x0717 #define COG2RSIM1_ADDR 0x0718 #define COG2FIS0_ADDR 0x0719 #define COG2FIS1_ADDR 0x071A #define COG2FSIM0_ADDR 0x071B #define COG2FSIM1_ADDR 0x071C #define COG2ASD0_ADDR 0x071D #define COG2ASD1_ADDR 0x071E #define COG2STR_ADDR 0x071F #define PRG1RTSS_ADDR 0x0794 #define PRG1FTSS_ADDR 0x0795 #define PRG1INS_ADDR 0x0796 #define PRG1CON0_ADDR 0x0797 #define PRG1CON1_ADDR 0x0798 #define PRG1CON2_ADDR 0x0799 #define PRG2RTSS_ADDR 0x079A #define PRG2FTSS_ADDR 0x079B #define PRG2INS_ADDR 0x079C #define PRG2CON0_ADDR 0x079D #define PRG2CON1_ADDR 0x079E #define PRG2CON2_ADDR 0x079F #define PWMEN_ADDR 0x0D8E #define PWMLD_ADDR 0x0D8F #define PWMOUT_ADDR 0x0D90 #define PWM5PH_ADDR 0x0D91 #define PWM5PHL_ADDR 0x0D91 #define PWM5PHH_ADDR 0x0D92 #define PWM5DC_ADDR 0x0D93 #define PWM5DCL_ADDR 0x0D93 #define PWM5DCH_ADDR 0x0D94 #define PWM5PR_ADDR 0x0D95 #define PWM5PRL_ADDR 0x0D95 #define PWM5PRH_ADDR 0x0D96 #define PWM5OF_ADDR 0x0D97 #define PWM5OFL_ADDR 0x0D97 #define PWM5OFH_ADDR 0x0D98 #define PWM5TMR_ADDR 0x0D99 #define PWM5TMRL_ADDR 0x0D99 #define PWM5TMRH_ADDR 0x0D9A #define PWM5CON_ADDR 0x0D9B #define PWM5INTCON_ADDR 0x0D9C #define PWM5INTE_ADDR 0x0D9C #define PWM5INTF_ADDR 0x0D9D #define PWM5INTFLG_ADDR 0x0D9D #define PWM5CLKCON_ADDR 0x0D9E #define PWM5LDCON_ADDR 0x0D9F #define PWM5OFCON_ADDR 0x0DA0 #define PWM6PH_ADDR 0x0DA1 #define PWM6PHL_ADDR 0x0DA1 #define PWM6PHH_ADDR 0x0DA2 #define PWM6DC_ADDR 0x0DA3 #define PWM6DCL_ADDR 0x0DA3 #define PWM6DCH_ADDR 0x0DA4 #define PWM6PR_ADDR 0x0DA5 #define PWM6PRL_ADDR 0x0DA5 #define PWM6PRH_ADDR 0x0DA6 #define PWM6OF_ADDR 0x0DA7 #define PWM6OFL_ADDR 0x0DA7 #define PWM6OFH_ADDR 0x0DA8 #define PWM6TMR_ADDR 0x0DA9 #define PWM6TMRL_ADDR 0x0DA9 #define PWM6TMRH_ADDR 0x0DAA #define PWM6CON_ADDR 0x0DAB #define PWM6INTCON_ADDR 0x0DAC #define PWM6INTE_ADDR 0x0DAC #define PWM6INTF_ADDR 0x0DAD #define PWM6INTFLG_ADDR 0x0DAD #define PWM6CLKCON_ADDR 0x0DAE #define PWM6LDCON_ADDR 0x0DAF #define PWM6OFCON_ADDR 0x0DB0 #define PPSLOCK_ADDR 0x0E0F #define INTPPS_ADDR 0x0E10 #define T0CKIPPS_ADDR 0x0E11 #define T1CKIPPS_ADDR 0x0E12 #define T1GPPS_ADDR 0x0E13 #define CCP1PPS_ADDR 0x0E14 #define CCP2PPS_ADDR 0x0E15 #define COG1INPPS_ADDR 0x0E16 #define COG2INPPS_ADDR 0x0E17 #define T2CKIPPS_ADDR 0x0E19 #define T3CKIPPS_ADDR 0x0E1A #define T3GPPS_ADDR 0x0E1B #define T4CKIPPS_ADDR 0x0E1C #define T5CKIPPS_ADDR 0x0E1D #define T5GPPS_ADDR 0x0E1E #define T6CKIPPS_ADDR 0x0E1F #define SSPCLKPPS_ADDR 0x0E20 #define SSPDATPPS_ADDR 0x0E21 #define SSPSSPPS_ADDR 0x0E22 #define RXPPS_ADDR 0x0E24 #define CKPPS_ADDR 0x0E25 #define CLCIN0PPS_ADDR 0x0E28 #define CLCIN1PPS_ADDR 0x0E29 #define CLCIN2PPS_ADDR 0x0E2A #define CLCIN3PPS_ADDR 0x0E2B #define PRG1RPPS_ADDR 0x0E2C #define PRG1FPPS_ADDR 0x0E2D #define PRG2RPPS_ADDR 0x0E2E #define PRG2FPPS_ADDR 0x0E2F #define MD1CHPPS_ADDR 0x0E30 #define MD1CLPPS_ADDR 0x0E31 #define MD1MODPPS_ADDR 0x0E32 #define MD2CHPPS_ADDR 0x0E33 #define MD2CLPPS_ADDR 0x0E34 #define MD2MODPPS_ADDR 0x0E35 #define RA0PPS_ADDR 0x0E90 #define RA1PPS_ADDR 0x0E91 #define RA2PPS_ADDR 0x0E92 #define RA4PPS_ADDR 0x0E94 #define RA5PPS_ADDR 0x0E95 #define RB4PPS_ADDR 0x0E9C #define RB5PPS_ADDR 0x0E9D #define RB6PPS_ADDR 0x0E9E #define RB7PPS_ADDR 0x0E9F #define RC0PPS_ADDR 0x0EA0 #define RC1PPS_ADDR 0x0EA1 #define RC2PPS_ADDR 0x0EA2 #define RC3PPS_ADDR 0x0EA3 #define RC4PPS_ADDR 0x0EA4 #define RC5PPS_ADDR 0x0EA5 #define RC6PPS_ADDR 0x0EA6 #define RC7PPS_ADDR 0x0EA7 #define CLCDATA_ADDR 0x0F0F #define CLC1CON_ADDR 0x0F10 #define CLC1POL_ADDR 0x0F11 #define CLC1SEL0_ADDR 0x0F12 #define CLC1SEL1_ADDR 0x0F13 #define CLC1SEL2_ADDR 0x0F14 #define CLC1SEL3_ADDR 0x0F15 #define CLC1GLS0_ADDR 0x0F16 #define CLC1GLS1_ADDR 0x0F17 #define CLC1GLS2_ADDR 0x0F18 #define CLC1GLS3_ADDR 0x0F19 #define CLC2CON_ADDR 0x0F1A #define CLC2POL_ADDR 0x0F1B #define CLC2SEL0_ADDR 0x0F1C #define CLC2SEL1_ADDR 0x0F1D #define CLC2SEL2_ADDR 0x0F1E #define CLC2SEL3_ADDR 0x0F1F #define CLC2GLS0_ADDR 0x0F20 #define CLC2GLS1_ADDR 0x0F21 #define CLC2GLS2_ADDR 0x0F22 #define CLC2GLS3_ADDR 0x0F23 #define CLC3CON_ADDR 0x0F24 #define CLC3POL_ADDR 0x0F25 #define CLC3SEL0_ADDR 0x0F26 #define CLC3SEL1_ADDR 0x0F27 #define CLC3SEL2_ADDR 0x0F28 #define CLC3SEL3_ADDR 0x0F29 #define CLC3GLS0_ADDR 0x0F2A #define CLC3GLS1_ADDR 0x0F2B #define CLC3GLS2_ADDR 0x0F2C #define CLC3GLS3_ADDR 0x0F2D #define STATUS_SHAD_ADDR 0x0FE4 #define WREG_SHAD_ADDR 0x0FE5 #define BSR_SHAD_ADDR 0x0FE6 #define PCLATH_SHAD_ADDR 0x0FE7 #define FSR0L_SHAD_ADDR 0x0FE8 #define FSR0H_SHAD_ADDR 0x0FE9 #define FSR1L_SHAD_ADDR 0x0FEA #define FSR1H_SHAD_ADDR 0x0FEB #define STKPTR_ADDR 0x0FED #define TOSL_ADDR 0x0FEE #define TOSH_ADDR 0x0FEF #endif // #ifndef NO_ADDR_DEFINES //============================================================================== // // Register Definitions // //============================================================================== extern __at(0x0000) __sfr INDF0; extern __at(0x0001) __sfr INDF1; extern __at(0x0002) __sfr PCL; //============================================================================== // STATUS Bits extern __at(0x0003) __sfr STATUS; typedef struct { unsigned C : 1; unsigned DC : 1; unsigned Z : 1; unsigned NOT_PD : 1; unsigned NOT_TO : 1; unsigned : 1; unsigned : 1; unsigned : 1; } __STATUSbits_t; extern __at(0x0003) volatile __STATUSbits_t STATUSbits; #define _C 0x01 #define _DC 0x02 #define _Z 0x04 #define _NOT_PD 0x08 #define _NOT_TO 0x10 //============================================================================== extern __at(0x0004) __sfr FSR0; extern __at(0x0004) __sfr FSR0L; extern __at(0x0005) __sfr FSR0H; extern __at(0x0006) __sfr FSR1; extern __at(0x0006) __sfr FSR1L; extern __at(0x0007) __sfr FSR1H; //============================================================================== // BSR Bits extern __at(0x0008) __sfr BSR; typedef union { struct { unsigned BSR0 : 1; unsigned BSR1 : 1; unsigned BSR2 : 1; unsigned BSR3 : 1; unsigned BSR4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned BSR : 5; unsigned : 3; }; } __BSRbits_t; extern __at(0x0008) volatile __BSRbits_t BSRbits; #define _BSR0 0x01 #define _BSR1 0x02 #define _BSR2 0x04 #define _BSR3 0x08 #define _BSR4 0x10 //============================================================================== extern __at(0x0009) __sfr WREG; extern __at(0x000A) __sfr PCLATH; //============================================================================== // INTCON Bits extern __at(0x000B) __sfr INTCON; typedef union { struct { unsigned IOCIF : 1; unsigned INTF : 1; unsigned TMR0IF : 1; unsigned IOCIE : 1; unsigned INTE : 1; unsigned TMR0IE : 1; unsigned PEIE : 1; unsigned GIE : 1; }; struct { unsigned : 1; unsigned : 1; unsigned T0IF : 1; unsigned : 1; unsigned : 1; unsigned T0IE : 1; unsigned : 1; unsigned : 1; }; } __INTCONbits_t; extern __at(0x000B) volatile __INTCONbits_t INTCONbits; #define _IOCIF 0x01 #define _INTF 0x02 #define _TMR0IF 0x04 #define _T0IF 0x04 #define _IOCIE 0x08 #define _INTE 0x10 #define _TMR0IE 0x20 #define _T0IE 0x20 #define _PEIE 0x40 #define _GIE 0x80 //============================================================================== //============================================================================== // PORTA Bits extern __at(0x000C) __sfr PORTA; typedef union { struct { unsigned RA0 : 1; unsigned RA1 : 1; unsigned RA2 : 1; unsigned RA3 : 1; unsigned RA4 : 1; unsigned RA5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RA : 6; unsigned : 2; }; } __PORTAbits_t; extern __at(0x000C) volatile __PORTAbits_t PORTAbits; #define _RA0 0x01 #define _RA1 0x02 #define _RA2 0x04 #define _RA3 0x08 #define _RA4 0x10 #define _RA5 0x20 //============================================================================== //============================================================================== // PORTB Bits extern __at(0x000D) __sfr PORTB; typedef struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned RB4 : 1; unsigned RB5 : 1; unsigned RB6 : 1; unsigned RB7 : 1; } __PORTBbits_t; extern __at(0x000D) volatile __PORTBbits_t PORTBbits; #define _RB4 0x10 #define _RB5 0x20 #define _RB6 0x40 #define _RB7 0x80 //============================================================================== //============================================================================== // PORTC Bits extern __at(0x000E) __sfr PORTC; typedef struct { unsigned RC0 : 1; unsigned RC1 : 1; unsigned RC2 : 1; unsigned RC3 : 1; unsigned RC4 : 1; unsigned RC5 : 1; unsigned RC6 : 1; unsigned RC7 : 1; } __PORTCbits_t; extern __at(0x000E) volatile __PORTCbits_t PORTCbits; #define _RC0 0x01 #define _RC1 0x02 #define _RC2 0x04 #define _RC3 0x08 #define _RC4 0x10 #define _RC5 0x20 #define _RC6 0x40 #define _RC7 0x80 //============================================================================== //============================================================================== // PIR1 Bits extern __at(0x0011) __sfr PIR1; typedef union { struct { unsigned TMR1IF : 1; unsigned TMR2IF : 1; unsigned CCP1IF : 1; unsigned SSP1IF : 1; unsigned TXIF : 1; unsigned RCIF : 1; unsigned ADIF : 1; unsigned TMR1GIF : 1; }; struct { unsigned : 1; unsigned : 1; unsigned CCPIF : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; } __PIR1bits_t; extern __at(0x0011) volatile __PIR1bits_t PIR1bits; #define _TMR1IF 0x01 #define _TMR2IF 0x02 #define _CCP1IF 0x04 #define _CCPIF 0x04 #define _SSP1IF 0x08 #define _TXIF 0x10 #define _RCIF 0x20 #define _ADIF 0x40 #define _TMR1GIF 0x80 //============================================================================== //============================================================================== // PIR2 Bits extern __at(0x0012) __sfr PIR2; typedef struct { unsigned CCP2IF : 1; unsigned C3IF : 1; unsigned C4IF : 1; unsigned BCL1IF : 1; unsigned : 1; unsigned C1IF : 1; unsigned C2IF : 1; unsigned OSFIF : 1; } __PIR2bits_t; extern __at(0x0012) volatile __PIR2bits_t PIR2bits; #define _CCP2IF 0x01 #define _C3IF 0x02 #define _C4IF 0x04 #define _BCL1IF 0x08 #define _C1IF 0x20 #define _C2IF 0x40 #define _OSFIF 0x80 //============================================================================== //============================================================================== // PIR3 Bits extern __at(0x0013) __sfr PIR3; typedef struct { unsigned CLC1IF : 1; unsigned CLC2IF : 1; unsigned CLC3IF : 1; unsigned COG2IF : 1; unsigned ZCDIF : 1; unsigned COG1IF : 1; unsigned PWM5IF : 1; unsigned PWM6IF : 1; } __PIR3bits_t; extern __at(0x0013) volatile __PIR3bits_t PIR3bits; #define _CLC1IF 0x01 #define _CLC2IF 0x02 #define _CLC3IF 0x04 #define _COG2IF 0x08 #define _ZCDIF 0x10 #define _COG1IF 0x20 #define _PWM5IF 0x40 #define _PWM6IF 0x80 //============================================================================== //============================================================================== // PIR4 Bits extern __at(0x0014) __sfr PIR4; typedef struct { unsigned TMR4IF : 1; unsigned TMR6IF : 1; unsigned TMR3IF : 1; unsigned TMR3GIF : 1; unsigned TMR5IF : 1; unsigned TMR5GIF : 1; unsigned : 1; unsigned : 1; } __PIR4bits_t; extern __at(0x0014) volatile __PIR4bits_t PIR4bits; #define _TMR4IF 0x01 #define _TMR6IF 0x02 #define _TMR3IF 0x04 #define _TMR3GIF 0x08 #define _TMR5IF 0x10 #define _TMR5GIF 0x20 //============================================================================== extern __at(0x0015) __sfr TMR0; extern __at(0x0016) __sfr TMR1; extern __at(0x0016) __sfr TMR1L; extern __at(0x0017) __sfr TMR1H; //============================================================================== // T1CON Bits extern __at(0x0018) __sfr T1CON; typedef union { struct { unsigned ON : 1; unsigned : 1; unsigned NOT_SYNC : 1; unsigned OSCEN : 1; unsigned CKPS0 : 1; unsigned CKPS1 : 1; unsigned CS0 : 1; unsigned CS1 : 1; }; struct { unsigned TMRON : 1; unsigned : 1; unsigned SYNC : 1; unsigned SOSCEN : 1; unsigned T1CKPS0 : 1; unsigned T1CKPS1 : 1; unsigned T1CS0 : 1; unsigned T1CS1 : 1; }; struct { unsigned TMR1ON : 1; unsigned : 1; unsigned NOT_T1SYNC : 1; unsigned T1OSCEN : 1; unsigned : 1; unsigned : 1; unsigned TMR1CS0 : 1; unsigned TMR1CS1 : 1; }; struct { unsigned T1ON : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned : 4; unsigned CKPS : 2; unsigned : 2; }; struct { unsigned : 4; unsigned T1CKPS : 2; unsigned : 2; }; struct { unsigned : 6; unsigned T1CS : 2; }; struct { unsigned : 6; unsigned CS : 2; }; struct { unsigned : 6; unsigned TMR1CS : 2; }; } __T1CONbits_t; extern __at(0x0018) volatile __T1CONbits_t T1CONbits; #define _T1CON_ON 0x01 #define _T1CON_TMRON 0x01 #define _T1CON_TMR1ON 0x01 #define _T1CON_T1ON 0x01 #define _T1CON_NOT_SYNC 0x04 #define _T1CON_SYNC 0x04 #define _T1CON_NOT_T1SYNC 0x04 #define _T1CON_OSCEN 0x08 #define _T1CON_SOSCEN 0x08 #define _T1CON_T1OSCEN 0x08 #define _T1CON_CKPS0 0x10 #define _T1CON_T1CKPS0 0x10 #define _T1CON_CKPS1 0x20 #define _T1CON_T1CKPS1 0x20 #define _T1CON_CS0 0x40 #define _T1CON_T1CS0 0x40 #define _T1CON_TMR1CS0 0x40 #define _T1CON_CS1 0x80 #define _T1CON_T1CS1 0x80 #define _T1CON_TMR1CS1 0x80 //============================================================================== //============================================================================== // T1GCON Bits extern __at(0x0019) __sfr T1GCON; typedef union { struct { unsigned GSS0 : 1; unsigned GSS1 : 1; unsigned GVAL : 1; unsigned GGO_NOT_DONE : 1; unsigned GSPM : 1; unsigned GTM : 1; unsigned GPOL : 1; unsigned GE : 1; }; struct { unsigned T1GSS0 : 1; unsigned T1GSS1 : 1; unsigned T1GVAL : 1; unsigned T1GGO_NOT_DONE : 1; unsigned T1GSPM : 1; unsigned T1GTM : 1; unsigned T1GPOL : 1; unsigned T1GE : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned TMR1GE : 1; }; struct { unsigned T1GSS : 2; unsigned : 6; }; struct { unsigned GSS : 2; unsigned : 6; }; } __T1GCONbits_t; extern __at(0x0019) volatile __T1GCONbits_t T1GCONbits; #define _GSS0 0x01 #define _T1GSS0 0x01 #define _GSS1 0x02 #define _T1GSS1 0x02 #define _GVAL 0x04 #define _T1GVAL 0x04 #define _GGO_NOT_DONE 0x08 #define _T1GGO_NOT_DONE 0x08 #define _GSPM 0x10 #define _T1GSPM 0x10 #define _GTM 0x20 #define _T1GTM 0x20 #define _GPOL 0x40 #define _T1GPOL 0x40 #define _GE 0x80 #define _T1GE 0x80 #define _TMR1GE 0x80 //============================================================================== extern __at(0x001A) __sfr T2TMR; extern __at(0x001A) __sfr TMR2; extern __at(0x001B) __sfr PR2; extern __at(0x001B) __sfr T2PR; //============================================================================== // T2CON Bits extern __at(0x001C) __sfr T2CON; typedef union { struct { unsigned OUTPS0 : 1; unsigned OUTPS1 : 1; unsigned OUTPS2 : 1; unsigned OUTPS3 : 1; unsigned CKPS0 : 1; unsigned CKPS1 : 1; unsigned CKPS2 : 1; unsigned ON : 1; }; struct { unsigned T2OUTPS0 : 1; unsigned T2OUTPS1 : 1; unsigned T2OUTPS2 : 1; unsigned T2OUTPS3 : 1; unsigned T2CKPS0 : 1; unsigned T2CKPS1 : 1; unsigned T2CKPS2 : 1; unsigned T2ON : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned TMR2ON : 1; }; struct { unsigned T2OUTPS : 4; unsigned : 4; }; struct { unsigned OUTPS : 4; unsigned : 4; }; struct { unsigned : 4; unsigned T2CKPS : 3; unsigned : 1; }; struct { unsigned : 4; unsigned CKPS : 3; unsigned : 1; }; } __T2CONbits_t; extern __at(0x001C) volatile __T2CONbits_t T2CONbits; #define _T2CON_OUTPS0 0x01 #define _T2CON_T2OUTPS0 0x01 #define _T2CON_OUTPS1 0x02 #define _T2CON_T2OUTPS1 0x02 #define _T2CON_OUTPS2 0x04 #define _T2CON_T2OUTPS2 0x04 #define _T2CON_OUTPS3 0x08 #define _T2CON_T2OUTPS3 0x08 #define _T2CON_CKPS0 0x10 #define _T2CON_T2CKPS0 0x10 #define _T2CON_CKPS1 0x20 #define _T2CON_T2CKPS1 0x20 #define _T2CON_CKPS2 0x40 #define _T2CON_T2CKPS2 0x40 #define _T2CON_ON 0x80 #define _T2CON_T2ON 0x80 #define _T2CON_TMR2ON 0x80 //============================================================================== //============================================================================== // T2HLT Bits extern __at(0x001D) __sfr T2HLT; typedef union { struct { unsigned MODE0 : 1; unsigned MODE1 : 1; unsigned MODE2 : 1; unsigned MODE3 : 1; unsigned MODE4 : 1; unsigned CKSYNC : 1; unsigned CKPOL : 1; unsigned PSYNC : 1; }; struct { unsigned T2MODE0 : 1; unsigned T2MODE1 : 1; unsigned T2MODE2 : 1; unsigned T2MODE3 : 1; unsigned T2MODE4 : 1; unsigned T2CKSYNC : 1; unsigned T2CKPOL : 1; unsigned T2PSYNC : 1; }; struct { unsigned T2MODE : 5; unsigned : 3; }; struct { unsigned MODE : 5; unsigned : 3; }; } __T2HLTbits_t; extern __at(0x001D) volatile __T2HLTbits_t T2HLTbits; #define _T2HLT_MODE0 0x01 #define _T2HLT_T2MODE0 0x01 #define _T2HLT_MODE1 0x02 #define _T2HLT_T2MODE1 0x02 #define _T2HLT_MODE2 0x04 #define _T2HLT_T2MODE2 0x04 #define _T2HLT_MODE3 0x08 #define _T2HLT_T2MODE3 0x08 #define _T2HLT_MODE4 0x10 #define _T2HLT_T2MODE4 0x10 #define _T2HLT_CKSYNC 0x20 #define _T2HLT_T2CKSYNC 0x20 #define _T2HLT_CKPOL 0x40 #define _T2HLT_T2CKPOL 0x40 #define _T2HLT_PSYNC 0x80 #define _T2HLT_T2PSYNC 0x80 //============================================================================== //============================================================================== // T2CLKCON Bits extern __at(0x001E) __sfr T2CLKCON; typedef union { struct { unsigned CS0 : 1; unsigned CS1 : 1; unsigned CS2 : 1; unsigned CS3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned T2CS0 : 1; unsigned T2CS1 : 1; unsigned T2CS2 : 1; unsigned T2CS3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned T2CS : 4; unsigned : 4; }; struct { unsigned CS : 4; unsigned : 4; }; } __T2CLKCONbits_t; extern __at(0x001E) volatile __T2CLKCONbits_t T2CLKCONbits; #define _T2CLKCON_CS0 0x01 #define _T2CLKCON_T2CS0 0x01 #define _T2CLKCON_CS1 0x02 #define _T2CLKCON_T2CS1 0x02 #define _T2CLKCON_CS2 0x04 #define _T2CLKCON_T2CS2 0x04 #define _T2CLKCON_CS3 0x08 #define _T2CLKCON_T2CS3 0x08 //============================================================================== //============================================================================== // T2RST Bits extern __at(0x001F) __sfr T2RST; typedef union { struct { unsigned RSEL0 : 1; unsigned RSEL1 : 1; unsigned RSEL2 : 1; unsigned RSEL3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned T2RSEL0 : 1; unsigned T2RSEL1 : 1; unsigned T2RSEL2 : 1; unsigned T2RSEL3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned T2RSEL : 4; unsigned : 4; }; struct { unsigned RSEL : 4; unsigned : 4; }; } __T2RSTbits_t; extern __at(0x001F) volatile __T2RSTbits_t T2RSTbits; #define _RSEL0 0x01 #define _T2RSEL0 0x01 #define _RSEL1 0x02 #define _T2RSEL1 0x02 #define _RSEL2 0x04 #define _T2RSEL2 0x04 #define _RSEL3 0x08 #define _T2RSEL3 0x08 //============================================================================== //============================================================================== // TRISA Bits extern __at(0x008C) __sfr TRISA; typedef struct { unsigned TRISA0 : 1; unsigned TRISA1 : 1; unsigned TRISA2 : 1; unsigned : 1; unsigned TRISA4 : 1; unsigned TRISA5 : 1; unsigned : 1; unsigned : 1; } __TRISAbits_t; extern __at(0x008C) volatile __TRISAbits_t TRISAbits; #define _TRISA0 0x01 #define _TRISA1 0x02 #define _TRISA2 0x04 #define _TRISA4 0x10 #define _TRISA5 0x20 //============================================================================== //============================================================================== // TRISB Bits extern __at(0x008D) __sfr TRISB; typedef struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned TRISB4 : 1; unsigned TRISB5 : 1; unsigned TRISB6 : 1; unsigned TRISB7 : 1; } __TRISBbits_t; extern __at(0x008D) volatile __TRISBbits_t TRISBbits; #define _TRISB4 0x10 #define _TRISB5 0x20 #define _TRISB6 0x40 #define _TRISB7 0x80 //============================================================================== //============================================================================== // TRISC Bits extern __at(0x008E) __sfr TRISC; typedef struct { unsigned TRISC0 : 1; unsigned TRISC1 : 1; unsigned TRISC2 : 1; unsigned TRISC3 : 1; unsigned TRISC4 : 1; unsigned TRISC5 : 1; unsigned TRISC6 : 1; unsigned TRISC7 : 1; } __TRISCbits_t; extern __at(0x008E) volatile __TRISCbits_t TRISCbits; #define _TRISC0 0x01 #define _TRISC1 0x02 #define _TRISC2 0x04 #define _TRISC3 0x08 #define _TRISC4 0x10 #define _TRISC5 0x20 #define _TRISC6 0x40 #define _TRISC7 0x80 //============================================================================== //============================================================================== // PIE1 Bits extern __at(0x0091) __sfr PIE1; typedef union { struct { unsigned TMR1IE : 1; unsigned TMR2IE : 1; unsigned CCP1IE : 1; unsigned SSP1IE : 1; unsigned TXIE : 1; unsigned RCIE : 1; unsigned ADIE : 1; unsigned TMR1GIE : 1; }; struct { unsigned : 1; unsigned : 1; unsigned CCPIE : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; } __PIE1bits_t; extern __at(0x0091) volatile __PIE1bits_t PIE1bits; #define _TMR1IE 0x01 #define _TMR2IE 0x02 #define _CCP1IE 0x04 #define _CCPIE 0x04 #define _SSP1IE 0x08 #define _TXIE 0x10 #define _RCIE 0x20 #define _ADIE 0x40 #define _TMR1GIE 0x80 //============================================================================== //============================================================================== // PIE2 Bits extern __at(0x0092) __sfr PIE2; typedef struct { unsigned CCP2IE : 1; unsigned C3IE : 1; unsigned C4IE : 1; unsigned BCL1IE : 1; unsigned : 1; unsigned C1IE : 1; unsigned C2IE : 1; unsigned OSFIE : 1; } __PIE2bits_t; extern __at(0x0092) volatile __PIE2bits_t PIE2bits; #define _CCP2IE 0x01 #define _C3IE 0x02 #define _C4IE 0x04 #define _BCL1IE 0x08 #define _C1IE 0x20 #define _C2IE 0x40 #define _OSFIE 0x80 //============================================================================== //============================================================================== // PIE3 Bits extern __at(0x0093) __sfr PIE3; typedef struct { unsigned CLC1IE : 1; unsigned CLC2IE : 1; unsigned CLC3IE : 1; unsigned COG2IE : 1; unsigned ZCDIE : 1; unsigned COGIE : 1; unsigned PWM5IE : 1; unsigned PWM6IE : 1; } __PIE3bits_t; extern __at(0x0093) volatile __PIE3bits_t PIE3bits; #define _CLC1IE 0x01 #define _CLC2IE 0x02 #define _CLC3IE 0x04 #define _COG2IE 0x08 #define _ZCDIE 0x10 #define _COGIE 0x20 #define _PWM5IE 0x40 #define _PWM6IE 0x80 //============================================================================== //============================================================================== // PIE4 Bits extern __at(0x0094) __sfr PIE4; typedef struct { unsigned TMR4IE : 1; unsigned TMR6IE : 1; unsigned TMR3IE : 1; unsigned TMR3GIE : 1; unsigned TMR5IE : 1; unsigned TMR5GIE : 1; unsigned : 1; unsigned : 1; } __PIE4bits_t; extern __at(0x0094) volatile __PIE4bits_t PIE4bits; #define _TMR4IE 0x01 #define _TMR6IE 0x02 #define _TMR3IE 0x04 #define _TMR3GIE 0x08 #define _TMR5IE 0x10 #define _TMR5GIE 0x20 //============================================================================== //============================================================================== // OPTION_REG Bits extern __at(0x0095) __sfr OPTION_REG; typedef union { struct { unsigned PS0 : 1; unsigned PS1 : 1; unsigned PS2 : 1; unsigned PSA : 1; unsigned TMR0SE : 1; unsigned TMR0CS : 1; unsigned INTEDG : 1; unsigned NOT_WPUEN : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned T0SE : 1; unsigned T0CS : 1; unsigned : 1; unsigned : 1; }; struct { unsigned PS : 3; unsigned : 5; }; } __OPTION_REGbits_t; extern __at(0x0095) volatile __OPTION_REGbits_t OPTION_REGbits; #define _PS0 0x01 #define _PS1 0x02 #define _PS2 0x04 #define _PSA 0x08 #define _TMR0SE 0x10 #define _T0SE 0x10 #define _TMR0CS 0x20 #define _T0CS 0x20 #define _INTEDG 0x40 #define _NOT_WPUEN 0x80 //============================================================================== //============================================================================== // PCON Bits extern __at(0x0096) __sfr PCON; typedef struct { unsigned NOT_BOR : 1; unsigned NOT_POR : 1; unsigned NOT_RI : 1; unsigned NOT_RMCLR : 1; unsigned NOT_RWDT : 1; unsigned : 1; unsigned STKUNF : 1; unsigned STKOVF : 1; } __PCONbits_t; extern __at(0x0096) volatile __PCONbits_t PCONbits; #define _NOT_BOR 0x01 #define _NOT_POR 0x02 #define _NOT_RI 0x04 #define _NOT_RMCLR 0x08 #define _NOT_RWDT 0x10 #define _STKUNF 0x40 #define _STKOVF 0x80 //============================================================================== //============================================================================== // WDTCON Bits extern __at(0x0097) __sfr WDTCON; typedef union { struct { unsigned SWDTEN : 1; unsigned WDTPS0 : 1; unsigned WDTPS1 : 1; unsigned WDTPS2 : 1; unsigned WDTPS3 : 1; unsigned WDTPS4 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned : 1; unsigned WDTPS : 5; unsigned : 2; }; } __WDTCONbits_t; extern __at(0x0097) volatile __WDTCONbits_t WDTCONbits; #define _SWDTEN 0x01 #define _WDTPS0 0x02 #define _WDTPS1 0x04 #define _WDTPS2 0x08 #define _WDTPS3 0x10 #define _WDTPS4 0x20 //============================================================================== //============================================================================== // OSCTUNE Bits extern __at(0x0098) __sfr OSCTUNE; typedef union { struct { unsigned TUN0 : 1; unsigned TUN1 : 1; unsigned TUN2 : 1; unsigned TUN3 : 1; unsigned TUN4 : 1; unsigned TUN5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned TUN : 6; unsigned : 2; }; } __OSCTUNEbits_t; extern __at(0x0098) volatile __OSCTUNEbits_t OSCTUNEbits; #define _TUN0 0x01 #define _TUN1 0x02 #define _TUN2 0x04 #define _TUN3 0x08 #define _TUN4 0x10 #define _TUN5 0x20 //============================================================================== //============================================================================== // OSCCON Bits extern __at(0x0099) __sfr OSCCON; typedef union { struct { unsigned SCS0 : 1; unsigned SCS1 : 1; unsigned : 1; unsigned IRCF0 : 1; unsigned IRCF1 : 1; unsigned IRCF2 : 1; unsigned IRCF3 : 1; unsigned SPLLEN : 1; }; struct { unsigned SCS : 2; unsigned : 6; }; struct { unsigned : 3; unsigned IRCF : 4; unsigned : 1; }; } __OSCCONbits_t; extern __at(0x0099) volatile __OSCCONbits_t OSCCONbits; #define _SCS0 0x01 #define _SCS1 0x02 #define _IRCF0 0x08 #define _IRCF1 0x10 #define _IRCF2 0x20 #define _IRCF3 0x40 #define _SPLLEN 0x80 //============================================================================== //============================================================================== // OSCSTAT Bits extern __at(0x009A) __sfr OSCSTAT; typedef struct { unsigned HFIOFS : 1; unsigned LFIOFR : 1; unsigned MFIOFR : 1; unsigned HFIOFL : 1; unsigned HFIOFR : 1; unsigned OSTS : 1; unsigned PLLR : 1; unsigned SOSCR : 1; } __OSCSTATbits_t; extern __at(0x009A) volatile __OSCSTATbits_t OSCSTATbits; #define _HFIOFS 0x01 #define _LFIOFR 0x02 #define _MFIOFR 0x04 #define _HFIOFL 0x08 #define _HFIOFR 0x10 #define _OSTS 0x20 #define _PLLR 0x40 #define _SOSCR 0x80 //============================================================================== extern __at(0x009B) __sfr ADRES; extern __at(0x009B) __sfr ADRESL; extern __at(0x009C) __sfr ADRESH; //============================================================================== // ADCON0 Bits extern __at(0x009D) __sfr ADCON0; typedef union { struct { unsigned ADON : 1; unsigned GO_NOT_DONE : 1; unsigned CHS0 : 1; unsigned CHS1 : 1; unsigned CHS2 : 1; unsigned CHS3 : 1; unsigned CHS4 : 1; unsigned : 1; }; struct { unsigned : 1; unsigned ADGO : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned : 1; unsigned GO : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned : 2; unsigned CHS : 5; unsigned : 1; }; } __ADCON0bits_t; extern __at(0x009D) volatile __ADCON0bits_t ADCON0bits; #define _ADON 0x01 #define _GO_NOT_DONE 0x02 #define _ADGO 0x02 #define _GO 0x02 #define _CHS0 0x04 #define _CHS1 0x08 #define _CHS2 0x10 #define _CHS3 0x20 #define _CHS4 0x40 //============================================================================== //============================================================================== // ADCON1 Bits extern __at(0x009E) __sfr ADCON1; typedef union { struct { unsigned ADPREF0 : 1; unsigned ADPREF1 : 1; unsigned ADNREF : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned ADFM : 1; }; struct { unsigned ADPREF : 2; unsigned : 6; }; } __ADCON1bits_t; extern __at(0x009E) volatile __ADCON1bits_t ADCON1bits; #define _ADPREF0 0x01 #define _ADPREF1 0x02 #define _ADNREF 0x04 #define _ADFM 0x80 //============================================================================== //============================================================================== // ADCON2 Bits extern __at(0x009F) __sfr ADCON2; typedef union { struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned TRIGSEL0 : 1; unsigned TRIGSEL1 : 1; unsigned TRIGSEL2 : 1; unsigned TRIGSEL3 : 1; unsigned TRIGSEL4 : 1; }; struct { unsigned : 3; unsigned TRIGSEL : 5; }; } __ADCON2bits_t; extern __at(0x009F) volatile __ADCON2bits_t ADCON2bits; #define _TRIGSEL0 0x08 #define _TRIGSEL1 0x10 #define _TRIGSEL2 0x20 #define _TRIGSEL3 0x40 #define _TRIGSEL4 0x80 //============================================================================== //============================================================================== // LATA Bits extern __at(0x010C) __sfr LATA; typedef struct { unsigned LATA0 : 1; unsigned LATA1 : 1; unsigned LATA2 : 1; unsigned : 1; unsigned LATA4 : 1; unsigned LATA5 : 1; unsigned : 1; unsigned : 1; } __LATAbits_t; extern __at(0x010C) volatile __LATAbits_t LATAbits; #define _LATA0 0x01 #define _LATA1 0x02 #define _LATA2 0x04 #define _LATA4 0x10 #define _LATA5 0x20 //============================================================================== //============================================================================== // LATB Bits extern __at(0x010D) __sfr LATB; typedef struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned LATB4 : 1; unsigned LATB5 : 1; unsigned LATB6 : 1; unsigned LATB7 : 1; } __LATBbits_t; extern __at(0x010D) volatile __LATBbits_t LATBbits; #define _LATB4 0x10 #define _LATB5 0x20 #define _LATB6 0x40 #define _LATB7 0x80 //============================================================================== //============================================================================== // LATC Bits extern __at(0x010E) __sfr LATC; typedef struct { unsigned LATC0 : 1; unsigned LATC1 : 1; unsigned LATC2 : 1; unsigned LATC3 : 1; unsigned LATC4 : 1; unsigned LATC5 : 1; unsigned LATC6 : 1; unsigned LATC7 : 1; } __LATCbits_t; extern __at(0x010E) volatile __LATCbits_t LATCbits; #define _LATC0 0x01 #define _LATC1 0x02 #define _LATC2 0x04 #define _LATC3 0x08 #define _LATC4 0x10 #define _LATC5 0x20 #define _LATC6 0x40 #define _LATC7 0x80 //============================================================================== //============================================================================== // CMOUT Bits extern __at(0x010F) __sfr CMOUT; typedef struct { unsigned MC1OUT : 1; unsigned MC2OUT : 1; unsigned MC3OUT : 1; unsigned MC4OUT : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; } __CMOUTbits_t; extern __at(0x010F) volatile __CMOUTbits_t CMOUTbits; #define _MC1OUT 0x01 #define _MC2OUT 0x02 #define _MC3OUT 0x04 #define _MC4OUT 0x08 //============================================================================== //============================================================================== // CM1CON0 Bits extern __at(0x0110) __sfr CM1CON0; typedef union { struct { unsigned SYNC : 1; unsigned HYS : 1; unsigned Reserved : 1; unsigned ZLF : 1; unsigned POL : 1; unsigned : 1; unsigned OUT : 1; unsigned ON : 1; }; struct { unsigned C1SYNC : 1; unsigned C1HYS : 1; unsigned C1SP : 1; unsigned C1ZLF : 1; unsigned C1POL : 1; unsigned : 1; unsigned C1OUT : 1; unsigned C1ON : 1; }; } __CM1CON0bits_t; extern __at(0x0110) volatile __CM1CON0bits_t CM1CON0bits; #define _CM1CON0_SYNC 0x01 #define _CM1CON0_C1SYNC 0x01 #define _CM1CON0_HYS 0x02 #define _CM1CON0_C1HYS 0x02 #define _CM1CON0_Reserved 0x04 #define _CM1CON0_C1SP 0x04 #define _CM1CON0_ZLF 0x08 #define _CM1CON0_C1ZLF 0x08 #define _CM1CON0_POL 0x10 #define _CM1CON0_C1POL 0x10 #define _CM1CON0_OUT 0x40 #define _CM1CON0_C1OUT 0x40 #define _CM1CON0_ON 0x80 #define _CM1CON0_C1ON 0x80 //============================================================================== //============================================================================== // CM1CON1 Bits extern __at(0x0111) __sfr CM1CON1; typedef union { struct { unsigned INTN : 1; unsigned INTP : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned C1INTN : 1; unsigned C1INTP : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; } __CM1CON1bits_t; extern __at(0x0111) volatile __CM1CON1bits_t CM1CON1bits; #define _CM1CON1_INTN 0x01 #define _CM1CON1_C1INTN 0x01 #define _CM1CON1_INTP 0x02 #define _CM1CON1_C1INTP 0x02 //============================================================================== //============================================================================== // CM1NSEL Bits extern __at(0x0112) __sfr CM1NSEL; typedef union { struct { unsigned NCH0 : 1; unsigned NCH1 : 1; unsigned NCH2 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned C1NCH0 : 1; unsigned C1NCH1 : 1; unsigned C1NCH2 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned NCH : 3; unsigned : 5; }; struct { unsigned C1NCH : 3; unsigned : 5; }; } __CM1NSELbits_t; extern __at(0x0112) volatile __CM1NSELbits_t CM1NSELbits; #define _NCH0 0x01 #define _C1NCH0 0x01 #define _NCH1 0x02 #define _C1NCH1 0x02 #define _NCH2 0x04 #define _C1NCH2 0x04 //============================================================================== //============================================================================== // CM1PSEL Bits extern __at(0x0113) __sfr CM1PSEL; typedef union { struct { unsigned PCH0 : 1; unsigned PCH1 : 1; unsigned PCH2 : 1; unsigned PCH3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned C1PCH0 : 1; unsigned C1PCH1 : 1; unsigned C1PCH2 : 1; unsigned C1PCH3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned PCH : 4; unsigned : 4; }; struct { unsigned C1PCH : 4; unsigned : 4; }; } __CM1PSELbits_t; extern __at(0x0113) volatile __CM1PSELbits_t CM1PSELbits; #define _PCH0 0x01 #define _C1PCH0 0x01 #define _PCH1 0x02 #define _C1PCH1 0x02 #define _PCH2 0x04 #define _C1PCH2 0x04 #define _PCH3 0x08 #define _C1PCH3 0x08 //============================================================================== //============================================================================== // CM2CON0 Bits extern __at(0x0114) __sfr CM2CON0; typedef union { struct { unsigned SYNC : 1; unsigned HYS : 1; unsigned Reserved : 1; unsigned ZLF : 1; unsigned POL : 1; unsigned : 1; unsigned OUT : 1; unsigned ON : 1; }; struct { unsigned C2SYNC : 1; unsigned C2HYS : 1; unsigned C2SP : 1; unsigned C2ZLF : 1; unsigned C2POL : 1; unsigned : 1; unsigned C2OUT : 1; unsigned C2ON : 1; }; } __CM2CON0bits_t; extern __at(0x0114) volatile __CM2CON0bits_t CM2CON0bits; #define _CM2CON0_SYNC 0x01 #define _CM2CON0_C2SYNC 0x01 #define _CM2CON0_HYS 0x02 #define _CM2CON0_C2HYS 0x02 #define _CM2CON0_Reserved 0x04 #define _CM2CON0_C2SP 0x04 #define _CM2CON0_ZLF 0x08 #define _CM2CON0_C2ZLF 0x08 #define _CM2CON0_POL 0x10 #define _CM2CON0_C2POL 0x10 #define _CM2CON0_OUT 0x40 #define _CM2CON0_C2OUT 0x40 #define _CM2CON0_ON 0x80 #define _CM2CON0_C2ON 0x80 //============================================================================== //============================================================================== // CM2CON1 Bits extern __at(0x0115) __sfr CM2CON1; typedef union { struct { unsigned INTN : 1; unsigned INTP : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned C2INTN : 1; unsigned C2INTP : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; } __CM2CON1bits_t; extern __at(0x0115) volatile __CM2CON1bits_t CM2CON1bits; #define _CM2CON1_INTN 0x01 #define _CM2CON1_C2INTN 0x01 #define _CM2CON1_INTP 0x02 #define _CM2CON1_C2INTP 0x02 //============================================================================== //============================================================================== // CM2NSEL Bits extern __at(0x0116) __sfr CM2NSEL; typedef union { struct { unsigned NCH0 : 1; unsigned NCH1 : 1; unsigned NCH2 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned C2NCH0 : 1; unsigned C2NCH1 : 1; unsigned C2NCH2 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned NCH : 3; unsigned : 5; }; struct { unsigned C2NCH : 3; unsigned : 5; }; } __CM2NSELbits_t; extern __at(0x0116) volatile __CM2NSELbits_t CM2NSELbits; #define _CM2NSEL_NCH0 0x01 #define _CM2NSEL_C2NCH0 0x01 #define _CM2NSEL_NCH1 0x02 #define _CM2NSEL_C2NCH1 0x02 #define _CM2NSEL_NCH2 0x04 #define _CM2NSEL_C2NCH2 0x04 //============================================================================== //============================================================================== // CM2PSEL Bits extern __at(0x0117) __sfr CM2PSEL; typedef union { struct { unsigned PCH0 : 1; unsigned PCH1 : 1; unsigned PCH2 : 1; unsigned PCH3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned C2PCH0 : 1; unsigned C2PCH1 : 1; unsigned C2PCH2 : 1; unsigned C2PCH3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned C2PCH : 4; unsigned : 4; }; struct { unsigned PCH : 4; unsigned : 4; }; } __CM2PSELbits_t; extern __at(0x0117) volatile __CM2PSELbits_t CM2PSELbits; #define _CM2PSEL_PCH0 0x01 #define _CM2PSEL_C2PCH0 0x01 #define _CM2PSEL_PCH1 0x02 #define _CM2PSEL_C2PCH1 0x02 #define _CM2PSEL_PCH2 0x04 #define _CM2PSEL_C2PCH2 0x04 #define _CM2PSEL_PCH3 0x08 #define _CM2PSEL_C2PCH3 0x08 //============================================================================== //============================================================================== // CM3CON0 Bits extern __at(0x0118) __sfr CM3CON0; typedef union { struct { unsigned SYNC : 1; unsigned HYS : 1; unsigned Reserved : 1; unsigned ZLF : 1; unsigned POL : 1; unsigned : 1; unsigned OUT : 1; unsigned ON : 1; }; struct { unsigned C3SYNC : 1; unsigned C3HYS : 1; unsigned C3SP : 1; unsigned C3ZLF : 1; unsigned C3POL : 1; unsigned : 1; unsigned C3OUT : 1; unsigned C3ON : 1; }; } __CM3CON0bits_t; extern __at(0x0118) volatile __CM3CON0bits_t CM3CON0bits; #define _CM3CON0_SYNC 0x01 #define _CM3CON0_C3SYNC 0x01 #define _CM3CON0_HYS 0x02 #define _CM3CON0_C3HYS 0x02 #define _CM3CON0_Reserved 0x04 #define _CM3CON0_C3SP 0x04 #define _CM3CON0_ZLF 0x08 #define _CM3CON0_C3ZLF 0x08 #define _CM3CON0_POL 0x10 #define _CM3CON0_C3POL 0x10 #define _CM3CON0_OUT 0x40 #define _CM3CON0_C3OUT 0x40 #define _CM3CON0_ON 0x80 #define _CM3CON0_C3ON 0x80 //============================================================================== //============================================================================== // CM3CON1 Bits extern __at(0x0119) __sfr CM3CON1; typedef union { struct { unsigned INTN : 1; unsigned INTP : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned C3INTN : 1; unsigned C3INTP : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; } __CM3CON1bits_t; extern __at(0x0119) volatile __CM3CON1bits_t CM3CON1bits; #define _CM3CON1_INTN 0x01 #define _CM3CON1_C3INTN 0x01 #define _CM3CON1_INTP 0x02 #define _CM3CON1_C3INTP 0x02 //============================================================================== //============================================================================== // CM3NSEL Bits extern __at(0x011A) __sfr CM3NSEL; typedef union { struct { unsigned NCH0 : 1; unsigned NCH1 : 1; unsigned NCH2 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned C3NCH0 : 1; unsigned C3NCH1 : 1; unsigned C3NCH2 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned NCH : 3; unsigned : 5; }; struct { unsigned C3NCH : 3; unsigned : 5; }; } __CM3NSELbits_t; extern __at(0x011A) volatile __CM3NSELbits_t CM3NSELbits; #define _CM3NSEL_NCH0 0x01 #define _CM3NSEL_C3NCH0 0x01 #define _CM3NSEL_NCH1 0x02 #define _CM3NSEL_C3NCH1 0x02 #define _CM3NSEL_NCH2 0x04 #define _CM3NSEL_C3NCH2 0x04 //============================================================================== //============================================================================== // CM3PSEL Bits extern __at(0x011B) __sfr CM3PSEL; typedef union { struct { unsigned PCH0 : 1; unsigned PCH1 : 1; unsigned PCH2 : 1; unsigned PCH3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned C3PCH0 : 1; unsigned C3PCH1 : 1; unsigned C3PCH2 : 1; unsigned C3PCH3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned PCH : 4; unsigned : 4; }; struct { unsigned C3PCH : 4; unsigned : 4; }; } __CM3PSELbits_t; extern __at(0x011B) volatile __CM3PSELbits_t CM3PSELbits; #define _CM3PSEL_PCH0 0x01 #define _CM3PSEL_C3PCH0 0x01 #define _CM3PSEL_PCH1 0x02 #define _CM3PSEL_C3PCH1 0x02 #define _CM3PSEL_PCH2 0x04 #define _CM3PSEL_C3PCH2 0x04 #define _CM3PSEL_PCH3 0x08 #define _CM3PSEL_C3PCH3 0x08 //============================================================================== //============================================================================== // CM4CON0 Bits extern __at(0x011C) __sfr CM4CON0; typedef union { struct { unsigned SYNC : 1; unsigned HYS : 1; unsigned Reserved : 1; unsigned ZLF : 1; unsigned POL : 1; unsigned : 1; unsigned OUT : 1; unsigned ON : 1; }; struct { unsigned C4SYNC : 1; unsigned C4HYS : 1; unsigned C4SP : 1; unsigned C4ZLF : 1; unsigned C4POL : 1; unsigned : 1; unsigned C4OUT : 1; unsigned C4ON : 1; }; } __CM4CON0bits_t; extern __at(0x011C) volatile __CM4CON0bits_t CM4CON0bits; #define _CM4CON0_SYNC 0x01 #define _CM4CON0_C4SYNC 0x01 #define _CM4CON0_HYS 0x02 #define _CM4CON0_C4HYS 0x02 #define _CM4CON0_Reserved 0x04 #define _CM4CON0_C4SP 0x04 #define _CM4CON0_ZLF 0x08 #define _CM4CON0_C4ZLF 0x08 #define _CM4CON0_POL 0x10 #define _CM4CON0_C4POL 0x10 #define _CM4CON0_OUT 0x40 #define _CM4CON0_C4OUT 0x40 #define _CM4CON0_ON 0x80 #define _CM4CON0_C4ON 0x80 //============================================================================== //============================================================================== // CM4CON1 Bits extern __at(0x011D) __sfr CM4CON1; typedef union { struct { unsigned INTN : 1; unsigned INTP : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned C4INTN : 1; unsigned C4INTP : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; } __CM4CON1bits_t; extern __at(0x011D) volatile __CM4CON1bits_t CM4CON1bits; #define _CM4CON1_INTN 0x01 #define _CM4CON1_C4INTN 0x01 #define _CM4CON1_INTP 0x02 #define _CM4CON1_C4INTP 0x02 //============================================================================== //============================================================================== // CM4NSEL Bits extern __at(0x011E) __sfr CM4NSEL; typedef union { struct { unsigned NCH0 : 1; unsigned NCH1 : 1; unsigned NCH2 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned C4NCH0 : 1; unsigned C4NCH1 : 1; unsigned C4NCH2 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned NCH : 3; unsigned : 5; }; struct { unsigned C4NCH : 3; unsigned : 5; }; } __CM4NSELbits_t; extern __at(0x011E) volatile __CM4NSELbits_t CM4NSELbits; #define _CM4NSEL_NCH0 0x01 #define _CM4NSEL_C4NCH0 0x01 #define _CM4NSEL_NCH1 0x02 #define _CM4NSEL_C4NCH1 0x02 #define _CM4NSEL_NCH2 0x04 #define _CM4NSEL_C4NCH2 0x04 //============================================================================== //============================================================================== // CM4PSEL Bits extern __at(0x011F) __sfr CM4PSEL; typedef union { struct { unsigned PCH0 : 1; unsigned PCH1 : 1; unsigned PCH2 : 1; unsigned PCH3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned C4PCH0 : 1; unsigned C4PCH1 : 1; unsigned C4PCH2 : 1; unsigned C4PCH3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned PCH : 4; unsigned : 4; }; struct { unsigned C4PCH : 4; unsigned : 4; }; } __CM4PSELbits_t; extern __at(0x011F) volatile __CM4PSELbits_t CM4PSELbits; #define _CM4PSEL_PCH0 0x01 #define _CM4PSEL_C4PCH0 0x01 #define _CM4PSEL_PCH1 0x02 #define _CM4PSEL_C4PCH1 0x02 #define _CM4PSEL_PCH2 0x04 #define _CM4PSEL_C4PCH2 0x04 #define _CM4PSEL_PCH3 0x08 #define _CM4PSEL_C4PCH3 0x08 //============================================================================== //============================================================================== // ANSELA Bits extern __at(0x018C) __sfr ANSELA; typedef struct { unsigned ANSA0 : 1; unsigned ANSA1 : 1; unsigned ANSA2 : 1; unsigned : 1; unsigned ANSA4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; } __ANSELAbits_t; extern __at(0x018C) volatile __ANSELAbits_t ANSELAbits; #define _ANSA0 0x01 #define _ANSA1 0x02 #define _ANSA2 0x04 #define _ANSA4 0x10 //============================================================================== //============================================================================== // ANSELB Bits extern __at(0x018D) __sfr ANSELB; typedef struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned ANSB4 : 1; unsigned ANSB5 : 1; unsigned ANSB6 : 1; unsigned ANSB7 : 1; } __ANSELBbits_t; extern __at(0x018D) volatile __ANSELBbits_t ANSELBbits; #define _ANSB4 0x10 #define _ANSB5 0x20 #define _ANSB6 0x40 #define _ANSB7 0x80 //============================================================================== //============================================================================== // ANSELC Bits extern __at(0x018E) __sfr ANSELC; typedef struct { unsigned ANSC0 : 1; unsigned ANSC1 : 1; unsigned ANSC2 : 1; unsigned ANSC3 : 1; unsigned : 1; unsigned : 1; unsigned ANSC6 : 1; unsigned ANSC7 : 1; } __ANSELCbits_t; extern __at(0x018E) volatile __ANSELCbits_t ANSELCbits; #define _ANSC0 0x01 #define _ANSC1 0x02 #define _ANSC2 0x04 #define _ANSC3 0x08 #define _ANSC6 0x40 #define _ANSC7 0x80 //============================================================================== extern __at(0x0191) __sfr PMADR; extern __at(0x0191) __sfr PMADRL; extern __at(0x0192) __sfr PMADRH; extern __at(0x0193) __sfr PMDAT; extern __at(0x0193) __sfr PMDATL; extern __at(0x0194) __sfr PMDATH; //============================================================================== // PMCON1 Bits extern __at(0x0195) __sfr PMCON1; typedef struct { unsigned RD : 1; unsigned WR : 1; unsigned WREN : 1; unsigned WRERR : 1; unsigned FREE : 1; unsigned LWLO : 1; unsigned CFGS : 1; unsigned : 1; } __PMCON1bits_t; extern __at(0x0195) volatile __PMCON1bits_t PMCON1bits; #define _RD 0x01 #define _WR 0x02 #define _WREN 0x04 #define _WRERR 0x08 #define _FREE 0x10 #define _LWLO 0x20 #define _CFGS 0x40 //============================================================================== extern __at(0x0196) __sfr PMCON2; //============================================================================== // VREGCON Bits extern __at(0x0197) __sfr VREGCON; typedef struct { unsigned Reserved : 1; unsigned VREGPM : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; } __VREGCONbits_t; extern __at(0x0197) volatile __VREGCONbits_t VREGCONbits; #define _VREGCON_Reserved 0x01 #define _VREGCON_VREGPM 0x02 //============================================================================== extern __at(0x0199) __sfr RC1REG; extern __at(0x0199) __sfr RCREG; extern __at(0x0199) __sfr RCREG1; extern __at(0x019A) __sfr TX1REG; extern __at(0x019A) __sfr TXREG; extern __at(0x019A) __sfr TXREG1; extern __at(0x019B) __sfr SP1BRG; extern __at(0x019B) __sfr SP1BRGL; extern __at(0x019B) __sfr SPBRG; extern __at(0x019B) __sfr SPBRG1; extern __at(0x019B) __sfr SPBRGL; extern __at(0x019C) __sfr SP1BRGH; extern __at(0x019C) __sfr SPBRGH; extern __at(0x019C) __sfr SPBRGH1; //============================================================================== // RC1STA Bits extern __at(0x019D) __sfr RC1STA; typedef struct { unsigned RX9D : 1; unsigned OERR : 1; unsigned FERR : 1; unsigned ADDEN : 1; unsigned CREN : 1; unsigned SREN : 1; unsigned RX9 : 1; unsigned SPEN : 1; } __RC1STAbits_t; extern __at(0x019D) volatile __RC1STAbits_t RC1STAbits; #define _RX9D 0x01 #define _OERR 0x02 #define _FERR 0x04 #define _ADDEN 0x08 #define _CREN 0x10 #define _SREN 0x20 #define _RX9 0x40 #define _SPEN 0x80 //============================================================================== //============================================================================== // RCSTA Bits extern __at(0x019D) __sfr RCSTA; typedef struct { unsigned RX9D : 1; unsigned OERR : 1; unsigned FERR : 1; unsigned ADDEN : 1; unsigned CREN : 1; unsigned SREN : 1; unsigned RX9 : 1; unsigned SPEN : 1; } __RCSTAbits_t; extern __at(0x019D) volatile __RCSTAbits_t RCSTAbits; #define _RCSTA_RX9D 0x01 #define _RCSTA_OERR 0x02 #define _RCSTA_FERR 0x04 #define _RCSTA_ADDEN 0x08 #define _RCSTA_CREN 0x10 #define _RCSTA_SREN 0x20 #define _RCSTA_RX9 0x40 #define _RCSTA_SPEN 0x80 //============================================================================== //============================================================================== // RCSTA1 Bits extern __at(0x019D) __sfr RCSTA1; typedef struct { unsigned RX9D : 1; unsigned OERR : 1; unsigned FERR : 1; unsigned ADDEN : 1; unsigned CREN : 1; unsigned SREN : 1; unsigned RX9 : 1; unsigned SPEN : 1; } __RCSTA1bits_t; extern __at(0x019D) volatile __RCSTA1bits_t RCSTA1bits; #define _RCSTA1_RX9D 0x01 #define _RCSTA1_OERR 0x02 #define _RCSTA1_FERR 0x04 #define _RCSTA1_ADDEN 0x08 #define _RCSTA1_CREN 0x10 #define _RCSTA1_SREN 0x20 #define _RCSTA1_RX9 0x40 #define _RCSTA1_SPEN 0x80 //============================================================================== //============================================================================== // TX1STA Bits extern __at(0x019E) __sfr TX1STA; typedef struct { unsigned TX9D : 1; unsigned TRMT : 1; unsigned BRGH : 1; unsigned SENDB : 1; unsigned SYNC : 1; unsigned TXEN : 1; unsigned TX9 : 1; unsigned CSRC : 1; } __TX1STAbits_t; extern __at(0x019E) volatile __TX1STAbits_t TX1STAbits; #define _TX1STA_TX9D 0x01 #define _TX1STA_TRMT 0x02 #define _TX1STA_BRGH 0x04 #define _TX1STA_SENDB 0x08 #define _TX1STA_SYNC 0x10 #define _TX1STA_TXEN 0x20 #define _TX1STA_TX9 0x40 #define _TX1STA_CSRC 0x80 //============================================================================== //============================================================================== // TXSTA Bits extern __at(0x019E) __sfr TXSTA; typedef struct { unsigned TX9D : 1; unsigned TRMT : 1; unsigned BRGH : 1; unsigned SENDB : 1; unsigned SYNC : 1; unsigned TXEN : 1; unsigned TX9 : 1; unsigned CSRC : 1; } __TXSTAbits_t; extern __at(0x019E) volatile __TXSTAbits_t TXSTAbits; #define _TXSTA_TX9D 0x01 #define _TXSTA_TRMT 0x02 #define _TXSTA_BRGH 0x04 #define _TXSTA_SENDB 0x08 #define _TXSTA_SYNC 0x10 #define _TXSTA_TXEN 0x20 #define _TXSTA_TX9 0x40 #define _TXSTA_CSRC 0x80 //============================================================================== //============================================================================== // TXSTA1 Bits extern __at(0x019E) __sfr TXSTA1; typedef struct { unsigned TX9D : 1; unsigned TRMT : 1; unsigned BRGH : 1; unsigned SENDB : 1; unsigned SYNC : 1; unsigned TXEN : 1; unsigned TX9 : 1; unsigned CSRC : 1; } __TXSTA1bits_t; extern __at(0x019E) volatile __TXSTA1bits_t TXSTA1bits; #define _TXSTA1_TX9D 0x01 #define _TXSTA1_TRMT 0x02 #define _TXSTA1_BRGH 0x04 #define _TXSTA1_SENDB 0x08 #define _TXSTA1_SYNC 0x10 #define _TXSTA1_TXEN 0x20 #define _TXSTA1_TX9 0x40 #define _TXSTA1_CSRC 0x80 //============================================================================== //============================================================================== // BAUD1CON Bits extern __at(0x019F) __sfr BAUD1CON; typedef struct { unsigned ABDEN : 1; unsigned WUE : 1; unsigned : 1; unsigned BRG16 : 1; unsigned SCKP : 1; unsigned : 1; unsigned RCIDL : 1; unsigned ABDOVF : 1; } __BAUD1CONbits_t; extern __at(0x019F) volatile __BAUD1CONbits_t BAUD1CONbits; #define _ABDEN 0x01 #define _WUE 0x02 #define _BRG16 0x08 #define _SCKP 0x10 #define _RCIDL 0x40 #define _ABDOVF 0x80 //============================================================================== //============================================================================== // BAUDCON Bits extern __at(0x019F) __sfr BAUDCON; typedef struct { unsigned ABDEN : 1; unsigned WUE : 1; unsigned : 1; unsigned BRG16 : 1; unsigned SCKP : 1; unsigned : 1; unsigned RCIDL : 1; unsigned ABDOVF : 1; } __BAUDCONbits_t; extern __at(0x019F) volatile __BAUDCONbits_t BAUDCONbits; #define _BAUDCON_ABDEN 0x01 #define _BAUDCON_WUE 0x02 #define _BAUDCON_BRG16 0x08 #define _BAUDCON_SCKP 0x10 #define _BAUDCON_RCIDL 0x40 #define _BAUDCON_ABDOVF 0x80 //============================================================================== //============================================================================== // BAUDCON1 Bits extern __at(0x019F) __sfr BAUDCON1; typedef struct { unsigned ABDEN : 1; unsigned WUE : 1; unsigned : 1; unsigned BRG16 : 1; unsigned SCKP : 1; unsigned : 1; unsigned RCIDL : 1; unsigned ABDOVF : 1; } __BAUDCON1bits_t; extern __at(0x019F) volatile __BAUDCON1bits_t BAUDCON1bits; #define _BAUDCON1_ABDEN 0x01 #define _BAUDCON1_WUE 0x02 #define _BAUDCON1_BRG16 0x08 #define _BAUDCON1_SCKP 0x10 #define _BAUDCON1_RCIDL 0x40 #define _BAUDCON1_ABDOVF 0x80 //============================================================================== //============================================================================== // BAUDCTL Bits extern __at(0x019F) __sfr BAUDCTL; typedef struct { unsigned ABDEN : 1; unsigned WUE : 1; unsigned : 1; unsigned BRG16 : 1; unsigned SCKP : 1; unsigned : 1; unsigned RCIDL : 1; unsigned ABDOVF : 1; } __BAUDCTLbits_t; extern __at(0x019F) volatile __BAUDCTLbits_t BAUDCTLbits; #define _BAUDCTL_ABDEN 0x01 #define _BAUDCTL_WUE 0x02 #define _BAUDCTL_BRG16 0x08 #define _BAUDCTL_SCKP 0x10 #define _BAUDCTL_RCIDL 0x40 #define _BAUDCTL_ABDOVF 0x80 //============================================================================== //============================================================================== // BAUDCTL1 Bits extern __at(0x019F) __sfr BAUDCTL1; typedef struct { unsigned ABDEN : 1; unsigned WUE : 1; unsigned : 1; unsigned BRG16 : 1; unsigned SCKP : 1; unsigned : 1; unsigned RCIDL : 1; unsigned ABDOVF : 1; } __BAUDCTL1bits_t; extern __at(0x019F) volatile __BAUDCTL1bits_t BAUDCTL1bits; #define _BAUDCTL1_ABDEN 0x01 #define _BAUDCTL1_WUE 0x02 #define _BAUDCTL1_BRG16 0x08 #define _BAUDCTL1_SCKP 0x10 #define _BAUDCTL1_RCIDL 0x40 #define _BAUDCTL1_ABDOVF 0x80 //============================================================================== //============================================================================== // WPUA Bits extern __at(0x020C) __sfr WPUA; typedef union { struct { unsigned WPUA0 : 1; unsigned WPUA1 : 1; unsigned WPUA2 : 1; unsigned WPUA3 : 1; unsigned WPUA4 : 1; unsigned WPUA5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned WPUA : 6; unsigned : 2; }; } __WPUAbits_t; extern __at(0x020C) volatile __WPUAbits_t WPUAbits; #define _WPUA0 0x01 #define _WPUA1 0x02 #define _WPUA2 0x04 #define _WPUA3 0x08 #define _WPUA4 0x10 #define _WPUA5 0x20 //============================================================================== //============================================================================== // WPUB Bits extern __at(0x020D) __sfr WPUB; typedef struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned WPUB4 : 1; unsigned WPUB5 : 1; unsigned WPUB6 : 1; unsigned WPUB7 : 1; } __WPUBbits_t; extern __at(0x020D) volatile __WPUBbits_t WPUBbits; #define _WPUB4 0x10 #define _WPUB5 0x20 #define _WPUB6 0x40 #define _WPUB7 0x80 //============================================================================== //============================================================================== // WPUC Bits extern __at(0x020E) __sfr WPUC; typedef struct { unsigned WPUC0 : 1; unsigned WPUC1 : 1; unsigned WPUC2 : 1; unsigned WPUC3 : 1; unsigned WPUC4 : 1; unsigned WPUC5 : 1; unsigned WPUC6 : 1; unsigned WPUC7 : 1; } __WPUCbits_t; extern __at(0x020E) volatile __WPUCbits_t WPUCbits; #define _WPUC0 0x01 #define _WPUC1 0x02 #define _WPUC2 0x04 #define _WPUC3 0x08 #define _WPUC4 0x10 #define _WPUC5 0x20 #define _WPUC6 0x40 #define _WPUC7 0x80 //============================================================================== //============================================================================== // SSP1BUF Bits extern __at(0x0211) __sfr SSP1BUF; typedef union { struct { unsigned SSP1BUF0 : 1; unsigned SSP1BUF1 : 1; unsigned SSP1BUF2 : 1; unsigned SSP1BUF3 : 1; unsigned SSP1BUF4 : 1; unsigned SSP1BUF5 : 1; unsigned SSP1BUF6 : 1; unsigned SSP1BUF7 : 1; }; struct { unsigned BUF0 : 1; unsigned BUF1 : 1; unsigned BUF2 : 1; unsigned BUF3 : 1; unsigned BUF4 : 1; unsigned BUF5 : 1; unsigned BUF6 : 1; unsigned BUF7 : 1; }; } __SSP1BUFbits_t; extern __at(0x0211) volatile __SSP1BUFbits_t SSP1BUFbits; #define _SSP1BUF0 0x01 #define _BUF0 0x01 #define _SSP1BUF1 0x02 #define _BUF1 0x02 #define _SSP1BUF2 0x04 #define _BUF2 0x04 #define _SSP1BUF3 0x08 #define _BUF3 0x08 #define _SSP1BUF4 0x10 #define _BUF4 0x10 #define _SSP1BUF5 0x20 #define _BUF5 0x20 #define _SSP1BUF6 0x40 #define _BUF6 0x40 #define _SSP1BUF7 0x80 #define _BUF7 0x80 //============================================================================== //============================================================================== // SSPBUF Bits extern __at(0x0211) __sfr SSPBUF; typedef union { struct { unsigned SSP1BUF0 : 1; unsigned SSP1BUF1 : 1; unsigned SSP1BUF2 : 1; unsigned SSP1BUF3 : 1; unsigned SSP1BUF4 : 1; unsigned SSP1BUF5 : 1; unsigned SSP1BUF6 : 1; unsigned SSP1BUF7 : 1; }; struct { unsigned BUF0 : 1; unsigned BUF1 : 1; unsigned BUF2 : 1; unsigned BUF3 : 1; unsigned BUF4 : 1; unsigned BUF5 : 1; unsigned BUF6 : 1; unsigned BUF7 : 1; }; } __SSPBUFbits_t; extern __at(0x0211) volatile __SSPBUFbits_t SSPBUFbits; #define _SSPBUF_SSP1BUF0 0x01 #define _SSPBUF_BUF0 0x01 #define _SSPBUF_SSP1BUF1 0x02 #define _SSPBUF_BUF1 0x02 #define _SSPBUF_SSP1BUF2 0x04 #define _SSPBUF_BUF2 0x04 #define _SSPBUF_SSP1BUF3 0x08 #define _SSPBUF_BUF3 0x08 #define _SSPBUF_SSP1BUF4 0x10 #define _SSPBUF_BUF4 0x10 #define _SSPBUF_SSP1BUF5 0x20 #define _SSPBUF_BUF5 0x20 #define _SSPBUF_SSP1BUF6 0x40 #define _SSPBUF_BUF6 0x40 #define _SSPBUF_SSP1BUF7 0x80 #define _SSPBUF_BUF7 0x80 //============================================================================== //============================================================================== // SSP1ADD Bits extern __at(0x0212) __sfr SSP1ADD; typedef union { struct { unsigned SSP1ADD0 : 1; unsigned SSP1ADD1 : 1; unsigned SSP1ADD2 : 1; unsigned SSP1ADD3 : 1; unsigned SSP1ADD4 : 1; unsigned SSP1ADD5 : 1; unsigned SSP1ADD6 : 1; unsigned SSP1ADD7 : 1; }; struct { unsigned ADD0 : 1; unsigned ADD1 : 1; unsigned ADD2 : 1; unsigned ADD3 : 1; unsigned ADD4 : 1; unsigned ADD5 : 1; unsigned ADD6 : 1; unsigned ADD7 : 1; }; } __SSP1ADDbits_t; extern __at(0x0212) volatile __SSP1ADDbits_t SSP1ADDbits; #define _SSP1ADD0 0x01 #define _ADD0 0x01 #define _SSP1ADD1 0x02 #define _ADD1 0x02 #define _SSP1ADD2 0x04 #define _ADD2 0x04 #define _SSP1ADD3 0x08 #define _ADD3 0x08 #define _SSP1ADD4 0x10 #define _ADD4 0x10 #define _SSP1ADD5 0x20 #define _ADD5 0x20 #define _SSP1ADD6 0x40 #define _ADD6 0x40 #define _SSP1ADD7 0x80 #define _ADD7 0x80 //============================================================================== //============================================================================== // SSPADD Bits extern __at(0x0212) __sfr SSPADD; typedef union { struct { unsigned SSP1ADD0 : 1; unsigned SSP1ADD1 : 1; unsigned SSP1ADD2 : 1; unsigned SSP1ADD3 : 1; unsigned SSP1ADD4 : 1; unsigned SSP1ADD5 : 1; unsigned SSP1ADD6 : 1; unsigned SSP1ADD7 : 1; }; struct { unsigned ADD0 : 1; unsigned ADD1 : 1; unsigned ADD2 : 1; unsigned ADD3 : 1; unsigned ADD4 : 1; unsigned ADD5 : 1; unsigned ADD6 : 1; unsigned ADD7 : 1; }; } __SSPADDbits_t; extern __at(0x0212) volatile __SSPADDbits_t SSPADDbits; #define _SSPADD_SSP1ADD0 0x01 #define _SSPADD_ADD0 0x01 #define _SSPADD_SSP1ADD1 0x02 #define _SSPADD_ADD1 0x02 #define _SSPADD_SSP1ADD2 0x04 #define _SSPADD_ADD2 0x04 #define _SSPADD_SSP1ADD3 0x08 #define _SSPADD_ADD3 0x08 #define _SSPADD_SSP1ADD4 0x10 #define _SSPADD_ADD4 0x10 #define _SSPADD_SSP1ADD5 0x20 #define _SSPADD_ADD5 0x20 #define _SSPADD_SSP1ADD6 0x40 #define _SSPADD_ADD6 0x40 #define _SSPADD_SSP1ADD7 0x80 #define _SSPADD_ADD7 0x80 //============================================================================== //============================================================================== // SSP1MSK Bits extern __at(0x0213) __sfr SSP1MSK; typedef union { struct { unsigned SSP1MSK0 : 1; unsigned SSP1MSK1 : 1; unsigned SSP1MSK2 : 1; unsigned SSP1MSK3 : 1; unsigned SSP1MSK4 : 1; unsigned SSP1MSK5 : 1; unsigned SSP1MSK6 : 1; unsigned SSP1MSK7 : 1; }; struct { unsigned MSK0 : 1; unsigned MSK1 : 1; unsigned MSK2 : 1; unsigned MSK3 : 1; unsigned MSK4 : 1; unsigned MSK5 : 1; unsigned MSK6 : 1; unsigned MSK7 : 1; }; } __SSP1MSKbits_t; extern __at(0x0213) volatile __SSP1MSKbits_t SSP1MSKbits; #define _SSP1MSK0 0x01 #define _MSK0 0x01 #define _SSP1MSK1 0x02 #define _MSK1 0x02 #define _SSP1MSK2 0x04 #define _MSK2 0x04 #define _SSP1MSK3 0x08 #define _MSK3 0x08 #define _SSP1MSK4 0x10 #define _MSK4 0x10 #define _SSP1MSK5 0x20 #define _MSK5 0x20 #define _SSP1MSK6 0x40 #define _MSK6 0x40 #define _SSP1MSK7 0x80 #define _MSK7 0x80 //============================================================================== //============================================================================== // SSPMSK Bits extern __at(0x0213) __sfr SSPMSK; typedef union { struct { unsigned SSP1MSK0 : 1; unsigned SSP1MSK1 : 1; unsigned SSP1MSK2 : 1; unsigned SSP1MSK3 : 1; unsigned SSP1MSK4 : 1; unsigned SSP1MSK5 : 1; unsigned SSP1MSK6 : 1; unsigned SSP1MSK7 : 1; }; struct { unsigned MSK0 : 1; unsigned MSK1 : 1; unsigned MSK2 : 1; unsigned MSK3 : 1; unsigned MSK4 : 1; unsigned MSK5 : 1; unsigned MSK6 : 1; unsigned MSK7 : 1; }; } __SSPMSKbits_t; extern __at(0x0213) volatile __SSPMSKbits_t SSPMSKbits; #define _SSPMSK_SSP1MSK0 0x01 #define _SSPMSK_MSK0 0x01 #define _SSPMSK_SSP1MSK1 0x02 #define _SSPMSK_MSK1 0x02 #define _SSPMSK_SSP1MSK2 0x04 #define _SSPMSK_MSK2 0x04 #define _SSPMSK_SSP1MSK3 0x08 #define _SSPMSK_MSK3 0x08 #define _SSPMSK_SSP1MSK4 0x10 #define _SSPMSK_MSK4 0x10 #define _SSPMSK_SSP1MSK5 0x20 #define _SSPMSK_MSK5 0x20 #define _SSPMSK_SSP1MSK6 0x40 #define _SSPMSK_MSK6 0x40 #define _SSPMSK_SSP1MSK7 0x80 #define _SSPMSK_MSK7 0x80 //============================================================================== //============================================================================== // SSP1STAT Bits extern __at(0x0214) __sfr SSP1STAT; typedef struct { unsigned BF : 1; unsigned UA : 1; unsigned R_NOT_W : 1; unsigned S : 1; unsigned P : 1; unsigned D_NOT_A : 1; unsigned CKE : 1; unsigned SMP : 1; } __SSP1STATbits_t; extern __at(0x0214) volatile __SSP1STATbits_t SSP1STATbits; #define _BF 0x01 #define _UA 0x02 #define _R_NOT_W 0x04 #define _S 0x08 #define _P 0x10 #define _D_NOT_A 0x20 #define _CKE 0x40 #define _SMP 0x80 //============================================================================== //============================================================================== // SSPSTAT Bits extern __at(0x0214) __sfr SSPSTAT; typedef struct { unsigned BF : 1; unsigned UA : 1; unsigned R_NOT_W : 1; unsigned S : 1; unsigned P : 1; unsigned D_NOT_A : 1; unsigned CKE : 1; unsigned SMP : 1; } __SSPSTATbits_t; extern __at(0x0214) volatile __SSPSTATbits_t SSPSTATbits; #define _SSPSTAT_BF 0x01 #define _SSPSTAT_UA 0x02 #define _SSPSTAT_R_NOT_W 0x04 #define _SSPSTAT_S 0x08 #define _SSPSTAT_P 0x10 #define _SSPSTAT_D_NOT_A 0x20 #define _SSPSTAT_CKE 0x40 #define _SSPSTAT_SMP 0x80 //============================================================================== //============================================================================== // SSP1CON Bits extern __at(0x0215) __sfr SSP1CON; typedef union { struct { unsigned SSPM0 : 1; unsigned SSPM1 : 1; unsigned SSPM2 : 1; unsigned SSPM3 : 1; unsigned CKP : 1; unsigned SSPEN : 1; unsigned SSPOV : 1; unsigned WCOL : 1; }; struct { unsigned SSPM : 4; unsigned : 4; }; } __SSP1CONbits_t; extern __at(0x0215) volatile __SSP1CONbits_t SSP1CONbits; #define _SSPM0 0x01 #define _SSPM1 0x02 #define _SSPM2 0x04 #define _SSPM3 0x08 #define _CKP 0x10 #define _SSPEN 0x20 #define _SSPOV 0x40 #define _WCOL 0x80 //============================================================================== //============================================================================== // SSP1CON1 Bits extern __at(0x0215) __sfr SSP1CON1; typedef union { struct { unsigned SSPM0 : 1; unsigned SSPM1 : 1; unsigned SSPM2 : 1; unsigned SSPM3 : 1; unsigned CKP : 1; unsigned SSPEN : 1; unsigned SSPOV : 1; unsigned WCOL : 1; }; struct { unsigned SSPM : 4; unsigned : 4; }; } __SSP1CON1bits_t; extern __at(0x0215) volatile __SSP1CON1bits_t SSP1CON1bits; #define _SSP1CON1_SSPM0 0x01 #define _SSP1CON1_SSPM1 0x02 #define _SSP1CON1_SSPM2 0x04 #define _SSP1CON1_SSPM3 0x08 #define _SSP1CON1_CKP 0x10 #define _SSP1CON1_SSPEN 0x20 #define _SSP1CON1_SSPOV 0x40 #define _SSP1CON1_WCOL 0x80 //============================================================================== //============================================================================== // SSPCON Bits extern __at(0x0215) __sfr SSPCON; typedef union { struct { unsigned SSPM0 : 1; unsigned SSPM1 : 1; unsigned SSPM2 : 1; unsigned SSPM3 : 1; unsigned CKP : 1; unsigned SSPEN : 1; unsigned SSPOV : 1; unsigned WCOL : 1; }; struct { unsigned SSPM : 4; unsigned : 4; }; } __SSPCONbits_t; extern __at(0x0215) volatile __SSPCONbits_t SSPCONbits; #define _SSPCON_SSPM0 0x01 #define _SSPCON_SSPM1 0x02 #define _SSPCON_SSPM2 0x04 #define _SSPCON_SSPM3 0x08 #define _SSPCON_CKP 0x10 #define _SSPCON_SSPEN 0x20 #define _SSPCON_SSPOV 0x40 #define _SSPCON_WCOL 0x80 //============================================================================== //============================================================================== // SSPCON1 Bits extern __at(0x0215) __sfr SSPCON1; typedef union { struct { unsigned SSPM0 : 1; unsigned SSPM1 : 1; unsigned SSPM2 : 1; unsigned SSPM3 : 1; unsigned CKP : 1; unsigned SSPEN : 1; unsigned SSPOV : 1; unsigned WCOL : 1; }; struct { unsigned SSPM : 4; unsigned : 4; }; } __SSPCON1bits_t; extern __at(0x0215) volatile __SSPCON1bits_t SSPCON1bits; #define _SSPCON1_SSPM0 0x01 #define _SSPCON1_SSPM1 0x02 #define _SSPCON1_SSPM2 0x04 #define _SSPCON1_SSPM3 0x08 #define _SSPCON1_CKP 0x10 #define _SSPCON1_SSPEN 0x20 #define _SSPCON1_SSPOV 0x40 #define _SSPCON1_WCOL 0x80 //============================================================================== //============================================================================== // SSP1CON2 Bits extern __at(0x0216) __sfr SSP1CON2; typedef struct { unsigned SEN : 1; unsigned RSEN : 1; unsigned PEN : 1; unsigned RCEN : 1; unsigned ACKEN : 1; unsigned ACKDT : 1; unsigned ACKSTAT : 1; unsigned GCEN : 1; } __SSP1CON2bits_t; extern __at(0x0216) volatile __SSP1CON2bits_t SSP1CON2bits; #define _SEN 0x01 #define _RSEN 0x02 #define _PEN 0x04 #define _RCEN 0x08 #define _ACKEN 0x10 #define _ACKDT 0x20 #define _ACKSTAT 0x40 #define _GCEN 0x80 //============================================================================== //============================================================================== // SSPCON2 Bits extern __at(0x0216) __sfr SSPCON2; typedef struct { unsigned SEN : 1; unsigned RSEN : 1; unsigned PEN : 1; unsigned RCEN : 1; unsigned ACKEN : 1; unsigned ACKDT : 1; unsigned ACKSTAT : 1; unsigned GCEN : 1; } __SSPCON2bits_t; extern __at(0x0216) volatile __SSPCON2bits_t SSPCON2bits; #define _SSPCON2_SEN 0x01 #define _SSPCON2_RSEN 0x02 #define _SSPCON2_PEN 0x04 #define _SSPCON2_RCEN 0x08 #define _SSPCON2_ACKEN 0x10 #define _SSPCON2_ACKDT 0x20 #define _SSPCON2_ACKSTAT 0x40 #define _SSPCON2_GCEN 0x80 //============================================================================== //============================================================================== // SSP1CON3 Bits extern __at(0x0217) __sfr SSP1CON3; typedef struct { unsigned DHEN : 1; unsigned AHEN : 1; unsigned SBCDE : 1; unsigned SDAHT : 1; unsigned BOEN : 1; unsigned SCIE : 1; unsigned PCIE : 1; unsigned ACKTIM : 1; } __SSP1CON3bits_t; extern __at(0x0217) volatile __SSP1CON3bits_t SSP1CON3bits; #define _DHEN 0x01 #define _AHEN 0x02 #define _SBCDE 0x04 #define _SDAHT 0x08 #define _BOEN 0x10 #define _SCIE 0x20 #define _PCIE 0x40 #define _ACKTIM 0x80 //============================================================================== //============================================================================== // SSPCON3 Bits extern __at(0x0217) __sfr SSPCON3; typedef struct { unsigned DHEN : 1; unsigned AHEN : 1; unsigned SBCDE : 1; unsigned SDAHT : 1; unsigned BOEN : 1; unsigned SCIE : 1; unsigned PCIE : 1; unsigned ACKTIM : 1; } __SSPCON3bits_t; extern __at(0x0217) volatile __SSPCON3bits_t SSPCON3bits; #define _SSPCON3_DHEN 0x01 #define _SSPCON3_AHEN 0x02 #define _SSPCON3_SBCDE 0x04 #define _SSPCON3_SDAHT 0x08 #define _SSPCON3_BOEN 0x10 #define _SSPCON3_SCIE 0x20 #define _SSPCON3_PCIE 0x40 #define _SSPCON3_ACKTIM 0x80 //============================================================================== //============================================================================== // BORCON Bits extern __at(0x021D) __sfr BORCON; typedef struct { unsigned BORRDY : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned BORFS : 1; unsigned SBOREN : 1; } __BORCONbits_t; extern __at(0x021D) volatile __BORCONbits_t BORCONbits; #define _BORRDY 0x01 #define _BORFS 0x40 #define _SBOREN 0x80 //============================================================================== //============================================================================== // FVRCON Bits extern __at(0x021E) __sfr FVRCON; typedef struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned TSRNG : 1; unsigned TSEN : 1; unsigned FVRRDY : 1; unsigned FVREN : 1; } __FVRCONbits_t; extern __at(0x021E) volatile __FVRCONbits_t FVRCONbits; #define _TSRNG 0x10 #define _TSEN 0x20 #define _FVRRDY 0x40 #define _FVREN 0x80 //============================================================================== //============================================================================== // ZCD1CON Bits extern __at(0x021F) __sfr ZCD1CON; typedef struct { unsigned ZCD1INTN : 1; unsigned ZCD1INTP : 1; unsigned : 1; unsigned : 1; unsigned ZCD1POL : 1; unsigned ZCD1OUT : 1; unsigned : 1; unsigned ZCD1EN : 1; } __ZCD1CONbits_t; extern __at(0x021F) volatile __ZCD1CONbits_t ZCD1CONbits; #define _ZCD1INTN 0x01 #define _ZCD1INTP 0x02 #define _ZCD1POL 0x10 #define _ZCD1OUT 0x20 #define _ZCD1EN 0x80 //============================================================================== //============================================================================== // ODCONA Bits extern __at(0x028C) __sfr ODCONA; typedef struct { unsigned ODA0 : 1; unsigned ODA1 : 1; unsigned ODA2 : 1; unsigned : 1; unsigned ODA4 : 1; unsigned ODA5 : 1; unsigned : 1; unsigned : 1; } __ODCONAbits_t; extern __at(0x028C) volatile __ODCONAbits_t ODCONAbits; #define _ODA0 0x01 #define _ODA1 0x02 #define _ODA2 0x04 #define _ODA4 0x10 #define _ODA5 0x20 //============================================================================== //============================================================================== // ODCONB Bits extern __at(0x028D) __sfr ODCONB; typedef struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned ODB4 : 1; unsigned ODB5 : 1; unsigned ODB6 : 1; unsigned ODB7 : 1; } __ODCONBbits_t; extern __at(0x028D) volatile __ODCONBbits_t ODCONBbits; #define _ODB4 0x10 #define _ODB5 0x20 #define _ODB6 0x40 #define _ODB7 0x80 //============================================================================== //============================================================================== // ODCONC Bits extern __at(0x028E) __sfr ODCONC; typedef struct { unsigned ODC0 : 1; unsigned ODC1 : 1; unsigned ODC2 : 1; unsigned ODC3 : 1; unsigned ODC4 : 1; unsigned ODC5 : 1; unsigned ODC6 : 1; unsigned ODC7 : 1; } __ODCONCbits_t; extern __at(0x028E) volatile __ODCONCbits_t ODCONCbits; #define _ODC0 0x01 #define _ODC1 0x02 #define _ODC2 0x04 #define _ODC3 0x08 #define _ODC4 0x10 #define _ODC5 0x20 #define _ODC6 0x40 #define _ODC7 0x80 //============================================================================== extern __at(0x0291) __sfr CCPR1; extern __at(0x0291) __sfr CCPR1L; extern __at(0x0292) __sfr CCPR1H; //============================================================================== // CCP1CON Bits extern __at(0x0293) __sfr CCP1CON; typedef union { struct { unsigned MODE0 : 1; unsigned MODE1 : 1; unsigned MODE2 : 1; unsigned MODE3 : 1; unsigned FMT : 1; unsigned OUT : 1; unsigned : 1; unsigned EN : 1; }; struct { unsigned CCP1MODE0 : 1; unsigned CCP1MODE1 : 1; unsigned CCP1MODE2 : 1; unsigned CCP1MODE3 : 1; unsigned CCP1FMT : 1; unsigned CCP1OUT : 1; unsigned : 1; unsigned CCP1EN : 1; }; struct { unsigned MODE : 4; unsigned : 4; }; struct { unsigned CCP1MODE : 4; unsigned : 4; }; } __CCP1CONbits_t; extern __at(0x0293) volatile __CCP1CONbits_t CCP1CONbits; #define _MODE0 0x01 #define _CCP1MODE0 0x01 #define _MODE1 0x02 #define _CCP1MODE1 0x02 #define _MODE2 0x04 #define _CCP1MODE2 0x04 #define _MODE3 0x08 #define _CCP1MODE3 0x08 #define _FMT 0x10 #define _CCP1FMT 0x10 #define _OUT 0x20 #define _CCP1OUT 0x20 #define _EN 0x80 #define _CCP1EN 0x80 //============================================================================== //============================================================================== // CCP1CAP Bits extern __at(0x0294) __sfr CCP1CAP; typedef union { struct { unsigned CTS0 : 1; unsigned CTS1 : 1; unsigned CTS2 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned CCP1CTS0 : 1; unsigned CCP1CTS1 : 1; unsigned CCP1CTS2 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned CCP1CTS : 3; unsigned : 5; }; struct { unsigned CTS : 3; unsigned : 5; }; } __CCP1CAPbits_t; extern __at(0x0294) volatile __CCP1CAPbits_t CCP1CAPbits; #define _CTS0 0x01 #define _CCP1CTS0 0x01 #define _CTS1 0x02 #define _CCP1CTS1 0x02 #define _CTS2 0x04 #define _CCP1CTS2 0x04 //============================================================================== extern __at(0x0298) __sfr CCPR2; extern __at(0x0298) __sfr CCPR2L; extern __at(0x0299) __sfr CCPR2H; //============================================================================== // CCP2CON Bits extern __at(0x029A) __sfr CCP2CON; typedef union { struct { unsigned MODE0 : 1; unsigned MODE1 : 1; unsigned MODE2 : 1; unsigned MODE3 : 1; unsigned FMT : 1; unsigned OUT : 1; unsigned : 1; unsigned EN : 1; }; struct { unsigned CCP2MODE0 : 1; unsigned CCP2MODE1 : 1; unsigned CCP2MODE2 : 1; unsigned CCP2MODE3 : 1; unsigned CCP2FMT : 1; unsigned CCP2OUT : 1; unsigned : 1; unsigned CCP2EN : 1; }; struct { unsigned CCP2MODE : 4; unsigned : 4; }; struct { unsigned MODE : 4; unsigned : 4; }; } __CCP2CONbits_t; extern __at(0x029A) volatile __CCP2CONbits_t CCP2CONbits; #define _CCP2CON_MODE0 0x01 #define _CCP2CON_CCP2MODE0 0x01 #define _CCP2CON_MODE1 0x02 #define _CCP2CON_CCP2MODE1 0x02 #define _CCP2CON_MODE2 0x04 #define _CCP2CON_CCP2MODE2 0x04 #define _CCP2CON_MODE3 0x08 #define _CCP2CON_CCP2MODE3 0x08 #define _CCP2CON_FMT 0x10 #define _CCP2CON_CCP2FMT 0x10 #define _CCP2CON_OUT 0x20 #define _CCP2CON_CCP2OUT 0x20 #define _CCP2CON_EN 0x80 #define _CCP2CON_CCP2EN 0x80 //============================================================================== //============================================================================== // CCP2CAP Bits extern __at(0x029B) __sfr CCP2CAP; typedef union { struct { unsigned CTS0 : 1; unsigned CTS1 : 1; unsigned CTS2 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned CCP2CTS0 : 1; unsigned CCP2CTS1 : 1; unsigned CCP2CTS2 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned CCP2CTS : 3; unsigned : 5; }; struct { unsigned CTS : 3; unsigned : 5; }; } __CCP2CAPbits_t; extern __at(0x029B) volatile __CCP2CAPbits_t CCP2CAPbits; #define _CCP2CAP_CTS0 0x01 #define _CCP2CAP_CCP2CTS0 0x01 #define _CCP2CAP_CTS1 0x02 #define _CCP2CAP_CCP2CTS1 0x02 #define _CCP2CAP_CTS2 0x04 #define _CCP2CAP_CCP2CTS2 0x04 //============================================================================== //============================================================================== // CCPTMRS Bits extern __at(0x029E) __sfr CCPTMRS; typedef union { struct { unsigned C1TSEL0 : 1; unsigned C1TSEL1 : 1; unsigned C2TSEL0 : 1; unsigned C2TSEL1 : 1; unsigned P3TSEL0 : 1; unsigned P3TSEL1 : 1; unsigned P4TSEL0 : 1; unsigned P4TSEL1 : 1; }; struct { unsigned C1TSEL : 2; unsigned : 6; }; struct { unsigned : 2; unsigned C2TSEL : 2; unsigned : 4; }; struct { unsigned : 4; unsigned P3TSEL : 2; unsigned : 2; }; struct { unsigned : 6; unsigned P4TSEL : 2; }; } __CCPTMRSbits_t; extern __at(0x029E) volatile __CCPTMRSbits_t CCPTMRSbits; #define _C1TSEL0 0x01 #define _C1TSEL1 0x02 #define _C2TSEL0 0x04 #define _C2TSEL1 0x08 #define _P3TSEL0 0x10 #define _P3TSEL1 0x20 #define _P4TSEL0 0x40 #define _P4TSEL1 0x80 //============================================================================== //============================================================================== // SLRCONA Bits extern __at(0x030C) __sfr SLRCONA; typedef struct { unsigned SLRA0 : 1; unsigned SLRA1 : 1; unsigned SLRA2 : 1; unsigned : 1; unsigned SLRA4 : 1; unsigned SLRA5 : 1; unsigned : 1; unsigned : 1; } __SLRCONAbits_t; extern __at(0x030C) volatile __SLRCONAbits_t SLRCONAbits; #define _SLRA0 0x01 #define _SLRA1 0x02 #define _SLRA2 0x04 #define _SLRA4 0x10 #define _SLRA5 0x20 //============================================================================== //============================================================================== // SLRCONB Bits extern __at(0x030D) __sfr SLRCONB; typedef struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned SLRB4 : 1; unsigned SLRB5 : 1; unsigned SLRB6 : 1; unsigned SLRB7 : 1; } __SLRCONBbits_t; extern __at(0x030D) volatile __SLRCONBbits_t SLRCONBbits; #define _SLRB4 0x10 #define _SLRB5 0x20 #define _SLRB6 0x40 #define _SLRB7 0x80 //============================================================================== //============================================================================== // SLRCONC Bits extern __at(0x030E) __sfr SLRCONC; typedef struct { unsigned SLRC0 : 1; unsigned SLRC1 : 1; unsigned SLRC2 : 1; unsigned SLRC3 : 1; unsigned SLRC4 : 1; unsigned SLRC5 : 1; unsigned SLRC6 : 1; unsigned SLRC7 : 1; } __SLRCONCbits_t; extern __at(0x030E) volatile __SLRCONCbits_t SLRCONCbits; #define _SLRC0 0x01 #define _SLRC1 0x02 #define _SLRC2 0x04 #define _SLRC3 0x08 #define _SLRC4 0x10 #define _SLRC5 0x20 #define _SLRC6 0x40 #define _SLRC7 0x80 //============================================================================== //============================================================================== // MD2CON0 Bits extern __at(0x031B) __sfr MD2CON0; typedef union { struct { unsigned BIT : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned OPOL : 1; unsigned OUT : 1; unsigned : 1; unsigned EN : 1; }; struct { unsigned MD2BIT : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned MD2OPOL : 1; unsigned MD2OUT : 1; unsigned : 1; unsigned MD2EN : 1; }; } __MD2CON0bits_t; extern __at(0x031B) volatile __MD2CON0bits_t MD2CON0bits; #define _MD2CON0_BIT 0x01 #define _MD2CON0_MD2BIT 0x01 #define _MD2CON0_OPOL 0x10 #define _MD2CON0_MD2OPOL 0x10 #define _MD2CON0_OUT 0x20 #define _MD2CON0_MD2OUT 0x20 #define _MD2CON0_EN 0x80 #define _MD2CON0_MD2EN 0x80 //============================================================================== //============================================================================== // MD2CON1 Bits extern __at(0x031C) __sfr MD2CON1; typedef union { struct { unsigned CLSYNC : 1; unsigned CLPOL : 1; unsigned : 1; unsigned : 1; unsigned CHSYNC : 1; unsigned CHPOL : 1; unsigned : 1; unsigned : 1; }; struct { unsigned MD2CLSYNC : 1; unsigned MD2CLPOL : 1; unsigned : 1; unsigned : 1; unsigned MD2CHSYNC : 1; unsigned MD2CHPOL : 1; unsigned : 1; unsigned : 1; }; } __MD2CON1bits_t; extern __at(0x031C) volatile __MD2CON1bits_t MD2CON1bits; #define _MD2CON1_CLSYNC 0x01 #define _MD2CON1_MD2CLSYNC 0x01 #define _MD2CON1_CLPOL 0x02 #define _MD2CON1_MD2CLPOL 0x02 #define _MD2CON1_CHSYNC 0x10 #define _MD2CON1_MD2CHSYNC 0x10 #define _MD2CON1_CHPOL 0x20 #define _MD2CON1_MD2CHPOL 0x20 //============================================================================== //============================================================================== // MD2SRC Bits extern __at(0x031D) __sfr MD2SRC; typedef union { struct { unsigned MS0 : 1; unsigned MS1 : 1; unsigned MS2 : 1; unsigned MS3 : 1; unsigned MS4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned MD2MS0 : 1; unsigned MD2MS1 : 1; unsigned MD2MS2 : 1; unsigned MD2MS3 : 1; unsigned MD2MS4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned MS : 5; unsigned : 3; }; struct { unsigned MD2MS : 5; unsigned : 3; }; } __MD2SRCbits_t; extern __at(0x031D) volatile __MD2SRCbits_t MD2SRCbits; #define _MD2SRC_MS0 0x01 #define _MD2SRC_MD2MS0 0x01 #define _MD2SRC_MS1 0x02 #define _MD2SRC_MD2MS1 0x02 #define _MD2SRC_MS2 0x04 #define _MD2SRC_MD2MS2 0x04 #define _MD2SRC_MS3 0x08 #define _MD2SRC_MD2MS3 0x08 #define _MD2SRC_MS4 0x10 #define _MD2SRC_MD2MS4 0x10 //============================================================================== //============================================================================== // MD2CARL Bits extern __at(0x031E) __sfr MD2CARL; typedef union { struct { unsigned CL0 : 1; unsigned CL1 : 1; unsigned CL2 : 1; unsigned CL3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned MD2CL0 : 1; unsigned MD2CL1 : 1; unsigned MD2CL2 : 1; unsigned MD2CL3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned CL : 4; unsigned : 4; }; struct { unsigned MD2CL : 4; unsigned : 4; }; } __MD2CARLbits_t; extern __at(0x031E) volatile __MD2CARLbits_t MD2CARLbits; #define _MD2CARL_CL0 0x01 #define _MD2CARL_MD2CL0 0x01 #define _MD2CARL_CL1 0x02 #define _MD2CARL_MD2CL1 0x02 #define _MD2CARL_CL2 0x04 #define _MD2CARL_MD2CL2 0x04 #define _MD2CARL_CL3 0x08 #define _MD2CARL_MD2CL3 0x08 //============================================================================== //============================================================================== // MD2CARH Bits extern __at(0x031F) __sfr MD2CARH; typedef union { struct { unsigned CH0 : 1; unsigned CH1 : 1; unsigned CH2 : 1; unsigned CH3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned MD2CH0 : 1; unsigned MD2CH1 : 1; unsigned MD2CH2 : 1; unsigned MD2CH3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned CH : 4; unsigned : 4; }; struct { unsigned MD2CH : 4; unsigned : 4; }; } __MD2CARHbits_t; extern __at(0x031F) volatile __MD2CARHbits_t MD2CARHbits; #define _MD2CARH_CH0 0x01 #define _MD2CARH_MD2CH0 0x01 #define _MD2CARH_CH1 0x02 #define _MD2CARH_MD2CH1 0x02 #define _MD2CARH_CH2 0x04 #define _MD2CARH_MD2CH2 0x04 #define _MD2CARH_CH3 0x08 #define _MD2CARH_MD2CH3 0x08 //============================================================================== //============================================================================== // INLVLA Bits extern __at(0x038C) __sfr INLVLA; typedef union { struct { unsigned INLVLA0 : 1; unsigned INLVLA1 : 1; unsigned INLVLA2 : 1; unsigned INLVLA3 : 1; unsigned INLVLA4 : 1; unsigned INLVLA5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned INLVLA : 6; unsigned : 2; }; } __INLVLAbits_t; extern __at(0x038C) volatile __INLVLAbits_t INLVLAbits; #define _INLVLA0 0x01 #define _INLVLA1 0x02 #define _INLVLA2 0x04 #define _INLVLA3 0x08 #define _INLVLA4 0x10 #define _INLVLA5 0x20 //============================================================================== //============================================================================== // INLVLB Bits extern __at(0x038D) __sfr INLVLB; typedef struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned INLVLB4 : 1; unsigned INLVLB5 : 1; unsigned INLVLB6 : 1; unsigned INLVLB7 : 1; } __INLVLBbits_t; extern __at(0x038D) volatile __INLVLBbits_t INLVLBbits; #define _INLVLB4 0x10 #define _INLVLB5 0x20 #define _INLVLB6 0x40 #define _INLVLB7 0x80 //============================================================================== //============================================================================== // INLVLC Bits extern __at(0x038E) __sfr INLVLC; typedef struct { unsigned INLVLC0 : 1; unsigned INLVLC1 : 1; unsigned INLVLC2 : 1; unsigned INLVLC3 : 1; unsigned INLVLC4 : 1; unsigned INLVLC5 : 1; unsigned INLVLC6 : 1; unsigned INLVLC7 : 1; } __INLVLCbits_t; extern __at(0x038E) volatile __INLVLCbits_t INLVLCbits; #define _INLVLC0 0x01 #define _INLVLC1 0x02 #define _INLVLC2 0x04 #define _INLVLC3 0x08 #define _INLVLC4 0x10 #define _INLVLC5 0x20 #define _INLVLC6 0x40 #define _INLVLC7 0x80 //============================================================================== //============================================================================== // IOCAP Bits extern __at(0x0391) __sfr IOCAP; typedef union { struct { unsigned IOCAP0 : 1; unsigned IOCAP1 : 1; unsigned IOCAP2 : 1; unsigned IOCAP3 : 1; unsigned IOCAP4 : 1; unsigned IOCAP5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned IOCAP : 6; unsigned : 2; }; } __IOCAPbits_t; extern __at(0x0391) volatile __IOCAPbits_t IOCAPbits; #define _IOCAP0 0x01 #define _IOCAP1 0x02 #define _IOCAP2 0x04 #define _IOCAP3 0x08 #define _IOCAP4 0x10 #define _IOCAP5 0x20 //============================================================================== //============================================================================== // IOCAN Bits extern __at(0x0392) __sfr IOCAN; typedef union { struct { unsigned IOCAN0 : 1; unsigned IOCAN1 : 1; unsigned IOCAN2 : 1; unsigned IOCAN3 : 1; unsigned IOCAN4 : 1; unsigned IOCAN5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned IOCAN : 6; unsigned : 2; }; } __IOCANbits_t; extern __at(0x0392) volatile __IOCANbits_t IOCANbits; #define _IOCAN0 0x01 #define _IOCAN1 0x02 #define _IOCAN2 0x04 #define _IOCAN3 0x08 #define _IOCAN4 0x10 #define _IOCAN5 0x20 //============================================================================== //============================================================================== // IOCAF Bits extern __at(0x0393) __sfr IOCAF; typedef union { struct { unsigned IOCAF0 : 1; unsigned IOCAF1 : 1; unsigned IOCAF2 : 1; unsigned IOCAF3 : 1; unsigned IOCAF4 : 1; unsigned IOCAF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned IOCAF : 6; unsigned : 2; }; } __IOCAFbits_t; extern __at(0x0393) volatile __IOCAFbits_t IOCAFbits; #define _IOCAF0 0x01 #define _IOCAF1 0x02 #define _IOCAF2 0x04 #define _IOCAF3 0x08 #define _IOCAF4 0x10 #define _IOCAF5 0x20 //============================================================================== //============================================================================== // IOCBP Bits extern __at(0x0394) __sfr IOCBP; typedef struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned IOCBP4 : 1; unsigned IOCBP5 : 1; unsigned IOCBP6 : 1; unsigned IOCBP7 : 1; } __IOCBPbits_t; extern __at(0x0394) volatile __IOCBPbits_t IOCBPbits; #define _IOCBP4 0x10 #define _IOCBP5 0x20 #define _IOCBP6 0x40 #define _IOCBP7 0x80 //============================================================================== //============================================================================== // IOCBN Bits extern __at(0x0395) __sfr IOCBN; typedef struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned IOCBN4 : 1; unsigned IOCBN5 : 1; unsigned IOCBN6 : 1; unsigned IOCBN7 : 1; } __IOCBNbits_t; extern __at(0x0395) volatile __IOCBNbits_t IOCBNbits; #define _IOCBN4 0x10 #define _IOCBN5 0x20 #define _IOCBN6 0x40 #define _IOCBN7 0x80 //============================================================================== //============================================================================== // IOCBF Bits extern __at(0x0396) __sfr IOCBF; typedef struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned IOCBF4 : 1; unsigned IOCBF5 : 1; unsigned IOCBF6 : 1; unsigned IOCBF7 : 1; } __IOCBFbits_t; extern __at(0x0396) volatile __IOCBFbits_t IOCBFbits; #define _IOCBF4 0x10 #define _IOCBF5 0x20 #define _IOCBF6 0x40 #define _IOCBF7 0x80 //============================================================================== //============================================================================== // IOCCP Bits extern __at(0x0397) __sfr IOCCP; typedef struct { unsigned IOCCP0 : 1; unsigned IOCCP1 : 1; unsigned IOCCP2 : 1; unsigned IOCCP3 : 1; unsigned IOCCP4 : 1; unsigned IOCCP5 : 1; unsigned IOCCP6 : 1; unsigned IOCCP7 : 1; } __IOCCPbits_t; extern __at(0x0397) volatile __IOCCPbits_t IOCCPbits; #define _IOCCP0 0x01 #define _IOCCP1 0x02 #define _IOCCP2 0x04 #define _IOCCP3 0x08 #define _IOCCP4 0x10 #define _IOCCP5 0x20 #define _IOCCP6 0x40 #define _IOCCP7 0x80 //============================================================================== //============================================================================== // IOCCN Bits extern __at(0x0398) __sfr IOCCN; typedef struct { unsigned IOCCN0 : 1; unsigned IOCCN1 : 1; unsigned IOCCN2 : 1; unsigned IOCCN3 : 1; unsigned IOCCN4 : 1; unsigned IOCCN5 : 1; unsigned IOCCN6 : 1; unsigned IOCCN7 : 1; } __IOCCNbits_t; extern __at(0x0398) volatile __IOCCNbits_t IOCCNbits; #define _IOCCN0 0x01 #define _IOCCN1 0x02 #define _IOCCN2 0x04 #define _IOCCN3 0x08 #define _IOCCN4 0x10 #define _IOCCN5 0x20 #define _IOCCN6 0x40 #define _IOCCN7 0x80 //============================================================================== //============================================================================== // IOCCF Bits extern __at(0x0399) __sfr IOCCF; typedef struct { unsigned IOCCF0 : 1; unsigned IOCCF1 : 1; unsigned IOCCF2 : 1; unsigned IOCCF3 : 1; unsigned IOCCF4 : 1; unsigned IOCCF5 : 1; unsigned IOCCF6 : 1; unsigned IOCCF7 : 1; } __IOCCFbits_t; extern __at(0x0399) volatile __IOCCFbits_t IOCCFbits; #define _IOCCF0 0x01 #define _IOCCF1 0x02 #define _IOCCF2 0x04 #define _IOCCF3 0x08 #define _IOCCF4 0x10 #define _IOCCF5 0x20 #define _IOCCF6 0x40 #define _IOCCF7 0x80 //============================================================================== //============================================================================== // MD1CON0 Bits extern __at(0x039B) __sfr MD1CON0; typedef union { struct { unsigned BIT : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned OPOL : 1; unsigned OUT : 1; unsigned : 1; unsigned EN : 1; }; struct { unsigned MD1BIT : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned MD1OPOL : 1; unsigned MD1OUT : 1; unsigned : 1; unsigned MD1EN : 1; }; } __MD1CON0bits_t; extern __at(0x039B) volatile __MD1CON0bits_t MD1CON0bits; #define _MD1CON0_BIT 0x01 #define _MD1CON0_MD1BIT 0x01 #define _MD1CON0_OPOL 0x10 #define _MD1CON0_MD1OPOL 0x10 #define _MD1CON0_OUT 0x20 #define _MD1CON0_MD1OUT 0x20 #define _MD1CON0_EN 0x80 #define _MD1CON0_MD1EN 0x80 //============================================================================== //============================================================================== // MD1CON1 Bits extern __at(0x039C) __sfr MD1CON1; typedef union { struct { unsigned CLSYNC : 1; unsigned CLPOL : 1; unsigned : 1; unsigned : 1; unsigned CHSYNC : 1; unsigned CHPOL : 1; unsigned : 1; unsigned : 1; }; struct { unsigned MD1CLSYNC : 1; unsigned MD1CLPOL : 1; unsigned : 1; unsigned : 1; unsigned MD1CHSYNC : 1; unsigned MD1CHPOL : 1; unsigned : 1; unsigned : 1; }; } __MD1CON1bits_t; extern __at(0x039C) volatile __MD1CON1bits_t MD1CON1bits; #define _CLSYNC 0x01 #define _MD1CLSYNC 0x01 #define _CLPOL 0x02 #define _MD1CLPOL 0x02 #define _CHSYNC 0x10 #define _MD1CHSYNC 0x10 #define _CHPOL 0x20 #define _MD1CHPOL 0x20 //============================================================================== //============================================================================== // MD1SRC Bits extern __at(0x039D) __sfr MD1SRC; typedef union { struct { unsigned MS0 : 1; unsigned MS1 : 1; unsigned MS2 : 1; unsigned MS3 : 1; unsigned MS4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned MD1MS0 : 1; unsigned MD1MS1 : 1; unsigned MD1MS2 : 1; unsigned MD1MS3 : 1; unsigned MD1MS4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned MD1MS : 5; unsigned : 3; }; struct { unsigned MS : 5; unsigned : 3; }; } __MD1SRCbits_t; extern __at(0x039D) volatile __MD1SRCbits_t MD1SRCbits; #define _MS0 0x01 #define _MD1MS0 0x01 #define _MS1 0x02 #define _MD1MS1 0x02 #define _MS2 0x04 #define _MD1MS2 0x04 #define _MS3 0x08 #define _MD1MS3 0x08 #define _MS4 0x10 #define _MD1MS4 0x10 //============================================================================== //============================================================================== // MD1CARL Bits extern __at(0x039E) __sfr MD1CARL; typedef union { struct { unsigned CL0 : 1; unsigned CL1 : 1; unsigned CL2 : 1; unsigned CL3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned MD1CL0 : 1; unsigned MD1CL1 : 1; unsigned MD1CL2 : 1; unsigned MD1CL3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned MD1CL : 4; unsigned : 4; }; struct { unsigned CL : 4; unsigned : 4; }; } __MD1CARLbits_t; extern __at(0x039E) volatile __MD1CARLbits_t MD1CARLbits; #define _CL0 0x01 #define _MD1CL0 0x01 #define _CL1 0x02 #define _MD1CL1 0x02 #define _CL2 0x04 #define _MD1CL2 0x04 #define _CL3 0x08 #define _MD1CL3 0x08 //============================================================================== //============================================================================== // MD1CARH Bits extern __at(0x039F) __sfr MD1CARH; typedef union { struct { unsigned CH0 : 1; unsigned CH1 : 1; unsigned CH2 : 1; unsigned CH3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned MD1CH0 : 1; unsigned MD1CH1 : 1; unsigned MD1CH2 : 1; unsigned MD1CH3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned MD1CH : 4; unsigned : 4; }; struct { unsigned CH : 4; unsigned : 4; }; } __MD1CARHbits_t; extern __at(0x039F) volatile __MD1CARHbits_t MD1CARHbits; #define _CH0 0x01 #define _MD1CH0 0x01 #define _CH1 0x02 #define _MD1CH1 0x02 #define _CH2 0x04 #define _MD1CH2 0x04 #define _CH3 0x08 #define _MD1CH3 0x08 //============================================================================== //============================================================================== // HIDRVC Bits extern __at(0x040E) __sfr HIDRVC; typedef struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned HIDC4 : 1; unsigned HIDC5 : 1; unsigned : 1; unsigned : 1; } __HIDRVCbits_t; extern __at(0x040E) volatile __HIDRVCbits_t HIDRVCbits; #define _HIDC4 0x10 #define _HIDC5 0x20 //============================================================================== extern __at(0x0413) __sfr T4TMR; extern __at(0x0413) __sfr TMR4; extern __at(0x0414) __sfr PR4; extern __at(0x0414) __sfr T4PR; //============================================================================== // T4CON Bits extern __at(0x0415) __sfr T4CON; typedef union { struct { unsigned OUTPS0 : 1; unsigned OUTPS1 : 1; unsigned OUTPS2 : 1; unsigned OUTPS3 : 1; unsigned CKPS0 : 1; unsigned CKPS1 : 1; unsigned CKPS2 : 1; unsigned ON : 1; }; struct { unsigned T4OUTPS0 : 1; unsigned T4OUTPS1 : 1; unsigned T4OUTPS2 : 1; unsigned T4OUTPS3 : 1; unsigned T4CKPS0 : 1; unsigned T4CKPS1 : 1; unsigned T4CKPS2 : 1; unsigned T4ON : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned TMR4ON : 1; }; struct { unsigned T4OUTPS : 4; unsigned : 4; }; struct { unsigned OUTPS : 4; unsigned : 4; }; struct { unsigned : 4; unsigned T4CKPS : 3; unsigned : 1; }; struct { unsigned : 4; unsigned CKPS : 3; unsigned : 1; }; } __T4CONbits_t; extern __at(0x0415) volatile __T4CONbits_t T4CONbits; #define _T4CON_OUTPS0 0x01 #define _T4CON_T4OUTPS0 0x01 #define _T4CON_OUTPS1 0x02 #define _T4CON_T4OUTPS1 0x02 #define _T4CON_OUTPS2 0x04 #define _T4CON_T4OUTPS2 0x04 #define _T4CON_OUTPS3 0x08 #define _T4CON_T4OUTPS3 0x08 #define _T4CON_CKPS0 0x10 #define _T4CON_T4CKPS0 0x10 #define _T4CON_CKPS1 0x20 #define _T4CON_T4CKPS1 0x20 #define _T4CON_CKPS2 0x40 #define _T4CON_T4CKPS2 0x40 #define _T4CON_ON 0x80 #define _T4CON_T4ON 0x80 #define _T4CON_TMR4ON 0x80 //============================================================================== //============================================================================== // T4HLT Bits extern __at(0x0416) __sfr T4HLT; typedef union { struct { unsigned MODE0 : 1; unsigned MODE1 : 1; unsigned MODE2 : 1; unsigned MODE3 : 1; unsigned MODE4 : 1; unsigned CKSYNC : 1; unsigned CKPOL : 1; unsigned PSYNC : 1; }; struct { unsigned T4MODE0 : 1; unsigned T4MODE1 : 1; unsigned T4MODE2 : 1; unsigned T4MODE3 : 1; unsigned T4MODE4 : 1; unsigned T4CKSYNC : 1; unsigned T4CKPOL : 1; unsigned T4PSYNC : 1; }; struct { unsigned MODE : 5; unsigned : 3; }; struct { unsigned T4MODE : 5; unsigned : 3; }; } __T4HLTbits_t; extern __at(0x0416) volatile __T4HLTbits_t T4HLTbits; #define _T4HLT_MODE0 0x01 #define _T4HLT_T4MODE0 0x01 #define _T4HLT_MODE1 0x02 #define _T4HLT_T4MODE1 0x02 #define _T4HLT_MODE2 0x04 #define _T4HLT_T4MODE2 0x04 #define _T4HLT_MODE3 0x08 #define _T4HLT_T4MODE3 0x08 #define _T4HLT_MODE4 0x10 #define _T4HLT_T4MODE4 0x10 #define _T4HLT_CKSYNC 0x20 #define _T4HLT_T4CKSYNC 0x20 #define _T4HLT_CKPOL 0x40 #define _T4HLT_T4CKPOL 0x40 #define _T4HLT_PSYNC 0x80 #define _T4HLT_T4PSYNC 0x80 //============================================================================== //============================================================================== // T4CLKCON Bits extern __at(0x0417) __sfr T4CLKCON; typedef union { struct { unsigned CS0 : 1; unsigned CS1 : 1; unsigned CS2 : 1; unsigned CS3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned T4CS0 : 1; unsigned T4CS1 : 1; unsigned T4CS2 : 1; unsigned T4CS3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned CS : 4; unsigned : 4; }; struct { unsigned T4CS : 4; unsigned : 4; }; } __T4CLKCONbits_t; extern __at(0x0417) volatile __T4CLKCONbits_t T4CLKCONbits; #define _T4CLKCON_CS0 0x01 #define _T4CLKCON_T4CS0 0x01 #define _T4CLKCON_CS1 0x02 #define _T4CLKCON_T4CS1 0x02 #define _T4CLKCON_CS2 0x04 #define _T4CLKCON_T4CS2 0x04 #define _T4CLKCON_CS3 0x08 #define _T4CLKCON_T4CS3 0x08 //============================================================================== //============================================================================== // T4RST Bits extern __at(0x0418) __sfr T4RST; typedef union { struct { unsigned RSEL0 : 1; unsigned RSEL1 : 1; unsigned RSEL2 : 1; unsigned RSEL3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned T4RSEL0 : 1; unsigned T4RSEL1 : 1; unsigned T4RSEL2 : 1; unsigned T4RSEL3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RSEL : 4; unsigned : 4; }; struct { unsigned T4RSEL : 4; unsigned : 4; }; } __T4RSTbits_t; extern __at(0x0418) volatile __T4RSTbits_t T4RSTbits; #define _T4RST_RSEL0 0x01 #define _T4RST_T4RSEL0 0x01 #define _T4RST_RSEL1 0x02 #define _T4RST_T4RSEL1 0x02 #define _T4RST_RSEL2 0x04 #define _T4RST_T4RSEL2 0x04 #define _T4RST_RSEL3 0x08 #define _T4RST_T4RSEL3 0x08 //============================================================================== extern __at(0x041A) __sfr T6TMR; extern __at(0x041A) __sfr TMR6; extern __at(0x041B) __sfr PR6; extern __at(0x041B) __sfr T6PR; //============================================================================== // T6CON Bits extern __at(0x041C) __sfr T6CON; typedef union { struct { unsigned OUTPS0 : 1; unsigned OUTPS1 : 1; unsigned OUTPS2 : 1; unsigned OUTPS3 : 1; unsigned CKPS0 : 1; unsigned CKPS1 : 1; unsigned CKPS2 : 1; unsigned ON : 1; }; struct { unsigned T6OUTPS0 : 1; unsigned T6OUTPS1 : 1; unsigned T6OUTPS2 : 1; unsigned T6OUTPS3 : 1; unsigned T6CKPS0 : 1; unsigned T6CKPS1 : 1; unsigned T6CKPS2 : 1; unsigned T6ON : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned TMR6ON : 1; }; struct { unsigned T6OUTPS : 4; unsigned : 4; }; struct { unsigned OUTPS : 4; unsigned : 4; }; struct { unsigned : 4; unsigned CKPS : 3; unsigned : 1; }; struct { unsigned : 4; unsigned T6CKPS : 3; unsigned : 1; }; } __T6CONbits_t; extern __at(0x041C) volatile __T6CONbits_t T6CONbits; #define _T6CON_OUTPS0 0x01 #define _T6CON_T6OUTPS0 0x01 #define _T6CON_OUTPS1 0x02 #define _T6CON_T6OUTPS1 0x02 #define _T6CON_OUTPS2 0x04 #define _T6CON_T6OUTPS2 0x04 #define _T6CON_OUTPS3 0x08 #define _T6CON_T6OUTPS3 0x08 #define _T6CON_CKPS0 0x10 #define _T6CON_T6CKPS0 0x10 #define _T6CON_CKPS1 0x20 #define _T6CON_T6CKPS1 0x20 #define _T6CON_CKPS2 0x40 #define _T6CON_T6CKPS2 0x40 #define _T6CON_ON 0x80 #define _T6CON_T6ON 0x80 #define _T6CON_TMR6ON 0x80 //============================================================================== //============================================================================== // T6HLT Bits extern __at(0x041D) __sfr T6HLT; typedef union { struct { unsigned MODE0 : 1; unsigned MODE1 : 1; unsigned MODE2 : 1; unsigned MODE3 : 1; unsigned MODE4 : 1; unsigned CKSYNC : 1; unsigned CKPOL : 1; unsigned PSYNC : 1; }; struct { unsigned T6MODE0 : 1; unsigned T6MODE1 : 1; unsigned T6MODE2 : 1; unsigned T6MODE3 : 1; unsigned T6MODE4 : 1; unsigned T6CKSYNC : 1; unsigned T6CKPOL : 1; unsigned T6PSYNC : 1; }; struct { unsigned T6MODE : 5; unsigned : 3; }; struct { unsigned MODE : 5; unsigned : 3; }; } __T6HLTbits_t; extern __at(0x041D) volatile __T6HLTbits_t T6HLTbits; #define _T6HLT_MODE0 0x01 #define _T6HLT_T6MODE0 0x01 #define _T6HLT_MODE1 0x02 #define _T6HLT_T6MODE1 0x02 #define _T6HLT_MODE2 0x04 #define _T6HLT_T6MODE2 0x04 #define _T6HLT_MODE3 0x08 #define _T6HLT_T6MODE3 0x08 #define _T6HLT_MODE4 0x10 #define _T6HLT_T6MODE4 0x10 #define _T6HLT_CKSYNC 0x20 #define _T6HLT_T6CKSYNC 0x20 #define _T6HLT_CKPOL 0x40 #define _T6HLT_T6CKPOL 0x40 #define _T6HLT_PSYNC 0x80 #define _T6HLT_T6PSYNC 0x80 //============================================================================== //============================================================================== // T6CLKCON Bits extern __at(0x041E) __sfr T6CLKCON; typedef union { struct { unsigned CS0 : 1; unsigned CS1 : 1; unsigned CS2 : 1; unsigned CS3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned T6CS0 : 1; unsigned T6CS1 : 1; unsigned T6CS2 : 1; unsigned T6CS3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned CS : 4; unsigned : 4; }; struct { unsigned T6CS : 4; unsigned : 4; }; } __T6CLKCONbits_t; extern __at(0x041E) volatile __T6CLKCONbits_t T6CLKCONbits; #define _T6CLKCON_CS0 0x01 #define _T6CLKCON_T6CS0 0x01 #define _T6CLKCON_CS1 0x02 #define _T6CLKCON_T6CS1 0x02 #define _T6CLKCON_CS2 0x04 #define _T6CLKCON_T6CS2 0x04 #define _T6CLKCON_CS3 0x08 #define _T6CLKCON_T6CS3 0x08 //============================================================================== //============================================================================== // T6RST Bits extern __at(0x041F) __sfr T6RST; typedef union { struct { unsigned RSEL0 : 1; unsigned RSEL1 : 1; unsigned RSEL2 : 1; unsigned RSEL3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned T6RSEL0 : 1; unsigned T6RSEL1 : 1; unsigned T6RSEL2 : 1; unsigned T6RSEL3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RSEL : 4; unsigned : 4; }; struct { unsigned T6RSEL : 4; unsigned : 4; }; } __T6RSTbits_t; extern __at(0x041F) volatile __T6RSTbits_t T6RSTbits; #define _T6RST_RSEL0 0x01 #define _T6RST_T6RSEL0 0x01 #define _T6RST_RSEL1 0x02 #define _T6RST_T6RSEL1 0x02 #define _T6RST_RSEL2 0x04 #define _T6RST_T6RSEL2 0x04 #define _T6RST_RSEL3 0x08 #define _T6RST_T6RSEL3 0x08 //============================================================================== extern __at(0x0493) __sfr TMR3; extern __at(0x0493) __sfr TMR3L; extern __at(0x0494) __sfr TMR3H; //============================================================================== // T3CON Bits extern __at(0x0495) __sfr T3CON; typedef union { struct { unsigned ON : 1; unsigned : 1; unsigned NOT_SYNC : 1; unsigned : 1; unsigned CKPS0 : 1; unsigned CKPS1 : 1; unsigned CS0 : 1; unsigned CS1 : 1; }; struct { unsigned TMRON : 1; unsigned : 1; unsigned SYNC : 1; unsigned : 1; unsigned T3CKPS0 : 1; unsigned T3CKPS1 : 1; unsigned T3CS0 : 1; unsigned T3CS1 : 1; }; struct { unsigned TMR3ON : 1; unsigned : 1; unsigned NOT_T3SYNC : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned TMR3CS0 : 1; unsigned TMR3CS1 : 1; }; struct { unsigned T3ON : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned : 4; unsigned T3CKPS : 2; unsigned : 2; }; struct { unsigned : 4; unsigned CKPS : 2; unsigned : 2; }; struct { unsigned : 6; unsigned CS : 2; }; struct { unsigned : 6; unsigned T3CS : 2; }; struct { unsigned : 6; unsigned TMR3CS : 2; }; } __T3CONbits_t; extern __at(0x0495) volatile __T3CONbits_t T3CONbits; #define _T3CON_ON 0x01 #define _T3CON_TMRON 0x01 #define _T3CON_TMR3ON 0x01 #define _T3CON_T3ON 0x01 #define _T3CON_NOT_SYNC 0x04 #define _T3CON_SYNC 0x04 #define _T3CON_NOT_T3SYNC 0x04 #define _T3CON_CKPS0 0x10 #define _T3CON_T3CKPS0 0x10 #define _T3CON_CKPS1 0x20 #define _T3CON_T3CKPS1 0x20 #define _T3CON_CS0 0x40 #define _T3CON_T3CS0 0x40 #define _T3CON_TMR3CS0 0x40 #define _T3CON_CS1 0x80 #define _T3CON_T3CS1 0x80 #define _T3CON_TMR3CS1 0x80 //============================================================================== //============================================================================== // T3GCON Bits extern __at(0x0496) __sfr T3GCON; typedef union { struct { unsigned GSS0 : 1; unsigned GSS1 : 1; unsigned GVAL : 1; unsigned GGO_NOT_DONE : 1; unsigned GSPM : 1; unsigned GTM : 1; unsigned GPOL : 1; unsigned GE : 1; }; struct { unsigned T3GSS0 : 1; unsigned T3GSS1 : 1; unsigned T3GVAL : 1; unsigned T3GGO_NOT_DONE : 1; unsigned T3GSPM : 1; unsigned T3GTM : 1; unsigned T3GPOL : 1; unsigned T3GE : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned TMR3GE : 1; }; struct { unsigned T3GSS : 2; unsigned : 6; }; struct { unsigned GSS : 2; unsigned : 6; }; } __T3GCONbits_t; extern __at(0x0496) volatile __T3GCONbits_t T3GCONbits; #define _T3GCON_GSS0 0x01 #define _T3GCON_T3GSS0 0x01 #define _T3GCON_GSS1 0x02 #define _T3GCON_T3GSS1 0x02 #define _T3GCON_GVAL 0x04 #define _T3GCON_T3GVAL 0x04 #define _T3GCON_GGO_NOT_DONE 0x08 #define _T3GCON_T3GGO_NOT_DONE 0x08 #define _T3GCON_GSPM 0x10 #define _T3GCON_T3GSPM 0x10 #define _T3GCON_GTM 0x20 #define _T3GCON_T3GTM 0x20 #define _T3GCON_GPOL 0x40 #define _T3GCON_T3GPOL 0x40 #define _T3GCON_GE 0x80 #define _T3GCON_T3GE 0x80 #define _T3GCON_TMR3GE 0x80 //============================================================================== extern __at(0x049A) __sfr TMR5; extern __at(0x049A) __sfr TMR5L; extern __at(0x049B) __sfr TMR5H; //============================================================================== // T5CON Bits extern __at(0x049C) __sfr T5CON; typedef union { struct { unsigned ON : 1; unsigned : 1; unsigned NOT_SYNC : 1; unsigned : 1; unsigned CKPS0 : 1; unsigned CKPS1 : 1; unsigned CS0 : 1; unsigned CS1 : 1; }; struct { unsigned TMRON : 1; unsigned : 1; unsigned SYNC : 1; unsigned : 1; unsigned T5CKPS0 : 1; unsigned T5CKPS1 : 1; unsigned T5CS0 : 1; unsigned T5CS1 : 1; }; struct { unsigned TMR5ON : 1; unsigned : 1; unsigned NOT_T5SYNC : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned TMR5CS0 : 1; unsigned TMR5CS1 : 1; }; struct { unsigned T5ON : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned : 4; unsigned CKPS : 2; unsigned : 2; }; struct { unsigned : 4; unsigned T5CKPS : 2; unsigned : 2; }; struct { unsigned : 6; unsigned T5CS : 2; }; struct { unsigned : 6; unsigned TMR5CS : 2; }; struct { unsigned : 6; unsigned CS : 2; }; } __T5CONbits_t; extern __at(0x049C) volatile __T5CONbits_t T5CONbits; #define _T5CON_ON 0x01 #define _T5CON_TMRON 0x01 #define _T5CON_TMR5ON 0x01 #define _T5CON_T5ON 0x01 #define _T5CON_NOT_SYNC 0x04 #define _T5CON_SYNC 0x04 #define _T5CON_NOT_T5SYNC 0x04 #define _T5CON_CKPS0 0x10 #define _T5CON_T5CKPS0 0x10 #define _T5CON_CKPS1 0x20 #define _T5CON_T5CKPS1 0x20 #define _T5CON_CS0 0x40 #define _T5CON_T5CS0 0x40 #define _T5CON_TMR5CS0 0x40 #define _T5CON_CS1 0x80 #define _T5CON_T5CS1 0x80 #define _T5CON_TMR5CS1 0x80 //============================================================================== //============================================================================== // T5GCON Bits extern __at(0x049D) __sfr T5GCON; typedef union { struct { unsigned GSS0 : 1; unsigned GSS1 : 1; unsigned GVAL : 1; unsigned GGO_NOT_DONE : 1; unsigned GSPM : 1; unsigned GTM : 1; unsigned GPOL : 1; unsigned GE : 1; }; struct { unsigned T5GSS0 : 1; unsigned T5GSS1 : 1; unsigned T5GVAL : 1; unsigned T5GGO_NOT_DONE : 1; unsigned T5GSPM : 1; unsigned T5GTM : 1; unsigned T5GPOL : 1; unsigned T5GE : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned TMR5GE : 1; }; struct { unsigned T5GSS : 2; unsigned : 6; }; struct { unsigned GSS : 2; unsigned : 6; }; } __T5GCONbits_t; extern __at(0x049D) volatile __T5GCONbits_t T5GCONbits; #define _T5GCON_GSS0 0x01 #define _T5GCON_T5GSS0 0x01 #define _T5GCON_GSS1 0x02 #define _T5GCON_T5GSS1 0x02 #define _T5GCON_GVAL 0x04 #define _T5GCON_T5GVAL 0x04 #define _T5GCON_GGO_NOT_DONE 0x08 #define _T5GCON_T5GGO_NOT_DONE 0x08 #define _T5GCON_GSPM 0x10 #define _T5GCON_T5GSPM 0x10 #define _T5GCON_GTM 0x20 #define _T5GCON_T5GTM 0x20 #define _T5GCON_GPOL 0x40 #define _T5GCON_T5GPOL 0x40 #define _T5GCON_GE 0x80 #define _T5GCON_T5GE 0x80 #define _T5GCON_TMR5GE 0x80 //============================================================================== extern __at(0x050F) __sfr OPA1NCHS; extern __at(0x0510) __sfr OPA1PCHS; //============================================================================== // OPA1CON Bits extern __at(0x0511) __sfr OPA1CON; typedef union { struct { unsigned ORM0 : 1; unsigned ORM1 : 1; unsigned ORPOL : 1; unsigned : 1; unsigned UG : 1; unsigned : 1; unsigned : 1; unsigned EN : 1; }; struct { unsigned OPA1ORM0 : 1; unsigned OPA1ORM1 : 1; unsigned OPA1ORPOL : 1; unsigned : 1; unsigned OPA1UG : 1; unsigned : 1; unsigned : 1; unsigned OPA1EN : 1; }; struct { unsigned ORM : 2; unsigned : 6; }; struct { unsigned OPA1ORM : 2; unsigned : 6; }; } __OPA1CONbits_t; extern __at(0x0511) volatile __OPA1CONbits_t OPA1CONbits; #define _OPA1CON_ORM0 0x01 #define _OPA1CON_OPA1ORM0 0x01 #define _OPA1CON_ORM1 0x02 #define _OPA1CON_OPA1ORM1 0x02 #define _OPA1CON_ORPOL 0x04 #define _OPA1CON_OPA1ORPOL 0x04 #define _OPA1CON_UG 0x10 #define _OPA1CON_OPA1UG 0x10 #define _OPA1CON_EN 0x80 #define _OPA1CON_OPA1EN 0x80 //============================================================================== extern __at(0x0512) __sfr OPA1ORS; extern __at(0x0513) __sfr OPA2NCHS; extern __at(0x0514) __sfr OPA2PCHS; //============================================================================== // OPA2CON Bits extern __at(0x0515) __sfr OPA2CON; typedef union { struct { unsigned ORM0 : 1; unsigned ORM1 : 1; unsigned ORPOL : 1; unsigned : 1; unsigned UG : 1; unsigned : 1; unsigned : 1; unsigned EN : 1; }; struct { unsigned OPA2ORM0 : 1; unsigned OPA2ORM1 : 1; unsigned OPA2ORPOL : 1; unsigned : 1; unsigned OPA2UG : 1; unsigned : 1; unsigned : 1; unsigned OPA2EN : 1; }; struct { unsigned OPA2ORM : 2; unsigned : 6; }; struct { unsigned ORM : 2; unsigned : 6; }; } __OPA2CONbits_t; extern __at(0x0515) volatile __OPA2CONbits_t OPA2CONbits; #define _OPA2CON_ORM0 0x01 #define _OPA2CON_OPA2ORM0 0x01 #define _OPA2CON_ORM1 0x02 #define _OPA2CON_OPA2ORM1 0x02 #define _OPA2CON_ORPOL 0x04 #define _OPA2CON_OPA2ORPOL 0x04 #define _OPA2CON_UG 0x10 #define _OPA2CON_OPA2UG 0x10 #define _OPA2CON_EN 0x80 #define _OPA2CON_OPA2EN 0x80 //============================================================================== extern __at(0x0516) __sfr OPA2ORS; //============================================================================== // DACLD Bits extern __at(0x0590) __sfr DACLD; typedef struct { unsigned DAC1LD : 1; unsigned DAC2LD : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; } __DACLDbits_t; extern __at(0x0590) volatile __DACLDbits_t DACLDbits; #define _DAC1LD 0x01 #define _DAC2LD 0x02 //============================================================================== //============================================================================== // DAC1CON0 Bits extern __at(0x0591) __sfr DAC1CON0; typedef union { struct { unsigned NSS0 : 1; unsigned : 1; unsigned PSS0 : 1; unsigned PSS1 : 1; unsigned : 1; unsigned OE1 : 1; unsigned FM : 1; unsigned EN : 1; }; struct { unsigned DACNSS0 : 1; unsigned : 1; unsigned DACPSS0 : 1; unsigned DACPSS1 : 1; unsigned : 1; unsigned OE : 1; unsigned DACFM : 1; unsigned DACEN : 1; }; struct { unsigned DAC1NSS0 : 1; unsigned : 1; unsigned DAC1PSS0 : 1; unsigned DAC1PSS1 : 1; unsigned : 1; unsigned DACOE1 : 1; unsigned DAC1FM : 1; unsigned DAC1EN : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned DACOE : 1; unsigned : 1; unsigned : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned DAC1OE1 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned : 2; unsigned PSS : 2; unsigned : 4; }; struct { unsigned : 2; unsigned DACPSS : 2; unsigned : 4; }; struct { unsigned : 2; unsigned DAC1PSS : 2; unsigned : 4; }; } __DAC1CON0bits_t; extern __at(0x0591) volatile __DAC1CON0bits_t DAC1CON0bits; #define _DAC1CON0_NSS0 0x01 #define _DAC1CON0_DACNSS0 0x01 #define _DAC1CON0_DAC1NSS0 0x01 #define _DAC1CON0_PSS0 0x04 #define _DAC1CON0_DACPSS0 0x04 #define _DAC1CON0_DAC1PSS0 0x04 #define _DAC1CON0_PSS1 0x08 #define _DAC1CON0_DACPSS1 0x08 #define _DAC1CON0_DAC1PSS1 0x08 #define _DAC1CON0_OE1 0x20 #define _DAC1CON0_OE 0x20 #define _DAC1CON0_DACOE1 0x20 #define _DAC1CON0_DACOE 0x20 #define _DAC1CON0_DAC1OE1 0x20 #define _DAC1CON0_FM 0x40 #define _DAC1CON0_DACFM 0x40 #define _DAC1CON0_DAC1FM 0x40 #define _DAC1CON0_EN 0x80 #define _DAC1CON0_DACEN 0x80 #define _DAC1CON0_DAC1EN 0x80 //============================================================================== //============================================================================== // DAC1CON1 Bits extern __at(0x0592) __sfr DAC1CON1; typedef union { struct { unsigned REF0 : 1; unsigned REF1 : 1; unsigned REF2 : 1; unsigned REF3 : 1; unsigned REF4 : 1; unsigned REF5 : 1; unsigned REF6 : 1; unsigned REF7 : 1; }; struct { unsigned DAC1REF0 : 1; unsigned DAC1REF1 : 1; unsigned DAC1REF2 : 1; unsigned DAC1REF3 : 1; unsigned DAC1REF4 : 1; unsigned DAC1REF5 : 1; unsigned DAC1REF6 : 1; unsigned DAC1REF7 : 1; }; struct { unsigned R0 : 1; unsigned R1 : 1; unsigned R2 : 1; unsigned R3 : 1; unsigned R4 : 1; unsigned R5 : 1; unsigned R6 : 1; unsigned R7 : 1; }; struct { unsigned DAC1R0 : 1; unsigned DAC1R1 : 1; unsigned DAC1R2 : 1; unsigned DAC1R3 : 1; unsigned DAC1R4 : 1; unsigned DAC1R5 : 1; unsigned DAC1R6 : 1; unsigned DAC1R7 : 1; }; } __DAC1CON1bits_t; extern __at(0x0592) volatile __DAC1CON1bits_t DAC1CON1bits; #define _REF0 0x01 #define _DAC1REF0 0x01 #define _R0 0x01 #define _DAC1R0 0x01 #define _REF1 0x02 #define _DAC1REF1 0x02 #define _R1 0x02 #define _DAC1R1 0x02 #define _REF2 0x04 #define _DAC1REF2 0x04 #define _R2 0x04 #define _DAC1R2 0x04 #define _REF3 0x08 #define _DAC1REF3 0x08 #define _R3 0x08 #define _DAC1R3 0x08 #define _REF4 0x10 #define _DAC1REF4 0x10 #define _R4 0x10 #define _DAC1R4 0x10 #define _REF5 0x20 #define _DAC1REF5 0x20 #define _R5 0x20 #define _DAC1R5 0x20 #define _REF6 0x40 #define _DAC1REF6 0x40 #define _R6 0x40 #define _DAC1R6 0x40 #define _REF7 0x80 #define _DAC1REF7 0x80 #define _R7 0x80 #define _DAC1R7 0x80 //============================================================================== extern __at(0x0592) __sfr DAC1REF; //============================================================================== // DAC1REFL Bits extern __at(0x0592) __sfr DAC1REFL; typedef union { struct { unsigned REF0 : 1; unsigned REF1 : 1; unsigned REF2 : 1; unsigned REF3 : 1; unsigned REF4 : 1; unsigned REF5 : 1; unsigned REF6 : 1; unsigned REF7 : 1; }; struct { unsigned DAC1REF0 : 1; unsigned DAC1REF1 : 1; unsigned DAC1REF2 : 1; unsigned DAC1REF3 : 1; unsigned DAC1REF4 : 1; unsigned DAC1REF5 : 1; unsigned DAC1REF6 : 1; unsigned DAC1REF7 : 1; }; struct { unsigned R0 : 1; unsigned R1 : 1; unsigned R2 : 1; unsigned R3 : 1; unsigned R4 : 1; unsigned R5 : 1; unsigned R6 : 1; unsigned R7 : 1; }; struct { unsigned DAC1R0 : 1; unsigned DAC1R1 : 1; unsigned DAC1R2 : 1; unsigned DAC1R3 : 1; unsigned DAC1R4 : 1; unsigned DAC1R5 : 1; unsigned DAC1R6 : 1; unsigned DAC1R7 : 1; }; } __DAC1REFLbits_t; extern __at(0x0592) volatile __DAC1REFLbits_t DAC1REFLbits; #define _DAC1REFL_REF0 0x01 #define _DAC1REFL_DAC1REF0 0x01 #define _DAC1REFL_R0 0x01 #define _DAC1REFL_DAC1R0 0x01 #define _DAC1REFL_REF1 0x02 #define _DAC1REFL_DAC1REF1 0x02 #define _DAC1REFL_R1 0x02 #define _DAC1REFL_DAC1R1 0x02 #define _DAC1REFL_REF2 0x04 #define _DAC1REFL_DAC1REF2 0x04 #define _DAC1REFL_R2 0x04 #define _DAC1REFL_DAC1R2 0x04 #define _DAC1REFL_REF3 0x08 #define _DAC1REFL_DAC1REF3 0x08 #define _DAC1REFL_R3 0x08 #define _DAC1REFL_DAC1R3 0x08 #define _DAC1REFL_REF4 0x10 #define _DAC1REFL_DAC1REF4 0x10 #define _DAC1REFL_R4 0x10 #define _DAC1REFL_DAC1R4 0x10 #define _DAC1REFL_REF5 0x20 #define _DAC1REFL_DAC1REF5 0x20 #define _DAC1REFL_R5 0x20 #define _DAC1REFL_DAC1R5 0x20 #define _DAC1REFL_REF6 0x40 #define _DAC1REFL_DAC1REF6 0x40 #define _DAC1REFL_R6 0x40 #define _DAC1REFL_DAC1R6 0x40 #define _DAC1REFL_REF7 0x80 #define _DAC1REFL_DAC1REF7 0x80 #define _DAC1REFL_R7 0x80 #define _DAC1REFL_DAC1R7 0x80 //============================================================================== //============================================================================== // DAC1CON2 Bits extern __at(0x0593) __sfr DAC1CON2; typedef union { struct { unsigned REF8 : 1; unsigned REF9 : 1; unsigned REF10 : 1; unsigned REF11 : 1; unsigned REF12 : 1; unsigned REF13 : 1; unsigned REF14 : 1; unsigned REF15 : 1; }; struct { unsigned DAC1REF8 : 1; unsigned DAC1REF9 : 1; unsigned DAC1REF10 : 1; unsigned DAC1REF11 : 1; unsigned DAC1REF12 : 1; unsigned DAC1REF13 : 1; unsigned DAC1REF14 : 1; unsigned DAC1REF15 : 1; }; struct { unsigned R8 : 1; unsigned R9 : 1; unsigned R10 : 1; unsigned R11 : 1; unsigned R12 : 1; unsigned R13 : 1; unsigned R14 : 1; unsigned R15 : 1; }; struct { unsigned DAC1R8 : 1; unsigned DAC1R9 : 1; unsigned DAC1R10 : 1; unsigned DAC1R11 : 1; unsigned DAC1R12 : 1; unsigned DAC1R13 : 1; unsigned DAC1R14 : 1; unsigned DAC1R15 : 1; }; } __DAC1CON2bits_t; extern __at(0x0593) volatile __DAC1CON2bits_t DAC1CON2bits; #define _REF8 0x01 #define _DAC1REF8 0x01 #define _R8 0x01 #define _DAC1R8 0x01 #define _REF9 0x02 #define _DAC1REF9 0x02 #define _R9 0x02 #define _DAC1R9 0x02 #define _REF10 0x04 #define _DAC1REF10 0x04 #define _R10 0x04 #define _DAC1R10 0x04 #define _REF11 0x08 #define _DAC1REF11 0x08 #define _R11 0x08 #define _DAC1R11 0x08 #define _REF12 0x10 #define _DAC1REF12 0x10 #define _R12 0x10 #define _DAC1R12 0x10 #define _REF13 0x20 #define _DAC1REF13 0x20 #define _R13 0x20 #define _DAC1R13 0x20 #define _REF14 0x40 #define _DAC1REF14 0x40 #define _R14 0x40 #define _DAC1R14 0x40 #define _REF15 0x80 #define _DAC1REF15 0x80 #define _R15 0x80 #define _DAC1R15 0x80 //============================================================================== //============================================================================== // DAC1REFH Bits extern __at(0x0593) __sfr DAC1REFH; typedef union { struct { unsigned REF8 : 1; unsigned REF9 : 1; unsigned REF10 : 1; unsigned REF11 : 1; unsigned REF12 : 1; unsigned REF13 : 1; unsigned REF14 : 1; unsigned REF15 : 1; }; struct { unsigned DAC1REF8 : 1; unsigned DAC1REF9 : 1; unsigned DAC1REF10 : 1; unsigned DAC1REF11 : 1; unsigned DAC1REF12 : 1; unsigned DAC1REF13 : 1; unsigned DAC1REF14 : 1; unsigned DAC1REF15 : 1; }; struct { unsigned R8 : 1; unsigned R9 : 1; unsigned R10 : 1; unsigned R11 : 1; unsigned R12 : 1; unsigned R13 : 1; unsigned R14 : 1; unsigned R15 : 1; }; struct { unsigned DAC1R8 : 1; unsigned DAC1R9 : 1; unsigned DAC1R10 : 1; unsigned DAC1R11 : 1; unsigned DAC1R12 : 1; unsigned DAC1R13 : 1; unsigned DAC1R14 : 1; unsigned DAC1R15 : 1; }; } __DAC1REFHbits_t; extern __at(0x0593) volatile __DAC1REFHbits_t DAC1REFHbits; #define _DAC1REFH_REF8 0x01 #define _DAC1REFH_DAC1REF8 0x01 #define _DAC1REFH_R8 0x01 #define _DAC1REFH_DAC1R8 0x01 #define _DAC1REFH_REF9 0x02 #define _DAC1REFH_DAC1REF9 0x02 #define _DAC1REFH_R9 0x02 #define _DAC1REFH_DAC1R9 0x02 #define _DAC1REFH_REF10 0x04 #define _DAC1REFH_DAC1REF10 0x04 #define _DAC1REFH_R10 0x04 #define _DAC1REFH_DAC1R10 0x04 #define _DAC1REFH_REF11 0x08 #define _DAC1REFH_DAC1REF11 0x08 #define _DAC1REFH_R11 0x08 #define _DAC1REFH_DAC1R11 0x08 #define _DAC1REFH_REF12 0x10 #define _DAC1REFH_DAC1REF12 0x10 #define _DAC1REFH_R12 0x10 #define _DAC1REFH_DAC1R12 0x10 #define _DAC1REFH_REF13 0x20 #define _DAC1REFH_DAC1REF13 0x20 #define _DAC1REFH_R13 0x20 #define _DAC1REFH_DAC1R13 0x20 #define _DAC1REFH_REF14 0x40 #define _DAC1REFH_DAC1REF14 0x40 #define _DAC1REFH_R14 0x40 #define _DAC1REFH_DAC1R14 0x40 #define _DAC1REFH_REF15 0x80 #define _DAC1REFH_DAC1REF15 0x80 #define _DAC1REFH_R15 0x80 #define _DAC1REFH_DAC1R15 0x80 //============================================================================== //============================================================================== // DAC2CON0 Bits extern __at(0x0594) __sfr DAC2CON0; typedef union { struct { unsigned NSS0 : 1; unsigned : 1; unsigned PSS0 : 1; unsigned PSS1 : 1; unsigned : 1; unsigned OE1 : 1; unsigned FM : 1; unsigned EN : 1; }; struct { unsigned DACNSS0 : 1; unsigned : 1; unsigned DACPSS0 : 1; unsigned DACPSS1 : 1; unsigned : 1; unsigned OE : 1; unsigned DACFM : 1; unsigned DACEN : 1; }; struct { unsigned DAC2NSS0 : 1; unsigned : 1; unsigned DAC2PSS0 : 1; unsigned DAC2PSS1 : 1; unsigned : 1; unsigned DACOE1 : 1; unsigned DAC2FM : 1; unsigned DAC2EN : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned DACOE : 1; unsigned : 1; unsigned : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned DAC2OE1 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned : 2; unsigned PSS : 2; unsigned : 4; }; struct { unsigned : 2; unsigned DAC2PSS : 2; unsigned : 4; }; struct { unsigned : 2; unsigned DACPSS : 2; unsigned : 4; }; } __DAC2CON0bits_t; extern __at(0x0594) volatile __DAC2CON0bits_t DAC2CON0bits; #define _DAC2CON0_NSS0 0x01 #define _DAC2CON0_DACNSS0 0x01 #define _DAC2CON0_DAC2NSS0 0x01 #define _DAC2CON0_PSS0 0x04 #define _DAC2CON0_DACPSS0 0x04 #define _DAC2CON0_DAC2PSS0 0x04 #define _DAC2CON0_PSS1 0x08 #define _DAC2CON0_DACPSS1 0x08 #define _DAC2CON0_DAC2PSS1 0x08 #define _DAC2CON0_OE1 0x20 #define _DAC2CON0_OE 0x20 #define _DAC2CON0_DACOE1 0x20 #define _DAC2CON0_DACOE 0x20 #define _DAC2CON0_DAC2OE1 0x20 #define _DAC2CON0_FM 0x40 #define _DAC2CON0_DACFM 0x40 #define _DAC2CON0_DAC2FM 0x40 #define _DAC2CON0_EN 0x80 #define _DAC2CON0_DACEN 0x80 #define _DAC2CON0_DAC2EN 0x80 //============================================================================== //============================================================================== // DAC2CON1 Bits extern __at(0x0595) __sfr DAC2CON1; typedef union { struct { unsigned REF0 : 1; unsigned REF1 : 1; unsigned REF2 : 1; unsigned REF3 : 1; unsigned REF4 : 1; unsigned REF5 : 1; unsigned REF6 : 1; unsigned REF7 : 1; }; struct { unsigned DAC2REF0 : 1; unsigned DAC2REF1 : 1; unsigned DAC2REF2 : 1; unsigned DAC2REF3 : 1; unsigned DAC2REF4 : 1; unsigned DAC2REF5 : 1; unsigned DAC2REF6 : 1; unsigned DAC2REF7 : 1; }; struct { unsigned R0 : 1; unsigned R1 : 1; unsigned R2 : 1; unsigned R3 : 1; unsigned R4 : 1; unsigned R5 : 1; unsigned R6 : 1; unsigned R7 : 1; }; struct { unsigned DAC2R0 : 1; unsigned DAC2R1 : 1; unsigned DAC2R2 : 1; unsigned DAC2R3 : 1; unsigned DAC2R4 : 1; unsigned DAC2R5 : 1; unsigned DAC2R6 : 1; unsigned DAC2R7 : 1; }; } __DAC2CON1bits_t; extern __at(0x0595) volatile __DAC2CON1bits_t DAC2CON1bits; #define _DAC2CON1_REF0 0x01 #define _DAC2CON1_DAC2REF0 0x01 #define _DAC2CON1_R0 0x01 #define _DAC2CON1_DAC2R0 0x01 #define _DAC2CON1_REF1 0x02 #define _DAC2CON1_DAC2REF1 0x02 #define _DAC2CON1_R1 0x02 #define _DAC2CON1_DAC2R1 0x02 #define _DAC2CON1_REF2 0x04 #define _DAC2CON1_DAC2REF2 0x04 #define _DAC2CON1_R2 0x04 #define _DAC2CON1_DAC2R2 0x04 #define _DAC2CON1_REF3 0x08 #define _DAC2CON1_DAC2REF3 0x08 #define _DAC2CON1_R3 0x08 #define _DAC2CON1_DAC2R3 0x08 #define _DAC2CON1_REF4 0x10 #define _DAC2CON1_DAC2REF4 0x10 #define _DAC2CON1_R4 0x10 #define _DAC2CON1_DAC2R4 0x10 #define _DAC2CON1_REF5 0x20 #define _DAC2CON1_DAC2REF5 0x20 #define _DAC2CON1_R5 0x20 #define _DAC2CON1_DAC2R5 0x20 #define _DAC2CON1_REF6 0x40 #define _DAC2CON1_DAC2REF6 0x40 #define _DAC2CON1_R6 0x40 #define _DAC2CON1_DAC2R6 0x40 #define _DAC2CON1_REF7 0x80 #define _DAC2CON1_DAC2REF7 0x80 #define _DAC2CON1_R7 0x80 #define _DAC2CON1_DAC2R7 0x80 //============================================================================== extern __at(0x0595) __sfr DAC2REF; //============================================================================== // DAC2REFL Bits extern __at(0x0595) __sfr DAC2REFL; typedef union { struct { unsigned REF0 : 1; unsigned REF1 : 1; unsigned REF2 : 1; unsigned REF3 : 1; unsigned REF4 : 1; unsigned REF5 : 1; unsigned REF6 : 1; unsigned REF7 : 1; }; struct { unsigned DAC2REF0 : 1; unsigned DAC2REF1 : 1; unsigned DAC2REF2 : 1; unsigned DAC2REF3 : 1; unsigned DAC2REF4 : 1; unsigned DAC2REF5 : 1; unsigned DAC2REF6 : 1; unsigned DAC2REF7 : 1; }; struct { unsigned R0 : 1; unsigned R1 : 1; unsigned R2 : 1; unsigned R3 : 1; unsigned R4 : 1; unsigned R5 : 1; unsigned R6 : 1; unsigned R7 : 1; }; struct { unsigned DAC2R0 : 1; unsigned DAC2R1 : 1; unsigned DAC2R2 : 1; unsigned DAC2R3 : 1; unsigned DAC2R4 : 1; unsigned DAC2R5 : 1; unsigned DAC2R6 : 1; unsigned DAC2R7 : 1; }; } __DAC2REFLbits_t; extern __at(0x0595) volatile __DAC2REFLbits_t DAC2REFLbits; #define _DAC2REFL_REF0 0x01 #define _DAC2REFL_DAC2REF0 0x01 #define _DAC2REFL_R0 0x01 #define _DAC2REFL_DAC2R0 0x01 #define _DAC2REFL_REF1 0x02 #define _DAC2REFL_DAC2REF1 0x02 #define _DAC2REFL_R1 0x02 #define _DAC2REFL_DAC2R1 0x02 #define _DAC2REFL_REF2 0x04 #define _DAC2REFL_DAC2REF2 0x04 #define _DAC2REFL_R2 0x04 #define _DAC2REFL_DAC2R2 0x04 #define _DAC2REFL_REF3 0x08 #define _DAC2REFL_DAC2REF3 0x08 #define _DAC2REFL_R3 0x08 #define _DAC2REFL_DAC2R3 0x08 #define _DAC2REFL_REF4 0x10 #define _DAC2REFL_DAC2REF4 0x10 #define _DAC2REFL_R4 0x10 #define _DAC2REFL_DAC2R4 0x10 #define _DAC2REFL_REF5 0x20 #define _DAC2REFL_DAC2REF5 0x20 #define _DAC2REFL_R5 0x20 #define _DAC2REFL_DAC2R5 0x20 #define _DAC2REFL_REF6 0x40 #define _DAC2REFL_DAC2REF6 0x40 #define _DAC2REFL_R6 0x40 #define _DAC2REFL_DAC2R6 0x40 #define _DAC2REFL_REF7 0x80 #define _DAC2REFL_DAC2REF7 0x80 #define _DAC2REFL_R7 0x80 #define _DAC2REFL_DAC2R7 0x80 //============================================================================== //============================================================================== // DAC2CON2 Bits extern __at(0x0596) __sfr DAC2CON2; typedef union { struct { unsigned REF8 : 1; unsigned REF9 : 1; unsigned REF10 : 1; unsigned REF11 : 1; unsigned REF12 : 1; unsigned REF13 : 1; unsigned REF14 : 1; unsigned REF15 : 1; }; struct { unsigned DAC2REF8 : 1; unsigned DAC2REF9 : 1; unsigned DAC2REF10 : 1; unsigned DAC2REF11 : 1; unsigned DAC2REF12 : 1; unsigned DAC2REF13 : 1; unsigned DAC2REF14 : 1; unsigned DAC2REF15 : 1; }; struct { unsigned R8 : 1; unsigned R9 : 1; unsigned R10 : 1; unsigned R11 : 1; unsigned R12 : 1; unsigned R13 : 1; unsigned R14 : 1; unsigned R15 : 1; }; struct { unsigned DAC2R8 : 1; unsigned DAC2R9 : 1; unsigned DAC2R10 : 1; unsigned DAC2R11 : 1; unsigned DAC2R12 : 1; unsigned DAC2R13 : 1; unsigned DAC2R14 : 1; unsigned DAC2R15 : 1; }; } __DAC2CON2bits_t; extern __at(0x0596) volatile __DAC2CON2bits_t DAC2CON2bits; #define _DAC2CON2_REF8 0x01 #define _DAC2CON2_DAC2REF8 0x01 #define _DAC2CON2_R8 0x01 #define _DAC2CON2_DAC2R8 0x01 #define _DAC2CON2_REF9 0x02 #define _DAC2CON2_DAC2REF9 0x02 #define _DAC2CON2_R9 0x02 #define _DAC2CON2_DAC2R9 0x02 #define _DAC2CON2_REF10 0x04 #define _DAC2CON2_DAC2REF10 0x04 #define _DAC2CON2_R10 0x04 #define _DAC2CON2_DAC2R10 0x04 #define _DAC2CON2_REF11 0x08 #define _DAC2CON2_DAC2REF11 0x08 #define _DAC2CON2_R11 0x08 #define _DAC2CON2_DAC2R11 0x08 #define _DAC2CON2_REF12 0x10 #define _DAC2CON2_DAC2REF12 0x10 #define _DAC2CON2_R12 0x10 #define _DAC2CON2_DAC2R12 0x10 #define _DAC2CON2_REF13 0x20 #define _DAC2CON2_DAC2REF13 0x20 #define _DAC2CON2_R13 0x20 #define _DAC2CON2_DAC2R13 0x20 #define _DAC2CON2_REF14 0x40 #define _DAC2CON2_DAC2REF14 0x40 #define _DAC2CON2_R14 0x40 #define _DAC2CON2_DAC2R14 0x40 #define _DAC2CON2_REF15 0x80 #define _DAC2CON2_DAC2REF15 0x80 #define _DAC2CON2_R15 0x80 #define _DAC2CON2_DAC2R15 0x80 //============================================================================== //============================================================================== // DAC2REFH Bits extern __at(0x0596) __sfr DAC2REFH; typedef union { struct { unsigned REF8 : 1; unsigned REF9 : 1; unsigned REF10 : 1; unsigned REF11 : 1; unsigned REF12 : 1; unsigned REF13 : 1; unsigned REF14 : 1; unsigned REF15 : 1; }; struct { unsigned DAC2REF8 : 1; unsigned DAC2REF9 : 1; unsigned DAC2REF10 : 1; unsigned DAC2REF11 : 1; unsigned DAC2REF12 : 1; unsigned DAC2REF13 : 1; unsigned DAC2REF14 : 1; unsigned DAC2REF15 : 1; }; struct { unsigned R8 : 1; unsigned R9 : 1; unsigned R10 : 1; unsigned R11 : 1; unsigned R12 : 1; unsigned R13 : 1; unsigned R14 : 1; unsigned R15 : 1; }; struct { unsigned DAC2R8 : 1; unsigned DAC2R9 : 1; unsigned DAC2R10 : 1; unsigned DAC2R11 : 1; unsigned DAC2R12 : 1; unsigned DAC2R13 : 1; unsigned DAC2R14 : 1; unsigned DAC2R15 : 1; }; } __DAC2REFHbits_t; extern __at(0x0596) volatile __DAC2REFHbits_t DAC2REFHbits; #define _DAC2REFH_REF8 0x01 #define _DAC2REFH_DAC2REF8 0x01 #define _DAC2REFH_R8 0x01 #define _DAC2REFH_DAC2R8 0x01 #define _DAC2REFH_REF9 0x02 #define _DAC2REFH_DAC2REF9 0x02 #define _DAC2REFH_R9 0x02 #define _DAC2REFH_DAC2R9 0x02 #define _DAC2REFH_REF10 0x04 #define _DAC2REFH_DAC2REF10 0x04 #define _DAC2REFH_R10 0x04 #define _DAC2REFH_DAC2R10 0x04 #define _DAC2REFH_REF11 0x08 #define _DAC2REFH_DAC2REF11 0x08 #define _DAC2REFH_R11 0x08 #define _DAC2REFH_DAC2R11 0x08 #define _DAC2REFH_REF12 0x10 #define _DAC2REFH_DAC2REF12 0x10 #define _DAC2REFH_R12 0x10 #define _DAC2REFH_DAC2R12 0x10 #define _DAC2REFH_REF13 0x20 #define _DAC2REFH_DAC2REF13 0x20 #define _DAC2REFH_R13 0x20 #define _DAC2REFH_DAC2R13 0x20 #define _DAC2REFH_REF14 0x40 #define _DAC2REFH_DAC2REF14 0x40 #define _DAC2REFH_R14 0x40 #define _DAC2REFH_DAC2R14 0x40 #define _DAC2REFH_REF15 0x80 #define _DAC2REFH_DAC2REF15 0x80 #define _DAC2REFH_R15 0x80 #define _DAC2REFH_DAC2R15 0x80 //============================================================================== //============================================================================== // DAC3CON0 Bits extern __at(0x0597) __sfr DAC3CON0; typedef union { struct { unsigned NSS : 1; unsigned : 1; unsigned PSS0 : 1; unsigned PSS1 : 1; unsigned : 1; unsigned OE1 : 1; unsigned : 1; unsigned EN : 1; }; struct { unsigned DACNSS : 1; unsigned : 1; unsigned DACPSS0 : 1; unsigned DACPSS1 : 1; unsigned : 1; unsigned DACOE1 : 1; unsigned : 1; unsigned DACEN : 1; }; struct { unsigned DAC3NSS : 1; unsigned : 1; unsigned DAC3PSS0 : 1; unsigned DAC3PSS1 : 1; unsigned : 1; unsigned DAC3OE1 : 1; unsigned : 1; unsigned DAC3EN : 1; }; struct { unsigned : 2; unsigned PSS : 2; unsigned : 4; }; struct { unsigned : 2; unsigned DAC3PSS : 2; unsigned : 4; }; struct { unsigned : 2; unsigned DACPSS : 2; unsigned : 4; }; } __DAC3CON0bits_t; extern __at(0x0597) volatile __DAC3CON0bits_t DAC3CON0bits; #define _DAC3CON0_NSS 0x01 #define _DAC3CON0_DACNSS 0x01 #define _DAC3CON0_DAC3NSS 0x01 #define _DAC3CON0_PSS0 0x04 #define _DAC3CON0_DACPSS0 0x04 #define _DAC3CON0_DAC3PSS0 0x04 #define _DAC3CON0_PSS1 0x08 #define _DAC3CON0_DACPSS1 0x08 #define _DAC3CON0_DAC3PSS1 0x08 #define _DAC3CON0_OE1 0x20 #define _DAC3CON0_DACOE1 0x20 #define _DAC3CON0_DAC3OE1 0x20 #define _DAC3CON0_EN 0x80 #define _DAC3CON0_DACEN 0x80 #define _DAC3CON0_DAC3EN 0x80 //============================================================================== //============================================================================== // DAC3CON1 Bits extern __at(0x0598) __sfr DAC3CON1; typedef union { struct { unsigned DACR0 : 1; unsigned DACR1 : 1; unsigned DACR2 : 1; unsigned DACR3 : 1; unsigned DACR4 : 1; unsigned REF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned R0 : 1; unsigned R1 : 1; unsigned R2 : 1; unsigned R3 : 1; unsigned R4 : 1; unsigned DAC3REF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned DAC3R0 : 1; unsigned DAC3R1 : 1; unsigned DAC3R2 : 1; unsigned DAC3R3 : 1; unsigned DAC3R4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned REF0 : 1; unsigned REF1 : 1; unsigned REF2 : 1; unsigned REF3 : 1; unsigned REF4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned DAC3REF0 : 1; unsigned DAC3REF1 : 1; unsigned DAC3REF2 : 1; unsigned DAC3REF3 : 1; unsigned DAC3REF4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned R : 5; unsigned : 3; }; struct { unsigned DACR : 5; unsigned : 3; }; struct { unsigned DAC3R : 5; unsigned : 3; }; struct { unsigned DAC3REF : 6; unsigned : 2; }; struct { unsigned REF : 6; unsigned : 2; }; } __DAC3CON1bits_t; extern __at(0x0598) volatile __DAC3CON1bits_t DAC3CON1bits; #define _DAC3CON1_DACR0 0x01 #define _DAC3CON1_R0 0x01 #define _DAC3CON1_DAC3R0 0x01 #define _DAC3CON1_REF0 0x01 #define _DAC3CON1_DAC3REF0 0x01 #define _DAC3CON1_DACR1 0x02 #define _DAC3CON1_R1 0x02 #define _DAC3CON1_DAC3R1 0x02 #define _DAC3CON1_REF1 0x02 #define _DAC3CON1_DAC3REF1 0x02 #define _DAC3CON1_DACR2 0x04 #define _DAC3CON1_R2 0x04 #define _DAC3CON1_DAC3R2 0x04 #define _DAC3CON1_REF2 0x04 #define _DAC3CON1_DAC3REF2 0x04 #define _DAC3CON1_DACR3 0x08 #define _DAC3CON1_R3 0x08 #define _DAC3CON1_DAC3R3 0x08 #define _DAC3CON1_REF3 0x08 #define _DAC3CON1_DAC3REF3 0x08 #define _DAC3CON1_DACR4 0x10 #define _DAC3CON1_R4 0x10 #define _DAC3CON1_DAC3R4 0x10 #define _DAC3CON1_REF4 0x10 #define _DAC3CON1_DAC3REF4 0x10 #define _DAC3CON1_REF5 0x20 #define _DAC3CON1_DAC3REF5 0x20 //============================================================================== //============================================================================== // DAC3REF Bits extern __at(0x0598) __sfr DAC3REF; typedef union { struct { unsigned DACR0 : 1; unsigned DACR1 : 1; unsigned DACR2 : 1; unsigned DACR3 : 1; unsigned DACR4 : 1; unsigned REF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned R0 : 1; unsigned R1 : 1; unsigned R2 : 1; unsigned R3 : 1; unsigned R4 : 1; unsigned DAC3REF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned DAC3R0 : 1; unsigned DAC3R1 : 1; unsigned DAC3R2 : 1; unsigned DAC3R3 : 1; unsigned DAC3R4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned REF0 : 1; unsigned REF1 : 1; unsigned REF2 : 1; unsigned REF3 : 1; unsigned REF4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned DAC3REF0 : 1; unsigned DAC3REF1 : 1; unsigned DAC3REF2 : 1; unsigned DAC3REF3 : 1; unsigned DAC3REF4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned REF : 6; unsigned : 2; }; struct { unsigned DAC3REF : 6; unsigned : 2; }; struct { unsigned DAC3R : 5; unsigned : 3; }; struct { unsigned DACR : 5; unsigned : 3; }; struct { unsigned R : 5; unsigned : 3; }; } __DAC3REFbits_t; extern __at(0x0598) volatile __DAC3REFbits_t DAC3REFbits; #define _DAC3REF_DACR0 0x01 #define _DAC3REF_R0 0x01 #define _DAC3REF_DAC3R0 0x01 #define _DAC3REF_REF0 0x01 #define _DAC3REF_DAC3REF0 0x01 #define _DAC3REF_DACR1 0x02 #define _DAC3REF_R1 0x02 #define _DAC3REF_DAC3R1 0x02 #define _DAC3REF_REF1 0x02 #define _DAC3REF_DAC3REF1 0x02 #define _DAC3REF_DACR2 0x04 #define _DAC3REF_R2 0x04 #define _DAC3REF_DAC3R2 0x04 #define _DAC3REF_REF2 0x04 #define _DAC3REF_DAC3REF2 0x04 #define _DAC3REF_DACR3 0x08 #define _DAC3REF_R3 0x08 #define _DAC3REF_DAC3R3 0x08 #define _DAC3REF_REF3 0x08 #define _DAC3REF_DAC3REF3 0x08 #define _DAC3REF_DACR4 0x10 #define _DAC3REF_R4 0x10 #define _DAC3REF_DAC3R4 0x10 #define _DAC3REF_REF4 0x10 #define _DAC3REF_DAC3REF4 0x10 #define _DAC3REF_REF5 0x20 #define _DAC3REF_DAC3REF5 0x20 //============================================================================== //============================================================================== // DAC4CON0 Bits extern __at(0x0599) __sfr DAC4CON0; typedef union { struct { unsigned NSS : 1; unsigned : 1; unsigned PSS0 : 1; unsigned PSS1 : 1; unsigned : 1; unsigned OE1 : 1; unsigned : 1; unsigned EN : 1; }; struct { unsigned DACNSS : 1; unsigned : 1; unsigned DACPSS0 : 1; unsigned DACPSS1 : 1; unsigned : 1; unsigned DACOE1 : 1; unsigned : 1; unsigned DACEN : 1; }; struct { unsigned DAC4NSS : 1; unsigned : 1; unsigned DAC4PSS0 : 1; unsigned DAC4PSS1 : 1; unsigned : 1; unsigned DAC4OE1 : 1; unsigned : 1; unsigned DAC4EN : 1; }; struct { unsigned : 2; unsigned PSS : 2; unsigned : 4; }; struct { unsigned : 2; unsigned DAC4PSS : 2; unsigned : 4; }; struct { unsigned : 2; unsigned DACPSS : 2; unsigned : 4; }; } __DAC4CON0bits_t; extern __at(0x0599) volatile __DAC4CON0bits_t DAC4CON0bits; #define _DAC4CON0_NSS 0x01 #define _DAC4CON0_DACNSS 0x01 #define _DAC4CON0_DAC4NSS 0x01 #define _DAC4CON0_PSS0 0x04 #define _DAC4CON0_DACPSS0 0x04 #define _DAC4CON0_DAC4PSS0 0x04 #define _DAC4CON0_PSS1 0x08 #define _DAC4CON0_DACPSS1 0x08 #define _DAC4CON0_DAC4PSS1 0x08 #define _DAC4CON0_OE1 0x20 #define _DAC4CON0_DACOE1 0x20 #define _DAC4CON0_DAC4OE1 0x20 #define _DAC4CON0_EN 0x80 #define _DAC4CON0_DACEN 0x80 #define _DAC4CON0_DAC4EN 0x80 //============================================================================== //============================================================================== // DAC4CON1 Bits extern __at(0x059A) __sfr DAC4CON1; typedef union { struct { unsigned DACR0 : 1; unsigned DACR1 : 1; unsigned DACR2 : 1; unsigned DACR3 : 1; unsigned DACR4 : 1; unsigned REF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned R0 : 1; unsigned R1 : 1; unsigned R2 : 1; unsigned R3 : 1; unsigned R4 : 1; unsigned DAC4REF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned DAC4R0 : 1; unsigned DAC4R1 : 1; unsigned DAC4R2 : 1; unsigned DAC4R3 : 1; unsigned DAC4R4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned REF0 : 1; unsigned REF1 : 1; unsigned REF2 : 1; unsigned REF3 : 1; unsigned REF4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned DAC4REF0 : 1; unsigned DAC4REF1 : 1; unsigned DAC4REF2 : 1; unsigned DAC4REF3 : 1; unsigned DAC4REF4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned R : 5; unsigned : 3; }; struct { unsigned DAC4REF : 6; unsigned : 2; }; struct { unsigned DACR : 5; unsigned : 3; }; struct { unsigned REF : 6; unsigned : 2; }; struct { unsigned DAC4R : 5; unsigned : 3; }; } __DAC4CON1bits_t; extern __at(0x059A) volatile __DAC4CON1bits_t DAC4CON1bits; #define _DAC4CON1_DACR0 0x01 #define _DAC4CON1_R0 0x01 #define _DAC4CON1_DAC4R0 0x01 #define _DAC4CON1_REF0 0x01 #define _DAC4CON1_DAC4REF0 0x01 #define _DAC4CON1_DACR1 0x02 #define _DAC4CON1_R1 0x02 #define _DAC4CON1_DAC4R1 0x02 #define _DAC4CON1_REF1 0x02 #define _DAC4CON1_DAC4REF1 0x02 #define _DAC4CON1_DACR2 0x04 #define _DAC4CON1_R2 0x04 #define _DAC4CON1_DAC4R2 0x04 #define _DAC4CON1_REF2 0x04 #define _DAC4CON1_DAC4REF2 0x04 #define _DAC4CON1_DACR3 0x08 #define _DAC4CON1_R3 0x08 #define _DAC4CON1_DAC4R3 0x08 #define _DAC4CON1_REF3 0x08 #define _DAC4CON1_DAC4REF3 0x08 #define _DAC4CON1_DACR4 0x10 #define _DAC4CON1_R4 0x10 #define _DAC4CON1_DAC4R4 0x10 #define _DAC4CON1_REF4 0x10 #define _DAC4CON1_DAC4REF4 0x10 #define _DAC4CON1_REF5 0x20 #define _DAC4CON1_DAC4REF5 0x20 //============================================================================== //============================================================================== // DAC4REF Bits extern __at(0x059A) __sfr DAC4REF; typedef union { struct { unsigned DACR0 : 1; unsigned DACR1 : 1; unsigned DACR2 : 1; unsigned DACR3 : 1; unsigned DACR4 : 1; unsigned REF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned R0 : 1; unsigned R1 : 1; unsigned R2 : 1; unsigned R3 : 1; unsigned R4 : 1; unsigned DAC4REF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned DAC4R0 : 1; unsigned DAC4R1 : 1; unsigned DAC4R2 : 1; unsigned DAC4R3 : 1; unsigned DAC4R4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned REF0 : 1; unsigned REF1 : 1; unsigned REF2 : 1; unsigned REF3 : 1; unsigned REF4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned DAC4REF0 : 1; unsigned DAC4REF1 : 1; unsigned DAC4REF2 : 1; unsigned DAC4REF3 : 1; unsigned DAC4REF4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned REF : 6; unsigned : 2; }; struct { unsigned DAC4R : 5; unsigned : 3; }; struct { unsigned R : 5; unsigned : 3; }; struct { unsigned DACR : 5; unsigned : 3; }; struct { unsigned DAC4REF : 6; unsigned : 2; }; } __DAC4REFbits_t; extern __at(0x059A) volatile __DAC4REFbits_t DAC4REFbits; #define _DAC4REF_DACR0 0x01 #define _DAC4REF_R0 0x01 #define _DAC4REF_DAC4R0 0x01 #define _DAC4REF_REF0 0x01 #define _DAC4REF_DAC4REF0 0x01 #define _DAC4REF_DACR1 0x02 #define _DAC4REF_R1 0x02 #define _DAC4REF_DAC4R1 0x02 #define _DAC4REF_REF1 0x02 #define _DAC4REF_DAC4REF1 0x02 #define _DAC4REF_DACR2 0x04 #define _DAC4REF_R2 0x04 #define _DAC4REF_DAC4R2 0x04 #define _DAC4REF_REF2 0x04 #define _DAC4REF_DAC4REF2 0x04 #define _DAC4REF_DACR3 0x08 #define _DAC4REF_R3 0x08 #define _DAC4REF_DAC4R3 0x08 #define _DAC4REF_REF3 0x08 #define _DAC4REF_DAC4REF3 0x08 #define _DAC4REF_DACR4 0x10 #define _DAC4REF_R4 0x10 #define _DAC4REF_DAC4R4 0x10 #define _DAC4REF_REF4 0x10 #define _DAC4REF_DAC4REF4 0x10 #define _DAC4REF_REF5 0x20 #define _DAC4REF_DAC4REF5 0x20 //============================================================================== //============================================================================== // PWM3DCL Bits extern __at(0x0617) __sfr PWM3DCL; typedef union { struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned DC0 : 1; unsigned DC1 : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned PWM3DC0 : 1; unsigned PWM3DC1 : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned PWMPW0 : 1; unsigned PWMPW1 : 1; }; struct { unsigned : 6; unsigned PWMPW : 2; }; struct { unsigned : 6; unsigned DC : 2; }; struct { unsigned : 6; unsigned PWM3DC : 2; }; } __PWM3DCLbits_t; extern __at(0x0617) volatile __PWM3DCLbits_t PWM3DCLbits; #define _DC0 0x40 #define _PWM3DC0 0x40 #define _PWMPW0 0x40 #define _DC1 0x80 #define _PWM3DC1 0x80 #define _PWMPW1 0x80 //============================================================================== //============================================================================== // PWM3DCH Bits extern __at(0x0618) __sfr PWM3DCH; typedef union { struct { unsigned DC2 : 1; unsigned DC3 : 1; unsigned DC4 : 1; unsigned DC5 : 1; unsigned DC6 : 1; unsigned DC7 : 1; unsigned DC8 : 1; unsigned DC9 : 1; }; struct { unsigned PWM3DC2 : 1; unsigned PWM3DC3 : 1; unsigned PWM3DC4 : 1; unsigned PWM3DC5 : 1; unsigned PWM3DC6 : 1; unsigned PWM3DC7 : 1; unsigned PWM3DC8 : 1; unsigned PWM3DC9 : 1; }; struct { unsigned PWMPW2 : 1; unsigned PWMPW3 : 1; unsigned PWMPW4 : 1; unsigned PWMPW5 : 1; unsigned PWMPW6 : 1; unsigned PWMPW7 : 1; unsigned PWMPW8 : 1; unsigned PWMPW9 : 1; }; } __PWM3DCHbits_t; extern __at(0x0618) volatile __PWM3DCHbits_t PWM3DCHbits; #define _DC2 0x01 #define _PWM3DC2 0x01 #define _PWMPW2 0x01 #define _DC3 0x02 #define _PWM3DC3 0x02 #define _PWMPW3 0x02 #define _DC4 0x04 #define _PWM3DC4 0x04 #define _PWMPW4 0x04 #define _DC5 0x08 #define _PWM3DC5 0x08 #define _PWMPW5 0x08 #define _DC6 0x10 #define _PWM3DC6 0x10 #define _PWMPW6 0x10 #define _DC7 0x20 #define _PWM3DC7 0x20 #define _PWMPW7 0x20 #define _DC8 0x40 #define _PWM3DC8 0x40 #define _PWMPW8 0x40 #define _DC9 0x80 #define _PWM3DC9 0x80 #define _PWMPW9 0x80 //============================================================================== //============================================================================== // PWM3CON Bits extern __at(0x0619) __sfr PWM3CON; typedef union { struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned POL : 1; unsigned OUT : 1; unsigned : 1; unsigned EN : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned PWM3POL : 1; unsigned PWM3OUT : 1; unsigned : 1; unsigned PWM3EN : 1; }; } __PWM3CONbits_t; extern __at(0x0619) volatile __PWM3CONbits_t PWM3CONbits; #define _PWM3CON_POL 0x10 #define _PWM3CON_PWM3POL 0x10 #define _PWM3CON_OUT 0x20 #define _PWM3CON_PWM3OUT 0x20 #define _PWM3CON_EN 0x80 #define _PWM3CON_PWM3EN 0x80 //============================================================================== //============================================================================== // PWM4DCL Bits extern __at(0x061A) __sfr PWM4DCL; typedef union { struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned DC0 : 1; unsigned DC1 : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned PWM4DC0 : 1; unsigned PWM4DC1 : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned PWMPW0 : 1; unsigned PWMPW1 : 1; }; struct { unsigned : 6; unsigned PWM4DC : 2; }; struct { unsigned : 6; unsigned DC : 2; }; struct { unsigned : 6; unsigned PWMPW : 2; }; } __PWM4DCLbits_t; extern __at(0x061A) volatile __PWM4DCLbits_t PWM4DCLbits; #define _PWM4DCL_DC0 0x40 #define _PWM4DCL_PWM4DC0 0x40 #define _PWM4DCL_PWMPW0 0x40 #define _PWM4DCL_DC1 0x80 #define _PWM4DCL_PWM4DC1 0x80 #define _PWM4DCL_PWMPW1 0x80 //============================================================================== //============================================================================== // PWM4DCH Bits extern __at(0x061B) __sfr PWM4DCH; typedef union { struct { unsigned DC2 : 1; unsigned DC3 : 1; unsigned DC4 : 1; unsigned DC5 : 1; unsigned DC6 : 1; unsigned DC7 : 1; unsigned DC8 : 1; unsigned DC9 : 1; }; struct { unsigned PWM4DC2 : 1; unsigned PWM4DC3 : 1; unsigned PWM4DC4 : 1; unsigned PWM4DC5 : 1; unsigned PWM4DC6 : 1; unsigned PWM4DC7 : 1; unsigned PWM4DC8 : 1; unsigned PWM4DC9 : 1; }; struct { unsigned PWMPW2 : 1; unsigned PWMPW3 : 1; unsigned PWMPW4 : 1; unsigned PWMPW5 : 1; unsigned PWMPW6 : 1; unsigned PWMPW7 : 1; unsigned PWMPW8 : 1; unsigned PWMPW9 : 1; }; } __PWM4DCHbits_t; extern __at(0x061B) volatile __PWM4DCHbits_t PWM4DCHbits; #define _PWM4DCH_DC2 0x01 #define _PWM4DCH_PWM4DC2 0x01 #define _PWM4DCH_PWMPW2 0x01 #define _PWM4DCH_DC3 0x02 #define _PWM4DCH_PWM4DC3 0x02 #define _PWM4DCH_PWMPW3 0x02 #define _PWM4DCH_DC4 0x04 #define _PWM4DCH_PWM4DC4 0x04 #define _PWM4DCH_PWMPW4 0x04 #define _PWM4DCH_DC5 0x08 #define _PWM4DCH_PWM4DC5 0x08 #define _PWM4DCH_PWMPW5 0x08 #define _PWM4DCH_DC6 0x10 #define _PWM4DCH_PWM4DC6 0x10 #define _PWM4DCH_PWMPW6 0x10 #define _PWM4DCH_DC7 0x20 #define _PWM4DCH_PWM4DC7 0x20 #define _PWM4DCH_PWMPW7 0x20 #define _PWM4DCH_DC8 0x40 #define _PWM4DCH_PWM4DC8 0x40 #define _PWM4DCH_PWMPW8 0x40 #define _PWM4DCH_DC9 0x80 #define _PWM4DCH_PWM4DC9 0x80 #define _PWM4DCH_PWMPW9 0x80 //============================================================================== //============================================================================== // PWM4CON Bits extern __at(0x061C) __sfr PWM4CON; typedef union { struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned POL : 1; unsigned OUT : 1; unsigned : 1; unsigned EN : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned PWM4POL : 1; unsigned PWM4OUT : 1; unsigned : 1; unsigned PWM4EN : 1; }; } __PWM4CONbits_t; extern __at(0x061C) volatile __PWM4CONbits_t PWM4CONbits; #define _PWM4CON_POL 0x10 #define _PWM4CON_PWM4POL 0x10 #define _PWM4CON_OUT 0x20 #define _PWM4CON_PWM4OUT 0x20 #define _PWM4CON_EN 0x80 #define _PWM4CON_PWM4EN 0x80 //============================================================================== //============================================================================== // COG1PHR Bits extern __at(0x068D) __sfr COG1PHR; typedef union { struct { unsigned PHR0 : 1; unsigned PHR1 : 1; unsigned PHR2 : 1; unsigned PHR3 : 1; unsigned PHR4 : 1; unsigned PHR5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G1PHR0 : 1; unsigned G1PHR1 : 1; unsigned G1PHR2 : 1; unsigned G1PHR3 : 1; unsigned G1PHR4 : 1; unsigned G1PHR5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned PHR : 6; unsigned : 2; }; struct { unsigned G1PHR : 6; unsigned : 2; }; } __COG1PHRbits_t; extern __at(0x068D) volatile __COG1PHRbits_t COG1PHRbits; #define _PHR0 0x01 #define _G1PHR0 0x01 #define _PHR1 0x02 #define _G1PHR1 0x02 #define _PHR2 0x04 #define _G1PHR2 0x04 #define _PHR3 0x08 #define _G1PHR3 0x08 #define _PHR4 0x10 #define _G1PHR4 0x10 #define _PHR5 0x20 #define _G1PHR5 0x20 //============================================================================== //============================================================================== // COG1PHF Bits extern __at(0x068E) __sfr COG1PHF; typedef union { struct { unsigned PHF0 : 1; unsigned PHF1 : 1; unsigned PHF2 : 1; unsigned PHF3 : 1; unsigned PHF4 : 1; unsigned PHF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G1PHF0 : 1; unsigned G1PHF1 : 1; unsigned G1PHF2 : 1; unsigned G1PHF3 : 1; unsigned G1PHF4 : 1; unsigned G1PHF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned PHF : 6; unsigned : 2; }; struct { unsigned G1PHF : 6; unsigned : 2; }; } __COG1PHFbits_t; extern __at(0x068E) volatile __COG1PHFbits_t COG1PHFbits; #define _PHF0 0x01 #define _G1PHF0 0x01 #define _PHF1 0x02 #define _G1PHF1 0x02 #define _PHF2 0x04 #define _G1PHF2 0x04 #define _PHF3 0x08 #define _G1PHF3 0x08 #define _PHF4 0x10 #define _G1PHF4 0x10 #define _PHF5 0x20 #define _G1PHF5 0x20 //============================================================================== //============================================================================== // COG1BLKR Bits extern __at(0x068F) __sfr COG1BLKR; typedef union { struct { unsigned BLKR0 : 1; unsigned BLKR1 : 1; unsigned BLKR2 : 1; unsigned BLKR3 : 1; unsigned BLKR4 : 1; unsigned BLKR5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G1BLKR0 : 1; unsigned G1BLKR1 : 1; unsigned G1BLKR2 : 1; unsigned G1BLKR3 : 1; unsigned G1BLKR4 : 1; unsigned G1BLKR5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G1BLKR : 6; unsigned : 2; }; struct { unsigned BLKR : 6; unsigned : 2; }; } __COG1BLKRbits_t; extern __at(0x068F) volatile __COG1BLKRbits_t COG1BLKRbits; #define _BLKR0 0x01 #define _G1BLKR0 0x01 #define _BLKR1 0x02 #define _G1BLKR1 0x02 #define _BLKR2 0x04 #define _G1BLKR2 0x04 #define _BLKR3 0x08 #define _G1BLKR3 0x08 #define _BLKR4 0x10 #define _G1BLKR4 0x10 #define _BLKR5 0x20 #define _G1BLKR5 0x20 //============================================================================== //============================================================================== // COG1BLKF Bits extern __at(0x0690) __sfr COG1BLKF; typedef union { struct { unsigned BLKF0 : 1; unsigned BLKF1 : 1; unsigned BLKF2 : 1; unsigned BLKF3 : 1; unsigned BLKF4 : 1; unsigned BLKF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G1BLKF0 : 1; unsigned G1BLKF1 : 1; unsigned G1BLKF2 : 1; unsigned G1BLKF3 : 1; unsigned G1BLKF4 : 1; unsigned G1BLKF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G1BLKF : 6; unsigned : 2; }; struct { unsigned BLKF : 6; unsigned : 2; }; } __COG1BLKFbits_t; extern __at(0x0690) volatile __COG1BLKFbits_t COG1BLKFbits; #define _BLKF0 0x01 #define _G1BLKF0 0x01 #define _BLKF1 0x02 #define _G1BLKF1 0x02 #define _BLKF2 0x04 #define _G1BLKF2 0x04 #define _BLKF3 0x08 #define _G1BLKF3 0x08 #define _BLKF4 0x10 #define _G1BLKF4 0x10 #define _BLKF5 0x20 #define _G1BLKF5 0x20 //============================================================================== //============================================================================== // COG1DBR Bits extern __at(0x0691) __sfr COG1DBR; typedef union { struct { unsigned DBR0 : 1; unsigned DBR1 : 1; unsigned DBR2 : 1; unsigned DBR3 : 1; unsigned DBR4 : 1; unsigned DBR5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G1DBR0 : 1; unsigned G1DBR1 : 1; unsigned G1DBR2 : 1; unsigned G1DBR3 : 1; unsigned G1DBR4 : 1; unsigned G1DBR5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G1DBR : 6; unsigned : 2; }; struct { unsigned DBR : 6; unsigned : 2; }; } __COG1DBRbits_t; extern __at(0x0691) volatile __COG1DBRbits_t COG1DBRbits; #define _DBR0 0x01 #define _G1DBR0 0x01 #define _DBR1 0x02 #define _G1DBR1 0x02 #define _DBR2 0x04 #define _G1DBR2 0x04 #define _DBR3 0x08 #define _G1DBR3 0x08 #define _DBR4 0x10 #define _G1DBR4 0x10 #define _DBR5 0x20 #define _G1DBR5 0x20 //============================================================================== //============================================================================== // COG1DBF Bits extern __at(0x0692) __sfr COG1DBF; typedef union { struct { unsigned DBF0 : 1; unsigned DBF1 : 1; unsigned DBF2 : 1; unsigned DBF3 : 1; unsigned DBF4 : 1; unsigned DBF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G1DBF0 : 1; unsigned G1DBF1 : 1; unsigned G1DBF2 : 1; unsigned G1DBF3 : 1; unsigned G1DBF4 : 1; unsigned G1DBF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G1DBF : 6; unsigned : 2; }; struct { unsigned DBF : 6; unsigned : 2; }; } __COG1DBFbits_t; extern __at(0x0692) volatile __COG1DBFbits_t COG1DBFbits; #define _DBF0 0x01 #define _G1DBF0 0x01 #define _DBF1 0x02 #define _G1DBF1 0x02 #define _DBF2 0x04 #define _G1DBF2 0x04 #define _DBF3 0x08 #define _G1DBF3 0x08 #define _DBF4 0x10 #define _G1DBF4 0x10 #define _DBF5 0x20 #define _G1DBF5 0x20 //============================================================================== //============================================================================== // COG1CON0 Bits extern __at(0x0693) __sfr COG1CON0; typedef union { struct { unsigned MD0 : 1; unsigned MD1 : 1; unsigned MD2 : 1; unsigned CS0 : 1; unsigned CS1 : 1; unsigned : 1; unsigned LD : 1; unsigned EN : 1; }; struct { unsigned G1MD0 : 1; unsigned G1MD1 : 1; unsigned G1MD2 : 1; unsigned G1CS0 : 1; unsigned G1CS1 : 1; unsigned : 1; unsigned G1LD : 1; unsigned G1EN : 1; }; struct { unsigned G1MD : 3; unsigned : 5; }; struct { unsigned MD : 3; unsigned : 5; }; struct { unsigned : 3; unsigned G1CS : 2; unsigned : 3; }; struct { unsigned : 3; unsigned CS : 2; unsigned : 3; }; } __COG1CON0bits_t; extern __at(0x0693) volatile __COG1CON0bits_t COG1CON0bits; #define _COG1CON0_MD0 0x01 #define _COG1CON0_G1MD0 0x01 #define _COG1CON0_MD1 0x02 #define _COG1CON0_G1MD1 0x02 #define _COG1CON0_MD2 0x04 #define _COG1CON0_G1MD2 0x04 #define _COG1CON0_CS0 0x08 #define _COG1CON0_G1CS0 0x08 #define _COG1CON0_CS1 0x10 #define _COG1CON0_G1CS1 0x10 #define _COG1CON0_LD 0x40 #define _COG1CON0_G1LD 0x40 #define _COG1CON0_EN 0x80 #define _COG1CON0_G1EN 0x80 //============================================================================== //============================================================================== // COG1CON1 Bits extern __at(0x0694) __sfr COG1CON1; typedef union { struct { unsigned POLA : 1; unsigned POLB : 1; unsigned POLC : 1; unsigned POLD : 1; unsigned : 1; unsigned : 1; unsigned FDBS : 1; unsigned RDBS : 1; }; struct { unsigned G1POLA : 1; unsigned G1POLB : 1; unsigned G1POLC : 1; unsigned G1POLD : 1; unsigned : 1; unsigned : 1; unsigned G1FDBS : 1; unsigned G1RDBS : 1; }; } __COG1CON1bits_t; extern __at(0x0694) volatile __COG1CON1bits_t COG1CON1bits; #define _POLA 0x01 #define _G1POLA 0x01 #define _POLB 0x02 #define _G1POLB 0x02 #define _POLC 0x04 #define _G1POLC 0x04 #define _POLD 0x08 #define _G1POLD 0x08 #define _FDBS 0x40 #define _G1FDBS 0x40 #define _RDBS 0x80 #define _G1RDBS 0x80 //============================================================================== //============================================================================== // COG1RIS0 Bits extern __at(0x0695) __sfr COG1RIS0; typedef union { struct { unsigned RIS0 : 1; unsigned RIS1 : 1; unsigned RIS2 : 1; unsigned RIS3 : 1; unsigned RIS4 : 1; unsigned RIS5 : 1; unsigned RIS6 : 1; unsigned RIS7 : 1; }; struct { unsigned G1RIS0 : 1; unsigned G1RIS1 : 1; unsigned G1RIS2 : 1; unsigned G1RIS3 : 1; unsigned G1RIS4 : 1; unsigned G1RIS5 : 1; unsigned G1RIS6 : 1; unsigned G1RIS7 : 1; }; } __COG1RIS0bits_t; extern __at(0x0695) volatile __COG1RIS0bits_t COG1RIS0bits; #define _RIS0 0x01 #define _G1RIS0 0x01 #define _RIS1 0x02 #define _G1RIS1 0x02 #define _RIS2 0x04 #define _G1RIS2 0x04 #define _RIS3 0x08 #define _G1RIS3 0x08 #define _RIS4 0x10 #define _G1RIS4 0x10 #define _RIS5 0x20 #define _G1RIS5 0x20 #define _RIS6 0x40 #define _G1RIS6 0x40 #define _RIS7 0x80 #define _G1RIS7 0x80 //============================================================================== //============================================================================== // COG1RIS1 Bits extern __at(0x0696) __sfr COG1RIS1; typedef union { struct { unsigned RIS8 : 1; unsigned RIS9 : 1; unsigned RIS10 : 1; unsigned RIS11 : 1; unsigned RIS12 : 1; unsigned RIS13 : 1; unsigned RIS14 : 1; unsigned RIS15 : 1; }; struct { unsigned G1RIS8 : 1; unsigned G1RIS9 : 1; unsigned G1RIS10 : 1; unsigned G1RIS11 : 1; unsigned G1RIS12 : 1; unsigned G1RIS13 : 1; unsigned G1RIS14 : 1; unsigned G1RIS15 : 1; }; } __COG1RIS1bits_t; extern __at(0x0696) volatile __COG1RIS1bits_t COG1RIS1bits; #define _RIS8 0x01 #define _G1RIS8 0x01 #define _RIS9 0x02 #define _G1RIS9 0x02 #define _RIS10 0x04 #define _G1RIS10 0x04 #define _RIS11 0x08 #define _G1RIS11 0x08 #define _RIS12 0x10 #define _G1RIS12 0x10 #define _RIS13 0x20 #define _G1RIS13 0x20 #define _RIS14 0x40 #define _G1RIS14 0x40 #define _RIS15 0x80 #define _G1RIS15 0x80 //============================================================================== //============================================================================== // COG1RSIM0 Bits extern __at(0x0697) __sfr COG1RSIM0; typedef union { struct { unsigned RSIM0 : 1; unsigned RSIM1 : 1; unsigned RSIM2 : 1; unsigned RSIM3 : 1; unsigned RSIM4 : 1; unsigned RSIM5 : 1; unsigned RSIM6 : 1; unsigned RSIM7 : 1; }; struct { unsigned G1RSIM0 : 1; unsigned G1RSIM1 : 1; unsigned G1RSIM2 : 1; unsigned G1RSIM3 : 1; unsigned G1RSIM4 : 1; unsigned G1RSIM5 : 1; unsigned G1RSIM6 : 1; unsigned G1RSIM7 : 1; }; } __COG1RSIM0bits_t; extern __at(0x0697) volatile __COG1RSIM0bits_t COG1RSIM0bits; #define _RSIM0 0x01 #define _G1RSIM0 0x01 #define _RSIM1 0x02 #define _G1RSIM1 0x02 #define _RSIM2 0x04 #define _G1RSIM2 0x04 #define _RSIM3 0x08 #define _G1RSIM3 0x08 #define _RSIM4 0x10 #define _G1RSIM4 0x10 #define _RSIM5 0x20 #define _G1RSIM5 0x20 #define _RSIM6 0x40 #define _G1RSIM6 0x40 #define _RSIM7 0x80 #define _G1RSIM7 0x80 //============================================================================== //============================================================================== // COG1RSIM1 Bits extern __at(0x0698) __sfr COG1RSIM1; typedef union { struct { unsigned RSIM8 : 1; unsigned RSIM9 : 1; unsigned RSIM10 : 1; unsigned RSIM11 : 1; unsigned RSIM12 : 1; unsigned RSIM13 : 1; unsigned RSIM14 : 1; unsigned RSIM15 : 1; }; struct { unsigned G1RSIM8 : 1; unsigned G1RSIM9 : 1; unsigned G1RSIM10 : 1; unsigned G1RSIM11 : 1; unsigned G1RSIM12 : 1; unsigned G1RSIM13 : 1; unsigned G1RSIM14 : 1; unsigned G1RSIM15 : 1; }; } __COG1RSIM1bits_t; extern __at(0x0698) volatile __COG1RSIM1bits_t COG1RSIM1bits; #define _RSIM8 0x01 #define _G1RSIM8 0x01 #define _RSIM9 0x02 #define _G1RSIM9 0x02 #define _RSIM10 0x04 #define _G1RSIM10 0x04 #define _RSIM11 0x08 #define _G1RSIM11 0x08 #define _RSIM12 0x10 #define _G1RSIM12 0x10 #define _RSIM13 0x20 #define _G1RSIM13 0x20 #define _RSIM14 0x40 #define _G1RSIM14 0x40 #define _RSIM15 0x80 #define _G1RSIM15 0x80 //============================================================================== //============================================================================== // COG1FIS0 Bits extern __at(0x0699) __sfr COG1FIS0; typedef union { struct { unsigned FIS0 : 1; unsigned FIS1 : 1; unsigned FIS2 : 1; unsigned FIS3 : 1; unsigned FIS4 : 1; unsigned FIS5 : 1; unsigned FIS6 : 1; unsigned FIS7 : 1; }; struct { unsigned G1FIS0 : 1; unsigned G1FIS1 : 1; unsigned G1FIS2 : 1; unsigned G1FIS3 : 1; unsigned G1FIS4 : 1; unsigned G1FIS5 : 1; unsigned G1FIS6 : 1; unsigned G1FIS7 : 1; }; } __COG1FIS0bits_t; extern __at(0x0699) volatile __COG1FIS0bits_t COG1FIS0bits; #define _FIS0 0x01 #define _G1FIS0 0x01 #define _FIS1 0x02 #define _G1FIS1 0x02 #define _FIS2 0x04 #define _G1FIS2 0x04 #define _FIS3 0x08 #define _G1FIS3 0x08 #define _FIS4 0x10 #define _G1FIS4 0x10 #define _FIS5 0x20 #define _G1FIS5 0x20 #define _FIS6 0x40 #define _G1FIS6 0x40 #define _FIS7 0x80 #define _G1FIS7 0x80 //============================================================================== //============================================================================== // COG1FIS1 Bits extern __at(0x069A) __sfr COG1FIS1; typedef union { struct { unsigned FIS8 : 1; unsigned FIS9 : 1; unsigned FIS10 : 1; unsigned FIS11 : 1; unsigned FIS12 : 1; unsigned FIS13 : 1; unsigned FIS14 : 1; unsigned FIS15 : 1; }; struct { unsigned G1FIS8 : 1; unsigned G1FIS9 : 1; unsigned G1FIS10 : 1; unsigned G1FIS11 : 1; unsigned G1FIS12 : 1; unsigned G1FIS13 : 1; unsigned G1FIS14 : 1; unsigned G1FIS15 : 1; }; } __COG1FIS1bits_t; extern __at(0x069A) volatile __COG1FIS1bits_t COG1FIS1bits; #define _FIS8 0x01 #define _G1FIS8 0x01 #define _FIS9 0x02 #define _G1FIS9 0x02 #define _FIS10 0x04 #define _G1FIS10 0x04 #define _FIS11 0x08 #define _G1FIS11 0x08 #define _FIS12 0x10 #define _G1FIS12 0x10 #define _FIS13 0x20 #define _G1FIS13 0x20 #define _FIS14 0x40 #define _G1FIS14 0x40 #define _FIS15 0x80 #define _G1FIS15 0x80 //============================================================================== //============================================================================== // COG1FSIM0 Bits extern __at(0x069B) __sfr COG1FSIM0; typedef union { struct { unsigned FSIM0 : 1; unsigned FSIM1 : 1; unsigned FSIM2 : 1; unsigned FSIM3 : 1; unsigned FSIM4 : 1; unsigned FSIM5 : 1; unsigned FSIM6 : 1; unsigned FSIM7 : 1; }; struct { unsigned G1FSIM0 : 1; unsigned G1FSIM1 : 1; unsigned G1FSIM2 : 1; unsigned G1FSIM3 : 1; unsigned G1FSIM4 : 1; unsigned G1FSIM5 : 1; unsigned G1FSIM6 : 1; unsigned G1FSIM7 : 1; }; } __COG1FSIM0bits_t; extern __at(0x069B) volatile __COG1FSIM0bits_t COG1FSIM0bits; #define _FSIM0 0x01 #define _G1FSIM0 0x01 #define _FSIM1 0x02 #define _G1FSIM1 0x02 #define _FSIM2 0x04 #define _G1FSIM2 0x04 #define _FSIM3 0x08 #define _G1FSIM3 0x08 #define _FSIM4 0x10 #define _G1FSIM4 0x10 #define _FSIM5 0x20 #define _G1FSIM5 0x20 #define _FSIM6 0x40 #define _G1FSIM6 0x40 #define _FSIM7 0x80 #define _G1FSIM7 0x80 //============================================================================== //============================================================================== // COG1FSIM1 Bits extern __at(0x069C) __sfr COG1FSIM1; typedef union { struct { unsigned FSIM8 : 1; unsigned FSIM9 : 1; unsigned FSIM10 : 1; unsigned FSIM11 : 1; unsigned FSIM12 : 1; unsigned FSIM13 : 1; unsigned FSIM14 : 1; unsigned FSIM15 : 1; }; struct { unsigned G1FSIM8 : 1; unsigned G1FSIM9 : 1; unsigned G1FSIM10 : 1; unsigned G1FSIM11 : 1; unsigned G1FSIM12 : 1; unsigned G1FSIM13 : 1; unsigned G1FSIM14 : 1; unsigned G1FSIM15 : 1; }; } __COG1FSIM1bits_t; extern __at(0x069C) volatile __COG1FSIM1bits_t COG1FSIM1bits; #define _FSIM8 0x01 #define _G1FSIM8 0x01 #define _FSIM9 0x02 #define _G1FSIM9 0x02 #define _FSIM10 0x04 #define _G1FSIM10 0x04 #define _FSIM11 0x08 #define _G1FSIM11 0x08 #define _FSIM12 0x10 #define _G1FSIM12 0x10 #define _FSIM13 0x20 #define _G1FSIM13 0x20 #define _FSIM14 0x40 #define _G1FSIM14 0x40 #define _FSIM15 0x80 #define _G1FSIM15 0x80 //============================================================================== //============================================================================== // COG1ASD0 Bits extern __at(0x069D) __sfr COG1ASD0; typedef union { struct { unsigned : 1; unsigned : 1; unsigned ASDAC0 : 1; unsigned ASDAC1 : 1; unsigned ASDBD0 : 1; unsigned ASDBD1 : 1; unsigned ASREN : 1; unsigned ASE : 1; }; struct { unsigned : 1; unsigned : 1; unsigned G1ASDAC0 : 1; unsigned G1ASDAC1 : 1; unsigned G1ASDBD0 : 1; unsigned G1ASDBD1 : 1; unsigned ARSEN : 1; unsigned G1ASE : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned G1ARSEN : 1; unsigned : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned G1ASREN : 1; unsigned : 1; }; struct { unsigned : 2; unsigned G1ASDAC : 2; unsigned : 4; }; struct { unsigned : 2; unsigned ASDAC : 2; unsigned : 4; }; struct { unsigned : 4; unsigned G1ASDBD : 2; unsigned : 2; }; struct { unsigned : 4; unsigned ASDBD : 2; unsigned : 2; }; } __COG1ASD0bits_t; extern __at(0x069D) volatile __COG1ASD0bits_t COG1ASD0bits; #define _ASDAC0 0x04 #define _G1ASDAC0 0x04 #define _ASDAC1 0x08 #define _G1ASDAC1 0x08 #define _ASDBD0 0x10 #define _G1ASDBD0 0x10 #define _ASDBD1 0x20 #define _G1ASDBD1 0x20 #define _ASREN 0x40 #define _ARSEN 0x40 #define _G1ARSEN 0x40 #define _G1ASREN 0x40 #define _ASE 0x80 #define _G1ASE 0x80 //============================================================================== //============================================================================== // COG1ASD1 Bits extern __at(0x069E) __sfr COG1ASD1; typedef union { struct { unsigned AS0E : 1; unsigned AS1E : 1; unsigned AS2E : 1; unsigned AS3E : 1; unsigned AS4E : 1; unsigned AS5E : 1; unsigned AS6E : 1; unsigned AS7E : 1; }; struct { unsigned G1AS0E : 1; unsigned G1AS1E : 1; unsigned G1AS2E : 1; unsigned G1AS3E : 1; unsigned G1AS4E : 1; unsigned G1AS5E : 1; unsigned G1AS6E : 1; unsigned G1AS7E : 1; }; } __COG1ASD1bits_t; extern __at(0x069E) volatile __COG1ASD1bits_t COG1ASD1bits; #define _AS0E 0x01 #define _G1AS0E 0x01 #define _AS1E 0x02 #define _G1AS1E 0x02 #define _AS2E 0x04 #define _G1AS2E 0x04 #define _AS3E 0x08 #define _G1AS3E 0x08 #define _AS4E 0x10 #define _G1AS4E 0x10 #define _AS5E 0x20 #define _G1AS5E 0x20 #define _AS6E 0x40 #define _G1AS6E 0x40 #define _AS7E 0x80 #define _G1AS7E 0x80 //============================================================================== //============================================================================== // COG1STR Bits extern __at(0x069F) __sfr COG1STR; typedef union { struct { unsigned STRA : 1; unsigned STRB : 1; unsigned STRC : 1; unsigned STRD : 1; unsigned SDATA : 1; unsigned SDATB : 1; unsigned SDATC : 1; unsigned SDATD : 1; }; struct { unsigned G1STRA : 1; unsigned G1STRB : 1; unsigned G1STRC : 1; unsigned G1STRD : 1; unsigned G1SDATA : 1; unsigned G1SDATB : 1; unsigned G1SDATC : 1; unsigned G1SDATD : 1; }; } __COG1STRbits_t; extern __at(0x069F) volatile __COG1STRbits_t COG1STRbits; #define _STRA 0x01 #define _G1STRA 0x01 #define _STRB 0x02 #define _G1STRB 0x02 #define _STRC 0x04 #define _G1STRC 0x04 #define _STRD 0x08 #define _G1STRD 0x08 #define _SDATA 0x10 #define _G1SDATA 0x10 #define _SDATB 0x20 #define _G1SDATB 0x20 #define _SDATC 0x40 #define _G1SDATC 0x40 #define _SDATD 0x80 #define _G1SDATD 0x80 //============================================================================== //============================================================================== // COG2PHR Bits extern __at(0x070D) __sfr COG2PHR; typedef union { struct { unsigned PHR0 : 1; unsigned PHR1 : 1; unsigned PHR2 : 1; unsigned PHR3 : 1; unsigned PHR4 : 1; unsigned PHR5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G2PHR0 : 1; unsigned G2PHR1 : 1; unsigned G2PHR2 : 1; unsigned G2PHR3 : 1; unsigned G2PHR4 : 1; unsigned G2PHR5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G2PHR : 6; unsigned : 2; }; struct { unsigned PHR : 6; unsigned : 2; }; } __COG2PHRbits_t; extern __at(0x070D) volatile __COG2PHRbits_t COG2PHRbits; #define _COG2PHR_PHR0 0x01 #define _COG2PHR_G2PHR0 0x01 #define _COG2PHR_PHR1 0x02 #define _COG2PHR_G2PHR1 0x02 #define _COG2PHR_PHR2 0x04 #define _COG2PHR_G2PHR2 0x04 #define _COG2PHR_PHR3 0x08 #define _COG2PHR_G2PHR3 0x08 #define _COG2PHR_PHR4 0x10 #define _COG2PHR_G2PHR4 0x10 #define _COG2PHR_PHR5 0x20 #define _COG2PHR_G2PHR5 0x20 //============================================================================== //============================================================================== // COG2PHF Bits extern __at(0x070E) __sfr COG2PHF; typedef union { struct { unsigned PHF0 : 1; unsigned PHF1 : 1; unsigned PHF2 : 1; unsigned PHF3 : 1; unsigned PHF4 : 1; unsigned PHF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G2PHF0 : 1; unsigned G2PHF1 : 1; unsigned G2PHF2 : 1; unsigned G2PHF3 : 1; unsigned G2PHF4 : 1; unsigned G2PHF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G2PHF : 6; unsigned : 2; }; struct { unsigned PHF : 6; unsigned : 2; }; } __COG2PHFbits_t; extern __at(0x070E) volatile __COG2PHFbits_t COG2PHFbits; #define _COG2PHF_PHF0 0x01 #define _COG2PHF_G2PHF0 0x01 #define _COG2PHF_PHF1 0x02 #define _COG2PHF_G2PHF1 0x02 #define _COG2PHF_PHF2 0x04 #define _COG2PHF_G2PHF2 0x04 #define _COG2PHF_PHF3 0x08 #define _COG2PHF_G2PHF3 0x08 #define _COG2PHF_PHF4 0x10 #define _COG2PHF_G2PHF4 0x10 #define _COG2PHF_PHF5 0x20 #define _COG2PHF_G2PHF5 0x20 //============================================================================== //============================================================================== // COG2BLKR Bits extern __at(0x070F) __sfr COG2BLKR; typedef union { struct { unsigned BLKR0 : 1; unsigned BLKR1 : 1; unsigned BLKR2 : 1; unsigned BLKR3 : 1; unsigned BLKR4 : 1; unsigned BLKR5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G2BLKR0 : 1; unsigned G2BLKR1 : 1; unsigned G2BLKR2 : 1; unsigned G2BLKR3 : 1; unsigned G2BLKR4 : 1; unsigned G2BLKR5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G2BLKR : 6; unsigned : 2; }; struct { unsigned BLKR : 6; unsigned : 2; }; } __COG2BLKRbits_t; extern __at(0x070F) volatile __COG2BLKRbits_t COG2BLKRbits; #define _COG2BLKR_BLKR0 0x01 #define _COG2BLKR_G2BLKR0 0x01 #define _COG2BLKR_BLKR1 0x02 #define _COG2BLKR_G2BLKR1 0x02 #define _COG2BLKR_BLKR2 0x04 #define _COG2BLKR_G2BLKR2 0x04 #define _COG2BLKR_BLKR3 0x08 #define _COG2BLKR_G2BLKR3 0x08 #define _COG2BLKR_BLKR4 0x10 #define _COG2BLKR_G2BLKR4 0x10 #define _COG2BLKR_BLKR5 0x20 #define _COG2BLKR_G2BLKR5 0x20 //============================================================================== //============================================================================== // COG2BLKF Bits extern __at(0x0710) __sfr COG2BLKF; typedef union { struct { unsigned BLKF0 : 1; unsigned BLKF1 : 1; unsigned BLKF2 : 1; unsigned BLKF3 : 1; unsigned BLKF4 : 1; unsigned BLKF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G2BLKF0 : 1; unsigned G2BLKF1 : 1; unsigned G2BLKF2 : 1; unsigned G2BLKF3 : 1; unsigned G2BLKF4 : 1; unsigned G2BLKF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned BLKF : 6; unsigned : 2; }; struct { unsigned G2BLKF : 6; unsigned : 2; }; } __COG2BLKFbits_t; extern __at(0x0710) volatile __COG2BLKFbits_t COG2BLKFbits; #define _COG2BLKF_BLKF0 0x01 #define _COG2BLKF_G2BLKF0 0x01 #define _COG2BLKF_BLKF1 0x02 #define _COG2BLKF_G2BLKF1 0x02 #define _COG2BLKF_BLKF2 0x04 #define _COG2BLKF_G2BLKF2 0x04 #define _COG2BLKF_BLKF3 0x08 #define _COG2BLKF_G2BLKF3 0x08 #define _COG2BLKF_BLKF4 0x10 #define _COG2BLKF_G2BLKF4 0x10 #define _COG2BLKF_BLKF5 0x20 #define _COG2BLKF_G2BLKF5 0x20 //============================================================================== //============================================================================== // COG2DBR Bits extern __at(0x0711) __sfr COG2DBR; typedef union { struct { unsigned DBR0 : 1; unsigned DBR1 : 1; unsigned DBR2 : 1; unsigned DBR3 : 1; unsigned DBR4 : 1; unsigned DBR5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G2DBR0 : 1; unsigned G2DBR1 : 1; unsigned G2DBR2 : 1; unsigned G2DBR3 : 1; unsigned G2DBR4 : 1; unsigned G2DBR5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G2DBR : 6; unsigned : 2; }; struct { unsigned DBR : 6; unsigned : 2; }; } __COG2DBRbits_t; extern __at(0x0711) volatile __COG2DBRbits_t COG2DBRbits; #define _COG2DBR_DBR0 0x01 #define _COG2DBR_G2DBR0 0x01 #define _COG2DBR_DBR1 0x02 #define _COG2DBR_G2DBR1 0x02 #define _COG2DBR_DBR2 0x04 #define _COG2DBR_G2DBR2 0x04 #define _COG2DBR_DBR3 0x08 #define _COG2DBR_G2DBR3 0x08 #define _COG2DBR_DBR4 0x10 #define _COG2DBR_G2DBR4 0x10 #define _COG2DBR_DBR5 0x20 #define _COG2DBR_G2DBR5 0x20 //============================================================================== //============================================================================== // COG2DBF Bits extern __at(0x0712) __sfr COG2DBF; typedef union { struct { unsigned DBF0 : 1; unsigned DBF1 : 1; unsigned DBF2 : 1; unsigned DBF3 : 1; unsigned DBF4 : 1; unsigned DBF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G2DBF0 : 1; unsigned G2DBF1 : 1; unsigned G2DBF2 : 1; unsigned G2DBF3 : 1; unsigned G2DBF4 : 1; unsigned G2DBF5 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned DBF : 6; unsigned : 2; }; struct { unsigned G2DBF : 6; unsigned : 2; }; } __COG2DBFbits_t; extern __at(0x0712) volatile __COG2DBFbits_t COG2DBFbits; #define _COG2DBF_DBF0 0x01 #define _COG2DBF_G2DBF0 0x01 #define _COG2DBF_DBF1 0x02 #define _COG2DBF_G2DBF1 0x02 #define _COG2DBF_DBF2 0x04 #define _COG2DBF_G2DBF2 0x04 #define _COG2DBF_DBF3 0x08 #define _COG2DBF_G2DBF3 0x08 #define _COG2DBF_DBF4 0x10 #define _COG2DBF_G2DBF4 0x10 #define _COG2DBF_DBF5 0x20 #define _COG2DBF_G2DBF5 0x20 //============================================================================== //============================================================================== // COG2CON0 Bits extern __at(0x0713) __sfr COG2CON0; typedef union { struct { unsigned MD0 : 1; unsigned MD1 : 1; unsigned MD2 : 1; unsigned CS0 : 1; unsigned CS1 : 1; unsigned : 1; unsigned LD : 1; unsigned EN : 1; }; struct { unsigned G2MD0 : 1; unsigned G2MD1 : 1; unsigned G2MD2 : 1; unsigned G2CS0 : 1; unsigned G2CS1 : 1; unsigned : 1; unsigned G2LD : 1; unsigned G2EN : 1; }; struct { unsigned MD : 3; unsigned : 5; }; struct { unsigned G2MD : 3; unsigned : 5; }; struct { unsigned : 3; unsigned G2CS : 2; unsigned : 3; }; struct { unsigned : 3; unsigned CS : 2; unsigned : 3; }; } __COG2CON0bits_t; extern __at(0x0713) volatile __COG2CON0bits_t COG2CON0bits; #define _COG2CON0_MD0 0x01 #define _COG2CON0_G2MD0 0x01 #define _COG2CON0_MD1 0x02 #define _COG2CON0_G2MD1 0x02 #define _COG2CON0_MD2 0x04 #define _COG2CON0_G2MD2 0x04 #define _COG2CON0_CS0 0x08 #define _COG2CON0_G2CS0 0x08 #define _COG2CON0_CS1 0x10 #define _COG2CON0_G2CS1 0x10 #define _COG2CON0_LD 0x40 #define _COG2CON0_G2LD 0x40 #define _COG2CON0_EN 0x80 #define _COG2CON0_G2EN 0x80 //============================================================================== //============================================================================== // COG2CON1 Bits extern __at(0x0714) __sfr COG2CON1; typedef union { struct { unsigned POLA : 1; unsigned POLB : 1; unsigned POLC : 1; unsigned POLD : 1; unsigned : 1; unsigned : 1; unsigned FDBS : 1; unsigned RDBS : 1; }; struct { unsigned G2POLA : 1; unsigned G2POLB : 1; unsigned G2POLC : 1; unsigned G2POLD : 1; unsigned : 1; unsigned : 1; unsigned G2FDBS : 1; unsigned G2RDBS : 1; }; } __COG2CON1bits_t; extern __at(0x0714) volatile __COG2CON1bits_t COG2CON1bits; #define _COG2CON1_POLA 0x01 #define _COG2CON1_G2POLA 0x01 #define _COG2CON1_POLB 0x02 #define _COG2CON1_G2POLB 0x02 #define _COG2CON1_POLC 0x04 #define _COG2CON1_G2POLC 0x04 #define _COG2CON1_POLD 0x08 #define _COG2CON1_G2POLD 0x08 #define _COG2CON1_FDBS 0x40 #define _COG2CON1_G2FDBS 0x40 #define _COG2CON1_RDBS 0x80 #define _COG2CON1_G2RDBS 0x80 //============================================================================== //============================================================================== // COG2RIS0 Bits extern __at(0x0715) __sfr COG2RIS0; typedef union { struct { unsigned RIS0 : 1; unsigned RIS1 : 1; unsigned RIS2 : 1; unsigned RIS3 : 1; unsigned RIS4 : 1; unsigned RIS5 : 1; unsigned RIS6 : 1; unsigned RIS7 : 1; }; struct { unsigned G2RIS0 : 1; unsigned G2RIS1 : 1; unsigned G2RIS2 : 1; unsigned G2RIS3 : 1; unsigned G2RIS4 : 1; unsigned G2RIS5 : 1; unsigned G2RIS6 : 1; unsigned G2RIS7 : 1; }; } __COG2RIS0bits_t; extern __at(0x0715) volatile __COG2RIS0bits_t COG2RIS0bits; #define _COG2RIS0_RIS0 0x01 #define _COG2RIS0_G2RIS0 0x01 #define _COG2RIS0_RIS1 0x02 #define _COG2RIS0_G2RIS1 0x02 #define _COG2RIS0_RIS2 0x04 #define _COG2RIS0_G2RIS2 0x04 #define _COG2RIS0_RIS3 0x08 #define _COG2RIS0_G2RIS3 0x08 #define _COG2RIS0_RIS4 0x10 #define _COG2RIS0_G2RIS4 0x10 #define _COG2RIS0_RIS5 0x20 #define _COG2RIS0_G2RIS5 0x20 #define _COG2RIS0_RIS6 0x40 #define _COG2RIS0_G2RIS6 0x40 #define _COG2RIS0_RIS7 0x80 #define _COG2RIS0_G2RIS7 0x80 //============================================================================== //============================================================================== // COG2RIS1 Bits extern __at(0x0716) __sfr COG2RIS1; typedef union { struct { unsigned RIS8 : 1; unsigned RIS9 : 1; unsigned RIS10 : 1; unsigned RIS11 : 1; unsigned RIS12 : 1; unsigned RIS13 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G2RIS8 : 1; unsigned G2RIS9 : 1; unsigned G2RIS10 : 1; unsigned G2RIS11 : 1; unsigned G2RIS12 : 1; unsigned G2RIS13 : 1; unsigned : 1; unsigned : 1; }; } __COG2RIS1bits_t; extern __at(0x0716) volatile __COG2RIS1bits_t COG2RIS1bits; #define _COG2RIS1_RIS8 0x01 #define _COG2RIS1_G2RIS8 0x01 #define _COG2RIS1_RIS9 0x02 #define _COG2RIS1_G2RIS9 0x02 #define _COG2RIS1_RIS10 0x04 #define _COG2RIS1_G2RIS10 0x04 #define _COG2RIS1_RIS11 0x08 #define _COG2RIS1_G2RIS11 0x08 #define _COG2RIS1_RIS12 0x10 #define _COG2RIS1_G2RIS12 0x10 #define _COG2RIS1_RIS13 0x20 #define _COG2RIS1_G2RIS13 0x20 //============================================================================== //============================================================================== // COG2RSIM0 Bits extern __at(0x0717) __sfr COG2RSIM0; typedef union { struct { unsigned RSIM0 : 1; unsigned RSIM1 : 1; unsigned RSIM2 : 1; unsigned RSIM3 : 1; unsigned RSIM4 : 1; unsigned RSIM5 : 1; unsigned RSIM6 : 1; unsigned RSIM7 : 1; }; struct { unsigned G2RSIM0 : 1; unsigned G2RSIM1 : 1; unsigned G2RSIM2 : 1; unsigned G2RSIM3 : 1; unsigned G2RSIM4 : 1; unsigned G2RSIM5 : 1; unsigned G2RSIM6 : 1; unsigned G2RSIM7 : 1; }; } __COG2RSIM0bits_t; extern __at(0x0717) volatile __COG2RSIM0bits_t COG2RSIM0bits; #define _COG2RSIM0_RSIM0 0x01 #define _COG2RSIM0_G2RSIM0 0x01 #define _COG2RSIM0_RSIM1 0x02 #define _COG2RSIM0_G2RSIM1 0x02 #define _COG2RSIM0_RSIM2 0x04 #define _COG2RSIM0_G2RSIM2 0x04 #define _COG2RSIM0_RSIM3 0x08 #define _COG2RSIM0_G2RSIM3 0x08 #define _COG2RSIM0_RSIM4 0x10 #define _COG2RSIM0_G2RSIM4 0x10 #define _COG2RSIM0_RSIM5 0x20 #define _COG2RSIM0_G2RSIM5 0x20 #define _COG2RSIM0_RSIM6 0x40 #define _COG2RSIM0_G2RSIM6 0x40 #define _COG2RSIM0_RSIM7 0x80 #define _COG2RSIM0_G2RSIM7 0x80 //============================================================================== //============================================================================== // COG2RSIM1 Bits extern __at(0x0718) __sfr COG2RSIM1; typedef union { struct { unsigned RSIM8 : 1; unsigned RSIM9 : 1; unsigned RSIM10 : 1; unsigned RSIM11 : 1; unsigned RSIM12 : 1; unsigned RSIM13 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G2RSIM8 : 1; unsigned G2RSIM9 : 1; unsigned G2RSIM10 : 1; unsigned G2RSIM11 : 1; unsigned G2RSIM12 : 1; unsigned G2RSIM13 : 1; unsigned : 1; unsigned : 1; }; } __COG2RSIM1bits_t; extern __at(0x0718) volatile __COG2RSIM1bits_t COG2RSIM1bits; #define _COG2RSIM1_RSIM8 0x01 #define _COG2RSIM1_G2RSIM8 0x01 #define _COG2RSIM1_RSIM9 0x02 #define _COG2RSIM1_G2RSIM9 0x02 #define _COG2RSIM1_RSIM10 0x04 #define _COG2RSIM1_G2RSIM10 0x04 #define _COG2RSIM1_RSIM11 0x08 #define _COG2RSIM1_G2RSIM11 0x08 #define _COG2RSIM1_RSIM12 0x10 #define _COG2RSIM1_G2RSIM12 0x10 #define _COG2RSIM1_RSIM13 0x20 #define _COG2RSIM1_G2RSIM13 0x20 //============================================================================== //============================================================================== // COG2FIS0 Bits extern __at(0x0719) __sfr COG2FIS0; typedef union { struct { unsigned FIS0 : 1; unsigned FIS1 : 1; unsigned FIS2 : 1; unsigned FIS3 : 1; unsigned FIS4 : 1; unsigned FIS5 : 1; unsigned FIS6 : 1; unsigned FIS7 : 1; }; struct { unsigned G2FIS0 : 1; unsigned G2FIS1 : 1; unsigned G2FIS2 : 1; unsigned G2FIS3 : 1; unsigned G2FIS4 : 1; unsigned G2FIS5 : 1; unsigned G2FIS6 : 1; unsigned G2FIS7 : 1; }; } __COG2FIS0bits_t; extern __at(0x0719) volatile __COG2FIS0bits_t COG2FIS0bits; #define _COG2FIS0_FIS0 0x01 #define _COG2FIS0_G2FIS0 0x01 #define _COG2FIS0_FIS1 0x02 #define _COG2FIS0_G2FIS1 0x02 #define _COG2FIS0_FIS2 0x04 #define _COG2FIS0_G2FIS2 0x04 #define _COG2FIS0_FIS3 0x08 #define _COG2FIS0_G2FIS3 0x08 #define _COG2FIS0_FIS4 0x10 #define _COG2FIS0_G2FIS4 0x10 #define _COG2FIS0_FIS5 0x20 #define _COG2FIS0_G2FIS5 0x20 #define _COG2FIS0_FIS6 0x40 #define _COG2FIS0_G2FIS6 0x40 #define _COG2FIS0_FIS7 0x80 #define _COG2FIS0_G2FIS7 0x80 //============================================================================== //============================================================================== // COG2FIS1 Bits extern __at(0x071A) __sfr COG2FIS1; typedef union { struct { unsigned FIS8 : 1; unsigned FIS9 : 1; unsigned FIS10 : 1; unsigned FIS11 : 1; unsigned FIS12 : 1; unsigned FIS13 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G2FIS8 : 1; unsigned G2FIS9 : 1; unsigned G2FIS10 : 1; unsigned G2FIS11 : 1; unsigned G2FIS12 : 1; unsigned G2FIS13 : 1; unsigned : 1; unsigned : 1; }; } __COG2FIS1bits_t; extern __at(0x071A) volatile __COG2FIS1bits_t COG2FIS1bits; #define _COG2FIS1_FIS8 0x01 #define _COG2FIS1_G2FIS8 0x01 #define _COG2FIS1_FIS9 0x02 #define _COG2FIS1_G2FIS9 0x02 #define _COG2FIS1_FIS10 0x04 #define _COG2FIS1_G2FIS10 0x04 #define _COG2FIS1_FIS11 0x08 #define _COG2FIS1_G2FIS11 0x08 #define _COG2FIS1_FIS12 0x10 #define _COG2FIS1_G2FIS12 0x10 #define _COG2FIS1_FIS13 0x20 #define _COG2FIS1_G2FIS13 0x20 //============================================================================== //============================================================================== // COG2FSIM0 Bits extern __at(0x071B) __sfr COG2FSIM0; typedef union { struct { unsigned FSIM0 : 1; unsigned FSIM1 : 1; unsigned FSIM2 : 1; unsigned FSIM3 : 1; unsigned FSIM4 : 1; unsigned FSIM5 : 1; unsigned FSIM6 : 1; unsigned FSIM7 : 1; }; struct { unsigned G2FSIM0 : 1; unsigned G2FSIM1 : 1; unsigned G2FSIM2 : 1; unsigned G2FSIM3 : 1; unsigned G2FSIM4 : 1; unsigned G2FSIM5 : 1; unsigned G2FSIM6 : 1; unsigned G2FSIM7 : 1; }; } __COG2FSIM0bits_t; extern __at(0x071B) volatile __COG2FSIM0bits_t COG2FSIM0bits; #define _COG2FSIM0_FSIM0 0x01 #define _COG2FSIM0_G2FSIM0 0x01 #define _COG2FSIM0_FSIM1 0x02 #define _COG2FSIM0_G2FSIM1 0x02 #define _COG2FSIM0_FSIM2 0x04 #define _COG2FSIM0_G2FSIM2 0x04 #define _COG2FSIM0_FSIM3 0x08 #define _COG2FSIM0_G2FSIM3 0x08 #define _COG2FSIM0_FSIM4 0x10 #define _COG2FSIM0_G2FSIM4 0x10 #define _COG2FSIM0_FSIM5 0x20 #define _COG2FSIM0_G2FSIM5 0x20 #define _COG2FSIM0_FSIM6 0x40 #define _COG2FSIM0_G2FSIM6 0x40 #define _COG2FSIM0_FSIM7 0x80 #define _COG2FSIM0_G2FSIM7 0x80 //============================================================================== //============================================================================== // COG2FSIM1 Bits extern __at(0x071C) __sfr COG2FSIM1; typedef union { struct { unsigned FSIM8 : 1; unsigned FSIM9 : 1; unsigned FSIM10 : 1; unsigned FSIM11 : 1; unsigned FSIM12 : 1; unsigned FSIM13 : 1; unsigned : 1; unsigned : 1; }; struct { unsigned G2FSIM8 : 1; unsigned G2FSIM9 : 1; unsigned G2FSIM10 : 1; unsigned G2FSIM11 : 1; unsigned G2FSIM12 : 1; unsigned G2FSIM13 : 1; unsigned : 1; unsigned : 1; }; } __COG2FSIM1bits_t; extern __at(0x071C) volatile __COG2FSIM1bits_t COG2FSIM1bits; #define _COG2FSIM1_FSIM8 0x01 #define _COG2FSIM1_G2FSIM8 0x01 #define _COG2FSIM1_FSIM9 0x02 #define _COG2FSIM1_G2FSIM9 0x02 #define _COG2FSIM1_FSIM10 0x04 #define _COG2FSIM1_G2FSIM10 0x04 #define _COG2FSIM1_FSIM11 0x08 #define _COG2FSIM1_G2FSIM11 0x08 #define _COG2FSIM1_FSIM12 0x10 #define _COG2FSIM1_G2FSIM12 0x10 #define _COG2FSIM1_FSIM13 0x20 #define _COG2FSIM1_G2FSIM13 0x20 //============================================================================== //============================================================================== // COG2ASD0 Bits extern __at(0x071D) __sfr COG2ASD0; typedef union { struct { unsigned : 1; unsigned : 1; unsigned ASDAC0 : 1; unsigned ASDAC1 : 1; unsigned ASDBD0 : 1; unsigned ASDBD1 : 1; unsigned ASREN : 1; unsigned ASE : 1; }; struct { unsigned : 1; unsigned : 1; unsigned G2ASDAC0 : 1; unsigned G2ASDAC1 : 1; unsigned G2ASDBD0 : 1; unsigned G2ASDBD1 : 1; unsigned ARSEN : 1; unsigned G2ASE : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned G2ARSEN : 1; unsigned : 1; }; struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned G2ASREN : 1; unsigned : 1; }; struct { unsigned : 2; unsigned G2ASDAC : 2; unsigned : 4; }; struct { unsigned : 2; unsigned ASDAC : 2; unsigned : 4; }; struct { unsigned : 4; unsigned ASDBD : 2; unsigned : 2; }; struct { unsigned : 4; unsigned G2ASDBD : 2; unsigned : 2; }; } __COG2ASD0bits_t; extern __at(0x071D) volatile __COG2ASD0bits_t COG2ASD0bits; #define _COG2ASD0_ASDAC0 0x04 #define _COG2ASD0_G2ASDAC0 0x04 #define _COG2ASD0_ASDAC1 0x08 #define _COG2ASD0_G2ASDAC1 0x08 #define _COG2ASD0_ASDBD0 0x10 #define _COG2ASD0_G2ASDBD0 0x10 #define _COG2ASD0_ASDBD1 0x20 #define _COG2ASD0_G2ASDBD1 0x20 #define _COG2ASD0_ASREN 0x40 #define _COG2ASD0_ARSEN 0x40 #define _COG2ASD0_G2ARSEN 0x40 #define _COG2ASD0_G2ASREN 0x40 #define _COG2ASD0_ASE 0x80 #define _COG2ASD0_G2ASE 0x80 //============================================================================== //============================================================================== // COG2ASD1 Bits extern __at(0x071E) __sfr COG2ASD1; typedef union { struct { unsigned AS0E : 1; unsigned AS1E : 1; unsigned AS2E : 1; unsigned AS3E : 1; unsigned AS4E : 1; unsigned AS5E : 1; unsigned AS6E : 1; unsigned AS7E : 1; }; struct { unsigned G2AS0E : 1; unsigned G2AS1E : 1; unsigned G2AS2E : 1; unsigned G2AS3E : 1; unsigned G2AS4E : 1; unsigned G2AS5E : 1; unsigned G2AS6E : 1; unsigned G2AS7E : 1; }; } __COG2ASD1bits_t; extern __at(0x071E) volatile __COG2ASD1bits_t COG2ASD1bits; #define _COG2ASD1_AS0E 0x01 #define _COG2ASD1_G2AS0E 0x01 #define _COG2ASD1_AS1E 0x02 #define _COG2ASD1_G2AS1E 0x02 #define _COG2ASD1_AS2E 0x04 #define _COG2ASD1_G2AS2E 0x04 #define _COG2ASD1_AS3E 0x08 #define _COG2ASD1_G2AS3E 0x08 #define _COG2ASD1_AS4E 0x10 #define _COG2ASD1_G2AS4E 0x10 #define _COG2ASD1_AS5E 0x20 #define _COG2ASD1_G2AS5E 0x20 #define _COG2ASD1_AS6E 0x40 #define _COG2ASD1_G2AS6E 0x40 #define _COG2ASD1_AS7E 0x80 #define _COG2ASD1_G2AS7E 0x80 //============================================================================== //============================================================================== // COG2STR Bits extern __at(0x071F) __sfr COG2STR; typedef union { struct { unsigned STRA : 1; unsigned STRB : 1; unsigned STRC : 1; unsigned STRD : 1; unsigned SDATA : 1; unsigned SDATB : 1; unsigned SDATC : 1; unsigned SDATD : 1; }; struct { unsigned G2STRA : 1; unsigned G2STRB : 1; unsigned G2STRC : 1; unsigned G2STRD : 1; unsigned G2SDATA : 1; unsigned G2SDATB : 1; unsigned G2SDATC : 1; unsigned G2SDATD : 1; }; } __COG2STRbits_t; extern __at(0x071F) volatile __COG2STRbits_t COG2STRbits; #define _COG2STR_STRA 0x01 #define _COG2STR_G2STRA 0x01 #define _COG2STR_STRB 0x02 #define _COG2STR_G2STRB 0x02 #define _COG2STR_STRC 0x04 #define _COG2STR_G2STRC 0x04 #define _COG2STR_STRD 0x08 #define _COG2STR_G2STRD 0x08 #define _COG2STR_SDATA 0x10 #define _COG2STR_G2SDATA 0x10 #define _COG2STR_SDATB 0x20 #define _COG2STR_G2SDATB 0x20 #define _COG2STR_SDATC 0x40 #define _COG2STR_G2SDATC 0x40 #define _COG2STR_SDATD 0x80 #define _COG2STR_G2SDATD 0x80 //============================================================================== //============================================================================== // PRG1RTSS Bits extern __at(0x0794) __sfr PRG1RTSS; typedef union { struct { unsigned RTSS0 : 1; unsigned RTSS1 : 1; unsigned RTSS2 : 1; unsigned RTSS3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RG1RTSS0 : 1; unsigned RG1RTSS1 : 1; unsigned RG1RTSS2 : 1; unsigned RG1RTSS3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RG1RTSS : 4; unsigned : 4; }; struct { unsigned RTSS : 4; unsigned : 4; }; } __PRG1RTSSbits_t; extern __at(0x0794) volatile __PRG1RTSSbits_t PRG1RTSSbits; #define _RTSS0 0x01 #define _RG1RTSS0 0x01 #define _RTSS1 0x02 #define _RG1RTSS1 0x02 #define _RTSS2 0x04 #define _RG1RTSS2 0x04 #define _RTSS3 0x08 #define _RG1RTSS3 0x08 //============================================================================== //============================================================================== // PRG1FTSS Bits extern __at(0x0795) __sfr PRG1FTSS; typedef union { struct { unsigned FTSS0 : 1; unsigned FTSS1 : 1; unsigned FTSS2 : 1; unsigned FTSS3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RG1FTSS0 : 1; unsigned RG1FTSS1 : 1; unsigned RG1FTSS2 : 1; unsigned RG1FTSS3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RG1FTSS : 4; unsigned : 4; }; struct { unsigned FTSS : 4; unsigned : 4; }; } __PRG1FTSSbits_t; extern __at(0x0795) volatile __PRG1FTSSbits_t PRG1FTSSbits; #define _FTSS0 0x01 #define _RG1FTSS0 0x01 #define _FTSS1 0x02 #define _RG1FTSS1 0x02 #define _FTSS2 0x04 #define _RG1FTSS2 0x04 #define _FTSS3 0x08 #define _RG1FTSS3 0x08 //============================================================================== //============================================================================== // PRG1INS Bits extern __at(0x0796) __sfr PRG1INS; typedef union { struct { unsigned INS0 : 1; unsigned INS1 : 1; unsigned INS2 : 1; unsigned INS3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RG1INS0 : 1; unsigned RG1INS1 : 1; unsigned RG1INS2 : 1; unsigned RG1INS3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RG1INS : 4; unsigned : 4; }; struct { unsigned INS : 4; unsigned : 4; }; } __PRG1INSbits_t; extern __at(0x0796) volatile __PRG1INSbits_t PRG1INSbits; #define _INS0 0x01 #define _RG1INS0 0x01 #define _INS1 0x02 #define _RG1INS1 0x02 #define _INS2 0x04 #define _RG1INS2 0x04 #define _INS3 0x08 #define _RG1INS3 0x08 //============================================================================== //============================================================================== // PRG1CON0 Bits extern __at(0x0797) __sfr PRG1CON0; typedef union { struct { unsigned GO : 1; unsigned OS : 1; unsigned MODE0 : 1; unsigned MODE1 : 1; unsigned REDG : 1; unsigned FEDG : 1; unsigned : 1; unsigned EN : 1; }; struct { unsigned RG1GO : 1; unsigned RG1OS : 1; unsigned RG1MODE0 : 1; unsigned RG1MODE1 : 1; unsigned RG1REDG : 1; unsigned RG1FEDG : 1; unsigned : 1; unsigned RG1EN : 1; }; struct { unsigned : 2; unsigned MODE : 2; unsigned : 4; }; struct { unsigned : 2; unsigned RG1MODE : 2; unsigned : 4; }; } __PRG1CON0bits_t; extern __at(0x0797) volatile __PRG1CON0bits_t PRG1CON0bits; #define _PRG1CON0_GO 0x01 #define _PRG1CON0_RG1GO 0x01 #define _PRG1CON0_OS 0x02 #define _PRG1CON0_RG1OS 0x02 #define _PRG1CON0_MODE0 0x04 #define _PRG1CON0_RG1MODE0 0x04 #define _PRG1CON0_MODE1 0x08 #define _PRG1CON0_RG1MODE1 0x08 #define _PRG1CON0_REDG 0x10 #define _PRG1CON0_RG1REDG 0x10 #define _PRG1CON0_FEDG 0x20 #define _PRG1CON0_RG1FEDG 0x20 #define _PRG1CON0_EN 0x80 #define _PRG1CON0_RG1EN 0x80 //============================================================================== //============================================================================== // PRG1CON1 Bits extern __at(0x0798) __sfr PRG1CON1; typedef union { struct { unsigned RPOL : 1; unsigned FPOL : 1; unsigned RDY : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RG1RPOL : 1; unsigned RG1FPOL : 1; unsigned RG1RDY : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; } __PRG1CON1bits_t; extern __at(0x0798) volatile __PRG1CON1bits_t PRG1CON1bits; #define _RPOL 0x01 #define _RG1RPOL 0x01 #define _FPOL 0x02 #define _RG1FPOL 0x02 #define _RDY 0x04 #define _RG1RDY 0x04 //============================================================================== //============================================================================== // PRG1CON2 Bits extern __at(0x0799) __sfr PRG1CON2; typedef union { struct { unsigned ISET0 : 1; unsigned ISET1 : 1; unsigned ISET2 : 1; unsigned ISET3 : 1; unsigned ISET4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RG1ISET0 : 1; unsigned RG1ISET1 : 1; unsigned RG1ISET2 : 1; unsigned RG1ISET3 : 1; unsigned RG1ISET4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RG1ISET : 5; unsigned : 3; }; struct { unsigned ISET : 5; unsigned : 3; }; } __PRG1CON2bits_t; extern __at(0x0799) volatile __PRG1CON2bits_t PRG1CON2bits; #define _ISET0 0x01 #define _RG1ISET0 0x01 #define _ISET1 0x02 #define _RG1ISET1 0x02 #define _ISET2 0x04 #define _RG1ISET2 0x04 #define _ISET3 0x08 #define _RG1ISET3 0x08 #define _ISET4 0x10 #define _RG1ISET4 0x10 //============================================================================== //============================================================================== // PRG2RTSS Bits extern __at(0x079A) __sfr PRG2RTSS; typedef union { struct { unsigned RTSS0 : 1; unsigned RTSS1 : 1; unsigned RTSS2 : 1; unsigned RTSS3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RG2RTSS0 : 1; unsigned RG2RTSS1 : 1; unsigned RG2RTSS2 : 1; unsigned RG2RTSS3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RG2RTSS : 4; unsigned : 4; }; struct { unsigned RTSS : 4; unsigned : 4; }; } __PRG2RTSSbits_t; extern __at(0x079A) volatile __PRG2RTSSbits_t PRG2RTSSbits; #define _PRG2RTSS_RTSS0 0x01 #define _PRG2RTSS_RG2RTSS0 0x01 #define _PRG2RTSS_RTSS1 0x02 #define _PRG2RTSS_RG2RTSS1 0x02 #define _PRG2RTSS_RTSS2 0x04 #define _PRG2RTSS_RG2RTSS2 0x04 #define _PRG2RTSS_RTSS3 0x08 #define _PRG2RTSS_RG2RTSS3 0x08 //============================================================================== //============================================================================== // PRG2FTSS Bits extern __at(0x079B) __sfr PRG2FTSS; typedef union { struct { unsigned FTSS0 : 1; unsigned FTSS1 : 1; unsigned FTSS2 : 1; unsigned FTSS3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RG2FTSS0 : 1; unsigned RG2FTSS1 : 1; unsigned RG2FTSS2 : 1; unsigned RG2FTSS3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RG2FTSS : 4; unsigned : 4; }; struct { unsigned FTSS : 4; unsigned : 4; }; } __PRG2FTSSbits_t; extern __at(0x079B) volatile __PRG2FTSSbits_t PRG2FTSSbits; #define _PRG2FTSS_FTSS0 0x01 #define _PRG2FTSS_RG2FTSS0 0x01 #define _PRG2FTSS_FTSS1 0x02 #define _PRG2FTSS_RG2FTSS1 0x02 #define _PRG2FTSS_FTSS2 0x04 #define _PRG2FTSS_RG2FTSS2 0x04 #define _PRG2FTSS_FTSS3 0x08 #define _PRG2FTSS_RG2FTSS3 0x08 //============================================================================== //============================================================================== // PRG2INS Bits extern __at(0x079C) __sfr PRG2INS; typedef union { struct { unsigned INS0 : 1; unsigned INS1 : 1; unsigned INS2 : 1; unsigned INS3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RG2INS0 : 1; unsigned RG2INS1 : 1; unsigned RG2INS2 : 1; unsigned RG2INS3 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned INS : 4; unsigned : 4; }; struct { unsigned RG2INS : 4; unsigned : 4; }; } __PRG2INSbits_t; extern __at(0x079C) volatile __PRG2INSbits_t PRG2INSbits; #define _PRG2INS_INS0 0x01 #define _PRG2INS_RG2INS0 0x01 #define _PRG2INS_INS1 0x02 #define _PRG2INS_RG2INS1 0x02 #define _PRG2INS_INS2 0x04 #define _PRG2INS_RG2INS2 0x04 #define _PRG2INS_INS3 0x08 #define _PRG2INS_RG2INS3 0x08 //============================================================================== //============================================================================== // PRG2CON0 Bits extern __at(0x079D) __sfr PRG2CON0; typedef union { struct { unsigned GO : 1; unsigned OS : 1; unsigned MODE0 : 1; unsigned MODE1 : 1; unsigned REDG : 1; unsigned FEDG : 1; unsigned : 1; unsigned EN : 1; }; struct { unsigned RG2GO : 1; unsigned RG2OS : 1; unsigned RG2MODE0 : 1; unsigned RG2MODE1 : 1; unsigned RG2REDG : 1; unsigned RG2FEDG : 1; unsigned : 1; unsigned RG2EN : 1; }; struct { unsigned : 2; unsigned RG2MODE : 2; unsigned : 4; }; struct { unsigned : 2; unsigned MODE : 2; unsigned : 4; }; } __PRG2CON0bits_t; extern __at(0x079D) volatile __PRG2CON0bits_t PRG2CON0bits; #define _PRG2CON0_GO 0x01 #define _PRG2CON0_RG2GO 0x01 #define _PRG2CON0_OS 0x02 #define _PRG2CON0_RG2OS 0x02 #define _PRG2CON0_MODE0 0x04 #define _PRG2CON0_RG2MODE0 0x04 #define _PRG2CON0_MODE1 0x08 #define _PRG2CON0_RG2MODE1 0x08 #define _PRG2CON0_REDG 0x10 #define _PRG2CON0_RG2REDG 0x10 #define _PRG2CON0_FEDG 0x20 #define _PRG2CON0_RG2FEDG 0x20 #define _PRG2CON0_EN 0x80 #define _PRG2CON0_RG2EN 0x80 //============================================================================== //============================================================================== // PRG2CON1 Bits extern __at(0x079E) __sfr PRG2CON1; typedef union { struct { unsigned RPOL : 1; unsigned FPOL : 1; unsigned RDY : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RG2RPOL : 1; unsigned RG2FPOL : 1; unsigned RG2RDY : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; } __PRG2CON1bits_t; extern __at(0x079E) volatile __PRG2CON1bits_t PRG2CON1bits; #define _PRG2CON1_RPOL 0x01 #define _PRG2CON1_RG2RPOL 0x01 #define _PRG2CON1_FPOL 0x02 #define _PRG2CON1_RG2FPOL 0x02 #define _PRG2CON1_RDY 0x04 #define _PRG2CON1_RG2RDY 0x04 //============================================================================== //============================================================================== // PRG2CON2 Bits extern __at(0x079F) __sfr PRG2CON2; typedef union { struct { unsigned ISET0 : 1; unsigned ISET1 : 1; unsigned ISET2 : 1; unsigned ISET3 : 1; unsigned ISET4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned RG2ISET0 : 1; unsigned RG2ISET1 : 1; unsigned RG2ISET2 : 1; unsigned RG2ISET3 : 1; unsigned RG2ISET4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned ISET : 5; unsigned : 3; }; struct { unsigned RG2ISET : 5; unsigned : 3; }; } __PRG2CON2bits_t; extern __at(0x079F) volatile __PRG2CON2bits_t PRG2CON2bits; #define _PRG2CON2_ISET0 0x01 #define _PRG2CON2_RG2ISET0 0x01 #define _PRG2CON2_ISET1 0x02 #define _PRG2CON2_RG2ISET1 0x02 #define _PRG2CON2_ISET2 0x04 #define _PRG2CON2_RG2ISET2 0x04 #define _PRG2CON2_ISET3 0x08 #define _PRG2CON2_RG2ISET3 0x08 #define _PRG2CON2_ISET4 0x10 #define _PRG2CON2_RG2ISET4 0x10 //============================================================================== //============================================================================== // PWMEN Bits extern __at(0x0D8E) __sfr PWMEN; typedef struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned MPWM5EN : 1; unsigned MPWM6EN : 1; unsigned : 1; unsigned : 1; } __PWMENbits_t; extern __at(0x0D8E) volatile __PWMENbits_t PWMENbits; #define _MPWM5EN 0x10 #define _MPWM6EN 0x20 //============================================================================== //============================================================================== // PWMLD Bits extern __at(0x0D8F) __sfr PWMLD; typedef struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned MPWM5LD : 1; unsigned MPWM6LD : 1; unsigned : 1; unsigned : 1; } __PWMLDbits_t; extern __at(0x0D8F) volatile __PWMLDbits_t PWMLDbits; #define _MPWM5LD 0x10 #define _MPWM6LD 0x20 //============================================================================== //============================================================================== // PWMOUT Bits extern __at(0x0D90) __sfr PWMOUT; typedef struct { unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned MPWM5OUT : 1; unsigned MPWM6OUT : 1; unsigned : 1; unsigned : 1; } __PWMOUTbits_t; extern __at(0x0D90) volatile __PWMOUTbits_t PWMOUTbits; #define _MPWM5OUT 0x10 #define _MPWM6OUT 0x20 //============================================================================== extern __at(0x0D91) __sfr PWM5PH; //============================================================================== // PWM5PHL Bits extern __at(0x0D91) __sfr PWM5PHL; typedef struct { unsigned PWM5PHL0 : 1; unsigned PWM5PHL1 : 1; unsigned PWM5PHL2 : 1; unsigned PWM5PHL3 : 1; unsigned PWM5PHL4 : 1; unsigned PWM5PHL5 : 1; unsigned PWM5PHL6 : 1; unsigned PWM5PHL7 : 1; } __PWM5PHLbits_t; extern __at(0x0D91) volatile __PWM5PHLbits_t PWM5PHLbits; #define _PWM5PHL0 0x01 #define _PWM5PHL1 0x02 #define _PWM5PHL2 0x04 #define _PWM5PHL3 0x08 #define _PWM5PHL4 0x10 #define _PWM5PHL5 0x20 #define _PWM5PHL6 0x40 #define _PWM5PHL7 0x80 //============================================================================== //============================================================================== // PWM5PHH Bits extern __at(0x0D92) __sfr PWM5PHH; typedef struct { unsigned PWM5PHH0 : 1; unsigned PWM5PHH1 : 1; unsigned PWM5PHH2 : 1; unsigned PWM5PHH3 : 1; unsigned PWM5PHH4 : 1; unsigned PWM5PHH5 : 1; unsigned PWM5PHH6 : 1; unsigned PWM5PHH7 : 1; } __PWM5PHHbits_t; extern __at(0x0D92) volatile __PWM5PHHbits_t PWM5PHHbits; #define _PWM5PHH0 0x01 #define _PWM5PHH1 0x02 #define _PWM5PHH2 0x04 #define _PWM5PHH3 0x08 #define _PWM5PHH4 0x10 #define _PWM5PHH5 0x20 #define _PWM5PHH6 0x40 #define _PWM5PHH7 0x80 //============================================================================== extern __at(0x0D93) __sfr PWM5DC; //============================================================================== // PWM5DCL Bits extern __at(0x0D93) __sfr PWM5DCL; typedef struct { unsigned PWM5DCL0 : 1; unsigned PWM5DCL1 : 1; unsigned PWM5DCL2 : 1; unsigned PWM5DCL3 : 1; unsigned PWM5DCL4 : 1; unsigned PWM5DCL5 : 1; unsigned PWM5DCL6 : 1; unsigned PWM5DCL7 : 1; } __PWM5DCLbits_t; extern __at(0x0D93) volatile __PWM5DCLbits_t PWM5DCLbits; #define _PWM5DCL0 0x01 #define _PWM5DCL1 0x02 #define _PWM5DCL2 0x04 #define _PWM5DCL3 0x08 #define _PWM5DCL4 0x10 #define _PWM5DCL5 0x20 #define _PWM5DCL6 0x40 #define _PWM5DCL7 0x80 //============================================================================== //============================================================================== // PWM5DCH Bits extern __at(0x0D94) __sfr PWM5DCH; typedef struct { unsigned PWM5DCH0 : 1; unsigned PWM5DCH1 : 1; unsigned PWM5DCH2 : 1; unsigned PWM5DCH3 : 1; unsigned PWM5DCH4 : 1; unsigned PWM5DCH5 : 1; unsigned PWM5DCH6 : 1; unsigned PWM5DCH7 : 1; } __PWM5DCHbits_t; extern __at(0x0D94) volatile __PWM5DCHbits_t PWM5DCHbits; #define _PWM5DCH0 0x01 #define _PWM5DCH1 0x02 #define _PWM5DCH2 0x04 #define _PWM5DCH3 0x08 #define _PWM5DCH4 0x10 #define _PWM5DCH5 0x20 #define _PWM5DCH6 0x40 #define _PWM5DCH7 0x80 //============================================================================== extern __at(0x0D95) __sfr PWM5PR; //============================================================================== // PWM5PRL Bits extern __at(0x0D95) __sfr PWM5PRL; typedef struct { unsigned PWM5PRL0 : 1; unsigned PWM5PRL1 : 1; unsigned PWM5PRL2 : 1; unsigned PWM5PRL3 : 1; unsigned PWM5PRL4 : 1; unsigned PWM5PRL5 : 1; unsigned PWM5PRL6 : 1; unsigned PWM5PRL7 : 1; } __PWM5PRLbits_t; extern __at(0x0D95) volatile __PWM5PRLbits_t PWM5PRLbits; #define _PWM5PRL0 0x01 #define _PWM5PRL1 0x02 #define _PWM5PRL2 0x04 #define _PWM5PRL3 0x08 #define _PWM5PRL4 0x10 #define _PWM5PRL5 0x20 #define _PWM5PRL6 0x40 #define _PWM5PRL7 0x80 //============================================================================== //============================================================================== // PWM5PRH Bits extern __at(0x0D96) __sfr PWM5PRH; typedef struct { unsigned PWM5PRH0 : 1; unsigned PWM5PRH1 : 1; unsigned PWM5PRH2 : 1; unsigned PWM5PRH3 : 1; unsigned PWM5PRH4 : 1; unsigned PWM5PRH5 : 1; unsigned PWM5PRH6 : 1; unsigned PWM5PRH7 : 1; } __PWM5PRHbits_t; extern __at(0x0D96) volatile __PWM5PRHbits_t PWM5PRHbits; #define _PWM5PRH0 0x01 #define _PWM5PRH1 0x02 #define _PWM5PRH2 0x04 #define _PWM5PRH3 0x08 #define _PWM5PRH4 0x10 #define _PWM5PRH5 0x20 #define _PWM5PRH6 0x40 #define _PWM5PRH7 0x80 //============================================================================== extern __at(0x0D97) __sfr PWM5OF; //============================================================================== // PWM5OFL Bits extern __at(0x0D97) __sfr PWM5OFL; typedef struct { unsigned PWM5OFL0 : 1; unsigned PWM5OFL1 : 1; unsigned PWM5OFL2 : 1; unsigned PWM5OFL3 : 1; unsigned PWM5OFL4 : 1; unsigned PWM5OFL5 : 1; unsigned PWM5OFL6 : 1; unsigned PWM5OFL7 : 1; } __PWM5OFLbits_t; extern __at(0x0D97) volatile __PWM5OFLbits_t PWM5OFLbits; #define _PWM5OFL0 0x01 #define _PWM5OFL1 0x02 #define _PWM5OFL2 0x04 #define _PWM5OFL3 0x08 #define _PWM5OFL4 0x10 #define _PWM5OFL5 0x20 #define _PWM5OFL6 0x40 #define _PWM5OFL7 0x80 //============================================================================== //============================================================================== // PWM5OFH Bits extern __at(0x0D98) __sfr PWM5OFH; typedef struct { unsigned PWM5OFH0 : 1; unsigned PWM5OFH1 : 1; unsigned PWM5OFH2 : 1; unsigned PWM5OFH3 : 1; unsigned PWM5OFH4 : 1; unsigned PWM5OFH5 : 1; unsigned PWM5OFH6 : 1; unsigned PWM5OFH7 : 1; } __PWM5OFHbits_t; extern __at(0x0D98) volatile __PWM5OFHbits_t PWM5OFHbits; #define _PWM5OFH0 0x01 #define _PWM5OFH1 0x02 #define _PWM5OFH2 0x04 #define _PWM5OFH3 0x08 #define _PWM5OFH4 0x10 #define _PWM5OFH5 0x20 #define _PWM5OFH6 0x40 #define _PWM5OFH7 0x80 //============================================================================== extern __at(0x0D99) __sfr PWM5TMR; //============================================================================== // PWM5TMRL Bits extern __at(0x0D99) __sfr PWM5TMRL; typedef struct { unsigned PWM5TMRL0 : 1; unsigned PWM5TMRL1 : 1; unsigned PWM5TMRL2 : 1; unsigned PWM5TMRL3 : 1; unsigned PWM5TMRL4 : 1; unsigned PWM5TMRL5 : 1; unsigned PWM5TMRL6 : 1; unsigned PWM5TMRL7 : 1; } __PWM5TMRLbits_t; extern __at(0x0D99) volatile __PWM5TMRLbits_t PWM5TMRLbits; #define _PWM5TMRL0 0x01 #define _PWM5TMRL1 0x02 #define _PWM5TMRL2 0x04 #define _PWM5TMRL3 0x08 #define _PWM5TMRL4 0x10 #define _PWM5TMRL5 0x20 #define _PWM5TMRL6 0x40 #define _PWM5TMRL7 0x80 //============================================================================== //============================================================================== // PWM5TMRH Bits extern __at(0x0D9A) __sfr PWM5TMRH; typedef struct { unsigned PWM5TMRH0 : 1; unsigned PWM5TMRH1 : 1; unsigned PWM5TMRH2 : 1; unsigned PWM5TMRH3 : 1; unsigned PWM5TMRH4 : 1; unsigned PWM5TMRH5 : 1; unsigned PWM5TMRH6 : 1; unsigned PWM5TMRH7 : 1; } __PWM5TMRHbits_t; extern __at(0x0D9A) volatile __PWM5TMRHbits_t PWM5TMRHbits; #define _PWM5TMRH0 0x01 #define _PWM5TMRH1 0x02 #define _PWM5TMRH2 0x04 #define _PWM5TMRH3 0x08 #define _PWM5TMRH4 0x10 #define _PWM5TMRH5 0x20 #define _PWM5TMRH6 0x40 #define _PWM5TMRH7 0x80 //============================================================================== //============================================================================== // PWM5CON Bits extern __at(0x0D9B) __sfr PWM5CON; typedef union { struct { unsigned : 1; unsigned : 1; unsigned PWM5MODE0 : 1; unsigned PWM5MODE1 : 1; unsigned POL : 1; unsigned OUT : 1; unsigned : 1; unsigned EN : 1; }; struct { unsigned : 1; unsigned : 1; unsigned MODE0 : 1; unsigned MODE1 : 1; unsigned PWM5POL : 1; unsigned PWM5OUT : 1; unsigned : 1; unsigned PWM5EN : 1; }; struct { unsigned : 2; unsigned PWM5MODE : 2; unsigned : 4; }; struct { unsigned : 2; unsigned MODE : 2; unsigned : 4; }; } __PWM5CONbits_t; extern __at(0x0D9B) volatile __PWM5CONbits_t PWM5CONbits; #define _PWM5CON_PWM5MODE0 0x04 #define _PWM5CON_MODE0 0x04 #define _PWM5CON_PWM5MODE1 0x08 #define _PWM5CON_MODE1 0x08 #define _PWM5CON_POL 0x10 #define _PWM5CON_PWM5POL 0x10 #define _PWM5CON_OUT 0x20 #define _PWM5CON_PWM5OUT 0x20 #define _PWM5CON_EN 0x80 #define _PWM5CON_PWM5EN 0x80 //============================================================================== //============================================================================== // PWM5INTCON Bits extern __at(0x0D9C) __sfr PWM5INTCON; typedef union { struct { unsigned PRIE : 1; unsigned DCIE : 1; unsigned PHIE : 1; unsigned OFIE : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned PWM5PRIE : 1; unsigned PWM5DCIE : 1; unsigned PWM5PHIE : 1; unsigned PWM5OFIE : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; } __PWM5INTCONbits_t; extern __at(0x0D9C) volatile __PWM5INTCONbits_t PWM5INTCONbits; #define _PRIE 0x01 #define _PWM5PRIE 0x01 #define _DCIE 0x02 #define _PWM5DCIE 0x02 #define _PHIE 0x04 #define _PWM5PHIE 0x04 #define _OFIE 0x08 #define _PWM5OFIE 0x08 //============================================================================== //============================================================================== // PWM5INTE Bits extern __at(0x0D9C) __sfr PWM5INTE; typedef union { struct { unsigned PRIE : 1; unsigned DCIE : 1; unsigned PHIE : 1; unsigned OFIE : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned PWM5PRIE : 1; unsigned PWM5DCIE : 1; unsigned PWM5PHIE : 1; unsigned PWM5OFIE : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; } __PWM5INTEbits_t; extern __at(0x0D9C) volatile __PWM5INTEbits_t PWM5INTEbits; #define _PWM5INTE_PRIE 0x01 #define _PWM5INTE_PWM5PRIE 0x01 #define _PWM5INTE_DCIE 0x02 #define _PWM5INTE_PWM5DCIE 0x02 #define _PWM5INTE_PHIE 0x04 #define _PWM5INTE_PWM5PHIE 0x04 #define _PWM5INTE_OFIE 0x08 #define _PWM5INTE_PWM5OFIE 0x08 //============================================================================== //============================================================================== // PWM5INTF Bits extern __at(0x0D9D) __sfr PWM5INTF; typedef union { struct { unsigned PRIF : 1; unsigned DCIF : 1; unsigned PHIF : 1; unsigned OFIF : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned PWM5PRIF : 1; unsigned PWM5DCIF : 1; unsigned PWM5PHIF : 1; unsigned PWM5OFIF : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; } __PWM5INTFbits_t; extern __at(0x0D9D) volatile __PWM5INTFbits_t PWM5INTFbits; #define _PRIF 0x01 #define _PWM5PRIF 0x01 #define _DCIF 0x02 #define _PWM5DCIF 0x02 #define _PHIF 0x04 #define _PWM5PHIF 0x04 #define _OFIF 0x08 #define _PWM5OFIF 0x08 //============================================================================== //============================================================================== // PWM5INTFLG Bits extern __at(0x0D9D) __sfr PWM5INTFLG; typedef union { struct { unsigned PRIF : 1; unsigned DCIF : 1; unsigned PHIF : 1; unsigned OFIF : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned PWM5PRIF : 1; unsigned PWM5DCIF : 1; unsigned PWM5PHIF : 1; unsigned PWM5OFIF : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; } __PWM5INTFLGbits_t; extern __at(0x0D9D) volatile __PWM5INTFLGbits_t PWM5INTFLGbits; #define _PWM5INTFLG_PRIF 0x01 #define _PWM5INTFLG_PWM5PRIF 0x01 #define _PWM5INTFLG_DCIF 0x02 #define _PWM5INTFLG_PWM5DCIF 0x02 #define _PWM5INTFLG_PHIF 0x04 #define _PWM5INTFLG_PWM5PHIF 0x04 #define _PWM5INTFLG_OFIF 0x08 #define _PWM5INTFLG_PWM5OFIF 0x08 //============================================================================== //============================================================================== // PWM5CLKCON Bits extern __at(0x0D9E) __sfr PWM5CLKCON; typedef union { struct { unsigned PWM5CS0 : 1; unsigned PWM5CS1 : 1; unsigned PWM5CS2 : 1; unsigned : 1; unsigned PWM5PS0 : 1; unsigned PWM5PS1 : 1; unsigned PWM5PS2 : 1; unsigned : 1; }; struct { unsigned CS0 : 1; unsigned CS1 : 1; unsigned CS2 : 1; unsigned : 1; unsigned PS0 : 1; unsigned PS1 : 1; unsigned PS2 : 1; unsigned : 1; }; struct { unsigned PWM5CS : 3; unsigned : 5; }; struct { unsigned CS : 3; unsigned : 5; }; struct { unsigned : 4; unsigned PS : 3; unsigned : 1; }; struct { unsigned : 4; unsigned PWM5PS : 3; unsigned : 1; }; } __PWM5CLKCONbits_t; extern __at(0x0D9E) volatile __PWM5CLKCONbits_t PWM5CLKCONbits; #define _PWM5CLKCON_PWM5CS0 0x01 #define _PWM5CLKCON_CS0 0x01 #define _PWM5CLKCON_PWM5CS1 0x02 #define _PWM5CLKCON_CS1 0x02 #define _PWM5CLKCON_PWM5CS2 0x04 #define _PWM5CLKCON_CS2 0x04 #define _PWM5CLKCON_PWM5PS0 0x10 #define _PWM5CLKCON_PS0 0x10 #define _PWM5CLKCON_PWM5PS1 0x20 #define _PWM5CLKCON_PS1 0x20 #define _PWM5CLKCON_PWM5PS2 0x40 #define _PWM5CLKCON_PS2 0x40 //============================================================================== //============================================================================== // PWM5LDCON Bits extern __at(0x0D9F) __sfr PWM5LDCON; typedef union { struct { unsigned PWM5LDS0 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned LDT : 1; unsigned LDA : 1; }; struct { unsigned LDS0 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned PWM5LDM : 1; unsigned PWM5LD : 1; }; } __PWM5LDCONbits_t; extern __at(0x0D9F) volatile __PWM5LDCONbits_t PWM5LDCONbits; #define _PWM5LDS0 0x01 #define _LDS0 0x01 #define _LDT 0x40 #define _PWM5LDM 0x40 #define _LDA 0x80 #define _PWM5LD 0x80 //============================================================================== //============================================================================== // PWM5OFCON Bits extern __at(0x0DA0) __sfr PWM5OFCON; typedef union { struct { unsigned PWM5OFS0 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned OFO : 1; unsigned PWM5OFM0 : 1; unsigned PWM5OFM1 : 1; unsigned : 1; }; struct { unsigned OFS0 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned PWM5OFMC : 1; unsigned OFM0 : 1; unsigned OFM1 : 1; unsigned : 1; }; struct { unsigned : 5; unsigned PWM5OFM : 2; unsigned : 1; }; struct { unsigned : 5; unsigned OFM : 2; unsigned : 1; }; } __PWM5OFCONbits_t; extern __at(0x0DA0) volatile __PWM5OFCONbits_t PWM5OFCONbits; #define _PWM5OFS0 0x01 #define _OFS0 0x01 #define _OFO 0x10 #define _PWM5OFMC 0x10 #define _PWM5OFM0 0x20 #define _OFM0 0x20 #define _PWM5OFM1 0x40 #define _OFM1 0x40 //============================================================================== extern __at(0x0DA1) __sfr PWM6PH; //============================================================================== // PWM6PHL Bits extern __at(0x0DA1) __sfr PWM6PHL; typedef struct { unsigned PWM6PHL0 : 1; unsigned PWM6PHL1 : 1; unsigned PWM6PHL2 : 1; unsigned PWM6PHL3 : 1; unsigned PWM6PHL4 : 1; unsigned PWM6PHL5 : 1; unsigned PWM6PHL6 : 1; unsigned PWM6PHL7 : 1; } __PWM6PHLbits_t; extern __at(0x0DA1) volatile __PWM6PHLbits_t PWM6PHLbits; #define _PWM6PHL0 0x01 #define _PWM6PHL1 0x02 #define _PWM6PHL2 0x04 #define _PWM6PHL3 0x08 #define _PWM6PHL4 0x10 #define _PWM6PHL5 0x20 #define _PWM6PHL6 0x40 #define _PWM6PHL7 0x80 //============================================================================== //============================================================================== // PWM6PHH Bits extern __at(0x0DA2) __sfr PWM6PHH; typedef struct { unsigned PWM6PHH0 : 1; unsigned PWM6PHH1 : 1; unsigned PWM6PHH2 : 1; unsigned PWM6PHH3 : 1; unsigned PWM6PHH4 : 1; unsigned PWM6PHH5 : 1; unsigned PWM6PHH6 : 1; unsigned PWM6PHH7 : 1; } __PWM6PHHbits_t; extern __at(0x0DA2) volatile __PWM6PHHbits_t PWM6PHHbits; #define _PWM6PHH0 0x01 #define _PWM6PHH1 0x02 #define _PWM6PHH2 0x04 #define _PWM6PHH3 0x08 #define _PWM6PHH4 0x10 #define _PWM6PHH5 0x20 #define _PWM6PHH6 0x40 #define _PWM6PHH7 0x80 //============================================================================== extern __at(0x0DA3) __sfr PWM6DC; //============================================================================== // PWM6DCL Bits extern __at(0x0DA3) __sfr PWM6DCL; typedef struct { unsigned PWM6DCL0 : 1; unsigned PWM6DCL1 : 1; unsigned PWM6DCL2 : 1; unsigned PWM6DCL3 : 1; unsigned PWM6DCL4 : 1; unsigned PWM6DCL5 : 1; unsigned PWM6DCL6 : 1; unsigned PWM6DCL7 : 1; } __PWM6DCLbits_t; extern __at(0x0DA3) volatile __PWM6DCLbits_t PWM6DCLbits; #define _PWM6DCL0 0x01 #define _PWM6DCL1 0x02 #define _PWM6DCL2 0x04 #define _PWM6DCL3 0x08 #define _PWM6DCL4 0x10 #define _PWM6DCL5 0x20 #define _PWM6DCL6 0x40 #define _PWM6DCL7 0x80 //============================================================================== //============================================================================== // PWM6DCH Bits extern __at(0x0DA4) __sfr PWM6DCH; typedef struct { unsigned PWM6DCH0 : 1; unsigned PWM6DCH1 : 1; unsigned PWM6DCH2 : 1; unsigned PWM6DCH3 : 1; unsigned PWM6DCH4 : 1; unsigned PWM6DCH5 : 1; unsigned PWM6DCH6 : 1; unsigned PWM6DCH7 : 1; } __PWM6DCHbits_t; extern __at(0x0DA4) volatile __PWM6DCHbits_t PWM6DCHbits; #define _PWM6DCH0 0x01 #define _PWM6DCH1 0x02 #define _PWM6DCH2 0x04 #define _PWM6DCH3 0x08 #define _PWM6DCH4 0x10 #define _PWM6DCH5 0x20 #define _PWM6DCH6 0x40 #define _PWM6DCH7 0x80 //============================================================================== extern __at(0x0DA5) __sfr PWM6PR; //============================================================================== // PWM6PRL Bits extern __at(0x0DA5) __sfr PWM6PRL; typedef struct { unsigned PWM6PRL0 : 1; unsigned PWM6PRL1 : 1; unsigned PWM6PRL2 : 1; unsigned PWM6PRL3 : 1; unsigned PWM6PRL4 : 1; unsigned PWM6PRL5 : 1; unsigned PWM6PRL6 : 1; unsigned PWM6PRL7 : 1; } __PWM6PRLbits_t; extern __at(0x0DA5) volatile __PWM6PRLbits_t PWM6PRLbits; #define _PWM6PRL0 0x01 #define _PWM6PRL1 0x02 #define _PWM6PRL2 0x04 #define _PWM6PRL3 0x08 #define _PWM6PRL4 0x10 #define _PWM6PRL5 0x20 #define _PWM6PRL6 0x40 #define _PWM6PRL7 0x80 //============================================================================== //============================================================================== // PWM6PRH Bits extern __at(0x0DA6) __sfr PWM6PRH; typedef struct { unsigned PWM6PRH0 : 1; unsigned PWM6PRH1 : 1; unsigned PWM6PRH2 : 1; unsigned PWM6PRH3 : 1; unsigned PWM6PRH4 : 1; unsigned PWM6PRH5 : 1; unsigned PWM6PRH6 : 1; unsigned PWM6PRH7 : 1; } __PWM6PRHbits_t; extern __at(0x0DA6) volatile __PWM6PRHbits_t PWM6PRHbits; #define _PWM6PRH0 0x01 #define _PWM6PRH1 0x02 #define _PWM6PRH2 0x04 #define _PWM6PRH3 0x08 #define _PWM6PRH4 0x10 #define _PWM6PRH5 0x20 #define _PWM6PRH6 0x40 #define _PWM6PRH7 0x80 //============================================================================== extern __at(0x0DA7) __sfr PWM6OF; //============================================================================== // PWM6OFL Bits extern __at(0x0DA7) __sfr PWM6OFL; typedef struct { unsigned PWM6OFL0 : 1; unsigned PWM6OFL1 : 1; unsigned PWM6OFL2 : 1; unsigned PWM6OFL3 : 1; unsigned PWM6OFL4 : 1; unsigned PWM6OFL5 : 1; unsigned PWM6OFL6 : 1; unsigned PWM6OFL7 : 1; } __PWM6OFLbits_t; extern __at(0x0DA7) volatile __PWM6OFLbits_t PWM6OFLbits; #define _PWM6OFL0 0x01 #define _PWM6OFL1 0x02 #define _PWM6OFL2 0x04 #define _PWM6OFL3 0x08 #define _PWM6OFL4 0x10 #define _PWM6OFL5 0x20 #define _PWM6OFL6 0x40 #define _PWM6OFL7 0x80 //============================================================================== //============================================================================== // PWM6OFH Bits extern __at(0x0DA8) __sfr PWM6OFH; typedef struct { unsigned PWM6OFH0 : 1; unsigned PWM6OFH1 : 1; unsigned PWM6OFH2 : 1; unsigned PWM6OFH3 : 1; unsigned PWM6OFH4 : 1; unsigned PWM6OFH5 : 1; unsigned PWM6OFH6 : 1; unsigned PWM6OFH7 : 1; } __PWM6OFHbits_t; extern __at(0x0DA8) volatile __PWM6OFHbits_t PWM6OFHbits; #define _PWM6OFH0 0x01 #define _PWM6OFH1 0x02 #define _PWM6OFH2 0x04 #define _PWM6OFH3 0x08 #define _PWM6OFH4 0x10 #define _PWM6OFH5 0x20 #define _PWM6OFH6 0x40 #define _PWM6OFH7 0x80 //============================================================================== extern __at(0x0DA9) __sfr PWM6TMR; //============================================================================== // PWM6TMRL Bits extern __at(0x0DA9) __sfr PWM6TMRL; typedef struct { unsigned PWM6TMRL0 : 1; unsigned PWM6TMRL1 : 1; unsigned PWM6TMRL2 : 1; unsigned PWM6TMRL3 : 1; unsigned PWM6TMRL4 : 1; unsigned PWM6TMRL5 : 1; unsigned PWM6TMRL6 : 1; unsigned PWM6TMRL7 : 1; } __PWM6TMRLbits_t; extern __at(0x0DA9) volatile __PWM6TMRLbits_t PWM6TMRLbits; #define _PWM6TMRL0 0x01 #define _PWM6TMRL1 0x02 #define _PWM6TMRL2 0x04 #define _PWM6TMRL3 0x08 #define _PWM6TMRL4 0x10 #define _PWM6TMRL5 0x20 #define _PWM6TMRL6 0x40 #define _PWM6TMRL7 0x80 //============================================================================== //============================================================================== // PWM6TMRH Bits extern __at(0x0DAA) __sfr PWM6TMRH; typedef struct { unsigned PWM6TMRH0 : 1; unsigned PWM6TMRH1 : 1; unsigned PWM6TMRH2 : 1; unsigned PWM6TMRH3 : 1; unsigned PWM6TMRH4 : 1; unsigned PWM6TMRH5 : 1; unsigned PWM6TMRH6 : 1; unsigned PWM6TMRH7 : 1; } __PWM6TMRHbits_t; extern __at(0x0DAA) volatile __PWM6TMRHbits_t PWM6TMRHbits; #define _PWM6TMRH0 0x01 #define _PWM6TMRH1 0x02 #define _PWM6TMRH2 0x04 #define _PWM6TMRH3 0x08 #define _PWM6TMRH4 0x10 #define _PWM6TMRH5 0x20 #define _PWM6TMRH6 0x40 #define _PWM6TMRH7 0x80 //============================================================================== //============================================================================== // PWM6CON Bits extern __at(0x0DAB) __sfr PWM6CON; typedef union { struct { unsigned : 1; unsigned : 1; unsigned PWM6MODE0 : 1; unsigned PWM6MODE1 : 1; unsigned POL : 1; unsigned OUT : 1; unsigned : 1; unsigned EN : 1; }; struct { unsigned : 1; unsigned : 1; unsigned MODE0 : 1; unsigned MODE1 : 1; unsigned PWM6POL : 1; unsigned PWM6OUT : 1; unsigned : 1; unsigned PWM6EN : 1; }; struct { unsigned : 2; unsigned PWM6MODE : 2; unsigned : 4; }; struct { unsigned : 2; unsigned MODE : 2; unsigned : 4; }; } __PWM6CONbits_t; extern __at(0x0DAB) volatile __PWM6CONbits_t PWM6CONbits; #define _PWM6CON_PWM6MODE0 0x04 #define _PWM6CON_MODE0 0x04 #define _PWM6CON_PWM6MODE1 0x08 #define _PWM6CON_MODE1 0x08 #define _PWM6CON_POL 0x10 #define _PWM6CON_PWM6POL 0x10 #define _PWM6CON_OUT 0x20 #define _PWM6CON_PWM6OUT 0x20 #define _PWM6CON_EN 0x80 #define _PWM6CON_PWM6EN 0x80 //============================================================================== //============================================================================== // PWM6INTCON Bits extern __at(0x0DAC) __sfr PWM6INTCON; typedef union { struct { unsigned PRIE : 1; unsigned DCIE : 1; unsigned PHIE : 1; unsigned OFIE : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned PWM6PRIE : 1; unsigned PWM6DCIE : 1; unsigned PWM6PHIE : 1; unsigned PWM6OFIE : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; } __PWM6INTCONbits_t; extern __at(0x0DAC) volatile __PWM6INTCONbits_t PWM6INTCONbits; #define _PWM6INTCON_PRIE 0x01 #define _PWM6INTCON_PWM6PRIE 0x01 #define _PWM6INTCON_DCIE 0x02 #define _PWM6INTCON_PWM6DCIE 0x02 #define _PWM6INTCON_PHIE 0x04 #define _PWM6INTCON_PWM6PHIE 0x04 #define _PWM6INTCON_OFIE 0x08 #define _PWM6INTCON_PWM6OFIE 0x08 //============================================================================== //============================================================================== // PWM6INTE Bits extern __at(0x0DAC) __sfr PWM6INTE; typedef union { struct { unsigned PRIE : 1; unsigned DCIE : 1; unsigned PHIE : 1; unsigned OFIE : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned PWM6PRIE : 1; unsigned PWM6DCIE : 1; unsigned PWM6PHIE : 1; unsigned PWM6OFIE : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; } __PWM6INTEbits_t; extern __at(0x0DAC) volatile __PWM6INTEbits_t PWM6INTEbits; #define _PWM6INTE_PRIE 0x01 #define _PWM6INTE_PWM6PRIE 0x01 #define _PWM6INTE_DCIE 0x02 #define _PWM6INTE_PWM6DCIE 0x02 #define _PWM6INTE_PHIE 0x04 #define _PWM6INTE_PWM6PHIE 0x04 #define _PWM6INTE_OFIE 0x08 #define _PWM6INTE_PWM6OFIE 0x08 //============================================================================== //============================================================================== // PWM6INTF Bits extern __at(0x0DAD) __sfr PWM6INTF; typedef union { struct { unsigned PRIF : 1; unsigned DCIF : 1; unsigned PHIF : 1; unsigned OFIF : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned PWM6PRIF : 1; unsigned PWM6DCIF : 1; unsigned PWM6PHIF : 1; unsigned PWM6OFIF : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; } __PWM6INTFbits_t; extern __at(0x0DAD) volatile __PWM6INTFbits_t PWM6INTFbits; #define _PWM6INTF_PRIF 0x01 #define _PWM6INTF_PWM6PRIF 0x01 #define _PWM6INTF_DCIF 0x02 #define _PWM6INTF_PWM6DCIF 0x02 #define _PWM6INTF_PHIF 0x04 #define _PWM6INTF_PWM6PHIF 0x04 #define _PWM6INTF_OFIF 0x08 #define _PWM6INTF_PWM6OFIF 0x08 //============================================================================== //============================================================================== // PWM6INTFLG Bits extern __at(0x0DAD) __sfr PWM6INTFLG; typedef union { struct { unsigned PRIF : 1; unsigned DCIF : 1; unsigned PHIF : 1; unsigned OFIF : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned PWM6PRIF : 1; unsigned PWM6DCIF : 1; unsigned PWM6PHIF : 1; unsigned PWM6OFIF : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; } __PWM6INTFLGbits_t; extern __at(0x0DAD) volatile __PWM6INTFLGbits_t PWM6INTFLGbits; #define _PWM6INTFLG_PRIF 0x01 #define _PWM6INTFLG_PWM6PRIF 0x01 #define _PWM6INTFLG_DCIF 0x02 #define _PWM6INTFLG_PWM6DCIF 0x02 #define _PWM6INTFLG_PHIF 0x04 #define _PWM6INTFLG_PWM6PHIF 0x04 #define _PWM6INTFLG_OFIF 0x08 #define _PWM6INTFLG_PWM6OFIF 0x08 //============================================================================== //============================================================================== // PWM6CLKCON Bits extern __at(0x0DAE) __sfr PWM6CLKCON; typedef union { struct { unsigned PWM6CS0 : 1; unsigned PWM6CS1 : 1; unsigned PWM6CS2 : 1; unsigned : 1; unsigned PWM6PS0 : 1; unsigned PWM6PS1 : 1; unsigned PWM6PS2 : 1; unsigned : 1; }; struct { unsigned CS0 : 1; unsigned CS1 : 1; unsigned CS2 : 1; unsigned : 1; unsigned PS0 : 1; unsigned PS1 : 1; unsigned PS2 : 1; unsigned : 1; }; struct { unsigned PWM6CS : 3; unsigned : 5; }; struct { unsigned CS : 3; unsigned : 5; }; struct { unsigned : 4; unsigned PS : 3; unsigned : 1; }; struct { unsigned : 4; unsigned PWM6PS : 3; unsigned : 1; }; } __PWM6CLKCONbits_t; extern __at(0x0DAE) volatile __PWM6CLKCONbits_t PWM6CLKCONbits; #define _PWM6CLKCON_PWM6CS0 0x01 #define _PWM6CLKCON_CS0 0x01 #define _PWM6CLKCON_PWM6CS1 0x02 #define _PWM6CLKCON_CS1 0x02 #define _PWM6CLKCON_PWM6CS2 0x04 #define _PWM6CLKCON_CS2 0x04 #define _PWM6CLKCON_PWM6PS0 0x10 #define _PWM6CLKCON_PS0 0x10 #define _PWM6CLKCON_PWM6PS1 0x20 #define _PWM6CLKCON_PS1 0x20 #define _PWM6CLKCON_PWM6PS2 0x40 #define _PWM6CLKCON_PS2 0x40 //============================================================================== //============================================================================== // PWM6LDCON Bits extern __at(0x0DAF) __sfr PWM6LDCON; typedef union { struct { unsigned PWM6LDS0 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned LDT : 1; unsigned LDA : 1; }; struct { unsigned LDS0 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned PWM6LDM : 1; unsigned PWM6LD : 1; }; } __PWM6LDCONbits_t; extern __at(0x0DAF) volatile __PWM6LDCONbits_t PWM6LDCONbits; #define _PWM6LDCON_PWM6LDS0 0x01 #define _PWM6LDCON_LDS0 0x01 #define _PWM6LDCON_LDT 0x40 #define _PWM6LDCON_PWM6LDM 0x40 #define _PWM6LDCON_LDA 0x80 #define _PWM6LDCON_PWM6LD 0x80 //============================================================================== //============================================================================== // PWM6OFCON Bits extern __at(0x0DB0) __sfr PWM6OFCON; typedef union { struct { unsigned PWM6OFS0 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned OFO : 1; unsigned PWM6OFM0 : 1; unsigned PWM6OFM1 : 1; unsigned : 1; }; struct { unsigned OFS0 : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned PWM6OFMC : 1; unsigned OFM0 : 1; unsigned OFM1 : 1; unsigned : 1; }; struct { unsigned : 5; unsigned OFM : 2; unsigned : 1; }; struct { unsigned : 5; unsigned PWM6OFM : 2; unsigned : 1; }; } __PWM6OFCONbits_t; extern __at(0x0DB0) volatile __PWM6OFCONbits_t PWM6OFCONbits; #define _PWM6OFCON_PWM6OFS0 0x01 #define _PWM6OFCON_OFS0 0x01 #define _PWM6OFCON_OFO 0x10 #define _PWM6OFCON_PWM6OFMC 0x10 #define _PWM6OFCON_PWM6OFM0 0x20 #define _PWM6OFCON_OFM0 0x20 #define _PWM6OFCON_PWM6OFM1 0x40 #define _PWM6OFCON_OFM1 0x40 //============================================================================== //============================================================================== // PPSLOCK Bits extern __at(0x0E0F) __sfr PPSLOCK; typedef struct { unsigned PPSLOCKED : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; } __PPSLOCKbits_t; extern __at(0x0E0F) volatile __PPSLOCKbits_t PPSLOCKbits; #define _PPSLOCKED 0x01 //============================================================================== extern __at(0x0E10) __sfr INTPPS; extern __at(0x0E11) __sfr T0CKIPPS; extern __at(0x0E12) __sfr T1CKIPPS; extern __at(0x0E13) __sfr T1GPPS; extern __at(0x0E14) __sfr CCP1PPS; extern __at(0x0E15) __sfr CCP2PPS; extern __at(0x0E16) __sfr COG1INPPS; extern __at(0x0E17) __sfr COG2INPPS; extern __at(0x0E19) __sfr T2CKIPPS; extern __at(0x0E1A) __sfr T3CKIPPS; extern __at(0x0E1B) __sfr T3GPPS; extern __at(0x0E1C) __sfr T4CKIPPS; extern __at(0x0E1D) __sfr T5CKIPPS; extern __at(0x0E1E) __sfr T5GPPS; extern __at(0x0E1F) __sfr T6CKIPPS; extern __at(0x0E20) __sfr SSPCLKPPS; extern __at(0x0E21) __sfr SSPDATPPS; extern __at(0x0E22) __sfr SSPSSPPS; extern __at(0x0E24) __sfr RXPPS; extern __at(0x0E25) __sfr CKPPS; extern __at(0x0E28) __sfr CLCIN0PPS; extern __at(0x0E29) __sfr CLCIN1PPS; extern __at(0x0E2A) __sfr CLCIN2PPS; extern __at(0x0E2B) __sfr CLCIN3PPS; extern __at(0x0E2C) __sfr PRG1RPPS; extern __at(0x0E2D) __sfr PRG1FPPS; extern __at(0x0E2E) __sfr PRG2RPPS; extern __at(0x0E2F) __sfr PRG2FPPS; extern __at(0x0E30) __sfr MD1CHPPS; extern __at(0x0E31) __sfr MD1CLPPS; extern __at(0x0E32) __sfr MD1MODPPS; extern __at(0x0E33) __sfr MD2CHPPS; extern __at(0x0E34) __sfr MD2CLPPS; extern __at(0x0E35) __sfr MD2MODPPS; extern __at(0x0E90) __sfr RA0PPS; extern __at(0x0E91) __sfr RA1PPS; extern __at(0x0E92) __sfr RA2PPS; extern __at(0x0E94) __sfr RA4PPS; extern __at(0x0E95) __sfr RA5PPS; extern __at(0x0E9C) __sfr RB4PPS; extern __at(0x0E9D) __sfr RB5PPS; extern __at(0x0E9E) __sfr RB6PPS; extern __at(0x0E9F) __sfr RB7PPS; extern __at(0x0EA0) __sfr RC0PPS; extern __at(0x0EA1) __sfr RC1PPS; extern __at(0x0EA2) __sfr RC2PPS; extern __at(0x0EA3) __sfr RC3PPS; extern __at(0x0EA4) __sfr RC4PPS; extern __at(0x0EA5) __sfr RC5PPS; extern __at(0x0EA6) __sfr RC6PPS; extern __at(0x0EA7) __sfr RC7PPS; //============================================================================== // CLCDATA Bits extern __at(0x0F0F) __sfr CLCDATA; typedef struct { unsigned MCLC1OUT : 1; unsigned MCLC2OUT : 1; unsigned MCLC3OUT : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; } __CLCDATAbits_t; extern __at(0x0F0F) volatile __CLCDATAbits_t CLCDATAbits; #define _MCLC1OUT 0x01 #define _MCLC2OUT 0x02 #define _MCLC3OUT 0x04 //============================================================================== //============================================================================== // CLC1CON Bits extern __at(0x0F10) __sfr CLC1CON; typedef union { struct { unsigned LC1MODE0 : 1; unsigned LC1MODE1 : 1; unsigned LC1MODE2 : 1; unsigned LC1INTN : 1; unsigned LC1INTP : 1; unsigned LC1OUT : 1; unsigned : 1; unsigned LC1EN : 1; }; struct { unsigned MODE0 : 1; unsigned MODE1 : 1; unsigned MODE2 : 1; unsigned INTN : 1; unsigned INTP : 1; unsigned OUT : 1; unsigned : 1; unsigned EN : 1; }; struct { unsigned LC1MODE : 3; unsigned : 5; }; struct { unsigned MODE : 3; unsigned : 5; }; } __CLC1CONbits_t; extern __at(0x0F10) volatile __CLC1CONbits_t CLC1CONbits; #define _CLC1CON_LC1MODE0 0x01 #define _CLC1CON_MODE0 0x01 #define _CLC1CON_LC1MODE1 0x02 #define _CLC1CON_MODE1 0x02 #define _CLC1CON_LC1MODE2 0x04 #define _CLC1CON_MODE2 0x04 #define _CLC1CON_LC1INTN 0x08 #define _CLC1CON_INTN 0x08 #define _CLC1CON_LC1INTP 0x10 #define _CLC1CON_INTP 0x10 #define _CLC1CON_LC1OUT 0x20 #define _CLC1CON_OUT 0x20 #define _CLC1CON_LC1EN 0x80 #define _CLC1CON_EN 0x80 //============================================================================== //============================================================================== // CLC1POL Bits extern __at(0x0F11) __sfr CLC1POL; typedef union { struct { unsigned LC1G1POL : 1; unsigned LC1G2POL : 1; unsigned LC1G3POL : 1; unsigned LC1G4POL : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned LC1POL : 1; }; struct { unsigned G1POL : 1; unsigned G2POL : 1; unsigned G3POL : 1; unsigned G4POL : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned POL : 1; }; } __CLC1POLbits_t; extern __at(0x0F11) volatile __CLC1POLbits_t CLC1POLbits; #define _LC1G1POL 0x01 #define _G1POL 0x01 #define _LC1G2POL 0x02 #define _G2POL 0x02 #define _LC1G3POL 0x04 #define _G3POL 0x04 #define _LC1G4POL 0x08 #define _G4POL 0x08 #define _LC1POL 0x80 #define _POL 0x80 //============================================================================== //============================================================================== // CLC1SEL0 Bits extern __at(0x0F12) __sfr CLC1SEL0; typedef union { struct { unsigned LC1D1S0 : 1; unsigned LC1D1S1 : 1; unsigned LC1D1S2 : 1; unsigned LC1D1S3 : 1; unsigned LC1D1S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D1S0 : 1; unsigned D1S1 : 1; unsigned D1S2 : 1; unsigned D1S3 : 1; unsigned D1S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D1S : 5; unsigned : 3; }; struct { unsigned LC1D1S : 5; unsigned : 3; }; } __CLC1SEL0bits_t; extern __at(0x0F12) volatile __CLC1SEL0bits_t CLC1SEL0bits; #define _LC1D1S0 0x01 #define _D1S0 0x01 #define _LC1D1S1 0x02 #define _D1S1 0x02 #define _LC1D1S2 0x04 #define _D1S2 0x04 #define _LC1D1S3 0x08 #define _D1S3 0x08 #define _LC1D1S4 0x10 #define _D1S4 0x10 //============================================================================== //============================================================================== // CLC1SEL1 Bits extern __at(0x0F13) __sfr CLC1SEL1; typedef union { struct { unsigned LC1D2S0 : 1; unsigned LC1D2S1 : 1; unsigned LC1D2S2 : 1; unsigned LC1D2S3 : 1; unsigned LC1D2S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D2S0 : 1; unsigned D2S1 : 1; unsigned D2S2 : 1; unsigned D2S3 : 1; unsigned D2S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D2S : 5; unsigned : 3; }; struct { unsigned LC1D2S : 5; unsigned : 3; }; } __CLC1SEL1bits_t; extern __at(0x0F13) volatile __CLC1SEL1bits_t CLC1SEL1bits; #define _LC1D2S0 0x01 #define _D2S0 0x01 #define _LC1D2S1 0x02 #define _D2S1 0x02 #define _LC1D2S2 0x04 #define _D2S2 0x04 #define _LC1D2S3 0x08 #define _D2S3 0x08 #define _LC1D2S4 0x10 #define _D2S4 0x10 //============================================================================== //============================================================================== // CLC1SEL2 Bits extern __at(0x0F14) __sfr CLC1SEL2; typedef union { struct { unsigned LC1D3S0 : 1; unsigned LC1D3S1 : 1; unsigned LC1D3S2 : 1; unsigned LC1D3S3 : 1; unsigned LC1D3S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D3S0 : 1; unsigned D3S1 : 1; unsigned D3S2 : 1; unsigned D3S3 : 1; unsigned D3S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned LC1D3S : 5; unsigned : 3; }; struct { unsigned D3S : 5; unsigned : 3; }; } __CLC1SEL2bits_t; extern __at(0x0F14) volatile __CLC1SEL2bits_t CLC1SEL2bits; #define _LC1D3S0 0x01 #define _D3S0 0x01 #define _LC1D3S1 0x02 #define _D3S1 0x02 #define _LC1D3S2 0x04 #define _D3S2 0x04 #define _LC1D3S3 0x08 #define _D3S3 0x08 #define _LC1D3S4 0x10 #define _D3S4 0x10 //============================================================================== //============================================================================== // CLC1SEL3 Bits extern __at(0x0F15) __sfr CLC1SEL3; typedef union { struct { unsigned LC1D4S0 : 1; unsigned LC1D4S1 : 1; unsigned LC1D4S2 : 1; unsigned LC1D4S3 : 1; unsigned LC1D4S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D4S0 : 1; unsigned D4S1 : 1; unsigned D4S2 : 1; unsigned D4S3 : 1; unsigned D4S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D4S : 5; unsigned : 3; }; struct { unsigned LC1D4S : 5; unsigned : 3; }; } __CLC1SEL3bits_t; extern __at(0x0F15) volatile __CLC1SEL3bits_t CLC1SEL3bits; #define _LC1D4S0 0x01 #define _D4S0 0x01 #define _LC1D4S1 0x02 #define _D4S1 0x02 #define _LC1D4S2 0x04 #define _D4S2 0x04 #define _LC1D4S3 0x08 #define _D4S3 0x08 #define _LC1D4S4 0x10 #define _D4S4 0x10 //============================================================================== //============================================================================== // CLC1GLS0 Bits extern __at(0x0F16) __sfr CLC1GLS0; typedef union { struct { unsigned LC1G1D1N : 1; unsigned LC1G1D1T : 1; unsigned LC1G1D2N : 1; unsigned LC1G1D2T : 1; unsigned LC1G1D3N : 1; unsigned LC1G1D3T : 1; unsigned LC1G1D4N : 1; unsigned LC1G1D4T : 1; }; struct { unsigned D1N : 1; unsigned D1T : 1; unsigned D2N : 1; unsigned D2T : 1; unsigned D3N : 1; unsigned D3T : 1; unsigned D4N : 1; unsigned D4T : 1; }; } __CLC1GLS0bits_t; extern __at(0x0F16) volatile __CLC1GLS0bits_t CLC1GLS0bits; #define _LC1G1D1N 0x01 #define _D1N 0x01 #define _LC1G1D1T 0x02 #define _D1T 0x02 #define _LC1G1D2N 0x04 #define _D2N 0x04 #define _LC1G1D2T 0x08 #define _D2T 0x08 #define _LC1G1D3N 0x10 #define _D3N 0x10 #define _LC1G1D3T 0x20 #define _D3T 0x20 #define _LC1G1D4N 0x40 #define _D4N 0x40 #define _LC1G1D4T 0x80 #define _D4T 0x80 //============================================================================== //============================================================================== // CLC1GLS1 Bits extern __at(0x0F17) __sfr CLC1GLS1; typedef union { struct { unsigned LC1G2D1N : 1; unsigned LC1G2D1T : 1; unsigned LC1G2D2N : 1; unsigned LC1G2D2T : 1; unsigned LC1G2D3N : 1; unsigned LC1G2D3T : 1; unsigned LC1G2D4N : 1; unsigned LC1G2D4T : 1; }; struct { unsigned D1N : 1; unsigned D1T : 1; unsigned D2N : 1; unsigned D2T : 1; unsigned D3N : 1; unsigned D3T : 1; unsigned D4N : 1; unsigned D4T : 1; }; } __CLC1GLS1bits_t; extern __at(0x0F17) volatile __CLC1GLS1bits_t CLC1GLS1bits; #define _CLC1GLS1_LC1G2D1N 0x01 #define _CLC1GLS1_D1N 0x01 #define _CLC1GLS1_LC1G2D1T 0x02 #define _CLC1GLS1_D1T 0x02 #define _CLC1GLS1_LC1G2D2N 0x04 #define _CLC1GLS1_D2N 0x04 #define _CLC1GLS1_LC1G2D2T 0x08 #define _CLC1GLS1_D2T 0x08 #define _CLC1GLS1_LC1G2D3N 0x10 #define _CLC1GLS1_D3N 0x10 #define _CLC1GLS1_LC1G2D3T 0x20 #define _CLC1GLS1_D3T 0x20 #define _CLC1GLS1_LC1G2D4N 0x40 #define _CLC1GLS1_D4N 0x40 #define _CLC1GLS1_LC1G2D4T 0x80 #define _CLC1GLS1_D4T 0x80 //============================================================================== //============================================================================== // CLC1GLS2 Bits extern __at(0x0F18) __sfr CLC1GLS2; typedef union { struct { unsigned LC1G3D1N : 1; unsigned LC1G3D1T : 1; unsigned LC1G3D2N : 1; unsigned LC1G3D2T : 1; unsigned LC1G3D3N : 1; unsigned LC1G3D3T : 1; unsigned LC1G3D4N : 1; unsigned LC1G3D4T : 1; }; struct { unsigned D1N : 1; unsigned D1T : 1; unsigned D2N : 1; unsigned D2T : 1; unsigned D3N : 1; unsigned D3T : 1; unsigned D4N : 1; unsigned D4T : 1; }; } __CLC1GLS2bits_t; extern __at(0x0F18) volatile __CLC1GLS2bits_t CLC1GLS2bits; #define _CLC1GLS2_LC1G3D1N 0x01 #define _CLC1GLS2_D1N 0x01 #define _CLC1GLS2_LC1G3D1T 0x02 #define _CLC1GLS2_D1T 0x02 #define _CLC1GLS2_LC1G3D2N 0x04 #define _CLC1GLS2_D2N 0x04 #define _CLC1GLS2_LC1G3D2T 0x08 #define _CLC1GLS2_D2T 0x08 #define _CLC1GLS2_LC1G3D3N 0x10 #define _CLC1GLS2_D3N 0x10 #define _CLC1GLS2_LC1G3D3T 0x20 #define _CLC1GLS2_D3T 0x20 #define _CLC1GLS2_LC1G3D4N 0x40 #define _CLC1GLS2_D4N 0x40 #define _CLC1GLS2_LC1G3D4T 0x80 #define _CLC1GLS2_D4T 0x80 //============================================================================== //============================================================================== // CLC1GLS3 Bits extern __at(0x0F19) __sfr CLC1GLS3; typedef union { struct { unsigned LC1G4D1N : 1; unsigned LC1G4D1T : 1; unsigned LC1G4D2N : 1; unsigned LC1G4D2T : 1; unsigned LC1G4D3N : 1; unsigned LC1G4D3T : 1; unsigned LC1G4D4N : 1; unsigned LC1G4D4T : 1; }; struct { unsigned G4D1N : 1; unsigned G4D1T : 1; unsigned G4D2N : 1; unsigned G4D2T : 1; unsigned G4D3N : 1; unsigned G4D3T : 1; unsigned G4D4N : 1; unsigned G4D4T : 1; }; } __CLC1GLS3bits_t; extern __at(0x0F19) volatile __CLC1GLS3bits_t CLC1GLS3bits; #define _LC1G4D1N 0x01 #define _G4D1N 0x01 #define _LC1G4D1T 0x02 #define _G4D1T 0x02 #define _LC1G4D2N 0x04 #define _G4D2N 0x04 #define _LC1G4D2T 0x08 #define _G4D2T 0x08 #define _LC1G4D3N 0x10 #define _G4D3N 0x10 #define _LC1G4D3T 0x20 #define _G4D3T 0x20 #define _LC1G4D4N 0x40 #define _G4D4N 0x40 #define _LC1G4D4T 0x80 #define _G4D4T 0x80 //============================================================================== //============================================================================== // CLC2CON Bits extern __at(0x0F1A) __sfr CLC2CON; typedef union { struct { unsigned LC2MODE0 : 1; unsigned LC2MODE1 : 1; unsigned LC2MODE2 : 1; unsigned LC2INTN : 1; unsigned LC2INTP : 1; unsigned LC2OUT : 1; unsigned : 1; unsigned LC2EN : 1; }; struct { unsigned MODE0 : 1; unsigned MODE1 : 1; unsigned MODE2 : 1; unsigned INTN : 1; unsigned INTP : 1; unsigned OUT : 1; unsigned : 1; unsigned EN : 1; }; struct { unsigned LC2MODE : 3; unsigned : 5; }; struct { unsigned MODE : 3; unsigned : 5; }; } __CLC2CONbits_t; extern __at(0x0F1A) volatile __CLC2CONbits_t CLC2CONbits; #define _CLC2CON_LC2MODE0 0x01 #define _CLC2CON_MODE0 0x01 #define _CLC2CON_LC2MODE1 0x02 #define _CLC2CON_MODE1 0x02 #define _CLC2CON_LC2MODE2 0x04 #define _CLC2CON_MODE2 0x04 #define _CLC2CON_LC2INTN 0x08 #define _CLC2CON_INTN 0x08 #define _CLC2CON_LC2INTP 0x10 #define _CLC2CON_INTP 0x10 #define _CLC2CON_LC2OUT 0x20 #define _CLC2CON_OUT 0x20 #define _CLC2CON_LC2EN 0x80 #define _CLC2CON_EN 0x80 //============================================================================== //============================================================================== // CLC2POL Bits extern __at(0x0F1B) __sfr CLC2POL; typedef union { struct { unsigned LC2G1POL : 1; unsigned LC2G2POL : 1; unsigned LC2G3POL : 1; unsigned LC2G4POL : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned LC2POL : 1; }; struct { unsigned G1POL : 1; unsigned G2POL : 1; unsigned G3POL : 1; unsigned G4POL : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned POL : 1; }; } __CLC2POLbits_t; extern __at(0x0F1B) volatile __CLC2POLbits_t CLC2POLbits; #define _CLC2POL_LC2G1POL 0x01 #define _CLC2POL_G1POL 0x01 #define _CLC2POL_LC2G2POL 0x02 #define _CLC2POL_G2POL 0x02 #define _CLC2POL_LC2G3POL 0x04 #define _CLC2POL_G3POL 0x04 #define _CLC2POL_LC2G4POL 0x08 #define _CLC2POL_G4POL 0x08 #define _CLC2POL_LC2POL 0x80 #define _CLC2POL_POL 0x80 //============================================================================== //============================================================================== // CLC2SEL0 Bits extern __at(0x0F1C) __sfr CLC2SEL0; typedef union { struct { unsigned LC2D1S0 : 1; unsigned LC2D1S1 : 1; unsigned LC2D1S2 : 1; unsigned LC2D1S3 : 1; unsigned LC2D1S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D1S0 : 1; unsigned D1S1 : 1; unsigned D1S2 : 1; unsigned D1S3 : 1; unsigned D1S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D1S : 5; unsigned : 3; }; struct { unsigned LC2D1S : 5; unsigned : 3; }; } __CLC2SEL0bits_t; extern __at(0x0F1C) volatile __CLC2SEL0bits_t CLC2SEL0bits; #define _CLC2SEL0_LC2D1S0 0x01 #define _CLC2SEL0_D1S0 0x01 #define _CLC2SEL0_LC2D1S1 0x02 #define _CLC2SEL0_D1S1 0x02 #define _CLC2SEL0_LC2D1S2 0x04 #define _CLC2SEL0_D1S2 0x04 #define _CLC2SEL0_LC2D1S3 0x08 #define _CLC2SEL0_D1S3 0x08 #define _CLC2SEL0_LC2D1S4 0x10 #define _CLC2SEL0_D1S4 0x10 //============================================================================== //============================================================================== // CLC2SEL1 Bits extern __at(0x0F1D) __sfr CLC2SEL1; typedef union { struct { unsigned LC2D2S0 : 1; unsigned LC2D2S1 : 1; unsigned LC2D2S2 : 1; unsigned LC2D2S3 : 1; unsigned LC2D2S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D2S0 : 1; unsigned D2S1 : 1; unsigned D2S2 : 1; unsigned D2S3 : 1; unsigned D2S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D2S : 5; unsigned : 3; }; struct { unsigned LC2D2S : 5; unsigned : 3; }; } __CLC2SEL1bits_t; extern __at(0x0F1D) volatile __CLC2SEL1bits_t CLC2SEL1bits; #define _CLC2SEL1_LC2D2S0 0x01 #define _CLC2SEL1_D2S0 0x01 #define _CLC2SEL1_LC2D2S1 0x02 #define _CLC2SEL1_D2S1 0x02 #define _CLC2SEL1_LC2D2S2 0x04 #define _CLC2SEL1_D2S2 0x04 #define _CLC2SEL1_LC2D2S3 0x08 #define _CLC2SEL1_D2S3 0x08 #define _CLC2SEL1_LC2D2S4 0x10 #define _CLC2SEL1_D2S4 0x10 //============================================================================== //============================================================================== // CLC2SEL2 Bits extern __at(0x0F1E) __sfr CLC2SEL2; typedef union { struct { unsigned LC2D3S0 : 1; unsigned LC2D3S1 : 1; unsigned LC2D3S2 : 1; unsigned LC2D3S3 : 1; unsigned LC2D3S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D3S0 : 1; unsigned D3S1 : 1; unsigned D3S2 : 1; unsigned D3S3 : 1; unsigned D3S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned LC2D3S : 5; unsigned : 3; }; struct { unsigned D3S : 5; unsigned : 3; }; } __CLC2SEL2bits_t; extern __at(0x0F1E) volatile __CLC2SEL2bits_t CLC2SEL2bits; #define _CLC2SEL2_LC2D3S0 0x01 #define _CLC2SEL2_D3S0 0x01 #define _CLC2SEL2_LC2D3S1 0x02 #define _CLC2SEL2_D3S1 0x02 #define _CLC2SEL2_LC2D3S2 0x04 #define _CLC2SEL2_D3S2 0x04 #define _CLC2SEL2_LC2D3S3 0x08 #define _CLC2SEL2_D3S3 0x08 #define _CLC2SEL2_LC2D3S4 0x10 #define _CLC2SEL2_D3S4 0x10 //============================================================================== //============================================================================== // CLC2SEL3 Bits extern __at(0x0F1F) __sfr CLC2SEL3; typedef union { struct { unsigned LC2D4S0 : 1; unsigned LC2D4S1 : 1; unsigned LC2D4S2 : 1; unsigned LC2D4S3 : 1; unsigned LC2D4S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D4S0 : 1; unsigned D4S1 : 1; unsigned D4S2 : 1; unsigned D4S3 : 1; unsigned D4S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned LC2D4S : 5; unsigned : 3; }; struct { unsigned D4S : 5; unsigned : 3; }; } __CLC2SEL3bits_t; extern __at(0x0F1F) volatile __CLC2SEL3bits_t CLC2SEL3bits; #define _CLC2SEL3_LC2D4S0 0x01 #define _CLC2SEL3_D4S0 0x01 #define _CLC2SEL3_LC2D4S1 0x02 #define _CLC2SEL3_D4S1 0x02 #define _CLC2SEL3_LC2D4S2 0x04 #define _CLC2SEL3_D4S2 0x04 #define _CLC2SEL3_LC2D4S3 0x08 #define _CLC2SEL3_D4S3 0x08 #define _CLC2SEL3_LC2D4S4 0x10 #define _CLC2SEL3_D4S4 0x10 //============================================================================== //============================================================================== // CLC2GLS0 Bits extern __at(0x0F20) __sfr CLC2GLS0; typedef union { struct { unsigned LC2G1D1N : 1; unsigned LC2G1D1T : 1; unsigned LC2G1D2N : 1; unsigned LC2G1D2T : 1; unsigned LC2G1D3N : 1; unsigned LC2G1D3T : 1; unsigned LC2G1D4N : 1; unsigned LC2G1D4T : 1; }; struct { unsigned D1N : 1; unsigned D1T : 1; unsigned D2N : 1; unsigned D2T : 1; unsigned D3N : 1; unsigned D3T : 1; unsigned D4N : 1; unsigned D4T : 1; }; } __CLC2GLS0bits_t; extern __at(0x0F20) volatile __CLC2GLS0bits_t CLC2GLS0bits; #define _CLC2GLS0_LC2G1D1N 0x01 #define _CLC2GLS0_D1N 0x01 #define _CLC2GLS0_LC2G1D1T 0x02 #define _CLC2GLS0_D1T 0x02 #define _CLC2GLS0_LC2G1D2N 0x04 #define _CLC2GLS0_D2N 0x04 #define _CLC2GLS0_LC2G1D2T 0x08 #define _CLC2GLS0_D2T 0x08 #define _CLC2GLS0_LC2G1D3N 0x10 #define _CLC2GLS0_D3N 0x10 #define _CLC2GLS0_LC2G1D3T 0x20 #define _CLC2GLS0_D3T 0x20 #define _CLC2GLS0_LC2G1D4N 0x40 #define _CLC2GLS0_D4N 0x40 #define _CLC2GLS0_LC2G1D4T 0x80 #define _CLC2GLS0_D4T 0x80 //============================================================================== //============================================================================== // CLC2GLS1 Bits extern __at(0x0F21) __sfr CLC2GLS1; typedef union { struct { unsigned LC2G2D1N : 1; unsigned LC2G2D1T : 1; unsigned LC2G2D2N : 1; unsigned LC2G2D2T : 1; unsigned LC2G2D3N : 1; unsigned LC2G2D3T : 1; unsigned LC2G2D4N : 1; unsigned LC2G2D4T : 1; }; struct { unsigned D1N : 1; unsigned D1T : 1; unsigned D2N : 1; unsigned D2T : 1; unsigned D3N : 1; unsigned D3T : 1; unsigned D4N : 1; unsigned D4T : 1; }; } __CLC2GLS1bits_t; extern __at(0x0F21) volatile __CLC2GLS1bits_t CLC2GLS1bits; #define _CLC2GLS1_LC2G2D1N 0x01 #define _CLC2GLS1_D1N 0x01 #define _CLC2GLS1_LC2G2D1T 0x02 #define _CLC2GLS1_D1T 0x02 #define _CLC2GLS1_LC2G2D2N 0x04 #define _CLC2GLS1_D2N 0x04 #define _CLC2GLS1_LC2G2D2T 0x08 #define _CLC2GLS1_D2T 0x08 #define _CLC2GLS1_LC2G2D3N 0x10 #define _CLC2GLS1_D3N 0x10 #define _CLC2GLS1_LC2G2D3T 0x20 #define _CLC2GLS1_D3T 0x20 #define _CLC2GLS1_LC2G2D4N 0x40 #define _CLC2GLS1_D4N 0x40 #define _CLC2GLS1_LC2G2D4T 0x80 #define _CLC2GLS1_D4T 0x80 //============================================================================== //============================================================================== // CLC2GLS2 Bits extern __at(0x0F22) __sfr CLC2GLS2; typedef union { struct { unsigned LC2G3D1N : 1; unsigned LC2G3D1T : 1; unsigned LC2G3D2N : 1; unsigned LC2G3D2T : 1; unsigned LC2G3D3N : 1; unsigned LC2G3D3T : 1; unsigned LC2G3D4N : 1; unsigned LC2G3D4T : 1; }; struct { unsigned D1N : 1; unsigned D1T : 1; unsigned D2N : 1; unsigned D2T : 1; unsigned D3N : 1; unsigned D3T : 1; unsigned D4N : 1; unsigned D4T : 1; }; } __CLC2GLS2bits_t; extern __at(0x0F22) volatile __CLC2GLS2bits_t CLC2GLS2bits; #define _CLC2GLS2_LC2G3D1N 0x01 #define _CLC2GLS2_D1N 0x01 #define _CLC2GLS2_LC2G3D1T 0x02 #define _CLC2GLS2_D1T 0x02 #define _CLC2GLS2_LC2G3D2N 0x04 #define _CLC2GLS2_D2N 0x04 #define _CLC2GLS2_LC2G3D2T 0x08 #define _CLC2GLS2_D2T 0x08 #define _CLC2GLS2_LC2G3D3N 0x10 #define _CLC2GLS2_D3N 0x10 #define _CLC2GLS2_LC2G3D3T 0x20 #define _CLC2GLS2_D3T 0x20 #define _CLC2GLS2_LC2G3D4N 0x40 #define _CLC2GLS2_D4N 0x40 #define _CLC2GLS2_LC2G3D4T 0x80 #define _CLC2GLS2_D4T 0x80 //============================================================================== //============================================================================== // CLC2GLS3 Bits extern __at(0x0F23) __sfr CLC2GLS3; typedef union { struct { unsigned LC2G4D1N : 1; unsigned LC2G4D1T : 1; unsigned LC2G4D2N : 1; unsigned LC2G4D2T : 1; unsigned LC2G4D3N : 1; unsigned LC2G4D3T : 1; unsigned LC2G4D4N : 1; unsigned LC2G4D4T : 1; }; struct { unsigned G4D1N : 1; unsigned G4D1T : 1; unsigned G4D2N : 1; unsigned G4D2T : 1; unsigned G4D3N : 1; unsigned G4D3T : 1; unsigned G4D4N : 1; unsigned G4D4T : 1; }; } __CLC2GLS3bits_t; extern __at(0x0F23) volatile __CLC2GLS3bits_t CLC2GLS3bits; #define _CLC2GLS3_LC2G4D1N 0x01 #define _CLC2GLS3_G4D1N 0x01 #define _CLC2GLS3_LC2G4D1T 0x02 #define _CLC2GLS3_G4D1T 0x02 #define _CLC2GLS3_LC2G4D2N 0x04 #define _CLC2GLS3_G4D2N 0x04 #define _CLC2GLS3_LC2G4D2T 0x08 #define _CLC2GLS3_G4D2T 0x08 #define _CLC2GLS3_LC2G4D3N 0x10 #define _CLC2GLS3_G4D3N 0x10 #define _CLC2GLS3_LC2G4D3T 0x20 #define _CLC2GLS3_G4D3T 0x20 #define _CLC2GLS3_LC2G4D4N 0x40 #define _CLC2GLS3_G4D4N 0x40 #define _CLC2GLS3_LC2G4D4T 0x80 #define _CLC2GLS3_G4D4T 0x80 //============================================================================== //============================================================================== // CLC3CON Bits extern __at(0x0F24) __sfr CLC3CON; typedef union { struct { unsigned LC3MODE0 : 1; unsigned LC3MODE1 : 1; unsigned LC3MODE2 : 1; unsigned LC3INTN : 1; unsigned LC3INTP : 1; unsigned LC3OUT : 1; unsigned : 1; unsigned LC3EN : 1; }; struct { unsigned MODE0 : 1; unsigned MODE1 : 1; unsigned MODE2 : 1; unsigned INTN : 1; unsigned INTP : 1; unsigned OUT : 1; unsigned : 1; unsigned EN : 1; }; struct { unsigned LC3MODE : 3; unsigned : 5; }; struct { unsigned MODE : 3; unsigned : 5; }; } __CLC3CONbits_t; extern __at(0x0F24) volatile __CLC3CONbits_t CLC3CONbits; #define _CLC3CON_LC3MODE0 0x01 #define _CLC3CON_MODE0 0x01 #define _CLC3CON_LC3MODE1 0x02 #define _CLC3CON_MODE1 0x02 #define _CLC3CON_LC3MODE2 0x04 #define _CLC3CON_MODE2 0x04 #define _CLC3CON_LC3INTN 0x08 #define _CLC3CON_INTN 0x08 #define _CLC3CON_LC3INTP 0x10 #define _CLC3CON_INTP 0x10 #define _CLC3CON_LC3OUT 0x20 #define _CLC3CON_OUT 0x20 #define _CLC3CON_LC3EN 0x80 #define _CLC3CON_EN 0x80 //============================================================================== //============================================================================== // CLC3POL Bits extern __at(0x0F25) __sfr CLC3POL; typedef union { struct { unsigned LC3G1POL : 1; unsigned LC3G2POL : 1; unsigned LC3G3POL : 1; unsigned LC3G4POL : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned LC3POL : 1; }; struct { unsigned G1POL : 1; unsigned G2POL : 1; unsigned G3POL : 1; unsigned G4POL : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned POL : 1; }; } __CLC3POLbits_t; extern __at(0x0F25) volatile __CLC3POLbits_t CLC3POLbits; #define _CLC3POL_LC3G1POL 0x01 #define _CLC3POL_G1POL 0x01 #define _CLC3POL_LC3G2POL 0x02 #define _CLC3POL_G2POL 0x02 #define _CLC3POL_LC3G3POL 0x04 #define _CLC3POL_G3POL 0x04 #define _CLC3POL_LC3G4POL 0x08 #define _CLC3POL_G4POL 0x08 #define _CLC3POL_LC3POL 0x80 #define _CLC3POL_POL 0x80 //============================================================================== //============================================================================== // CLC3SEL0 Bits extern __at(0x0F26) __sfr CLC3SEL0; typedef union { struct { unsigned LC3D1S0 : 1; unsigned LC3D1S1 : 1; unsigned LC3D1S2 : 1; unsigned LC3D1S3 : 1; unsigned LC3D1S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D1S0 : 1; unsigned D1S1 : 1; unsigned D1S2 : 1; unsigned D1S3 : 1; unsigned D1S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned LC3D1S : 5; unsigned : 3; }; struct { unsigned D1S : 5; unsigned : 3; }; } __CLC3SEL0bits_t; extern __at(0x0F26) volatile __CLC3SEL0bits_t CLC3SEL0bits; #define _CLC3SEL0_LC3D1S0 0x01 #define _CLC3SEL0_D1S0 0x01 #define _CLC3SEL0_LC3D1S1 0x02 #define _CLC3SEL0_D1S1 0x02 #define _CLC3SEL0_LC3D1S2 0x04 #define _CLC3SEL0_D1S2 0x04 #define _CLC3SEL0_LC3D1S3 0x08 #define _CLC3SEL0_D1S3 0x08 #define _CLC3SEL0_LC3D1S4 0x10 #define _CLC3SEL0_D1S4 0x10 //============================================================================== //============================================================================== // CLC3SEL1 Bits extern __at(0x0F27) __sfr CLC3SEL1; typedef union { struct { unsigned LC3D2S0 : 1; unsigned LC3D2S1 : 1; unsigned LC3D2S2 : 1; unsigned LC3D2S3 : 1; unsigned LC3D2S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D2S0 : 1; unsigned D2S1 : 1; unsigned D2S2 : 1; unsigned D2S3 : 1; unsigned D2S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned LC3D2S : 5; unsigned : 3; }; struct { unsigned D2S : 5; unsigned : 3; }; } __CLC3SEL1bits_t; extern __at(0x0F27) volatile __CLC3SEL1bits_t CLC3SEL1bits; #define _CLC3SEL1_LC3D2S0 0x01 #define _CLC3SEL1_D2S0 0x01 #define _CLC3SEL1_LC3D2S1 0x02 #define _CLC3SEL1_D2S1 0x02 #define _CLC3SEL1_LC3D2S2 0x04 #define _CLC3SEL1_D2S2 0x04 #define _CLC3SEL1_LC3D2S3 0x08 #define _CLC3SEL1_D2S3 0x08 #define _CLC3SEL1_LC3D2S4 0x10 #define _CLC3SEL1_D2S4 0x10 //============================================================================== //============================================================================== // CLC3SEL2 Bits extern __at(0x0F28) __sfr CLC3SEL2; typedef union { struct { unsigned LC3D3S0 : 1; unsigned LC3D3S1 : 1; unsigned LC3D3S2 : 1; unsigned LC3D3S3 : 1; unsigned LC3D3S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D3S0 : 1; unsigned D3S1 : 1; unsigned D3S2 : 1; unsigned D3S3 : 1; unsigned D3S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D3S : 5; unsigned : 3; }; struct { unsigned LC3D3S : 5; unsigned : 3; }; } __CLC3SEL2bits_t; extern __at(0x0F28) volatile __CLC3SEL2bits_t CLC3SEL2bits; #define _CLC3SEL2_LC3D3S0 0x01 #define _CLC3SEL2_D3S0 0x01 #define _CLC3SEL2_LC3D3S1 0x02 #define _CLC3SEL2_D3S1 0x02 #define _CLC3SEL2_LC3D3S2 0x04 #define _CLC3SEL2_D3S2 0x04 #define _CLC3SEL2_LC3D3S3 0x08 #define _CLC3SEL2_D3S3 0x08 #define _CLC3SEL2_LC3D3S4 0x10 #define _CLC3SEL2_D3S4 0x10 //============================================================================== //============================================================================== // CLC3SEL3 Bits extern __at(0x0F29) __sfr CLC3SEL3; typedef union { struct { unsigned LC3D4S0 : 1; unsigned LC3D4S1 : 1; unsigned LC3D4S2 : 1; unsigned LC3D4S3 : 1; unsigned LC3D4S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D4S0 : 1; unsigned D4S1 : 1; unsigned D4S2 : 1; unsigned D4S3 : 1; unsigned D4S4 : 1; unsigned : 1; unsigned : 1; unsigned : 1; }; struct { unsigned D4S : 5; unsigned : 3; }; struct { unsigned LC3D4S : 5; unsigned : 3; }; } __CLC3SEL3bits_t; extern __at(0x0F29) volatile __CLC3SEL3bits_t CLC3SEL3bits; #define _CLC3SEL3_LC3D4S0 0x01 #define _CLC3SEL3_D4S0 0x01 #define _CLC3SEL3_LC3D4S1 0x02 #define _CLC3SEL3_D4S1 0x02 #define _CLC3SEL3_LC3D4S2 0x04 #define _CLC3SEL3_D4S2 0x04 #define _CLC3SEL3_LC3D4S3 0x08 #define _CLC3SEL3_D4S3 0x08 #define _CLC3SEL3_LC3D4S4 0x10 #define _CLC3SEL3_D4S4 0x10 //============================================================================== //============================================================================== // CLC3GLS0 Bits extern __at(0x0F2A) __sfr CLC3GLS0; typedef union { struct { unsigned LC3G1D1N : 1; unsigned LC3G1D1T : 1; unsigned LC3G1D2N : 1; unsigned LC3G1D2T : 1; unsigned LC3G1D3N : 1; unsigned LC3G1D3T : 1; unsigned LC3G1D4N : 1; unsigned LC3G1D4T : 1; }; struct { unsigned D1N : 1; unsigned D1T : 1; unsigned D2N : 1; unsigned D2T : 1; unsigned D3N : 1; unsigned D3T : 1; unsigned D4N : 1; unsigned D4T : 1; }; } __CLC3GLS0bits_t; extern __at(0x0F2A) volatile __CLC3GLS0bits_t CLC3GLS0bits; #define _CLC3GLS0_LC3G1D1N 0x01 #define _CLC3GLS0_D1N 0x01 #define _CLC3GLS0_LC3G1D1T 0x02 #define _CLC3GLS0_D1T 0x02 #define _CLC3GLS0_LC3G1D2N 0x04 #define _CLC3GLS0_D2N 0x04 #define _CLC3GLS0_LC3G1D2T 0x08 #define _CLC3GLS0_D2T 0x08 #define _CLC3GLS0_LC3G1D3N 0x10 #define _CLC3GLS0_D3N 0x10 #define _CLC3GLS0_LC3G1D3T 0x20 #define _CLC3GLS0_D3T 0x20 #define _CLC3GLS0_LC3G1D4N 0x40 #define _CLC3GLS0_D4N 0x40 #define _CLC3GLS0_LC3G1D4T 0x80 #define _CLC3GLS0_D4T 0x80 //============================================================================== //============================================================================== // CLC3GLS1 Bits extern __at(0x0F2B) __sfr CLC3GLS1; typedef union { struct { unsigned LC3G2D1N : 1; unsigned LC3G2D1T : 1; unsigned LC3G2D2N : 1; unsigned LC3G2D2T : 1; unsigned LC3G2D3N : 1; unsigned LC3G2D3T : 1; unsigned LC3G2D4N : 1; unsigned LC3G2D4T : 1; }; struct { unsigned D1N : 1; unsigned D1T : 1; unsigned D2N : 1; unsigned D2T : 1; unsigned D3N : 1; unsigned D3T : 1; unsigned D4N : 1; unsigned D4T : 1; }; } __CLC3GLS1bits_t; extern __at(0x0F2B) volatile __CLC3GLS1bits_t CLC3GLS1bits; #define _CLC3GLS1_LC3G2D1N 0x01 #define _CLC3GLS1_D1N 0x01 #define _CLC3GLS1_LC3G2D1T 0x02 #define _CLC3GLS1_D1T 0x02 #define _CLC3GLS1_LC3G2D2N 0x04 #define _CLC3GLS1_D2N 0x04 #define _CLC3GLS1_LC3G2D2T 0x08 #define _CLC3GLS1_D2T 0x08 #define _CLC3GLS1_LC3G2D3N 0x10 #define _CLC3GLS1_D3N 0x10 #define _CLC3GLS1_LC3G2D3T 0x20 #define _CLC3GLS1_D3T 0x20 #define _CLC3GLS1_LC3G2D4N 0x40 #define _CLC3GLS1_D4N 0x40 #define _CLC3GLS1_LC3G2D4T 0x80 #define _CLC3GLS1_D4T 0x80 //============================================================================== //============================================================================== // CLC3GLS2 Bits extern __at(0x0F2C) __sfr CLC3GLS2; typedef union { struct { unsigned LC3G3D1N : 1; unsigned LC3G3D1T : 1; unsigned LC3G3D2N : 1; unsigned LC3G3D2T : 1; unsigned LC3G3D3N : 1; unsigned LC3G3D3T : 1; unsigned LC3G3D4N : 1; unsigned LC3G3D4T : 1; }; struct { unsigned D1N : 1; unsigned D1T : 1; unsigned D2N : 1; unsigned D2T : 1; unsigned D3N : 1; unsigned D3T : 1; unsigned D4N : 1; unsigned D4T : 1; }; } __CLC3GLS2bits_t; extern __at(0x0F2C) volatile __CLC3GLS2bits_t CLC3GLS2bits; #define _CLC3GLS2_LC3G3D1N 0x01 #define _CLC3GLS2_D1N 0x01 #define _CLC3GLS2_LC3G3D1T 0x02 #define _CLC3GLS2_D1T 0x02 #define _CLC3GLS2_LC3G3D2N 0x04 #define _CLC3GLS2_D2N 0x04 #define _CLC3GLS2_LC3G3D2T 0x08 #define _CLC3GLS2_D2T 0x08 #define _CLC3GLS2_LC3G3D3N 0x10 #define _CLC3GLS2_D3N 0x10 #define _CLC3GLS2_LC3G3D3T 0x20 #define _CLC3GLS2_D3T 0x20 #define _CLC3GLS2_LC3G3D4N 0x40 #define _CLC3GLS2_D4N 0x40 #define _CLC3GLS2_LC3G3D4T 0x80 #define _CLC3GLS2_D4T 0x80 //============================================================================== //============================================================================== // CLC3GLS3 Bits extern __at(0x0F2D) __sfr CLC3GLS3; typedef union { struct { unsigned LC3G4D1N : 1; unsigned LC3G4D1T : 1; unsigned LC3G4D2N : 1; unsigned LC3G4D2T : 1; unsigned LC3G4D3N : 1; unsigned LC3G4D3T : 1; unsigned LC3G4D4N : 1; unsigned LC3G4D4T : 1; }; struct { unsigned G4D1N : 1; unsigned G4D1T : 1; unsigned G4D2N : 1; unsigned G4D2T : 1; unsigned G4D3N : 1; unsigned G4D3T : 1; unsigned G4D4N : 1; unsigned G4D4T : 1; }; } __CLC3GLS3bits_t; extern __at(0x0F2D) volatile __CLC3GLS3bits_t CLC3GLS3bits; #define _CLC3GLS3_LC3G4D1N 0x01 #define _CLC3GLS3_G4D1N 0x01 #define _CLC3GLS3_LC3G4D1T 0x02 #define _CLC3GLS3_G4D1T 0x02 #define _CLC3GLS3_LC3G4D2N 0x04 #define _CLC3GLS3_G4D2N 0x04 #define _CLC3GLS3_LC3G4D2T 0x08 #define _CLC3GLS3_G4D2T 0x08 #define _CLC3GLS3_LC3G4D3N 0x10 #define _CLC3GLS3_G4D3N 0x10 #define _CLC3GLS3_LC3G4D3T 0x20 #define _CLC3GLS3_G4D3T 0x20 #define _CLC3GLS3_LC3G4D4N 0x40 #define _CLC3GLS3_G4D4N 0x40 #define _CLC3GLS3_LC3G4D4T 0x80 #define _CLC3GLS3_G4D4T 0x80 //============================================================================== //============================================================================== // STATUS_SHAD Bits extern __at(0x0FE4) __sfr STATUS_SHAD; typedef struct { unsigned C_SHAD : 1; unsigned DC_SHAD : 1; unsigned Z_SHAD : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; unsigned : 1; } __STATUS_SHADbits_t; extern __at(0x0FE4) volatile __STATUS_SHADbits_t STATUS_SHADbits; #define _C_SHAD 0x01 #define _DC_SHAD 0x02 #define _Z_SHAD 0x04 //============================================================================== extern __at(0x0FE5) __sfr WREG_SHAD; extern __at(0x0FE6) __sfr BSR_SHAD; extern __at(0x0FE7) __sfr PCLATH_SHAD; extern __at(0x0FE8) __sfr FSR0L_SHAD; extern __at(0x0FE9) __sfr FSR0H_SHAD; extern __at(0x0FEA) __sfr FSR1L_SHAD; extern __at(0x0FEB) __sfr FSR1H_SHAD; extern __at(0x0FED) __sfr STKPTR; extern __at(0x0FEE) __sfr TOSL; extern __at(0x0FEF) __sfr TOSH; //============================================================================== // // Configuration Bits // //============================================================================== #define _CONFIG1 0x8007 #define _CONFIG2 0x8008 //----------------------------- CONFIG1 Options ------------------------------- #define _FOSC_LP 0x3FF8 // LP Oscillator, Low-power crystal connected between OSC1 and OSC2 pins. #define _FOSC_XT 0x3FF9 // XT Oscillator, Crystal/resonator connected between OSC1 and OSC2 pins. #define _FOSC_HS 0x3FFA // HS Oscillator, High-speed crystal/resonator connected between OSC1 and OSC2 pins. #define _FOSC_EXTRC 0x3FFB // EXTRC oscillator: External RC circuit connected to CLKIN pin. #define _FOSC_INTOSC 0x3FFC // INTOSC oscillator: I/O function on CLKIN pin. #define _FOSC_ECL 0x3FFD // ECL, External Clock, Low Power Mode (0-0.5 MHz): device clock supplied to CLKIN pins. #define _FOSC_ECM 0x3FFE // ECM, External Clock, Medium Power Mode (0.5-4 MHz): device clock supplied to CLKIN pins. #define _FOSC_ECH 0x3FFF // ECH, External Clock, High Power Mode (4-20 MHz): device clock supplied to CLKIN pins. #define _WDTE_OFF 0x3FE7 // WDT disabled. #define _WDTE_SWDTEN 0x3FEF // WDT controlled by the SWDTEN bit in the WDTCON register. #define _WDTE_NSLEEP 0x3FF7 // WDT enabled while running and disabled in Sleep. #define _WDTE_ON 0x3FFF // WDT enabled. #define _PWRTE_ON 0x3FDF // PWRT enabled. #define _PWRTE_OFF 0x3FFF // PWRT disabled. #define _MCLRE_OFF 0x3FBF // MCLR/VPP pin function is digital input. #define _MCLRE_ON 0x3FFF // MCLR/VPP pin function is MCLR. #define _CP_ON 0x3F7F // Program memory code protection is enabled. #define _CP_OFF 0x3FFF // Program memory code protection is disabled. #define _BOREN_OFF 0x39FF // Brown-out Reset disabled. #define _BOREN_SBODEN 0x3BFF // Brown-out Reset controlled by the SBOREN bit in the BORCON register. #define _BOREN_NSLEEP 0x3DFF // Brown-out Reset enabled while running and disabled in Sleep. #define _BOREN_ON 0x3FFF // Brown-out Reset enabled. #define _CLKOUTEN_ON 0x37FF // CLKOUT function is enabled on the CLKOUT pin. #define _CLKOUTEN_OFF 0x3FFF // CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin. #define _IESO_OFF 0x2FFF // Internal/External Switchover Mode is disabled. #define _IESO_ON 0x3FFF // Internal/External Switchover Mode is enabled. #define _FCMEN_OFF 0x1FFF // Fail-Safe Clock Monitor is disabled. #define _FCMEN_ON 0x3FFF // Fail-Safe Clock Monitor is enabled. //----------------------------- CONFIG2 Options ------------------------------- #define _WRT_ALL 0x3FFC // 000h to 1FFFh write protected, no addresses may be modified by EECON control. #define _WRT_HALF 0x3FFD // 000h to FFFh write protected, 1000h to 1FFFh may be modified by EECON control. #define _WRT_BOOT 0x3FFE // 000h to 1FFh write protected, 200h to 1FFFh may be modified by EECON control. #define _WRT_OFF 0x3FFF // Write protection off. #define _PPS1WAY_OFF 0x3FFB // The PPSLOCK bit can be set and cleared repeatedly by software. #define _PPS1WAY_ON 0x3FFF // The PPSLOCK bit cannot be cleared once it is set by software. #define _ZCD_ON 0x3F7F // Zero-cross detect circuit is enabled at POR. #define _ZCD_OFF 0x3FFF // Zero-cross detect circuit is disabled at POR. #define _PLLEN_OFF 0x3EFF // 4x PLL is enabled when software sets the SPLLEN bit. #define _PLLEN_ON 0x3FFF // 4x PLL is always enabled. #define _STVREN_OFF 0x3DFF // Stack Overflow or Underflow will not cause a Reset. #define _STVREN_ON 0x3FFF // Stack Overflow or Underflow will cause a Reset. #define _BORV_HI 0x3BFF // Brown-out Reset Voltage (Vbor), high trip point selected. #define _BORV_LO 0x3FFF // Brown-out Reset Voltage (Vbor), low trip point selected. #define _LPBOR_ON 0x37FF // Low-Power BOR is enabled. #define _LPBOR_OFF 0x3FFF // Low-Power BOR is disabled. #define _DEBUG_ON 0x2FFF // In-Circuit Debugger enabled, ICSPCLK and ICSPDAT are dedicated to the debugger. #define _DEBUG_OFF 0x3FFF // In-Circuit Debugger disabled, ICSPCLK and ICSPDAT are general purpose I/O pins. #define _LVP_OFF 0x1FFF // High-voltage on MCLR/VPP must be used for programming. #define _LVP_ON 0x3FFF // Low-voltage programming enabled. //============================================================================== #define _DEVID1 0x8006 #define _IDLOC0 0x8000 #define _IDLOC1 0x8001 #define _IDLOC2 0x8002 #define _IDLOC3 0x8003 //============================================================================== #ifndef NO_BIT_DEFINES #define ADON ADCON0bits.ADON // bit 0 #define GO_NOT_DONE ADCON0bits.GO_NOT_DONE // bit 1, shadows bit in ADCON0bits #define ADGO ADCON0bits.ADGO // bit 1, shadows bit in ADCON0bits #define GO ADCON0bits.GO // bit 1, shadows bit in ADCON0bits #define CHS0 ADCON0bits.CHS0 // bit 2 #define CHS1 ADCON0bits.CHS1 // bit 3 #define CHS2 ADCON0bits.CHS2 // bit 4 #define CHS3 ADCON0bits.CHS3 // bit 5 #define CHS4 ADCON0bits.CHS4 // bit 6 #define ADPREF0 ADCON1bits.ADPREF0 // bit 0 #define ADPREF1 ADCON1bits.ADPREF1 // bit 1 #define ADNREF ADCON1bits.ADNREF // bit 2 #define ADFM ADCON1bits.ADFM // bit 7 #define TRIGSEL0 ADCON2bits.TRIGSEL0 // bit 3 #define TRIGSEL1 ADCON2bits.TRIGSEL1 // bit 4 #define TRIGSEL2 ADCON2bits.TRIGSEL2 // bit 5 #define TRIGSEL3 ADCON2bits.TRIGSEL3 // bit 6 #define TRIGSEL4 ADCON2bits.TRIGSEL4 // bit 7 #define ANSA0 ANSELAbits.ANSA0 // bit 0 #define ANSA1 ANSELAbits.ANSA1 // bit 1 #define ANSA2 ANSELAbits.ANSA2 // bit 2 #define ANSA4 ANSELAbits.ANSA4 // bit 4 #define ANSB4 ANSELBbits.ANSB4 // bit 4 #define ANSB5 ANSELBbits.ANSB5 // bit 5 #define ANSB6 ANSELBbits.ANSB6 // bit 6 #define ANSB7 ANSELBbits.ANSB7 // bit 7 #define ANSC0 ANSELCbits.ANSC0 // bit 0 #define ANSC1 ANSELCbits.ANSC1 // bit 1 #define ANSC2 ANSELCbits.ANSC2 // bit 2 #define ANSC3 ANSELCbits.ANSC3 // bit 3 #define ANSC6 ANSELCbits.ANSC6 // bit 6 #define ANSC7 ANSELCbits.ANSC7 // bit 7 #define ABDEN BAUD1CONbits.ABDEN // bit 0 #define WUE BAUD1CONbits.WUE // bit 1 #define BRG16 BAUD1CONbits.BRG16 // bit 3 #define SCKP BAUD1CONbits.SCKP // bit 4 #define RCIDL BAUD1CONbits.RCIDL // bit 6 #define ABDOVF BAUD1CONbits.ABDOVF // bit 7 #define BORRDY BORCONbits.BORRDY // bit 0 #define BORFS BORCONbits.BORFS // bit 6 #define SBOREN BORCONbits.SBOREN // bit 7 #define BSR0 BSRbits.BSR0 // bit 0 #define BSR1 BSRbits.BSR1 // bit 1 #define BSR2 BSRbits.BSR2 // bit 2 #define BSR3 BSRbits.BSR3 // bit 3 #define BSR4 BSRbits.BSR4 // bit 4 #define CTS0 CCP1CAPbits.CTS0 // bit 0, shadows bit in CCP1CAPbits #define CCP1CTS0 CCP1CAPbits.CCP1CTS0 // bit 0, shadows bit in CCP1CAPbits #define CTS1 CCP1CAPbits.CTS1 // bit 1, shadows bit in CCP1CAPbits #define CCP1CTS1 CCP1CAPbits.CCP1CTS1 // bit 1, shadows bit in CCP1CAPbits #define CTS2 CCP1CAPbits.CTS2 // bit 2, shadows bit in CCP1CAPbits #define CCP1CTS2 CCP1CAPbits.CCP1CTS2 // bit 2, shadows bit in CCP1CAPbits #define MODE0 CCP1CONbits.MODE0 // bit 0, shadows bit in CCP1CONbits #define CCP1MODE0 CCP1CONbits.CCP1MODE0 // bit 0, shadows bit in CCP1CONbits #define MODE1 CCP1CONbits.MODE1 // bit 1, shadows bit in CCP1CONbits #define CCP1MODE1 CCP1CONbits.CCP1MODE1 // bit 1, shadows bit in CCP1CONbits #define MODE2 CCP1CONbits.MODE2 // bit 2, shadows bit in CCP1CONbits #define CCP1MODE2 CCP1CONbits.CCP1MODE2 // bit 2, shadows bit in CCP1CONbits #define MODE3 CCP1CONbits.MODE3 // bit 3, shadows bit in CCP1CONbits #define CCP1MODE3 CCP1CONbits.CCP1MODE3 // bit 3, shadows bit in CCP1CONbits #define FMT CCP1CONbits.FMT // bit 4, shadows bit in CCP1CONbits #define CCP1FMT CCP1CONbits.CCP1FMT // bit 4, shadows bit in CCP1CONbits #define OUT CCP1CONbits.OUT // bit 5, shadows bit in CCP1CONbits #define CCP1OUT CCP1CONbits.CCP1OUT // bit 5, shadows bit in CCP1CONbits #define EN CCP1CONbits.EN // bit 7, shadows bit in CCP1CONbits #define CCP1EN CCP1CONbits.CCP1EN // bit 7, shadows bit in CCP1CONbits #define C1TSEL0 CCPTMRSbits.C1TSEL0 // bit 0 #define C1TSEL1 CCPTMRSbits.C1TSEL1 // bit 1 #define C2TSEL0 CCPTMRSbits.C2TSEL0 // bit 2 #define C2TSEL1 CCPTMRSbits.C2TSEL1 // bit 3 #define P3TSEL0 CCPTMRSbits.P3TSEL0 // bit 4 #define P3TSEL1 CCPTMRSbits.P3TSEL1 // bit 5 #define P4TSEL0 CCPTMRSbits.P4TSEL0 // bit 6 #define P4TSEL1 CCPTMRSbits.P4TSEL1 // bit 7 #define LC1G1D1N CLC1GLS0bits.LC1G1D1N // bit 0, shadows bit in CLC1GLS0bits #define D1N CLC1GLS0bits.D1N // bit 0, shadows bit in CLC1GLS0bits #define LC1G1D1T CLC1GLS0bits.LC1G1D1T // bit 1, shadows bit in CLC1GLS0bits #define D1T CLC1GLS0bits.D1T // bit 1, shadows bit in CLC1GLS0bits #define LC1G1D2N CLC1GLS0bits.LC1G1D2N // bit 2, shadows bit in CLC1GLS0bits #define D2N CLC1GLS0bits.D2N // bit 2, shadows bit in CLC1GLS0bits #define LC1G1D2T CLC1GLS0bits.LC1G1D2T // bit 3, shadows bit in CLC1GLS0bits #define D2T CLC1GLS0bits.D2T // bit 3, shadows bit in CLC1GLS0bits #define LC1G1D3N CLC1GLS0bits.LC1G1D3N // bit 4, shadows bit in CLC1GLS0bits #define D3N CLC1GLS0bits.D3N // bit 4, shadows bit in CLC1GLS0bits #define LC1G1D3T CLC1GLS0bits.LC1G1D3T // bit 5, shadows bit in CLC1GLS0bits #define D3T CLC1GLS0bits.D3T // bit 5, shadows bit in CLC1GLS0bits #define LC1G1D4N CLC1GLS0bits.LC1G1D4N // bit 6, shadows bit in CLC1GLS0bits #define D4N CLC1GLS0bits.D4N // bit 6, shadows bit in CLC1GLS0bits #define LC1G1D4T CLC1GLS0bits.LC1G1D4T // bit 7, shadows bit in CLC1GLS0bits #define D4T CLC1GLS0bits.D4T // bit 7, shadows bit in CLC1GLS0bits #define LC1G4D1N CLC1GLS3bits.LC1G4D1N // bit 0, shadows bit in CLC1GLS3bits #define G4D1N CLC1GLS3bits.G4D1N // bit 0, shadows bit in CLC1GLS3bits #define LC1G4D1T CLC1GLS3bits.LC1G4D1T // bit 1, shadows bit in CLC1GLS3bits #define G4D1T CLC1GLS3bits.G4D1T // bit 1, shadows bit in CLC1GLS3bits #define LC1G4D2N CLC1GLS3bits.LC1G4D2N // bit 2, shadows bit in CLC1GLS3bits #define G4D2N CLC1GLS3bits.G4D2N // bit 2, shadows bit in CLC1GLS3bits #define LC1G4D2T CLC1GLS3bits.LC1G4D2T // bit 3, shadows bit in CLC1GLS3bits #define G4D2T CLC1GLS3bits.G4D2T // bit 3, shadows bit in CLC1GLS3bits #define LC1G4D3N CLC1GLS3bits.LC1G4D3N // bit 4, shadows bit in CLC1GLS3bits #define G4D3N CLC1GLS3bits.G4D3N // bit 4, shadows bit in CLC1GLS3bits #define LC1G4D3T CLC1GLS3bits.LC1G4D3T // bit 5, shadows bit in CLC1GLS3bits #define G4D3T CLC1GLS3bits.G4D3T // bit 5, shadows bit in CLC1GLS3bits #define LC1G4D4N CLC1GLS3bits.LC1G4D4N // bit 6, shadows bit in CLC1GLS3bits #define G4D4N CLC1GLS3bits.G4D4N // bit 6, shadows bit in CLC1GLS3bits #define LC1G4D4T CLC1GLS3bits.LC1G4D4T // bit 7, shadows bit in CLC1GLS3bits #define G4D4T CLC1GLS3bits.G4D4T // bit 7, shadows bit in CLC1GLS3bits #define LC1G1POL CLC1POLbits.LC1G1POL // bit 0, shadows bit in CLC1POLbits #define G1POL CLC1POLbits.G1POL // bit 0, shadows bit in CLC1POLbits #define LC1G2POL CLC1POLbits.LC1G2POL // bit 1, shadows bit in CLC1POLbits #define G2POL CLC1POLbits.G2POL // bit 1, shadows bit in CLC1POLbits #define LC1G3POL CLC1POLbits.LC1G3POL // bit 2, shadows bit in CLC1POLbits #define G3POL CLC1POLbits.G3POL // bit 2, shadows bit in CLC1POLbits #define LC1G4POL CLC1POLbits.LC1G4POL // bit 3, shadows bit in CLC1POLbits #define G4POL CLC1POLbits.G4POL // bit 3, shadows bit in CLC1POLbits #define LC1POL CLC1POLbits.LC1POL // bit 7, shadows bit in CLC1POLbits #define POL CLC1POLbits.POL // bit 7, shadows bit in CLC1POLbits #define LC1D1S0 CLC1SEL0bits.LC1D1S0 // bit 0, shadows bit in CLC1SEL0bits #define D1S0 CLC1SEL0bits.D1S0 // bit 0, shadows bit in CLC1SEL0bits #define LC1D1S1 CLC1SEL0bits.LC1D1S1 // bit 1, shadows bit in CLC1SEL0bits #define D1S1 CLC1SEL0bits.D1S1 // bit 1, shadows bit in CLC1SEL0bits #define LC1D1S2 CLC1SEL0bits.LC1D1S2 // bit 2, shadows bit in CLC1SEL0bits #define D1S2 CLC1SEL0bits.D1S2 // bit 2, shadows bit in CLC1SEL0bits #define LC1D1S3 CLC1SEL0bits.LC1D1S3 // bit 3, shadows bit in CLC1SEL0bits #define D1S3 CLC1SEL0bits.D1S3 // bit 3, shadows bit in CLC1SEL0bits #define LC1D1S4 CLC1SEL0bits.LC1D1S4 // bit 4, shadows bit in CLC1SEL0bits #define D1S4 CLC1SEL0bits.D1S4 // bit 4, shadows bit in CLC1SEL0bits #define LC1D2S0 CLC1SEL1bits.LC1D2S0 // bit 0, shadows bit in CLC1SEL1bits #define D2S0 CLC1SEL1bits.D2S0 // bit 0, shadows bit in CLC1SEL1bits #define LC1D2S1 CLC1SEL1bits.LC1D2S1 // bit 1, shadows bit in CLC1SEL1bits #define D2S1 CLC1SEL1bits.D2S1 // bit 1, shadows bit in CLC1SEL1bits #define LC1D2S2 CLC1SEL1bits.LC1D2S2 // bit 2, shadows bit in CLC1SEL1bits #define D2S2 CLC1SEL1bits.D2S2 // bit 2, shadows bit in CLC1SEL1bits #define LC1D2S3 CLC1SEL1bits.LC1D2S3 // bit 3, shadows bit in CLC1SEL1bits #define D2S3 CLC1SEL1bits.D2S3 // bit 3, shadows bit in CLC1SEL1bits #define LC1D2S4 CLC1SEL1bits.LC1D2S4 // bit 4, shadows bit in CLC1SEL1bits #define D2S4 CLC1SEL1bits.D2S4 // bit 4, shadows bit in CLC1SEL1bits #define LC1D3S0 CLC1SEL2bits.LC1D3S0 // bit 0, shadows bit in CLC1SEL2bits #define D3S0 CLC1SEL2bits.D3S0 // bit 0, shadows bit in CLC1SEL2bits #define LC1D3S1 CLC1SEL2bits.LC1D3S1 // bit 1, shadows bit in CLC1SEL2bits #define D3S1 CLC1SEL2bits.D3S1 // bit 1, shadows bit in CLC1SEL2bits #define LC1D3S2 CLC1SEL2bits.LC1D3S2 // bit 2, shadows bit in CLC1SEL2bits #define D3S2 CLC1SEL2bits.D3S2 // bit 2, shadows bit in CLC1SEL2bits #define LC1D3S3 CLC1SEL2bits.LC1D3S3 // bit 3, shadows bit in CLC1SEL2bits #define D3S3 CLC1SEL2bits.D3S3 // bit 3, shadows bit in CLC1SEL2bits #define LC1D3S4 CLC1SEL2bits.LC1D3S4 // bit 4, shadows bit in CLC1SEL2bits #define D3S4 CLC1SEL2bits.D3S4 // bit 4, shadows bit in CLC1SEL2bits #define LC1D4S0 CLC1SEL3bits.LC1D4S0 // bit 0, shadows bit in CLC1SEL3bits #define D4S0 CLC1SEL3bits.D4S0 // bit 0, shadows bit in CLC1SEL3bits #define LC1D4S1 CLC1SEL3bits.LC1D4S1 // bit 1, shadows bit in CLC1SEL3bits #define D4S1 CLC1SEL3bits.D4S1 // bit 1, shadows bit in CLC1SEL3bits #define LC1D4S2 CLC1SEL3bits.LC1D4S2 // bit 2, shadows bit in CLC1SEL3bits #define D4S2 CLC1SEL3bits.D4S2 // bit 2, shadows bit in CLC1SEL3bits #define LC1D4S3 CLC1SEL3bits.LC1D4S3 // bit 3, shadows bit in CLC1SEL3bits #define D4S3 CLC1SEL3bits.D4S3 // bit 3, shadows bit in CLC1SEL3bits #define LC1D4S4 CLC1SEL3bits.LC1D4S4 // bit 4, shadows bit in CLC1SEL3bits #define D4S4 CLC1SEL3bits.D4S4 // bit 4, shadows bit in CLC1SEL3bits #define MCLC1OUT CLCDATAbits.MCLC1OUT // bit 0 #define MCLC2OUT CLCDATAbits.MCLC2OUT // bit 1 #define MCLC3OUT CLCDATAbits.MCLC3OUT // bit 2 #define NCH0 CM1NSELbits.NCH0 // bit 0, shadows bit in CM1NSELbits #define C1NCH0 CM1NSELbits.C1NCH0 // bit 0, shadows bit in CM1NSELbits #define NCH1 CM1NSELbits.NCH1 // bit 1, shadows bit in CM1NSELbits #define C1NCH1 CM1NSELbits.C1NCH1 // bit 1, shadows bit in CM1NSELbits #define NCH2 CM1NSELbits.NCH2 // bit 2, shadows bit in CM1NSELbits #define C1NCH2 CM1NSELbits.C1NCH2 // bit 2, shadows bit in CM1NSELbits #define PCH0 CM1PSELbits.PCH0 // bit 0, shadows bit in CM1PSELbits #define C1PCH0 CM1PSELbits.C1PCH0 // bit 0, shadows bit in CM1PSELbits #define PCH1 CM1PSELbits.PCH1 // bit 1, shadows bit in CM1PSELbits #define C1PCH1 CM1PSELbits.C1PCH1 // bit 1, shadows bit in CM1PSELbits #define PCH2 CM1PSELbits.PCH2 // bit 2, shadows bit in CM1PSELbits #define C1PCH2 CM1PSELbits.C1PCH2 // bit 2, shadows bit in CM1PSELbits #define PCH3 CM1PSELbits.PCH3 // bit 3, shadows bit in CM1PSELbits #define C1PCH3 CM1PSELbits.C1PCH3 // bit 3, shadows bit in CM1PSELbits #define MC1OUT CMOUTbits.MC1OUT // bit 0 #define MC2OUT CMOUTbits.MC2OUT // bit 1 #define MC3OUT CMOUTbits.MC3OUT // bit 2 #define MC4OUT CMOUTbits.MC4OUT // bit 3 #define ASDAC0 COG1ASD0bits.ASDAC0 // bit 2, shadows bit in COG1ASD0bits #define G1ASDAC0 COG1ASD0bits.G1ASDAC0 // bit 2, shadows bit in COG1ASD0bits #define ASDAC1 COG1ASD0bits.ASDAC1 // bit 3, shadows bit in COG1ASD0bits #define G1ASDAC1 COG1ASD0bits.G1ASDAC1 // bit 3, shadows bit in COG1ASD0bits #define ASDBD0 COG1ASD0bits.ASDBD0 // bit 4, shadows bit in COG1ASD0bits #define G1ASDBD0 COG1ASD0bits.G1ASDBD0 // bit 4, shadows bit in COG1ASD0bits #define ASDBD1 COG1ASD0bits.ASDBD1 // bit 5, shadows bit in COG1ASD0bits #define G1ASDBD1 COG1ASD0bits.G1ASDBD1 // bit 5, shadows bit in COG1ASD0bits #define ASREN COG1ASD0bits.ASREN // bit 6, shadows bit in COG1ASD0bits #define ARSEN COG1ASD0bits.ARSEN // bit 6, shadows bit in COG1ASD0bits #define G1ARSEN COG1ASD0bits.G1ARSEN // bit 6, shadows bit in COG1ASD0bits #define G1ASREN COG1ASD0bits.G1ASREN // bit 6, shadows bit in COG1ASD0bits #define ASE COG1ASD0bits.ASE // bit 7, shadows bit in COG1ASD0bits #define G1ASE COG1ASD0bits.G1ASE // bit 7, shadows bit in COG1ASD0bits #define AS0E COG1ASD1bits.AS0E // bit 0, shadows bit in COG1ASD1bits #define G1AS0E COG1ASD1bits.G1AS0E // bit 0, shadows bit in COG1ASD1bits #define AS1E COG1ASD1bits.AS1E // bit 1, shadows bit in COG1ASD1bits #define G1AS1E COG1ASD1bits.G1AS1E // bit 1, shadows bit in COG1ASD1bits #define AS2E COG1ASD1bits.AS2E // bit 2, shadows bit in COG1ASD1bits #define G1AS2E COG1ASD1bits.G1AS2E // bit 2, shadows bit in COG1ASD1bits #define AS3E COG1ASD1bits.AS3E // bit 3, shadows bit in COG1ASD1bits #define G1AS3E COG1ASD1bits.G1AS3E // bit 3, shadows bit in COG1ASD1bits #define AS4E COG1ASD1bits.AS4E // bit 4, shadows bit in COG1ASD1bits #define G1AS4E COG1ASD1bits.G1AS4E // bit 4, shadows bit in COG1ASD1bits #define AS5E COG1ASD1bits.AS5E // bit 5, shadows bit in COG1ASD1bits #define G1AS5E COG1ASD1bits.G1AS5E // bit 5, shadows bit in COG1ASD1bits #define AS6E COG1ASD1bits.AS6E // bit 6, shadows bit in COG1ASD1bits #define G1AS6E COG1ASD1bits.G1AS6E // bit 6, shadows bit in COG1ASD1bits #define AS7E COG1ASD1bits.AS7E // bit 7, shadows bit in COG1ASD1bits #define G1AS7E COG1ASD1bits.G1AS7E // bit 7, shadows bit in COG1ASD1bits #define BLKF0 COG1BLKFbits.BLKF0 // bit 0, shadows bit in COG1BLKFbits #define G1BLKF0 COG1BLKFbits.G1BLKF0 // bit 0, shadows bit in COG1BLKFbits #define BLKF1 COG1BLKFbits.BLKF1 // bit 1, shadows bit in COG1BLKFbits #define G1BLKF1 COG1BLKFbits.G1BLKF1 // bit 1, shadows bit in COG1BLKFbits #define BLKF2 COG1BLKFbits.BLKF2 // bit 2, shadows bit in COG1BLKFbits #define G1BLKF2 COG1BLKFbits.G1BLKF2 // bit 2, shadows bit in COG1BLKFbits #define BLKF3 COG1BLKFbits.BLKF3 // bit 3, shadows bit in COG1BLKFbits #define G1BLKF3 COG1BLKFbits.G1BLKF3 // bit 3, shadows bit in COG1BLKFbits #define BLKF4 COG1BLKFbits.BLKF4 // bit 4, shadows bit in COG1BLKFbits #define G1BLKF4 COG1BLKFbits.G1BLKF4 // bit 4, shadows bit in COG1BLKFbits #define BLKF5 COG1BLKFbits.BLKF5 // bit 5, shadows bit in COG1BLKFbits #define G1BLKF5 COG1BLKFbits.G1BLKF5 // bit 5, shadows bit in COG1BLKFbits #define BLKR0 COG1BLKRbits.BLKR0 // bit 0, shadows bit in COG1BLKRbits #define G1BLKR0 COG1BLKRbits.G1BLKR0 // bit 0, shadows bit in COG1BLKRbits #define BLKR1 COG1BLKRbits.BLKR1 // bit 1, shadows bit in COG1BLKRbits #define G1BLKR1 COG1BLKRbits.G1BLKR1 // bit 1, shadows bit in COG1BLKRbits #define BLKR2 COG1BLKRbits.BLKR2 // bit 2, shadows bit in COG1BLKRbits #define G1BLKR2 COG1BLKRbits.G1BLKR2 // bit 2, shadows bit in COG1BLKRbits #define BLKR3 COG1BLKRbits.BLKR3 // bit 3, shadows bit in COG1BLKRbits #define G1BLKR3 COG1BLKRbits.G1BLKR3 // bit 3, shadows bit in COG1BLKRbits #define BLKR4 COG1BLKRbits.BLKR4 // bit 4, shadows bit in COG1BLKRbits #define G1BLKR4 COG1BLKRbits.G1BLKR4 // bit 4, shadows bit in COG1BLKRbits #define BLKR5 COG1BLKRbits.BLKR5 // bit 5, shadows bit in COG1BLKRbits #define G1BLKR5 COG1BLKRbits.G1BLKR5 // bit 5, shadows bit in COG1BLKRbits #define POLA COG1CON1bits.POLA // bit 0, shadows bit in COG1CON1bits #define G1POLA COG1CON1bits.G1POLA // bit 0, shadows bit in COG1CON1bits #define POLB COG1CON1bits.POLB // bit 1, shadows bit in COG1CON1bits #define G1POLB COG1CON1bits.G1POLB // bit 1, shadows bit in COG1CON1bits #define POLC COG1CON1bits.POLC // bit 2, shadows bit in COG1CON1bits #define G1POLC COG1CON1bits.G1POLC // bit 2, shadows bit in COG1CON1bits #define POLD COG1CON1bits.POLD // bit 3, shadows bit in COG1CON1bits #define G1POLD COG1CON1bits.G1POLD // bit 3, shadows bit in COG1CON1bits #define FDBS COG1CON1bits.FDBS // bit 6, shadows bit in COG1CON1bits #define G1FDBS COG1CON1bits.G1FDBS // bit 6, shadows bit in COG1CON1bits #define RDBS COG1CON1bits.RDBS // bit 7, shadows bit in COG1CON1bits #define G1RDBS COG1CON1bits.G1RDBS // bit 7, shadows bit in COG1CON1bits #define DBF0 COG1DBFbits.DBF0 // bit 0, shadows bit in COG1DBFbits #define G1DBF0 COG1DBFbits.G1DBF0 // bit 0, shadows bit in COG1DBFbits #define DBF1 COG1DBFbits.DBF1 // bit 1, shadows bit in COG1DBFbits #define G1DBF1 COG1DBFbits.G1DBF1 // bit 1, shadows bit in COG1DBFbits #define DBF2 COG1DBFbits.DBF2 // bit 2, shadows bit in COG1DBFbits #define G1DBF2 COG1DBFbits.G1DBF2 // bit 2, shadows bit in COG1DBFbits #define DBF3 COG1DBFbits.DBF3 // bit 3, shadows bit in COG1DBFbits #define G1DBF3 COG1DBFbits.G1DBF3 // bit 3, shadows bit in COG1DBFbits #define DBF4 COG1DBFbits.DBF4 // bit 4, shadows bit in COG1DBFbits #define G1DBF4 COG1DBFbits.G1DBF4 // bit 4, shadows bit in COG1DBFbits #define DBF5 COG1DBFbits.DBF5 // bit 5, shadows bit in COG1DBFbits #define G1DBF5 COG1DBFbits.G1DBF5 // bit 5, shadows bit in COG1DBFbits #define DBR0 COG1DBRbits.DBR0 // bit 0, shadows bit in COG1DBRbits #define G1DBR0 COG1DBRbits.G1DBR0 // bit 0, shadows bit in COG1DBRbits #define DBR1 COG1DBRbits.DBR1 // bit 1, shadows bit in COG1DBRbits #define G1DBR1 COG1DBRbits.G1DBR1 // bit 1, shadows bit in COG1DBRbits #define DBR2 COG1DBRbits.DBR2 // bit 2, shadows bit in COG1DBRbits #define G1DBR2 COG1DBRbits.G1DBR2 // bit 2, shadows bit in COG1DBRbits #define DBR3 COG1DBRbits.DBR3 // bit 3, shadows bit in COG1DBRbits #define G1DBR3 COG1DBRbits.G1DBR3 // bit 3, shadows bit in COG1DBRbits #define DBR4 COG1DBRbits.DBR4 // bit 4, shadows bit in COG1DBRbits #define G1DBR4 COG1DBRbits.G1DBR4 // bit 4, shadows bit in COG1DBRbits #define DBR5 COG1DBRbits.DBR5 // bit 5, shadows bit in COG1DBRbits #define G1DBR5 COG1DBRbits.G1DBR5 // bit 5, shadows bit in COG1DBRbits #define FIS0 COG1FIS0bits.FIS0 // bit 0, shadows bit in COG1FIS0bits #define G1FIS0 COG1FIS0bits.G1FIS0 // bit 0, shadows bit in COG1FIS0bits #define FIS1 COG1FIS0bits.FIS1 // bit 1, shadows bit in COG1FIS0bits #define G1FIS1 COG1FIS0bits.G1FIS1 // bit 1, shadows bit in COG1FIS0bits #define FIS2 COG1FIS0bits.FIS2 // bit 2, shadows bit in COG1FIS0bits #define G1FIS2 COG1FIS0bits.G1FIS2 // bit 2, shadows bit in COG1FIS0bits #define FIS3 COG1FIS0bits.FIS3 // bit 3, shadows bit in COG1FIS0bits #define G1FIS3 COG1FIS0bits.G1FIS3 // bit 3, shadows bit in COG1FIS0bits #define FIS4 COG1FIS0bits.FIS4 // bit 4, shadows bit in COG1FIS0bits #define G1FIS4 COG1FIS0bits.G1FIS4 // bit 4, shadows bit in COG1FIS0bits #define FIS5 COG1FIS0bits.FIS5 // bit 5, shadows bit in COG1FIS0bits #define G1FIS5 COG1FIS0bits.G1FIS5 // bit 5, shadows bit in COG1FIS0bits #define FIS6 COG1FIS0bits.FIS6 // bit 6, shadows bit in COG1FIS0bits #define G1FIS6 COG1FIS0bits.G1FIS6 // bit 6, shadows bit in COG1FIS0bits #define FIS7 COG1FIS0bits.FIS7 // bit 7, shadows bit in COG1FIS0bits #define G1FIS7 COG1FIS0bits.G1FIS7 // bit 7, shadows bit in COG1FIS0bits #define FIS8 COG1FIS1bits.FIS8 // bit 0, shadows bit in COG1FIS1bits #define G1FIS8 COG1FIS1bits.G1FIS8 // bit 0, shadows bit in COG1FIS1bits #define FIS9 COG1FIS1bits.FIS9 // bit 1, shadows bit in COG1FIS1bits #define G1FIS9 COG1FIS1bits.G1FIS9 // bit 1, shadows bit in COG1FIS1bits #define FIS10 COG1FIS1bits.FIS10 // bit 2, shadows bit in COG1FIS1bits #define G1FIS10 COG1FIS1bits.G1FIS10 // bit 2, shadows bit in COG1FIS1bits #define FIS11 COG1FIS1bits.FIS11 // bit 3, shadows bit in COG1FIS1bits #define G1FIS11 COG1FIS1bits.G1FIS11 // bit 3, shadows bit in COG1FIS1bits #define FIS12 COG1FIS1bits.FIS12 // bit 4, shadows bit in COG1FIS1bits #define G1FIS12 COG1FIS1bits.G1FIS12 // bit 4, shadows bit in COG1FIS1bits #define FIS13 COG1FIS1bits.FIS13 // bit 5, shadows bit in COG1FIS1bits #define G1FIS13 COG1FIS1bits.G1FIS13 // bit 5, shadows bit in COG1FIS1bits #define FIS14 COG1FIS1bits.FIS14 // bit 6, shadows bit in COG1FIS1bits #define G1FIS14 COG1FIS1bits.G1FIS14 // bit 6, shadows bit in COG1FIS1bits #define FIS15 COG1FIS1bits.FIS15 // bit 7, shadows bit in COG1FIS1bits #define G1FIS15 COG1FIS1bits.G1FIS15 // bit 7, shadows bit in COG1FIS1bits #define FSIM0 COG1FSIM0bits.FSIM0 // bit 0, shadows bit in COG1FSIM0bits #define G1FSIM0 COG1FSIM0bits.G1FSIM0 // bit 0, shadows bit in COG1FSIM0bits #define FSIM1 COG1FSIM0bits.FSIM1 // bit 1, shadows bit in COG1FSIM0bits #define G1FSIM1 COG1FSIM0bits.G1FSIM1 // bit 1, shadows bit in COG1FSIM0bits #define FSIM2 COG1FSIM0bits.FSIM2 // bit 2, shadows bit in COG1FSIM0bits #define G1FSIM2 COG1FSIM0bits.G1FSIM2 // bit 2, shadows bit in COG1FSIM0bits #define FSIM3 COG1FSIM0bits.FSIM3 // bit 3, shadows bit in COG1FSIM0bits #define G1FSIM3 COG1FSIM0bits.G1FSIM3 // bit 3, shadows bit in COG1FSIM0bits #define FSIM4 COG1FSIM0bits.FSIM4 // bit 4, shadows bit in COG1FSIM0bits #define G1FSIM4 COG1FSIM0bits.G1FSIM4 // bit 4, shadows bit in COG1FSIM0bits #define FSIM5 COG1FSIM0bits.FSIM5 // bit 5, shadows bit in COG1FSIM0bits #define G1FSIM5 COG1FSIM0bits.G1FSIM5 // bit 5, shadows bit in COG1FSIM0bits #define FSIM6 COG1FSIM0bits.FSIM6 // bit 6, shadows bit in COG1FSIM0bits #define G1FSIM6 COG1FSIM0bits.G1FSIM6 // bit 6, shadows bit in COG1FSIM0bits #define FSIM7 COG1FSIM0bits.FSIM7 // bit 7, shadows bit in COG1FSIM0bits #define G1FSIM7 COG1FSIM0bits.G1FSIM7 // bit 7, shadows bit in COG1FSIM0bits #define FSIM8 COG1FSIM1bits.FSIM8 // bit 0, shadows bit in COG1FSIM1bits #define G1FSIM8 COG1FSIM1bits.G1FSIM8 // bit 0, shadows bit in COG1FSIM1bits #define FSIM9 COG1FSIM1bits.FSIM9 // bit 1, shadows bit in COG1FSIM1bits #define G1FSIM9 COG1FSIM1bits.G1FSIM9 // bit 1, shadows bit in COG1FSIM1bits #define FSIM10 COG1FSIM1bits.FSIM10 // bit 2, shadows bit in COG1FSIM1bits #define G1FSIM10 COG1FSIM1bits.G1FSIM10 // bit 2, shadows bit in COG1FSIM1bits #define FSIM11 COG1FSIM1bits.FSIM11 // bit 3, shadows bit in COG1FSIM1bits #define G1FSIM11 COG1FSIM1bits.G1FSIM11 // bit 3, shadows bit in COG1FSIM1bits #define FSIM12 COG1FSIM1bits.FSIM12 // bit 4, shadows bit in COG1FSIM1bits #define G1FSIM12 COG1FSIM1bits.G1FSIM12 // bit 4, shadows bit in COG1FSIM1bits #define FSIM13 COG1FSIM1bits.FSIM13 // bit 5, shadows bit in COG1FSIM1bits #define G1FSIM13 COG1FSIM1bits.G1FSIM13 // bit 5, shadows bit in COG1FSIM1bits #define FSIM14 COG1FSIM1bits.FSIM14 // bit 6, shadows bit in COG1FSIM1bits #define G1FSIM14 COG1FSIM1bits.G1FSIM14 // bit 6, shadows bit in COG1FSIM1bits #define FSIM15 COG1FSIM1bits.FSIM15 // bit 7, shadows bit in COG1FSIM1bits #define G1FSIM15 COG1FSIM1bits.G1FSIM15 // bit 7, shadows bit in COG1FSIM1bits #define PHF0 COG1PHFbits.PHF0 // bit 0, shadows bit in COG1PHFbits #define G1PHF0 COG1PHFbits.G1PHF0 // bit 0, shadows bit in COG1PHFbits #define PHF1 COG1PHFbits.PHF1 // bit 1, shadows bit in COG1PHFbits #define G1PHF1 COG1PHFbits.G1PHF1 // bit 1, shadows bit in COG1PHFbits #define PHF2 COG1PHFbits.PHF2 // bit 2, shadows bit in COG1PHFbits #define G1PHF2 COG1PHFbits.G1PHF2 // bit 2, shadows bit in COG1PHFbits #define PHF3 COG1PHFbits.PHF3 // bit 3, shadows bit in COG1PHFbits #define G1PHF3 COG1PHFbits.G1PHF3 // bit 3, shadows bit in COG1PHFbits #define PHF4 COG1PHFbits.PHF4 // bit 4, shadows bit in COG1PHFbits #define G1PHF4 COG1PHFbits.G1PHF4 // bit 4, shadows bit in COG1PHFbits #define PHF5 COG1PHFbits.PHF5 // bit 5, shadows bit in COG1PHFbits #define G1PHF5 COG1PHFbits.G1PHF5 // bit 5, shadows bit in COG1PHFbits #define PHR0 COG1PHRbits.PHR0 // bit 0, shadows bit in COG1PHRbits #define G1PHR0 COG1PHRbits.G1PHR0 // bit 0, shadows bit in COG1PHRbits #define PHR1 COG1PHRbits.PHR1 // bit 1, shadows bit in COG1PHRbits #define G1PHR1 COG1PHRbits.G1PHR1 // bit 1, shadows bit in COG1PHRbits #define PHR2 COG1PHRbits.PHR2 // bit 2, shadows bit in COG1PHRbits #define G1PHR2 COG1PHRbits.G1PHR2 // bit 2, shadows bit in COG1PHRbits #define PHR3 COG1PHRbits.PHR3 // bit 3, shadows bit in COG1PHRbits #define G1PHR3 COG1PHRbits.G1PHR3 // bit 3, shadows bit in COG1PHRbits #define PHR4 COG1PHRbits.PHR4 // bit 4, shadows bit in COG1PHRbits #define G1PHR4 COG1PHRbits.G1PHR4 // bit 4, shadows bit in COG1PHRbits #define PHR5 COG1PHRbits.PHR5 // bit 5, shadows bit in COG1PHRbits #define G1PHR5 COG1PHRbits.G1PHR5 // bit 5, shadows bit in COG1PHRbits #define RIS0 COG1RIS0bits.RIS0 // bit 0, shadows bit in COG1RIS0bits #define G1RIS0 COG1RIS0bits.G1RIS0 // bit 0, shadows bit in COG1RIS0bits #define RIS1 COG1RIS0bits.RIS1 // bit 1, shadows bit in COG1RIS0bits #define G1RIS1 COG1RIS0bits.G1RIS1 // bit 1, shadows bit in COG1RIS0bits #define RIS2 COG1RIS0bits.RIS2 // bit 2, shadows bit in COG1RIS0bits #define G1RIS2 COG1RIS0bits.G1RIS2 // bit 2, shadows bit in COG1RIS0bits #define RIS3 COG1RIS0bits.RIS3 // bit 3, shadows bit in COG1RIS0bits #define G1RIS3 COG1RIS0bits.G1RIS3 // bit 3, shadows bit in COG1RIS0bits #define RIS4 COG1RIS0bits.RIS4 // bit 4, shadows bit in COG1RIS0bits #define G1RIS4 COG1RIS0bits.G1RIS4 // bit 4, shadows bit in COG1RIS0bits #define RIS5 COG1RIS0bits.RIS5 // bit 5, shadows bit in COG1RIS0bits #define G1RIS5 COG1RIS0bits.G1RIS5 // bit 5, shadows bit in COG1RIS0bits #define RIS6 COG1RIS0bits.RIS6 // bit 6, shadows bit in COG1RIS0bits #define G1RIS6 COG1RIS0bits.G1RIS6 // bit 6, shadows bit in COG1RIS0bits #define RIS7 COG1RIS0bits.RIS7 // bit 7, shadows bit in COG1RIS0bits #define G1RIS7 COG1RIS0bits.G1RIS7 // bit 7, shadows bit in COG1RIS0bits #define RIS8 COG1RIS1bits.RIS8 // bit 0, shadows bit in COG1RIS1bits #define G1RIS8 COG1RIS1bits.G1RIS8 // bit 0, shadows bit in COG1RIS1bits #define RIS9 COG1RIS1bits.RIS9 // bit 1, shadows bit in COG1RIS1bits #define G1RIS9 COG1RIS1bits.G1RIS9 // bit 1, shadows bit in COG1RIS1bits #define RIS10 COG1RIS1bits.RIS10 // bit 2, shadows bit in COG1RIS1bits #define G1RIS10 COG1RIS1bits.G1RIS10 // bit 2, shadows bit in COG1RIS1bits #define RIS11 COG1RIS1bits.RIS11 // bit 3, shadows bit in COG1RIS1bits #define G1RIS11 COG1RIS1bits.G1RIS11 // bit 3, shadows bit in COG1RIS1bits #define RIS12 COG1RIS1bits.RIS12 // bit 4, shadows bit in COG1RIS1bits #define G1RIS12 COG1RIS1bits.G1RIS12 // bit 4, shadows bit in COG1RIS1bits #define RIS13 COG1RIS1bits.RIS13 // bit 5, shadows bit in COG1RIS1bits #define G1RIS13 COG1RIS1bits.G1RIS13 // bit 5, shadows bit in COG1RIS1bits #define RIS14 COG1RIS1bits.RIS14 // bit 6, shadows bit in COG1RIS1bits #define G1RIS14 COG1RIS1bits.G1RIS14 // bit 6, shadows bit in COG1RIS1bits #define RIS15 COG1RIS1bits.RIS15 // bit 7, shadows bit in COG1RIS1bits #define G1RIS15 COG1RIS1bits.G1RIS15 // bit 7, shadows bit in COG1RIS1bits #define RSIM0 COG1RSIM0bits.RSIM0 // bit 0, shadows bit in COG1RSIM0bits #define G1RSIM0 COG1RSIM0bits.G1RSIM0 // bit 0, shadows bit in COG1RSIM0bits #define RSIM1 COG1RSIM0bits.RSIM1 // bit 1, shadows bit in COG1RSIM0bits #define G1RSIM1 COG1RSIM0bits.G1RSIM1 // bit 1, shadows bit in COG1RSIM0bits #define RSIM2 COG1RSIM0bits.RSIM2 // bit 2, shadows bit in COG1RSIM0bits #define G1RSIM2 COG1RSIM0bits.G1RSIM2 // bit 2, shadows bit in COG1RSIM0bits #define RSIM3 COG1RSIM0bits.RSIM3 // bit 3, shadows bit in COG1RSIM0bits #define G1RSIM3 COG1RSIM0bits.G1RSIM3 // bit 3, shadows bit in COG1RSIM0bits #define RSIM4 COG1RSIM0bits.RSIM4 // bit 4, shadows bit in COG1RSIM0bits #define G1RSIM4 COG1RSIM0bits.G1RSIM4 // bit 4, shadows bit in COG1RSIM0bits #define RSIM5 COG1RSIM0bits.RSIM5 // bit 5, shadows bit in COG1RSIM0bits #define G1RSIM5 COG1RSIM0bits.G1RSIM5 // bit 5, shadows bit in COG1RSIM0bits #define RSIM6 COG1RSIM0bits.RSIM6 // bit 6, shadows bit in COG1RSIM0bits #define G1RSIM6 COG1RSIM0bits.G1RSIM6 // bit 6, shadows bit in COG1RSIM0bits #define RSIM7 COG1RSIM0bits.RSIM7 // bit 7, shadows bit in COG1RSIM0bits #define G1RSIM7 COG1RSIM0bits.G1RSIM7 // bit 7, shadows bit in COG1RSIM0bits #define RSIM8 COG1RSIM1bits.RSIM8 // bit 0, shadows bit in COG1RSIM1bits #define G1RSIM8 COG1RSIM1bits.G1RSIM8 // bit 0, shadows bit in COG1RSIM1bits #define RSIM9 COG1RSIM1bits.RSIM9 // bit 1, shadows bit in COG1RSIM1bits #define G1RSIM9 COG1RSIM1bits.G1RSIM9 // bit 1, shadows bit in COG1RSIM1bits #define RSIM10 COG1RSIM1bits.RSIM10 // bit 2, shadows bit in COG1RSIM1bits #define G1RSIM10 COG1RSIM1bits.G1RSIM10 // bit 2, shadows bit in COG1RSIM1bits #define RSIM11 COG1RSIM1bits.RSIM11 // bit 3, shadows bit in COG1RSIM1bits #define G1RSIM11 COG1RSIM1bits.G1RSIM11 // bit 3, shadows bit in COG1RSIM1bits #define RSIM12 COG1RSIM1bits.RSIM12 // bit 4, shadows bit in COG1RSIM1bits #define G1RSIM12 COG1RSIM1bits.G1RSIM12 // bit 4, shadows bit in COG1RSIM1bits #define RSIM13 COG1RSIM1bits.RSIM13 // bit 5, shadows bit in COG1RSIM1bits #define G1RSIM13 COG1RSIM1bits.G1RSIM13 // bit 5, shadows bit in COG1RSIM1bits #define RSIM14 COG1RSIM1bits.RSIM14 // bit 6, shadows bit in COG1RSIM1bits #define G1RSIM14 COG1RSIM1bits.G1RSIM14 // bit 6, shadows bit in COG1RSIM1bits #define RSIM15 COG1RSIM1bits.RSIM15 // bit 7, shadows bit in COG1RSIM1bits #define G1RSIM15 COG1RSIM1bits.G1RSIM15 // bit 7, shadows bit in COG1RSIM1bits #define STRA COG1STRbits.STRA // bit 0, shadows bit in COG1STRbits #define G1STRA COG1STRbits.G1STRA // bit 0, shadows bit in COG1STRbits #define STRB COG1STRbits.STRB // bit 1, shadows bit in COG1STRbits #define G1STRB COG1STRbits.G1STRB // bit 1, shadows bit in COG1STRbits #define STRC COG1STRbits.STRC // bit 2, shadows bit in COG1STRbits #define G1STRC COG1STRbits.G1STRC // bit 2, shadows bit in COG1STRbits #define STRD COG1STRbits.STRD // bit 3, shadows bit in COG1STRbits #define G1STRD COG1STRbits.G1STRD // bit 3, shadows bit in COG1STRbits #define SDATA COG1STRbits.SDATA // bit 4, shadows bit in COG1STRbits #define G1SDATA COG1STRbits.G1SDATA // bit 4, shadows bit in COG1STRbits #define SDATB COG1STRbits.SDATB // bit 5, shadows bit in COG1STRbits #define G1SDATB COG1STRbits.G1SDATB // bit 5, shadows bit in COG1STRbits #define SDATC COG1STRbits.SDATC // bit 6, shadows bit in COG1STRbits #define G1SDATC COG1STRbits.G1SDATC // bit 6, shadows bit in COG1STRbits #define SDATD COG1STRbits.SDATD // bit 7, shadows bit in COG1STRbits #define G1SDATD COG1STRbits.G1SDATD // bit 7, shadows bit in COG1STRbits #define REF0 DAC1CON1bits.REF0 // bit 0, shadows bit in DAC1CON1bits #define DAC1REF0 DAC1CON1bits.DAC1REF0 // bit 0, shadows bit in DAC1CON1bits #define R0 DAC1CON1bits.R0 // bit 0, shadows bit in DAC1CON1bits #define DAC1R0 DAC1CON1bits.DAC1R0 // bit 0, shadows bit in DAC1CON1bits #define REF1 DAC1CON1bits.REF1 // bit 1, shadows bit in DAC1CON1bits #define DAC1REF1 DAC1CON1bits.DAC1REF1 // bit 1, shadows bit in DAC1CON1bits #define R1 DAC1CON1bits.R1 // bit 1, shadows bit in DAC1CON1bits #define DAC1R1 DAC1CON1bits.DAC1R1 // bit 1, shadows bit in DAC1CON1bits #define REF2 DAC1CON1bits.REF2 // bit 2, shadows bit in DAC1CON1bits #define DAC1REF2 DAC1CON1bits.DAC1REF2 // bit 2, shadows bit in DAC1CON1bits #define R2 DAC1CON1bits.R2 // bit 2, shadows bit in DAC1CON1bits #define DAC1R2 DAC1CON1bits.DAC1R2 // bit 2, shadows bit in DAC1CON1bits #define REF3 DAC1CON1bits.REF3 // bit 3, shadows bit in DAC1CON1bits #define DAC1REF3 DAC1CON1bits.DAC1REF3 // bit 3, shadows bit in DAC1CON1bits #define R3 DAC1CON1bits.R3 // bit 3, shadows bit in DAC1CON1bits #define DAC1R3 DAC1CON1bits.DAC1R3 // bit 3, shadows bit in DAC1CON1bits #define REF4 DAC1CON1bits.REF4 // bit 4, shadows bit in DAC1CON1bits #define DAC1REF4 DAC1CON1bits.DAC1REF4 // bit 4, shadows bit in DAC1CON1bits #define R4 DAC1CON1bits.R4 // bit 4, shadows bit in DAC1CON1bits #define DAC1R4 DAC1CON1bits.DAC1R4 // bit 4, shadows bit in DAC1CON1bits #define REF5 DAC1CON1bits.REF5 // bit 5, shadows bit in DAC1CON1bits #define DAC1REF5 DAC1CON1bits.DAC1REF5 // bit 5, shadows bit in DAC1CON1bits #define R5 DAC1CON1bits.R5 // bit 5, shadows bit in DAC1CON1bits #define DAC1R5 DAC1CON1bits.DAC1R5 // bit 5, shadows bit in DAC1CON1bits #define REF6 DAC1CON1bits.REF6 // bit 6, shadows bit in DAC1CON1bits #define DAC1REF6 DAC1CON1bits.DAC1REF6 // bit 6, shadows bit in DAC1CON1bits #define R6 DAC1CON1bits.R6 // bit 6, shadows bit in DAC1CON1bits #define DAC1R6 DAC1CON1bits.DAC1R6 // bit 6, shadows bit in DAC1CON1bits #define REF7 DAC1CON1bits.REF7 // bit 7, shadows bit in DAC1CON1bits #define DAC1REF7 DAC1CON1bits.DAC1REF7 // bit 7, shadows bit in DAC1CON1bits #define R7 DAC1CON1bits.R7 // bit 7, shadows bit in DAC1CON1bits #define DAC1R7 DAC1CON1bits.DAC1R7 // bit 7, shadows bit in DAC1CON1bits #define REF8 DAC1CON2bits.REF8 // bit 0, shadows bit in DAC1CON2bits #define DAC1REF8 DAC1CON2bits.DAC1REF8 // bit 0, shadows bit in DAC1CON2bits #define R8 DAC1CON2bits.R8 // bit 0, shadows bit in DAC1CON2bits #define DAC1R8 DAC1CON2bits.DAC1R8 // bit 0, shadows bit in DAC1CON2bits #define REF9 DAC1CON2bits.REF9 // bit 1, shadows bit in DAC1CON2bits #define DAC1REF9 DAC1CON2bits.DAC1REF9 // bit 1, shadows bit in DAC1CON2bits #define R9 DAC1CON2bits.R9 // bit 1, shadows bit in DAC1CON2bits #define DAC1R9 DAC1CON2bits.DAC1R9 // bit 1, shadows bit in DAC1CON2bits #define REF10 DAC1CON2bits.REF10 // bit 2, shadows bit in DAC1CON2bits #define DAC1REF10 DAC1CON2bits.DAC1REF10 // bit 2, shadows bit in DAC1CON2bits #define R10 DAC1CON2bits.R10 // bit 2, shadows bit in DAC1CON2bits #define DAC1R10 DAC1CON2bits.DAC1R10 // bit 2, shadows bit in DAC1CON2bits #define REF11 DAC1CON2bits.REF11 // bit 3, shadows bit in DAC1CON2bits #define DAC1REF11 DAC1CON2bits.DAC1REF11 // bit 3, shadows bit in DAC1CON2bits #define R11 DAC1CON2bits.R11 // bit 3, shadows bit in DAC1CON2bits #define DAC1R11 DAC1CON2bits.DAC1R11 // bit 3, shadows bit in DAC1CON2bits #define REF12 DAC1CON2bits.REF12 // bit 4, shadows bit in DAC1CON2bits #define DAC1REF12 DAC1CON2bits.DAC1REF12 // bit 4, shadows bit in DAC1CON2bits #define R12 DAC1CON2bits.R12 // bit 4, shadows bit in DAC1CON2bits #define DAC1R12 DAC1CON2bits.DAC1R12 // bit 4, shadows bit in DAC1CON2bits #define REF13 DAC1CON2bits.REF13 // bit 5, shadows bit in DAC1CON2bits #define DAC1REF13 DAC1CON2bits.DAC1REF13 // bit 5, shadows bit in DAC1CON2bits #define R13 DAC1CON2bits.R13 // bit 5, shadows bit in DAC1CON2bits #define DAC1R13 DAC1CON2bits.DAC1R13 // bit 5, shadows bit in DAC1CON2bits #define REF14 DAC1CON2bits.REF14 // bit 6, shadows bit in DAC1CON2bits #define DAC1REF14 DAC1CON2bits.DAC1REF14 // bit 6, shadows bit in DAC1CON2bits #define R14 DAC1CON2bits.R14 // bit 6, shadows bit in DAC1CON2bits #define DAC1R14 DAC1CON2bits.DAC1R14 // bit 6, shadows bit in DAC1CON2bits #define REF15 DAC1CON2bits.REF15 // bit 7, shadows bit in DAC1CON2bits #define DAC1REF15 DAC1CON2bits.DAC1REF15 // bit 7, shadows bit in DAC1CON2bits #define R15 DAC1CON2bits.R15 // bit 7, shadows bit in DAC1CON2bits #define DAC1R15 DAC1CON2bits.DAC1R15 // bit 7, shadows bit in DAC1CON2bits #define DAC1LD DACLDbits.DAC1LD // bit 0 #define DAC2LD DACLDbits.DAC2LD // bit 1 #define TSRNG FVRCONbits.TSRNG // bit 4 #define TSEN FVRCONbits.TSEN // bit 5 #define FVRRDY FVRCONbits.FVRRDY // bit 6 #define FVREN FVRCONbits.FVREN // bit 7 #define HIDC4 HIDRVCbits.HIDC4 // bit 4 #define HIDC5 HIDRVCbits.HIDC5 // bit 5 #define INLVLA0 INLVLAbits.INLVLA0 // bit 0 #define INLVLA1 INLVLAbits.INLVLA1 // bit 1 #define INLVLA2 INLVLAbits.INLVLA2 // bit 2 #define INLVLA3 INLVLAbits.INLVLA3 // bit 3 #define INLVLA4 INLVLAbits.INLVLA4 // bit 4 #define INLVLA5 INLVLAbits.INLVLA5 // bit 5 #define INLVLB4 INLVLBbits.INLVLB4 // bit 4 #define INLVLB5 INLVLBbits.INLVLB5 // bit 5 #define INLVLB6 INLVLBbits.INLVLB6 // bit 6 #define INLVLB7 INLVLBbits.INLVLB7 // bit 7 #define INLVLC0 INLVLCbits.INLVLC0 // bit 0 #define INLVLC1 INLVLCbits.INLVLC1 // bit 1 #define INLVLC2 INLVLCbits.INLVLC2 // bit 2 #define INLVLC3 INLVLCbits.INLVLC3 // bit 3 #define INLVLC4 INLVLCbits.INLVLC4 // bit 4 #define INLVLC5 INLVLCbits.INLVLC5 // bit 5 #define INLVLC6 INLVLCbits.INLVLC6 // bit 6 #define INLVLC7 INLVLCbits.INLVLC7 // bit 7 #define IOCIF INTCONbits.IOCIF // bit 0 #define INTF INTCONbits.INTF // bit 1 #define TMR0IF INTCONbits.TMR0IF // bit 2, shadows bit in INTCONbits #define T0IF INTCONbits.T0IF // bit 2, shadows bit in INTCONbits #define IOCIE INTCONbits.IOCIE // bit 3 #define INTE INTCONbits.INTE // bit 4 #define TMR0IE INTCONbits.TMR0IE // bit 5, shadows bit in INTCONbits #define T0IE INTCONbits.T0IE // bit 5, shadows bit in INTCONbits #define PEIE INTCONbits.PEIE // bit 6 #define GIE INTCONbits.GIE // bit 7 #define IOCAF0 IOCAFbits.IOCAF0 // bit 0 #define IOCAF1 IOCAFbits.IOCAF1 // bit 1 #define IOCAF2 IOCAFbits.IOCAF2 // bit 2 #define IOCAF3 IOCAFbits.IOCAF3 // bit 3 #define IOCAF4 IOCAFbits.IOCAF4 // bit 4 #define IOCAF5 IOCAFbits.IOCAF5 // bit 5 #define IOCAN0 IOCANbits.IOCAN0 // bit 0 #define IOCAN1 IOCANbits.IOCAN1 // bit 1 #define IOCAN2 IOCANbits.IOCAN2 // bit 2 #define IOCAN3 IOCANbits.IOCAN3 // bit 3 #define IOCAN4 IOCANbits.IOCAN4 // bit 4 #define IOCAN5 IOCANbits.IOCAN5 // bit 5 #define IOCAP0 IOCAPbits.IOCAP0 // bit 0 #define IOCAP1 IOCAPbits.IOCAP1 // bit 1 #define IOCAP2 IOCAPbits.IOCAP2 // bit 2 #define IOCAP3 IOCAPbits.IOCAP3 // bit 3 #define IOCAP4 IOCAPbits.IOCAP4 // bit 4 #define IOCAP5 IOCAPbits.IOCAP5 // bit 5 #define IOCBF4 IOCBFbits.IOCBF4 // bit 4 #define IOCBF5 IOCBFbits.IOCBF5 // bit 5 #define IOCBF6 IOCBFbits.IOCBF6 // bit 6 #define IOCBF7 IOCBFbits.IOCBF7 // bit 7 #define IOCBN4 IOCBNbits.IOCBN4 // bit 4 #define IOCBN5 IOCBNbits.IOCBN5 // bit 5 #define IOCBN6 IOCBNbits.IOCBN6 // bit 6 #define IOCBN7 IOCBNbits.IOCBN7 // bit 7 #define IOCBP4 IOCBPbits.IOCBP4 // bit 4 #define IOCBP5 IOCBPbits.IOCBP5 // bit 5 #define IOCBP6 IOCBPbits.IOCBP6 // bit 6 #define IOCBP7 IOCBPbits.IOCBP7 // bit 7 #define IOCCF0 IOCCFbits.IOCCF0 // bit 0 #define IOCCF1 IOCCFbits.IOCCF1 // bit 1 #define IOCCF2 IOCCFbits.IOCCF2 // bit 2 #define IOCCF3 IOCCFbits.IOCCF3 // bit 3 #define IOCCF4 IOCCFbits.IOCCF4 // bit 4 #define IOCCF5 IOCCFbits.IOCCF5 // bit 5 #define IOCCF6 IOCCFbits.IOCCF6 // bit 6 #define IOCCF7 IOCCFbits.IOCCF7 // bit 7 #define IOCCN0 IOCCNbits.IOCCN0 // bit 0 #define IOCCN1 IOCCNbits.IOCCN1 // bit 1 #define IOCCN2 IOCCNbits.IOCCN2 // bit 2 #define IOCCN3 IOCCNbits.IOCCN3 // bit 3 #define IOCCN4 IOCCNbits.IOCCN4 // bit 4 #define IOCCN5 IOCCNbits.IOCCN5 // bit 5 #define IOCCN6 IOCCNbits.IOCCN6 // bit 6 #define IOCCN7 IOCCNbits.IOCCN7 // bit 7 #define IOCCP0 IOCCPbits.IOCCP0 // bit 0 #define IOCCP1 IOCCPbits.IOCCP1 // bit 1 #define IOCCP2 IOCCPbits.IOCCP2 // bit 2 #define IOCCP3 IOCCPbits.IOCCP3 // bit 3 #define IOCCP4 IOCCPbits.IOCCP4 // bit 4 #define IOCCP5 IOCCPbits.IOCCP5 // bit 5 #define IOCCP6 IOCCPbits.IOCCP6 // bit 6 #define IOCCP7 IOCCPbits.IOCCP7 // bit 7 #define LATA0 LATAbits.LATA0 // bit 0 #define LATA1 LATAbits.LATA1 // bit 1 #define LATA2 LATAbits.LATA2 // bit 2 #define LATA4 LATAbits.LATA4 // bit 4 #define LATA5 LATAbits.LATA5 // bit 5 #define LATB4 LATBbits.LATB4 // bit 4 #define LATB5 LATBbits.LATB5 // bit 5 #define LATB6 LATBbits.LATB6 // bit 6 #define LATB7 LATBbits.LATB7 // bit 7 #define LATC0 LATCbits.LATC0 // bit 0 #define LATC1 LATCbits.LATC1 // bit 1 #define LATC2 LATCbits.LATC2 // bit 2 #define LATC3 LATCbits.LATC3 // bit 3 #define LATC4 LATCbits.LATC4 // bit 4 #define LATC5 LATCbits.LATC5 // bit 5 #define LATC6 LATCbits.LATC6 // bit 6 #define LATC7 LATCbits.LATC7 // bit 7 #define CH0 MD1CARHbits.CH0 // bit 0, shadows bit in MD1CARHbits #define MD1CH0 MD1CARHbits.MD1CH0 // bit 0, shadows bit in MD1CARHbits #define CH1 MD1CARHbits.CH1 // bit 1, shadows bit in MD1CARHbits #define MD1CH1 MD1CARHbits.MD1CH1 // bit 1, shadows bit in MD1CARHbits #define CH2 MD1CARHbits.CH2 // bit 2, shadows bit in MD1CARHbits #define MD1CH2 MD1CARHbits.MD1CH2 // bit 2, shadows bit in MD1CARHbits #define CH3 MD1CARHbits.CH3 // bit 3, shadows bit in MD1CARHbits #define MD1CH3 MD1CARHbits.MD1CH3 // bit 3, shadows bit in MD1CARHbits #define CL0 MD1CARLbits.CL0 // bit 0, shadows bit in MD1CARLbits #define MD1CL0 MD1CARLbits.MD1CL0 // bit 0, shadows bit in MD1CARLbits #define CL1 MD1CARLbits.CL1 // bit 1, shadows bit in MD1CARLbits #define MD1CL1 MD1CARLbits.MD1CL1 // bit 1, shadows bit in MD1CARLbits #define CL2 MD1CARLbits.CL2 // bit 2, shadows bit in MD1CARLbits #define MD1CL2 MD1CARLbits.MD1CL2 // bit 2, shadows bit in MD1CARLbits #define CL3 MD1CARLbits.CL3 // bit 3, shadows bit in MD1CARLbits #define MD1CL3 MD1CARLbits.MD1CL3 // bit 3, shadows bit in MD1CARLbits #define CLSYNC MD1CON1bits.CLSYNC // bit 0, shadows bit in MD1CON1bits #define MD1CLSYNC MD1CON1bits.MD1CLSYNC // bit 0, shadows bit in MD1CON1bits #define CLPOL MD1CON1bits.CLPOL // bit 1, shadows bit in MD1CON1bits #define MD1CLPOL MD1CON1bits.MD1CLPOL // bit 1, shadows bit in MD1CON1bits #define CHSYNC MD1CON1bits.CHSYNC // bit 4, shadows bit in MD1CON1bits #define MD1CHSYNC MD1CON1bits.MD1CHSYNC // bit 4, shadows bit in MD1CON1bits #define CHPOL MD1CON1bits.CHPOL // bit 5, shadows bit in MD1CON1bits #define MD1CHPOL MD1CON1bits.MD1CHPOL // bit 5, shadows bit in MD1CON1bits #define MS0 MD1SRCbits.MS0 // bit 0, shadows bit in MD1SRCbits #define MD1MS0 MD1SRCbits.MD1MS0 // bit 0, shadows bit in MD1SRCbits #define MS1 MD1SRCbits.MS1 // bit 1, shadows bit in MD1SRCbits #define MD1MS1 MD1SRCbits.MD1MS1 // bit 1, shadows bit in MD1SRCbits #define MS2 MD1SRCbits.MS2 // bit 2, shadows bit in MD1SRCbits #define MD1MS2 MD1SRCbits.MD1MS2 // bit 2, shadows bit in MD1SRCbits #define MS3 MD1SRCbits.MS3 // bit 3, shadows bit in MD1SRCbits #define MD1MS3 MD1SRCbits.MD1MS3 // bit 3, shadows bit in MD1SRCbits #define MS4 MD1SRCbits.MS4 // bit 4, shadows bit in MD1SRCbits #define MD1MS4 MD1SRCbits.MD1MS4 // bit 4, shadows bit in MD1SRCbits #define ODA0 ODCONAbits.ODA0 // bit 0 #define ODA1 ODCONAbits.ODA1 // bit 1 #define ODA2 ODCONAbits.ODA2 // bit 2 #define ODA4 ODCONAbits.ODA4 // bit 4 #define ODA5 ODCONAbits.ODA5 // bit 5 #define ODB4 ODCONBbits.ODB4 // bit 4 #define ODB5 ODCONBbits.ODB5 // bit 5 #define ODB6 ODCONBbits.ODB6 // bit 6 #define ODB7 ODCONBbits.ODB7 // bit 7 #define ODC0 ODCONCbits.ODC0 // bit 0 #define ODC1 ODCONCbits.ODC1 // bit 1 #define ODC2 ODCONCbits.ODC2 // bit 2 #define ODC3 ODCONCbits.ODC3 // bit 3 #define ODC4 ODCONCbits.ODC4 // bit 4 #define ODC5 ODCONCbits.ODC5 // bit 5 #define ODC6 ODCONCbits.ODC6 // bit 6 #define ODC7 ODCONCbits.ODC7 // bit 7 #define PS0 OPTION_REGbits.PS0 // bit 0 #define PS1 OPTION_REGbits.PS1 // bit 1 #define PS2 OPTION_REGbits.PS2 // bit 2 #define PSA OPTION_REGbits.PSA // bit 3 #define TMR0SE OPTION_REGbits.TMR0SE // bit 4, shadows bit in OPTION_REGbits #define T0SE OPTION_REGbits.T0SE // bit 4, shadows bit in OPTION_REGbits #define TMR0CS OPTION_REGbits.TMR0CS // bit 5, shadows bit in OPTION_REGbits #define T0CS OPTION_REGbits.T0CS // bit 5, shadows bit in OPTION_REGbits #define INTEDG OPTION_REGbits.INTEDG // bit 6 #define NOT_WPUEN OPTION_REGbits.NOT_WPUEN // bit 7 #define SCS0 OSCCONbits.SCS0 // bit 0 #define SCS1 OSCCONbits.SCS1 // bit 1 #define IRCF0 OSCCONbits.IRCF0 // bit 3 #define IRCF1 OSCCONbits.IRCF1 // bit 4 #define IRCF2 OSCCONbits.IRCF2 // bit 5 #define IRCF3 OSCCONbits.IRCF3 // bit 6 #define SPLLEN OSCCONbits.SPLLEN // bit 7 #define HFIOFS OSCSTATbits.HFIOFS // bit 0 #define LFIOFR OSCSTATbits.LFIOFR // bit 1 #define MFIOFR OSCSTATbits.MFIOFR // bit 2 #define HFIOFL OSCSTATbits.HFIOFL // bit 3 #define HFIOFR OSCSTATbits.HFIOFR // bit 4 #define OSTS OSCSTATbits.OSTS // bit 5 #define PLLR OSCSTATbits.PLLR // bit 6 #define SOSCR OSCSTATbits.SOSCR // bit 7 #define TUN0 OSCTUNEbits.TUN0 // bit 0 #define TUN1 OSCTUNEbits.TUN1 // bit 1 #define TUN2 OSCTUNEbits.TUN2 // bit 2 #define TUN3 OSCTUNEbits.TUN3 // bit 3 #define TUN4 OSCTUNEbits.TUN4 // bit 4 #define TUN5 OSCTUNEbits.TUN5 // bit 5 #define NOT_BOR PCONbits.NOT_BOR // bit 0 #define NOT_POR PCONbits.NOT_POR // bit 1 #define NOT_RI PCONbits.NOT_RI // bit 2 #define NOT_RMCLR PCONbits.NOT_RMCLR // bit 3 #define NOT_RWDT PCONbits.NOT_RWDT // bit 4 #define STKUNF PCONbits.STKUNF // bit 6 #define STKOVF PCONbits.STKOVF // bit 7 #define TMR1IE PIE1bits.TMR1IE // bit 0 #define TMR2IE PIE1bits.TMR2IE // bit 1 #define CCP1IE PIE1bits.CCP1IE // bit 2, shadows bit in PIE1bits #define CCPIE PIE1bits.CCPIE // bit 2, shadows bit in PIE1bits #define SSP1IE PIE1bits.SSP1IE // bit 3 #define TXIE PIE1bits.TXIE // bit 4 #define RCIE PIE1bits.RCIE // bit 5 #define ADIE PIE1bits.ADIE // bit 6 #define TMR1GIE PIE1bits.TMR1GIE // bit 7 #define CCP2IE PIE2bits.CCP2IE // bit 0 #define C3IE PIE2bits.C3IE // bit 1 #define C4IE PIE2bits.C4IE // bit 2 #define BCL1IE PIE2bits.BCL1IE // bit 3 #define C1IE PIE2bits.C1IE // bit 5 #define C2IE PIE2bits.C2IE // bit 6 #define OSFIE PIE2bits.OSFIE // bit 7 #define CLC1IE PIE3bits.CLC1IE // bit 0 #define CLC2IE PIE3bits.CLC2IE // bit 1 #define CLC3IE PIE3bits.CLC3IE // bit 2 #define COG2IE PIE3bits.COG2IE // bit 3 #define ZCDIE PIE3bits.ZCDIE // bit 4 #define COGIE PIE3bits.COGIE // bit 5 #define PWM5IE PIE3bits.PWM5IE // bit 6 #define PWM6IE PIE3bits.PWM6IE // bit 7 #define TMR4IE PIE4bits.TMR4IE // bit 0 #define TMR6IE PIE4bits.TMR6IE // bit 1 #define TMR3IE PIE4bits.TMR3IE // bit 2 #define TMR3GIE PIE4bits.TMR3GIE // bit 3 #define TMR5IE PIE4bits.TMR5IE // bit 4 #define TMR5GIE PIE4bits.TMR5GIE // bit 5 #define TMR1IF PIR1bits.TMR1IF // bit 0 #define TMR2IF PIR1bits.TMR2IF // bit 1 #define CCP1IF PIR1bits.CCP1IF // bit 2, shadows bit in PIR1bits #define CCPIF PIR1bits.CCPIF // bit 2, shadows bit in PIR1bits #define SSP1IF PIR1bits.SSP1IF // bit 3 #define TXIF PIR1bits.TXIF // bit 4 #define RCIF PIR1bits.RCIF // bit 5 #define ADIF PIR1bits.ADIF // bit 6 #define TMR1GIF PIR1bits.TMR1GIF // bit 7 #define CCP2IF PIR2bits.CCP2IF // bit 0 #define C3IF PIR2bits.C3IF // bit 1 #define C4IF PIR2bits.C4IF // bit 2 #define BCL1IF PIR2bits.BCL1IF // bit 3 #define C1IF PIR2bits.C1IF // bit 5 #define C2IF PIR2bits.C2IF // bit 6 #define OSFIF PIR2bits.OSFIF // bit 7 #define CLC1IF PIR3bits.CLC1IF // bit 0 #define CLC2IF PIR3bits.CLC2IF // bit 1 #define CLC3IF PIR3bits.CLC3IF // bit 2 #define COG2IF PIR3bits.COG2IF // bit 3 #define ZCDIF PIR3bits.ZCDIF // bit 4 #define COG1IF PIR3bits.COG1IF // bit 5 #define PWM5IF PIR3bits.PWM5IF // bit 6 #define PWM6IF PIR3bits.PWM6IF // bit 7 #define TMR4IF PIR4bits.TMR4IF // bit 0 #define TMR6IF PIR4bits.TMR6IF // bit 1 #define TMR3IF PIR4bits.TMR3IF // bit 2 #define TMR3GIF PIR4bits.TMR3GIF // bit 3 #define TMR5IF PIR4bits.TMR5IF // bit 4 #define TMR5GIF PIR4bits.TMR5GIF // bit 5 #define RD PMCON1bits.RD // bit 0 #define WR PMCON1bits.WR // bit 1 #define WREN PMCON1bits.WREN // bit 2 #define WRERR PMCON1bits.WRERR // bit 3 #define FREE PMCON1bits.FREE // bit 4 #define LWLO PMCON1bits.LWLO // bit 5 #define CFGS PMCON1bits.CFGS // bit 6 #define RA0 PORTAbits.RA0 // bit 0 #define RA1 PORTAbits.RA1 // bit 1 #define RA2 PORTAbits.RA2 // bit 2 #define RA3 PORTAbits.RA3 // bit 3 #define RA4 PORTAbits.RA4 // bit 4 #define RA5 PORTAbits.RA5 // bit 5 #define RB4 PORTBbits.RB4 // bit 4 #define RB5 PORTBbits.RB5 // bit 5 #define RB6 PORTBbits.RB6 // bit 6 #define RB7 PORTBbits.RB7 // bit 7 #define RC0 PORTCbits.RC0 // bit 0 #define RC1 PORTCbits.RC1 // bit 1 #define RC2 PORTCbits.RC2 // bit 2 #define RC3 PORTCbits.RC3 // bit 3 #define RC4 PORTCbits.RC4 // bit 4 #define RC5 PORTCbits.RC5 // bit 5 #define RC6 PORTCbits.RC6 // bit 6 #define RC7 PORTCbits.RC7 // bit 7 #define PPSLOCKED PPSLOCKbits.PPSLOCKED // bit 0 #define RPOL PRG1CON1bits.RPOL // bit 0, shadows bit in PRG1CON1bits #define RG1RPOL PRG1CON1bits.RG1RPOL // bit 0, shadows bit in PRG1CON1bits #define FPOL PRG1CON1bits.FPOL // bit 1, shadows bit in PRG1CON1bits #define RG1FPOL PRG1CON1bits.RG1FPOL // bit 1, shadows bit in PRG1CON1bits #define RDY PRG1CON1bits.RDY // bit 2, shadows bit in PRG1CON1bits #define RG1RDY PRG1CON1bits.RG1RDY // bit 2, shadows bit in PRG1CON1bits #define ISET0 PRG1CON2bits.ISET0 // bit 0, shadows bit in PRG1CON2bits #define RG1ISET0 PRG1CON2bits.RG1ISET0 // bit 0, shadows bit in PRG1CON2bits #define ISET1 PRG1CON2bits.ISET1 // bit 1, shadows bit in PRG1CON2bits #define RG1ISET1 PRG1CON2bits.RG1ISET1 // bit 1, shadows bit in PRG1CON2bits #define ISET2 PRG1CON2bits.ISET2 // bit 2, shadows bit in PRG1CON2bits #define RG1ISET2 PRG1CON2bits.RG1ISET2 // bit 2, shadows bit in PRG1CON2bits #define ISET3 PRG1CON2bits.ISET3 // bit 3, shadows bit in PRG1CON2bits #define RG1ISET3 PRG1CON2bits.RG1ISET3 // bit 3, shadows bit in PRG1CON2bits #define ISET4 PRG1CON2bits.ISET4 // bit 4, shadows bit in PRG1CON2bits #define RG1ISET4 PRG1CON2bits.RG1ISET4 // bit 4, shadows bit in PRG1CON2bits #define FTSS0 PRG1FTSSbits.FTSS0 // bit 0, shadows bit in PRG1FTSSbits #define RG1FTSS0 PRG1FTSSbits.RG1FTSS0 // bit 0, shadows bit in PRG1FTSSbits #define FTSS1 PRG1FTSSbits.FTSS1 // bit 1, shadows bit in PRG1FTSSbits #define RG1FTSS1 PRG1FTSSbits.RG1FTSS1 // bit 1, shadows bit in PRG1FTSSbits #define FTSS2 PRG1FTSSbits.FTSS2 // bit 2, shadows bit in PRG1FTSSbits #define RG1FTSS2 PRG1FTSSbits.RG1FTSS2 // bit 2, shadows bit in PRG1FTSSbits #define FTSS3 PRG1FTSSbits.FTSS3 // bit 3, shadows bit in PRG1FTSSbits #define RG1FTSS3 PRG1FTSSbits.RG1FTSS3 // bit 3, shadows bit in PRG1FTSSbits #define INS0 PRG1INSbits.INS0 // bit 0, shadows bit in PRG1INSbits #define RG1INS0 PRG1INSbits.RG1INS0 // bit 0, shadows bit in PRG1INSbits #define INS1 PRG1INSbits.INS1 // bit 1, shadows bit in PRG1INSbits #define RG1INS1 PRG1INSbits.RG1INS1 // bit 1, shadows bit in PRG1INSbits #define INS2 PRG1INSbits.INS2 // bit 2, shadows bit in PRG1INSbits #define RG1INS2 PRG1INSbits.RG1INS2 // bit 2, shadows bit in PRG1INSbits #define INS3 PRG1INSbits.INS3 // bit 3, shadows bit in PRG1INSbits #define RG1INS3 PRG1INSbits.RG1INS3 // bit 3, shadows bit in PRG1INSbits #define RTSS0 PRG1RTSSbits.RTSS0 // bit 0, shadows bit in PRG1RTSSbits #define RG1RTSS0 PRG1RTSSbits.RG1RTSS0 // bit 0, shadows bit in PRG1RTSSbits #define RTSS1 PRG1RTSSbits.RTSS1 // bit 1, shadows bit in PRG1RTSSbits #define RG1RTSS1 PRG1RTSSbits.RG1RTSS1 // bit 1, shadows bit in PRG1RTSSbits #define RTSS2 PRG1RTSSbits.RTSS2 // bit 2, shadows bit in PRG1RTSSbits #define RG1RTSS2 PRG1RTSSbits.RG1RTSS2 // bit 2, shadows bit in PRG1RTSSbits #define RTSS3 PRG1RTSSbits.RTSS3 // bit 3, shadows bit in PRG1RTSSbits #define RG1RTSS3 PRG1RTSSbits.RG1RTSS3 // bit 3, shadows bit in PRG1RTSSbits #define DC2 PWM3DCHbits.DC2 // bit 0, shadows bit in PWM3DCHbits #define PWM3DC2 PWM3DCHbits.PWM3DC2 // bit 0, shadows bit in PWM3DCHbits #define PWMPW2 PWM3DCHbits.PWMPW2 // bit 0, shadows bit in PWM3DCHbits #define DC3 PWM3DCHbits.DC3 // bit 1, shadows bit in PWM3DCHbits #define PWM3DC3 PWM3DCHbits.PWM3DC3 // bit 1, shadows bit in PWM3DCHbits #define PWMPW3 PWM3DCHbits.PWMPW3 // bit 1, shadows bit in PWM3DCHbits #define DC4 PWM3DCHbits.DC4 // bit 2, shadows bit in PWM3DCHbits #define PWM3DC4 PWM3DCHbits.PWM3DC4 // bit 2, shadows bit in PWM3DCHbits #define PWMPW4 PWM3DCHbits.PWMPW4 // bit 2, shadows bit in PWM3DCHbits #define DC5 PWM3DCHbits.DC5 // bit 3, shadows bit in PWM3DCHbits #define PWM3DC5 PWM3DCHbits.PWM3DC5 // bit 3, shadows bit in PWM3DCHbits #define PWMPW5 PWM3DCHbits.PWMPW5 // bit 3, shadows bit in PWM3DCHbits #define DC6 PWM3DCHbits.DC6 // bit 4, shadows bit in PWM3DCHbits #define PWM3DC6 PWM3DCHbits.PWM3DC6 // bit 4, shadows bit in PWM3DCHbits #define PWMPW6 PWM3DCHbits.PWMPW6 // bit 4, shadows bit in PWM3DCHbits #define DC7 PWM3DCHbits.DC7 // bit 5, shadows bit in PWM3DCHbits #define PWM3DC7 PWM3DCHbits.PWM3DC7 // bit 5, shadows bit in PWM3DCHbits #define PWMPW7 PWM3DCHbits.PWMPW7 // bit 5, shadows bit in PWM3DCHbits #define DC8 PWM3DCHbits.DC8 // bit 6, shadows bit in PWM3DCHbits #define PWM3DC8 PWM3DCHbits.PWM3DC8 // bit 6, shadows bit in PWM3DCHbits #define PWMPW8 PWM3DCHbits.PWMPW8 // bit 6, shadows bit in PWM3DCHbits #define DC9 PWM3DCHbits.DC9 // bit 7, shadows bit in PWM3DCHbits #define PWM3DC9 PWM3DCHbits.PWM3DC9 // bit 7, shadows bit in PWM3DCHbits #define PWMPW9 PWM3DCHbits.PWMPW9 // bit 7, shadows bit in PWM3DCHbits #define DC0 PWM3DCLbits.DC0 // bit 6, shadows bit in PWM3DCLbits #define PWM3DC0 PWM3DCLbits.PWM3DC0 // bit 6, shadows bit in PWM3DCLbits #define PWMPW0 PWM3DCLbits.PWMPW0 // bit 6, shadows bit in PWM3DCLbits #define DC1 PWM3DCLbits.DC1 // bit 7, shadows bit in PWM3DCLbits #define PWM3DC1 PWM3DCLbits.PWM3DC1 // bit 7, shadows bit in PWM3DCLbits #define PWMPW1 PWM3DCLbits.PWMPW1 // bit 7, shadows bit in PWM3DCLbits #define PWM5DCH0 PWM5DCHbits.PWM5DCH0 // bit 0 #define PWM5DCH1 PWM5DCHbits.PWM5DCH1 // bit 1 #define PWM5DCH2 PWM5DCHbits.PWM5DCH2 // bit 2 #define PWM5DCH3 PWM5DCHbits.PWM5DCH3 // bit 3 #define PWM5DCH4 PWM5DCHbits.PWM5DCH4 // bit 4 #define PWM5DCH5 PWM5DCHbits.PWM5DCH5 // bit 5 #define PWM5DCH6 PWM5DCHbits.PWM5DCH6 // bit 6 #define PWM5DCH7 PWM5DCHbits.PWM5DCH7 // bit 7 #define PWM5DCL0 PWM5DCLbits.PWM5DCL0 // bit 0 #define PWM5DCL1 PWM5DCLbits.PWM5DCL1 // bit 1 #define PWM5DCL2 PWM5DCLbits.PWM5DCL2 // bit 2 #define PWM5DCL3 PWM5DCLbits.PWM5DCL3 // bit 3 #define PWM5DCL4 PWM5DCLbits.PWM5DCL4 // bit 4 #define PWM5DCL5 PWM5DCLbits.PWM5DCL5 // bit 5 #define PWM5DCL6 PWM5DCLbits.PWM5DCL6 // bit 6 #define PWM5DCL7 PWM5DCLbits.PWM5DCL7 // bit 7 #define PRIE PWM5INTCONbits.PRIE // bit 0, shadows bit in PWM5INTCONbits #define PWM5PRIE PWM5INTCONbits.PWM5PRIE // bit 0, shadows bit in PWM5INTCONbits #define DCIE PWM5INTCONbits.DCIE // bit 1, shadows bit in PWM5INTCONbits #define PWM5DCIE PWM5INTCONbits.PWM5DCIE // bit 1, shadows bit in PWM5INTCONbits #define PHIE PWM5INTCONbits.PHIE // bit 2, shadows bit in PWM5INTCONbits #define PWM5PHIE PWM5INTCONbits.PWM5PHIE // bit 2, shadows bit in PWM5INTCONbits #define OFIE PWM5INTCONbits.OFIE // bit 3, shadows bit in PWM5INTCONbits #define PWM5OFIE PWM5INTCONbits.PWM5OFIE // bit 3, shadows bit in PWM5INTCONbits #define PRIF PWM5INTFbits.PRIF // bit 0, shadows bit in PWM5INTFbits #define PWM5PRIF PWM5INTFbits.PWM5PRIF // bit 0, shadows bit in PWM5INTFbits #define DCIF PWM5INTFbits.DCIF // bit 1, shadows bit in PWM5INTFbits #define PWM5DCIF PWM5INTFbits.PWM5DCIF // bit 1, shadows bit in PWM5INTFbits #define PHIF PWM5INTFbits.PHIF // bit 2, shadows bit in PWM5INTFbits #define PWM5PHIF PWM5INTFbits.PWM5PHIF // bit 2, shadows bit in PWM5INTFbits #define OFIF PWM5INTFbits.OFIF // bit 3, shadows bit in PWM5INTFbits #define PWM5OFIF PWM5INTFbits.PWM5OFIF // bit 3, shadows bit in PWM5INTFbits #define PWM5LDS0 PWM5LDCONbits.PWM5LDS0 // bit 0, shadows bit in PWM5LDCONbits #define LDS0 PWM5LDCONbits.LDS0 // bit 0, shadows bit in PWM5LDCONbits #define LDT PWM5LDCONbits.LDT // bit 6, shadows bit in PWM5LDCONbits #define PWM5LDM PWM5LDCONbits.PWM5LDM // bit 6, shadows bit in PWM5LDCONbits #define LDA PWM5LDCONbits.LDA // bit 7, shadows bit in PWM5LDCONbits #define PWM5LD PWM5LDCONbits.PWM5LD // bit 7, shadows bit in PWM5LDCONbits #define PWM5OFS0 PWM5OFCONbits.PWM5OFS0 // bit 0, shadows bit in PWM5OFCONbits #define OFS0 PWM5OFCONbits.OFS0 // bit 0, shadows bit in PWM5OFCONbits #define OFO PWM5OFCONbits.OFO // bit 4, shadows bit in PWM5OFCONbits #define PWM5OFMC PWM5OFCONbits.PWM5OFMC // bit 4, shadows bit in PWM5OFCONbits #define PWM5OFM0 PWM5OFCONbits.PWM5OFM0 // bit 5, shadows bit in PWM5OFCONbits #define OFM0 PWM5OFCONbits.OFM0 // bit 5, shadows bit in PWM5OFCONbits #define PWM5OFM1 PWM5OFCONbits.PWM5OFM1 // bit 6, shadows bit in PWM5OFCONbits #define OFM1 PWM5OFCONbits.OFM1 // bit 6, shadows bit in PWM5OFCONbits #define PWM5OFH0 PWM5OFHbits.PWM5OFH0 // bit 0 #define PWM5OFH1 PWM5OFHbits.PWM5OFH1 // bit 1 #define PWM5OFH2 PWM5OFHbits.PWM5OFH2 // bit 2 #define PWM5OFH3 PWM5OFHbits.PWM5OFH3 // bit 3 #define PWM5OFH4 PWM5OFHbits.PWM5OFH4 // bit 4 #define PWM5OFH5 PWM5OFHbits.PWM5OFH5 // bit 5 #define PWM5OFH6 PWM5OFHbits.PWM5OFH6 // bit 6 #define PWM5OFH7 PWM5OFHbits.PWM5OFH7 // bit 7 #define PWM5OFL0 PWM5OFLbits.PWM5OFL0 // bit 0 #define PWM5OFL1 PWM5OFLbits.PWM5OFL1 // bit 1 #define PWM5OFL2 PWM5OFLbits.PWM5OFL2 // bit 2 #define PWM5OFL3 PWM5OFLbits.PWM5OFL3 // bit 3 #define PWM5OFL4 PWM5OFLbits.PWM5OFL4 // bit 4 #define PWM5OFL5 PWM5OFLbits.PWM5OFL5 // bit 5 #define PWM5OFL6 PWM5OFLbits.PWM5OFL6 // bit 6 #define PWM5OFL7 PWM5OFLbits.PWM5OFL7 // bit 7 #define PWM5PHH0 PWM5PHHbits.PWM5PHH0 // bit 0 #define PWM5PHH1 PWM5PHHbits.PWM5PHH1 // bit 1 #define PWM5PHH2 PWM5PHHbits.PWM5PHH2 // bit 2 #define PWM5PHH3 PWM5PHHbits.PWM5PHH3 // bit 3 #define PWM5PHH4 PWM5PHHbits.PWM5PHH4 // bit 4 #define PWM5PHH5 PWM5PHHbits.PWM5PHH5 // bit 5 #define PWM5PHH6 PWM5PHHbits.PWM5PHH6 // bit 6 #define PWM5PHH7 PWM5PHHbits.PWM5PHH7 // bit 7 #define PWM5PHL0 PWM5PHLbits.PWM5PHL0 // bit 0 #define PWM5PHL1 PWM5PHLbits.PWM5PHL1 // bit 1 #define PWM5PHL2 PWM5PHLbits.PWM5PHL2 // bit 2 #define PWM5PHL3 PWM5PHLbits.PWM5PHL3 // bit 3 #define PWM5PHL4 PWM5PHLbits.PWM5PHL4 // bit 4 #define PWM5PHL5 PWM5PHLbits.PWM5PHL5 // bit 5 #define PWM5PHL6 PWM5PHLbits.PWM5PHL6 // bit 6 #define PWM5PHL7 PWM5PHLbits.PWM5PHL7 // bit 7 #define PWM5PRH0 PWM5PRHbits.PWM5PRH0 // bit 0 #define PWM5PRH1 PWM5PRHbits.PWM5PRH1 // bit 1 #define PWM5PRH2 PWM5PRHbits.PWM5PRH2 // bit 2 #define PWM5PRH3 PWM5PRHbits.PWM5PRH3 // bit 3 #define PWM5PRH4 PWM5PRHbits.PWM5PRH4 // bit 4 #define PWM5PRH5 PWM5PRHbits.PWM5PRH5 // bit 5 #define PWM5PRH6 PWM5PRHbits.PWM5PRH6 // bit 6 #define PWM5PRH7 PWM5PRHbits.PWM5PRH7 // bit 7 #define PWM5PRL0 PWM5PRLbits.PWM5PRL0 // bit 0 #define PWM5PRL1 PWM5PRLbits.PWM5PRL1 // bit 1 #define PWM5PRL2 PWM5PRLbits.PWM5PRL2 // bit 2 #define PWM5PRL3 PWM5PRLbits.PWM5PRL3 // bit 3 #define PWM5PRL4 PWM5PRLbits.PWM5PRL4 // bit 4 #define PWM5PRL5 PWM5PRLbits.PWM5PRL5 // bit 5 #define PWM5PRL6 PWM5PRLbits.PWM5PRL6 // bit 6 #define PWM5PRL7 PWM5PRLbits.PWM5PRL7 // bit 7 #define PWM5TMRH0 PWM5TMRHbits.PWM5TMRH0 // bit 0 #define PWM5TMRH1 PWM5TMRHbits.PWM5TMRH1 // bit 1 #define PWM5TMRH2 PWM5TMRHbits.PWM5TMRH2 // bit 2 #define PWM5TMRH3 PWM5TMRHbits.PWM5TMRH3 // bit 3 #define PWM5TMRH4 PWM5TMRHbits.PWM5TMRH4 // bit 4 #define PWM5TMRH5 PWM5TMRHbits.PWM5TMRH5 // bit 5 #define PWM5TMRH6 PWM5TMRHbits.PWM5TMRH6 // bit 6 #define PWM5TMRH7 PWM5TMRHbits.PWM5TMRH7 // bit 7 #define PWM5TMRL0 PWM5TMRLbits.PWM5TMRL0 // bit 0 #define PWM5TMRL1 PWM5TMRLbits.PWM5TMRL1 // bit 1 #define PWM5TMRL2 PWM5TMRLbits.PWM5TMRL2 // bit 2 #define PWM5TMRL3 PWM5TMRLbits.PWM5TMRL3 // bit 3 #define PWM5TMRL4 PWM5TMRLbits.PWM5TMRL4 // bit 4 #define PWM5TMRL5 PWM5TMRLbits.PWM5TMRL5 // bit 5 #define PWM5TMRL6 PWM5TMRLbits.PWM5TMRL6 // bit 6 #define PWM5TMRL7 PWM5TMRLbits.PWM5TMRL7 // bit 7 #define PWM6DCH0 PWM6DCHbits.PWM6DCH0 // bit 0 #define PWM6DCH1 PWM6DCHbits.PWM6DCH1 // bit 1 #define PWM6DCH2 PWM6DCHbits.PWM6DCH2 // bit 2 #define PWM6DCH3 PWM6DCHbits.PWM6DCH3 // bit 3 #define PWM6DCH4 PWM6DCHbits.PWM6DCH4 // bit 4 #define PWM6DCH5 PWM6DCHbits.PWM6DCH5 // bit 5 #define PWM6DCH6 PWM6DCHbits.PWM6DCH6 // bit 6 #define PWM6DCH7 PWM6DCHbits.PWM6DCH7 // bit 7 #define PWM6DCL0 PWM6DCLbits.PWM6DCL0 // bit 0 #define PWM6DCL1 PWM6DCLbits.PWM6DCL1 // bit 1 #define PWM6DCL2 PWM6DCLbits.PWM6DCL2 // bit 2 #define PWM6DCL3 PWM6DCLbits.PWM6DCL3 // bit 3 #define PWM6DCL4 PWM6DCLbits.PWM6DCL4 // bit 4 #define PWM6DCL5 PWM6DCLbits.PWM6DCL5 // bit 5 #define PWM6DCL6 PWM6DCLbits.PWM6DCL6 // bit 6 #define PWM6DCL7 PWM6DCLbits.PWM6DCL7 // bit 7 #define PWM6OFH0 PWM6OFHbits.PWM6OFH0 // bit 0 #define PWM6OFH1 PWM6OFHbits.PWM6OFH1 // bit 1 #define PWM6OFH2 PWM6OFHbits.PWM6OFH2 // bit 2 #define PWM6OFH3 PWM6OFHbits.PWM6OFH3 // bit 3 #define PWM6OFH4 PWM6OFHbits.PWM6OFH4 // bit 4 #define PWM6OFH5 PWM6OFHbits.PWM6OFH5 // bit 5 #define PWM6OFH6 PWM6OFHbits.PWM6OFH6 // bit 6 #define PWM6OFH7 PWM6OFHbits.PWM6OFH7 // bit 7 #define PWM6OFL0 PWM6OFLbits.PWM6OFL0 // bit 0 #define PWM6OFL1 PWM6OFLbits.PWM6OFL1 // bit 1 #define PWM6OFL2 PWM6OFLbits.PWM6OFL2 // bit 2 #define PWM6OFL3 PWM6OFLbits.PWM6OFL3 // bit 3 #define PWM6OFL4 PWM6OFLbits.PWM6OFL4 // bit 4 #define PWM6OFL5 PWM6OFLbits.PWM6OFL5 // bit 5 #define PWM6OFL6 PWM6OFLbits.PWM6OFL6 // bit 6 #define PWM6OFL7 PWM6OFLbits.PWM6OFL7 // bit 7 #define PWM6PHH0 PWM6PHHbits.PWM6PHH0 // bit 0 #define PWM6PHH1 PWM6PHHbits.PWM6PHH1 // bit 1 #define PWM6PHH2 PWM6PHHbits.PWM6PHH2 // bit 2 #define PWM6PHH3 PWM6PHHbits.PWM6PHH3 // bit 3 #define PWM6PHH4 PWM6PHHbits.PWM6PHH4 // bit 4 #define PWM6PHH5 PWM6PHHbits.PWM6PHH5 // bit 5 #define PWM6PHH6 PWM6PHHbits.PWM6PHH6 // bit 6 #define PWM6PHH7 PWM6PHHbits.PWM6PHH7 // bit 7 #define PWM6PHL0 PWM6PHLbits.PWM6PHL0 // bit 0 #define PWM6PHL1 PWM6PHLbits.PWM6PHL1 // bit 1 #define PWM6PHL2 PWM6PHLbits.PWM6PHL2 // bit 2 #define PWM6PHL3 PWM6PHLbits.PWM6PHL3 // bit 3 #define PWM6PHL4 PWM6PHLbits.PWM6PHL4 // bit 4 #define PWM6PHL5 PWM6PHLbits.PWM6PHL5 // bit 5 #define PWM6PHL6 PWM6PHLbits.PWM6PHL6 // bit 6 #define PWM6PHL7 PWM6PHLbits.PWM6PHL7 // bit 7 #define PWM6PRH0 PWM6PRHbits.PWM6PRH0 // bit 0 #define PWM6PRH1 PWM6PRHbits.PWM6PRH1 // bit 1 #define PWM6PRH2 PWM6PRHbits.PWM6PRH2 // bit 2 #define PWM6PRH3 PWM6PRHbits.PWM6PRH3 // bit 3 #define PWM6PRH4 PWM6PRHbits.PWM6PRH4 // bit 4 #define PWM6PRH5 PWM6PRHbits.PWM6PRH5 // bit 5 #define PWM6PRH6 PWM6PRHbits.PWM6PRH6 // bit 6 #define PWM6PRH7 PWM6PRHbits.PWM6PRH7 // bit 7 #define PWM6PRL0 PWM6PRLbits.PWM6PRL0 // bit 0 #define PWM6PRL1 PWM6PRLbits.PWM6PRL1 // bit 1 #define PWM6PRL2 PWM6PRLbits.PWM6PRL2 // bit 2 #define PWM6PRL3 PWM6PRLbits.PWM6PRL3 // bit 3 #define PWM6PRL4 PWM6PRLbits.PWM6PRL4 // bit 4 #define PWM6PRL5 PWM6PRLbits.PWM6PRL5 // bit 5 #define PWM6PRL6 PWM6PRLbits.PWM6PRL6 // bit 6 #define PWM6PRL7 PWM6PRLbits.PWM6PRL7 // bit 7 #define PWM6TMRH0 PWM6TMRHbits.PWM6TMRH0 // bit 0 #define PWM6TMRH1 PWM6TMRHbits.PWM6TMRH1 // bit 1 #define PWM6TMRH2 PWM6TMRHbits.PWM6TMRH2 // bit 2 #define PWM6TMRH3 PWM6TMRHbits.PWM6TMRH3 // bit 3 #define PWM6TMRH4 PWM6TMRHbits.PWM6TMRH4 // bit 4 #define PWM6TMRH5 PWM6TMRHbits.PWM6TMRH5 // bit 5 #define PWM6TMRH6 PWM6TMRHbits.PWM6TMRH6 // bit 6 #define PWM6TMRH7 PWM6TMRHbits.PWM6TMRH7 // bit 7 #define PWM6TMRL0 PWM6TMRLbits.PWM6TMRL0 // bit 0 #define PWM6TMRL1 PWM6TMRLbits.PWM6TMRL1 // bit 1 #define PWM6TMRL2 PWM6TMRLbits.PWM6TMRL2 // bit 2 #define PWM6TMRL3 PWM6TMRLbits.PWM6TMRL3 // bit 3 #define PWM6TMRL4 PWM6TMRLbits.PWM6TMRL4 // bit 4 #define PWM6TMRL5 PWM6TMRLbits.PWM6TMRL5 // bit 5 #define PWM6TMRL6 PWM6TMRLbits.PWM6TMRL6 // bit 6 #define PWM6TMRL7 PWM6TMRLbits.PWM6TMRL7 // bit 7 #define MPWM5EN PWMENbits.MPWM5EN // bit 4 #define MPWM6EN PWMENbits.MPWM6EN // bit 5 #define MPWM5LD PWMLDbits.MPWM5LD // bit 4 #define MPWM6LD PWMLDbits.MPWM6LD // bit 5 #define MPWM5OUT PWMOUTbits.MPWM5OUT // bit 4 #define MPWM6OUT PWMOUTbits.MPWM6OUT // bit 5 #define RX9D RC1STAbits.RX9D // bit 0 #define OERR RC1STAbits.OERR // bit 1 #define FERR RC1STAbits.FERR // bit 2 #define ADDEN RC1STAbits.ADDEN // bit 3 #define CREN RC1STAbits.CREN // bit 4 #define SREN RC1STAbits.SREN // bit 5 #define RX9 RC1STAbits.RX9 // bit 6 #define SPEN RC1STAbits.SPEN // bit 7 #define SLRA0 SLRCONAbits.SLRA0 // bit 0 #define SLRA1 SLRCONAbits.SLRA1 // bit 1 #define SLRA2 SLRCONAbits.SLRA2 // bit 2 #define SLRA4 SLRCONAbits.SLRA4 // bit 4 #define SLRA5 SLRCONAbits.SLRA5 // bit 5 #define SLRB4 SLRCONBbits.SLRB4 // bit 4 #define SLRB5 SLRCONBbits.SLRB5 // bit 5 #define SLRB6 SLRCONBbits.SLRB6 // bit 6 #define SLRB7 SLRCONBbits.SLRB7 // bit 7 #define SLRC0 SLRCONCbits.SLRC0 // bit 0 #define SLRC1 SLRCONCbits.SLRC1 // bit 1 #define SLRC2 SLRCONCbits.SLRC2 // bit 2 #define SLRC3 SLRCONCbits.SLRC3 // bit 3 #define SLRC4 SLRCONCbits.SLRC4 // bit 4 #define SLRC5 SLRCONCbits.SLRC5 // bit 5 #define SLRC6 SLRCONCbits.SLRC6 // bit 6 #define SLRC7 SLRCONCbits.SLRC7 // bit 7 #define SSP1ADD0 SSP1ADDbits.SSP1ADD0 // bit 0, shadows bit in SSP1ADDbits #define ADD0 SSP1ADDbits.ADD0 // bit 0, shadows bit in SSP1ADDbits #define SSP1ADD1 SSP1ADDbits.SSP1ADD1 // bit 1, shadows bit in SSP1ADDbits #define ADD1 SSP1ADDbits.ADD1 // bit 1, shadows bit in SSP1ADDbits #define SSP1ADD2 SSP1ADDbits.SSP1ADD2 // bit 2, shadows bit in SSP1ADDbits #define ADD2 SSP1ADDbits.ADD2 // bit 2, shadows bit in SSP1ADDbits #define SSP1ADD3 SSP1ADDbits.SSP1ADD3 // bit 3, shadows bit in SSP1ADDbits #define ADD3 SSP1ADDbits.ADD3 // bit 3, shadows bit in SSP1ADDbits #define SSP1ADD4 SSP1ADDbits.SSP1ADD4 // bit 4, shadows bit in SSP1ADDbits #define ADD4 SSP1ADDbits.ADD4 // bit 4, shadows bit in SSP1ADDbits #define SSP1ADD5 SSP1ADDbits.SSP1ADD5 // bit 5, shadows bit in SSP1ADDbits #define ADD5 SSP1ADDbits.ADD5 // bit 5, shadows bit in SSP1ADDbits #define SSP1ADD6 SSP1ADDbits.SSP1ADD6 // bit 6, shadows bit in SSP1ADDbits #define ADD6 SSP1ADDbits.ADD6 // bit 6, shadows bit in SSP1ADDbits #define SSP1ADD7 SSP1ADDbits.SSP1ADD7 // bit 7, shadows bit in SSP1ADDbits #define ADD7 SSP1ADDbits.ADD7 // bit 7, shadows bit in SSP1ADDbits #define SSP1BUF0 SSP1BUFbits.SSP1BUF0 // bit 0, shadows bit in SSP1BUFbits #define BUF0 SSP1BUFbits.BUF0 // bit 0, shadows bit in SSP1BUFbits #define SSP1BUF1 SSP1BUFbits.SSP1BUF1 // bit 1, shadows bit in SSP1BUFbits #define BUF1 SSP1BUFbits.BUF1 // bit 1, shadows bit in SSP1BUFbits #define SSP1BUF2 SSP1BUFbits.SSP1BUF2 // bit 2, shadows bit in SSP1BUFbits #define BUF2 SSP1BUFbits.BUF2 // bit 2, shadows bit in SSP1BUFbits #define SSP1BUF3 SSP1BUFbits.SSP1BUF3 // bit 3, shadows bit in SSP1BUFbits #define BUF3 SSP1BUFbits.BUF3 // bit 3, shadows bit in SSP1BUFbits #define SSP1BUF4 SSP1BUFbits.SSP1BUF4 // bit 4, shadows bit in SSP1BUFbits #define BUF4 SSP1BUFbits.BUF4 // bit 4, shadows bit in SSP1BUFbits #define SSP1BUF5 SSP1BUFbits.SSP1BUF5 // bit 5, shadows bit in SSP1BUFbits #define BUF5 SSP1BUFbits.BUF5 // bit 5, shadows bit in SSP1BUFbits #define SSP1BUF6 SSP1BUFbits.SSP1BUF6 // bit 6, shadows bit in SSP1BUFbits #define BUF6 SSP1BUFbits.BUF6 // bit 6, shadows bit in SSP1BUFbits #define SSP1BUF7 SSP1BUFbits.SSP1BUF7 // bit 7, shadows bit in SSP1BUFbits #define BUF7 SSP1BUFbits.BUF7 // bit 7, shadows bit in SSP1BUFbits #define SSPM0 SSP1CONbits.SSPM0 // bit 0 #define SSPM1 SSP1CONbits.SSPM1 // bit 1 #define SSPM2 SSP1CONbits.SSPM2 // bit 2 #define SSPM3 SSP1CONbits.SSPM3 // bit 3 #define CKP SSP1CONbits.CKP // bit 4 #define SSPEN SSP1CONbits.SSPEN // bit 5 #define SSPOV SSP1CONbits.SSPOV // bit 6 #define WCOL SSP1CONbits.WCOL // bit 7 #define SEN SSP1CON2bits.SEN // bit 0 #define RSEN SSP1CON2bits.RSEN // bit 1 #define PEN SSP1CON2bits.PEN // bit 2 #define RCEN SSP1CON2bits.RCEN // bit 3 #define ACKEN SSP1CON2bits.ACKEN // bit 4 #define ACKDT SSP1CON2bits.ACKDT // bit 5 #define ACKSTAT SSP1CON2bits.ACKSTAT // bit 6 #define GCEN SSP1CON2bits.GCEN // bit 7 #define DHEN SSP1CON3bits.DHEN // bit 0 #define AHEN SSP1CON3bits.AHEN // bit 1 #define SBCDE SSP1CON3bits.SBCDE // bit 2 #define SDAHT SSP1CON3bits.SDAHT // bit 3 #define BOEN SSP1CON3bits.BOEN // bit 4 #define SCIE SSP1CON3bits.SCIE // bit 5 #define PCIE SSP1CON3bits.PCIE // bit 6 #define ACKTIM SSP1CON3bits.ACKTIM // bit 7 #define SSP1MSK0 SSP1MSKbits.SSP1MSK0 // bit 0, shadows bit in SSP1MSKbits #define MSK0 SSP1MSKbits.MSK0 // bit 0, shadows bit in SSP1MSKbits #define SSP1MSK1 SSP1MSKbits.SSP1MSK1 // bit 1, shadows bit in SSP1MSKbits #define MSK1 SSP1MSKbits.MSK1 // bit 1, shadows bit in SSP1MSKbits #define SSP1MSK2 SSP1MSKbits.SSP1MSK2 // bit 2, shadows bit in SSP1MSKbits #define MSK2 SSP1MSKbits.MSK2 // bit 2, shadows bit in SSP1MSKbits #define SSP1MSK3 SSP1MSKbits.SSP1MSK3 // bit 3, shadows bit in SSP1MSKbits #define MSK3 SSP1MSKbits.MSK3 // bit 3, shadows bit in SSP1MSKbits #define SSP1MSK4 SSP1MSKbits.SSP1MSK4 // bit 4, shadows bit in SSP1MSKbits #define MSK4 SSP1MSKbits.MSK4 // bit 4, shadows bit in SSP1MSKbits #define SSP1MSK5 SSP1MSKbits.SSP1MSK5 // bit 5, shadows bit in SSP1MSKbits #define MSK5 SSP1MSKbits.MSK5 // bit 5, shadows bit in SSP1MSKbits #define SSP1MSK6 SSP1MSKbits.SSP1MSK6 // bit 6, shadows bit in SSP1MSKbits #define MSK6 SSP1MSKbits.MSK6 // bit 6, shadows bit in SSP1MSKbits #define SSP1MSK7 SSP1MSKbits.SSP1MSK7 // bit 7, shadows bit in SSP1MSKbits #define MSK7 SSP1MSKbits.MSK7 // bit 7, shadows bit in SSP1MSKbits #define BF SSP1STATbits.BF // bit 0 #define UA SSP1STATbits.UA // bit 1 #define R_NOT_W SSP1STATbits.R_NOT_W // bit 2 #define S SSP1STATbits.S // bit 3 #define P SSP1STATbits.P // bit 4 #define D_NOT_A SSP1STATbits.D_NOT_A // bit 5 #define CKE SSP1STATbits.CKE // bit 6 #define SMP SSP1STATbits.SMP // bit 7 #define C STATUSbits.C // bit 0 #define DC STATUSbits.DC // bit 1 #define Z STATUSbits.Z // bit 2 #define NOT_PD STATUSbits.NOT_PD // bit 3 #define NOT_TO STATUSbits.NOT_TO // bit 4 #define C_SHAD STATUS_SHADbits.C_SHAD // bit 0 #define DC_SHAD STATUS_SHADbits.DC_SHAD // bit 1 #define Z_SHAD STATUS_SHADbits.Z_SHAD // bit 2 #define GSS0 T1GCONbits.GSS0 // bit 0, shadows bit in T1GCONbits #define T1GSS0 T1GCONbits.T1GSS0 // bit 0, shadows bit in T1GCONbits #define GSS1 T1GCONbits.GSS1 // bit 1, shadows bit in T1GCONbits #define T1GSS1 T1GCONbits.T1GSS1 // bit 1, shadows bit in T1GCONbits #define GVAL T1GCONbits.GVAL // bit 2, shadows bit in T1GCONbits #define T1GVAL T1GCONbits.T1GVAL // bit 2, shadows bit in T1GCONbits #define GGO_NOT_DONE T1GCONbits.GGO_NOT_DONE // bit 3, shadows bit in T1GCONbits #define T1GGO_NOT_DONE T1GCONbits.T1GGO_NOT_DONE // bit 3, shadows bit in T1GCONbits #define GSPM T1GCONbits.GSPM // bit 4, shadows bit in T1GCONbits #define T1GSPM T1GCONbits.T1GSPM // bit 4, shadows bit in T1GCONbits #define GTM T1GCONbits.GTM // bit 5, shadows bit in T1GCONbits #define T1GTM T1GCONbits.T1GTM // bit 5, shadows bit in T1GCONbits #define GPOL T1GCONbits.GPOL // bit 6, shadows bit in T1GCONbits #define T1GPOL T1GCONbits.T1GPOL // bit 6, shadows bit in T1GCONbits #define GE T1GCONbits.GE // bit 7, shadows bit in T1GCONbits #define T1GE T1GCONbits.T1GE // bit 7, shadows bit in T1GCONbits #define TMR1GE T1GCONbits.TMR1GE // bit 7, shadows bit in T1GCONbits #define RSEL0 T2RSTbits.RSEL0 // bit 0, shadows bit in T2RSTbits #define T2RSEL0 T2RSTbits.T2RSEL0 // bit 0, shadows bit in T2RSTbits #define RSEL1 T2RSTbits.RSEL1 // bit 1, shadows bit in T2RSTbits #define T2RSEL1 T2RSTbits.T2RSEL1 // bit 1, shadows bit in T2RSTbits #define RSEL2 T2RSTbits.RSEL2 // bit 2, shadows bit in T2RSTbits #define T2RSEL2 T2RSTbits.T2RSEL2 // bit 2, shadows bit in T2RSTbits #define RSEL3 T2RSTbits.RSEL3 // bit 3, shadows bit in T2RSTbits #define T2RSEL3 T2RSTbits.T2RSEL3 // bit 3, shadows bit in T2RSTbits #define TRISA0 TRISAbits.TRISA0 // bit 0 #define TRISA1 TRISAbits.TRISA1 // bit 1 #define TRISA2 TRISAbits.TRISA2 // bit 2 #define TRISA4 TRISAbits.TRISA4 // bit 4 #define TRISA5 TRISAbits.TRISA5 // bit 5 #define TRISB4 TRISBbits.TRISB4 // bit 4 #define TRISB5 TRISBbits.TRISB5 // bit 5 #define TRISB6 TRISBbits.TRISB6 // bit 6 #define TRISB7 TRISBbits.TRISB7 // bit 7 #define TRISC0 TRISCbits.TRISC0 // bit 0 #define TRISC1 TRISCbits.TRISC1 // bit 1 #define TRISC2 TRISCbits.TRISC2 // bit 2 #define TRISC3 TRISCbits.TRISC3 // bit 3 #define TRISC4 TRISCbits.TRISC4 // bit 4 #define TRISC5 TRISCbits.TRISC5 // bit 5 #define TRISC6 TRISCbits.TRISC6 // bit 6 #define TRISC7 TRISCbits.TRISC7 // bit 7 #define SWDTEN WDTCONbits.SWDTEN // bit 0 #define WDTPS0 WDTCONbits.WDTPS0 // bit 1 #define WDTPS1 WDTCONbits.WDTPS1 // bit 2 #define WDTPS2 WDTCONbits.WDTPS2 // bit 3 #define WDTPS3 WDTCONbits.WDTPS3 // bit 4 #define WDTPS4 WDTCONbits.WDTPS4 // bit 5 #define WPUA0 WPUAbits.WPUA0 // bit 0 #define WPUA1 WPUAbits.WPUA1 // bit 1 #define WPUA2 WPUAbits.WPUA2 // bit 2 #define WPUA3 WPUAbits.WPUA3 // bit 3 #define WPUA4 WPUAbits.WPUA4 // bit 4 #define WPUA5 WPUAbits.WPUA5 // bit 5 #define WPUB4 WPUBbits.WPUB4 // bit 4 #define WPUB5 WPUBbits.WPUB5 // bit 5 #define WPUB6 WPUBbits.WPUB6 // bit 6 #define WPUB7 WPUBbits.WPUB7 // bit 7 #define WPUC0 WPUCbits.WPUC0 // bit 0 #define WPUC1 WPUCbits.WPUC1 // bit 1 #define WPUC2 WPUCbits.WPUC2 // bit 2 #define WPUC3 WPUCbits.WPUC3 // bit 3 #define WPUC4 WPUCbits.WPUC4 // bit 4 #define WPUC5 WPUCbits.WPUC5 // bit 5 #define WPUC6 WPUCbits.WPUC6 // bit 6 #define WPUC7 WPUCbits.WPUC7 // bit 7 #define ZCD1INTN ZCD1CONbits.ZCD1INTN // bit 0 #define ZCD1INTP ZCD1CONbits.ZCD1INTP // bit 1 #define ZCD1POL ZCD1CONbits.ZCD1POL // bit 4 #define ZCD1OUT ZCD1CONbits.ZCD1OUT // bit 5 #define ZCD1EN ZCD1CONbits.ZCD1EN // bit 7 #endif // #ifndef NO_BIT_DEFINES #endif // #ifndef __PIC16F1768_H__
dfreniche/cpctelera
cpctelera/tools/sdcc-3.6.8-r9946/src/device/non-free/include/pic14/pic16f1768.h
C
gpl-3.0
529,914
/************************************************************************** * Otter Browser: Web browser controlled by the user, not vice-versa. * Copyright (C) 2013 - 2017 Michal Dutkiewicz aka Emdek <michal@emdek.pl> * * 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 "NetworkCache.h" #include "SessionsManager.h" #include "SettingsManager.h" #include <QtCore/QDateTime> #include <QtCore/QDir> namespace Otter { NetworkCache::NetworkCache(QObject *parent) : QNetworkDiskCache(parent) { const QString cachePath(SessionsManager::getCachePath()); if (!cachePath.isEmpty()) { QDir().mkpath(cachePath); setCacheDirectory(cachePath); setMaximumCacheSize(SettingsManager::getOption(SettingsManager::Cache_DiskCacheLimitOption).toInt() * 1024); connect(SettingsManager::getInstance(), SIGNAL(optionChanged(int,QVariant)), this, SLOT(handleOptionChanged(int,QVariant))); } } void NetworkCache::handleOptionChanged(int identifier, const QVariant &value) { if (identifier == SettingsManager::Cache_DiskCacheLimitOption) { setMaximumCacheSize(value.toInt() * 1024); } } void NetworkCache::clearCache(int period) { if (period <= 0) { clear(); emit cleared(); return; } const QDir cacheMainDirectory(cacheDirectory()); const QStringList directories(cacheMainDirectory.entryList(QDir::AllDirs | QDir::NoDotAndDotDot)); for (int i = 0; i < directories.count(); ++i) { const QDir cacheSubDirectory(cacheMainDirectory.absoluteFilePath(directories.at(i))); const QStringList subDirectories(cacheSubDirectory.entryList(QDir::AllDirs | QDir::NoDotAndDotDot)); for (int j = 0; j < subDirectories.count(); ++j) { const QFileInfoList files(QDir(cacheSubDirectory.absoluteFilePath(subDirectories.at(j))).entryInfoList(QDir::Files)); for (int k = 0; k < files.count(); ++k) { if (files.at(k).lastModified().secsTo(QDateTime::currentDateTime()) < (period * 3600)) { const QNetworkCacheMetaData metaData(fileMetaData(files.at(k).absoluteFilePath())); if (metaData.isValid()) { remove(metaData.url()); } } } } } } void NetworkCache::insert(QIODevice *device) { QNetworkDiskCache::insert(device); if (m_devices.contains(device)) { emit entryAdded(m_devices[device]); m_devices.remove(device); } } QIODevice* NetworkCache::prepare(const QNetworkCacheMetaData &metaData) { QIODevice *device(QNetworkDiskCache::prepare(metaData)); if (device) { m_devices[device] = metaData.url(); } return device; } QString NetworkCache::getPathForUrl(const QUrl &url) { if (!url.isValid() || !metaData(url).isValid()) { return QString(); } const QDir cacheMainDirectory(cacheDirectory()); const QStringList directories(cacheMainDirectory.entryList(QDir::AllDirs | QDir::NoDotAndDotDot)); for (int i = 0; i < directories.count(); ++i) { const QDir cacheSubDirectory(cacheMainDirectory.absoluteFilePath(directories.at(i))); const QStringList subDirectories(cacheSubDirectory.entryList(QDir::AllDirs | QDir::NoDotAndDotDot)); for (int j = 0; j < subDirectories.count(); ++j) { const QDir cacheFilesDirectory(cacheSubDirectory.absoluteFilePath(subDirectories.at(j))); const QStringList files(cacheFilesDirectory.entryList(QDir::Files)); for (int k = 0; k < files.count(); ++k) { const QString cacheFilePath(cacheFilesDirectory.absoluteFilePath(files.at(k))); const QNetworkCacheMetaData metaData(fileMetaData(cacheFilePath)); if (metaData.isValid() && url == metaData.url()) { return cacheFilePath; } } } } return QString(); } QVector<QUrl> NetworkCache::getEntries() const { QVector<QUrl> entries; const QDir cacheMainDirectory(cacheDirectory()); const QStringList directories(cacheMainDirectory.entryList(QDir::AllDirs | QDir::NoDotAndDotDot)); for (int i = 0; i < directories.count(); ++i) { const QDir cacheSubDirectory(cacheMainDirectory.absoluteFilePath(directories.at(i))); const QStringList subDirectories(cacheSubDirectory.entryList(QDir::AllDirs | QDir::NoDotAndDotDot)); for (int j = 0; j < subDirectories.count(); ++j) { const QDir cacheFilesDirectory(cacheSubDirectory.absoluteFilePath(subDirectories.at(j))); const QStringList files(cacheFilesDirectory.entryList(QDir::Files)); for (int k = 0; k < files.count(); ++k) { const QNetworkCacheMetaData metaData(fileMetaData(cacheFilesDirectory.absoluteFilePath(files.at(k)))); if (metaData.url().isValid()) { entries.append(metaData.url()); } } } } return entries; } bool NetworkCache::remove(const QUrl &url) { const bool result(QNetworkDiskCache::remove(url)); if (result) { emit entryRemoved(url); } return result; } }
pierreporte/otter-browser
src/core/NetworkCache.cpp
C++
gpl-3.0
5,368
<?php /* * This file is part of Totara LMS * * Copyright (C) 2010 onwards Totara Learning Solutions LTD * * 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/>. * * @author Simon Coggins <simon.coggins@totaralms.com> * @package totara * @subpackage totara_hierarchy */ require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/config.php'); require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->dirroot.'/totara/hierarchy/prefix/competency/template/edit_form.php'); /// /// Setup / loading data /// // Template id; 0 if creating new template $id = optional_param('id', 0, PARAM_INT); // framework id; required when creating a new template $frameworkid = optional_param('frameworkid', 0, PARAM_INT); // We require either an id for editing, or a framework for creating if (!$id && !$frameworkid) { print_error('incorrectparameters', 'totara_hierarchy'); } // Make this page appear under the manage templates admin item admin_externalpage_setup('competencymanage', '', array(), '/totara/hierarchy/prefix/competency/template/edit.php'); $context = context_system::instance(); if ($id == 0) { // Creating new competency template require_capability('totara/hierarchy:createcompetencytemplate', $context); $template = new stdClass(); $template->id = 0; $template->description = ''; $template->visible = 1; $template->frameworkid = $frameworkid; } else { // Editing existing competency template require_capability('totara/hierarchy:updatecompetencytemplate', $context); if (!$template = $DB->get_record('comp_template', array('id' => $id))) { print_error('incorrectcompetencytemplateid', 'totara_hierarchy'); } } // Load framework if (!$framework = $DB->get_record('comp_framework', array('id' => $template->frameworkid))) { print_error('incorrectcompetencyframeworkid', 'totara_hierarchy'); } // create form $template->descriptionformat = FORMAT_HTML; $template = file_prepare_standard_editor($template, 'description', $TEXTAREA_OPTIONS, $TEXTAREA_OPTIONS['context'], 'totara_hierarchy', 'comp_template', $template->id); $form = new competencytemplate_edit_form(null, array()); $form->set_data($template); // cancelled if ($form->is_cancelled()) { redirect("$CFG->wwwroot/totara/hierarchy/framework/view.php?prefix=competency&frameworkid=".$framework->id); // Update data } else if ($templatenew = $form->get_data()) { $time = time(); $templatenew->timemodified = $time; $templatenew->usermodified = $USER->id; // Save // New template if ($templatenew->id == 0) { unset($templatenew->id); $templatenew->timecreated = $time; $templatenew->competencycount = 0; if (!$templatenew->id = $DB->insert_record('comp_template', $templatenew)) { print_error('createcompetencytemplaterecord', 'totara_hierarchy'); } // Existing template } else { if (!$DB->update_record('comp_template', $templatenew)) { print_error('updatecompetencytemplaterecord', 'totara_hierarchy'); } } // Log add_to_log(SITEID, 'competency', 'template update', "hierarchy/prefix/competency/template/view.php?id={$templatenew->id}", ''); //fix the description field and redirect $templatenew = file_postupdate_standard_editor($templatenew, 'description', $TEXTAREA_OPTIONS, $TEXTAREA_OPTIONS['context'], 'totara_hierarchy', 'comp_template', $templatenew->id); $DB->set_field('comp_template', 'description', $templatenew->description, array('id' => $templatenew->id)); redirect("$CFG->wwwroot/totara/hierarchy/framework/view.php?prefix=competency&frameworkid=".$framework->id); //never reached } /// Display page header $PAGE->navbar->add(get_string("competencyframeworks", 'totara_hierarchy'), new moodle_url('/totara/hierarchy/framework/index.php', array('prefix' => 'competency'))); $PAGE->navbar->add(format_string($framework->fullname), new moodle_url('totara/hierarchy/framework/view.php', array('prefix' => 'competency', 'frameworkid' => $framework->id))); if ($template->id == 0) { $heading = get_string('addnewtemplate', 'totara_hierarchy'); $PAGE->navbar->add($heading); } else { $heading = get_string('editgeneric', 'totara_hierarchy', format_string($template->fullname)); $PAGE->navbar->add(format_string($template->fullname)); } echo $OUTPUT->header(); echo $OUTPUT->heading($heading); /// Finally display THE form $form->display(); /// and proper footer echo $OUTPUT->footer();
totara/seedlings
totara/hierarchy/prefix/competency/template/edit.php
PHP
gpl-3.0
5,198
#pragma once #include "vfs_error.h" #include <utility> namespace vfs { template<typename ValueType> class Result { public: Result(ValueType value) : mError(Error::Success), mValue(std::move(value)) { } Result(Error error) : mError(error) { } Error error() const { return mError; } explicit operator bool() const { return mError == Error::Success; } ValueType &operator *() { return mValue; } const ValueType &operator *() const { return mValue; } ValueType *operator ->() { return &mValue; } const ValueType *operator ->() const { return &mValue; } private: Error mError; ValueType mValue; }; } // namespace vfs
decaf-emu/decaf-emu
src/libdecaf/src/vfs/vfs_result.h
C
gpl-3.0
755
.flashMessageContainer { position: fixed; z-index: var(--zIndex-FlashMessageContainer); top: 0; left: 50%; width: 512px; padding-top: 8px; transform: translate(-50%, 0); &:empty { display: none; } }
neos/neos-ui
packages/neos-ui/src/Containers/FlashMessages/style.css
CSS
gpl-3.0
244
<?php if (!defined('FROM_BASE')) { header($_SERVER['SERVER_PROTOCOL'] . ' 403'); die('Invalid requested path.'); } /* Autoload settings */ $autoload['libraries'] = array(); $autoload['extensions'] = array('pagination', 'timezone'); $autoload['models'] = array(); $autoload['modules'] = array();
ucodev/uweb
user/config/autoload.php
PHP
gpl-3.0
296
#pragma once // NOTE : The following MIT license applies to this file ONLY and not to the SDK as a whole. Please review the SDK documentation // for the description of the full license terms, which are also provided in the file "NDI License Agreement.pdf" within the SDK or // online at http://new.tk/ndisdk_license/. Your use of any part of this SDK is acknowledgment that you agree to the SDK license // terms. The full NDI SDK may be downloaded at http://ndi.tv/ // //************************************************************************************************************************************* // // Copyright(c) 2014-2020, NewTek, inc. // // 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. // //************************************************************************************************************************************* // Is this library being compiled, or imported by another application. #ifdef PROCESSINGNDILIB_STATIC # ifdef __cplusplus # define PROCESSINGNDILIB_API extern "C" # else // __cplusplus # define PROCESSINGNDILIB_API # endif // __cplusplus #else // PROCESSINGNDILIB_STATIC # ifdef _WIN32 # ifdef PROCESSINGNDILIB_EXPORTS # ifdef __cplusplus # define PROCESSINGNDILIB_API extern "C" __declspec(dllexport) # else // __cplusplus # define PROCESSINGNDILIB_API __declspec(dllexport) # endif // __cplusplus # else // PROCESSINGNDILIB_EXPORTS # ifdef __cplusplus # define PROCESSINGNDILIB_API extern "C" __declspec(dllimport) # else // __cplusplus # define PROCESSINGNDILIB_API __declspec(dllimport) # endif // __cplusplus # ifdef _WIN64 # define NDILIB_LIBRARY_NAME "Processing.NDI.Lib.x64.dll" # define NDILIB_REDIST_FOLDER "NDI_RUNTIME_DIR_V4" # define NDILIB_REDIST_URL "http://new.tk/NDIRedistV4" # else // _WIN64 # define NDILIB_LIBRARY_NAME "Processing.NDI.Lib.x86.dll" # define NDILIB_REDIST_FOLDER "NDI_RUNTIME_DIR_V4" # define NDILIB_REDIST_URL "http://new.tk/NDIRedistV4" # endif // _WIN64 # endif // PROCESSINGNDILIB_EXPORTS # else // _WIN32 # ifdef __APPLE__ # define NDILIB_LIBRARY_NAME "libndi.4.dylib" # define NDILIB_REDIST_FOLDER "NDI_RUNTIME_DIR_V4" # define NDILIB_REDIST_URL "http://new.tk/NDIRedistV4Apple" # else // __APPLE__ # define NDILIB_LIBRARY_NAME "libndi.so.4" # define NDILIB_REDIST_FOLDER "NDI_RUNTIME_DIR_V4" # define NDILIB_REDIST_URL "" # endif // __APPLE__ # ifdef __cplusplus # define PROCESSINGNDILIB_API extern "C" __attribute((visibility("default"))) # else // __cplusplus # define PROCESSINGNDILIB_API __attribute((visibility("default"))) # endif // __cplusplus # endif // _WIN32 #endif // PROCESSINGNDILIB_STATIC #ifndef PROCESSINGNDILIB_DEPRECATED # ifdef _WIN32 # ifdef _MSC_VER # define PROCESSINGNDILIB_DEPRECATED __declspec(deprecated) # else // _MSC_VER # define PROCESSINGNDILIB_DEPRECATED __attribute((deprecated)) # endif // _MSC_VER # else // _WIN32 # define PROCESSINGNDILIB_DEPRECATED # endif // _WIN32 #endif // PROCESSINGNDILIB_DEPRECATED #ifndef NDILIB_CPP_DEFAULT_CONSTRUCTORS # ifdef __cplusplus # define NDILIB_CPP_DEFAULT_CONSTRUCTORS 1 # else // __cplusplus # define NDILIB_CPP_DEFAULT_CONSTRUCTORS 0 # endif // __cplusplus #endif // NDILIB_CPP_DEFAULT_CONSTRUCTORS #ifndef NDILIB_CPP_DEFAULT_VALUE # ifdef __cplusplus # define NDILIB_CPP_DEFAULT_VALUE(a) =(a) # else // __cplusplus # define NDILIB_CPP_DEFAULT_VALUE(a) # endif // __cplusplus #endif // NDILIB_CPP_DEFAULT_VALUE // Data structures shared by multiple SDKs #include "Processing.NDI.compat.h" #include "Processing.NDI.structs.h" // This is not actually required, but will start and end the libraries which might get // you slightly better performance in some cases. In general it is more "correct" to // call these although it is not required. There is no way to call these that would have // an adverse impact on anything (even calling destroy before you've deleted all your // objects). This will return false if the CPU is not sufficiently capable to run NDILib // currently NDILib requires SSE4.2 instructions (see documentation). You can verify // a specific CPU against the library with a call to NDIlib_is_supported_CPU() PROCESSINGNDILIB_API bool NDIlib_initialize(void); PROCESSINGNDILIB_API void NDIlib_destroy(void); PROCESSINGNDILIB_API const char* NDIlib_version(void); // Recover whether the current CPU in the system is capable of running NDILib. PROCESSINGNDILIB_API bool NDIlib_is_supported_CPU(void); // The finding (discovery API) #include "Processing.NDI.Find.h" // The receiving video and audio API #include "Processing.NDI.Recv.h" // Extensions to support PTZ control, etc... #include "Processing.NDI.Recv.ex.h" // The sending video API #include "Processing.NDI.Send.h" // The routing of inputs API #include "Processing.NDI.Routing.h" // Utility functions #include "Processing.NDI.utilities.h" // Deprecated structures and functions #include "Processing.NDI.deprecated.h" // The frame synchronizer #include "Processing.NDI.FrameSync.h" // Dynamic loading used for OSS libraries #include "Processing.NDI.DynamicLoad.h" // The C++ implementations #if NDILIB_CPP_DEFAULT_CONSTRUCTORS #include "Processing.NDI.Lib.cplusplus.h" #endif // NDILIB_CPP_DEFAULT_CONSTRUCTORS
CasparCG/Server
src/modules/newtek/interop/Processing.NDI.Lib.h
C
gpl-3.0
6,443
<?php /* * ©2013 Croce Rossa Italiana */ /** * Rappresenta un ramo dell'albero GeoPolitico */ class RamoGeoPolitico extends ArrayIterator { public $array; /** * Costruisce un iteratore sul ramogeopolitico. * @param $geoinsieme GeoPolitica o array di GeoPolitica. * @param $esplorazione Opzionale. Modalita' di esplorazione. Una di ESPLORA_* * @param $estensione Opzionale. Estensione massima */ public function __construct( $geoinsieme, $esplorazione = ESPLORA_RAMI, $estensione = EST_UNITA ) { if ( !is_array($geoinsieme ) ) $geoinsieme = [$geoinsieme]; if ( $esplorazione == NON_ESPLORARE ) { $array = $geoinsieme; } else { $array = []; foreach ( $geoinsieme as $i ) { $array = array_merge($array, $i->esplora($estensione, $esplorazione)); } } $this->array = $array; parent::__construct($array); } /** * Esegue il metodo su ogni elemento dell'iteratore e ritorna il risultato */ public function __call($metodo, $argomenti = []) { $r = []; foreach ( $this->array as $i ) { $y = call_user_func_array([$i, $metodo], $argomenti); if (!is_array($y)) $y = [$y]; $r = array_merge($r, $y); } return $r; } }
CroceRossaCatania/gaia
core/class/RamoGeoPolitico.php
PHP
gpl-3.0
1,197
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc (build 1.5.0_07) on Tue Sep 11 10:29:27 EDT 2007 --> <TITLE> E-Index </TITLE> <LINK REL ="stylesheet" TYPE="text/css" HREF="../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { parent.document.title="E-Index"; } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <!-- ========= START OF TOP NAVBAR ======= --> <A NAME="navbar_top"><!-- --></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../net/jbouchard/bool/package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Use</FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../net/jbouchard/bool/package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Index</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;<A HREF="index-2.html"><B>PREV LETTER</B></A>&nbsp; &nbsp;<A HREF="index-4.html"><B>NEXT LETTER</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../index.html?index-filesindex-3.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="index-3.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <!-- ========= END OF TOP NAVBAR ========= --> <A HREF="index-1.html">A</A> <A HREF="index-2.html">B</A> <A HREF="index-3.html">E</A> <A HREF="index-4.html">G</A> <A HREF="index-5.html">I</A> <A HREF="index-6.html">M</A> <A HREF="index-7.html">N</A> <A HREF="index-8.html">O</A> <A HREF="index-9.html">P</A> <A HREF="index-10.html">R</A> <A HREF="index-11.html">S</A> <A HREF="index-12.html">T</A> <A HREF="index-13.html">U</A> <A HREF="index-14.html">V</A> <HR> <A NAME="_E_"><!-- --></A><H2> <B>E</B></H2> <DL> <DT><A HREF="../net/jbouchard/bool/BooleanExpression.html#equals(java.lang.Object)"><B>equals(Object)</B></A> - Method in class net.jbouchard.bool.<A HREF="../net/jbouchard/bool/BooleanExpression.html" title="class in net.jbouchard.bool">BooleanExpression</A> <DD>Return true if obj is a BooleanExpression of the same expression, else false <DT><A HREF="../net/jbouchard/bool/BooleanExpression.html#evaluate(java.util.Map)"><B>evaluate(Map&lt;String, Boolean&gt;)</B></A> - Method in class net.jbouchard.bool.<A HREF="../net/jbouchard/bool/BooleanExpression.html" title="class in net.jbouchard.bool">BooleanExpression</A> <DD>Evaluate this BooleanExpression for the given dictionary of variables to values and returns the truth value. <DT><A HREF="../net/jbouchard/bool/BooleanOperator.html#evaluate(boolean...)"><B>evaluate(boolean...)</B></A> - Method in class net.jbouchard.bool.<A HREF="../net/jbouchard/bool/BooleanOperator.html" title="class in net.jbouchard.bool">BooleanOperator</A> <DD>Evaluate the truth value of this operator for the given operand(s). <DT><A HREF="../net/jbouchard/bool/BooleanExpression.html#expression"><B>expression</B></A> - Variable in class net.jbouchard.bool.<A HREF="../net/jbouchard/bool/BooleanExpression.html" title="class in net.jbouchard.bool">BooleanExpression</A> <DD>The given string to be parsed into this BooleanExpression <DT><A HREF="../net/jbouchard/bool/TruthTable.html#expressionCollection"><B>expressionCollection</B></A> - Variable in class net.jbouchard.bool.<A HREF="../net/jbouchard/bool/TruthTable.html" title="class in net.jbouchard.bool">TruthTable</A> <DD>The collection of expressions for which the truth table is to be generated </DL> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <A NAME="navbar_bottom"><!-- --></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_bottom_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../net/jbouchard/bool/package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Use</FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../net/jbouchard/bool/package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Index</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;<A HREF="index-2.html"><B>PREV LETTER</B></A>&nbsp; &nbsp;<A HREF="index-4.html"><B>NEXT LETTER</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../index.html?index-filesindex-3.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="index-3.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <!-- ======== END OF BOTTOM NAVBAR ======= --> <A HREF="index-1.html">A</A> <A HREF="index-2.html">B</A> <A HREF="index-3.html">E</A> <A HREF="index-4.html">G</A> <A HREF="index-5.html">I</A> <A HREF="index-6.html">M</A> <A HREF="index-7.html">N</A> <A HREF="index-8.html">O</A> <A HREF="index-9.html">P</A> <A HREF="index-10.html">R</A> <A HREF="index-11.html">S</A> <A HREF="index-12.html">T</A> <A HREF="index-13.html">U</A> <A HREF="index-14.html">V</A> <HR> </BODY> </HTML>
AnkitaB/TruthTableSolver
doc/index-files/index-3.html
HTML
gpl-3.0
7,502
<?php /** Dump to XML format in structure <database name=""><table name=""><column name="">value * @link https://www.adminer.org/plugins/#use * @author Jakub Vrana, http://www.vrana.cz/ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other) */ class AdminerDumpXml { /** @access protected */ var $database = false; function dumpFormat() { return array('xml' => 'XML'); } function dumpTable($table, $style, $is_view = false) { if ($_POST["format"] == "xml") { return true; } } function _database() { echo "</database>\n"; } function dumpData($table, $style, $query) { if ($_POST["format"] == "xml") { if (!$this->database) { $this->database = true; echo "<database name='" . h(DB) . "'>\n"; register_shutdown_function(array($this, '_database')); } $connection = connection(); $result = $connection->query($query, 1); if ($result) { while ($row = $result->fetch_assoc()) { echo "\t<table name='" . h($table) . "'>\n"; foreach ($row as $key => $val) { echo "\t\t<column name='" . h($key) . "'" . (isset($val) ? "" : " null='null'") . ">" . h($val) . "</column>\n"; } echo "\t</table>\n"; } } return true; } } function dumpHeaders($identifier, $multi_table = false) { if ($_POST["format"] == "xml") { header("Content-Type: text/xml; charset=utf-8"); return "xml"; } } }
palibaacsi/ask
wp-content/plugins/adminer/inc/plugins/dump-xml.php
PHP
gpl-3.0
1,512
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>jtheory.com : : : jdring 2.0</title> <meta content="jtheory" name="author"> </head> <body bgcolor="#ffffff"> <table align="center" background="swirl_bg.jpg" border="0" cellpadding="0" cellspacing="0" height="597" width="696"> <tbody> <tr> <td align="center" valign="center"> <br> <table border="1" cellpadding="2" cellspacing="30" height="352" width="610"> <tbody> <tr> <td valign="top"> <table align="left" border="0" cellpadding="0" cellspacing="0" width="400"> <tbody> <tr> <td style="border: 2px dotted white; border-collapse: collapse;" align="center" bgcolor="#9999cc"><font color="#ffffff"><b>jdring 2.0</b></font><br> </td> </tr> <tr> <td align="left" valign="top">JDRing is a lightweight Java scheduling library that is simple and small, but still supports ringing alarms at specified intervals, as one-time events, or on complex schedules with full cron-like control.&nbsp; See below for a full list of features.<br> </td> </tr> </tbody> </table> </td> </tr> <tr> <td valign="top"> <table align="right" border="0" cellpadding="0" cellspacing="0" width="400"> <tbody> <tr> <td style="border: 2px dotted white; border-collapse: collapse;" align="center" bgcolor="#9999cc"><font color="#ffffff"><b>why?</b></font><br> </td> </tr> <tr> <td align="left" valign="top">JDRing was originally written by Oliver Dedieu (other contributors: David Sims, Simon B&eacute;cot, and Jim Lerner), and released under the LGPL license.&nbsp; I needed a simple scheduling library, so I fixed some bugs in it and added a lot of features that I wanted (including rewriting the scheduling code to support full cron flexibility).&nbsp; I've tried to send my changes back to Oliver, but he didn't respond, and the project homepage has disappeared (I think Oliver has moved on to bigger and better things), so I'm hosting my version here.&nbsp; There are many other scheduling tools available that you can use in your Java projects.&nbsp; In comparison, JDRing is quite simple to use and very compact (the jar is only 24K), plus it provides all of the scheduling features and flexibility that most projects need. </td> </tr> </tbody> </table> </td> </tr> <tr> <td valign="top"> <table align="left" border="0" cellpadding="0" cellspacing="0" width="400"> <tbody> <tr> <td style="border: 2px dotted white; border-collapse: collapse;" align="center" bgcolor="#9999cc"><font color="#ffffff"><b>features</b></font><br> </td> </tr> <tr> <td align="left" valign="top"> <ul> <li>Alarms are added to and removed from the schedule in code -- no file formats or XML schemas to learn.&nbsp; Just call a method to add an alarm (and specify a listener that you define).</li> <li>You can optionally specify a name for each alarm; this lets you use a single listener for multiple alarms.&nbsp; If you don't specify a name, JDRing automatically gives each alarm a unique name.<br> </li> <li>Alarms can be rung at a fixed interval (e.g., every 30 minutes), or at a single fixed date (e.g., November 10th, 2004 at 10:15 AM), or on a cron-based flexible schedule.</li> <li>With cron-style scheduling, you can provide a list of minutes, hours, days of the month, days of the week, and months (or "all" for any of these), and the alarm will ring on every match.&nbsp; For example, you could ring an alarm on every half-hour from 9am through 2pm, Monday through Thursday, in only the summer months.&nbsp; The list would be like this: minutes: 0, 30; hours: 9,10,11,12,13,14; days of week: 1,2,3,4; days of month: all; months: 5,6,7.</li> <li>Counting standards are consistent with the <code>java.utils.Calendar</code> class, so minutes range from 0 to 59, hours from 0 to 23, days of the week from 1 (Sunday) to 7, and days of the month from 1 to 31 (depending on the month).&nbsp; Months are not as you might expect, though -- they go from 0 (Jan) to 11 (December).</li> <li>When days of week and days of month are both specified in a cron-style schedule, the alarm is rung when <i>either one</i> matches (this is how cron works as well).&nbsp; For example, an alarm with minutes: 0; hours: 6; days of week: 2,3; days of month: 1,15; and months: all.&nbsp; This alarm will ring at 6am on every Monday and Tuesday, plus on the first and fifteenth of the month (well, if the first is a Monday, it will ring once on that day).<br> </li> <li>Alarms by default are rung (listeners are notified) within a single alarm thread, so a long-running alarm will delay following alarms until it completes.&nbsp; This may be what you want -- because alarm tasks may be dependant on previous ones.&nbsp; If not, any alarm may be flagged to ring in a seperate thread, so that it will not delay the other alarms.<br> </li> </ul> </td> </tr> </tbody> </table> </td> </tr> <tr> <td valign="top"> <table align="right" border="0" cellpadding="0" cellspacing="0" width="400"> <tbody> <tr> <td style="border: 2px dotted white; border-collapse: collapse;" align="center" bgcolor="#9999cc"><font color="#ffffff"><b>download</b></font><br> </td> </tr> <tr> <td align="left" valign="top"><a href="files/jdring-2.0.zip">jdring-2.0.zip</a> (includes source code, license, and jar file)<br> </td> </tr> </tbody> </table> </td> </tr> <tr> <td valign="top"> <table align="left" border="0" cellpadding="0" cellspacing="0" width="400"> <tbody> <tr> <td style="border: 2px dotted white; border-collapse: collapse;" align="center" bgcolor="#9999cc"><font color="#ffffff"><b>license</b></font><br> </td> </tr> <tr> <td align="left" valign="top">This program is copyright (c) jtheory creations and others, and licensed as open source under the <a target="_blank" href="http://www.gnu.org/licenses/lgpl.txt">LGPL (Lesser GNU Public License)</a>, so you can freely download it, modify it, and use it.&nbsp; As long as you obey the limitations of the license (read it if you aren't sure!), you can even redistribute it for no charge. </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </body> </html>
NetHome/NetHomeServer
external/jdring/README.html
HTML
gpl-3.0
7,479
// extends src/nodes/image.js which extends src/node-box-native-view.js $(function(){ Iframework.NativeNodes["image-rectangle"] = Iframework.NativeNodes["image"].extend({ info: { title: "rectangle", description: "draw a rectangle" }, initializeModule: function(){ }, inputrect: function (rect) { this._x = rect[0]; this._y = rect[1]; this._w = rect[2]; this._h = rect[3]; }, inputfill: function (color) { this._triggerRedraw = true; this._fill = color; this.context.fillStyle = this._fill; }, inputstroke: function (color) { this._triggerRedraw = true; this._stroke = color; this.context.strokeStyle = this._stroke; }, inputstrokewidth: function (w) { this._triggerRedraw = true; this._strokewidth = w; this.context.lineWidth = this._strokewidth; }, disconnectEdge: function(edge) { // Called from Edge.disconnect(); if (edge.Target.id === "background") { this._background = null; this._triggerRedraw = true; } }, canvasSettings: function () { this.context.fillStyle = this._fill; this.context.strokeStyle = this._stroke; this.context.lineWidth = this._strokewidth; }, redraw: function(){ // Called from NodeBoxNativeView.renderAnimationFrame() this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); var setSettings = false; if (this._background) { if (this.canvas.width !== this._background.width || this.canvas.height !== this._background.height) { this.canvas.width = this._background.width; this.canvas.height = this._background.height; setSettings = true; } } else { var width = this._w + 2*this._x; if (this.canvas.width !== width) { this.canvas.width = this._w + 2*this._x; setSettings = true; } var height = this._h + 2*this._y; if (this.canvas.height !== height) { this.canvas.height = this._h + 2*this._y; setSettings = true; } } if (setSettings) { this.canvasSettings(); } // BG if (this._background) { this.context.drawImage(this._background, 0, 0); } // Angle // if (this._angle !== undefined) { // this.context.translate(this._x, this._y); // this.context.rotate(this._angle); // // Fill // if (this._fill && this._fill!=="") { // this.context.fillRect(0-(this._w/2), 0-(this._h/2), this._w, this._h); // } // // Stroke // if (this._stroke && this._stroke!=="" && this._strokewidth && this._strokewidth>0) { // this.context.strokeRect(0-(this._w/2), 0-(this._h/2), this._w, this._h); // } // this.context.rotate(0-this._angle); // this.context.translate(0-this._x, 0-this._y); // this.inputsend(); // return; // } // Fill if (this._fill && this._fill!=="") { this.context.fillRect(this._x, this._y, this._w, this._h); } // Stroke if (this._stroke && this._stroke!=="" && this._strokewidth && this._strokewidth>0) { this.context.strokeRect(this._x, this._y, this._w, this._h); } this.inputsend(); }, inputsend: function () { this.send("image", this.canvas); }, inputs: { background: { type: "image", description: "first image layer" }, rect: { type: "array:f4", description: "a rectangle array with x, y, width, height" }, x: { type: "float", description: "x of top-left corner", "default": 75 }, y: { type: "float", description: "y of top-left corner", "default": 75 }, w: { type: "float", description: "rectangle width", "default": 350 }, h: { type: "float", description: "rectangle height", "default": 350 }, fill: { type: "color", description: "fill color", "default": "" }, stroke: { type: "color", description: "stroke color", "default": "black" }, strokewidth: { type: "float", description: "stroke width", "default": 1 }, // clear: { // type: "bang", // description: "clear the canvas" // }, send: { type: "bang", description: "send the combined canvas" } }, outputs: { image: { type: "image" } } }); });
woylaski/notebook
web/iframework-master/src/nodes/image-rectangle.js
JavaScript
gpl-3.0
4,701
#ifndef _LMWKSTA_H #define _LMWKSTA_H #ifdef __cplusplus extern "C" { #endif #include <lmuseflg.h> #define WKSTA_PLATFORM_ID_PARMNUM 100 #define WKSTA_COMPUTERNAME_PARMNUM 1 #define WKSTA_LANGROUP_PARMNUM 2 #define WKSTA_VER_MAJOR_PARMNUM 4 #define WKSTA_VER_MINOR_PARMNUM 5 #define WKSTA_LOGGED_ON_USERS_PARMNUM 6 #define WKSTA_LANROOT_PARMNUM 7 #define WKSTA_LOGON_DOMAIN_PARMNUM 8 #define WKSTA_LOGON_SERVER_PARMNUM 9 #define WKSTA_CHARWAIT_PARMNUM 10 #define WKSTA_CHARTIME_PARMNUM 11 #define WKSTA_CHARCOUNT_PARMNUM 12 #define WKSTA_KEEPCONN_PARMNUM 13 #define WKSTA_KEEPSEARCH_PARMNUM 14 #define WKSTA_MAXCMDS_PARMNUM 15 #define WKSTA_NUMWORKBUF_PARMNUM 16 #define WKSTA_MAXWRKCACHE_PARMNUM 17 #define WKSTA_SESSTIMEOUT_PARMNUM 18 #define WKSTA_SIZERROR_PARMNUM 19 #define WKSTA_NUMALERTS_PARMNUM 20 #define WKSTA_NUMSERVICES_PARMNUM 21 #define WKSTA_NUMCHARBUF_PARMNUM 22 #define WKSTA_SIZCHARBUF_PARMNUM 23 #define WKSTA_ERRLOGSZ_PARMNUM 27 #define WKSTA_PRINTBUFTIME_PARMNUM 28 #define WKSTA_SIZWORKBUF_PARMNUM 29 #define WKSTA_MAILSLOTS_PARMNUM 30 #define WKSTA_NUMDGRAMBUF_PARMNUM 31 #define WKSTA_WRKHEURISTICS_PARMNUM 32 #define WKSTA_MAXTHREADS_PARMNUM 33 #define WKSTA_LOCKQUOTA_PARMNUM 41 #define WKSTA_LOCKINCREMENT_PARMNUM 42 #define WKSTA_LOCKMAXIMUM_PARMNUM 43 #define WKSTA_PIPEINCREMENT_PARMNUM 44 #define WKSTA_PIPEMAXIMUM_PARMNUM 45 #define WKSTA_DORMANTFILELIMIT_PARMNUM 46 #define WKSTA_CACHEFILETIMEOUT_PARMNUM 47 #define WKSTA_USEOPPORTUNISTICLOCKING_PARMNUM 48 #define WKSTA_USEUNLOCKBEHIND_PARMNUM 49 #define WKSTA_USECLOSEBEHIND_PARMNUM 50 #define WKSTA_BUFFERNAMEDPIPES_PARMNUM 51 #define WKSTA_USELOCKANDREADANDUNLOCK_PARMNUM 52 #define WKSTA_UTILIZENTCACHING_PARMNUM 53 #define WKSTA_USERAWREAD_PARMNUM 54 #define WKSTA_USERAWWRITE_PARMNUM 55 #define WKSTA_USEWRITERAWWITHDATA_PARMNUM 56 #define WKSTA_USEENCRYPTION_PARMNUM 57 #define WKSTA_BUFFILESWITHDENYWRITE_PARMNUM 58 #define WKSTA_BUFFERREADONLYFILES_PARMNUM 59 #define WKSTA_FORCECORECREATEMODE_PARMNUM 60 #define WKSTA_USE512BYTESMAXTRANSFER_PARMNUM 61 #define WKSTA_READAHEADTHRUPUT_PARMNUM 62 #define WKSTA_OTH_DOMAINS_PARMNUM 101 #define TRANSPORT_QUALITYOFSERVICE_PARMNUM 201 #define TRANSPORT_NAME_PARMNUM 202 typedef struct _WKSTA_INFO_100 { DWORD wki100_platform_id; LPWSTR wki100_computername; LPWSTR wki100_langroup; DWORD wki100_ver_major; DWORD wki100_ver_minor; }WKSTA_INFO_100,*PWKSTA_INFO_100,*LPWKSTA_INFO_100; typedef struct _WKSTA_INFO_101 { DWORD wki101_platform_id; LPWSTR wki101_computername; LPWSTR wki101_langroup; DWORD wki101_ver_major; DWORD wki101_ver_minor; LPWSTR wki101_lanroot; }WKSTA_INFO_101,*PWKSTA_INFO_101,*LPWKSTA_INFO_101; typedef struct _WKSTA_INFO_102 { DWORD wki102_platform_id; LPWSTR wki102_computername; LPWSTR wki102_langroup; DWORD wki102_ver_major; DWORD wki102_ver_minor; LPWSTR wki102_lanroot; DWORD wki102_logged_on_users; }WKSTA_INFO_102,*PWKSTA_INFO_102,*LPWKSTA_INFO_102; typedef struct _WKSTA_INFO_302{ DWORD wki302_char_wait; DWORD wki302_collection_time; DWORD wki302_maximum_collection_count; DWORD wki302_keep_conn; DWORD wki302_keep_search; DWORD wki302_max_cmds; DWORD wki302_num_work_buf; DWORD wki302_siz_work_buf; DWORD wki302_max_wrk_cache; DWORD wki302_sess_timeout; DWORD wki302_siz_error; DWORD wki302_num_alerts; DWORD wki302_num_services; DWORD wki302_errlog_sz; DWORD wki302_print_buf_time; DWORD wki302_num_char_buf; DWORD wki302_siz_char_buf; LPWSTR wki302_wrk_heuristics; DWORD wki302_mailslots; DWORD wki302_num_dgram_buf; }WKSTA_INFO_302,*PWKSTA_INFO_302,*LPWKSTA_INFO_302; typedef struct _WKSTA_INFO_402{ DWORD wki402_char_wait; DWORD wki402_collection_time; DWORD wki402_maximum_collection_count; DWORD wki402_keep_conn; DWORD wki402_keep_search; DWORD wki402_max_cmds; DWORD wki402_num_work_buf; DWORD wki402_siz_work_buf; DWORD wki402_max_wrk_cache; DWORD wki402_sess_timeout; DWORD wki402_siz_error; DWORD wki402_num_alerts; DWORD wki402_num_services; DWORD wki402_errlog_sz; DWORD wki402_print_buf_time; DWORD wki402_num_char_buf; DWORD wki402_siz_char_buf; LPWSTR wki402_wrk_heuristics; DWORD wki402_mailslots; DWORD wki402_num_dgram_buf; DWORD wki402_max_threads; }WKSTA_INFO_402,*PWKSTA_INFO_402,*LPWKSTA_INFO_402; typedef struct _WKSTA_INFO_502{ DWORD wki502_char_wait; DWORD wki502_collection_time; DWORD wki502_maximum_collection_count; DWORD wki502_keep_conn; DWORD wki502_max_cmds; DWORD wki502_sess_timeout; DWORD wki502_siz_char_buf; DWORD wki502_max_threads; DWORD wki502_lock_quota; DWORD wki502_lock_increment; DWORD wki502_lock_maximum; DWORD wki502_pipe_increment; DWORD wki502_pipe_maximum; DWORD wki502_cache_file_timeout; DWORD wki502_dormant_file_limit; DWORD wki502_read_ahead_throughput; DWORD wki502_num_mailslot_buffers; DWORD wki502_num_srv_announce_buffers; DWORD wki502_max_illegal_datagram_events; DWORD wki502_illegal_datagram_event_reset_frequency; BOOL wki502_log_election_packets; BOOL wki502_use_opportunistic_locking; BOOL wki502_use_unlock_behind; BOOL wki502_use_close_behind; BOOL wki502_buf_named_pipes; BOOL wki502_use_lock_read_unlock; BOOL wki502_utilize_nt_caching; BOOL wki502_use_raw_read; BOOL wki502_use_raw_write; BOOL wki502_use_write_raw_data; BOOL wki502_use_encryption; BOOL wki502_buf_files_deny_write; BOOL wki502_buf_read_only_files; BOOL wki502_force_core_create_mode; BOOL wki502_use_512_byte_max_transfer; }WKSTA_INFO_502,*PWKSTA_INFO_502,*LPWKSTA_INFO_502; typedef struct _WKSTA_INFO_1010 { DWORD wki1010_char_wait;} WKSTA_INFO_1010,*PWKSTA_INFO_1010,*LPWKSTA_INFO_1010; typedef struct _WKSTA_INFO_1011 { DWORD wki1011_collection_time;} WKSTA_INFO_1011,*PWKSTA_INFO_1011,*LPWKSTA_INFO_1011; typedef struct _WKSTA_INFO_1012 { DWORD wki1012_maximum_collection_count;} WKSTA_INFO_1012,*PWKSTA_INFO_1012,*LPWKSTA_INFO_1012; typedef struct _WKSTA_INFO_1027 { DWORD wki1027_errlog_sz;} WKSTA_INFO_1027,*PWKSTA_INFO_1027,*LPWKSTA_INFO_1027; typedef struct _WKSTA_INFO_1028 { DWORD wki1028_print_buf_time;} WKSTA_INFO_1028,*PWKSTA_INFO_1028,*LPWKSTA_INFO_1028; typedef struct _WKSTA_INFO_1032 { DWORD wki1032_wrk_heuristics;} WKSTA_INFO_1032,*PWKSTA_INFO_1032,*LPWKSTA_INFO_1032; typedef struct _WKSTA_INFO_1013 { DWORD wki1013_keep_conn;} WKSTA_INFO_1013,*PWKSTA_INFO_1013,*LPWKSTA_INFO_1013; typedef struct _WKSTA_INFO_1018 { DWORD wki1018_sess_timeout;} WKSTA_INFO_1018,*PWKSTA_INFO_1018,*LPWKSTA_INFO_1018; typedef struct _WKSTA_INFO_1023 { DWORD wki1023_siz_char_buf;} WKSTA_INFO_1023,*PWKSTA_INFO_1023,*LPWKSTA_INFO_1023; typedef struct _WKSTA_INFO_1033 { DWORD wki1033_max_threads;} WKSTA_INFO_1033,*PWKSTA_INFO_1033,*LPWKSTA_INFO_1033; typedef struct _WKSTA_INFO_1041 { DWORD wki1041_lock_quota;} WKSTA_INFO_1041,*PWKSTA_INFO_1041,*LPWKSTA_INFO_1041; typedef struct _WKSTA_INFO_1042 { DWORD wki1042_lock_increment;} WKSTA_INFO_1042,*PWKSTA_INFO_1042,*LPWKSTA_INFO_1042; typedef struct _WKSTA_INFO_1043 { DWORD wki1043_lock_maximum;} WKSTA_INFO_1043,*PWKSTA_INFO_1043,*LPWKSTA_INFO_1043; typedef struct _WKSTA_INFO_1044 { DWORD wki1044_pipe_increment;} WKSTA_INFO_1044,*PWKSTA_INFO_1044,*LPWKSTA_INFO_1044; typedef struct _WKSTA_INFO_1045 { DWORD wki1045_pipe_maximum;} WKSTA_INFO_1045,*PWKSTA_INFO_1045,*LPWKSTA_INFO_1045; typedef struct _WKSTA_INFO_1046 { DWORD wki1046_dormant_file_limit;} WKSTA_INFO_1046,*PWKSTA_INFO_1046,*LPWKSTA_INFO_1046; typedef struct _WKSTA_INFO_1047 { DWORD wki1047_cache_file_timeout;} WKSTA_INFO_1047,*PWKSTA_INFO_1047,*LPWKSTA_INFO_1047; typedef struct _WKSTA_INFO_1048 { BOOL wki1048_use_opportunistic_locking;} WKSTA_INFO_1048,*PWKSTA_INFO_1048,*LPWKSTA_INFO_1048; typedef struct _WKSTA_INFO_1049 { BOOL wki1049_use_unlock_behind;} WKSTA_INFO_1049,*PWKSTA_INFO_1049,*LPWKSTA_INFO_1049; typedef struct _WKSTA_INFO_1050 { BOOL wki1050_use_close_behind;} WKSTA_INFO_1050,*PWKSTA_INFO_1050,*LPWKSTA_INFO_1050; typedef struct _WKSTA_INFO_1051 { BOOL wki1051_buf_named_pipes;} WKSTA_INFO_1051,*PWKSTA_INFO_1051,*LPWKSTA_INFO_1051; typedef struct _WKSTA_INFO_1052 { BOOL wki1052_use_lock_read_unlock;} WKSTA_INFO_1052,*PWKSTA_INFO_1052,*LPWKSTA_INFO_1052; typedef struct _WKSTA_INFO_1053 { BOOL wki1053_utilize_nt_caching;} WKSTA_INFO_1053,*PWKSTA_INFO_1053,*LPWKSTA_INFO_1053; typedef struct _WKSTA_INFO_1054 { BOOL wki1054_use_raw_read;} WKSTA_INFO_1054,*PWKSTA_INFO_1054,*LPWKSTA_INFO_1054; typedef struct _WKSTA_INFO_1055 { BOOL wki1055_use_raw_write;} WKSTA_INFO_1055,*PWKSTA_INFO_1055,*LPWKSTA_INFO_1055; typedef struct _WKSTA_INFO_1056 { BOOL wki1056_use_write_raw_data;} WKSTA_INFO_1056,*PWKSTA_INFO_1056,*LPWKSTA_INFO_1056; typedef struct _WKSTA_INFO_1057 { BOOL wki1057_use_encryption;} WKSTA_INFO_1057,*PWKSTA_INFO_1057,*LPWKSTA_INFO_1057; typedef struct _WKSTA_INFO_1058 { BOOL wki1058_buf_files_deny_write;} WKSTA_INFO_1058,*PWKSTA_INFO_1058,*LPWKSTA_INFO_1058; typedef struct _WKSTA_INFO_1059 { BOOL wki1059_buf_read_only_files;} WKSTA_INFO_1059,*PWKSTA_INFO_1059,*LPWKSTA_INFO_1059; typedef struct _WKSTA_INFO_1060 { BOOL wki1060_force_core_create_mode;} WKSTA_INFO_1060,*PWKSTA_INFO_1060,*LPWKSTA_INFO_1060; typedef struct _WKSTA_INFO_1061 { BOOL wki1061_use_512_byte_max_transfer;} WKSTA_INFO_1061,*PWKSTA_INFO_1061,*LPWKSTA_INFO_1061; typedef struct _WKSTA_INFO_1062 { DWORD wki1062_read_ahead_throughput;} WKSTA_INFO_1062,*PWKSTA_INFO_1062,*LPWKSTA_INFO_1062; typedef struct _WKSTA_USER_INFO_0 { LPWSTR wkui0_username;}WKSTA_USER_INFO_0,*PWKSTA_USER_INFO_0,*LPWKSTA_USER_INFO_0; typedef struct _WKSTA_USER_INFO_1 { LPWSTR wkui1_username; LPWSTR wkui1_logon_domain; LPWSTR wkui1_oth_domains; LPWSTR wkui1_logon_server; }WKSTA_USER_INFO_1,*PWKSTA_USER_INFO_1,*LPWKSTA_USER_INFO_1; typedef struct _WKSTA_USER_INFO_1101 { LPWSTR wkui1101_oth_domains;} WKSTA_USER_INFO_1101,*PWKSTA_USER_INFO_1101,*LPWKSTA_USER_INFO_1101; typedef struct _WKSTA_TRANSPORT_INFO_0 { DWORD wkti0_quality_of_service; DWORD wkti0_number_of_vcs; LPWSTR wkti0_transport_name; LPWSTR wkti0_transport_address; BOOL wkti0_wan_ish; }WKSTA_TRANSPORT_INFO_0,*PWKSTA_TRANSPORT_INFO_0,*LPWKSTA_TRANSPORT_INFO_0; NET_API_STATUS WINAPI NetWkstaGetInfo(LPWSTR,DWORD,PBYTE*); NET_API_STATUS WINAPI NetWkstaSetInfo(LPWSTR,DWORD,PBYTE,PDWORD); NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR,DWORD,PBYTE*); NET_API_STATUS WINAPI NetWkstaUserSetInfo(LPWSTR,DWORD,PBYTE,PDWORD); NET_API_STATUS WINAPI NetWkstaUserEnum(LPWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD); NET_API_STATUS WINAPI NetWkstaTransportAdd(LPWSTR,DWORD,PBYTE,PDWORD); NET_API_STATUS WINAPI NetWkstaTransportDel(LPWSTR,LPWSTR,DWORD); NET_API_STATUS WINAPI NetWkstaTransportEnum(LPWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD); #ifdef __cplusplus } #endif #endif
Mariale13/UDS_Protocol
EXTERNAL_SOURCE/MinGW/Include/lmwksta.h
C
gpl-3.0
10,904
# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com> # # This file is part of Ansible # # Ansible 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. # # Ansible 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 Ansible. If not, see <http://www.gnu.org/licenses/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type import ast import contextlib import datetime import os import pwd import re import time from functools import wraps from io import StringIO from numbers import Number try: from hashlib import sha1 except ImportError: from sha import sha as sha1 from jinja2.exceptions import TemplateSyntaxError, UndefinedError from jinja2.loaders import FileSystemLoader from jinja2.runtime import Context, StrictUndefined from ansible import constants as C from ansible.errors import AnsibleError, AnsibleFilterError, AnsibleUndefinedVariable, AnsibleAssertionError from ansible.module_utils.six import string_types, text_type from ansible.module_utils._text import to_native, to_text, to_bytes from ansible.module_utils.common._collections_compat import Sequence, Mapping from ansible.plugins.loader import filter_loader, lookup_loader, test_loader from ansible.template.safe_eval import safe_eval from ansible.template.template import AnsibleJ2Template from ansible.template.vars import AnsibleJ2Vars from ansible.utils.display import Display from ansible.utils.unsafe_proxy import UnsafeProxy, wrap_var display = Display() __all__ = ['Templar', 'generate_ansible_template_vars'] # A regex for checking to see if a variable we're trying to # expand is just a single variable name. # Primitive Types which we don't want Jinja to convert to strings. NON_TEMPLATED_TYPES = (bool, Number) JINJA2_OVERRIDE = '#jinja2:' USE_JINJA2_NATIVE = False if C.DEFAULT_JINJA2_NATIVE: try: from jinja2.nativetypes import NativeEnvironment as Environment from ansible.template.native_helpers import ansible_native_concat as j2_concat USE_JINJA2_NATIVE = True except ImportError: from jinja2 import Environment from jinja2.utils import concat as j2_concat from jinja2 import __version__ as j2_version display.warning( 'jinja2_native requires Jinja 2.10 and above. ' 'Version detected: %s. Falling back to default.' % j2_version ) else: from jinja2 import Environment from jinja2.utils import concat as j2_concat def generate_ansible_template_vars(path): b_path = to_bytes(path) try: template_uid = pwd.getpwuid(os.stat(b_path).st_uid).pw_name except (KeyError, TypeError): template_uid = os.stat(b_path).st_uid temp_vars = {} temp_vars['template_host'] = to_text(os.uname()[1]) temp_vars['template_path'] = path temp_vars['template_mtime'] = datetime.datetime.fromtimestamp(os.path.getmtime(b_path)) temp_vars['template_uid'] = to_text(template_uid) temp_vars['template_fullpath'] = os.path.abspath(path) temp_vars['template_run_date'] = datetime.datetime.now() managed_default = C.DEFAULT_MANAGED_STR managed_str = managed_default.format( host=temp_vars['template_host'], uid=temp_vars['template_uid'], file=temp_vars['template_path'], ) temp_vars['ansible_managed'] = to_text(time.strftime(to_native(managed_str), time.localtime(os.path.getmtime(b_path)))) return temp_vars def _escape_backslashes(data, jinja_env): """Double backslashes within jinja2 expressions A user may enter something like this in a playbook:: debug: msg: "Test Case 1\\3; {{ test1_name | regex_replace('^(.*)_name$', '\\1')}}" The string inside of the {{ gets interpreted multiple times First by yaml. Then by python. And finally by jinja2 as part of it's variable. Because it is processed by both python and jinja2, the backslash escaped characters get unescaped twice. This means that we'd normally have to use four backslashes to escape that. This is painful for playbook authors as they have to remember different rules for inside vs outside of a jinja2 expression (The backslashes outside of the "{{ }}" only get processed by yaml and python. So they only need to be escaped once). The following code fixes this by automatically performing the extra quoting of backslashes inside of a jinja2 expression. """ if '\\' in data and '{{' in data: new_data = [] d2 = jinja_env.preprocess(data) in_var = False for token in jinja_env.lex(d2): if token[1] == 'variable_begin': in_var = True new_data.append(token[2]) elif token[1] == 'variable_end': in_var = False new_data.append(token[2]) elif in_var and token[1] == 'string': # Double backslashes only if we're inside of a jinja2 variable new_data.append(token[2].replace('\\', '\\\\')) else: new_data.append(token[2]) data = ''.join(new_data) return data def _count_newlines_from_end(in_str): ''' Counts the number of newlines at the end of a string. This is used during the jinja2 templating to ensure the count matches the input, since some newlines may be thrown away during the templating. ''' try: i = len(in_str) j = i - 1 while in_str[j] == '\n': j -= 1 return i - 1 - j except IndexError: # Uncommon cases: zero length string and string containing only newlines return i def tests_as_filters_warning(name, func): ''' Closure to enable displaying a deprecation warning when tests are used as a filter This closure is only used when registering ansible provided tests as filters This function should be removed in 2.9 along with registering ansible provided tests as filters in Templar._get_filters ''' @wraps(func) def wrapper(*args, **kwargs): display.deprecated( 'Using tests as filters is deprecated. Instead of using `result|%(name)s` use ' '`result is %(name)s`' % dict(name=name), version='2.9' ) return func(*args, **kwargs) return wrapper class AnsibleContext(Context): ''' A custom context, which intercepts resolve() calls and sets a flag internally if any variable lookup returns an AnsibleUnsafe value. This flag is checked post-templating, and (when set) will result in the final templated result being wrapped via UnsafeProxy. ''' def __init__(self, *args, **kwargs): super(AnsibleContext, self).__init__(*args, **kwargs) self.unsafe = False def _is_unsafe(self, val): ''' Our helper function, which will also recursively check dict and list entries due to the fact that they may be repr'd and contain a key or value which contains jinja2 syntax and would otherwise lose the AnsibleUnsafe value. ''' if isinstance(val, dict): for key in val.keys(): if self._is_unsafe(val[key]): return True elif isinstance(val, list): for item in val: if self._is_unsafe(item): return True elif isinstance(val, string_types) and hasattr(val, '__UNSAFE__'): return True return False def _update_unsafe(self, val): if val is not None and not self.unsafe and self._is_unsafe(val): self.unsafe = True def resolve(self, key): ''' The intercepted resolve(), which uses the helper above to set the internal flag whenever an unsafe variable value is returned. ''' val = super(AnsibleContext, self).resolve(key) self._update_unsafe(val) return val def resolve_or_missing(self, key): val = super(AnsibleContext, self).resolve_or_missing(key) self._update_unsafe(val) return val class AnsibleEnvironment(Environment): ''' Our custom environment, which simply allows us to override the class-level values for the Template and Context classes used by jinja2 internally. ''' context_class = AnsibleContext template_class = AnsibleJ2Template class Templar: ''' The main class for templating, with the main entry-point of template(). ''' def __init__(self, loader, shared_loader_obj=None, variables=None): variables = {} if variables is None else variables self._loader = loader self._filters = None self._tests = None self._available_variables = variables self._cached_result = {} if loader: self._basedir = loader.get_basedir() else: self._basedir = './' if shared_loader_obj: self._filter_loader = getattr(shared_loader_obj, 'filter_loader') self._test_loader = getattr(shared_loader_obj, 'test_loader') self._lookup_loader = getattr(shared_loader_obj, 'lookup_loader') else: self._filter_loader = filter_loader self._test_loader = test_loader self._lookup_loader = lookup_loader # flags to determine whether certain failures during templating # should result in fatal errors being raised self._fail_on_lookup_errors = True self._fail_on_filter_errors = True self._fail_on_undefined_errors = C.DEFAULT_UNDEFINED_VAR_BEHAVIOR self.environment = AnsibleEnvironment( trim_blocks=True, undefined=StrictUndefined, extensions=self._get_extensions(), finalize=self._finalize, loader=FileSystemLoader(self._basedir), ) # the current rendering context under which the templar class is working self.cur_context = None self.SINGLE_VAR = re.compile(r"^%s\s*(\w*)\s*%s$" % (self.environment.variable_start_string, self.environment.variable_end_string)) self._clean_regex = re.compile(r'(?:%s|%s|%s|%s)' % ( self.environment.variable_start_string, self.environment.block_start_string, self.environment.block_end_string, self.environment.variable_end_string )) self._no_type_regex = re.compile(r'.*?\|\s*(?:%s)(?:\([^\|]*\))?\s*\)?\s*(?:%s)' % ('|'.join(C.STRING_TYPE_FILTERS), self.environment.variable_end_string)) def _get_filters(self, builtin_filters): ''' Returns filter plugins, after loading and caching them if need be ''' if self._filters is not None: return self._filters.copy() self._filters = dict() # TODO: Remove registering tests as filters in 2.9 for name, func in self._get_tests().items(): if name in builtin_filters: # If we have a custom test named the same as a builtin filter, don't register as a filter continue self._filters[name] = tests_as_filters_warning(name, func) for fp in self._filter_loader.all(): self._filters.update(fp.filters()) return self._filters.copy() def _get_tests(self): ''' Returns tests plugins, after loading and caching them if need be ''' if self._tests is not None: return self._tests.copy() self._tests = dict() for fp in self._test_loader.all(): self._tests.update(fp.tests()) return self._tests.copy() def _get_extensions(self): ''' Return jinja2 extensions to load. If some extensions are set via jinja_extensions in ansible.cfg, we try to load them with the jinja environment. ''' jinja_exts = [] if C.DEFAULT_JINJA2_EXTENSIONS: # make sure the configuration directive doesn't contain spaces # and split extensions in an array jinja_exts = C.DEFAULT_JINJA2_EXTENSIONS.replace(" ", "").split(',') return jinja_exts def set_available_variables(self, variables): ''' Sets the list of template variables this Templar instance will use to template things, so we don't have to pass them around between internal methods. We also clear the template cache here, as the variables are being changed. ''' if not isinstance(variables, dict): raise AnsibleAssertionError("the type of 'variables' should be a dict but was a %s" % (type(variables))) self._available_variables = variables self._cached_result = {} def template(self, variable, convert_bare=False, preserve_trailing_newlines=True, escape_backslashes=True, fail_on_undefined=None, overrides=None, convert_data=True, static_vars=None, cache=True, disable_lookups=False): ''' Templates (possibly recursively) any given data as input. If convert_bare is set to True, the given data will be wrapped as a jinja2 variable ('{{foo}}') before being sent through the template engine. ''' static_vars = [''] if static_vars is None else static_vars # Don't template unsafe variables, just return them. if hasattr(variable, '__UNSAFE__'): return variable if fail_on_undefined is None: fail_on_undefined = self._fail_on_undefined_errors try: if convert_bare: variable = self._convert_bare_variable(variable) if isinstance(variable, string_types): result = variable if self._contains_vars(variable): # Check to see if the string we are trying to render is just referencing a single # var. In this case we don't want to accidentally change the type of the variable # to a string by using the jinja template renderer. We just want to pass it. only_one = self.SINGLE_VAR.match(variable) if only_one: var_name = only_one.group(1) if var_name in self._available_variables: resolved_val = self._available_variables[var_name] if isinstance(resolved_val, NON_TEMPLATED_TYPES): return resolved_val elif resolved_val is None: return C.DEFAULT_NULL_REPRESENTATION # Using a cache in order to prevent template calls with already templated variables sha1_hash = None if cache: variable_hash = sha1(text_type(variable).encode('utf-8')) options_hash = sha1( ( text_type(preserve_trailing_newlines) + text_type(escape_backslashes) + text_type(fail_on_undefined) + text_type(overrides) ).encode('utf-8') ) sha1_hash = variable_hash.hexdigest() + options_hash.hexdigest() if cache and sha1_hash in self._cached_result: result = self._cached_result[sha1_hash] else: result = self.do_template( variable, preserve_trailing_newlines=preserve_trailing_newlines, escape_backslashes=escape_backslashes, fail_on_undefined=fail_on_undefined, overrides=overrides, disable_lookups=disable_lookups, ) if not USE_JINJA2_NATIVE: unsafe = hasattr(result, '__UNSAFE__') if convert_data and not self._no_type_regex.match(variable): # if this looks like a dictionary or list, convert it to such using the safe_eval method if (result.startswith("{") and not result.startswith(self.environment.variable_start_string)) or \ result.startswith("[") or result in ("True", "False"): eval_results = safe_eval(result, locals=self._available_variables, include_exceptions=True) if eval_results[1] is None: result = eval_results[0] if unsafe: result = wrap_var(result) else: # FIXME: if the safe_eval raised an error, should we do something with it? pass # we only cache in the case where we have a single variable # name, to make sure we're not putting things which may otherwise # be dynamic in the cache (filters, lookups, etc.) if cache: self._cached_result[sha1_hash] = result return result elif isinstance(variable, (list, tuple)): return [self.template( v, preserve_trailing_newlines=preserve_trailing_newlines, fail_on_undefined=fail_on_undefined, overrides=overrides, disable_lookups=disable_lookups, ) for v in variable] elif isinstance(variable, (dict, Mapping)): d = {} # we don't use iteritems() here to avoid problems if the underlying dict # changes sizes due to the templating, which can happen with hostvars for k in variable.keys(): if k not in static_vars: d[k] = self.template( variable[k], preserve_trailing_newlines=preserve_trailing_newlines, fail_on_undefined=fail_on_undefined, overrides=overrides, disable_lookups=disable_lookups, ) else: d[k] = variable[k] return d else: return variable except AnsibleFilterError: if self._fail_on_filter_errors: raise else: return variable def is_template(self, data): ''' lets us know if data has a template''' if isinstance(data, string_types): try: new = self.do_template(data, fail_on_undefined=True) except (AnsibleUndefinedVariable, UndefinedError): return True except: return False return (new != data) elif isinstance(data, (list, tuple)): for v in data: if self.is_template(v): return True elif isinstance(data, dict): for k in data: if self.is_template(k) or self.is_template(data[k]): return True return False def templatable(self, data): ''' returns True if the data can be templated w/o errors ''' templatable = True try: self.template(data) except: templatable = False return templatable def _contains_vars(self, data): ''' returns True if the data contains a variable pattern ''' if isinstance(data, string_types): for marker in (self.environment.block_start_string, self.environment.variable_start_string, self.environment.comment_start_string): if marker in data: return True return False def _convert_bare_variable(self, variable): ''' Wraps a bare string, which may have an attribute portion (ie. foo.bar) in jinja2 variable braces so that it is evaluated properly. ''' if isinstance(variable, string_types): contains_filters = "|" in variable first_part = variable.split("|")[0].split(".")[0].split("[")[0] if (contains_filters or first_part in self._available_variables) and self.environment.variable_start_string not in variable: return "%s%s%s" % (self.environment.variable_start_string, variable, self.environment.variable_end_string) # the variable didn't meet the conditions to be converted, # so just return it as-is return variable def _finalize(self, thing): ''' A custom finalize method for jinja2, which prevents None from being returned. This avoids a string of ``"None"`` as ``None`` has no importance in YAML. If using ANSIBLE_JINJA2_NATIVE we bypass this and return the actual value always ''' if USE_JINJA2_NATIVE: return thing return thing if thing is not None else '' def _fail_lookup(self, name, *args, **kwargs): raise AnsibleError("The lookup `%s` was found, however lookups were disabled from templating" % name) def _now_datetime(self, utc=False, fmt=None): '''jinja2 global function to return current datetime, potentially formatted via strftime''' if utc: now = datetime.datetime.utcnow() else: now = datetime.datetime.now() if fmt: return now.strftime(fmt) return now def _query_lookup(self, name, *args, **kwargs): ''' wrapper for lookup, force wantlist true''' kwargs['wantlist'] = True return self._lookup(name, *args, **kwargs) def _lookup(self, name, *args, **kwargs): instance = self._lookup_loader.get(name.lower(), loader=self._loader, templar=self) if instance is not None: wantlist = kwargs.pop('wantlist', False) allow_unsafe = kwargs.pop('allow_unsafe', C.DEFAULT_ALLOW_UNSAFE_LOOKUPS) errors = kwargs.pop('errors', 'strict') from ansible.utils.listify import listify_lookup_plugin_terms loop_terms = listify_lookup_plugin_terms(terms=args, templar=self, loader=self._loader, fail_on_undefined=True, convert_bare=False) # safely catch run failures per #5059 try: ran = instance.run(loop_terms, variables=self._available_variables, **kwargs) except (AnsibleUndefinedVariable, UndefinedError) as e: raise AnsibleUndefinedVariable(e) except Exception as e: if self._fail_on_lookup_errors: msg = u"An unhandled exception occurred while running the lookup plugin '%s'. Error was a %s, original message: %s" % \ (name, type(e), to_text(e)) if errors == 'warn': display.warning(msg) elif errors == 'ignore': display.display(msg, log_only=True) else: raise AnsibleError(to_native(msg)) ran = None if ran and not allow_unsafe: if wantlist: ran = wrap_var(ran) else: try: ran = UnsafeProxy(",".join(ran)) except TypeError: # Lookup Plugins should always return lists. Throw an error if that's not # the case: if not isinstance(ran, Sequence): raise AnsibleError("The lookup plugin '%s' did not return a list." % name) # The TypeError we can recover from is when the value *inside* of the list # is not a string if len(ran) == 1: ran = wrap_var(ran[0]) else: ran = wrap_var(ran) if self.cur_context: self.cur_context.unsafe = True return ran else: raise AnsibleError("lookup plugin (%s) not found" % name) def do_template(self, data, preserve_trailing_newlines=True, escape_backslashes=True, fail_on_undefined=None, overrides=None, disable_lookups=False): if USE_JINJA2_NATIVE and not isinstance(data, string_types): return data # For preserving the number of input newlines in the output (used # later in this method) data_newlines = _count_newlines_from_end(data) if fail_on_undefined is None: fail_on_undefined = self._fail_on_undefined_errors try: # allows template header overrides to change jinja2 options. if overrides is None: myenv = self.environment.overlay() else: myenv = self.environment.overlay(overrides) # Get jinja env overrides from template if hasattr(data, 'startswith') and data.startswith(JINJA2_OVERRIDE): eol = data.find('\n') line = data[len(JINJA2_OVERRIDE):eol] data = data[eol + 1:] for pair in line.split(','): (key, val) = pair.split(':') key = key.strip() setattr(myenv, key, ast.literal_eval(val.strip())) # Adds Ansible custom filters and tests myenv.filters.update(self._get_filters(myenv.filters)) myenv.tests.update(self._get_tests()) if escape_backslashes: # Allow users to specify backslashes in playbooks as "\\" instead of as "\\\\". data = _escape_backslashes(data, myenv) try: t = myenv.from_string(data) except TemplateSyntaxError as e: raise AnsibleError("template error while templating string: %s. String: %s" % (to_native(e), to_native(data))) except Exception as e: if 'recursion' in to_native(e): raise AnsibleError("recursive loop detected in template string: %s" % to_native(data)) else: return data if disable_lookups: t.globals['query'] = t.globals['q'] = t.globals['lookup'] = self._fail_lookup else: t.globals['lookup'] = self._lookup t.globals['query'] = t.globals['q'] = self._query_lookup t.globals['now'] = self._now_datetime t.globals['finalize'] = self._finalize jvars = AnsibleJ2Vars(self, t.globals) self.cur_context = new_context = t.new_context(jvars, shared=True) rf = t.root_render_func(new_context) try: res = j2_concat(rf) if getattr(new_context, 'unsafe', False): res = wrap_var(res) except TypeError as te: if 'StrictUndefined' in to_native(te): errmsg = "Unable to look up a name or access an attribute in template string (%s).\n" % to_native(data) errmsg += "Make sure your variable name does not contain invalid characters like '-': %s" % to_native(te) raise AnsibleUndefinedVariable(errmsg) else: display.debug("failing because of a type error, template data is: %s" % to_native(data)) raise AnsibleError("Unexpected templating type error occurred on (%s): %s" % (to_native(data), to_native(te))) if USE_JINJA2_NATIVE and not isinstance(res, string_types): return res if preserve_trailing_newlines: # The low level calls above do not preserve the newline # characters at the end of the input data, so we use the # calculate the difference in newlines and append them # to the resulting output for parity # # jinja2 added a keep_trailing_newline option in 2.7 when # creating an Environment. That would let us make this code # better (remove a single newline if # preserve_trailing_newlines is False). Once we can depend on # that version being present, modify our code to set that when # initializing self.environment and remove a single trailing # newline here if preserve_newlines is False. res_newlines = _count_newlines_from_end(res) if data_newlines > res_newlines: res += self.environment.newline_sequence * (data_newlines - res_newlines) return res except (UndefinedError, AnsibleUndefinedVariable) as e: if fail_on_undefined: raise AnsibleUndefinedVariable(e) else: display.debug("Ignoring undefined failure: %s" % to_text(e)) return data # for backwards compatibility in case anyone is using old private method directly _do_template = do_template
veger/ansible
lib/ansible/template/__init__.py
Python
gpl-3.0
30,186
RSpec::Matchers.define :require_string_for do |property| match do |type_class| config = {name: 'name'} config[property] = 2 expect do type_class.new(config) end.to raise_error(Puppet::Error, /#{property} should be a String/) end failure_message do |type_class| "#{type_class} should require #{property} to be a String" end end RSpec::Matchers.define :require_hash_for do |property| match do |type_class| config = {name: 'name'} config[property] = 2 expect do type_class.new(config) end.to raise_error(Puppet::Error, /#{property} should be a Hash/) end failure_message do |type_class| "#{type_class} should require #{property} to be a Hash" end end RSpec.shared_examples "array properties" do |properties| properties.each do |property| it "should require #{property} to be an Array" do config = {name: 'name'} config[property] = 2 expect do type_class.new(config) end.to raise_error(Puppet::Error, /#{property} should be an Array/) end end end RSpec::Matchers.define :require_integer_for do |property| match do |type_class| config = {name: 'name'} config[property] = 'string' expect do type_class.new(config) end.to raise_error(Puppet::Error, /#{property} should be an Integer/) end failure_message do |type_class| "#{type_class} should require #{property} to be a Integer" end end RSpec.shared_examples "boolean properties" do |properties| properties.each do |property| it "should require #{property} to be boolean" do config = {name: 'name'} config[property] = 'string' expect do type_class.new(config) end.to raise_error(Puppet::Error, /Parameter #{property} failed on .*: Invalid value/) end end end RSpec::Matchers.define :be_read_only do |property| match do |type_class| config = {name: 'name'} config[property] = 'invalid' expect do type_class.new(config) end.to raise_error(Puppet::Error, /#{property} is read-only/) end failure_message do |type_class| "#{type_class} should require #{property} to be read-only" end end
nauskis/Puppet-for-dummies
windowsia/puppet/modules/iis/spec/support/matchers/type_provider_interface.rb
Ruby
gpl-3.0
2,157
/* attsim.cc Implementation of the Attenuator class RELACS - Relaxed ELectrophysiological data Acquisition, Control, and Stimulation Copyright (C) 2002-2015 Jan Benda <jan.benda@uni-tuebingen.de> 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. RELACS 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 <cmath> #include <relacs/attsim.h> using namespace std; namespace relacs { const double AttSim::AttStep = 0.5; const double AttSim::AttMax = 100.0; const double AttSim::AttMin = -25.0; double AttSim::Decibel[AttSim::MaxDevices] = { 0, 0 }; AttSim::AttSim( void ) : Attenuator( "Attenuator Simulation" ) { initOptions(); } AttSim::~AttSim( void ) { } int AttSim::open( const string &device ) { Info.clear(); setDeviceName( "Attenuator Simulation" ); setDeviceVendor( "RELACS" ); setDeviceFile( device ); setInfo(); Info.addNumber( "resolution", 0.5, "dB" ); return 0; } bool AttSim::isOpen( void ) const { return true; } void AttSim::close( void ) { Info.clear(); } const Options &AttSim::settings( void ) const { Settings.clear(); if ( Decibel[0] == MuteAttenuationLevel ) Settings.addText( "level1", "muted" ); else Settings.addNumber( "level1", Decibel[0], "dB" ); if ( Decibel[1] == MuteAttenuationLevel ) Settings.addText( "level2", "muted" ); else Settings.addNumber( "level2", Decibel[1], "dB" ); return Settings; } int AttSim::lines( void ) const { return MaxDevices; } double AttSim::minLevel( void ) const { return AttMin; } double AttSim::maxLevel( void ) const { return AttMax; } void AttSim::levels( vector<double> &l ) const { l.clear(); l.reserve( (int)::ceil((AttMax-AttMin)/AttStep) ); for ( int k=0; AttMin + k*AttStep <= AttMax; k++ ) l.push_back( AttMin + k*AttStep ); } int AttSim::attenuate( int di, double &decibel ) { if ( di < 0 || di >= MaxDevices ) return InvalidDevice; if ( decibel == MuteAttenuationLevel ) { Decibel[di] = decibel; return 0; } if ( decibel < AttMin ) { decibel = AttMin; return Overflow; } if ( decibel > AttMax ) { decibel = AttMax; return Underflow; } decibel = floor( (decibel+0.5*AttStep)/AttStep )*AttStep; Decibel[di] = decibel; return 0; } int AttSim::testAttenuate( int di, double &decibel ) { if ( di < 0 || di >= MaxDevices ) return InvalidDevice; if ( decibel == MuteAttenuationLevel ) { return 0; } if ( decibel < AttMin ) { decibel = AttMin; return Overflow; } if ( decibel > AttMax ) { decibel = AttMax; return Underflow; } decibel = floor( (decibel+0.5*AttStep)/AttStep )*AttStep; return 0; } }; /* namespace relacs */
gicmo/relacs
relacs/src/attsim.cc
C++
gpl-3.0
3,225
/* * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * The contents of this file constitute Original Code as defined in and * are subject to the Apple Public Source License Version 1.1 (the * "License"). You may not use this file except in compliance with the * License. Please obtain a copy of the License at * http://www.apple.com/publicsource and read it before using this file. * * This Original Code and all software distributed under the License are * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the * License for the specific language governing rights and limitations * under the License. * * @APPLE_LICENSE_HEADER_END@ */ /******************************************************************************* * * * File: fenv_private.h * * * * Contains: Defines for manipulating environmental settings directly. * * * *******************************************************************************/ #ifndef __FENV_PRIVATE__ #define __FENV_PRIVATE__ /* Pick up the publicly visible enums formerly sited here */ #include "fenv.h" /* Macros to get or set environment flags doubleword */ #define FEGETENVD(x) ({ __label__ L1, L2; L1: (void)&&L1; \ asm volatile ("mffs %0" : "=f" (x)); \ L2: (void)&&L2; }) #define FESETENVD(x) ({ __label__ L1, L2; L1: (void)&&L1; \ asm volatile("mtfsf 255,%0" : : "f" (x)); \ L2: (void)&&L2; }) /* Macros to get or set environment flags doubleword in their own dispatch group */ #define FEGETENVD_GRP(x) ({ __label__ L1, L2; L1: (void)&&L1; \ asm volatile ("mffs %0" : "=f" (x)); \ L2: (void)&&L2; __NOOP; __NOOP; __NOOP; }) #define FESETENVD_GRP(x) ({ __label__ L1, L2; __NOOP; __NOOP; __NOOP; L1: (void)&&L1; \ asm volatile ("mtfsf 255,%0" : : "f" (x)); \ L2: (void)&&L2;}) /* exception flags */ #define FE_SET_FX 0x80000000 /* floating-point exception summary (FX) bit */ #define FE_CLR_FX 0x7fffffff #define SET_INVALID 0x01000000 /* the bitwise negation (one's complement) of FE_ALL_EXCEPT */ #define FE_NO_EXCEPT 0xc1ffffff /* the bitwise OR of all of the separate exception bits in the FPSCR */ #define FE_ALL_FLAGS 0xfff80300 /* the bitwise negation (one's complement) of the previous macro */ #define FE_NO_FLAGS 0x0007fcff /* the bitwise OR of all of the separate invalid stickies in the FPSCR */ #define FE_ALL_INVALID 0x01f80300 /* the bitwise negation (one's complement) of the previous macro */ #define FE_NO_INVALID 0xfe07fcff /* an AND mask to disable all floating-point exception enables in the FPSCR */ #define FE_NO_ENABLES 0xffffff07 /* rounding direction mode bits */ #define FE_ALL_RND 0x00000003 #define FE_NO_RND 0xfffffffc #define EXCEPT_MASK 0x1ff80000 #endif /* __FENV_PRIVATE__ */
darlinghq/darling
src/libm/Source/PowerPC/fenv_private.h
C
gpl-3.0
3,594
/* * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h" #include <assert.h> // assert #include <math.h> // pow() #include <string.h> // memcpy() #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/trace.h" #include "webrtc/system_wrappers/interface/trace_event.h" namespace webrtc { RTPReceiverStrategy* RTPReceiverStrategy::CreateAudioStrategy( int32_t id, RtpData* data_callback, RtpAudioFeedback* incoming_messages_callback) { return new RTPReceiverAudio(id, data_callback, incoming_messages_callback); } RTPReceiverAudio::RTPReceiverAudio(const int32_t id, RtpData* data_callback, RtpAudioFeedback* incoming_messages_callback) : RTPReceiverStrategy(data_callback), TelephoneEventHandler(), id_(id), last_received_frequency_(8000), telephone_event_forward_to_decoder_(false), telephone_event_payload_type_(-1), cng_nb_payload_type_(-1), cng_wb_payload_type_(-1), cng_swb_payload_type_(-1), cng_fb_payload_type_(-1), cng_payload_type_(-1), g722_payload_type_(-1), last_received_g722_(false), num_energy_(0), current_remote_energy_(), cb_audio_feedback_(incoming_messages_callback) { last_payload_.Audio.channels = 1; memset(current_remote_energy_, 0, sizeof(current_remote_energy_)); } // Outband TelephoneEvent(DTMF) detection void RTPReceiverAudio::SetTelephoneEventForwardToDecoder( bool forward_to_decoder) { CriticalSectionScoped lock(crit_sect_.get()); telephone_event_forward_to_decoder_ = forward_to_decoder; } // Is forwarding of outband telephone events turned on/off? bool RTPReceiverAudio::TelephoneEventForwardToDecoder() const { CriticalSectionScoped lock(crit_sect_.get()); return telephone_event_forward_to_decoder_; } bool RTPReceiverAudio::TelephoneEventPayloadType( int8_t payload_type) const { CriticalSectionScoped lock(crit_sect_.get()); return (telephone_event_payload_type_ == payload_type) ? true : false; } bool RTPReceiverAudio::CNGPayloadType(int8_t payload_type, uint32_t* frequency, bool* cng_payload_type_has_changed) { CriticalSectionScoped lock(crit_sect_.get()); *cng_payload_type_has_changed = false; // We can have four CNG on 8000Hz, 16000Hz, 32000Hz and 48000Hz. if (cng_nb_payload_type_ == payload_type) { *frequency = 8000; if (cng_payload_type_ != -1 && cng_payload_type_ != cng_nb_payload_type_) *cng_payload_type_has_changed = true; cng_payload_type_ = cng_nb_payload_type_; return true; } else if (cng_wb_payload_type_ == payload_type) { // if last received codec is G.722 we must use frequency 8000 if (last_received_g722_) { *frequency = 8000; } else { *frequency = 16000; } if (cng_payload_type_ != -1 && cng_payload_type_ != cng_wb_payload_type_) *cng_payload_type_has_changed = true; cng_payload_type_ = cng_wb_payload_type_; return true; } else if (cng_swb_payload_type_ == payload_type) { *frequency = 32000; if ((cng_payload_type_ != -1) && (cng_payload_type_ != cng_swb_payload_type_)) *cng_payload_type_has_changed = true; cng_payload_type_ = cng_swb_payload_type_; return true; } else if (cng_fb_payload_type_ == payload_type) { *frequency = 48000; if (cng_payload_type_ != -1 && cng_payload_type_ != cng_fb_payload_type_) *cng_payload_type_has_changed = true; cng_payload_type_ = cng_fb_payload_type_; return true; } else { // not CNG if (g722_payload_type_ == payload_type) { last_received_g722_ = true; } else { last_received_g722_ = false; } } return false; } bool RTPReceiverAudio::ShouldReportCsrcChanges(uint8_t payload_type) const { // Don't do this for DTMF packets, otherwise it's fine. return !TelephoneEventPayloadType(payload_type); } // - Sample based or frame based codecs based on RFC 3551 // - // - NOTE! There is one error in the RFC, stating G.722 uses 8 bits/samples. // - The correct rate is 4 bits/sample. // - // - name of sampling default // - encoding sample/frame bits/sample rate ms/frame ms/packet // - // - Sample based audio codecs // - DVI4 sample 4 var. 20 // - G722 sample 4 16,000 20 // - G726-40 sample 5 8,000 20 // - G726-32 sample 4 8,000 20 // - G726-24 sample 3 8,000 20 // - G726-16 sample 2 8,000 20 // - L8 sample 8 var. 20 // - L16 sample 16 var. 20 // - PCMA sample 8 var. 20 // - PCMU sample 8 var. 20 // - // - Frame based audio codecs // - G723 frame N/A 8,000 30 30 // - G728 frame N/A 8,000 2.5 20 // - G729 frame N/A 8,000 10 20 // - G729D frame N/A 8,000 10 20 // - G729E frame N/A 8,000 10 20 // - GSM frame N/A 8,000 20 20 // - GSM-EFR frame N/A 8,000 20 20 // - LPC frame N/A 8,000 20 20 // - MPA frame N/A var. var. // - // - G7221 frame N/A int32_t RTPReceiverAudio::OnNewPayloadTypeCreated( const char payload_name[RTP_PAYLOAD_NAME_SIZE], int8_t payload_type, uint32_t frequency) { CriticalSectionScoped lock(crit_sect_.get()); if (ModuleRTPUtility::StringCompare(payload_name, "telephone-event", 15)) { telephone_event_payload_type_ = payload_type; } if (ModuleRTPUtility::StringCompare(payload_name, "cn", 2)) { // we can have three CNG on 8000Hz, 16000Hz and 32000Hz if (frequency == 8000) { cng_nb_payload_type_ = payload_type; } else if (frequency == 16000) { cng_wb_payload_type_ = payload_type; } else if (frequency == 32000) { cng_swb_payload_type_ = payload_type; } else if (frequency == 48000) { cng_fb_payload_type_ = payload_type; } else { assert(false); return -1; } } return 0; } int32_t RTPReceiverAudio::ParseRtpPacket(WebRtcRTPHeader* rtp_header, const PayloadUnion& specific_payload, bool is_red, const uint8_t* payload, uint16_t payload_length, int64_t timestamp_ms, bool is_first_packet) { TRACE_EVENT2("webrtc_rtp", "Audio::ParseRtp", "seqnum", rtp_header->header.sequenceNumber, "timestamp", rtp_header->header.timestamp); rtp_header->type.Audio.numEnergy = rtp_header->header.numCSRCs; num_energy_ = rtp_header->type.Audio.numEnergy; if (rtp_header->type.Audio.numEnergy > 0 && rtp_header->type.Audio.numEnergy <= kRtpCsrcSize) { memcpy(current_remote_energy_, rtp_header->type.Audio.arrOfEnergy, rtp_header->type.Audio.numEnergy); } return ParseAudioCodecSpecific(rtp_header, payload, payload_length, specific_payload.Audio, is_red); } int RTPReceiverAudio::GetPayloadTypeFrequency() const { CriticalSectionScoped lock(crit_sect_.get()); if (last_received_g722_) { return 8000; } return last_received_frequency_; } RTPAliveType RTPReceiverAudio::ProcessDeadOrAlive( uint16_t last_payload_length) const { // Our CNG is 9 bytes; if it's a likely CNG the receiver needs to check // kRtpNoRtp against NetEq speech_type kOutputPLCtoCNG. if (last_payload_length < 10) { // our CNG is 9 bytes return kRtpNoRtp; } else { return kRtpDead; } } void RTPReceiverAudio::CheckPayloadChanged(int8_t payload_type, PayloadUnion* specific_payload, bool* should_reset_statistics, bool* should_discard_changes) { *should_discard_changes = false; *should_reset_statistics = false; if (TelephoneEventPayloadType(payload_type)) { // Don't do callbacks for DTMF packets. *should_discard_changes = true; return; } // frequency is updated for CNG bool cng_payload_type_has_changed = false; bool is_cng_payload_type = CNGPayloadType(payload_type, &specific_payload->Audio.frequency, &cng_payload_type_has_changed); *should_reset_statistics = cng_payload_type_has_changed; if (is_cng_payload_type) { // Don't do callbacks for DTMF packets. *should_discard_changes = true; return; } } int RTPReceiverAudio::Energy(uint8_t array_of_energy[kRtpCsrcSize]) const { CriticalSectionScoped cs(crit_sect_.get()); assert(num_energy_ <= kRtpCsrcSize); if (num_energy_ > 0) { memcpy(array_of_energy, current_remote_energy_, sizeof(uint8_t) * num_energy_); } return num_energy_; } int32_t RTPReceiverAudio::InvokeOnInitializeDecoder( RtpFeedback* callback, int32_t id, int8_t payload_type, const char payload_name[RTP_PAYLOAD_NAME_SIZE], const PayloadUnion& specific_payload) const { if (-1 == callback->OnInitializeDecoder(id, payload_type, payload_name, specific_payload.Audio.frequency, specific_payload.Audio.channels, specific_payload.Audio.rate)) { WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, id, "Failed to create video decoder for payload type:%d", payload_type); return -1; } return 0; } // We are not allowed to have any critsects when calling data_callback. int32_t RTPReceiverAudio::ParseAudioCodecSpecific( WebRtcRTPHeader* rtp_header, const uint8_t* payload_data, uint16_t payload_length, const AudioPayload& audio_specific, bool is_red) { if (payload_length == 0) { return 0; } bool telephone_event_packet = TelephoneEventPayloadType(rtp_header->header.payloadType); if (telephone_event_packet) { CriticalSectionScoped lock(crit_sect_.get()); // RFC 4733 2.3 // 0 1 2 3 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // | event |E|R| volume | duration | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // if (payload_length % 4 != 0) { return -1; } uint8_t number_of_events = payload_length / 4; // sanity if (number_of_events >= MAX_NUMBER_OF_PARALLEL_TELEPHONE_EVENTS) { number_of_events = MAX_NUMBER_OF_PARALLEL_TELEPHONE_EVENTS; } for (int n = 0; n < number_of_events; ++n) { bool end = (payload_data[(4 * n) + 1] & 0x80) ? true : false; std::set<uint8_t>::iterator event = telephone_event_reported_.find(payload_data[4 * n]); if (event != telephone_event_reported_.end()) { // we have already seen this event if (end) { telephone_event_reported_.erase(payload_data[4 * n]); } } else { if (end) { // don't add if it's a end of a tone } else { telephone_event_reported_.insert(payload_data[4 * n]); } } } // RFC 4733 2.5.1.3 & 2.5.2.3 Long-Duration Events // should not be a problem since we don't care about the duration // RFC 4733 See 2.5.1.5. & 2.5.2.4. Multiple Events in a Packet } { CriticalSectionScoped lock(crit_sect_.get()); if (!telephone_event_packet) { last_received_frequency_ = audio_specific.frequency; } // Check if this is a CNG packet, receiver might want to know uint32_t ignored; bool also_ignored; if (CNGPayloadType(rtp_header->header.payloadType, &ignored, &also_ignored)) { rtp_header->type.Audio.isCNG = true; rtp_header->frameType = kAudioFrameCN; } else { rtp_header->frameType = kAudioFrameSpeech; rtp_header->type.Audio.isCNG = false; } // check if it's a DTMF event, hence something we can playout if (telephone_event_packet) { if (!telephone_event_forward_to_decoder_) { // don't forward event to decoder return 0; } std::set<uint8_t>::iterator first = telephone_event_reported_.begin(); if (first != telephone_event_reported_.end() && *first > 15) { // don't forward non DTMF events return 0; } } } // TODO(holmer): Break this out to have RED parsing handled generically. if (is_red && !(payload_data[0] & 0x80)) { // we recive only one frame packed in a RED packet remove the RED wrapper rtp_header->header.payloadType = payload_data[0]; // only one frame in the RED strip the one byte to help NetEq return data_callback_->OnReceivedPayloadData( payload_data + 1, payload_length - 1, rtp_header); } rtp_header->type.Audio.channel = audio_specific.channels; return data_callback_->OnReceivedPayloadData( payload_data, payload_length, rtp_header); } } // namespace webrtc
liyouchang/webrtc-qt
webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.cc
C++
gpl-3.0
14,655
/* Unix SMB/CIFS implementation. Core SMB2 server Copyright (C) Stefan Metzmacher 2009 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 "includes.h" #include "smbd/smbd.h" #include "smbd/globals.h" #include "../libcli/smb/smb_common.h" #include "trans2.h" #include "../lib/util/tevent_ntstatus.h" static struct tevent_req *smbd_smb2_find_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct smbd_smb2_request *smb2req, struct files_struct *in_fsp, uint8_t in_file_info_class, uint8_t in_flags, uint32_t in_file_index, uint32_t in_output_buffer_length, const char *in_file_name); static NTSTATUS smbd_smb2_find_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, DATA_BLOB *out_output_buffer); static void smbd_smb2_request_find_done(struct tevent_req *subreq); NTSTATUS smbd_smb2_request_process_find(struct smbd_smb2_request *req) { NTSTATUS status; const uint8_t *inbody; uint8_t in_file_info_class; uint8_t in_flags; uint32_t in_file_index; uint64_t in_file_id_persistent; uint64_t in_file_id_volatile; struct files_struct *in_fsp; uint16_t in_file_name_offset; uint16_t in_file_name_length; DATA_BLOB in_file_name_buffer; char *in_file_name_string; size_t in_file_name_string_size; uint32_t in_output_buffer_length; struct tevent_req *subreq; bool ok; status = smbd_smb2_request_verify_sizes(req, 0x21); if (!NT_STATUS_IS_OK(status)) { return smbd_smb2_request_error(req, status); } inbody = SMBD_SMB2_IN_BODY_PTR(req); in_file_info_class = CVAL(inbody, 0x02); in_flags = CVAL(inbody, 0x03); in_file_index = IVAL(inbody, 0x04); in_file_id_persistent = BVAL(inbody, 0x08); in_file_id_volatile = BVAL(inbody, 0x10); in_file_name_offset = SVAL(inbody, 0x18); in_file_name_length = SVAL(inbody, 0x1A); in_output_buffer_length = IVAL(inbody, 0x1C); if (in_file_name_offset == 0 && in_file_name_length == 0) { /* This is ok */ } else if (in_file_name_offset != (SMB2_HDR_BODY + SMBD_SMB2_IN_BODY_LEN(req))) { return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER); } if (in_file_name_length > SMBD_SMB2_IN_DYN_LEN(req)) { return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER); } /* The output header is 8 bytes. */ if (in_output_buffer_length <= 8) { return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER); } DEBUG(10,("smbd_smb2_request_find_done: in_output_buffer_length = %u\n", (unsigned int)in_output_buffer_length )); /* Take into account the output header. */ in_output_buffer_length -= 8; in_file_name_buffer.data = SMBD_SMB2_IN_DYN_PTR(req); in_file_name_buffer.length = in_file_name_length; ok = convert_string_talloc(req, CH_UTF16, CH_UNIX, in_file_name_buffer.data, in_file_name_buffer.length, &in_file_name_string, &in_file_name_string_size); if (!ok) { return smbd_smb2_request_error(req, NT_STATUS_ILLEGAL_CHARACTER); } if (in_file_name_buffer.length == 0) { in_file_name_string_size = 0; } if (strlen(in_file_name_string) != in_file_name_string_size) { return smbd_smb2_request_error(req, NT_STATUS_OBJECT_NAME_INVALID); } in_fsp = file_fsp_smb2(req, in_file_id_persistent, in_file_id_volatile); if (in_fsp == NULL) { return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED); } subreq = smbd_smb2_find_send(req, req->sconn->ev_ctx, req, in_fsp, in_file_info_class, in_flags, in_file_index, in_output_buffer_length, in_file_name_string); if (subreq == NULL) { return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY); } tevent_req_set_callback(subreq, smbd_smb2_request_find_done, req); return smbd_smb2_request_pending_queue(req, subreq, 500); } static void smbd_smb2_request_find_done(struct tevent_req *subreq) { struct smbd_smb2_request *req = tevent_req_callback_data(subreq, struct smbd_smb2_request); DATA_BLOB outbody; DATA_BLOB outdyn; uint16_t out_output_buffer_offset; DATA_BLOB out_output_buffer = data_blob_null; NTSTATUS status; NTSTATUS error; /* transport error */ status = smbd_smb2_find_recv(subreq, req, &out_output_buffer); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { error = smbd_smb2_request_error(req, status); if (!NT_STATUS_IS_OK(error)) { smbd_server_connection_terminate(req->sconn, nt_errstr(error)); return; } return; } out_output_buffer_offset = SMB2_HDR_BODY + 0x08; outbody = data_blob_talloc(req->out.vector, NULL, 0x08); if (outbody.data == NULL) { error = smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY); if (!NT_STATUS_IS_OK(error)) { smbd_server_connection_terminate(req->sconn, nt_errstr(error)); return; } return; } SSVAL(outbody.data, 0x00, 0x08 + 1); /* struct size */ SSVAL(outbody.data, 0x02, out_output_buffer_offset); /* output buffer offset */ SIVAL(outbody.data, 0x04, out_output_buffer.length); /* output buffer length */ DEBUG(10,("smbd_smb2_request_find_done: out_output_buffer.length = %u\n", (unsigned int)out_output_buffer.length )); outdyn = out_output_buffer; error = smbd_smb2_request_done(req, outbody, &outdyn); if (!NT_STATUS_IS_OK(error)) { smbd_server_connection_terminate(req->sconn, nt_errstr(error)); return; } } struct smbd_smb2_find_state { struct smbd_smb2_request *smb2req; DATA_BLOB out_output_buffer; }; static struct tevent_req *smbd_smb2_find_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct smbd_smb2_request *smb2req, struct files_struct *fsp, uint8_t in_file_info_class, uint8_t in_flags, uint32_t in_file_index, uint32_t in_output_buffer_length, const char *in_file_name) { struct tevent_req *req; struct smbd_smb2_find_state *state; struct smb_request *smbreq; connection_struct *conn = smb2req->tcon->compat; NTSTATUS status; NTSTATUS empty_status; uint32_t info_level; uint32_t max_count; char *pdata; char *base_data; char *end_data; int last_entry_off = 0; int off = 0; uint32_t num = 0; uint32_t dirtype = FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_DIRECTORY; bool dont_descend = false; bool ask_sharemode = true; req = tevent_req_create(mem_ctx, &state, struct smbd_smb2_find_state); if (req == NULL) { return NULL; } state->smb2req = smb2req; state->out_output_buffer = data_blob_null; DEBUG(10,("smbd_smb2_find_send: %s - %s\n", fsp_str_dbg(fsp), fsp_fnum_dbg(fsp))); smbreq = smbd_smb2_fake_smb_request(smb2req); if (tevent_req_nomem(smbreq, req)) { return tevent_req_post(req, ev); } if (!fsp->is_directory) { tevent_req_nterror(req, NT_STATUS_NOT_SUPPORTED); return tevent_req_post(req, ev); } if (strcmp(in_file_name, "") == 0) { tevent_req_nterror(req, NT_STATUS_OBJECT_NAME_INVALID); return tevent_req_post(req, ev); } if (strcmp(in_file_name, "\\") == 0) { tevent_req_nterror(req, NT_STATUS_OBJECT_NAME_INVALID); return tevent_req_post(req, ev); } if (strcmp(in_file_name, "/") == 0) { tevent_req_nterror(req, NT_STATUS_OBJECT_NAME_INVALID); return tevent_req_post(req, ev); } if (in_output_buffer_length > smb2req->sconn->smb2.max_trans) { DEBUG(2,("smbd_smb2_find_send: " "client ignored max trans:%s: 0x%08X: 0x%08X\n", __location__, in_output_buffer_length, smb2req->sconn->smb2.max_trans)); tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER); return tevent_req_post(req, ev); } status = smbd_smb2_request_verify_creditcharge(smb2req, in_output_buffer_length); if (!NT_STATUS_IS_OK(status)) { tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER); return tevent_req_post(req, ev); } switch (in_file_info_class) { case SMB2_FIND_DIRECTORY_INFO: info_level = SMB_FIND_FILE_DIRECTORY_INFO; break; case SMB2_FIND_FULL_DIRECTORY_INFO: info_level = SMB_FIND_FILE_FULL_DIRECTORY_INFO; break; case SMB2_FIND_BOTH_DIRECTORY_INFO: info_level = SMB_FIND_FILE_BOTH_DIRECTORY_INFO; break; case SMB2_FIND_NAME_INFO: info_level = SMB_FIND_FILE_NAMES_INFO; break; case SMB2_FIND_ID_BOTH_DIRECTORY_INFO: info_level = SMB_FIND_ID_BOTH_DIRECTORY_INFO; break; case SMB2_FIND_ID_FULL_DIRECTORY_INFO: info_level = SMB_FIND_ID_FULL_DIRECTORY_INFO; break; default: tevent_req_nterror(req, NT_STATUS_INVALID_INFO_CLASS); return tevent_req_post(req, ev); } if (in_flags & SMB2_CONTINUE_FLAG_REOPEN) { dptr_CloseDir(fsp); } if (fsp->dptr == NULL) { bool wcard_has_wild; wcard_has_wild = ms_has_wild(in_file_name); status = dptr_create(conn, NULL, /* req */ fsp, fsp->fsp_name->base_name, false, /* old_handle */ false, /* expect_close */ 0, /* spid */ in_file_name, /* wcard */ wcard_has_wild, dirtype, &fsp->dptr); if (!NT_STATUS_IS_OK(status)) { tevent_req_nterror(req, status); return tevent_req_post(req, ev); } empty_status = NT_STATUS_NO_SUCH_FILE; } else { empty_status = STATUS_NO_MORE_FILES; } if (in_flags & SMB2_CONTINUE_FLAG_RESTART) { dptr_SeekDir(fsp->dptr, 0); } if (in_flags & SMB2_CONTINUE_FLAG_SINGLE) { max_count = 1; } else { max_count = UINT16_MAX; } #define DIR_ENTRY_SAFETY_MARGIN 4096 state->out_output_buffer = data_blob_talloc(state, NULL, in_output_buffer_length + DIR_ENTRY_SAFETY_MARGIN); if (tevent_req_nomem(state->out_output_buffer.data, req)) { return tevent_req_post(req, ev); } state->out_output_buffer.length = 0; pdata = (char *)state->out_output_buffer.data; base_data = pdata; /* * end_data must include the safety margin as it's what is * used to determine if pushed strings have been truncated. */ end_data = pdata + in_output_buffer_length + DIR_ENTRY_SAFETY_MARGIN - 1; last_entry_off = 0; off = 0; num = 0; DEBUG(8,("smbd_smb2_find_send: dirpath=<%s> dontdescend=<%s>, " "in_output_buffer_length = %u\n", fsp->fsp_name->base_name, lp_dontdescend(talloc_tos(), SNUM(conn)), (unsigned int)in_output_buffer_length )); if (in_list(fsp->fsp_name->base_name,lp_dontdescend(talloc_tos(), SNUM(conn)), conn->case_sensitive)) { dont_descend = true; } ask_sharemode = lp_parm_bool(SNUM(conn), "smbd", "search ask sharemode", true); while (true) { bool ok; bool got_exact_match = false; bool out_of_space = false; int space_remaining = in_output_buffer_length - off; SMB_ASSERT(space_remaining >= 0); ok = smbd_dirptr_lanman2_entry(state, conn, fsp->dptr, smbreq->flags2, in_file_name, dirtype, info_level, false, /* requires_resume_key */ dont_descend, ask_sharemode, 8, /* align to 8 bytes */ false, /* no padding */ &pdata, base_data, end_data, space_remaining, &out_of_space, &got_exact_match, &last_entry_off, NULL); off = (int)PTR_DIFF(pdata, base_data); if (!ok) { if (num > 0) { SIVAL(state->out_output_buffer.data, last_entry_off, 0); tevent_req_done(req); return tevent_req_post(req, ev); } else if (out_of_space) { tevent_req_nterror(req, NT_STATUS_INFO_LENGTH_MISMATCH); return tevent_req_post(req, ev); } else { tevent_req_nterror(req, empty_status); return tevent_req_post(req, ev); } } num++; state->out_output_buffer.length = off; if (num < max_count) { continue; } SIVAL(state->out_output_buffer.data, last_entry_off, 0); tevent_req_done(req); return tevent_req_post(req, ev); } tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR); return tevent_req_post(req, ev); } static NTSTATUS smbd_smb2_find_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, DATA_BLOB *out_output_buffer) { NTSTATUS status; struct smbd_smb2_find_state *state = tevent_req_data(req, struct smbd_smb2_find_state); if (tevent_req_is_nterror(req, &status)) { tevent_req_received(req); return status; } *out_output_buffer = state->out_output_buffer; talloc_steal(mem_ctx, out_output_buffer->data); tevent_req_received(req); return NT_STATUS_OK; }
framon/samba
source3/smbd/smb2_find.c
C
gpl-3.0
12,954
# -*- coding: utf-8 -*- from south.v2 import SchemaMigration class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass models = { } complete_apps = ['admin']
Karaage-Cluster/karaage-debian
karaage/legacy/admin/south_migrations/0004_auto__del_logentry.py
Python
gpl-3.0
237
package dna.parallel.nodeAssignment; import dna.parallel.partition.AllPartitions; import dna.updates.batch.Batch; import dna.updates.update.NodeAddition; public class RoundRobinNodeAssignment extends NodeAssignment { protected int counter = 0; public RoundRobinNodeAssignment(int partitionCount) { super(partitionCount); } @SuppressWarnings("rawtypes") @Override public int assignNode(AllPartitions all, Batch b, NodeAddition na) { this.counter = (this.counter + 1) % this.partitionCount; return this.counter; } }
Rwilmes/DNA
src/dna/parallel/nodeAssignment/RoundRobinNodeAssignment.java
Java
gpl-3.0
533
<?php /** * @package Mautic * @copyright 2014 Mautic Contributors. All rights reserved. * @author Mautic * @link http://mautic.org * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ namespace Mautic\LeadBundle\EventListener; use Doctrine\DBAL\Types\StringType; use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs; use Doctrine\ORM\Tools\ToolEvents; use Mautic\LeadBundle\Model\FieldModel; /** * Class DoctrineSubscriber */ class DoctrineSubscriber implements \Doctrine\Common\EventSubscriber { /** * @return array */ public function getSubscribedEvents() { return array( ToolEvents::postGenerateSchema ); } /** * @param GenerateSchemaEventArgs $args */ public function postGenerateSchema(GenerateSchemaEventArgs $args) { $schema = $args->getSchema(); try { if (!$schema->hasTable(MAUTIC_TABLE_PREFIX.'lead_fields')) { return; } $table = $schema->getTable(MAUTIC_TABLE_PREFIX.'leads'); //get a list of fields $fields = $args->getEntityManager()->getConnection()->createQueryBuilder() ->select('f.alias, f.is_unique_identifer as is_unique, f.type') ->from(MAUTIC_TABLE_PREFIX.'lead_fields', 'f') ->orderBy('f.field_order', 'ASC') ->execute()->fetchAll(); // Compile which ones are unique identifiers // Email will always be included first $uniqueFields = array('email' => 'email'); foreach ($fields as $f) { if ($f['is_unique'] && $f['alias'] != 'email') { $uniqueFields[$f['alias']] = $f['alias']; } $columnDef = FieldModel::getSchemaDefinition($f['alias'], $f['type'], !empty($f['is_unique'])); $table->addColumn($columnDef['name'], $columnDef['type'], $columnDef['options']); $indexOptions = ($columnDef['type'] == 'text') ? ['where' => "({$columnDef['name']}(767))"] : []; $table->addIndex(array($f['alias']), MAUTIC_TABLE_PREFIX.$f['alias'].'_search', $indexOptions); } // Only allow indexes for string types $columns = $table->getColumns(); /** @var \Doctrine\DBAL\Schema\Column $column */ foreach ($columns as $column) { $type = $column->getType(); $name = $column->getName(); if (!$type instanceof StringType) { unset($uniqueFields[$name]); } elseif (isset($uniqueFields[$name])) { $uniqueFields[$name] = $uniqueFields[$name]; } } if (count($uniqueFields) > 1) { // Only use three to prevent max key length errors $uniqueFields = array_slice($uniqueFields, 0, 3); $table->addIndex($uniqueFields, MAUTIC_TABLE_PREFIX.'unique_identifier_search'); } $table->addIndex(['attribution', 'attribution_date'], MAUTIC_TABLE_PREFIX.'contact_attribution'); } catch (\Exception $e) { //table doesn't exist or something bad happened so oh well error_log($e->getMessage()); } } }
bags307/marketing_automation
app/bundles/LeadBundle/EventListener/DoctrineSubscriber.php
PHP
gpl-3.0
3,347
/* * Copyright (C) 2010, Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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. */ #include "config.h" #include "core/inspector/InspectorCSSAgent.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/ExceptionStatePlaceholder.h" #include "core/CSSPropertyNames.h" #include "core/InspectorTypeBuilder.h" #include "core/StylePropertyShorthand.h" #include "core/css/CSSComputedStyleDeclaration.h" #include "core/css/CSSDefaultStyleSheets.h" #include "core/css/CSSImportRule.h" #include "core/css/CSSMediaRule.h" #include "core/css/CSSRule.h" #include "core/css/CSSRuleList.h" #include "core/css/CSSStyleRule.h" #include "core/css/CSSStyleSheet.h" #include "core/css/MediaList.h" #include "core/css/MediaQuery.h" #include "core/css/MediaValues.h" #include "core/css/StylePropertySet.h" #include "core/css/StyleRule.h" #include "core/css/StyleSheet.h" #include "core/css/StyleSheetContents.h" #include "core/css/StyleSheetList.h" #include "core/css/parser/CSSParser.h" #include "core/css/resolver/StyleResolver.h" #include "core/dom/Node.h" #include "core/dom/StyleEngine.h" #include "core/dom/Text.h" #include "core/frame/LocalFrame.h" #include "core/html/HTMLHeadElement.h" #include "core/html/VoidCallback.h" #include "core/inspector/InspectorHistory.h" #include "core/inspector/InspectorPageAgent.h" #include "core/inspector/InspectorResourceAgent.h" #include "core/inspector/InspectorResourceContentLoader.h" #include "core/inspector/InspectorState.h" #include "core/inspector/InstrumentingAgents.h" #include "core/layout/LayoutObject.h" #include "core/layout/LayoutObjectInlines.h" #include "core/layout/LayoutText.h" #include "core/layout/LayoutTextFragment.h" #include "core/layout/line/InlineTextBox.h" #include "core/loader/DocumentLoader.h" #include "core/page/Page.h" #include "platform/fonts/Font.h" #include "platform/fonts/GlyphBuffer.h" #include "platform/fonts/shaping/SimpleShaper.h" #include "platform/text/TextRun.h" #include "wtf/CurrentTime.h" #include "wtf/text/CString.h" #include "wtf/text/StringConcatenate.h" namespace { using namespace blink; String createShorthandValue(Document* document, const String& shorthand, const String& oldText, const String& longhand, const String& newValue) { RefPtrWillBeRawPtr<StyleSheetContents> styleSheetContents = StyleSheetContents::create(strictCSSParserContext()); String text = " div { " + shorthand + ": " + oldText + "; }"; CSSParser::parseSheet(CSSParserContext(*document, 0), styleSheetContents.get(), text); RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet = CSSStyleSheet::create(styleSheetContents); CSSStyleRule* rule = toCSSStyleRule(styleSheet->item(0)); CSSStyleDeclaration* style = rule->style(); TrackExceptionState exceptionState; style->setProperty(longhand, newValue, style->getPropertyPriority(longhand), exceptionState); return style->getPropertyValue(shorthand); } } // namespace namespace CSSAgentState { static const char cssAgentEnabled[] = "cssAgentEnabled"; } typedef blink::InspectorBackendDispatcher::CSSCommandHandler::EnableCallback EnableCallback; namespace blink { enum ForcePseudoClassFlags { PseudoNone = 0, PseudoHover = 1 << 0, PseudoFocus = 1 << 1, PseudoActive = 1 << 2, PseudoVisited = 1 << 3 }; static unsigned computePseudoClassMask(JSONArray* pseudoClassArray) { DEFINE_STATIC_LOCAL(String, active, ("active")); DEFINE_STATIC_LOCAL(String, hover, ("hover")); DEFINE_STATIC_LOCAL(String, focus, ("focus")); DEFINE_STATIC_LOCAL(String, visited, ("visited")); if (!pseudoClassArray || !pseudoClassArray->length()) return PseudoNone; unsigned result = PseudoNone; for (size_t i = 0; i < pseudoClassArray->length(); ++i) { RefPtr<JSONValue> pseudoClassValue = pseudoClassArray->get(i); String pseudoClass; bool success = pseudoClassValue->asString(&pseudoClass); if (!success) continue; if (pseudoClass == active) result |= PseudoActive; else if (pseudoClass == hover) result |= PseudoHover; else if (pseudoClass == focus) result |= PseudoFocus; else if (pseudoClass == visited) result |= PseudoVisited; } return result; } class InspectorCSSAgent::StyleSheetAction : public InspectorHistory::Action { WTF_MAKE_NONCOPYABLE(StyleSheetAction); public: StyleSheetAction(const String& name) : InspectorHistory::Action(name) { } }; class InspectorCSSAgent::InspectorResourceContentLoaderCallback final : public VoidCallback { public: InspectorResourceContentLoaderCallback(InspectorCSSAgent*, PassRefPtrWillBeRawPtr<EnableCallback>); DECLARE_VIRTUAL_TRACE(); virtual void handleEvent() override; private: RawPtrWillBeMember<InspectorCSSAgent> m_cssAgent; RefPtrWillBeMember<EnableCallback> m_callback; }; InspectorCSSAgent::InspectorResourceContentLoaderCallback::InspectorResourceContentLoaderCallback(InspectorCSSAgent* cssAgent, PassRefPtrWillBeRawPtr<EnableCallback> callback) : m_cssAgent(cssAgent) , m_callback(callback) { } DEFINE_TRACE(InspectorCSSAgent::InspectorResourceContentLoaderCallback) { visitor->trace(m_cssAgent); visitor->trace(m_callback); VoidCallback::trace(visitor); } void InspectorCSSAgent::InspectorResourceContentLoaderCallback::handleEvent() { // enable always succeeds. if (!m_callback->isActive()) return; m_cssAgent->wasEnabled(); m_callback->sendSuccess(); } class InspectorCSSAgent::SetStyleSheetTextAction final : public InspectorCSSAgent::StyleSheetAction { WTF_MAKE_NONCOPYABLE(SetStyleSheetTextAction); public: SetStyleSheetTextAction(InspectorStyleSheetBase* styleSheet, const String& text) : InspectorCSSAgent::StyleSheetAction("SetStyleSheetText") , m_styleSheet(styleSheet) , m_text(text) { } virtual bool perform(ExceptionState& exceptionState) override { if (!m_styleSheet->getText(&m_oldText)) return false; return redo(exceptionState); } virtual bool undo(ExceptionState& exceptionState) override { return m_styleSheet->setText(m_oldText, exceptionState); } virtual bool redo(ExceptionState& exceptionState) override { return m_styleSheet->setText(m_text, exceptionState); } virtual String mergeId() override { return String::format("SetStyleSheetText %s", m_styleSheet->id().utf8().data()); } virtual void merge(PassRefPtrWillBeRawPtr<Action> action) override { ASSERT(action->mergeId() == mergeId()); SetStyleSheetTextAction* other = static_cast<SetStyleSheetTextAction*>(action.get()); m_text = other->m_text; } DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_styleSheet); InspectorCSSAgent::StyleSheetAction::trace(visitor); } private: RefPtrWillBeMember<InspectorStyleSheetBase> m_styleSheet; String m_text; String m_oldText; }; class InspectorCSSAgent::ModifyRuleAction final : public InspectorCSSAgent::StyleSheetAction { WTF_MAKE_NONCOPYABLE(ModifyRuleAction); public: enum Type { SetRuleSelector, SetStyleText, SetMediaRuleText }; ModifyRuleAction(Type type, InspectorStyleSheet* styleSheet, const SourceRange& range, const String& text) : InspectorCSSAgent::StyleSheetAction("ModifyRuleAction") , m_styleSheet(styleSheet) , m_type(type) , m_newText(text) , m_oldRange(range) , m_cssRule(nullptr) { } virtual bool perform(ExceptionState& exceptionState) override { return redo(exceptionState); } virtual bool undo(ExceptionState& exceptionState) override { switch (m_type) { case SetRuleSelector: return m_styleSheet->setRuleSelector(m_newRange, m_oldText, nullptr, nullptr, exceptionState); case SetStyleText: return m_styleSheet->setStyleText(m_newRange, m_oldText, nullptr, nullptr, exceptionState); case SetMediaRuleText: return m_styleSheet->setMediaRuleText(m_newRange, m_oldText, nullptr, nullptr, exceptionState); default: ASSERT_NOT_REACHED(); } return false; } virtual bool redo(ExceptionState& exceptionState) override { switch (m_type) { case SetRuleSelector: m_cssRule = m_styleSheet->setRuleSelector(m_oldRange, m_newText, &m_newRange, &m_oldText, exceptionState); break; case SetStyleText: m_cssRule = m_styleSheet->setStyleText(m_oldRange, m_newText, &m_newRange, &m_oldText, exceptionState); break; case SetMediaRuleText: m_cssRule = m_styleSheet->setMediaRuleText(m_oldRange, m_newText, &m_newRange, &m_oldText, exceptionState); break; default: ASSERT_NOT_REACHED(); } return m_cssRule; } RefPtrWillBeRawPtr<CSSRule> takeRule() { RefPtrWillBeRawPtr<CSSRule> result = m_cssRule; m_cssRule = nullptr; return result; } DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_styleSheet); visitor->trace(m_cssRule); InspectorCSSAgent::StyleSheetAction::trace(visitor); } virtual String mergeId() override { return String::format("ModifyRuleAction:%d %s:%d", m_type, m_styleSheet->id().utf8().data(), m_oldRange.start); } virtual bool isNoop() override { return m_oldText == m_newText; } virtual void merge(PassRefPtrWillBeRawPtr<Action> action) override { ASSERT(action->mergeId() == mergeId()); ModifyRuleAction* other = static_cast<ModifyRuleAction*>(action.get()); m_newText = other->m_newText; m_newRange = other->m_newRange; } private: RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; Type m_type; String m_oldText; String m_newText; SourceRange m_oldRange; SourceRange m_newRange; RefPtrWillBeMember<CSSRule> m_cssRule; }; class InspectorCSSAgent::SetElementStyleAction final : public InspectorCSSAgent::StyleSheetAction { WTF_MAKE_NONCOPYABLE(SetElementStyleAction); public: SetElementStyleAction(InspectorStyleSheetForInlineStyle* styleSheet, const String& text) : InspectorCSSAgent::StyleSheetAction("SetElementStyleAction") , m_styleSheet(styleSheet) , m_text(text) { } virtual bool perform(ExceptionState& exceptionState) override { return redo(exceptionState); } virtual bool undo(ExceptionState& exceptionState) override { return m_styleSheet->setText(m_oldText, exceptionState); } virtual bool redo(ExceptionState& exceptionState) override { if (!m_styleSheet->getText(&m_oldText)) return false; return m_styleSheet->setText(m_text, exceptionState); } DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_styleSheet); InspectorCSSAgent::StyleSheetAction::trace(visitor); } virtual String mergeId() override { return String::format("SetElementStyleAction:%s", m_styleSheet->id().utf8().data()); } virtual void merge(PassRefPtrWillBeRawPtr<Action> action) override { ASSERT(action->mergeId() == mergeId()); SetElementStyleAction* other = static_cast<SetElementStyleAction*>(action.get()); m_text = other->m_text; } private: RefPtrWillBeMember<InspectorStyleSheetForInlineStyle> m_styleSheet; String m_text; String m_oldText; }; class InspectorCSSAgent::AddRuleAction final : public InspectorCSSAgent::StyleSheetAction { WTF_MAKE_NONCOPYABLE(AddRuleAction); public: AddRuleAction(InspectorStyleSheet* styleSheet, const String& ruleText, const SourceRange& location) : InspectorCSSAgent::StyleSheetAction("AddRule") , m_styleSheet(styleSheet) , m_ruleText(ruleText) , m_location(location) { } virtual bool perform(ExceptionState& exceptionState) override { return redo(exceptionState); } virtual bool undo(ExceptionState& exceptionState) override { return m_styleSheet->deleteRule(m_addedRange, exceptionState); } virtual bool redo(ExceptionState& exceptionState) override { m_cssRule = m_styleSheet->addRule(m_ruleText, m_location, &m_addedRange, exceptionState); if (exceptionState.hadException()) return false; return true; } RefPtrWillBeRawPtr<CSSStyleRule> takeRule() { RefPtrWillBeRawPtr<CSSStyleRule> result = m_cssRule; m_cssRule = nullptr; return result; } DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_styleSheet); visitor->trace(m_cssRule); InspectorCSSAgent::StyleSheetAction::trace(visitor); } private: RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; RefPtrWillBeMember<CSSStyleRule> m_cssRule; String m_ruleText; String m_oldText; SourceRange m_location; SourceRange m_addedRange; }; // static CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule) { if (!rule || rule->type() != CSSRule::STYLE_RULE) return nullptr; return toCSSStyleRule(rule); } // static CSSMediaRule* InspectorCSSAgent::asCSSMediaRule(CSSRule* rule) { if (!rule || rule->type() != CSSRule::MEDIA_RULE) return nullptr; return toCSSMediaRule(rule); } InspectorCSSAgent::InspectorCSSAgent(InspectorDOMAgent* domAgent, InspectorPageAgent* pageAgent, InspectorResourceAgent* resourceAgent, InspectorResourceContentLoader* resourceContentLoader) : InspectorBaseAgent<InspectorCSSAgent, InspectorFrontend::CSS>("CSS") , m_domAgent(domAgent) , m_pageAgent(pageAgent) , m_resourceAgent(resourceAgent) , m_resourceContentLoader(resourceContentLoader) , m_creatingViaInspectorStyleSheet(false) , m_isSettingStyleSheetText(false) { m_domAgent->setDOMListener(this); } InspectorCSSAgent::~InspectorCSSAgent() { #if !ENABLE(OILPAN) ASSERT(!m_domAgent); reset(); #endif } void InspectorCSSAgent::discardAgent() { m_domAgent->setDOMListener(nullptr); m_domAgent = nullptr; } void InspectorCSSAgent::restore() { if (m_state->getBoolean(CSSAgentState::cssAgentEnabled)) wasEnabled(); } void InspectorCSSAgent::flushPendingProtocolNotifications() { if (!m_invalidatedDocuments.size()) return; WillBeHeapHashSet<RawPtrWillBeMember<Document> > invalidatedDocuments; m_invalidatedDocuments.swap(&invalidatedDocuments); for (Document* document: invalidatedDocuments) updateActiveStyleSheets(document, ExistingFrontendRefresh); } void InspectorCSSAgent::reset() { m_idToInspectorStyleSheet.clear(); m_idToInspectorStyleSheetForInlineStyle.clear(); m_cssStyleSheetToInspectorStyleSheet.clear(); m_documentToCSSStyleSheets.clear(); m_invalidatedDocuments.clear(); m_nodeToInspectorStyleSheet.clear(); m_documentToViaInspectorStyleSheet.clear(); resetNonPersistentData(); } void InspectorCSSAgent::resetNonPersistentData() { resetPseudoStates(); } void InspectorCSSAgent::enable(ErrorString* errorString, PassRefPtrWillBeRawPtr<EnableCallback> prpCallback) { if (!m_domAgent->enabled()) { *errorString = "DOM agent needs to be enabled first."; return; } m_state->setBoolean(CSSAgentState::cssAgentEnabled, true); m_resourceContentLoader->ensureResourcesContentLoaded(new InspectorCSSAgent::InspectorResourceContentLoaderCallback(this, prpCallback)); } void InspectorCSSAgent::wasEnabled() { if (!m_state->getBoolean(CSSAgentState::cssAgentEnabled)) { // We were disabled while fetching resources. return; } m_instrumentingAgents->setInspectorCSSAgent(this); WillBeHeapVector<RawPtrWillBeMember<Document> > documents = m_domAgent->documents(); for (Document* document : documents) updateActiveStyleSheets(document, InitialFrontendLoad); } void InspectorCSSAgent::disable(ErrorString*) { reset(); m_instrumentingAgents->setInspectorCSSAgent(0); m_state->setBoolean(CSSAgentState::cssAgentEnabled, false); } void InspectorCSSAgent::didCommitLoadForLocalFrame(LocalFrame* frame) { if (frame == m_pageAgent->inspectedFrame()) { reset(); m_editedStyleSheets.clear(); m_editedStyleElements.clear(); } } void InspectorCSSAgent::mediaQueryResultChanged() { flushPendingProtocolNotifications(); frontend()->mediaQueryResultChanged(); } void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document) { if (m_isSettingStyleSheetText) return; m_invalidatedDocuments.add(document); if (m_creatingViaInspectorStyleSheet) flushPendingProtocolNotifications(); } void InspectorCSSAgent::updateActiveStyleSheets(Document* document, StyleSheetsUpdateType styleSheetsUpdateType) { WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> > newSheetsVector; InspectorCSSAgent::collectAllDocumentStyleSheets(document, newSheetsVector); setActiveStyleSheets(document, newSheetsVector, styleSheetsUpdateType); } void InspectorCSSAgent::setActiveStyleSheets(Document* document, const WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> >& allSheetsVector, StyleSheetsUpdateType styleSheetsUpdateType) { bool isInitialFrontendLoad = styleSheetsUpdateType == InitialFrontendLoad; WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> >* documentCSSStyleSheets = m_documentToCSSStyleSheets.get(document); if (!documentCSSStyleSheets) { documentCSSStyleSheets = new WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> >(); OwnPtrWillBeRawPtr<WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> > > documentCSSStyleSheetsPtr = adoptPtrWillBeNoop(documentCSSStyleSheets); m_documentToCSSStyleSheets.set(document, documentCSSStyleSheetsPtr.release()); } WillBeHeapHashSet<RawPtrWillBeMember<CSSStyleSheet> > removedSheets(*documentCSSStyleSheets); WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> > addedSheets; for (CSSStyleSheet* cssStyleSheet : allSheetsVector) { if (removedSheets.contains(cssStyleSheet)) { removedSheets.remove(cssStyleSheet); if (isInitialFrontendLoad) addedSheets.append(cssStyleSheet); } else { addedSheets.append(cssStyleSheet); } } for (CSSStyleSheet* cssStyleSheet : removedSheets) { RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspectorStyleSheet.get(cssStyleSheet); ASSERT(inspectorStyleSheet); documentCSSStyleSheets->remove(cssStyleSheet); if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) { String id = unbindStyleSheet(inspectorStyleSheet.get()); if (frontend() && !isInitialFrontendLoad) frontend()->styleSheetRemoved(id); } } for (CSSStyleSheet* cssStyleSheet : addedSheets) { bool isNew = isInitialFrontendLoad || !m_cssStyleSheetToInspectorStyleSheet.contains(cssStyleSheet); if (isNew) { InspectorStyleSheet* newStyleSheet = bindStyleSheet(cssStyleSheet); documentCSSStyleSheets->add(cssStyleSheet); if (frontend()) frontend()->styleSheetAdded(newStyleSheet->buildObjectForStyleSheetInfo()); } } if (documentCSSStyleSheets->isEmpty()) m_documentToCSSStyleSheets.remove(document); } void InspectorCSSAgent::documentDetached(Document* document) { m_invalidatedDocuments.remove(document); setActiveStyleSheets(document, WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> >(), ExistingFrontendRefresh); } void InspectorCSSAgent::addEditedStyleSheet(const String& url, const String& content) { m_editedStyleSheets.set(url, content); } bool InspectorCSSAgent::getEditedStyleSheet(const String& url, String* content) { if (!m_editedStyleSheets.contains(url)) return false; *content = m_editedStyleSheets.get(url); return true; } void InspectorCSSAgent::addEditedStyleElement(int backendNodeId, const String& content) { m_editedStyleElements.set(backendNodeId, content); } bool InspectorCSSAgent::getEditedStyleElement(int backendNodeId, String* content) { if (!m_editedStyleElements.contains(backendNodeId)) return false; *content = m_editedStyleElements.get(backendNodeId); return true; } bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoType pseudoType) { if (m_nodeIdToForcedPseudoState.isEmpty()) return false; int nodeId = m_domAgent->boundNodeId(element); if (!nodeId) return false; NodeIdToForcedPseudoState::iterator it = m_nodeIdToForcedPseudoState.find(nodeId); if (it == m_nodeIdToForcedPseudoState.end()) return false; unsigned forcedPseudoState = it->value; switch (pseudoType) { case CSSSelector::PseudoActive: return forcedPseudoState & PseudoActive; case CSSSelector::PseudoFocus: return forcedPseudoState & PseudoFocus; case CSSSelector::PseudoHover: return forcedPseudoState & PseudoHover; case CSSSelector::PseudoVisited: return forcedPseudoState & PseudoVisited; default: return false; } } void InspectorCSSAgent::getMediaQueries(ErrorString* errorString, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSMedia> >& medias) { medias = TypeBuilder::Array<TypeBuilder::CSS::CSSMedia>::create(); for (auto& style : m_idToInspectorStyleSheet) { RefPtrWillBeRawPtr<InspectorStyleSheet> styleSheet = style.value; collectMediaQueriesFromStyleSheet(styleSheet->pageStyleSheet(), medias.get()); const CSSRuleVector& flatRules = styleSheet->flatRules(); for (unsigned i = 0; i < flatRules.size(); ++i) { CSSRule* rule = flatRules.at(i).get(); if (rule->type() == CSSRule::MEDIA_RULE || rule->type() == CSSRule::IMPORT_RULE) collectMediaQueriesFromRule(rule, medias.get()); } } } void InspectorCSSAgent::getMatchedStylesForNode(ErrorString* errorString, int nodeId, const bool* excludePseudo, const bool* excludeInherited, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::RuleMatch> >& matchedCSSRules, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches> >& pseudoIdMatches, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry> >& inheritedEntries) { Element* element = elementForId(errorString, nodeId); if (!element) { *errorString = "Node not found"; return; } Element* originalElement = element; PseudoId elementPseudoId = element->pseudoId(); if (elementPseudoId) { element = element->parentOrShadowHostElement(); if (!element) { *errorString = "Pseudo element has no parent"; return; } } Document* ownerDocument = element->ownerDocument(); // A non-active document has no styles. if (!ownerDocument->isActive()) return; // FIXME: It's really gross for the inspector to reach in and access StyleResolver // directly here. We need to provide the Inspector better APIs to get this information // without grabbing at internal style classes! // Matched rules. StyleResolver& styleResolver = ownerDocument->ensureStyleResolver(); element->updateDistribution(); RefPtrWillBeRawPtr<CSSRuleList> matchedRules = styleResolver.pseudoCSSRulesForElement(element, elementPseudoId, StyleResolver::AllCSSRules); matchedCSSRules = buildArrayForMatchedRuleList(matchedRules.get(), originalElement, NOPSEUDO); // Pseudo elements. if (!elementPseudoId && !asBool(excludePseudo)) { RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches> > pseudoElements = TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches>::create(); for (PseudoId pseudoId = FIRST_PUBLIC_PSEUDOID; pseudoId < AFTER_LAST_INTERNAL_PSEUDOID; pseudoId = static_cast<PseudoId>(pseudoId + 1)) { RefPtrWillBeRawPtr<CSSRuleList> matchedRules = styleResolver.pseudoCSSRulesForElement(element, pseudoId, StyleResolver::AllCSSRules); if (matchedRules && matchedRules->length()) { RefPtr<TypeBuilder::CSS::PseudoIdMatches> matches = TypeBuilder::CSS::PseudoIdMatches::create() .setPseudoId(static_cast<int>(pseudoId)) .setMatches(buildArrayForMatchedRuleList(matchedRules.get(), element, pseudoId)); pseudoElements->addItem(matches.release()); } } pseudoIdMatches = pseudoElements.release(); } // Inherited styles. if (!elementPseudoId && !asBool(excludeInherited)) { RefPtr<TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry> > entries = TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry>::create(); Element* parentElement = element->parentOrShadowHostElement(); while (parentElement) { StyleResolver& parentStyleResolver = parentElement->ownerDocument()->ensureStyleResolver(); RefPtrWillBeRawPtr<CSSRuleList> parentMatchedRules = parentStyleResolver.cssRulesForElement(parentElement, StyleResolver::AllCSSRules); RefPtr<TypeBuilder::CSS::InheritedStyleEntry> entry = TypeBuilder::CSS::InheritedStyleEntry::create() .setMatchedCSSRules(buildArrayForMatchedRuleList(parentMatchedRules.get(), parentElement, NOPSEUDO)); if (parentElement->style() && parentElement->style()->length()) { InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyleSheet(parentElement); if (styleSheet) entry->setInlineStyle(styleSheet->buildObjectForStyle(styleSheet->inlineStyle())); } entries->addItem(entry.release()); parentElement = parentElement->parentOrShadowHostElement(); } inheritedEntries = entries.release(); } } void InspectorCSSAgent::getInlineStylesForNode(ErrorString* errorString, int nodeId, RefPtr<TypeBuilder::CSS::CSSStyle>& inlineStyle, RefPtr<TypeBuilder::CSS::CSSStyle>& attributesStyle) { Element* element = elementForId(errorString, nodeId); if (!element) return; InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyleSheet(element); if (!styleSheet) return; inlineStyle = styleSheet->buildObjectForStyle(element->style()); RefPtr<TypeBuilder::CSS::CSSStyle> attributes = buildObjectForAttributesStyle(element); attributesStyle = attributes ? attributes.release() : nullptr; } void InspectorCSSAgent::getComputedStyleForNode(ErrorString* errorString, int nodeId, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> >& style) { Node* node = m_domAgent->assertNode(errorString, nodeId); if (!node) return; RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleInfo = CSSComputedStyleDeclaration::create(node, true); RefPtrWillBeRawPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(computedStyleInfo, nullptr, nullptr); style = inspectorStyle->buildArrayForComputedStyle(); } void InspectorCSSAgent::collectPlatformFontsForLayoutObject(LayoutObject* layoutObject, HashCountedSet<String>* fontStats) { if (!layoutObject->isText()) return; LayoutText* layoutText = toLayoutText(layoutObject); for (InlineTextBox* box = layoutText->firstTextBox(); box; box = box->nextTextBox()) { const ComputedStyle& style = layoutText->styleRef(box->isFirstLineStyle()); const Font& font = style.font(); TextRun run = box->constructTextRunForInspector(style, font); SimpleShaper shaper(&font, run); GlyphBuffer glyphBuffer; shaper.advance(run.length(), &glyphBuffer); for (unsigned i = 0; i < glyphBuffer.size(); ++i) { String familyName = glyphBuffer.fontDataAt(i)->platformData().fontFamilyName(); if (familyName.isNull()) familyName = ""; fontStats->add(familyName); } } } void InspectorCSSAgent::getPlatformFontsForNode(ErrorString* errorString, int nodeId, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PlatformFontUsage>>& platformFonts) { Node* node = m_domAgent->assertNode(errorString, nodeId); if (!node) return; HashCountedSet<String> fontStats; LayoutObject* root = node->layoutObject(); if (root) { collectPlatformFontsForLayoutObject(root, &fontStats); // Iterate upto two layers deep. for (LayoutObject* child = root->slowFirstChild(); child; child = child->nextSibling()) { collectPlatformFontsForLayoutObject(child, &fontStats); for (LayoutObject* child2 = child->slowFirstChild(); child2; child2 = child2->nextSibling()) collectPlatformFontsForLayoutObject(child2, &fontStats); } } platformFonts = TypeBuilder::Array<TypeBuilder::CSS::PlatformFontUsage>::create(); for (auto& font : fontStats) { RefPtr<TypeBuilder::CSS::PlatformFontUsage> platformFont = TypeBuilder::CSS::PlatformFontUsage::create() .setFamilyName(font.key) .setGlyphCount(font.value); platformFonts->addItem(platformFont); } } void InspectorCSSAgent::getStyleSheetText(ErrorString* errorString, const String& styleSheetId, String* result) { InspectorStyleSheetBase* inspectorStyleSheet = assertStyleSheetForId(errorString, styleSheetId); if (!inspectorStyleSheet) return; inspectorStyleSheet->getText(result); } void InspectorCSSAgent::setStyleSheetText(ErrorString* errorString, const String& styleSheetId, const String& text) { InspectorStyleSheetBase* inspectorStyleSheet = assertStyleSheetForId(errorString, styleSheetId); if (!inspectorStyleSheet) { *errorString = "Style sheet with id " + styleSheetId + " not found"; return; } TrackExceptionState exceptionState; m_domAgent->history()->perform(adoptRefWillBeNoop(new SetStyleSheetTextAction(inspectorStyleSheet, text)), exceptionState); *errorString = InspectorDOMAgent::toErrorString(exceptionState); } static bool extractRangeComponent(ErrorString* errorString, const RefPtr<JSONObject>& range, const String& component, unsigned& result) { int parsedValue = 0; if (!range->getNumber(component, &parsedValue) || parsedValue < 0) { *errorString = "range." + component + " must be a non-negative integer"; return false; } result = parsedValue; return true; } static bool jsonRangeToSourceRange(ErrorString* errorString, InspectorStyleSheetBase* inspectorStyleSheet, const RefPtr<JSONObject>& range, SourceRange* sourceRange) { unsigned startLineNumber = 0; unsigned startColumn = 0; unsigned endLineNumber = 0; unsigned endColumn = 0; if (!extractRangeComponent(errorString, range, "startLine", startLineNumber) || !extractRangeComponent(errorString, range, "startColumn", startColumn) || !extractRangeComponent(errorString, range, "endLine", endLineNumber) || !extractRangeComponent(errorString, range, "endColumn", endColumn)) return false; unsigned startOffset = 0; unsigned endOffset = 0; bool success = inspectorStyleSheet->lineNumberAndColumnToOffset(startLineNumber, startColumn, &startOffset) && inspectorStyleSheet->lineNumberAndColumnToOffset(endLineNumber, endColumn, &endOffset); if (!success) { *errorString = "Specified range is out of bounds"; return false; } if (startOffset > endOffset) { *errorString = "Range start must not succeed its end"; return false; } sourceRange->start = startOffset; sourceRange->end = endOffset; return true; } void InspectorCSSAgent::setRuleSelector(ErrorString* errorString, const String& styleSheetId, const RefPtr<JSONObject>& range, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result) { InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(errorString, styleSheetId); if (!inspectorStyleSheet) { *errorString = "Stylesheet not found"; return; } SourceRange selectorRange; if (!jsonRangeToSourceRange(errorString, inspectorStyleSheet, range, &selectorRange)) return; TrackExceptionState exceptionState; RefPtrWillBeRawPtr<ModifyRuleAction> action = adoptRefWillBeNoop(new ModifyRuleAction(ModifyRuleAction::SetRuleSelector, inspectorStyleSheet, selectorRange, selector)); bool success = m_domAgent->history()->perform(action, exceptionState); if (success) { RefPtrWillBeRawPtr<CSSStyleRule> rule = InspectorCSSAgent::asCSSStyleRule(action->takeRule().get()); result = inspectorStyleSheet->buildObjectForRule(rule.get(), buildMediaListChain(rule.get())); } *errorString = InspectorDOMAgent::toErrorString(exceptionState); } void InspectorCSSAgent::setStyleText(ErrorString* errorString, const String& styleSheetId, const RefPtr<JSONObject>& range, const String& text, RefPtr<TypeBuilder::CSS::CSSStyle>& result) { InspectorStyleSheetBase* inspectorStyleSheet = assertStyleSheetForId(errorString, styleSheetId); if (!inspectorStyleSheet) { *errorString = "Stylesheet not found"; return; } SourceRange selectorRange; if (!jsonRangeToSourceRange(errorString, inspectorStyleSheet, range, &selectorRange)) return; CSSStyleDeclaration* style = setStyleText(errorString, inspectorStyleSheet, selectorRange, text); if (style) result = inspectorStyleSheet->buildObjectForStyle(style); } CSSStyleDeclaration* InspectorCSSAgent::setStyleText(ErrorString* errorString, InspectorStyleSheetBase* inspectorStyleSheet, const SourceRange& range, const String& text) { TrackExceptionState exceptionState; if (inspectorStyleSheet->isInlineStyle()) { InspectorStyleSheetForInlineStyle* inlineStyleSheet = static_cast<InspectorStyleSheetForInlineStyle*>(inspectorStyleSheet); RefPtrWillBeRawPtr<SetElementStyleAction> action = adoptRefWillBeNoop(new SetElementStyleAction(inlineStyleSheet, text)); bool success = m_domAgent->history()->perform(action, exceptionState); if (success) return inlineStyleSheet->inlineStyle(); } else { RefPtrWillBeRawPtr<ModifyRuleAction> action = adoptRefWillBeNoop(new ModifyRuleAction(ModifyRuleAction::SetStyleText, static_cast<InspectorStyleSheet*>(inspectorStyleSheet), range, text)); bool success = m_domAgent->history()->perform(action, exceptionState); if (success) { RefPtrWillBeRawPtr<CSSStyleRule> rule = InspectorCSSAgent::asCSSStyleRule(action->takeRule().get()); return rule->style(); } } *errorString = InspectorDOMAgent::toErrorString(exceptionState); return nullptr; } void InspectorCSSAgent::setMediaText(ErrorString* errorString, const String& styleSheetId, const RefPtr<JSONObject>& range, const String& text, RefPtr<TypeBuilder::CSS::CSSMedia>& result) { InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(errorString, styleSheetId); if (!inspectorStyleSheet) { *errorString = "Stylesheet not found"; return; } SourceRange textRange; if (!jsonRangeToSourceRange(errorString, inspectorStyleSheet, range, &textRange)) return; TrackExceptionState exceptionState; RefPtrWillBeRawPtr<ModifyRuleAction> action = adoptRefWillBeNoop(new ModifyRuleAction(ModifyRuleAction::SetMediaRuleText, inspectorStyleSheet, textRange, text)); bool success = m_domAgent->history()->perform(action, exceptionState); if (success) { RefPtrWillBeRawPtr<CSSMediaRule> rule = InspectorCSSAgent::asCSSMediaRule(action->takeRule().get()); String sourceURL = rule->parentStyleSheet()->contents()->baseURL(); if (sourceURL.isEmpty()) sourceURL = InspectorDOMAgent::documentURLString(rule->parentStyleSheet()->ownerDocument()); result = buildMediaObject(rule->media(), MediaListSourceMediaRule, sourceURL, rule->parentStyleSheet()); } *errorString = InspectorDOMAgent::toErrorString(exceptionState); } void InspectorCSSAgent::createStyleSheet(ErrorString* errorString, const String& frameId, TypeBuilder::CSS::StyleSheetId* outStyleSheetId) { LocalFrame* frame = m_pageAgent->frameForId(frameId); if (!frame) { *errorString = "Frame not found"; return; } Document* document = frame->document(); if (!document) { *errorString = "Frame does not have a document"; return; } InspectorStyleSheet* inspectorStyleSheet = viaInspectorStyleSheet(document, true); if (!inspectorStyleSheet) { *errorString = "No target stylesheet found"; return; } updateActiveStyleSheets(document, ExistingFrontendRefresh); *outStyleSheetId = inspectorStyleSheet->id(); } void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleSheetId, const String& ruleText, const RefPtr<JSONObject>& location, RefPtr<TypeBuilder::CSS::CSSRule>& result) { InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(errorString, styleSheetId); if (!inspectorStyleSheet) return; SourceRange ruleLocation; if (!jsonRangeToSourceRange(errorString, inspectorStyleSheet, location, &ruleLocation)) return; TrackExceptionState exceptionState; RefPtrWillBeRawPtr<AddRuleAction> action = adoptRefWillBeNoop(new AddRuleAction(inspectorStyleSheet, ruleText, ruleLocation)); bool success = m_domAgent->history()->perform(action, exceptionState); if (!success) { *errorString = InspectorDOMAgent::toErrorString(exceptionState); return; } RefPtrWillBeRawPtr<CSSStyleRule> rule = action->takeRule(); result = inspectorStyleSheet->buildObjectForRule(rule.get(), buildMediaListChain(rule.get())); } void InspectorCSSAgent::forcePseudoState(ErrorString* errorString, int nodeId, const RefPtr<JSONArray>& forcedPseudoClasses) { Element* element = m_domAgent->assertElement(errorString, nodeId); if (!element) return; unsigned forcedPseudoState = computePseudoClassMask(forcedPseudoClasses.get()); NodeIdToForcedPseudoState::iterator it = m_nodeIdToForcedPseudoState.find(nodeId); unsigned currentForcedPseudoState = it == m_nodeIdToForcedPseudoState.end() ? 0 : it->value; bool needStyleRecalc = forcedPseudoState != currentForcedPseudoState; if (!needStyleRecalc) return; if (forcedPseudoState) m_nodeIdToForcedPseudoState.set(nodeId, forcedPseudoState); else m_nodeIdToForcedPseudoState.remove(nodeId); element->ownerDocument()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::Inspector)); } PassRefPtr<TypeBuilder::CSS::CSSMedia> InspectorCSSAgent::buildMediaObject(const MediaList* media, MediaListSource mediaListSource, const String& sourceURL, CSSStyleSheet* parentStyleSheet) { // Make certain compilers happy by initializing |source| up-front. TypeBuilder::CSS::CSSMedia::Source::Enum source = TypeBuilder::CSS::CSSMedia::Source::InlineSheet; switch (mediaListSource) { case MediaListSourceMediaRule: source = TypeBuilder::CSS::CSSMedia::Source::MediaRule; break; case MediaListSourceImportRule: source = TypeBuilder::CSS::CSSMedia::Source::ImportRule; break; case MediaListSourceLinkedSheet: source = TypeBuilder::CSS::CSSMedia::Source::LinkedSheet; break; case MediaListSourceInlineSheet: source = TypeBuilder::CSS::CSSMedia::Source::InlineSheet; break; } const MediaQuerySet* queries = media->queries(); const WillBeHeapVector<OwnPtrWillBeMember<MediaQuery> >& queryVector = queries->queryVector(); LocalFrame* frame = nullptr; if (parentStyleSheet) { if (Document* document = parentStyleSheet->ownerDocument()) frame = document->frame(); } OwnPtr<MediaQueryEvaluator> mediaEvaluator = adoptPtr(new MediaQueryEvaluator(frame)); InspectorStyleSheet* inspectorStyleSheet = parentStyleSheet ? m_cssStyleSheetToInspectorStyleSheet.get(parentStyleSheet) : nullptr; RefPtr<TypeBuilder::Array<TypeBuilder::CSS::MediaQuery> > mediaListArray = TypeBuilder::Array<TypeBuilder::CSS::MediaQuery>::create(); RefPtr<MediaValues> mediaValues = MediaValues::createDynamicIfFrameExists(frame); bool hasMediaQueryItems = false; for (size_t i = 0; i < queryVector.size(); ++i) { MediaQuery* query = queryVector.at(i).get(); const ExpressionHeapVector& expressions = query->expressions(); RefPtr<TypeBuilder::Array<TypeBuilder::CSS::MediaQueryExpression> > expressionArray = TypeBuilder::Array<TypeBuilder::CSS::MediaQueryExpression>::create(); bool hasExpressionItems = false; for (size_t j = 0; j < expressions.size(); ++j) { MediaQueryExp* mediaQueryExp = expressions.at(j).get(); MediaQueryExpValue expValue = mediaQueryExp->expValue(); if (!expValue.isValue) continue; const char* valueName = CSSPrimitiveValue::unitTypeToString(expValue.unit); RefPtr<TypeBuilder::CSS::MediaQueryExpression> mediaQueryExpression = TypeBuilder::CSS::MediaQueryExpression::create() .setValue(expValue.value) .setUnit(String(valueName)) .setFeature(mediaQueryExp->mediaFeature()); if (inspectorStyleSheet && media->parentRule()) { RefPtr<TypeBuilder::CSS::SourceRange> valueRange = inspectorStyleSheet->mediaQueryExpValueSourceRange(media->parentRule(), i, j); if (valueRange) mediaQueryExpression->setValueRange(valueRange); } int computedLength; if (mediaValues->computeLength(expValue.value, expValue.unit, computedLength)) mediaQueryExpression->setComputedLength(computedLength); expressionArray->addItem(mediaQueryExpression); hasExpressionItems = true; } if (!hasExpressionItems) continue; RefPtr<TypeBuilder::CSS::MediaQuery> mediaQuery = TypeBuilder::CSS::MediaQuery::create() .setActive(mediaEvaluator->eval(query, nullptr)) .setExpressions(expressionArray); mediaListArray->addItem(mediaQuery); hasMediaQueryItems = true; } RefPtr<TypeBuilder::CSS::CSSMedia> mediaObject = TypeBuilder::CSS::CSSMedia::create() .setText(media->mediaText()) .setSource(source); if (hasMediaQueryItems) mediaObject->setMediaList(mediaListArray); if (inspectorStyleSheet && mediaListSource != MediaListSourceLinkedSheet) mediaObject->setParentStyleSheetId(inspectorStyleSheet->id()); if (!sourceURL.isEmpty()) { mediaObject->setSourceURL(sourceURL); CSSRule* parentRule = media->parentRule(); if (!parentRule) return mediaObject.release(); InspectorStyleSheet* inspectorStyleSheet = bindStyleSheet(parentRule->parentStyleSheet()); RefPtr<TypeBuilder::CSS::SourceRange> mediaRange = inspectorStyleSheet->ruleHeaderSourceRange(parentRule); if (mediaRange) mediaObject->setRange(mediaRange); } return mediaObject.release(); } bool InspectorCSSAgent::collectMediaQueriesFromStyleSheet(CSSStyleSheet* styleSheet, TypeBuilder::Array<TypeBuilder::CSS::CSSMedia>* mediaArray) { bool addedItems = false; MediaList* mediaList = styleSheet->media(); String sourceURL; if (mediaList && mediaList->length()) { Document* doc = styleSheet->ownerDocument(); if (doc) sourceURL = doc->url(); else if (!styleSheet->contents()->baseURL().isEmpty()) sourceURL = styleSheet->contents()->baseURL(); else sourceURL = ""; mediaArray->addItem(buildMediaObject(mediaList, styleSheet->ownerNode() ? MediaListSourceLinkedSheet : MediaListSourceInlineSheet, sourceURL, styleSheet)); addedItems = true; } return addedItems; } bool InspectorCSSAgent::collectMediaQueriesFromRule(CSSRule* rule, TypeBuilder::Array<TypeBuilder::CSS::CSSMedia>* mediaArray) { MediaList* mediaList; String sourceURL; CSSStyleSheet* parentStyleSheet = nullptr; bool isMediaRule = true; bool addedItems = false; if (rule->type() == CSSRule::MEDIA_RULE) { CSSMediaRule* mediaRule = toCSSMediaRule(rule); mediaList = mediaRule->media(); parentStyleSheet = mediaRule->parentStyleSheet(); } else if (rule->type() == CSSRule::IMPORT_RULE) { CSSImportRule* importRule = toCSSImportRule(rule); mediaList = importRule->media(); parentStyleSheet = importRule->parentStyleSheet(); isMediaRule = false; } else { mediaList = nullptr; } if (parentStyleSheet) { sourceURL = parentStyleSheet->contents()->baseURL(); if (sourceURL.isEmpty()) sourceURL = InspectorDOMAgent::documentURLString(parentStyleSheet->ownerDocument()); } else { sourceURL = ""; } if (mediaList && mediaList->length()) { mediaArray->addItem(buildMediaObject(mediaList, isMediaRule ? MediaListSourceMediaRule : MediaListSourceImportRule, sourceURL, parentStyleSheet)); addedItems = true; } return addedItems; } PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSMedia> > InspectorCSSAgent::buildMediaListChain(CSSRule* rule) { if (!rule) return nullptr; RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSMedia> > mediaArray = TypeBuilder::Array<TypeBuilder::CSS::CSSMedia>::create(); bool hasItems = false; CSSRule* parentRule = rule; while (parentRule) { hasItems = collectMediaQueriesFromRule(parentRule, mediaArray.get()) || hasItems; if (parentRule->parentRule()) { parentRule = parentRule->parentRule(); } else { CSSStyleSheet* styleSheet = parentRule->parentStyleSheet(); while (styleSheet) { hasItems = collectMediaQueriesFromStyleSheet(styleSheet, mediaArray.get()) || hasItems; parentRule = styleSheet->ownerRule(); if (parentRule) break; styleSheet = styleSheet->parentStyleSheet(); } } } return hasItems ? mediaArray : nullptr; } InspectorStyleSheetForInlineStyle* InspectorCSSAgent::asInspectorStyleSheet(Element* element) { NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(element); if (it != m_nodeToInspectorStyleSheet.end()) return it->value.get(); CSSStyleDeclaration* style = element->style(); if (!style) return nullptr; RefPtrWillBeRawPtr<InspectorStyleSheetForInlineStyle> inspectorStyleSheet = InspectorStyleSheetForInlineStyle::create(element, this); m_idToInspectorStyleSheetForInlineStyle.set(inspectorStyleSheet->id(), inspectorStyleSheet); m_nodeToInspectorStyleSheet.set(element, inspectorStyleSheet); return inspectorStyleSheet.get(); } Element* InspectorCSSAgent::elementForId(ErrorString* errorString, int nodeId) { Node* node = m_domAgent->nodeForId(nodeId); if (!node) { *errorString = "No node with given id found"; return nullptr; } if (!node->isElementNode()) { *errorString = "Not an element node"; return nullptr; } return toElement(node); } // static void InspectorCSSAgent::collectAllDocumentStyleSheets(Document* document, WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> >& result) { const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>> activeStyleSheets = document->styleEngine().activeStyleSheetsForInspector(); for (const auto& style : activeStyleSheets) { CSSStyleSheet* styleSheet = style.get(); InspectorCSSAgent::collectStyleSheets(styleSheet, result); } } // static void InspectorCSSAgent::collectStyleSheets(CSSStyleSheet* styleSheet, WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> >& result) { result.append(styleSheet); for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) { CSSRule* rule = styleSheet->item(i); if (rule->type() == CSSRule::IMPORT_RULE) { CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleSheet(); if (importedStyleSheet) InspectorCSSAgent::collectStyleSheets(importedStyleSheet, result); } } } InspectorStyleSheet* InspectorCSSAgent::bindStyleSheet(CSSStyleSheet* styleSheet) { RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspectorStyleSheet.get(styleSheet); if (!inspectorStyleSheet) { Document* document = styleSheet->ownerDocument(); inspectorStyleSheet = InspectorStyleSheet::create(m_resourceAgent, styleSheet, detectOrigin(styleSheet, document), InspectorDOMAgent::documentURLString(document), this); m_idToInspectorStyleSheet.set(inspectorStyleSheet->id(), inspectorStyleSheet); m_cssStyleSheetToInspectorStyleSheet.set(styleSheet, inspectorStyleSheet); if (m_creatingViaInspectorStyleSheet) m_documentToViaInspectorStyleSheet.add(document, inspectorStyleSheet); } return inspectorStyleSheet.get(); } String InspectorCSSAgent::unbindStyleSheet(InspectorStyleSheet* inspectorStyleSheet) { String id = inspectorStyleSheet->id(); m_idToInspectorStyleSheet.remove(id); if (inspectorStyleSheet->pageStyleSheet()) m_cssStyleSheetToInspectorStyleSheet.remove(inspectorStyleSheet->pageStyleSheet()); return id; } InspectorStyleSheet* InspectorCSSAgent::viaInspectorStyleSheet(Document* document, bool createIfAbsent) { if (!document) { ASSERT(!createIfAbsent); return nullptr; } if (!document->isHTMLDocument() && !document->isSVGDocument()) return nullptr; RefPtrWillBeRawPtr<InspectorStyleSheet> inspectorStyleSheet = m_documentToViaInspectorStyleSheet.get(document); if (inspectorStyleSheet || !createIfAbsent) return inspectorStyleSheet.get(); TrackExceptionState exceptionState; RefPtrWillBeRawPtr<Element> styleElement = document->createElement("style", exceptionState); if (!exceptionState.hadException()) styleElement->setAttribute("type", "text/css", exceptionState); if (!exceptionState.hadException()) { ContainerNode* targetNode; // HEAD is absent in ImageDocuments, for example. if (document->head()) targetNode = document->head(); else if (document->body()) targetNode = document->body(); else return nullptr; InlineStyleOverrideScope overrideScope(document); m_creatingViaInspectorStyleSheet = true; targetNode->appendChild(styleElement, exceptionState); // At this point the added stylesheet will get bound through the updateActiveStyleSheets() invocation. // We just need to pick the respective InspectorStyleSheet from m_documentToViaInspectorStyleSheet. m_creatingViaInspectorStyleSheet = false; } if (exceptionState.hadException()) return nullptr; return m_documentToViaInspectorStyleSheet.get(document); } InspectorStyleSheet* InspectorCSSAgent::assertInspectorStyleSheetForId(ErrorString* errorString, const String& styleSheetId) { IdToInspectorStyleSheet::iterator it = m_idToInspectorStyleSheet.find(styleSheetId); if (it == m_idToInspectorStyleSheet.end()) { *errorString = "No style sheet with given id found"; return nullptr; } return it->value.get(); } InspectorStyleSheetBase* InspectorCSSAgent::assertStyleSheetForId(ErrorString* errorString, const String& styleSheetId) { String placeholder; InspectorStyleSheetBase* result = assertInspectorStyleSheetForId(&placeholder, styleSheetId); if (result) return result; IdToInspectorStyleSheetForInlineStyle::iterator it = m_idToInspectorStyleSheetForInlineStyle.find(styleSheetId); if (it == m_idToInspectorStyleSheetForInlineStyle.end()) { *errorString = "No style sheet with given id found"; return nullptr; } return it->value.get(); } TypeBuilder::CSS::StyleSheetOrigin::Enum InspectorCSSAgent::detectOrigin(CSSStyleSheet* pageStyleSheet, Document* ownerDocument) { if (m_creatingViaInspectorStyleSheet) return TypeBuilder::CSS::StyleSheetOrigin::Inspector; TypeBuilder::CSS::StyleSheetOrigin::Enum origin = TypeBuilder::CSS::StyleSheetOrigin::Regular; if (pageStyleSheet && !pageStyleSheet->ownerNode() && pageStyleSheet->href().isEmpty()) origin = TypeBuilder::CSS::StyleSheetOrigin::User_agent; else if (pageStyleSheet && pageStyleSheet->ownerNode() && pageStyleSheet->ownerNode()->isDocumentNode()) origin = TypeBuilder::CSS::StyleSheetOrigin::Injected; else { InspectorStyleSheet* viaInspectorStyleSheetForOwner = viaInspectorStyleSheet(ownerDocument, false); if (viaInspectorStyleSheetForOwner && pageStyleSheet == viaInspectorStyleSheetForOwner->pageStyleSheet()) origin = TypeBuilder::CSS::StyleSheetOrigin::Inspector; } return origin; } PassRefPtr<TypeBuilder::CSS::CSSRule> InspectorCSSAgent::buildObjectForRule(CSSStyleRule* rule) { if (!rule) return nullptr; // CSSRules returned by StyleResolver::pseudoCSSRulesForElement lack parent pointers if they are coming from // user agent stylesheets. To work around this issue, we use CSSOM wrapper created by inspector. if (!rule->parentStyleSheet()) { if (!m_inspectorUserAgentStyleSheet) m_inspectorUserAgentStyleSheet = CSSStyleSheet::create(CSSDefaultStyleSheets::instance().defaultStyleSheet()); rule->setParentStyleSheet(m_inspectorUserAgentStyleSheet.get()); } return bindStyleSheet(rule->parentStyleSheet())->buildObjectForRule(rule, buildMediaListChain(rule)); } static inline bool matchesPseudoElement(const CSSSelector* selector, PseudoId elementPseudoId) { // According to http://www.w3.org/TR/css3-selectors/#pseudo-elements, "Only one pseudo-element may appear per selector." // As such, check the last selector in the tag history. for (; !selector->isLastInTagHistory(); ++selector) { } PseudoId selectorPseudoId = CSSSelector::pseudoId(selector->pseudoType()); // FIXME: This only covers the case of matching pseudo-element selectors against PseudoElements. // We should come up with a solution for matching pseudo-element selectors against ordinary Elements, too. return selectorPseudoId == elementPseudoId; } PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::RuleMatch> > InspectorCSSAgent::buildArrayForMatchedRuleList(CSSRuleList* ruleList, Element* element, PseudoId matchesForPseudoId) { RefPtr<TypeBuilder::Array<TypeBuilder::CSS::RuleMatch> > result = TypeBuilder::Array<TypeBuilder::CSS::RuleMatch>::create(); if (!ruleList) return result.release(); for (unsigned i = 0, size = ruleList->length(); i < size; ++i) { CSSStyleRule* rule = asCSSStyleRule(ruleList->item(i)); RefPtr<TypeBuilder::CSS::CSSRule> ruleObject = buildObjectForRule(rule); if (!ruleObject) continue; RefPtr<TypeBuilder::Array<int> > matchingSelectors = TypeBuilder::Array<int>::create(); const CSSSelectorList& selectorList = rule->styleRule()->selectorList(); long index = 0; PseudoId elementPseudoId = matchesForPseudoId ? matchesForPseudoId : element->pseudoId(); for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(*selector)) { const CSSSelector* firstTagHistorySelector = selector; bool matched = false; if (elementPseudoId) matched = matchesPseudoElement(selector, elementPseudoId); // Modifies |selector|. else matched = element->matches(firstTagHistorySelector->selectorText(), IGNORE_EXCEPTION); if (matched) matchingSelectors->addItem(index); ++index; } RefPtr<TypeBuilder::CSS::RuleMatch> match = TypeBuilder::CSS::RuleMatch::create() .setRule(ruleObject.release()) .setMatchingSelectors(matchingSelectors.release()); result->addItem(match); } return result; } PassRefPtr<TypeBuilder::CSS::CSSStyle> InspectorCSSAgent::buildObjectForAttributesStyle(Element* element) { if (!element->isStyledElement()) return nullptr; // FIXME: Ugliness below. StylePropertySet* attributeStyle = const_cast<StylePropertySet*>(element->presentationAttributeStyle()); if (!attributeStyle) return nullptr; MutableStylePropertySet* mutableAttributeStyle = toMutableStylePropertySet(attributeStyle); RefPtrWillBeRawPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(mutableAttributeStyle->ensureCSSStyleDeclaration(), nullptr, nullptr); return inspectorStyle->buildObjectForStyle(); } void InspectorCSSAgent::didRemoveDocument(Document* document) { if (document) m_documentToViaInspectorStyleSheet.remove(document); } void InspectorCSSAgent::didRemoveDOMNode(Node* node) { if (!node) return; int nodeId = m_domAgent->boundNodeId(node); if (nodeId) m_nodeIdToForcedPseudoState.remove(nodeId); NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(node); if (it == m_nodeToInspectorStyleSheet.end()) return; m_idToInspectorStyleSheetForInlineStyle.remove(it->value->id()); m_nodeToInspectorStyleSheet.remove(node); } void InspectorCSSAgent::didModifyDOMAttr(Element* element) { if (!element) return; NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(element); if (it == m_nodeToInspectorStyleSheet.end()) return; it->value->didModifyElementAttribute(); } void InspectorCSSAgent::styleSheetChanged(InspectorStyleSheetBase* styleSheet) { flushPendingProtocolNotifications(); frontend()->styleSheetChanged(styleSheet->id()); } void InspectorCSSAgent::willReparseStyleSheet() { ASSERT(!m_isSettingStyleSheetText); m_isSettingStyleSheetText = true; } void InspectorCSSAgent::didReparseStyleSheet() { ASSERT(m_isSettingStyleSheetText); m_isSettingStyleSheetText = false; } void InspectorCSSAgent::resetPseudoStates() { WillBeHeapHashSet<RawPtrWillBeMember<Document> > documentsToChange; for (auto& state : m_nodeIdToForcedPseudoState) { Element* element = toElement(m_domAgent->nodeForId(state.key)); if (element && element->ownerDocument()) documentsToChange.add(element->ownerDocument()); } m_nodeIdToForcedPseudoState.clear(); for (auto& document : documentsToChange) document->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::Inspector)); } void InspectorCSSAgent::setCSSPropertyValue(ErrorString* errorString, Element* element, CSSPropertyID propertyId, const String& value) { PseudoId elementPseudoId = element->pseudoId(); if (elementPseudoId) { element = element->parentOrShadowHostElement(); if (!element) { *errorString = "Pseudo element has no parent"; return; } } Document* ownerDocument = element->ownerDocument(); // A non-active document has no styles. if (!ownerDocument->isActive()) { *errorString = "Can't edit a node from a non-active document"; return; } // Matched rules. Vector<StylePropertyShorthand, 4> shorthands; getMatchingShorthandsForLonghand(propertyId, &shorthands); String shorthand = shorthands.size() > 0 ? getPropertyNameString(shorthands[0].id()) : String(); String longhand = getPropertyNameString(propertyId); CSSStyleDeclaration* foundStyle = nullptr; bool isImportant = false; CSSStyleDeclaration* inlineStyle = element->style(); if (inlineStyle && !inlineStyle->getPropertyValue(longhand).isEmpty()) { foundStyle = inlineStyle; isImportant = inlineStyle->getPropertyPriority(longhand) == "important"; } StyleResolver& styleResolver = ownerDocument->ensureStyleResolver(); element->updateDistribution(); RefPtrWillBeRawPtr<CSSRuleList> ruleList = styleResolver.pseudoCSSRulesForElement(element, elementPseudoId, StyleResolver::AllCSSRules); for (unsigned i = 0, size = ruleList ? ruleList->length() : 0; i < size; ++i) { if (isImportant) break; if (ruleList->item(size - i - 1)->type() != CSSRule::STYLE_RULE) continue; CSSStyleRule* rule = toCSSStyleRule(ruleList->item(size - i - 1)); if (!rule) continue; CSSStyleDeclaration* style = rule->style(); if (!style) continue; if (style->getPropertyValue(longhand).isEmpty()) continue; isImportant = style->getPropertyPriority(longhand) == "important"; if (isImportant || !foundStyle) foundStyle = style; } if (!foundStyle || !foundStyle->parentStyleSheet()) foundStyle = inlineStyle; if (!foundStyle) { *errorString = "Can't find a style to edit"; return; } InspectorStyleSheetBase* inspectorStyleSheet = nullptr; RefPtrWillBeRawPtr<CSSRuleSourceData> sourceData = nullptr; if (foundStyle != inlineStyle) { InspectorStyleSheet* styleSheet = bindStyleSheet(foundStyle->parentStyleSheet()); inspectorStyleSheet = styleSheet; sourceData = styleSheet->sourceDataForRule(foundStyle->parentRule()); } if (!sourceData) { InspectorStyleSheetForInlineStyle* inlineStyleSheet = asInspectorStyleSheet(element); inspectorStyleSheet = inlineStyleSheet; sourceData = inlineStyleSheet->ruleSourceData(); } if (!sourceData) { *errorString = "Can't find a source to edit"; return; } int foundIndex = -1; WillBeHeapVector<CSSPropertySourceData> properties = sourceData->styleSourceData->propertyData; for (unsigned i = 0; i < properties.size(); ++i) { CSSPropertySourceData property = properties[properties.size() - i - 1]; String name = property.name; if (property.disabled) continue; if (name != shorthand && name != longhand) continue; if (property.important || foundIndex == -1) foundIndex = properties.size() - i - 1; if (property.important) break; } SourceRange bodyRange = sourceData->ruleBodyRange; String styleSheetText; inspectorStyleSheet->getText(&styleSheetText); String styleText = styleSheetText.substring(bodyRange.start, bodyRange.length()); if (foundIndex == -1) { String newPropertyText = "\n" + longhand + ": " + value + (isImportant ? " !important" : "") + ";"; styleText.append(newPropertyText); } else { CSSPropertySourceData declaration = properties[foundIndex]; String newValueText; if (declaration.name == shorthand) newValueText = createShorthandValue(ownerDocument, shorthand, declaration.value, longhand, value); else newValueText = value; String newPropertyText = declaration.name + ": " + newValueText + (declaration.important ? " !important" : "") + ";"; styleText.replace(declaration.range.start - bodyRange.start, declaration.range.length(), newPropertyText); } setStyleText(errorString, inspectorStyleSheet, bodyRange, styleText); } void InspectorCSSAgent::setEffectivePropertyValueForNode(ErrorString* errorString, int nodeId, const String& propertyName, const String& value) { Element* element = elementForId(errorString, nodeId); if (!element) return; CSSPropertyID property = cssPropertyID(propertyName); if (!property) { *errorString = "Invalid property name"; return; } setCSSPropertyValue(errorString, element, cssPropertyID(propertyName), value); } DEFINE_TRACE(InspectorCSSAgent) { visitor->trace(m_domAgent); visitor->trace(m_pageAgent); visitor->trace(m_resourceAgent); visitor->trace(m_resourceContentLoader); #if ENABLE(OILPAN) visitor->trace(m_idToInspectorStyleSheet); visitor->trace(m_idToInspectorStyleSheetForInlineStyle); visitor->trace(m_cssStyleSheetToInspectorStyleSheet); visitor->trace(m_documentToCSSStyleSheets); visitor->trace(m_invalidatedDocuments); visitor->trace(m_nodeToInspectorStyleSheet); visitor->trace(m_documentToViaInspectorStyleSheet); #endif visitor->trace(m_inspectorUserAgentStyleSheet); InspectorBaseAgent::trace(visitor); } } // namespace blink
victorzhao/miniblink49
third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp
C++
gpl-3.0
66,587
<?php // This file is part of Moodle - http://moodle.org/ // // Moodle 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. // // Moodle 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 Moodle. If not, see <http://www.gnu.org/licenses/>. /** * * @package block * @subpackage ajax_marking * @copyright 2012 Matt Gibson * @author Matt Gibson {@link http://moodle.org/user/view.php?id=81450} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->dirroot.'/enrol/locallib.php'); require_once($CFG->dirroot.'/blocks/ajax_marking/lib.php'); require_once($CFG->dirroot.'/mod/assign/lib.php'); require_once($CFG->dirroot.'/blocks/ajax_marking/tests/block_ajax_marking_mod_assign_generator.class.php'); require_once($CFG->dirroot.'/blocks/ajax_marking/tests/block_ajax_marking_mod_quiz_generator.class.php'); require_once($CFG->dirroot.'/blocks/ajax_marking/tests/block_ajax_marking_mod_workshop_generator.class.php'); require_once($CFG->dirroot.'/blocks/ajax_marking/classes/nodes_builder_base.class.php'); /** * Unit test for the nodes_builder class. */ class test_nodes_builder_base extends advanced_testcase { /** * @var stdClass */ protected $course; /** * @var array of stdClass objects */ protected $students; /** * @var array of stdClass objects */ protected $teachers; /** * @var int How many submissions ought to come back */ protected $submissioncount; /** * @var array of assign module instances made by the generator. */ protected $assigns; /** * Gets a blank course with 2 teachers and 10 students ready for each test. */ protected function setUp() { global $PAGE, $DB; // First test will set up DB submissions, so we keep it hanging around for the others. $this->resetAfterTest(); // Make a course. $generator = $this->getDataGenerator(); $this->course = $generator->create_course(); $this->setAdminUser(); $PAGE->set_course($this->course); $manager = new course_enrolment_manager($PAGE, $this->course); $plugins = $manager->get_enrolment_plugins(); $instances = $manager->get_enrolment_instances(); /* @var enrol_manual_plugin $manualenrolplugin */ $manualenrolplugin = reset($plugins); $manualenrolinstance = reset($instances); $studentroleid = $DB->get_field('role', 'id', array('shortname' => 'student')); $teacherroleid = $DB->get_field('role', 'id', array('shortname' => 'teacher')); // Make some students. for ($i = 0; $i < 10; $i++) { $student = $generator->create_user(); $this->students[$student->id] = $student; $manualenrolplugin->enrol_user($manualenrolinstance, $student->id, $studentroleid); } // Make a couple of teachers. $teacher1 = $generator->create_user(); $this->teachers[$teacher1->id] = $teacher1; $manualenrolplugin->enrol_user($manualenrolinstance, $teacher1->id, $teacherroleid); $teacher2 = $generator->create_user(); $this->teachers[$teacher2->id] = $teacher2; $manualenrolplugin->enrol_user($manualenrolinstance, $teacher2->id, $teacherroleid); } /** * Makes data for all the modules: * - one assign and 10 submissions * - 4 assignments and 40 submissions * - 5 forums and 500 forum posts * - 1 quiz with one question and 10 answers * - 1 workshop with 10 submissions * * Submissions are counted and stored as $this->submissioncount. * * @param array $modstoinclude the modules to mke submissions for. Default: all. * @return int */ private function make_module_submissions($modstoinclude = array()) { global $DB; $submissioncount = 0; // Assignment module is disabled in the PHPUnit DB, so we need to re-enable it. $DB->set_field('modules', 'visible', 1, array('name' => 'assignment')); $classes = block_ajax_marking_get_module_classes(true); foreach ($classes as $modclass) { $modname = $modclass->get_module_name(); if (!empty($modstoinclude) && !in_array($modname, $modstoinclude)) { continue; } // We need some submissions, but these are different for every module. // Without a standardised way of doing this, we will use methods in this class to do // the job until a better way emerges. $createdatamethod = 'create_'.$modname.'_submission_data'; if (method_exists($this, $createdatamethod)) { // Let the modules decide what number of things should be expected. Some are more // complex than others. $count = $this->$createdatamethod(); $submissioncount += $count; } } return $submissioncount; } /** * For each module, we need to see if we can actually get any data back using the query from * the module's query factory. Possible problem with third (fourth?) party module access code, * so check first to see if the generator can handle making one to test with. */ public function test_module_query_factories() { global $DB; // Assignment module is disabled in the PHPUnit DB, so we need to re-enable it. $DB->set_field('modules', 'visible', 1, array('name' => 'assignment')); $classes = block_ajax_marking_get_module_classes(); foreach ($classes as $modclass) { $modname = $modclass->get_module_name(); // We need some submissions, but these are different for every module. // Without a standardised way of doing this, we will use methods in this class to do // the job until a better way emerges. $createdatamethod = 'create_'.$modname.'_submission_data'; if (method_exists($this, $createdatamethod)) { // Let the modules decide what number of things should be expected. Some are more // complex than others. $expectedcount = $this->$createdatamethod(); if (empty($expectedcount)) { continue; } } else { // No point carrying on without some data to check. continue; } // Make query. $query = $modclass->query_factory(); // We will get an error if we leave it like this as the userids in the first // column are not unique. $wrapper = new block_ajax_marking_query_base(); $wrapper->add_select(array('function' => 'COUNT', 'column' => '*', 'alias' => 'count')); $wrapper->add_from(array('table' => $query, 'alias' => 'modulequery')); // Run query. Get one stdClass with a count property. $unmarkedstuff = $wrapper->execute(); // Make sure we get the right number of things back. $this->assertEquals($expectedcount, reset($unmarkedstuff)->count); } } /** * Makes submissions that ought to be picked up by test_basic_module_retrieval() as well as * a few others that shouldn't be. This is for the 2.2 and earlier assignment module. * * @return int how many to expect */ private function create_assignment_submission_data() { $submissioncount = 0; // Provide defaults to prevent IDE griping. $student = new stdClass(); $student->id = 3; /* @var phpunit_module_generator $assignmentgenerator */ $assignmentgenerator = $this->getDataGenerator()->get_plugin_generator('mod_assignment'); $assignments = array(); $assignmentrecord = new stdClass(); $assignmentrecord->course = $this->course->id; $assignmentrecord->timedue = strtotime('1 hour ago'); // Make offline assignment to confuse things. $assignmentrecord->assignmenttype = 'offline'; $assignments[] = $assignmentgenerator->create_instance($assignmentrecord); // Make online text assignment. $assignmentrecord->assignmenttype = 'online'; $assignments[] = $assignmentgenerator->create_instance($assignmentrecord); // Make single file submission assignment. $assignmentrecord->assignmenttype = 'upload'; $assignments[] = $assignmentgenerator->create_instance($assignmentrecord); // Make advanced upload assignment. $assignmentrecord->assignmenttype = 'uploadsingle'; $assignments[] = $assignmentgenerator->create_instance($assignmentrecord); // Currently, we only have create_instance() in the generator, so we need to do this // from scratch. foreach ($assignments as $assignment) { foreach ($this->students as $student) { // Make new submission. // Stuff common to all types first. $submission = new stdClass(); $submission->assignment = $assignment->id; $submission->userid = $student->id; // Now stuff that varies across types to alter the defaults. switch ($assignment->assignmenttype) { case 'offline': // Theoretically impossible, but good to check. break; case 'online': $submission->data1 = 'Text of online essay here'; $submission->data2 = 1; break; case 'upload': $submission->numfiles = 1; $submission->data2 = 'submitted'; break; case 'uploadsingle': $submission->numfiles = 0; $submission->data1 = ''; $submission->data2 = ''; break; } $this->make_assignment_submission($submission); // Add one to the count. if ($assignment->assignmenttype != 'offline') { $submissioncount++; } } } // Make some data to test edge cases. // Deadline not passed. Does not matter. Ought to be picked up. $assignmentrecord = new stdClass(); $assignmentrecord->assignmenttype = 'online'; $assignmentrecord->course = $this->course->id; $assignmentrecord->timedue = strtotime('1 hour'); $assignment = $assignmentgenerator->create_instance($assignmentrecord); $submission = new stdClass(); $submission->assignment = $assignment->id; $submission->userid = $student->id; // One will be left over from the loop. $submission->data1 = 'Text of online essay here'; $submission->data2 = 1; $this->make_assignment_submission($submission); $submissioncount++; // Not finalised. $assignmentrecord = new stdClass(); $assignmentrecord->assignmenttype = 'upload'; $assignmentrecord->course = $this->course->id; $assignment = $assignmentgenerator->create_instance($assignmentrecord); $submission = new stdClass(); $submission->assignment = $assignment->id; $submission->userid = $student->id; // One will be left over from the loop. $submission->numfiles = 1; $submission->data2 = ''; // Should be 'submitted' to be picked up. $this->make_assignment_submission($submission); // Empty feedback? $assignmentrecord = new stdClass(); $assignmentrecord->assignmenttype = 'upload'; $assignmentrecord->course = $this->course->id; $assignment = $assignmentgenerator->create_instance($assignmentrecord); $submission = new stdClass(); $submission->assignment = $assignment->id; $submission->userid = $student->id; // One will be left over from the loop. $submission->numfiles = 1; $submission->data2 = 'submitted'; $submission->submissioncomment = ''; $submission->format = 1; $submission->grade = -1; $this->make_assignment_submission($submission); $submissioncount++; $this->submissioncount += $submissioncount; return $submissioncount; } /** * Makes a fake assignment submission. * * @param stdClass $submissionrecord * @throws coding_exception * @return bool|\stdClass */ private function make_assignment_submission($submissionrecord) { global $DB; if (!isset($submissionrecord->assignment)) { throw new coding_exception('Make submission needs an assignment id.'); } if (!isset($submissionrecord->userid)) { throw new coding_exception('Make submission needs a user id.'); } // Make new submission. // Stuff common to all types first. $submission = new stdClass(); $submission->timecreated = time(); $submission->timemodified = time(); // Now defaults. $submission->numfiles = 0; $submission->data1 = null; $submission->data2 = null; $submission->grade = -1; $submission->submissioncomment = ''; $submission->format = 0; $submission->teacher = 0; $submission->timemarked = 0; $submission->mailed = 0; $extended = (object)array_merge((array)$submission, (array)$submissionrecord); return $DB->insert_record('assignment_submissions', $extended); } /** * Makes forum discussions to be checked against the module query factory. * * @return int how many to expect. */ private function create_forum_submission_data() { global $DB; $submissioncount = 0; // Provide defaults to prevent IDE griping. $student = new stdClass(); $student->id = 3; // Make forums /* @var mod_forum_generator $forumgenerator */ $forumgenerator = $this->getDataGenerator()->get_plugin_generator('mod_forum'); $forumrecord = new stdClass(); $forumrecord->assessed = 1; $forumrecord->scale = 4; $forumrecord->course = $this->course->id; $forumtypes = array( 'single', 'eachuser', 'qanda', 'blog', 'general' ); foreach ($forumtypes as $type) { $forumrecord->type = $type; if (isset($forumrecord->id)) { unset($forumrecord->id); } // Single post forums make a discussion and first post. Needs to be by student. $this->setUser($student->id); $forum = $forumgenerator->create_instance($forumrecord); $this->setAdminUser(); if ($type == 'single') { // Generator will have made a related discussion. $submissioncount++; } // Make discussion. Make sure each student makes one (in case we violate // eachuser constraints). reset($this->students); // Reset counter due to nested loops. foreach ($this->students as $student) { $discussion = new stdClass(); $discussion->course = $this->course->id; $discussion->forum = $forum->id; $discussion->userid = $student->id; $discussion->timemodified = strtotime('1 hour ago'); $discussion->id = $DB->insert_record('forum_discussions', $discussion); $firstpost = new stdClass(); $firstpost->discussion = $discussion->id; $firstpost->parent = 0; $firstpost->created = time(); $firstpost->userid = $student->id; $firstpost->modified = time(); $firstpost->subject = 'First post subject'; $firstpost->message = 'First post message'; $firstpost->id = $DB->insert_record('forum_posts', $firstpost); $discussion->firstpost = $firstpost->id; $DB->update_record('forum_discussions', $discussion); $submissioncount++; // Make some reply posts. Need to copy the array so we can have the pointer in two places at once. $tempstudents = $this->students; reset($tempstudents); foreach ($tempstudents as $replystudent) { if ($replystudent->id == $student->id) { // Eachuser won't like this. continue; } $post = new stdclass(); $post->discussion = $discussion->id; $post->parent = $firstpost->id; // All direct replies to the first post for simplicity. $post->userid = $replystudent->id; $post->created = time(); $post->modified = time(); $post->subject = 'blah'; $post->message = 'blah'; $post->id = $DB->insert_record('forum_posts', $post); $submissioncount++; } } } $this->submissioncount += $submissioncount; return $submissioncount; } /** * Makes test submission data for the assign module. Leaves us with one assignment and a single submission * for each user. * * @return int how many things to expect. */ private function create_assign_submission_data () { $submissioncount = 0; // Provide defaults to prevent IDE griping. $student = new stdClass(); $student->id = 3; /* @var phpunit_module_generator $assigngenerator */ $assigngenerator = new block_ajax_marking_mod_assign_generator($this->getDataGenerator()); $assigns = array(); $assignrecord = new stdClass(); $assignrecord->assessed = 1; $assignrecord->scale = 4; $assignrecord->course = $this->course->id; $this->assigns[] = $assigngenerator->create_instance($assignrecord); foreach ($this->assigns as $assign) { foreach ($this->students as $student) { $submission = new stdClass(); $submission->userid = $student->id; $submission->assignment = $assign->id; $assigngenerator->create_assign_submission($submission); $submissioncount++; } } $this->submissioncount += $submissioncount; return $submissioncount; } /** * Makes test submission data for the quiz module. One quiz, with one essay question and one answer per student. * * @return int how many things to expect. */ private function create_quiz_submission_data() { $submissioncount = 0; // Provide defaults to prevent the IDE griping. $student = new stdClass(); $student->id = 3; /* @var block_ajax_marking_mod_quiz_generator $quizgenerator */ $quizgenerator = new block_ajax_marking_mod_quiz_generator($this->getDataGenerator()); $quizrecord = new stdClass(); $quizrecord->course = $this->course->id; $quiz = $quizgenerator->create_instance($quizrecord); $question = $quizgenerator->make_question($this->course->id); $quizgenerator->add_question_to_quiz($question->id, $quiz); foreach ($this->students as $student) { $this->setUser($student->id); $submissioncount += $quizgenerator->make_student_quiz_atttempt($student, $quiz); } $this->setAdminUser(); $this->submissioncount += $submissioncount; return $submissioncount; } /** * Makes fake submission data for the workshop module so we can see if the block retrieves it * OK. */ private function create_workshop_submission_data() { global $DB; $submissionscount = 0; // Make a workshop. $workshopgenerator = new block_ajax_marking_mod_workshop_generator($this->getDataGenerator()); $workshoprecord = new stdClass(); $workshoprecord->course = $this->course->id; $workshop = $workshopgenerator->create_instance($workshoprecord); // Make a submission for each student. foreach ($this->students as $student) { $submissionscount += $workshopgenerator->make_student_submission($student, $workshop); } // Take it into evaluation mode. $workshop->phase = workshop::PHASE_EVALUATION; $DB->update_record('workshop', $workshop); $this->submissioncount += $submissionscount; return $submissionscount; } /** * This function will run the whole query with all filters against a data set which ought * to all come back, i.e. none of the items will be intercepted by any filters. * * @todo different courses - one in, one out. */ public function test_unmarked_nodes_basic() { // Make all the test data and get a total count back. $this->make_module_submissions(); // Make sure the current user is a teacher in the course. $this->setUser(key($this->teachers)); // Make a full nodes query. Doesn't work without a filter of some sort. $filters = array('courseid' => 'nextnodefilter'); $nodes = block_ajax_marking_nodes_builder_base::unmarked_nodes($filters); $this->assertNotEmpty($nodes, 'No nodes returned at all'); // Compare result. $actual = reset($nodes)->itemcount; $message = 'Wrong number of course nodes: '.$actual.' instead of '.$this->submissioncount; $this->assertEquals($this->submissioncount, $actual, $message); // Now try with coursemoduleid. Counts should be the same as we have only one course. $filters = array( 'courseid' => $this->course->id, 'coursemoduleid' => 'nextnodefilter' ); $nodes = block_ajax_marking_nodes_builder_base::unmarked_nodes($filters); // Compare result. $actual = 0; foreach ($nodes as $node) { $actual += $node->itemcount; } $message = 'Wrong number of coursemodule nodes: '.$actual.' instead of '.$this->submissioncount; $this->assertEquals($this->submissioncount, $actual, $message); } /** * This will test to make sure that when we tell it to group by courseid, we get the right count back. */ public function test_courseid_current() { } /** * This tests the function that takes a load of coursemodule nodes, then attaches the groups and each group's * current display status. * * Need to test: * - Get the groups that are there * - Group to have display 1 if no settings * - Group to have display 1/0 at course level with no coursemodule level setting *- Group to have 1/0 at coursemodule level if set, regardless of the course level setting. */ public function test_attach_groups_to_coursemodule_nodes() { global $USER, $DB; // The setUp() leaves us with 10 users and two teachers in one course. // Make two coursemodules. /* @var phpunit_module_generator $assigngenerator */ $generator = $this->getDataGenerator(); $assigngenerator = new block_ajax_marking_mod_assign_generator($generator); $assignrecord = new stdClass(); $assignrecord->assessed = 1; $assignrecord->scale = 4; $assignrecord->course = $this->course->id; $assign1 = $assigngenerator->create_instance($assignrecord); $assignrecord = new stdClass(); $assignrecord->assessed = 1; $assignrecord->scale = 4; $assignrecord->course = $this->course->id; $assign2 = $assigngenerator->create_instance($assignrecord); // Make two groups. $protptypegroup = new stdClass(); $protptypegroup->courseid = $this->course->id; $group1 = $generator->create_group($protptypegroup); $protptypegroup = new stdClass(); $protptypegroup->courseid = $this->course->id; $group2 = $generator->create_group($protptypegroup); // Make some fake nodes. $nodeswithgroups = array(); $node = new stdClass(); $node->coursemoduleid = $assign1->cmid; $nodeswithgroups[$assign1->cmid] = $node; $node = new stdClass(); $node->coursemoduleid = $assign2->cmid; $nodeswithgroups[$assign2->cmid] = $node; // Test that we get the groups. All should have display = 1. $class = new ReflectionClass('block_ajax_marking_nodes_builder_base'); $method = $class->getMethod('attach_groups_to_coursemodule_nodes'); $method->setAccessible(true); $nodeswithgroups = $method->invokeArgs($class, array($nodeswithgroups)); $this->assertEquals(2, count($nodeswithgroups)); $this->assertEquals(2, count($nodeswithgroups[$assign1->cmid]->groups)); $this->assertEquals(2, count($nodeswithgroups[$assign2->cmid]->groups)); $this->assertArrayHasKey($group1->id, $nodeswithgroups[$assign1->id]->groups); $this->assertArrayHasKey($group2->id, $nodeswithgroups[$assign1->id]->groups); $this->assertEquals(1, $nodeswithgroups[$assign1->id]->groups[$group1->id]->display); $this->assertEquals(1, $nodeswithgroups[$assign1->id]->groups[$group2->id]->display); // Hide one group at course level. $coursesetting = new stdClass(); $coursesetting->userid = $USER->id; $coursesetting->tablename = 'course'; $coursesetting->instanceid = $this->course->id; $coursesetting->display = 1; $coursesetting->groupsdisplay = 1; $coursesetting->showorphans = 1; $coursesetting->id = $DB->insert_record('block_ajax_marking', $coursesetting); $groupsetting = new stdClass(); $groupsetting->configid = $coursesetting->id; $groupsetting->groupid = $group1->id; $groupsetting->display = 0; $groupsetting->id = $DB->insert_record('block_ajax_marking_groups', $groupsetting); // Make some fake nodes. $nodescoursehidden = array(); $node = new stdClass(); $node->coursemoduleid = $assign1->cmid; $nodescoursemodulehidden[$assign1->cmid] = $node; $node = new stdClass(); $node->coursemoduleid = $assign2->cmid; $nodescoursemodulehidden[$assign2->cmid] = $node; $nodescoursemodulehidden = $method->invokeArgs($class, array($nodescoursemodulehidden)); $this->assertEquals(2, count($nodescoursemodulehidden)); $message = 'Wrong number of groups'; $this->assertEquals(2, count($nodescoursemodulehidden[$assign1->cmid]->groups), $message); $this->assertEquals(2, count($nodescoursemodulehidden[$assign2->cmid]->groups), $message); $this->assertArrayHasKey($group1->id, $nodescoursemodulehidden[$assign1->id]->groups); $this->assertArrayHasKey($group2->id, $nodescoursemodulehidden[$assign1->id]->groups); $message = 'Display should be 0 after group was hidden at course level'; $this->assertEquals(0, $nodescoursemodulehidden[$assign1->id]->groups[$group1->id]->display, $message); $this->assertEquals(1, $nodescoursemodulehidden[$assign1->id]->groups[$group2->id]->display); // Now try hiding at course module level. $coursemodulesetting = new stdClass(); $coursemodulesetting->userid = $USER->id; $coursemodulesetting->tablename = 'course_modules'; $coursemodulesetting->instanceid = $assign1->cmid; $coursemodulesetting->display = 1; $coursemodulesetting->groupsdisplay = 1; $coursemodulesetting->showorphans = 1; $coursemodulesetting->id = $DB->insert_record('block_ajax_marking', $coursemodulesetting); $groupsetting = new stdClass(); $groupsetting->configid = $coursemodulesetting->id; $groupsetting->groupid = $group1->id; $groupsetting->display = 1; $groupsetting->id = $DB->insert_record('block_ajax_marking_groups', $groupsetting); // Make some fake nodes. $nodescoursemodulehidden = array(); $node = new stdClass(); $node->coursemoduleid = $assign1->cmid; $nodescoursehidden[$assign1->cmid] = $node; $node = new stdClass(); $node->coursemoduleid = $assign2->cmid; $nodescoursehidden[$assign2->cmid] = $node; $nodescoursehidden = $method->invokeArgs($class, array($nodescoursehidden)); // Now, group 1 should be hidden for assign 2 (no override), but visible for assign 1. $this->assertEquals(2, count($nodescoursehidden)); $message = 'Wrong number of groups'; $this->assertEquals(2, count($nodescoursehidden[$assign1->cmid]->groups), $message); $this->assertEquals(2, count($nodescoursehidden[$assign2->cmid]->groups), $message); $this->assertArrayHasKey($group1->id, $nodescoursehidden[$assign1->id]->groups); $this->assertArrayHasKey($group2->id, $nodescoursehidden[$assign1->id]->groups); $message = 'Display should be 1 after group was made visible at course module level'; $this->assertEquals(1, $nodescoursehidden[$assign1->id]->groups[$group1->id]->display, $message); $this->assertEquals(0, $nodescoursehidden[$assign2->id]->groups[$group1->id]->display); } /** * In case we want to get a coursemodule or something, we may need to know what the id of a module is. * * @param string $modulename * @return int */ protected function get_module_id($modulename) { global $DB; static $cachedids = array(); if (array_key_exists($modulename, $cachedids)) { return $cachedids[$modulename]; } $moduleid = $DB->get_field('modules', 'id', array('name' => $modulename)); $cachedids[$modulename] = $moduleid; return $moduleid; } /** * Makes sure we can get one node only for when the counts will have changed due to a settings tweak. * */ public function test_get_count_for_single_node() { // Make all the test data and get a total count back. $this->make_module_submissions(); // Make sure the current user is a teacher in the course. $this->setUser(key($this->teachers)); $filters = array(); $filters['currentfilter'] = 'courseid'; $filters['filtervalue'] = $this->course->id; $node = block_ajax_marking_nodes_builder_base::get_count_for_single_node($filters); $message = "Wrong number of things returned as the count for a single node. Expected {$this->submissioncount} ". "but got {$node['itemcount']}"; $this->assertEquals($this->submissioncount, $node['itemcount'], $message); } /** * Make nodes for quiz questions to make sure they're there. */ public function test_quiz_question_nodes_work() { global $DB; $this->make_module_submissions(); $this->setUser(key($this->teachers)); // Quiz. $quizmoduleid = $this->get_module_id('quiz'); $quizcoursemodules = $DB->get_records('course_modules', array('module' => $quizmoduleid)); $quizone = reset($quizcoursemodules); $filters = array(); $filters['coursemoduleid'] = $quizone->id; $filters['questionid'] = 'nextnodefilter'; // We know at least one question was made in an empty DB. $nodes = block_ajax_marking_nodes_builder_base::unmarked_nodes($filters); $this->assertInternalType('array', $nodes); } /** * Make sure we get some nodes back for assignment submissions rather than an error. */ public function test_assignment_userid_nodes_work() { global $DB; $this->make_module_submissions(); $this->setUser(key($this->teachers)); // Assignment. $assignmentmoduleid = $this->get_module_id('assignment'); $assignmentcoursemodules = $DB->get_records('course_modules', array('module' => $assignmentmoduleid)); $assignmentone = reset($assignmentcoursemodules); $filters = array(); $filters['coursemoduleid'] = $assignmentone->id; $filters['userid'] = 'nextnodefilter'; $nodes = block_ajax_marking_nodes_builder_base::unmarked_nodes($filters); $this->assertInternalType('array', $nodes); } /** * Makes sure we have the settings attached to the nodes when we ask for them. */ public function test_attach_config_settings_to_nodes() { global $DB; // Make all the test data and get a total count back. $this->make_module_submissions(); // Make sure the current user is a teacher in the course. $teacher = reset($this->teachers); $this->setUser($teacher->id); $filters = array(); $filters['courseid'] = 'nextnodefilter'; // Make a setting to see if we get the value attached. $coursesetting = new stdClass(); $coursesetting->userid = $teacher->id; $coursesetting->tablename = 'course'; $coursesetting->instanceid = $this->course->id; $coursesetting->groupsdisplay = 0; $DB->insert_record('block_ajax_marking', $coursesetting); $nodes = block_ajax_marking_nodes_builder_base::unmarked_nodes($filters); $this->assertNotEmpty($nodes, 'No nodes returned at all'); // Should only be one. $coursenode = reset($nodes); $this->assertObjectHasAttribute('groupsdisplay', $coursenode, 'Course node does not have a groupsdisplay field'); $this->assertNotNull($coursenode->groupsdisplay, 'Course groupsdisplay setting should be zero but is null.'); $message = 'Expected to get the groupsdisplay setting attached to the course node, but it\'s not'; $this->assertEquals(0, $coursenode->groupsdisplay, $message); // Now check for coursemodules. $assign = reset($this->assigns); $filters = array(); $filters['courseid'] = $this->course->id; $filters['coursemoduleid'] = 'nextnodefilter'; $nodes = block_ajax_marking_nodes_builder_base::unmarked_nodes($filters); $foundit = false; foreach ($nodes as $node) { if ($node->coursemoduleid == $assign->cmid) { $foundit = true; $this->assertObjectHasAttribute('groupsdisplay', $node, 'coursemodule node does not have a groupsdisplay field'); $this->assertNull($node->groupsdisplay, 'Did not get groups display as null on coursemodule node'); } } $this->assertTrue($foundit, 'Did not get coursemodule back in nodes array'); // Now override so that 0 at course level becomes 1. $cmsetting = new stdClass(); $cmsetting->userid = $teacher->id; $cmsetting->tablename = 'course_modules'; $cmsetting->instanceid = $assign->cmid; $cmsetting->groupsdisplay = 1; $DB->insert_record('block_ajax_marking', $cmsetting); $nodes = block_ajax_marking_nodes_builder_base::unmarked_nodes($filters); $foundit = false; foreach ($nodes as $node) { if ($node->coursemoduleid == $assign->cmid) { $foundit = true; $this->assertObjectHasAttribute('groupsdisplay', $node, 'coursemodule node does not have a groupsdisplay field'); $this->assertEquals(1, $node->groupsdisplay, 'Did not get groups display as 1 on coursemodule node after override'); } } $this->assertTrue($foundit, 'Did not get coursemodule back in nodes array'); } /** * Makes fake submission data for the coursework module so we can do the tests. There's a need to cover all * possible use cases, so we need: * - One with allocations enabled, one without. The one without should always show up, but the allocations one * should only be OK for when there is an allocation. * - One with feedbacks from another teacher that should still show up * - One with the right number of feedbacks already, which shouldn't show up * - One empty feedback with no grade or comment which should show up. * * @return int the number of submissions to expect. */ private function create_coursework_submission_data() { global $USER; $expectedcount = 0; // Make two submissions, one with and one without allocations. // Make one have single and one multiple marker. $generator = $this->getDataGenerator(); /* @var mod_coursework_generator $courseworkgenerator */ $courseworkgenerator = $generator->get_plugin_generator('mod_coursework'); $firststudent = reset($this->students); $laststudent = end($this->students); $firstteacher = reset($this->teachers); $lastteacher = end($this->teachers); $singlewithallocation = new stdClass(); $singlewithallocation->course = $this->course->id; $singlewithallocation->numberofmarkers = 1; $singlewithallocation->allocationenabled = 1; $singlewithallocation = $courseworkgenerator->create_instance($singlewithallocation); $singlenoallocation = new stdClass(); $singlenoallocation->course = $this->course->id; $singlenoallocation->numberofmarkers = 1; $singlenoallocation->allocationenabled = 0; $singlenoallocation = $courseworkgenerator->create_instance($singlenoallocation); $multiplepartialgraded = new stdClass(); $multiplepartialgraded->course = $this->course->id; $multiplepartialgraded->numberofmarkers = 2; $multiplepartialgraded->allocationenabled = 0; $multiplepartialgraded = $courseworkgenerator->create_instance($multiplepartialgraded); $singleemptyfeedback = new stdClass(); $singleemptyfeedback->course = $this->course->id; $singleemptyfeedback->numberofmarkers = 2; $singleemptyfeedback->allocationenabled = 0; $singleemptyfeedback = $courseworkgenerator->create_instance($singleemptyfeedback); $singleresubmitted = new stdClass(); $singleresubmitted->course = $this->course->id; $singleresubmitted->numberofmarkers = 2; $singleresubmitted->allocationenabled = 0; $singleresubmitted = $courseworkgenerator->create_instance($singleresubmitted); // Now make some submissions for the allocation one. Then one allocation so we can make sure we just // get the right one. The others should remain hidden. foreach ($this->students as $student) { $submission = new stdClass(); $submission->userid = $student->id; $submission->courseworkid = $singlewithallocation->id; $submission = $courseworkgenerator->create_submission($submission, $singlewithallocation); } // The $submission variable will be left as the last one in the list. Make an allocation for just // this one and expect that the others will not show up. $allocation = new stdClass(); $allocation->assessorid = $USER->id; $allocation->studentid = $submission->userid; $allocation->courseworkid = $singlewithallocation->id; $allocation = $courseworkgenerator->create_allocation($allocation); $expectedcount++; // Now try with no allocations and they should all turn up. reset($this->students); foreach ($this->students as $student) { $submission = new stdClass(); $submission->userid = $student->id; $submission->courseworkid = $singlenoallocation->id; $submission = $courseworkgenerator->create_submission($submission, $singlenoallocation); $expectedcount++; } // Now check that when another teacher has made a feedback, we still get it back when there is room // for more feedbacks. $submission = new stdClass(); $submission->userid = $student->id; $submission->courseworkid = $multiplepartialgraded->id; $submission = $courseworkgenerator->create_submission($submission, $multiplepartialgraded); $expectedcount++; // This feedback ought not to matter. $feedback = new stdClass(); $feedback->assessorid = 67; // Using random large teacher ids so we won't have interference. $feedback->submissionid = $submission->id; $feedback->timemodified = time() + 1; // Need to be later than the submission. $feedback = $courseworkgenerator->create_feedback($feedback); // Now make one with the maximum number of feedbacks and make sure it doesn't turn up. // The one we just made will be for the last student in the list. $submission = new stdClass(); $submission->userid = $firststudent->id; $submission->courseworkid = $multiplepartialgraded->id; $submission = $courseworkgenerator->create_submission($submission, $multiplepartialgraded); $feedback = new stdClass(); $feedback->assessorid = 45; $feedback->submissionid = $submission->id; $feedback->timemodified = time() + 1; // Need to be later than the submission. $feedback = $courseworkgenerator->create_feedback($feedback); $feedback = new stdClass(); $feedback->assessorid = 87; $feedback->submissionid = $submission->id; $feedback->timemodified = time() + 1; // Need to be later than the submission. $feedback = $courseworkgenerator->create_feedback($feedback); // Now make one with a feedback by the current user, which should still show up because the feedback // has no grade or comment. We also check that ones which have been graded are missing. $submission = new stdClass(); $submission->userid = $student->id; $submission->courseworkid = $singleemptyfeedback->id; $submission = $courseworkgenerator->create_submission($submission, $singleemptyfeedback); $expectedcount++; // Empty comment and grade - should show up. $feedback = new stdClass(); $feedback->assessorid = $USER->id; $feedback->submissionid = $submission->id; $feedback->timemodified = time() + 1; // Need to be later than the submission. $feedback = $courseworkgenerator->create_feedback($feedback); // This one has a comment and grade, so it ought to not show up. $submission = new stdClass(); $submission->userid = $laststudent->id; $submission->courseworkid = $singleemptyfeedback->id; $submission = $courseworkgenerator->create_submission($submission, $singleemptyfeedback); $feedback = new stdClass(); $feedback->assessorid = $USER->id; $feedback->grade = 65; $feedback->feedbackcomment = 'some text'; $feedback->submissionid = $submission->id; $feedback->timemodified = time() + 1; // Need to be later than the submission. $feedback = $courseworkgenerator->create_feedback($feedback); // TODO test comment OR grade. // TODO Now make one which has been resubmitted after a previous grading to make sure it'll turn up again. $this->submissioncount += $expectedcount; return $expectedcount; } public function test_coursework_query_single_with_allocation() { global $USER, $DB; // Perhaps the coursework module is not here? if (!$DB->record_exists('modules', array('name' => 'coursework', 'visible' => 1))) { return; } $generator = $this->getDataGenerator(); /* @var mod_coursework_generator $courseworkgenerator */ $courseworkgenerator = $generator->get_plugin_generator('mod_coursework'); $singlewithallocation = new stdClass(); $singlewithallocation->course = $this->course->id; $singlewithallocation->numberofmarkers = 1; $singlewithallocation->allocationenabled = 1; $singlewithallocation = $courseworkgenerator->create_instance($singlewithallocation); // Now make some submissions for the allocation one. Then one allocation so we can make sure we just // get the right one. The others should remain hidden. $submission = new stdClass(); foreach ($this->students as $student) { $submission = new stdClass(); $submission->userid = $student->id; $submission->courseworkid = $singlewithallocation->id; $submission = $courseworkgenerator->create_submission($submission, $singlewithallocation); } // The $submission variable will be left as the last one in the list. Make an allocation for just // this one and expect that the others will not show up. $allocation = new stdClass(); $allocation->assessorid = $USER->id; $allocation->studentid = $submission->userid; $allocation->courseworkid = $singlewithallocation->id; $allocation = $courseworkgenerator->create_allocation($allocation); $expectedcount = 1; $actualcount = $this->get_modulequery_count('coursework'); $this->assertEquals($expectedcount, $actualcount, 'Allocations are not showing up right'); } /** * Counts how many items the module query gives us. * * @param string $modulename * @throws coding_exception * @return int */ protected function get_modulequery_count($modulename) { $modclasses = block_ajax_marking_get_module_classes(); if (!array_key_exists($modulename, $modclasses)) { throw new coding_exception('Missing '.$modulename.' module class'); } $modclass = $modclasses[$modulename]; // Make query. $query = $modclass->query_factory(); // We will get an error if we leave it like this as the userids in the first // column are not unique. $wrapper = new block_ajax_marking_query_base(); $wrapper->add_select(array('function' => 'COUNT', 'column' => '*', 'alias' => 'count')); $wrapper->add_from(array('table' => $query, 'alias' => 'modulequery')); // Run query. Get one stdClass with a count property. $unmarkedstuff = $wrapper->execute(); // Make sure we get the right number of things back. return reset($unmarkedstuff)->count; } /** * We need to find out if each individual module works or not. This loops over them testing that we get * something back. */ public function test_individual_modules() { // Make all the test data and get a total count back. // Make sure the current user is a teacher in the course. $moduleclasses = block_ajax_marking_get_module_classes(); foreach ($moduleclasses as $moduleclass) { // Make the test data for just this module. $modname = $moduleclass->get_module_name(); $this->setAdminUser(); $expected = $this->make_module_submissions(array($modname)); $this->setUser(key($this->teachers)); // Make a query for just that module. $countindb = $this->get_modulequery_count($modname); // Make sure we get the right number of things back. $message = 'Found '.$countindb.' things for '.$modname.' instead of '.$expected; $this->assertEquals($expected, $countindb, $message); } } }
orvsd-skol/moodle25
blocks/ajax_marking/tests/nodes_builder_test.php
PHP
gpl-3.0
48,845
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Example - example-example37-production</title> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script> <script src="script.js"></script> </head> <body ng-app="debounceExample"> <div ng-controller="ExampleController"> <form> Name: <input type="text" ng-model="user.name" ng-model-options="{ debounce: 250 }" /><br /> </form> <pre>username = "{{user.name}}"</pre> </div> </body> </html>
oczane/geochat
public/js/lib/docs/examples/example-example37/index-production.html
HTML
gpl-3.0
520
/* ************************************************************************************************************************ * uC/OS-III * The Real-Time Kernel * * (c) Copyright 2009-2011; Micrium, Inc.; Weston, FL * All rights reserved. Protected by international copyright laws. * * APPLICATION HOOKS * * File : OS_APP_HOOKS.C * By : JJL * Version : V3.02.00 * * LICENSING TERMS: * --------------- * uC/OS-III is provided in source form for FREE short-term evaluation, for educational use or * for peaceful research. If you plan or intend to use uC/OS-III in a commercial application/ * product then, you need to contact Micrium to properly license uC/OS-III for its use in your * application/product. We provide ALL the source code for your convenience and to help you * experience uC/OS-III. The fact that the source is provided does NOT mean that you can use * it commercially without paying a licensing fee. * * Knowledge of the source code may NOT be used to develop a similar product. * * Please help us continue to provide the embedded community with the finest software available. * Your honesty is greatly appreciated. * * You can contact us at www.micrium.com, or by phone at +1 (954) 217-2036. ************************************************************************************************************************ */ #include <os.h> #include <os_app_hooks.h> /*$PAGE*/ /* ************************************************************************************************************************ * SET ALL APPLICATION HOOKS * * Description: Set ALL application hooks. * * Arguments : none. * * Note(s) : none ************************************************************************************************************************ */ void App_OS_SetAllHooks (void) { #if OS_CFG_APP_HOOKS_EN > 0u CPU_SR_ALLOC(); CPU_CRITICAL_ENTER(); OS_AppTaskCreateHookPtr = App_OS_TaskCreateHook; OS_AppTaskDelHookPtr = App_OS_TaskDelHook; OS_AppTaskReturnHookPtr = App_OS_TaskReturnHook; OS_AppIdleTaskHookPtr = App_OS_IdleTaskHook; OS_AppStatTaskHookPtr = App_OS_StatTaskHook; OS_AppTaskSwHookPtr = App_OS_TaskSwHook; OS_AppTimeTickHookPtr = App_OS_TimeTickHook; CPU_CRITICAL_EXIT(); #endif } /*$PAGE*/ /* ************************************************************************************************************************ * CLEAR ALL APPLICATION HOOKS * * Description: Clear ALL application hooks. * * Arguments : none. * * Note(s) : none ************************************************************************************************************************ */ void App_OS_ClrAllHooks (void) { #if OS_CFG_APP_HOOKS_EN > 0u CPU_SR_ALLOC(); CPU_CRITICAL_ENTER(); OS_AppTaskCreateHookPtr = (OS_APP_HOOK_TCB)0; OS_AppTaskDelHookPtr = (OS_APP_HOOK_TCB)0; OS_AppTaskReturnHookPtr = (OS_APP_HOOK_TCB)0; OS_AppIdleTaskHookPtr = (OS_APP_HOOK_VOID)0; OS_AppStatTaskHookPtr = (OS_APP_HOOK_VOID)0; OS_AppTaskSwHookPtr = (OS_APP_HOOK_VOID)0; OS_AppTimeTickHookPtr = (OS_APP_HOOK_VOID)0; CPU_CRITICAL_EXIT(); #endif } /*$PAGE*/ /* ************************************************************************************************************************ * APPLICATION TASK CREATION HOOK * * Description: This function is called when a task is created. * * Arguments : p_tcb is a pointer to the task control block of the task being created. * * Note(s) : none ************************************************************************************************************************ */ void App_OS_TaskCreateHook (OS_TCB *p_tcb) { (void)&p_tcb; } /*$PAGE*/ /* ************************************************************************************************************************ * APPLICATION TASK DELETION HOOK * * Description: This function is called when a task is deleted. * * Arguments : p_tcb is a pointer to the task control block of the task being deleted. * * Note(s) : none ************************************************************************************************************************ */ void App_OS_TaskDelHook (OS_TCB *p_tcb) { (void)&p_tcb; } /*$PAGE*/ /* ************************************************************************************************************************ * APPLICATION TASK RETURN HOOK * * Description: This function is called if a task accidentally returns. In other words, a task should either be an * infinite loop or delete itself when done. * * Arguments : p_tcb is a pointer to the OS_TCB of the task that is returning. * * Note(s) : none ************************************************************************************************************************ */ void App_OS_TaskReturnHook (OS_TCB *p_tcb) { (void)&p_tcb; } /*$PAGE*/ /* ************************************************************************************************************************ * APPLICATION IDLE TASK HOOK * * Description: This function is called by the idle task. This hook has been added to allow you to do such things as * STOP the CPU to conserve power. * * Arguments : none * * Note(s) : none ************************************************************************************************************************ */ void App_OS_IdleTaskHook (void) { } /*$PAGE*/ /* ************************************************************************************************************************ * APPLICATION OS INITIALIZATION HOOK * * Description: This function is called by OSInit() at the beginning of OSInit(). * * Arguments : none * * Note(s) : none ************************************************************************************************************************ */ void App_OS_InitHook (void) { } /*$PAGE*/ /* ************************************************************************************************************************ * APPLICATION STATISTIC TASK HOOK * * Description: This function is called every second by uC/OS-III's statistics task. This allows your application to add * functionality to the statistics task. * * Arguments : none * * Note(s) : none ************************************************************************************************************************ */ void App_OS_StatTaskHook (void) { } /*$PAGE*/ /* ************************************************************************************************************************ * APPLICATION TASK SWITCH HOOK * * Description: This function is called when a task switch is performed. This allows you to perform other operations * during a context switch. * * Arguments : none * * Note(s) : 1) Interrupts are disabled during this call. * 2) It is assumed that the global pointer 'OSTCBHighRdyPtr' points to the TCB of the task that will be * 'switched in' (i.e. the highest priority task) and, 'OSTCBCurPtr' points to the task being switched out * (i.e. the preempted task). ************************************************************************************************************************ */ void App_OS_TaskSwHook (void) { } /*$PAGE*/ /* ************************************************************************************************************************ * APPLICATION TICK HOOK * * Description: This function is called every tick. * * Arguments : none * * Note(s) : 1) This function is assumed to be called from the Tick ISR. ************************************************************************************************************************ */ void App_OS_TimeTickHook (void) { }
zhaocongcan/LPQ26X_SoftCode
uCOS-III/Cfg/os_app_hooks.c
C
gpl-3.0
8,496
/* Copyright (c) 2004-2016 by Jakob Schröter <js@camaya.net> This file is part of the gloox library. http://camaya.net/gloox This software is distributed under a license. The full license agreement can be found in the file LICENSE in this distribution. This software may not be copied, modified, sold or distributed other than expressed in the named license agreement. This software is distributed without any warranty. */ #ifndef PUBSUBEVENT_H__ #define PUBSUBEVENT_H__ #include "stanzaextension.h" #include "pubsub.h" #include "gloox.h" namespace gloox { class Tag; namespace PubSub { /** * @brief This is an implementation of a PubSub Notification as a StanzaExtension. * * @author Vincent Thomasset <vthomasset@gmail.com> * @since 1.0 */ class GLOOX_API Event : public StanzaExtension { public: /** * Stores a retract or item notification. */ struct ItemOperation { /** * Constructor. * * @param remove Whether this is a retract operation or not (ie item). * @param itemid Item ID of this item. * @param pld Payload for this object (in the case of a non transient * item notification). */ ItemOperation( bool remove, const std::string& itemid, const Tag* pld = 0 ) : retract( remove ), item( itemid ), payload( pld ) {} /** * Copy constructor. * @param right The ItemOperation to copy from. */ ItemOperation( const ItemOperation& right ); bool retract; std::string item; const Tag* payload; }; /** * A list of ItemOperations. */ typedef std::list<ItemOperation*> ItemOperationList; /** * PubSub event notification Stanza Extension. * @param event A tag to parse. */ Event( const Tag* event ); /** * PubSub event notification Stanza Extension. * @param node The node's ID for which the notification is sent. * @param type The event's type. */ Event( const std::string& node, PubSub::EventType type ); /** * Virtual destructor. */ virtual ~Event(); /** * Returns the event's type. * @return The event's type. */ PubSub::EventType type() const { return m_type; } /** * Returns the list of subscription IDs for which this notification * is valid. * @return The list of subscription IDs. */ const StringList& subscriptions() const { return m_subscriptionIDs ? *m_subscriptionIDs : m_emptyStringList; } /** * Returns the list of ItemOperations for EventItems(Retract) notification. * @return The list of ItemOperations. */ const ItemOperationList& items() const { return m_itemOperations ? *m_itemOperations : m_emptyOperationList; } /** * Add an item to the list of ItemOperations for EventItems(Retract) notification. * After calling, the PubSub::Event object owns the ItemOperation and will free it. * @param op An ItemOperation to add. */ void addItem( ItemOperation* op ); /** * Returns the node's ID for which the notification is sent. * @return The node's ID. */ const std::string& node() const { return m_node; } /** * Returns the subscribe/unsubscribed JID. Only set for subscription notifications * (type() == EventSubscription). * @return The affected JID. */ const JID& jid() { return m_jid; } /** * Returns the subscription state. Only set for subscription notifications * (type() == EventSubscription). * @return @b True if the subscription request was approved, @b false otherwise. */ bool subscription() { return m_subscription; } // reimplemented from StanzaExtension const std::string& filterString() const; // reimplemented from StanzaExtension StanzaExtension* newInstance( const Tag* tag ) const { return new Event( tag ); } // reimplemented from StanzaExtension Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const; private: Event& operator=( const Event& ); PubSub::EventType m_type; std::string m_node; StringList* m_subscriptionIDs; JID m_jid; Tag* m_config; ItemOperationList* m_itemOperations; std::string m_collection; bool m_subscription; const ItemOperationList m_emptyOperationList; const StringList m_emptyStringList; }; } } #endif // PUBSUBEVENT_H__
vanklompf/gloox
src/pubsubevent.h
C
gpl-3.0
4,984
package net.minecraft.util.datafix.walkers; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.datafix.DataFixesManager; import net.minecraft.util.datafix.IDataFixer; public class ItemStackDataLists extends Filtered { private final String[] matchingTags; public ItemStackDataLists(String id, String... tags) { super("id", id); this.matchingTags = tags; } NBTTagCompound filteredProcess(IDataFixer fixer, NBTTagCompound compound, int versionIn) { for (String s : this.matchingTags) { compound = DataFixesManager.processInventory(fixer, compound, versionIn, s); } return compound; } }
TheValarProject/AwakenDreamsClient
mcp/src/minecraft/net/minecraft/util/datafix/walkers/ItemStackDataLists.java
Java
gpl-3.0
692
package main import ( h "goshawkdb.io/tests/harness" "log" "time" ) func main() { setup := h.NewSetup() config1, err := h.NewPathProvider("./v1.json", false) if err != nil { log.Fatal(err) } config2, err := h.NewPathProvider("./v2.json", false) if err != nil { log.Fatal(err) } rm1 := setup.NewRM("one", 10001, nil, config1) rm2 := setup.NewRM("two", 10002, nil, config1) rm3 := setup.NewRM("three", 10003, nil, config1) rm4 := setup.NewRM("four", 10004, nil, config2) prog := h.Program([]h.Instruction{ setup, rm1.Start(), rm2.Start(), rm3.Start(), setup.Sleep(5 * time.Second), rm4.Start(), setup.Sleep(15 * time.Second), rm1.Terminate(), rm2.Terminate(), rm3.Terminate(), rm4.Terminate(), rm1.Wait(), rm2.Wait(), rm3.Wait(), rm4.Wait(), }) log.Println(h.Run(setup, prog)) }
goshawkdb/tests
topology/repl/8/main.go
GO
gpl-3.0
837
package fr.lium.experimental.spkDiarization.programs; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.StringTokenizer; import java.util.TreeMap; import java.util.logging.Level; import java.util.logging.Logger; import www.spatial.maine.edu.assignment.HungarianAlgorithm; import fr.lium.experimental.spkDiarization.libClusteringData.speakerName.SpeakerName; import fr.lium.experimental.spkDiarization.libClusteringData.speakerName.SpeakerNameSet; import fr.lium.experimental.spkDiarization.libClusteringData.transcription.Entity; import fr.lium.experimental.spkDiarization.libClusteringData.transcription.EntitySet; import fr.lium.experimental.spkDiarization.libClusteringData.transcription.Link; import fr.lium.experimental.spkDiarization.libClusteringData.transcription.LinkSet; import fr.lium.experimental.spkDiarization.libClusteringData.turnRepresentation.Turn; import fr.lium.experimental.spkDiarization.libClusteringData.turnRepresentation.TurnSet; import fr.lium.experimental.spkDiarization.libNamedSpeaker.AssociatioAudioVideo; import fr.lium.experimental.spkDiarization.libNamedSpeaker.SpeakerNameUtils; import fr.lium.experimental.spkDiarization.libNamedSpeaker.TargetNameMap; import fr.lium.experimental.spkDiarization.libSCTree.SCTProbabilities; import fr.lium.spkDiarization.lib.DiarizationException; import fr.lium.spkDiarization.lib.MainTools; import fr.lium.spkDiarization.lib.SpkDiarizationLogger; import fr.lium.spkDiarization.lib.libDiarizationError.DiarizationError; import fr.lium.spkDiarization.libClusteringData.Cluster; import fr.lium.spkDiarization.libClusteringData.ClusterSet; import fr.lium.spkDiarization.libClusteringData.Segment; import fr.lium.spkDiarization.libModel.ModelScores; import fr.lium.spkDiarization.parameter.Parameter; /** * The Class SpeakerIdenificationDecision2. */ public class SpeakerIdenificationDecision2 { /** The Constant logger. */ private final static Logger logger = Logger.getLogger(SpeakerIdenificationDecision2.class.getName()); /** The previous threshold. */ public static double PREVIOUS_THRESHOLD = 0.05; /** The current threshold. */ public static double CURRENT_THRESHOLD = 0.05; /** The next threshold. */ public static double NEXT_THRESHOLD = 0.05; /** The parameter. */ static Parameter parameter; /** The name and gender map. */ static TargetNameMap nameAndGenderMap; /** The personne list. */ static LinkedList<String> personneList; /** The first name and gender map. */ static TargetNameMap firstNameAndGenderMap; /** The score keys. */ static String scoreKeys[] = { "audio-score", "trans-score", "writing-score", "ocrSpk-score", "ocrHead-score", "video-score" }; /** The name keys. */ static String nameKeys[] = { "audio-name", "trans-name", "writing-name", "ocrSpk-name", "ocrHead-name", "video-name" }; /** * Print the available options. * * @param parameter is all the parameters * @param program name of this program * @throws IllegalArgumentException the illegal argument exception * @throws IllegalAccessException the illegal access exception * @throws InvocationTargetException the invocation target exception */ public static void info(Parameter parameter, String program) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (parameter.help) { logger.config(parameter.getSeparator2()); logger.config("Program name = " + program); logger.config(parameter.getSeparator()); parameter.logShow(); parameter.getParameterSegmentationInputFile().logAll(); // sInMask parameter.getParameterSegmentationOutputFile().logAll(); // sOutMask logger.config(parameter.getSeparator()); parameter.getParameterNamedSpeaker().logAll(); } } /** * Gets the first name. * * @param name the name * @return the first name */ protected static String getFirstName(String name) { String first = new String(name); StringTokenizer tokenizer = new StringTokenizer(first, "_"); if (tokenizer.hasMoreTokens()) { first = tokenizer.nextToken(); } return first; } /** * For each Solution of the SolutionsSet, put probabilities in the Cluster of the previous, current and next Turn for the target speaker. * * @param probabilities the probabilities * @param speakerName the name of the target speaker * @param turnSet list of turn * @param index index of the current turn in turns * * TODO make permutation of speaker name word (firstname/lastname - lastname/firstname) * @return the string */ public static String putSpeakerName(SCTProbabilities probabilities, String speakerName, TurnSet turnSet, int index) { // SCTProbabilities probabilities = solution.getProbabilities(); String normalizedSpeakerName = SpeakerNameUtils.normalizeSpeakerName(speakerName); String speakerGender; if (parameter.getParameterNamedSpeaker().isFirstNameCheck()) { StringTokenizer tokenizer = new StringTokenizer(normalizedSpeakerName, "_"); if (tokenizer.hasMoreTokens()) { normalizedSpeakerName = tokenizer.nextToken(); } speakerGender = firstNameAndGenderMap.get(normalizedSpeakerName); logger.finest("normalized speaker name: " + normalizedSpeakerName + ", speakerGender firstname checked: " + speakerGender); } else { speakerGender = nameAndGenderMap.get(normalizedSpeakerName); logger.finest("normalized speaker name: " + normalizedSpeakerName + ", speakerGender name checked: " + speakerGender); } // logger.fine("normalized speaker name:" + normalizedSpeakerName + " gender is:" + speakerGender); Turn turn; double scorePrev = 0, scoreCurrent = 0, scoreNext = 0.0; // boolean maximum = parameter.getParameterNamedSpeaker().isMaximum(); // previous turn if ((index - 1) >= 0) { turn = turnSet.get(index - 1); // String previousName = SpeakerNameUtils.normalizeSpeakerName(turn.getCluster().getName()); scorePrev = probabilities.get(SpeakerNameUtils.PREVIOUS); if ((checkGender(turn, speakerGender) == true) && (scorePrev > PREVIOUS_THRESHOLD)) { logger.info("ACCEPT trans: " + turn.getCluster().getName() + " --> " + speakerName + " = " + scorePrev + " previous= " + turn.first().getStart()); addScore(turn, speakerName, scorePrev); } } // Current turn turn = turnSet.get(index); // String currentName = SpeakerNameUtils.normalizeSpeakerName(turn.getCluster().getName()); scoreCurrent = probabilities.get(SpeakerNameUtils.CURRENT); if ((checkGender(turn, speakerGender) == true) && (scoreCurrent > CURRENT_THRESHOLD)) { logger.info("ACCEPT trans: " + turn.getCluster().getName() + " --> " + speakerName + " = " + scoreCurrent + " current= " + turn.first().getStart()); addScore(turn, speakerName, scoreCurrent); } // newt turn if ((index + 1) < turnSet.size()) { turn = turnSet.get(index + 1); scoreNext = probabilities.get(SpeakerNameUtils.NEXT); String nextName = SpeakerNameUtils.normalizeSpeakerName(turn.getCluster().getName()); if ((checkGender(turn, speakerGender) == true) && (scoreNext > NEXT_THRESHOLD)) { logger.info("ACCEPT trans: " + nextName + " --> " + speakerName + " = " + scoreNext + " next= " + turn.first().getStart()); addScore(turn, speakerName, scoreNext); } } speakerName = SpeakerNameUtils.normalizeSpeakerName(speakerName); return speakerName; } /** * Put max speaker name. * * @param probabilities the probabilities * @param speakerName the speaker name * @param turnSet the turn set * @param index the index * @return the string */ public static String putMaxSpeakerName(SCTProbabilities probabilities, String speakerName, TurnSet turnSet, int index) { // SCTProbabilities probabilities = solution.getProbabilities(); String normalizedSpeakerName = SpeakerNameUtils.normalizeSpeakerName(speakerName); String speakerGender; if (parameter.getParameterNamedSpeaker().isFirstNameCheck()) { StringTokenizer tokenizer = new StringTokenizer(normalizedSpeakerName, "_"); if (tokenizer.hasMoreTokens()) { normalizedSpeakerName = tokenizer.nextToken(); } speakerGender = firstNameAndGenderMap.get(normalizedSpeakerName); logger.finest("normalized speaker name: " + normalizedSpeakerName + ", speakerGender firstname checked: " + speakerGender); } else { speakerGender = nameAndGenderMap.get(normalizedSpeakerName); logger.finest("normalized speaker name: " + normalizedSpeakerName + ", speakerGender name checked: " + speakerGender); } Turn turn = turnSet.get(index); Turn turnMax = null; String label = SpeakerNameUtils.OTHER; double score = probabilities.get(SpeakerNameUtils.OTHER); double scoreMax = score; score = probabilities.get(SpeakerNameUtils.INSHOW); if (score > scoreMax) { scoreMax = score; label = SpeakerNameUtils.INSHOW; } score = probabilities.get(SpeakerNameUtils.CURRENT); if (((checkGender(turn, speakerGender) == true) && (score > CURRENT_THRESHOLD)) == false) { if (score > scoreMax) { scoreMax = score; turnMax = null; label = SpeakerNameUtils.CURRENT; } } // previous turn if ((index - 1) >= 0) { turn = turnSet.get(index - 1); score = probabilities.get(SpeakerNameUtils.PREVIOUS); if ((checkGender(turn, speakerGender) == true) && (score > PREVIOUS_THRESHOLD)) { if (score > scoreMax) { scoreMax = score; turnMax = turn; label = SpeakerNameUtils.PREVIOUS; } } } if ((index + 1) < turnSet.size()) { turn = turnSet.get(index + 1); score = probabilities.get(SpeakerNameUtils.NEXT); if ((checkGender(turn, speakerGender) == true) && (score > NEXT_THRESHOLD)) { if (score > scoreMax) { scoreMax = score; turnMax = turn; label = SpeakerNameUtils.NEXT; } } } if (turnMax != null) { logger.info("ACCEPT MAX trans: " + turnMax.getCluster().getName() + " --> " + speakerName + " = " + scoreMax + " max= " + turnMax.first().getStart() + " label:" + label); addScore(turnMax, speakerName, scoreMax); } return speakerName; } /** * Check coherence of genres between the target speaker name and the gender of the trun . * * @param turn the turn * @param speakerGender the speaker gender * * @return true, if successful */ public static boolean checkGender(Turn turn, String speakerGender) { // logger.info("gender speaker:" + speakerGender + " check=" + parameter.getParameterNamedSpeaker().isDontCheckGender()); if (parameter.getParameterNamedSpeaker().isDontCheckGender() == false) { // logger.info("gender check speaker:" + speakerGender + " turn=" + turn.getCluster().getGender()); if ((turn.getCluster().getGender().equals(speakerGender) == false) && (speakerGender != null) && !"U".equals(speakerGender)) { return false; } } return true; } /** * Adds the score to the cluster attached to the turn. * * @param turn the turn link to a cluster * @param name the name of the target speaker * @param value the score */ public static void addScore(Turn turn, String name, double value) { Cluster cluster = turn.getCluster(); SpeakerName speakerName = cluster.getSpeakerName(name); speakerName.addScoreCluster(value); } /** * Checks if is start with speaker name. * * @param speakerName the speaker name * @param list the list * @return the string */ public static String isStartWithSpeakerName(String speakerName, LinkedList<String> list) { String partialName = SpeakerNameUtils.normalizeSpeakerName(speakerName) + "_"; for (String name : list) { if (name.startsWith(partialName)) { return name; } } return null; } /** * Check gender. * * @param cluster the cluster * @param speakerName the speaker name * @return true, if successful */ public static boolean checkGender(Cluster cluster, String speakerName) { String speakerGender = "U"; String normalizedSpeakerName = SpeakerNameUtils.normalizeSpeakerName(speakerName); if (parameter.getParameterNamedSpeaker().isFirstNameCheck()) { StringTokenizer tokenizer = new StringTokenizer(normalizedSpeakerName, "_"); if (tokenizer.hasMoreTokens()) { normalizedSpeakerName = tokenizer.nextToken(); } speakerGender = firstNameAndGenderMap.get(normalizedSpeakerName); logger.finest("normalized speaker name: " + normalizedSpeakerName + ", speakerGender firstname checked: " + speakerGender); } else { speakerGender = nameAndGenderMap.get(normalizedSpeakerName); logger.finest("normalized speaker name: " + normalizedSpeakerName + ", speakerGender name checked: " + speakerGender); } // logger.info("gender speaker:" + speakerGender + " check=" + parameter.getParameterNamedSpeaker().isDontCheckGender()); if (parameter.getParameterNamedSpeaker().isDontCheckGender() == false) { // logger.info("gender check speaker:" + speakerGender + " turn=" + turn.getCluster().getGender()); if ((cluster.getGender().equals(speakerGender) == false) && (speakerGender != null) && !"U".equals(speakerGender)) { return false; } } return true; } /** * Put audio score. * * @param clusterSet the cluster set */ public static void putAudioScore(ClusterSet clusterSet) { boolean isCloseListCheck = parameter.getParameterNamedSpeaker().isCloseListCheck(); logger.info("------ Use Audio ------"); if (parameter.getParameterNamedSpeaker().isUseAudio()) { double thr = parameter.getParameterNamedSpeaker().getThresholdAudio(); for (String name : clusterSet) { Cluster cluster = clusterSet.getCluster(name); ModelScores modelScores = cluster.getModelScores(); for (String identity : modelScores.keySet()) { if (SpeakerNameUtils.checkSpeakerName(identity, isCloseListCheck, nameAndGenderMap, firstNameAndGenderMap) == true) { if (checkGender(cluster, identity) == true) { double score = modelScores.get(identity); if (score > thr) { SpeakerName speakerName = cluster.getSpeakerName(SpeakerNameUtils.normalizeSpeakerName(identity)); speakerName.addScoreCluster(score); logger.info("ACCEPT Audio name : " + cluster.getName() + " (" + cluster.getGender() + ") --> " + identity + " = " + score + " (" + thr + ")"); } else { logger.finest("REJECT Audio THR : " + cluster.getName() + " --> " + identity + " = " + score + " (" + thr + ")"); } } else { logger.finest("REJECT Audio GENDER : " + cluster.getName() + " (" + cluster.getGender() + ") --> " + identity + " gender "); } } else { logger.finest("REJECT Audio LIST : " + cluster.getName() + " (" + cluster.getGender() + ") --> " + identity + " gender "); } } } } } /** * Put audio score max. * * @param clusterSet the cluster set */ public static void putAudioScoreMax(ClusterSet clusterSet) { logger.info("------ Use Audio ------"); boolean isCloseListCheck = parameter.getParameterNamedSpeaker().isCloseListCheck(); if (parameter.getParameterNamedSpeaker().isUseAudio()) { double thr = parameter.getParameterNamedSpeaker().getThresholdAudio(); for (String name : clusterSet) { Cluster cluster = clusterSet.getCluster(name); ModelScores modelScores = cluster.getModelScores(); double max = -Double.MAX_VALUE; String maxIdentity = "empty"; for (String identity : modelScores.keySet()) { if (SpeakerNameUtils.checkSpeakerName(identity, isCloseListCheck, nameAndGenderMap, firstNameAndGenderMap) == true) { if (checkGender(cluster, identity) == true) { double score = modelScores.get(identity); if ((score > thr) && (score > max)) { max = score; maxIdentity = identity; } } } } if (max > -Double.MAX_VALUE) { SpeakerName speakerName = cluster.getSpeakerName(SpeakerNameUtils.normalizeSpeakerName(maxIdentity)); speakerName.addScoreCluster(max); logger.info("ACCEPT Audio MAX name max : " + cluster.getName() + ") --> " + maxIdentity + " = " + max + " (" + thr + ")"); } } } } /** * Put video score. * * @param clusterSet the cluster set */ public static void putVideoScore(ClusterSet clusterSet) { logger.info("------ Use Video ------"); boolean isCloseListCheck = parameter.getParameterNamedSpeaker().isCloseListCheck(); if (parameter.getParameterNamedSpeaker().isUseVideo()) { double thr = parameter.getParameterNamedSpeaker().getThresholdVideo(); for (String name : clusterSet) { Cluster cluster = clusterSet.getCluster(name); ModelScores modelScores = cluster.getModelScores(); double max = -Double.MAX_VALUE; String maxIdentity = "empty"; for (String identity : modelScores.keySet()) { if (SpeakerNameUtils.checkSpeakerName(identity, isCloseListCheck, nameAndGenderMap, firstNameAndGenderMap) == true) { if (checkGender(cluster, identity) == true) { double score = modelScores.get(identity); if ((score > thr) && (score > max)) { max = score; maxIdentity = identity; } } } } if (max > -Double.MAX_VALUE) { SpeakerName speakerName = cluster.getSpeakerName(SpeakerNameUtils.normalizeSpeakerName(maxIdentity)); speakerName.addScoreCluster(max); logger.info("ACCEPT Video name max : " + cluster.getName() + ") --> " + maxIdentity + " = " + max + " (" + thr + ")"); } } } } /** * Put writing max. * * @param audioClusterSet the audio cluster set * @param thr the thr */ public static void putWritingMax(ClusterSet audioClusterSet, double thr) { // stratégie : si l'EN pers est co boolean isCloseListCheck = parameter.getParameterNamedSpeaker().isCloseListCheck(); logger.info("------ Use Writing ------"); // double thr = parameter.getParameterNamedSpeaker().getThresholdWriting(); if (parameter.getParameterNamedSpeaker().isUseWriting()) { Cluster writing = audioClusterSet.getWriting(); for (Segment writingSegment : writing) { EntitySet entitySet = writingSegment.getTranscription().getEntitySet(); for (Entity entity : entitySet) { // if ((entity.isPerson() == true)){ if ((entity.isPerson() == true) && (entity.start() == 0)) { String name = entity.getListOfWords(); String person = SpeakerNameUtils.normalizeSpeakerName(name); if (SpeakerNameUtils.checkSpeakerName(person, isCloseListCheck, nameAndGenderMap, firstNameAndGenderMap) == true) { int nbMatch = 0; double maxRate = 0; Segment matchSegment = null; for (Cluster cluster : audioClusterSet.getClusterVectorRepresentation()) { for (Segment segment : cluster) { int m = DiarizationError.match(writingSegment, segment); double rate = m / (double) writingSegment.getLength(); if (rate >= thr) { nbMatch++; } if (rate >= maxRate) { maxRate = rate; matchSegment = segment; } /* * if ((rate >= maxRate) && (rate >= thr)) { nbMatch++; maxRate = rate; matchHeadSegment = segment; } */ } } if ((nbMatch == 1) && (maxRate > thr)) { Cluster cluster = matchSegment.getCluster(); // if(nbMatch > 0) { if (checkGender(cluster, person) == true) { SpeakerName speakerName = cluster.getSpeakerName(person); speakerName.addScoreCluster(thr); // speakerName.addScoreCluster(thr); logger.info("ACCEPT WRITING name : " + cluster.getName() + " --> " + person + " = " + maxRate); } else { logger.info("REJECT WRITING name : " + cluster.getName() + " --> " + person + " = " + thr + " / gender"); } } else { logger.info("REJECT WRITING name : UNK --> " + person + " = " + thr + " / nbMatch: " + nbMatch + " maxRate:" + maxRate); } } else { logger.info("REJECT WRITING name : " + person + " / list"); } } } } } } /** * Put writing. * * @param audioClusterSet the audio cluster set * @param thr the thr */ public static void putWriting(ClusterSet audioClusterSet, double thr) { // stratégie : si l'EN pers est co boolean isCloseListCheck = parameter.getParameterNamedSpeaker().isCloseListCheck(); logger.info("------ Use Writing ------"); // double thr = parameter.getParameterNamedSpeaker().getThresholdWriting(); if (parameter.getParameterNamedSpeaker().isUseWriting()) { Cluster writing = audioClusterSet.getWriting(); for (Segment writingSegment : writing) { EntitySet entitySet = writingSegment.getTranscription().getEntitySet(); for (Entity entity : entitySet) { if ((entity.isPerson() == true) && (entity.start() == 0)) { String name = entity.getListOfWords(); String person = SpeakerNameUtils.normalizeSpeakerName(name); if (SpeakerNameUtils.checkSpeakerName(person, isCloseListCheck, nameAndGenderMap, firstNameAndGenderMap) == true) { for (Cluster cluster : audioClusterSet.getClusterVectorRepresentation()) { for (Segment segment : cluster) { int m = DiarizationError.match(writingSegment, segment); double rate = m / (double) writingSegment.getLength(); if (rate >= thr) { // if(nbMatch > 0) { if (checkGender(cluster, person) == true) { SpeakerName speakerName = cluster.getSpeakerName(person); speakerName.addScoreCluster(rate); logger.info("ACCEPT WRITING name : " + cluster.getName() + " --> " + person + " = " + rate); } else { logger.info("REJECT WRITING name : " + cluster.getName() + " --> " + person + " = " + thr + " / gender"); } } } } } else { logger.info("REJECT WRITING name : " + person + " / list"); } } } } } } /** * Put transcription score. * * @param clusterSet the cluster set * @throws CloneNotSupportedException the clone not supported exception * @throws DiarizationException the diarization exception */ public static void putTranscriptionScore(ClusterSet clusterSet) throws CloneNotSupportedException, DiarizationException { logger.info("------ Use Transcription ------"); if (parameter.getParameterNamedSpeaker().isUseTranscription()) { personneList = new LinkedList<String>(); TurnSet turns = clusterSet.getTurns(); boolean isCloseListCheck = parameter.getParameterNamedSpeaker().isCloseListCheck(); for (int i = 0; i < turns.size(); i++) { Turn currentTurn = turns.get(i); LinkSet linkSet = currentTurn.getCollapsedLinkSet(); boolean startTurn = true; boolean endTurn = true; SpeakerNameUtils.makeLinkSetForSCT(linkSet, startTurn, endTurn); for (int index = 0; index < linkSet.size(); index++) { Link link = linkSet.getLink(index); if (link.haveEntity(EntitySet.TypePersonne) == true) { SCTProbabilities probabilities = link.getEntity().getScore("SCT"); String speakerName = link.getWord(); if (SpeakerNameUtils.checkSpeakerName(speakerName, isCloseListCheck, nameAndGenderMap, firstNameAndGenderMap) == true) { /* * String ch = ""; for (String key : probabilities.keySet()) { ch += " "+key+":"+probabilities.get(key); } */ String normalizedName; // if (parameter.getParameterNamedSpeaker().isMaximum()) { // normalizedName = putSpeakerName(probabilities, speakerName, turns, i); // } else { normalizedName = putMaxSpeakerName(probabilities, speakerName, turns, i); // } personneList.addFirst(normalizedName); } } } } } } /** * Decide maximum. * * @param clusterSet the cluster set * @param scoreKey the score key * @param nameKey the name key * @return the cluster set */ public static ClusterSet decideMaximum(ClusterSet clusterSet, String scoreKey, String nameKey) { logger.info("------ Maximum decision ------"); ClusterSet clusterSetResult = clusterSet.clone(); ClusterSet videoClusterSetResult = null; if (clusterSet.getHeadClusterSet() != null) { videoClusterSetResult = clusterSet.getHeadClusterSet().clone(); } for (String name : clusterSet) { Cluster cluster = clusterSetResult.getCluster(name); SpeakerNameSet spkNameSet = cluster.getSpeakerNameSet(); if (spkNameSet.size() == 0) { continue; } SpeakerName winer = spkNameSet.getMaxScore(); if ((videoClusterSetResult != null) && (videoClusterSetResult.getCluster(name) != null)) { // videoClusterSetResult.getCluster(name).setName(winer.getName()); videoClusterSetResult.getCluster(name).setInformation(nameKey, winer.getName()); videoClusterSetResult.getCluster(name).setInformation(scoreKey, winer.getScore()); logger.info(String.format("ASSIGN VIDEO MAX %s (%s) -->%s = %.2f", name, cluster.getGender(), winer.getName(), winer.getScore()).toString()); } // --ici -- // cluster.setName(winer.getName()); cluster.setInformation(nameKey, winer.getName()); cluster.setInformation(scoreKey, winer.getScore()); logger.info(String.format("ASSIGN AUDIO MAX %s (%s) -->%s = %.2f", name, cluster.getGender(), winer.getName(), winer.getScore()).toString()); } return clusterSetResult; } /** * Assign the candidate speaker name to cluster. Use the Hungarian Algorithm * * @param clusterSet the clusters * @param scoreKey the score key * @param nameKey the name key * @return the a new cluster set */ public static ClusterSet decideHungarian(ClusterSet clusterSet, String scoreKey, String nameKey) { logger.info("------ decide hungrarian ------"); ClusterSet clusterSetResult = clusterSet.clone(); clusterSetResult.setHeadClusterSet(clusterSet.getHeadClusterSet().clone()); TreeMap<String, Integer> clusterNameIndexMap = new TreeMap<String, Integer>(); TreeMap<String, Integer> speakerNameIndexMap = new TreeMap<String, Integer>(); TreeMap<Integer, String> reverseClusterNameIndexMap = new TreeMap<Integer, String>(); TreeMap<Integer, String> reverseSpeakerNameIndexMap = new TreeMap<Integer, String>(); // ClusterSet videoClusterSet = clusterSet.getHeadClusterSet(); ClusterSet videoClusterSetResult = clusterSetResult.getHeadClusterSet(); int clusterIndex = 0; int spkIndex = 0; for (String name : clusterSet) { Cluster cluster = clusterSet.getCluster(name); SpeakerNameSet spkNameSet = cluster.getSpeakerNameSet(); if (spkNameSet.size() == 0) { continue; } clusterNameIndexMap.put(name, clusterIndex); reverseClusterNameIndexMap.put(clusterIndex, name); Iterator<String> itr = spkNameSet.iterator(); while (itr.hasNext()) { String key = itr.next(); SpeakerName spkName = spkNameSet.get(key); if (!speakerNameIndexMap.containsKey(spkName.getName())) { speakerNameIndexMap.put(spkName.getName(), spkIndex); reverseSpeakerNameIndexMap.put(spkIndex, spkName.getName()); spkIndex++; } } clusterIndex++; } double[][] costMatrix = new double[clusterNameIndexMap.size()][speakerNameIndexMap.size()]; // Start by assigning a great value to each entry (worst value) for (int i = 0; i < clusterNameIndexMap.size(); i++) { for (int j = 0; j < speakerNameIndexMap.size(); j++) { // costMatrix[i][j]=Float.MAX_VALUE; costMatrix[i][j] = 0; } } clusterIndex = 0; spkIndex = 0; for (String name : clusterSet) { Cluster cluster = clusterSet.getCluster(name); SpeakerNameSet spkNameSet = cluster.getSpeakerNameSet(); if (spkNameSet.size() == 0) { continue; } clusterIndex = clusterNameIndexMap.get(name); Iterator<String> itr = spkNameSet.iterator(); while (itr.hasNext()) { String key = itr.next(); SpeakerName spkName = spkNameSet.get(key); spkIndex = speakerNameIndexMap.get(spkName.getName()); costMatrix[clusterIndex][spkIndex] = spkName.getScore(); } } boolean transposed = false; if ((costMatrix.length > 0) && (costMatrix.length > costMatrix[0].length)) { logger.finest("Array transposed (because rows>columns).\n"); // Cols must be >= Rows. costMatrix = HungarianAlgorithm.transpose(costMatrix); transposed = true; } logger.finest("(Printing out only 2 decimals)"); logger.finest("The matrix is:"); String log = ""; for (double[] element : costMatrix) { for (double element2 : element) { log += String.format("%.2f ", element2).toString(); } logger.finest(log); } if (costMatrix.length > 0) { String sumType = "max"; int[][] assignment = new int[costMatrix.length][2]; assignment = HungarianAlgorithm.hgAlgorithm(costMatrix, sumType); // Call Hungarian algorithm. logger.finest("The winning assignment (" + sumType + " sum) is:\n"); double sum = 0; for (int[] element : assignment) { // <COMMENT> to avoid printing the elements that make up the assignment String clusterName; String newName; if (!transposed) { clusterName = clusterSet.getCluster(reverseClusterNameIndexMap.get(element[0])).getName(); newName = reverseSpeakerNameIndexMap.get(element[1]); } else { clusterName = clusterSet.getCluster(reverseClusterNameIndexMap.get(element[1])).getName(); newName = reverseSpeakerNameIndexMap.get(element[0]); } sum = sum + costMatrix[element[0]][element[1]]; if (costMatrix[element[0]][element[1]] > parameter.getParameterNamedSpeaker().getThresholdDecision()) { logger.info(String.format("ASSIGN HONG %s -->%s = %.2f", clusterName, newName, costMatrix[element[0]][element[1]]).toString()); // clusterSetResult.getCluster(clusterName).setName(newName); clusterSetResult.getCluster(clusterName).setInformation(nameKey, newName); clusterSetResult.getCluster(clusterName).setInformation(scoreKey, costMatrix[element[0]][element[1]]); if ((videoClusterSetResult != null) && (videoClusterSetResult.getCluster(clusterName) != null)) { // videoClusterSetResult.getCluster(clusterName).setName(newName); videoClusterSetResult.getCluster(clusterName).setInformation(nameKey, newName); videoClusterSetResult.getCluster(clusterName).setInformation(scoreKey, costMatrix[element[0]][element[1]]); } } } logger.finest(String.format("\nThe %s is: %.2f\n", sumType, sum).toString()); } return clusterSetResult; } /** * Prints the float matrix. * * @param matrix the matrix */ public static void printFloatMatrix(float[][] matrix) { String log = ""; for (float[] element : matrix) { for (float element2 : element) { log += element2 + "\t"; } logger.finest(log); } } /* * Killer function ;-) It will go through each cluster, and compute each speaker score according to the belief function theory */ /** * Compute belief functions. * * @param clusters the clusters * @throws Exception the exception */ public static void computeBeliefFunctions(ClusterSet clusters) throws Exception { logger.info("------ compute Belief functions ------"); for (String name : clusters) { Cluster cluster = clusters.getCluster(name); cluster.computeBeliefFunctions(); // cluster.debugSpeakerName(); } } /** * Prints the cluster name. * * @param clusterSet the cluster set */ static public void printClusterName(ClusterSet clusterSet) { for (String name : clusterSet) { if (clusterSet.getCluster(name).segmentsSize() > 0) { logger.info("speaker cluster key:" + name + " name:" + clusterSet.getCluster(name).getName() + " gender:" + clusterSet.getCluster(name).getGender()); } } ClusterSet headClusterSet = clusterSet.getHeadClusterSet(); if (headClusterSet != null) { for (String name : headClusterSet) { if (headClusterSet.getCluster(name).segmentsSize() > 0) { logger.info("head cluster key:" + name + " name:" + headClusterSet.getCluster(name).getName() + " gender:" + headClusterSet.getCluster(name).getGender()); } } } } /** * Sets the anonymous. * * @param clusterSet the new anonymous */ public static void setAnonymous(ClusterSet clusterSet) { logger.info("------ setAnonymous ------"); for (String idx : clusterSet) { Cluster cluster = clusterSet.getCluster(idx); String name = cluster.getName(); if (name.matches("S[0-9]+")) { String newName = name.replaceFirst("S", "speaker#"); cluster.setName(newName); logger.info("SPEAKER remplace name: " + name + " with new Name:" + newName); } } ClusterSet headClusterSet = clusterSet.getHeadClusterSet(); if (headClusterSet != null) { for (String idx : headClusterSet) { Cluster cluster = headClusterSet.getCluster(idx); String name = cluster.getName(); if (name.matches("C[0-9]+")) { String newName = name.replaceFirst("C", "speaker#"); cluster.setName(newName); logger.info("HEAD remplace name: " + name + " with new Name:" + newName); } } } } /** * Selection. * * @param clusterSet the cluster set */ public static void selection(ClusterSet clusterSet) { logger.info("------ selection ------"); double thr = parameter.getParameterNamedSpeaker().getThresholdDecision(); for (String name : clusterSet) { Cluster cluster = clusterSet.getCluster(name); double max = -Double.MAX_VALUE; String maxName = cluster.getName(); String nameKey = ""; for (int i = 0; i < nameKeys.length; i++) { if (cluster.getInformation(nameKeys[i]) != "") { if (Double.valueOf(cluster.getInformation(scoreKeys[i])) > max) { max = Double.valueOf(cluster.getInformation(scoreKeys[i])); maxName = cluster.getInformation(nameKeys[i]); nameKey = nameKeys[i]; } } } if (max > thr) { logger.info("SET cluster:" + name + " Name:" + maxName + " score:" + max + "(" + thr + ") key:" + nameKey); cluster.setName(maxName); } } } /** * Merge cluster set. * * @param clusterSet the cluster set */ public static void mergeClusterSet(ClusterSet clusterSet) { ArrayList<String> array = new ArrayList<String>(clusterSet.getClusterMap().keySet()); int i = 1; while (i < array.size()) { String nameP = array.get(i - 1); String name = array.get(i); Cluster clusterP = clusterSet.getCluster(nameP); Cluster cluster = clusterSet.getCluster(name); // logger.info("*** nameP: "+nameP+" ("+clusterP+") name:"+name+" ("+cluster+")"); if (clusterP.getName().equals(cluster.getName())) { logger.info("*** merge i:" + i + " nameP: " + nameP + " (" + clusterP + ") name:" + name + " (" + cluster + ")"); clusterSet.mergeCluster(nameP, name); array.remove(i); } else { i++; } } } /** * The main method. * * @param args the arguments * @throws Exception the exception */ public static void main(String[] args) throws Exception { try { SpkDiarizationLogger.setup(); parameter = MainTools.getParameters(args); info(parameter, "SpeakerIdenificationDecision"); if (parameter.show.isEmpty() == false) { PREVIOUS_THRESHOLD = CURRENT_THRESHOLD = NEXT_THRESHOLD = parameter.getParameterNamedSpeaker().getThresholdTranscription(); ClusterSet audioClusterSet = MainTools.readClusterSet(parameter); audioClusterSet.collapse(); audioClusterSet.getHeadClusterSet().collapse(5); // get the speaker name list nameAndGenderMap = SpeakerNameUtils.loadList(parameter.getParameterNamedSpeaker().getNameAndGenderList()); firstNameAndGenderMap = null; if (parameter.getParameterNamedSpeaker().isFirstNameCheck()) { firstNameAndGenderMap = SpeakerNameUtils.loadList(parameter.getParameterNamedSpeaker().getFirstNameList()); } logger.info("+++ AUDIO ++++++++++++++++++++++"); // Trans putTranscriptionScore(audioClusterSet); computeBeliefFunctions(audioClusterSet); ClusterSet afterTrans = decideMaximum(audioClusterSet, scoreKeys[1], nameKeys[1]); // ClusterSet afterTrans = decideHungarian(audioClusterSet, scoreKeys[1], nameKeys[1]); // Writting for (String name : afterTrans) { afterTrans.getCluster(name).clearSpeakerNameSet(); } putWriting(afterTrans, parameter.getParameterNamedSpeaker().getThresholdWriting()); computeBeliefFunctions(afterTrans); ClusterSet afterWriting = decideMaximum(afterTrans, scoreKeys[2], nameKeys[2]); // JFA for (String name : afterWriting) { afterWriting.getCluster(name).clearSpeakerNameSet(); } putAudioScoreMax(afterWriting); // putHeadScore(audioClusterSet); computeBeliefFunctions(afterWriting); ClusterSet afterAudio = decideMaximum(afterWriting, scoreKeys[0], nameKeys[0]); logger.info("+++ VIDEO ++++++++++++++++++++++"); parameter.getParameterNamedSpeaker().setDontCheckGender(true); ClusterSet videoClusterSet = afterAudio.getHeadClusterSet(); videoClusterSet.setWriting(afterAudio.getWriting()); // Writting for (String name : videoClusterSet) { videoClusterSet.getCluster(name).clearSpeakerNameSet(); } putWriting(videoClusterSet, parameter.getParameterNamedSpeaker().getThresholdWriting()); computeBeliefFunctions(videoClusterSet); videoClusterSet = decideMaximum(videoClusterSet, scoreKeys[4], nameKeys[4]); // SURF for (String name : videoClusterSet) { videoClusterSet.getCluster(name).clearSpeakerNameSet(); } putVideoScore(videoClusterSet); computeBeliefFunctions(videoClusterSet); videoClusterSet = decideMaximum(videoClusterSet, scoreKeys[5], nameKeys[5]); logger.info("+++ DECISION ++++++++++++++++++++++"); selection(afterAudio); selection(videoClusterSet); afterAudio.setHeadClusterSet(videoClusterSet); AssociatioAudioVideo.assignSpeakerToHead(afterAudio); /* * while(nbSet > 0) { mergeClusterSet(afterAudio); mergeClusterSet(afterAudio.getHeadClusterSet()); nbSet = AssociatioAudioVideo.assignSpeakerToHead(afterAudio); } */ setAnonymous(afterAudio); logger.info("After Association ============================="); printClusterName(afterAudio); MainTools.writeClusterSet(parameter, afterAudio, true); } } catch (DiarizationException e) { logger.log(Level.SEVERE, "exception ", e); e.printStackTrace(); } } }
Adirockzz95/GenderDetect
src/src/fr/lium/experimental/spkDiarization/programs/SpeakerIdenificationDecision2.java
Java
gpl-3.0
38,353
<div class="modal-header"> <button type="button" ng-click="close()" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <h3>change password</h3> </div> <div id="changePassword" class="modal-body"> <div class="content"> <form novalidate name="changePasswordForm" ng-controller="ChangePasswordController" class="form-horizontal"> <div class="form-group"> <label for="oldpassword-change" class="col-lg-4 control-label" >old password</label> <div class="col-lg-8"> <input type="password" class="form-control" id="oldpassword-change" ng-model="oldpassword"> </div> </div> <div class="form-group"> <label for="newpassword-change" class="col-lg-4 control-label" >new password</label> <div class="col-lg-8"> <input type="password" class="form-control" id="newpassword-change" ng-model="newpassword"> </div> </div> <div class="form-group"> <label for="repeatpassword-change" class="col-lg-4 control-label" >repeat new password</label> <div class="col-lg-8"> <input type="password" class="form-control" id="repeatpassword-change" ng-model="repeatnewpassword"> </div> </div> <div class="form-actions"> <a ng-click="changePassword(oldpassword, newpassword, repeatnewpassword)" class="btn btn-default">confirm password change</a> </div> </form> </div> </div> <div class="modal-footer"> <button class="btn" ng-click="close()" data-dismiss="modal" aria-hidden="true">Close</button> </div>
pando85/cherrymusic
web/static/client/modals/change_password.html
HTML
gpl-3.0
1,653
/* * Generated by asn1c-0.9.24 (http://lionet.info/asn1c) * From ASN.1 module "InformationElements" * found in "../asn/InformationElements.asn" * `asn1c -fcompound-names -fnative-types` */ #include "HS-DSCH-DrxCellfach-info.h" static asn_TYPE_member_t asn_MBR_HS_DSCH_DrxCellfach_info_1[] = { { ATF_NOFLAGS, 0, offsetof(struct HS_DSCH_DrxCellfach_info, t_321), (ASN_TAG_CLASS_CONTEXT | (0 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_T_321, 0, /* Defer constraints checking to the member type */ 0, /* No PER visible constraints */ 0, "t-321" }, { ATF_NOFLAGS, 0, offsetof(struct HS_DSCH_DrxCellfach_info, hs_dsch_DrxCycleFach), (ASN_TAG_CLASS_CONTEXT | (1 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HS_DSCH_DrxCycleFach, 0, /* Defer constraints checking to the member type */ 0, /* No PER visible constraints */ 0, "hs-dsch-DrxCycleFach" }, { ATF_NOFLAGS, 0, offsetof(struct HS_DSCH_DrxCellfach_info, hs_dsch_DrxBurstFach), (ASN_TAG_CLASS_CONTEXT | (2 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_HS_DSCH_DrxBurstFach, 0, /* Defer constraints checking to the member type */ 0, /* No PER visible constraints */ 0, "hs-dsch-DrxBurstFach" }, { ATF_NOFLAGS, 0, offsetof(struct HS_DSCH_DrxCellfach_info, drxInterruption_hs_dsch), (ASN_TAG_CLASS_CONTEXT | (3 << 2)), -1, /* IMPLICIT tag at current level */ &asn_DEF_BOOLEAN, 0, /* Defer constraints checking to the member type */ 0, /* No PER visible constraints */ 0, "drxInterruption-hs-dsch" }, }; static ber_tlv_tag_t asn_DEF_HS_DSCH_DrxCellfach_info_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; static asn_TYPE_tag2member_t asn_MAP_HS_DSCH_DrxCellfach_info_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* t-321 at 8805 */ { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* hs-dsch-DrxCycleFach at 8806 */ { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* hs-dsch-DrxBurstFach at 8807 */ { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0 } /* drxInterruption-hs-dsch at 8808 */ }; static asn_SEQUENCE_specifics_t asn_SPC_HS_DSCH_DrxCellfach_info_specs_1 = { sizeof(struct HS_DSCH_DrxCellfach_info), offsetof(struct HS_DSCH_DrxCellfach_info, _asn_ctx), asn_MAP_HS_DSCH_DrxCellfach_info_tag2el_1, 4, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; asn_TYPE_descriptor_t asn_DEF_HS_DSCH_DrxCellfach_info = { "HS-DSCH-DrxCellfach-info", "HS-DSCH-DrxCellfach-info", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, SEQUENCE_decode_ber, SEQUENCE_encode_der, SEQUENCE_decode_xer, SEQUENCE_encode_xer, SEQUENCE_decode_uper, SEQUENCE_encode_uper, 0, /* Use generic outmost tag fetcher */ asn_DEF_HS_DSCH_DrxCellfach_info_tags_1, sizeof(asn_DEF_HS_DSCH_DrxCellfach_info_tags_1) /sizeof(asn_DEF_HS_DSCH_DrxCellfach_info_tags_1[0]), /* 1 */ asn_DEF_HS_DSCH_DrxCellfach_info_tags_1, /* Same as above */ sizeof(asn_DEF_HS_DSCH_DrxCellfach_info_tags_1) /sizeof(asn_DEF_HS_DSCH_DrxCellfach_info_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ asn_MBR_HS_DSCH_DrxCellfach_info_1, 4, /* Elements count */ &asn_SPC_HS_DSCH_DrxCellfach_info_specs_1 /* Additional specs */ };
E3V3A/snoopsnitch
contrib/libosmo-asn1-rrc/src/HS-DSCH-DrxCellfach-info.c
C
gpl-3.0
3,290
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 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/>. Description Gather data from all processors onto single processor according to some communication schedule (usually linear-to-master or tree-to-master). The gathered data will be a single value constructed from the values on individual processors using a user-specified operator. \*---------------------------------------------------------------------------*/ #include "UOPstream.H" #include "OPstream.H" #include "UIPstream.H" #include "IPstream.H" #include "contiguous.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class T, class BinaryOp> void Pstream::gather ( const List<UPstream::commsStruct>& comms, T& Value, const BinaryOp& bop, const int tag, const label comm ) { if (UPstream::parRun() && UPstream::nProcs(comm) > 1) { // Get my communication order const commsStruct& myComm = comms[UPstream::myProcNo(comm)]; // Receive from my downstairs neighbours forAll(myComm.below(), belowI) { T value; if (contiguous<T>()) { UIPstream::read ( UPstream::scheduled, myComm.below()[belowI], reinterpret_cast<char*>(&value), sizeof(T), tag, comm ); } else { IPstream fromBelow ( UPstream::scheduled, myComm.below()[belowI], 0, tag, comm ); fromBelow >> value; } Value = bop(Value, value); } // Send up Value if (myComm.above() != -1) { if (contiguous<T>()) { UOPstream::write ( UPstream::scheduled, myComm.above(), reinterpret_cast<const char*>(&Value), sizeof(T), tag, comm ); } else { OPstream toAbove ( UPstream::scheduled, myComm.above(), 0, tag, comm ); toAbove << Value; } } } } template<class T, class BinaryOp> void Pstream::gather ( T& Value, const BinaryOp& bop, const int tag, const label comm ) { if (UPstream::nProcs(comm) < UPstream::nProcsSimpleSum) { gather(UPstream::linearCommunication(comm), Value, bop, tag, comm); } else { gather(UPstream::treeCommunication(comm), Value, bop, tag, comm); } } template<class T> void Pstream::scatter ( const List<UPstream::commsStruct>& comms, T& Value, const int tag, const label comm ) { if (UPstream::parRun() && UPstream::nProcs(comm) > 1) { // Get my communication order const commsStruct& myComm = comms[UPstream::myProcNo(comm)]; // Reveive from up if (myComm.above() != -1) { if (contiguous<T>()) { UIPstream::read ( UPstream::scheduled, myComm.above(), reinterpret_cast<char*>(&Value), sizeof(T), tag, comm ); } else { IPstream fromAbove ( UPstream::scheduled, myComm.above(), 0, tag, comm ); fromAbove >> Value; } } // Send to my downstairs neighbours. Note reverse order (compared to // receiving). This is to make sure to send to the critical path // (only when using a tree schedule!) first. forAllReverse(myComm.below(), belowI) { if (contiguous<T>()) { UOPstream::write ( UPstream::scheduled, myComm.below()[belowI], reinterpret_cast<const char*>(&Value), sizeof(T), tag, comm ); } else { OPstream toBelow ( UPstream::scheduled, myComm.below()[belowI], 0, tag, comm ); toBelow << Value; } } } } template<class T> void Pstream::scatter(T& Value, const int tag, const label comm) { if (UPstream::nProcs(comm) < UPstream::nProcsSimpleSum) { scatter(UPstream::linearCommunication(comm), Value, tag, comm); } else { scatter(UPstream::treeCommunication(comm), Value, tag, comm); } } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // ************************************************************************* //
stuart23/cmake-OpenFOAM
src/OpenFOAM/db/IOstreams/Pstreams/gatherScatter.C
C++
gpl-3.0
6,558
// Copyright John Maddock 2008. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // # include <pch.hpp> #ifndef BOOST_MATH_TR1_SOURCE # define BOOST_MATH_TR1_SOURCE #endif #include <boost/math/tr1.hpp> #include <boost/math/special_functions/round.hpp> #include "c_policy.hpp" namespace boost{ namespace math{ namespace tr1{ extern "C" long BOOST_MATH_TR1_DECL lroundl BOOST_PREVENT_MACRO_SUBSTITUTION(long double x) BOOST_MATH_C99_THROW_SPEC { return c_policies::lround BOOST_PREVENT_MACRO_SUBSTITUTION(x); } }}}
gorkinovich/DefendersOfMankind
dependencies/boost-1.46.0/libs/math/src/tr1/lroundl.cpp
C++
gpl-3.0
667
#!/usr/bin/env python2 # ############################################################################## ### NZBGET POST-PROCESSING SCRIPT ### # Post-Process to CouchPotato, SickBeard, NzbDrone, Mylar, Gamez, HeadPhones. # # This script sends the download to your automated media management servers. # # NOTE: This script requires Python to be installed on your system. ############################################################################## # ### OPTIONS ### ## General # Auto Update nzbToMedia (0, 1). # # Set to 1 if you want nzbToMedia to automatically check for and update to the latest version #auto_update=0 # Safe Mode protection of DestDir (0, 1). # # Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake. #safe_mode=1 ## Gamez # Gamez script category. # # category that gets called for post-processing with Gamez. #gzCategory=games # Gamez api key. #gzapikey= # Gamez host. # # The ipaddress for your Gamez server. e.g For the Same system use localhost or 127.0.0.1 #gzhost=localhost # Gamez port. #gzport=8085 # Gamez uses ssl (0, 1). # # Set to 1 if using ssl, else set to 0. #gzssl=0 # Gamez library # # move downloaded games here. #gzlibrary # Gamez web_root # # set this if using a reverse proxy. #gzweb_root= # Gamez watch directory. # # set this to where your Gamez completed downloads are. #gzwatch_dir= ## Posix # Niceness for external tasks Extractor and Transcoder. # # Set the Niceness value for the nice command. These range from -20 (most favorable to the process) to 19 (least favorable to the process). #niceness=10 # ionice scheduling class (0, 1, 2, 3). # # Set the ionice scheduling class. 0 for none, 1 for real time, 2 for best-effort, 3 for idle. #ionice_class=2 # ionice scheduling class data. # # Set the ionice scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data. #ionice_classdata=4 ## WakeOnLan # use WOL (0, 1). # # set to 1 to send WOL broadcast to the mac and test the server (e.g. xbmc) on the host and port specified. #wolwake=0 # WOL MAC # # enter the mac address of the system to be woken. #wolmac=00:01:2e:2D:64:e1 # Set the Host and Port of a server to verify system has woken. #wolhost=192.168.1.37 #wolport=80 ### NZBGET POST-PROCESSING SCRIPT ### ############################################################################## import sys import nzbToMedia section = "Gamez" result = nzbToMedia.main(sys.argv, section) sys.exit(result)
DxCx/nzbToMedia
nzbToGamez.py
Python
gpl-3.0
2,702
{% extends "forms.html" %} {% block title %}Edit Machine Category{% endblock %} {% block breadcrumbs %} <div class="breadcrumbs"> <a href='{% url "index" %}'>Home</a>&nbsp;› <a href="{% url 'kg_machine_category_list' %}">Machines</a>&nbsp;› {% if object %} Edit Machine Category {% else %} Create Machine Category {% endif %} </div> {% endblock %} {% block content %} <form method="post" action=".">{% csrf_token %} {% load forms %} <fieldset class="aligned ()"> {% form_as_div form %} </fieldset> <div class="submit-row"> <input type="submit" value="Save" class="default" /> </div> </form> {% endblock %}
Karaage-Cluster/karaage-debian
karaage/templates/karaage/machines/machinecategory_form.html
HTML
gpl-3.0
689
using System; namespace Controls { public class ExceptionEventArgs : EventArgs { internal ExceptionEventArgs(string errorMessage) { ErrorMessage = errorMessage; } public string ErrorMessage { get; } } }
h82258652/ImageEx
ImageExV2/ImageEx/ExceptionEventArgs.cs
C#
gpl-3.0
291
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright (C) 2017 Google # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # ---------------------------------------------------------------------------- # # *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** # # ---------------------------------------------------------------------------- # # This file is automatically generated by Magic Modules and manual # changes will be clobbered when the file is regenerated. # # Please read more about how to change this file at # https://www.github.com/GoogleCloudPlatform/magic-modules # # ---------------------------------------------------------------------------- from __future__ import absolute_import, division, print_function __metaclass__ = type ################################################################################ # Documentation ################################################################################ ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: gcp_pubsub_subscription_info description: - Gather info for GCP Subscription short_description: Gather info for GCP Subscription version_added: '2.8' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 - requests >= 2.18.4 - google-auth >= 1.3.0 options: project: description: - The Google Cloud Platform project to use. type: str auth_kind: description: - The type of credential used. type: str required: true choices: - application - machineaccount - serviceaccount service_account_contents: description: - The contents of a Service Account JSON file, either in a dictionary or as a JSON string that represents it. type: jsonarg service_account_file: description: - The path of a Service Account JSON file if serviceaccount is selected as type. type: path service_account_email: description: - An optional service account email address if machineaccount is selected and the user does not wish to use the default email. type: str scopes: description: - Array of scopes to be used type: list env_type: description: - Specifies which Ansible environment you're running this module within. - This should not be set unless you know what you're doing. - This only alters the User Agent string for any API requests. type: str notes: - for authentication, you can set service_account_file using the C(gcp_service_account_file) env variable. - for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS) env variable. - For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) env variable. - For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. - For authentication, you can set scopes using the C(GCP_SCOPES) env variable. - Environment variables values will only be used if the playbook values are not set. - The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' - name: get info on a subscription gcp_pubsub_subscription_info: project: test_project auth_kind: serviceaccount service_account_file: "/tmp/auth.pem" ''' RETURN = ''' resources: description: List of resources returned: always type: complex contains: name: description: - Name of the subscription. returned: success type: str topic: description: - A reference to a Topic resource. returned: success type: dict labels: description: - A set of key/value label pairs to assign to this Subscription. returned: success type: dict pushConfig: description: - If push delivery is used with this subscription, this field is used to configure it. An empty pushConfig signifies that the subscriber will pull and ack messages using API methods. returned: success type: complex contains: oidcToken: description: - If specified, Pub/Sub will generate and attach an OIDC JWT token as an Authorization header in the HTTP request for every pushed message. returned: success type: complex contains: serviceAccountEmail: description: - Service account email to be used for generating the OIDC token. - The caller (for subscriptions.create, subscriptions.patch, and subscriptions.modifyPushConfig RPCs) must have the iam.serviceAccounts.actAs permission for the service account. returned: success type: str audience: description: - 'Audience to be used when generating OIDC token. The audience claim identifies the recipients that the JWT is intended for. The audience value is a single case-sensitive string. Having multiple values (array) for the audience field is not supported. More info about the OIDC JWT token audience here: U(https://tools.ietf.org/html/rfc7519#section-4.1.3) Note: if not specified, the Push endpoint URL will be used.' returned: success type: str pushEndpoint: description: - A URL locating the endpoint to which messages should be pushed. - For example, a Webhook endpoint might use "U(https://example.com/push"). returned: success type: str attributes: description: - Endpoint configuration attributes. - Every endpoint has a set of API supported attributes that can be used to control different aspects of the message delivery. - The currently supported attribute is x-goog-version, which you can use to change the format of the pushed message. This attribute indicates the version of the data expected by the endpoint. This controls the shape of the pushed message (i.e., its fields and metadata). The endpoint version is based on the version of the Pub/Sub API. - If not present during the subscriptions.create call, it will default to the version of the API used to make such call. If not present during a subscriptions.modifyPushConfig call, its value will not be changed. subscriptions.get calls will always return a valid version, even if the subscription was created without this attribute. - 'The possible values for this attribute are: - v1beta1: uses the push format defined in the v1beta1 Pub/Sub API.' - "- v1 or v1beta2: uses the push format defined in the v1 Pub/Sub API." returned: success type: dict ackDeadlineSeconds: description: - This value is the maximum time after a subscriber receives a message before the subscriber should acknowledge the message. After message delivery but before the ack deadline expires and before the message is acknowledged, it is an outstanding message and will not be delivered again during that time (on a best-effort basis). - For pull subscriptions, this value is used as the initial value for the ack deadline. To override this value for a given message, call subscriptions.modifyAckDeadline with the corresponding ackId if using pull. The minimum custom deadline you can specify is 10 seconds. The maximum custom deadline you can specify is 600 seconds (10 minutes). - If this parameter is 0, a default value of 10 seconds is used. - For push delivery, this value is also used to set the request timeout for the call to the push endpoint. - If the subscriber never acknowledges the message, the Pub/Sub system will eventually redeliver the message. returned: success type: int messageRetentionDuration: description: - How long to retain unacknowledged messages in the subscription's backlog, from the moment a message is published. If retainAckedMessages is true, then this also configures the retention of acknowledged messages, and thus configures how far back in time a subscriptions.seek can be done. Defaults to 7 days. Cannot be more than 7 days (`"604800s"`) or less than 10 minutes (`"600s"`). - 'A duration in seconds with up to nine fractional digits, terminated by ''s''. Example: `"600.5s"`.' returned: success type: str retainAckedMessages: description: - Indicates whether to retain acknowledged messages. If `true`, then messages are not expunged from the subscription's backlog, even if they are acknowledged, until they fall out of the messageRetentionDuration window. returned: success type: bool expirationPolicy: description: - A policy that specifies the conditions for this subscription's expiration. - A subscription is considered active as long as any connected subscriber is successfully consuming messages from the subscription or is issuing operations on the subscription. If expirationPolicy is not set, a default policy with ttl of 31 days will be used. If it is set but left empty, the resource never expires. The minimum allowed value for expirationPolicy.ttl is 1 day. returned: success type: complex contains: ttl: description: - Specifies the "time-to-live" duration for an associated resource. The resource expires if it is not active for a period of ttl. - If ttl is not set, the associated resource never expires. - A duration in seconds with up to nine fractional digits, terminated by 's'. - Example - "3.5s". returned: success type: str ''' ################################################################################ # Imports ################################################################################ from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest import json ################################################################################ # Main ################################################################################ def main(): module = GcpModule(argument_spec=dict()) if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/pubsub'] return_value = {'resources': fetch_list(module, collection(module))} module.exit_json(**return_value) def collection(module): return "https://pubsub.googleapis.com/v1/projects/{project}/subscriptions".format(**module.params) def fetch_list(module, link): auth = GcpSession(module, 'pubsub') return auth.list(link, return_if_object, array_name='subscriptions') def return_if_object(module, response): # If not found, return nothing. if response.status_code == 404: return None # If no content, return nothing. if response.status_code == 204: return None try: module.raise_for_status(response) result = response.json() except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst: module.fail_json(msg="Invalid JSON response with error: %s" % inst) if navigate_hash(result, ['error', 'errors']): module.fail_json(msg=navigate_hash(result, ['error', 'errors'])) return result if __name__ == "__main__": main()
sestrella/ansible
lib/ansible/modules/cloud/google/gcp_pubsub_subscription_info.py
Python
gpl-3.0
11,806
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><title>R: Pearson and Lee's data on the heights of parents and children...</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="R.css"> </head><body> <table width="100%" summary="page for PearsonLee"><tr><td>PearsonLee</td><td align="right">R Documentation</td></tr></table> <h2> Pearson and Lee's data on the heights of parents and children classified by gender </h2> <h3>Description</h3> <p>Wachsmuth et. al (2003) noticed that a loess smooth through Galton's data on heights of mid-parents and their offspring exhibited a slightly non-linear trend, and asked whether this might be due to Galton having pooled the heights of fathers and mothers and sons and daughters in constructing his tables and graphs. </p> <p>To answer this question, they used analogous data from English families at about the same time, tabulated by Karl Pearson and Alice Lee (1896, 1903), but where the heights of parents and children were each classified by gender of the parent. </p> <h3>Usage</h3> <pre>data(PearsonLee)</pre> <h3>Format</h3> <p>A frequency data frame with 746 observations on the following 6 variables. </p> <dl> <dt><code>child</code></dt><dd><p>child height in inches, a numeric vector</p> </dd> <dt><code>parent</code></dt><dd><p>parent height in inches, a numeric vector</p> </dd> <dt><code>frequency</code></dt><dd><p>a numeric vector</p> </dd> <dt><code>gp</code></dt><dd><p>a factor with levels <code>fd</code> <code>fs</code> <code>md</code> <code>ms</code></p> </dd> <dt><code>par</code></dt><dd><p>a factor with levels <code>Father</code> <code>Mother</code></p> </dd> <dt><code>chl</code></dt><dd><p>a factor with levels <code>Daughter</code> <code>Son</code></p> </dd> </dl> <h3>Details</h3> <p>The variables <code>gp</code>, <code>par</code> and <code>chl</code> are provided to allow stratifying the data according to the gender of the father/mother and son/daughter. </p> <h3>Source</h3> <p>Pearson, K. and Lee, A. (1896). Mathematical contributions to the theory of evolution. On telegony in man, etc. <EM>Proceedings of the Royal Society of London</EM>, 60 , 273-283. </p> <p>Pearson, K. and Lee, A. (1903). On the laws of inheritance in man: I. Inheritance of physical characters. <EM>Biometika</EM>, 2(4), 357-462. (Tables XXII, p. 415; XXV, p. 417; XXVIII, p. 419 and XXXI, p. 421.) </p> <h3>References</h3> <p>Wachsmuth, A.W., Wilkinson L., Dallal G.E. (2003). Galton's bend: A previously undiscovered nonlinearity in Galton's family stature regression data. <EM>The American Statistician</EM>, 57, 190-192. <a href="http://www.cs.uic.edu/~wilkinson/Publications/galton.pdf">http://www.cs.uic.edu/~wilkinson/Publications/galton.pdf</a> </p> <h3>See Also</h3> <p><code>Galton</code> </p> <h3>Examples</h3> <pre> data(PearsonLee) str(PearsonLee) with(PearsonLee, { lim &lt;- c(55,80) xv &lt;- seq(55,80, .5) sunflowerplot(parent,child, number=frequency, xlim=lim, ylim=lim, seg.col="gray", size=.1) abline(lm(child ~ parent, weights=frequency), col="blue", lwd=2) lines(xv, predict(loess(child ~ parent, weights=frequency), data.frame(parent=xv)), col="blue", lwd=2) # NB: dataEllipse doesn't take frequency into account if(require(car)) { dataEllipse(parent,child, xlim=lim, ylim=lim, plot.points=FALSE) } }) ## separate plots for combinations of (chl, par) # this doesn't quite work, because xyplot can't handle weights require(lattice) xyplot(child ~ parent|par+chl, data=PearsonLee, type=c("p", "r", "smooth"), col.line="red") # Using ggplot [thx: Dennis Murphy] require(ggplot2) ggplot(PearsonLee, aes(x = parent, y = child, weight=frequency)) + geom_point(size = 1.5, position = position_jitter(width = 0.2)) + geom_smooth(method = lm, aes(weight = PearsonLee$frequency, colour = 'Linear'), se = FALSE, size = 1.5) + geom_smooth(aes(weight = PearsonLee$frequency, colour = 'Loess'), se = FALSE, size = 1.5) + facet_grid(chl ~ par) + scale_colour_manual(breaks = c('Linear', 'Loess'), values = c('green', 'red')) + theme(legend.position = c(0.14, 0.885), legend.background = element_rect(fill = 'white')) # inverse regression, as in Wachmuth et al. (2003) ggplot(PearsonLee, aes(x = child, y = parent, weight=frequency)) + geom_point(size = 1.5, position = position_jitter(width = 0.2)) + geom_smooth(method = lm, aes(weight = PearsonLee$frequency, colour = 'Linear'), se = FALSE, size = 1.5) + geom_smooth(aes(weight = PearsonLee$frequency, colour = 'Loess'), se = FALSE, size = 1.5) + facet_grid(chl ~ par) + scale_colour_manual(breaks = c('Linear', 'Loess'), values = c('green', 'red')) + theme(legend.position = c(0.14, 0.885), legend.background = element_rect(fill = 'white')) </pre> </body></html>
johnmyleswhite/RDatasets.jl
doc/HistData/PearsonLee.html
HTML
gpl-3.0
4,989
/* * This file is part of BBCT for Android. * * Copyright 2012-14 codeguru <codeguru@users.sourceforge.net> * * BBCT for Android 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. * * BBCT for Android 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/>. */ /** * Exceptions used throughout the Swing version of BBCT. */ package bbct.common.exceptions;
BaseballCardTracker/bbct
swing/src/main/java/bbct/common/exceptions/package-info.java
Java
gpl-3.0
869
<?php /* Copyright (C) 2004-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Ion Agorria <ion@agorria.com> * * 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 2 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/>. * or see http://www.gnu.org/ */ /** * \file htdocs/fourn/commande/card.php * \ingroup supplier, order * \brief Card supplier order */ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formorder.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_order/modules_commandefournisseur.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; if (! empty($conf->askpricesupplier->enabled)) require DOL_DOCUMENT_ROOT . '/comm/askpricesupplier/class/askpricesupplier.class.php'; if (!empty($conf->produit->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP $langs->load('admin'); $langs->load('orders'); $langs->load('sendings'); $langs->load('companies'); $langs->load('bills'); $langs->load('propal'); $langs->load('askpricesupplier'); $langs->load('deliveries'); $langs->load('products'); $langs->load('stocks'); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); $id = GETPOST('id','int'); $ref = GETPOST('ref','alpha'); $action = GETPOST('action','alpha'); $confirm = GETPOST('confirm','alpha'); $comclientid = GETPOST('comid','int'); $socid = GETPOST('socid','int'); $projectid = GETPOST('projectid','int'); $cancel = GETPOST('cancel','alpha'); $lineid = GETPOST('lineid', 'int'); $lineid = GETPOST('lineid', 'int'); $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility //PDF $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); $datelivraison=dol_mktime(GETPOST('liv_hour','int'), GETPOST('liv_min','int'), GETPOST('liv_sec','int'), GETPOST('liv_month','int'), GETPOST('liv_day','int'),GETPOST('liv_year','int')); // Security check if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'fournisseur', $id, '', 'commande'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('ordersuppliercard','globalcard')); $object = new CommandeFournisseur($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); //Date prefix $date_pf = ''; // Load object if ($id > 0 || ! empty($ref)) { $ret = $object->fetch($id, $ref); if ($ret < 0) dol_print_error($db,$object->error); $ret = $object->fetch_thirdparty(); if ($ret < 0) dol_print_error($db,$object->error); } else if (! empty($socid) && $socid > 0) { $fourn = new Fournisseur($db); $ret=$fourn->fetch($socid); if ($ret < 0) dol_print_error($db,$object->error); $object->socid = $fourn->id; $ret = $object->fetch_thirdparty(); if ($ret < 0) dol_print_error($db,$object->error); } $permissionnote=$user->rights->fournisseur->commande->creer; // Used by the include of actions_setnotes.inc.php $permissiondellink=$user->rights->fournisseur->commande->creer; // Used by the include of actions_dellink.inc.php $permissiontoedit=$user->rights->fournisseur->commande->creer; // Used by the include of actions_lineupdown.inc.php /* * Actions */ $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { if ($cancel) $action=''; include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer) { $result=$object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); else $object->ref_supplier = GETPOST('ref_supplier','alpha'); // The setValueFrom does not set new property of object } // Set incoterm if ($action == 'set_incoterms' && $user->rights->fournisseur->commande->creer) { $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // conditions de reglement if ($action == 'setconditions' && $user->rights->fournisseur->commande->creer) { $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // mode de reglement if ($action == 'setmode' && $user->rights->fournisseur->commande->creer) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // bank account if ($action == 'setbankaccount' && $user->rights->fournisseur->commande->creer) { $result=$object->setBankAccount(GETPOST('fk_account', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // date de livraison if ($action == 'setdate_livraison' && $user->rights->fournisseur->commande->creer) { $result=$object->set_date_livraison($user,$datelivraison); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // Set project if ($action == 'classin' && $user->rights->fournisseur->commande->creer) { $result=$object->setProject($projectid); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } if ($action == 'setremisepercent' && $user->rights->fournisseur->commande->creer) { $result = $object->set_remise($user, $_POST['remise_percent']); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } if ($action == 'reopen') // no test on permission here, permission to use will depends on status { if (in_array($object->statut, array(1, 2, 3, 5, 6, 7, 9))) { if ($object->statut == 1) $newstatus=0; // Validated->Draft else if ($object->statut == 2) $newstatus=0; // Approved->Draft else if ($object->statut == 3) $newstatus=2; // Ordered->Approved else if ($object->statut == 5) $newstatus=4; // Received->Received partially else if ($object->statut == 6) $newstatus=2; // Canceled->Approved else if ($object->statut == 7) $newstatus=3; // Canceled->Process running else if ($object->statut == 9) $newstatus=1; // Refused->Validated $db->begin(); $result = $object->setStatus($user, $newstatus); if ($result > 0) { if ($newstatus == 0) { $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur'; $sql.= ' SET fk_user_approve = null, fk_user_approve2 = null, date_approve = null, date_approve2 = null'; $sql.= ' WHERE rowid = '.$object->id; $resql=$db->query($sql); } $db->commit(); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } } } /* * Add a line into product */ if ($action == 'addline' && $user->rights->fournisseur->commande->creer) { $langs->load('errors'); $error = 0; // Set if we used free entry or predefined product $predef=''; $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $date_start=dol_mktime(GETPOST('date_start'.$date_pf.'hour'), GETPOST('date_start'.$date_pf.'min'), 0, GETPOST('date_start'.$date_pf.'month'), GETPOST('date_start'.$date_pf.'day'), GETPOST('date_start'.$date_pf.'year')); $date_end=dol_mktime(GETPOST('date_end'.$date_pf.'hour'), GETPOST('date_end'.$date_pf.'min'), 0, GETPOST('date_end'.$date_pf.'month'), GETPOST('date_end'.$date_pf.'day'), GETPOST('date_end'.$date_pf.'year')); if (GETPOST('prod_entry_mode') == 'free') { $idprod=0; $price_ht = GETPOST('price_ht'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { $idprod=GETPOST('idprod', 'int'); $price_ht = ''; $tva_tx = ''; } $qty = GETPOST('qty'.$predef); $remise_percent=GETPOST('remise_percent'.$predef); // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { unset($_POST["options_" . $key]); } } if (GETPOST('prod_entry_mode')=='free' && GETPOST('price_ht') < 0 && $qty < 0) { setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'), $langs->transnoentitiesnoconv('Qty')), 'errors'); $error++; } if (GETPOST('prod_entry_mode')=='free' && ! GETPOST('idprodfournprice') && GETPOST('type') < 0) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); $error++; } if (GETPOST('prod_entry_mode')=='free' && GETPOST('price_ht')==='' && GETPOST('price_ttc')==='') // Unit price can be 0 but not '' { setEventMessage($langs->trans($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice'))), 'errors'); $error++; } if (GETPOST('prod_entry_mode')=='free' && ! GETPOST('dp_desc')) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); $error++; } if (! GETPOST('qty')) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); $error++; } // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit // Ecrase $txtva par celui du produit if ((GETPOST('prod_entry_mode') != 'free') && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' { $idprod=0; $productsupplier = new ProductFournisseur($db); if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) if (GETPOST('idprodfournprice') > 0) { $idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qty); // Just to see if a price exists for the quantity. Not used to found vat. } if ($idprod > 0) { $res=$productsupplier->fetch($idprod); $label = $productsupplier->label; $desc = $productsupplier->description; if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); $type = $productsupplier->type; // Local Taxes $localtax1_tx= get_localtax($tva_tx, 1,$mysoc,$object->thirdparty); $localtax2_tx= get_localtax($tva_tx, 2,$mysoc,$object->thirdparty); $result=$object->addline( $desc, $productsupplier->fourn_pu, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $productsupplier->id, GETPOST('idprodfournprice'), $productsupplier->fourn_ref, $remise_percent, 'HT', $pu_ttc, $type, '', '', $date_start, $date_end, $array_options, $productsupplier->fk_unit ); } if ($idprod == -99 || $idprod == 0) { // Product not selected $error++; $langs->load("errors"); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ProductOrService")).' '.$langs->trans("or").' '.$langs->trans("NoPriceDefinedForThisSupplier"), 'errors'); } if ($idprod == -1) { // Quantity too low $error++; $langs->load("errors"); setEventMessage($langs->trans("ErrorQtyTooLowForThisSupplier"), 'errors'); } } else if((GETPOST('price_ht')!=='' || GETPOST('price_ttc')!=='') && empty($error)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); $tva_tx = str_replace('*', '', $tva_tx); $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); $desc = $product_desc; $type = GETPOST('type'); $fk_unit= GETPOST('units', 'alpha'); $tva_tx = price2num($tva_tx); // When vat is text input field // Local Taxes $localtax1_tx= get_localtax($tva_tx, 1,$mysoc,$object->thirdparty); $localtax2_tx= get_localtax($tva_tx, 2,$mysoc,$object->thirdparty); if (GETPOST('price_ht')!=='') { $price_base_type = 'HT'; $ht = price2num(GETPOST('price_ht')); $ttc = 0; } else { $ttc = price2num(GETPOST('price_ttc')); $ht = $ttc / (1 + ($tva_tx / 100)); $price_base_type = 'HT'; } $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit); } //print "xx".$tva_tx; exit; if (! $error && $result > 0) { $ret=$object->fetch($object->id); // Reload to get new records // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db,$result); } unset($_POST ['prod_entry_mode']); unset($_POST['qty']); unset($_POST['type']); unset($_POST['remise_percent']); unset($_POST['pu']); unset($_POST['price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['label']); unset($localtax1_tx); unset($localtax2_tx); unset($_POST['np_marginRate']); unset($_POST['np_markRate']); unset($_POST['dp_desc']); unset($_POST['idprodfournprice']); unset($_POST['date_starthour']); unset($_POST['date_startmin']); unset($_POST['date_startsec']); unset($_POST['date_startday']); unset($_POST['date_startmonth']); unset($_POST['date_startyear']); unset($_POST['date_endhour']); unset($_POST['date_endmin']); unset($_POST['date_endsec']); unset($_POST['date_endday']); unset($_POST['date_endmonth']); unset($_POST['date_endyear']); } else { setEventMessages($object->error, $object->errors, 'errors'); } } /* * Mise a jour d'une ligne dans la commande */ if ($action == 'updateline' && $user->rights->fournisseur->commande->creer && ! GETPOST('cancel')) { $tva_tx = GETPOST('tva_tx'); if (GETPOST('price_ht') != '') { $price_base_type = 'HT'; $ht = price2num(GETPOST('price_ht')); } else { $ttc = price2num(GETPOST('price_ttc')); $ht = $ttc / (1 + ($tva_tx / 100)); $price_base_type = 'HT'; } if ($lineid) { $line = new CommandeFournisseurLigne($db); $res = $line->fetch($lineid); if (!$res) dol_print_error($db); } $date_start=dol_mktime(GETPOST('date_start'.$date_pf.'hour'), GETPOST('date_start'.$date_pf.'min'), 0, GETPOST('date_start'.$date_pf.'month'), GETPOST('date_start'.$date_pf.'day'), GETPOST('date_start'.$date_pf.'year')); $date_end=dol_mktime(GETPOST('date_end'.$date_pf.'hour'), GETPOST('date_end'.$date_pf.'min'), 0, GETPOST('date_end'.$date_pf.'month'), GETPOST('date_end'.$date_pf.'day'), GETPOST('date_end'.$date_pf.'year')); $localtax1_tx=get_localtax($tva_tx,1,$mysoc,$object->thirdparty); $localtax2_tx=get_localtax($tva_tx,2,$mysoc,$object->thirdparty); // Extrafields Lines $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { unset($_POST["options_" . $key]); } } $result = $object->updateline( $lineid, $_POST['product_desc'], $ht, $_POST['qty'], $_POST['remise_percent'], $tva_tx, $localtax1_tx, $localtax2_tx, $price_base_type, 0, isset($_POST["type"])?$_POST["type"]:$line->product_type, false, $date_start, $date_end, $array_options, $_POST['units'] ); unset($_POST['qty']); unset($_POST['type']); unset($_POST['idprodfournprice']); unset($_POST['remmise_percent']); unset($_POST['dp_desc']); unset($_POST['np_desc']); unset($_POST['pu']); unset($_POST['tva_tx']); unset($_POST['date_start']); unset($_POST['date_end']); unset($_POST['units']); unset($localtax1_tx); unset($localtax2_tx); if ($result >= 0) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db,$result); } } else { dol_print_error($db,$object->error); exit; } } // Remove a product line if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fournisseur->commande->creer) { $result = $object->deleteline($lineid); if ($result > 0) { // Define output language $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret = $object->fetch($object->id); // Reload to get new records $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); /* Fix bug 1485 : Reset action to avoid asking again confirmation on failure */ $action=''; } } // Validate if ($action == 'confirm_valid' && $confirm == 'yes' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->commande->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_order_advance->validate))) ) { $object->date_commande=dol_now(); $result = $object->valid($user); if ($result >= 0) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db,$result); } } else { setEventMessages($object->error, $object->errors, 'errors'); } // If we have permission, and if we don't need to provide the idwarehouse, we go directly on approved step if (empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE) && $user->rights->fournisseur->commande->approuver && ! (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $object->hasProductsOrServices(1))) { $action='confirm_approve'; // can make standard or first level approval also if permission is set } } if (($action == 'confirm_approve' || $action == 'confirm_approve2') && $confirm == 'yes' && $user->rights->fournisseur->commande->approuver) { $idwarehouse=GETPOST('idwarehouse', 'int'); $qualified_for_stock_change=0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $qualified_for_stock_change=$object->hasProductsOrServices(2); } else { $qualified_for_stock_change=$object->hasProductsOrServices(1); } // Check parameters if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change) // warning name of option should be STOCK_CALCULATE_ON_SUPPLIER_APPROVE_ORDER { if (! $idwarehouse || $idwarehouse == -1) { $error++; setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")), 'errors'); $action=''; } } if (! $error) { $result = $object->approve($user, $idwarehouse, ($action=='confirm_approve2'?1:0)); if ($result > 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } } } if ($action == 'confirm_refuse' && $confirm == 'yes' && $user->rights->fournisseur->commande->approuver) { $result = $object->refuse($user); if ($result > 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } } if ($action == 'confirm_commande' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander) { $result = $object->commande($user, $_REQUEST["datecommande"], $_REQUEST["methode"], $_REQUEST['comment']); if ($result > 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } } if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisseur->commande->supprimer) { $result=$object->delete($user); if ($result > 0) { header("Location: ".DOL_URL_ROOT.'/fourn/commande/list.php'); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } } // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->fournisseur->commande->creer) { if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); } else { if ($object->id > 0) { $result=$object->createFromClone(); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); $action=''; } } } } // Set status of reception (complete, partial, ...) if ($action == 'livraison' && $user->rights->fournisseur->commande->receptionner) { if (GETPOST("type") != '') { $date_liv = dol_mktime(GETPOST('rehour'),GETPOST('remin'),GETPOST('resec'),GETPOST("remonth"),GETPOST("reday"),GETPOST("reyear")); $result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment")); if ($result > 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; } else if($result == -3) { setEventMessage($langs->trans("NotAuthorized"), 'errors'); } else { setEventMessages($object->error, $object->errors, 'errors'); } } else { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Delivery")), 'errors'); } } if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander) { $result = $object->cancel($user); if ($result > 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } } if ($action == 'builddoc' && $user->rights->fournisseur->commande->creer) // En get ou en post { // Build document // Save last template used to generate document if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); $outputlangs = $langs; if (GETPOST('lang_id')) { $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang(GETPOST('lang_id')); } $result= $object->generateDocument($object->modelpdf,$outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); $action=''; } } // Delete file in doc form if ($action == 'remove_file' && $object->id > 0 && $user->rights->fournisseur->commande->creer) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $langs->load("other"); $upload_dir = $conf->fournisseur->commande->dir_output; $file = $upload_dir . '/' . GETPOST('file'); $ret=dol_delete_file($file,0,0,0,$object); if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); } if ($action == 'update_extras') { // Fill array 'array_options' with data from add form $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute')); if ($ret < 0) $error++; if (! $error) { // Actions on extra fields (by external module or standard code) // TODO le hook fait double emploi avec le trigger !! $hookmanager->initHooks(array('supplierorderdao')); $parameters=array('id'=>$object->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$object->insertExtraFields(); if ($result < 0) { $error++; } } } else if ($reshook < 0) $error++; } else { $action = 'edit_extras'; } } /* * Create an order */ if ($action == 'add' && $user->rights->fournisseur->commande->creer) { $error=0; if ($socid <1) { setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentities('Supplier')), 'errors'); $action='create'; $error++; } if (! $error) { $db->begin(); // Creation commande $object->ref_supplier = GETPOST('refsupplier'); $object->socid = $socid; $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); $object->note_private = GETPOST('note_private'); $object->note_public = GETPOST('note_public'); $object->date_livraison = $datelivraison; $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); // Fill array 'array_options' with data from add form if (! $error) { $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if ($ret < 0) $error++; } if (! $error) { // If creation from another object of another module (Example: origin=propal, originid=1) if (! empty($origin) && ! empty($originid)) { $element = 'comm/askpricesupplier'; $subelement = 'askpricesupplier'; $object->origin = $origin; $object->origin_id = $originid; // Possibility to add external linked objects with hooks $object->linked_objects [$object->origin] = $object->origin_id; $other_linked_objects = GETPOST('other_linked_objects', 'array'); if (! empty($other_linked_objects)) { $object->linked_objects = array_merge($object->linked_objects, $other_linked_objects); } $object_id = $object->create($user); if ($object_id > 0) { dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); $classname = ucfirst($subelement); $srcobject = new $classname($db); dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); $result = $srcobject->fetch($object->origin_id); if ($result > 0) { $object->set_date_livraison($user, $srcobject->date_livraison); $object->set_id_projet($user, $srcobject->fk_project); $lines = $srcobject->lines; if (empty($lines) && method_exists($srcobject, 'fetch_lines')) { $srcobject->fetch_lines(); $lines = $srcobject->lines; } $fk_parent_line = 0; $num = count($lines); $productsupplier = new ProductFournisseur($db); for($i = 0; $i < $num; $i ++) { if (empty($lines[$i]->subprice) || $lines[$i]->qty <= 0) continue; $label = (! empty($lines[$i]->label) ? $lines[$i]->label : ''); $desc = (! empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle); $product_type = (! empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0); // Reset fk_parent_line for no child products and special product if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { $fk_parent_line = 0; } // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if // trigger used { $lines[$i]->fetch_optionals($lines[$i]->rowid); $array_option = $lines[$i]->array_options; } $idprod = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty); $res = $productsupplier->fetch($idProductFourn); $result = $object->addline( $desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $productsupplier->product_fourn_price_id, $productsupplier->ref_fourn, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->product_type, '', '', null, null, array(), $lines[$i]->fk_unit ); if ($result < 0) { $error ++; break; } // Defined the new fk_parent_line if ($result > 0 && $lines[$i]->product_type == 9) { $fk_parent_line = $result; } } // Hooks $parameters = array('objFrom' => $srcobject); $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) $error ++; } else { setEventMessages($srcobject->error, $srcobject->errors, 'errors'); $error ++; } } else { setEventMessages($object->error, $object->errors, 'errors'); $error ++; } } else { $id = $object->create($user); if ($id < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } } } if ($error) { $langs->load("errors"); $db->rollback(); $action='create'; $_GET['socid']=$_POST['socid']; } else { $db->commit(); header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } } } /* * Add file in email form */ if (GETPOST('addfile')) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Set tmp user directory TODO Use a dedicated directory for temp mails files $vardir=$conf->user->dir_output."/".$user->id; $upload_dir_tmp = $vardir.'/temp'; dol_add_file_process($upload_dir_tmp,0,0); $action='presend'; } /* * Remove file in email form */ if (GETPOST('removedfile')) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Set tmp user directory $vardir=$conf->user->dir_output."/".$user->id; $upload_dir_tmp = $vardir.'/temp'; // TODO Delete only files that was uploaded from email form dol_remove_file_process($_POST['removedfile'],0); $action='presend'; } /* * Send mail */ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) { $langs->load('mails'); if ($object->id > 0) { // $ref = dol_sanitizeFileName($object->ref); // $file = $conf->fournisseur->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf'; // if (is_readable($file)) // { if (GETPOST('sendto','alpha')) { // Le destinataire a ete fourni via le champ libre $sendto = GETPOST('sendto','alpha'); $sendtoid = 0; } elseif (GETPOST('receiver','alpha') != '-1') { // Recipient was provided from combo list if (GETPOST('receiver','alpha') == 'thirdparty') // Id of third party { $sendto = $object->client->email; $sendtoid = 0; } else // Id du contact { $sendto = $object->client->contact_get_property(GETPOST('receiver','alpha'),'email'); $sendtoid = GETPOST('receiver','alpha'); } } if (dol_strlen($sendto)) { $langs->load("commercial"); $from = GETPOST('fromname','alpha') . ' <' . GETPOST('frommail','alpha') .'>'; $replyto = GETPOST('replytoname','alpha'). ' <' . GETPOST('replytomail','alpha').'>'; $message = GETPOST('message'); $sendtocc = GETPOST('sendtocc','alpha'); $deliveryreceipt = GETPOST('deliveryreceipt','alpha'); if ($action == 'send') { if (dol_strlen(GETPOST('subject'))) $subject=GETPOST('subject'); else $subject = $langs->transnoentities('CustomerOrder').' '.$object->ref; $actiontypecode='AC_SUP_ORD'; $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); $actionmsg = dol_concatdesc($actionmsg, $message); } $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); } // Create form object include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $attachedfiles=$formmail->get_attached_files(); $filepath = $attachedfiles['paths']; $filename = $attachedfiles['names']; $mimetype = $attachedfiles['mimes']; // Send mail require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1); if ($mailfile->error) { setEventMessage($mailfile->error, 'errors'); } else { $result=$mailfile->sendfile(); if ($result) { $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contain " setEventMessage($mesg); $error=0; // Initialisation donnees $object->sendtoid = $sendtoid; $object->actiontypecode = $actiontypecode; $object->actionmsg = $actionmsg; $object->actionmsg2 = $actionmsg2; $object->fk_element = $object->id; $object->elementtype = $object->element; // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($db); $result=$interface->run_triggers('ORDER_SUPPLIER_SENTBYMAIL',$object,$user,$langs,$conf); if ($result < 0) { $error++; $errors=$interface->errors; } // Fin appel triggers if ($error) { setEventMessage($object->error, 'errors'); } else { // Redirect here // This avoid sending mail twice if going out and then back to page header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } } else { $langs->load("other"); if ($mailfile->error) { $mesg = $langs->trans('ErrorFailedToSendMail',$from,$sendto); $mesg.= '<br>'.$mailfile->error; } else { $mesg = 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; } setEventMessage($mesg, 'errors'); } } /* } else { $langs->load("other"); $mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>'; $action='presend'; dol_syslog('Recipient email is empty'); }*/ } else { $langs->load("errors"); setEventMessage($langs->trans('ErrorCantReadFile',$file), 'errors'); dol_syslog('Failed to read file: '.$file); } } else { $langs->load("other"); setEventMessage($langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")), 'errors'); dol_syslog('Impossible de lire les donnees de la facture. Le fichier facture n\'a peut-etre pas ete genere.'); } } if ($action == 'webservice' && GETPOST('mode', 'alpha') == "send" && ! GETPOST('cancel')) { $ws_url = $object->thirdparty->webservices_url; $ws_key = $object->thirdparty->webservices_key; $ws_user = GETPOST('ws_user','alpha'); $ws_password = GETPOST('ws_password','alpha'); $ws_entity = GETPOST('ws_entity','int'); $ws_thirdparty = GETPOST('ws_thirdparty','int'); // NS and Authentication parameters $ws_ns='http://www.dolibarr.org/ns/'; $ws_authentication=array( 'dolibarrkey'=>$ws_key, 'sourceapplication'=>'DolibarrWebServiceClient', 'login'=>$ws_user, 'password'=>$ws_password, 'entity'=>$ws_entity ); //Is sync supplier web services module activated? and everything filled? if (empty($conf->syncsupplierwebservices->enabled)) { setEventMessage($langs->trans("WarningModuleNotActive",$langs->transnoentities("Module2650Name"))); } else if (empty($ws_url) || empty($ws_key)) { setEventMessage($langs->trans("ErrorWebServicesFieldsRequired"), 'errors'); } else if (empty($ws_user) || empty($ws_password) || empty($ws_thirdparty)) { setEventMessage($langs->trans("ErrorFieldsRequired"), 'errors'); } else { //Create SOAP client and connect it to order $soapclient_order = new nusoap_client($ws_url."/webservices/server_order.php"); $soapclient_order->soap_defencoding='UTF-8'; $soapclient_order->decodeUTF8(false); //Create SOAP client and connect it to product/service $soapclient_product = new nusoap_client($ws_url."/webservices/server_productorservice.php"); $soapclient_product->soap_defencoding='UTF-8'; $soapclient_product->decodeUTF8(false); //Prepare the order lines from order $order_lines = array(); foreach ($object->lines as $line) { $ws_parameters = array('authentication' => $ws_authentication, 'id' => '', 'ref' => $line->ref_supplier); $result_product = $soapclient_product->call("getProductOrService", $ws_parameters, $ws_ns, ''); if ($result_product["result"]["result_code"] == "OK") { $order_lines[] = array( 'desc' => $line->product_desc, 'type' => $line->product_type, 'product_id' => $result_product["product"]["id"], 'vat_rate' => $line->tva_tx, 'qty' => $line->qty, 'price' => $line->price, 'unitprice' => $line->subprice, 'total_net' => $line->total_ht, 'total_vat' => $line->total_tva, 'total' => $line->total_ttc, 'date_start' => $line->date_start, 'date_end' => $line->date_end, ); } } //Prepare the order header $order = array( 'thirdparty_id' => $ws_thirdparty, 'date' => dol_print_date(dol_now(),'dayrfc'), 'total_net' => $object->total_ht, 'total_var' => $object->total_tva, 'total' => $object->total_ttc, 'lines' => $order_lines ); $ws_parameters = array('authentication'=>$ws_authentication, 'order' => $order); $result_order = $soapclient_order->call("createOrder", $ws_parameters, $ws_ns, ''); if (empty($result_order["result"]["result_code"])) //No result, check error str { setEventMessage($langs->trans("SOAPError")." '".$soapclient_order->error_str."'", 'errors'); } else if ($result_order["result"]["result_code"] != "OK") //Something went wrong { setEventMessage($langs->trans("SOAPError")." '".$result_order["result"]["result_code"]."' - '".$result_order["result"]["result_label"]."'", 'errors'); } else { setEventMessage($langs->trans("RemoteOrderRef")." ".$result_order["ref"], 'mesgs'); } } } if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->commande->creer) { if ($action == 'addcontact') { if ($object->id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); } if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); } else { setEventMessage($object->error, 'errors'); } } } // bascule du statut d'un contact else if ($action == 'swapstatut' && $object->id > 0) { $result=$object->swapContactStatus(GETPOST('ligne')); } // Efface un contact else if ($action == 'deletecontact' && $object->id > 0) { $result = $object->delete_contact($_GET["lineid"]); if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { dol_print_error($db); } } } } /* * View */ llxHeader('',$langs->trans("OrderCard"),"CommandeFournisseur"); $form = new Form($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); $productstatic = new Product($db); /* *************************************************************************** */ /* */ /* Mode vue et edition */ /* */ /* *************************************************************************** */ $now=dol_now(); if ($action=='create') { print_fiche_titre($langs->trans('NewOrder')); dol_htmloutput_events(); $societe=''; if ($socid>0) { $societe=new Societe($db); $societe->fetch($socid); } if (! empty($origin) && ! empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { $element = $regs [1]; $subelement = $regs [2]; } $element = 'comm/askpricesupplier'; $subelement = 'askpricesupplier'; dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); $classname = ucfirst($subelement); $objectsrc = new $classname($db); $objectsrc->fetch($originid); if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) $objectsrc->fetch_lines(); $objectsrc->fetch_thirdparty(); // Replicate extrafields $objectsrc->fetch_optionals($originid); $object->array_options = $objectsrc->array_options; $projectid = (! empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); $ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); $soc = $objectsrc->client; $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); $shipping_method_id = (! empty($objectsrc->shipping_method_id)?$objectsrc->shipping_method_id:(! empty($soc->shipping_method_id)?$soc->shipping_method_id:0)); $demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0)); $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; $datedelivery = (! empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : ''); $note_private = (! empty($objectsrc->note_private) ? $objectsrc->note_private : (! empty($objectsrc->note_private) ? $objectsrc->note_private : '')); $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : ''); // Object source contacts list $srccontactslist = $objectsrc->liste_contact(- 1, 'external', 1); } else { $cond_reglement_id = $societe->cond_reglement_supplier_id; $mode_reglement_id = $societe->mode_reglement_supplier_id; } print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="socid" value="' . $soc->id . '">' . "\n"; print '<input type="hidden" name="remise_percent" value="' . $soc->remise_percent . '">'; print '<input type="hidden" name="origin" value="' . $origin . '">'; print '<input type="hidden" name="originid" value="' . $originid . '">'; dol_fiche_head(''); print '<table class="border" width="100%">'; // Ref print '<tr><td>'.$langs->trans('Ref').'</td><td>'.$langs->trans('Draft').'</td></tr>'; // Third party print '<tr><td class="fieldrequired">'.$langs->trans('Supplier').'</td>'; print '<td>'; if ($socid > 0) { print $societe->getNomUrl(1); print '<input type="hidden" name="socid" value="'.$socid.'">'; } else { print $form->select_company((empty($socid)?'':$socid),'socid','s.fournisseur = 1',1); } print '</td>'; // Ref supplier print '<tr><td>'.$langs->trans('RefSupplier').'</td><td><input name="refsupplier" type="text"></td>'; print '</tr>'; print '</td></tr>'; // Payment term print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">'; $form->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id,'cond_reglement_id'); print '</td></tr>'; // Payment mode print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">'; $form->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id'); print '</td></tr>'; // Planned delivery date print '<tr><td>'; print $langs->trans('DateDeliveryPlanned'); print '</td>'; print '<td>'; $usehourmin=0; if (! empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin=1; $form->select_date($datelivraison?$datelivraison:-1,'liv_',$usehourmin,$usehourmin,'',"set"); print '</td></tr>'; // Bank Account if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && ! empty($conf->banque->enabled)) { $langs->load("bank"); print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">'; $form->select_comptes($fk_account, 'fk_account', 0, '', 1); print '</td></tr>'; } // Incoterms if (!empty($conf->incoterm->enabled)) { print '<tr>'; print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $object->libelle_incoterms, 1).'</label></td>'; print '<td colspan="3" class="maxwidthonsmartphone">'; print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:'')); print '</td></tr>'; } print '<tr><td>'.$langs->trans('NotePublic').'</td>'; print '<td>'; $doleditor = new DolEditor('note_public', isset($note_public) ? $note_public : GETPOST('note_public'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); print $doleditor->Create(1); print '</td>'; //print '<textarea name="note_public" wrap="soft" cols="60" rows="'.ROWS_5.'"></textarea>'; print '</tr>'; print '<tr><td>'.$langs->trans('NotePrivate').'</td>'; print '<td>'; $doleditor = new DolEditor('note_private', isset($note_private) ? $note_private : GETPOST('note_private'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); print $doleditor->Create(1); print '</td>'; //print '<td><textarea name="note_private" wrap="soft" cols="60" rows="'.ROWS_5.'"></textarea></td>'; print '</tr>'; if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { print "\n<!-- " . $classname . " info -->"; print "\n"; print '<input type="hidden" name="amount" value="' . $objectsrc->total_ht . '">' . "\n"; print '<input type="hidden" name="total" value="' . $objectsrc->total_ttc . '">' . "\n"; print '<input type="hidden" name="tva" value="' . $objectsrc->total_tva . '">' . "\n"; print '<input type="hidden" name="origin" value="' . $objectsrc->element . '">'; print '<input type="hidden" name="originid" value="' . $objectsrc->id . '">'; $newclassname = $classname; if ($newclassname == 'AskPriceSupplier') $newclassname = 'CommercialAskPriceSupplier'; print '<tr><td>' . $langs->trans($newclassname) . '</td><td colspan="2">' . $objectsrc->getNomUrl(1) . '</td></tr>'; print '<tr><td>' . $langs->trans('TotalHT') . '</td><td colspan="2">' . price($objectsrc->total_ht) . '</td></tr>'; print '<tr><td>' . $langs->trans('TotalVAT') . '</td><td colspan="2">' . price($objectsrc->total_tva) . "</td></tr>"; if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE { print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td colspan="2">' . price($objectsrc->total_localtax1) . "</td></tr>"; } if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF { print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td colspan="2">' . price($objectsrc->total_localtax2) . "</td></tr>"; } print '<tr><td>' . $langs->trans('TotalTTC') . '</td><td colspan="2">' . price($objectsrc->total_ttc) . "</td></tr>"; } // Other options $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); } // Bouton "Create Draft" print "</table>\n"; dol_fiche_end(); print '<div class="center"><input type="submit" class="button" name="bouton" value="'.$langs->trans('CreateDraft').'"></div>'; print "</form>\n"; // Show origin lines if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { $title = $langs->trans('ProductsAndServices'); print load_fiche_titre($title,'',''); print '<table class="noborder" width="100%">'; $objectsrc->printOriginLinesList(); print '</table>'; } } elseif (! empty($object->id)) { $societe = new Fournisseur($db); $result=$societe->fetch($object->socid); if ($result < 0) dol_print_error($db); $author = new User($db); $author->fetch($object->user_author_id); $res=$object->fetch_optionals($object->id,$extralabels); $head = ordersupplier_prepare_head($object); $title=$langs->trans("SupplierOrder"); dol_fiche_head($head, 'card', $title, 0, 'order'); $formconfirm=''; /* * Confirmation de la suppression de la commande */ if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 2); } // Clone confirmation if ($action == 'clone') { // Create an array for form $formquestion=array( //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1) ); // Paiement incomplet. On demande si motif = escompte ou autre $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneOrder'),$langs->trans('ConfirmCloneOrder',$object->ref),'confirm_clone',$formquestion,'yes',1); } /* * Confirmation de la validation */ if ($action == 'valid') { $object->date_commande=dol_now(); // We check if number is temporary number if (preg_match('/^[\(]?PROV/i',$object->ref) || empty($object->ref)) // empty should not happened, but when it occurs, the test save life { $newref = $object->getNextNumRef($object->thirdparty); } else $newref = $object->ref; if ($newref < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action=''; } else { $text=$langs->trans('ConfirmValidateOrder',$newref); if (! empty($conf->notification->enabled)) { require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; $notify=new Notify($db); $text.='<br>'; $text.=$notify->confirmMessage('ORDER_SUPPLIER_VALIDATE', $object->socid, $object); } $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_valid', '', 0, 1); } } /* * Confirm approval */ if ($action == 'approve' || $action == 'approve2') { $qualified_for_stock_change=0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $qualified_for_stock_change=$object->hasProductsOrServices(2); } else { $qualified_for_stock_change=$object->hasProductsOrServices(1); } $formquestion=array(); if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change) { $langs->load("stocks"); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct=new FormProduct($db); $formquestion=array( //'text' => $langs->trans("ConfirmClone"), //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1)) ); } $text=$langs->trans("ConfirmApproveThisOrder",$object->ref); if (! empty($conf->notification->enabled)) { require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; $notify=new Notify($db); $text.='<br>'; $text.=$notify->confirmMessage('ORDER_SUPPLIER_APPROVE', $object->socid, $object); } $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ApproveThisOrder"), $text, "confirm_".$action, $formquestion, 1, 1, 240); } /* * Confirmation de la desapprobation */ if ($action == 'refuse') { $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("DenyingThisOrder"),$langs->trans("ConfirmDenyingThisOrder",$object->ref),"confirm_refuse", '', 0, 1); } /* * Confirmation de l'annulation */ if ($action == 'cancel') { $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("Cancel"),$langs->trans("ConfirmCancelThisOrder",$object->ref),"confirm_cancel", '', 0, 1); } /* * Confirmation de l'envoi de la commande */ if ($action == 'commande') { $date_com = dol_mktime(GETPOST('rehour'),GETPOST('remin'),GETPOST('resec'),GETPOST("remonth"),GETPOST("reday"),GETPOST("reyear")); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id."&datecommande=".$date_com."&methode=".$_POST["methodecommande"]."&comment=".urlencode($_POST["comment"]), $langs->trans("MakeOrder"),$langs->trans("ConfirmMakeOrder",dol_print_date($date_com,'day')),"confirm_commande",'',0,2); } // Confirmation to delete line if ($action == 'ask_deleteline') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); } if (!$formconfirm) { $parameters=array('lineid'=>$lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; } // Print form confirm print $formconfirm; /* * Commande */ $nbrow=8; if (! empty($conf->projet->enabled)) $nbrow++; //Local taxes if($mysoc->localtax1_assuj=="1") $nbrow++; if($mysoc->localtax2_assuj=="1") $nbrow++; print '<table class="border" width="100%">'; $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; // Ref print '<tr><td width="20%">'.$langs->trans("Ref").'</td>'; print '<td colspan="2">'; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref'); print '</td>'; print '</tr>'; // Ref supplier print '<tr><td>'; print $form->editfieldkey("RefSupplier",'ref_supplier',$object->ref_supplier,$object,$user->rights->fournisseur->commande->creer); print '</td><td colspan="2">'; print $form->editfieldval("RefSupplier",'ref_supplier',$object->ref_supplier,$object,$user->rights->fournisseur->commande->creer); print '</td></tr>'; // Fournisseur print '<tr><td>'.$langs->trans("Supplier")."</td>"; print '<td colspan="2">'.$object->thirdparty->getNomUrl(1,'supplier').'</td>'; print '</tr>'; // Statut print '<tr>'; print '<td>'.$langs->trans("Status").'</td>'; print '<td colspan="2">'; print $object->getLibStatut(4); print "</td></tr>"; // Date if ($object->methode_commande_id > 0) { print '<tr><td>'.$langs->trans("Date").'</td><td colspan="2">'; if ($object->date_commande) { print dol_print_date($object->date_commande,"dayhourtext")."\n"; } print "</td></tr>"; if ($object->methode_commande) { print '<tr><td>'.$langs->trans("Method").'</td><td colspan="2">'.$object->getInputMethod().'</td></tr>'; } } // Author print '<tr><td>'.$langs->trans("AuthorRequest").'</td>'; print '<td colspan="2">'.$author->getNomUrl(1).'</td>'; print '</tr>'; // Conditions de reglement par defaut $langs->load('bills'); print '<tr><td class="nowrap">'; print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; print $langs->trans('PaymentConditions'); print '<td>'; if ($action != 'editconditions') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>'; print '</tr></table>'; print '</td><td colspan="2">'; if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id,'cond_reglement_id'); } else { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id,'none'); } print "</td>"; print '</tr>'; // Mode of payment $langs->load('bills'); print '<tr><td class="nowrap">'; print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; print $langs->trans('PaymentMode'); print '</td>'; if ($action != 'editmode') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$object->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>'; print '</tr></table>'; print '</td><td colspan="2">'; if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id'); } else { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none'); } print '</td></tr>'; // Bank Account if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && ! empty($conf->banque->enabled)) { print '<tr><td class="nowrap">'; print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; print $langs->trans('BankAccount'); print '<td>'; if ($action != 'editbankaccount' && $user->rights->fournisseur->commande->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>'; print '</tr></table>'; print '</td><td colspan="3">'; if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); } else { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); } print '</td>'; print '</tr>'; } // Delivery date planed print '<tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>'; print $langs->trans('DateDeliveryPlanned'); print '</td>'; if ($action != 'editdate_livraison') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'</a></td>'; print '</tr></table>'; print '</td><td colspan="2">'; if ($action == 'editdate_livraison') { print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="action" value="setdate_livraison">'; $usehourmin=0; if (! empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin=1; $form->select_date($object->date_livraison?$object->date_livraison:-1,'liv_',$usehourmin,$usehourmin,'',"setdate_livraison"); print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; print '</form>'; } else { $usehourmin='day'; if (! empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin='dayhour'; print $object->date_livraison ? dol_print_date($object->date_livraison, $usehourmin) : '&nbsp;'; } print '</td></tr>'; // Delivery delay (in days) print '<tr>'; print '<td>'.$langs->trans('NbDaysToDelivery').'&nbsp;'.img_picto($langs->trans('DescNbDaysToDelivery'), 'info', 'style="cursor:help"').'</td>'; print '<td>'.$object->getMaxDeliveryTimeDay($langs).'</td>'; print '</tr>'; // Project if (! empty($conf->projet->enabled)) { $langs->load('projects'); print '<tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>'; print $langs->trans('Project'); print '</td>'; if ($action != 'classify') print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->trans('SetProject')).'</a></td>'; print '</tr></table>'; print '</td><td colspan="2">'; //print "$object->id, $object->socid, $object->fk_project"; if ($action == 'classify') { $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:'-1'), $object->fk_project, 'projectid', 0, 0, 1); } else { $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0); } print '</td>'; print '</tr>'; } // Incoterms if (!empty($conf->incoterm->enabled)) { print '<tr><td>'; print '<table width="100%" class="nobordernopadding"><tr><td>'; print $langs->trans('IncotermLabel'); print '<td><td align="right">'; if ($user->rights->fournisseur->commande->creer) print '<a href="'.DOL_URL_ROOT.'/fourn/commande/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>'; else print '&nbsp;'; print '</td></tr></table>'; print '</td>'; print '<td colspan="3">'; if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1); } else { print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id); } print '</td></tr>'; } // Other attributes $cols = 3; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; // Total print '<tr><td>'.$langs->trans("AmountHT").'</td>'; print '<td colspan="2">'.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).'</td>'; print '</tr>'; // Total VAT print '<tr><td>'.$langs->trans("AmountVAT").'</td><td colspan="2">'.price($object->total_tva,'',$langs,1,-1,-1,$conf->currency).'</td>'; print '</tr>'; // Amount Local Taxes if ($mysoc->localtax1_assuj=="1" || $object->total_localtax1 != 0) //Localtax1 { print '<tr><td>'.$langs->transcountry("AmountLT1",$mysoc->country_code).'</td>'; print '<td colspan="2">'.price($object->total_localtax1,'',$langs,1,-1,-1,$conf->currency).'</td>'; print '</tr>'; } if ($mysoc->localtax2_assuj=="1" || $object->total_localtax2 != 0) //Localtax2 { print '<tr><td>'.$langs->transcountry("AmountLT2",$mysoc->country_code).'</td>'; print '<td colspan="2">'.price($object->total_localtax2,'',$langs,1,-1,-1,$conf->currency).'</td>'; print '</tr>'; } // Total TTC print '<tr><td>'.$langs->trans("AmountTTC").'</td><td colspan="2">'.price($object->total_ttc,'',$langs,1,-1,-1,$conf->currency).'</td>'; print '</tr>'; print "</table><br>"; if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $blocname = 'notes'; $title = $langs->trans('Notes'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } /* * Lines */ //$result = $object->getLinesArray(); print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline')?'#add':'#line_'.GETPOST('lineid')).'" method="POST"> <input type="hidden" name="token" value="'.$_SESSION['newtoken'].'"> <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline') . '"> <input type="hidden" name="mode" value=""> <input type="hidden" name="id" value="'.$object->id.'"> <input type="hidden" name="socid" value="'.$societe->id.'"> '; if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; } print '<table id="tablelines" class="noborder noshadow" width="100%">'; // Add free products/services form global $forceall, $senderissupplier, $dateSelector; $forceall=1; $senderissupplier=1; $dateSelector=0; // Show object lines $inputalsopricewithtax=0; if (! empty($object->lines)) $ret = $object->printObjectLines($action, $societe, $mysoc, $lineid, 1); $num = count($object->lines); /* $i = 0; $total = 0; if ($num) { print '<tr class="liste_titre">'; print '<td>'.$langs->trans('Label').'</td>'; print '<td align="right" width="50">'.$langs->trans('VAT').'</td>'; print '<td align="right" width="80">'.$langs->trans('PriceUHT').'</td>'; print '<td align="right" width="50">'.$langs->trans('Qty').'</td>'; print '<td align="right" width="50">'.$langs->trans('ReductionShort').'</td>'; print '<td align="right" width="50">'.$langs->trans('TotalHTShort').'</td>'; print '<td width="48" colspan="3">&nbsp;</td>'; print "</tr>\n"; } $var=true; while ($i < $num) { $line = $object->lines[$i]; $var=!$var; // Show product and description $type=(! empty($line->product_type)?$line->product_type:(! empty($line->fk_product_type)?$line->fk_product_type:0)); // Try to enhance type detection using date_start and date_end for free lines where type // was not saved. $date_start=''; $date_end=''; if (! empty($line->date_start)) { $date_start=$line->date_start; $type=1; } if (! empty($line->date_end)) { $date_end=$line->date_end; $type=1; } // Edit line if ($action != 'editline' || $_GET['rowid'] != $line->id) { print '<tr id="row-'.$line->id.'" '.$bc[$var].'>'; // Show product and description print '<td>'; if ($line->fk_product > 0) { print '<a name="'.$line->id.'"></a>'; // ancre pour retourner sur la ligne $product_static=new ProductFournisseur($db); $product_static->fetch($line->fk_product); $text=$product_static->getNomUrl(1,'supplier'); $text.= ' - '.$product_static->libelle; $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description)); print $form->textwithtooltip($text,$description,3,'','',$i); // Show range print_date_range($date_start,$date_end); // Add description in form if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) print ($line->description && $line->description!=$product_static->libelle)?'<br>'.dol_htmlentitiesbr($line->description):''; } // Description - Editor wysiwyg if (! $line->fk_product) { if ($type==1) $text = img_object($langs->trans('Service'),'service'); else $text = img_object($langs->trans('Product'),'product'); print $text.' '.nl2br($line->description); // Show range print_date_range($date_start,$date_end); } print '</td>'; print '<td align="right" class="nowrap">'.vatrate($line->tva_tx).'%</td>'; print '<td align="right" class="nowrap">'.price($line->subprice)."</td>\n"; print '<td align="right" class="nowrap">'.$line->qty.'</td>'; if ($line->remise_percent > 0) { print '<td align="right" class="nowrap">'.dol_print_reduction($line->remise_percent,$langs)."</td>\n"; } else { print '<td>&nbsp;</td>'; } print '<td align="right" class="nowrap">'.price($line->total_ht).'</td>'; if (is_object($hookmanager)) { $parameters=array('line'=>$line,'num'=>$num,'i'=>$i); $reshook=$hookmanager->executeHooks('printObjectLine',$parameters,$object,$action); } if ($object->statut == 0 && $user->rights->fournisseur->commande->creer) { print '<td align="center" width="16"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=editline&amp;rowid='.$line->id.'#'.$line->id.'">'; print img_edit(); print '</a></td>'; $actiondelete='delete_product_line'; print '<td align="center" width="16"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action='.$actiondelete.'&amp;lineid='.$line->id.'">'; print img_delete(); print '</a></td>'; } else { print '<td>&nbsp;</td><td>&nbsp;</td>'; } print "</tr>"; } // Edit line if ($action == 'editline' && $user->rights->fournisseur->commande->creer && ($_GET["rowid"] == $line->id)) { print "\n"; print '<tr '.$bc[$var].'>'; print '<td>'; print '<input type="hidden" name="elrowid" value="'.$_GET['rowid'].'">'; print '<a name="'.$line->id.'"></a>'; // ancre pour retourner sur la ligne if ((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && $line->fk_product > 0) { $product_static=new ProductFournisseur($db); $product_static->fetch($line->fk_product); $text=$product_static->getNomUrl(1,'supplier'); $text.= ' - '.$product_static->libelle; $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description)); print $form->textwithtooltip($text,$description,3,'','',$i); // Show range print_date_range($date_start,$date_end); print '<br>'; } else { $forceall=1; // For suppliers, we always show all types print $form->select_type_of_lines($line->product_type,'type',1,0,$forceall); if ($forceall || (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) || (empty($conf->product->enabled) && empty($conf->service->enabled))) print '<br>'; } if (is_object($hookmanager)) { $parameters=array('fk_parent_line'=>$line->fk_parent_line, 'line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i); $reshook=$hookmanager->executeHooks('formEditProductOptions',$parameters,$object,$action); } $nbrows=ROWS_2; if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; $doleditor=new DolEditor('eldesc',$line->description,'',200,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); $doleditor->Create(); print '<br>'; print $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; print $form->select_date($date_start,'date_start'.$date_pf,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,'',1,0,1); print ' '.$langs->trans('to').' '; print $form->select_date($date_end,'date_end'.$date_pf,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,'',1,0,1); print '</td>'; print '<td>'; print $form->load_tva('tva_tx',$line->tva_tx,$object->thirdparty,$mysoc); print '</td>'; print '<td align="right"><input size="5" type="text" name="pu" value="'.price($line->subprice).'"></td>'; print '<td align="right"><input size="2" type="text" name="qty" value="'.$line->qty.'"></td>'; print '<td align="right" class="nowrap"><input size="1" type="text" name="remise_percent" value="'.$line->remise_percent.'"><span class="hideonsmartphone">%</span></td>'; print '<td align="center" colspan="4"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">'; print '<br><input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'"></td>'; print '</tr>' . "\n"; } $i++; } */ // Form to add new line if ($object->statut == 0 && $user->rights->fournisseur->commande->creer) { if ($action != 'editline') { $var = true; // Add free products/services $object->formAddObjectLine(1, $societe, $mysoc); $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook } } print '</table>'; print '</form>'; dol_fiche_end(); /* * Action presend */ if (GETPOST('modelselected')) { $action = 'presend'; } if ($action == 'presend') { $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); $file=$fileparams['fullname']; // Define output language $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->client->default_lang; if (!empty($newlang)) { $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('commercial'); } // Build document if it not exists if (! $file || ! is_readable($file)) { $result= $object->generateDocument(GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); exit; } $fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); $file=$fileparams['fullname']; } print '<div class="clearboth"></div>'; print '<br>'; print_fiche_titre($langs->trans('SendOrderByMail')); dol_fiche_head(''); // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); $formmail->fromtype = 'user'; $formmail->fromid = $user->id; $formmail->fromname = $user->getFullName($langs); $formmail->frommail = $user->email; $formmail->withfrom=1; $liste=array(); foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; $formmail->withto=GETPOST("sendto")?GETPOST("sendto"):$liste; $formmail->withtocc=$liste; $formmail->withtoccc=(! empty($conf->global->MAIN_EMAIL_USECCC)?$conf->global->MAIN_EMAIL_USECCC:false); $formmail->withtopic=$outputlangs->trans('SendOrderRef','__ORDERREF__'); $formmail->withfile=2; $formmail->withbody=1; $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; $object->fetch_projet(); // Tableau des substitutions $formmail->substit['__ORDERREF__']=$object->ref; $formmail->substit['__ORDERSUPPLIERREF__']=$object->ref_supplier; $formmail->substit['__THIRDPARTY_NAME__'] = $object->thirdparty->name; $formmail->substit['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:''); $formmail->substit['__SIGNATURE__']=$user->signature; $formmail->substit['__PERSONALIZED__']=''; $formmail->substit['__CONTACTCIVNAME__']=''; //Find the good contact adress $custcontact=''; $contactarr=array(); $contactarr=$object->liste_contact(-1,'external'); if (is_array($contactarr) && count($contactarr)>0) { foreach($contactarr as $contact) { if ($contact['libelle']==$langs->trans('TypeContact_order_supplier_external_BILLING')) { require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $contactstatic=new Contact($db); $contactstatic->fetch($contact['id']); $custcontact=$contactstatic->getFullName($langs,1); } } if (!empty($custcontact)) { $formmail->substit['__CONTACTCIVNAME__']=$custcontact; } } // Tableau des parametres complementaires $formmail->param['action']='send'; $formmail->param['models']='order_supplier_send'; $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['orderid']=$object->id; $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; // Init list of files if (GETPOST("mode")=='init') { $formmail->clear_attached_files(); $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); } // Show form print $formmail->get_form(); dol_fiche_end(); } /* * Action webservice */ elseif ($action == 'webservice' && GETPOST('mode', 'alpha') != "send" && ! GETPOST('cancel')) { $mode = GETPOST('mode', 'alpha'); $ws_url = $object->thirdparty->webservices_url; $ws_key = $object->thirdparty->webservices_key; $ws_user = GETPOST('ws_user','alpha'); $ws_password = GETPOST('ws_password','alpha'); // NS and Authentication parameters $ws_ns = 'http://www.dolibarr.org/ns/'; $ws_authentication = array( 'dolibarrkey'=>$ws_key, 'sourceapplication'=>'DolibarrWebServiceClient', 'login'=>$ws_user, 'password'=>$ws_password, 'entity'=>'' ); print load_fiche_titre($langs->trans('CreateRemoteOrder'),''); //Is everything filled? if (empty($ws_url) || empty($ws_key)) { setEventMessage($langs->trans("ErrorWebServicesFieldsRequired"), 'errors'); $mode = "init"; $error_occurred = true; //Don't allow to set the user/pass if thirdparty fields are not filled } else if ($mode != "init" && (empty($ws_user) || empty($ws_password))) { setEventMessage($langs->trans("ErrorFieldsRequired"), 'errors'); $mode = "init"; } if ($mode == "init") { //Table/form header print '<table class="border" width="100%">'; print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="action" value="webservice">'; print '<input type="hidden" name="mode" value="check">'; if ($error_occurred) { print "<br>".$langs->trans("ErrorOccurredReviseAndRetry")."<br>"; print '<input class="button" type="submit" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; } else { $textinput_size = "50"; // Webservice url print '<tr><td>'.$langs->trans("WebServiceURL").'</td><td colspan="3">'.dol_print_url($ws_url).'</td></tr>'; //Remote User print '<tr><td>'.$langs->trans("User").'</td><td><input size="'.$textinput_size.'" type="text" name="ws_user"></td></tr>'; //Remote Password print '<tr><td>'.$langs->trans("Password").'</td><td><input size="'.$textinput_size.'" type="text" name="ws_password"></td></tr>'; //Submit button print '<tr><td align="center" colspan="2">'; print '<input class="button" type="submit" id="ws_submit" name="ws_submit" value="'.$langs->trans("CreateRemoteOrder").'">'; print ' &nbsp; &nbsp; '; //Cancel button print '<input class="button" type="submit" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; print '</td></tr>'; } //End table/form print '</form>'; print '</table>'; } elseif ($mode == "check") { $ws_entity = ''; $ws_thirdparty = ''; $error_occurred = false; //Create SOAP client and connect it to user $soapclient_user = new nusoap_client($ws_url."/webservices/server_user.php"); $soapclient_user->soap_defencoding='UTF-8'; $soapclient_user->decodeUTF8(false); //Get the thirdparty associated to user $ws_parameters = array('authentication'=>$ws_authentication, 'id' => '', 'ref'=>$ws_user); $result_user = $soapclient_user->call("getUser", $ws_parameters, $ws_ns, ''); $user_status_code = $result_user["result"]["result_code"]; if ($user_status_code == "OK") { //Fill the variables $ws_entity = $result_user["user"]["entity"]; $ws_authentication['entity'] = $ws_entity; $ws_thirdparty = $result_user["user"]["fk_thirdparty"]; if (empty($ws_thirdparty)) { setEventMessage($langs->trans("RemoteUserMissingAssociatedSoc"), 'errors'); $error_occurred = true; } else { //Create SOAP client and connect it to product/service $soapclient_product = new nusoap_client($ws_url."/webservices/server_productorservice.php"); $soapclient_product->soap_defencoding='UTF-8'; $soapclient_product->decodeUTF8(false); // Iterate each line and get the reference that uses the supplier of that product/service $i = 0; foreach ($object->lines as $line) { $i = $i + 1; $ref_supplier = $line->ref_supplier; $line_id = $i."º) ".$line->product_ref.": "; if (empty($ref_supplier)) { continue; } $ws_parameters = array('authentication' => $ws_authentication, 'id' => '', 'ref' => $ref_supplier); $result_product = $soapclient_product->call("getProductOrService", $ws_parameters, $ws_ns, ''); if (!$result_product) { setEventMessage($line_id.$langs->trans("SOAPError")." ".$soapclient_product->error_str." - ".$soapclient_product->response, 'errors'); $error_occurred = true; break; } // Check the result code $status_code = $result_product["result"]["result_code"]; if (empty($status_code)) //No result, check error str { setEventMessage($langs->trans("SOAPError")." '".$soapclient_order->error_str."'", 'errors'); } else if ($status_code != "OK") //Something went wrong { if ($status_code == "NOT_FOUND") { setEventMessage($line_id.$langs->trans("SupplierMissingRef")." '".$ref_supplier."'", 'warnings'); } else { setEventMessage($line_id.$langs->trans("ResponseNonOK")." '".$status_code."' - '".$result_product["result"]["result_label"]."'", 'errors'); $error_occurred = true; break; } } // Ensure that price is equal and warn user if it's not $supplier_price = price($result_product["product"]["price_net"]); //Price of client tab in supplier dolibarr $local_price = NULL; //Price of supplier as stated in product suppliers tab on this dolibarr, NULL if not found $product_fourn = new ProductFournisseur($db); $product_fourn_list = $product_fourn->list_product_fournisseur_price($line->fk_product); if (count($product_fourn_list)>0) { foreach($product_fourn_list as $product_fourn_line) { //Only accept the line where the supplier is the same at this order and has the same ref if ($product_fourn_line->fourn_id == $object->socid && $product_fourn_line->fourn_ref == $ref_supplier) { $local_price = price($product_fourn_line->fourn_price); } } } if ($local_price != NULL && $local_price != $supplier_price) { setEventMessage($line_id.$langs->trans("RemotePriceMismatch")." ".$supplier_price." - ".$local_price, 'warnings'); } // Check if is in sale if (empty($result_product["product"]["status_tosell"])) { setEventMessage($line_id.$langs->trans("ProductStatusNotOnSellShort")." '".$ref_supplier."'", 'warnings'); } } } } elseif ($user_status_code == "PERMISSION_DENIED") { setEventMessage($langs->trans("RemoteUserNotPermission"), 'errors'); $error_occurred = true; } elseif ($user_status_code == "BAD_CREDENTIALS") { setEventMessage($langs->trans("RemoteUserBadCredentials"), 'errors'); $error_occurred = true; } else { setEventMessage($langs->trans("ResponseNonOK")." '".$user_status_code."'", 'errors'); $error_occurred = true; } //Form print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="action" value="webservice">'; print '<input type="hidden" name="mode" value="send">'; print '<input type="hidden" name="ws_user" value="'.$ws_user.'">'; print '<input type="hidden" name="ws_password" value="'.$ws_password.'">'; print '<input type="hidden" name="ws_entity" value="'.$ws_entity.'">'; print '<input type="hidden" name="ws_thirdparty" value="'.$ws_thirdparty.'">'; if ($error_occurred) { print "<br>".$langs->trans("ErrorOccurredReviseAndRetry")."<br>"; } else { print '<input class="button" type="submit" id="ws_submit" name="ws_submit" value="'.$langs->trans("Confirm").'">'; print ' &nbsp; &nbsp; '; } print '<input class="button" type="submit" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; print '</form>'; } } /* * Show buttons */ else { /** * Boutons actions */ $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if (empty($reshook)) { if ($user->societe_id == 0 && $action != 'editline' && $action != 'delete') { print '<div class="tabsAction">'; // Validate if ($object->statut == 0 && $num > 0) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->commande->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_order_advance->validate))) { $tmpbuttonlabel=$langs->trans('Validate'); if ($user->rights->fournisseur->commande->approuver && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) $tmpbuttonlabel = $langs->trans("ValidateAndApprove"); print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valid">'; print $tmpbuttonlabel; print '</a>'; } } // Modify if ($object->statut == 1) { if ($user->rights->fournisseur->commande->commander) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("Modify").'</a>'; } } // Approve if ($object->statut == 1) { if ($user->rights->fournisseur->commande->approuver) { if (! empty($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL && ! empty($object->user_approve_id)) { print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("FirstApprovalAlreadyDone")).'">'.$langs->trans("ApproveOrder").'</a>'; } else { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=approve">'.$langs->trans("ApproveOrder").'</a>'; } } else { print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans("ApproveOrder").'</a>'; } } // Second approval (if option SUPPLIER_ORDER_DOUBLE_APPROVAL is set) if (! empty($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL) { if ($object->statut == 1) { if ($user->rights->fournisseur->commande->approve2) { if (! empty($object->user_approve_id2)) { print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("SecondApprovalAlreadyDone")).'">'.$langs->trans("Approve2Order").'</a>'; } else { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=approve2">'.$langs->trans("Approve2Order").'</a>'; } } else { print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans("Approve2Order").'</a>'; } } } // Refuse if ($object->statut == 1) { if ($user->rights->fournisseur->commande->approuver || $user->rights->fournisseur->commande->approve2) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=refuse">'.$langs->trans("RefuseOrder").'</a>'; } else { print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans("RefuseOrder").'</a>'; } } // Send if (in_array($object->statut, array(2, 3, 4, 5))) { if ($user->rights->fournisseur->commande->commander) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a>'; } } // Reopen if (in_array($object->statut, array(2))) { $buttonshown=0; if (! $buttonshown && $user->rights->fournisseur->commande->approuver) { if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) || (! empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) && $user->id == $object->user_approve_id)) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("Disapprove").'</a>'; $buttonshown++; } } if (! $buttonshown && $user->rights->fournisseur->commande->approve2 && ! empty($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL)) { if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) || (! empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) && $user->id == $object->user_approve_id2)) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("Disapprove").'</a>'; } } } if (in_array($object->statut, array(3, 5, 6, 7, 9))) { if ($user->rights->fournisseur->commande->commander) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>'; } } // Create bill if (! empty($conf->facture->enabled)) { if (! empty($conf->fournisseur->enabled) && ($object->statut >= 2 && $object->statut != 9)) // 2 means accepted { if ($user->rights->fournisseur->facture->creer) { print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>'; } //if ($user->rights->fournisseur->commande->creer && $object->statut > 2) //{ // print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>'; //} } } // Create a remote order using WebService only if module is activated if (! empty($conf->syncsupplierwebservices->enabled) && $object->statut >= 2) // 2 means accepted { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=webservice&amp;mode=init">'.$langs->trans('CreateRemoteOrder').'</a>'; } // Clone if ($user->rights->fournisseur->commande->creer) { print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a>'; } // Cancel if ($object->statut == 2) { if ($user->rights->fournisseur->commande->commander) { print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=cancel">'.$langs->trans("CancelOrder").'</a>'; } } // Delete if ($user->rights->fournisseur->commande->supprimer) { print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>'; } print "</div>"; } } print "<br>"; print '<div class="fichecenter"><div class="fichehalfleft">'; /* * Documents generes */ $comfournref = dol_sanitizeFileName($object->ref); $file = $conf->fournisseur->dir_output . '/commande/' . $comfournref . '/' . $comfournref . '.pdf'; $relativepath = $comfournref.'/'.$comfournref.'.pdf'; $filedir = $conf->fournisseur->dir_output . '/commande/' . $comfournref; $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed=$user->rights->fournisseur->commande->creer; $delallowed=$user->rights->fournisseur->commande->supprimer; print $formfile->showdocuments('commande_fournisseur',$comfournref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,0,0,'','','',$object->thirdparty->default_lang); $somethingshown=$formfile->numoffiles; // Linked object block $somethingshown = $form->showLinkedObjectBlock($object); // Show links to link elements //$linktoelem = $form->showLinkToObjectBlock($object); //if ($linktoelem) print '<br>'.$linktoelem; print '</div><div class="fichehalfright"><div class="ficheaddleft">'; if ($user->rights->fournisseur->commande->commander && $object->statut == 2) { /* * Commander (action=commande) */ print '<!-- form to record supplier order -->'."\n"; print '<form name="commande" action="card.php?id='.$object->id.'&amp;action=commande" method="post">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="action" value="commande">'; print_fiche_titre($langs->trans("ToOrder"),'',''); print '<table class="border" width="100%">'; //print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("ToOrder").'</td></tr>'; print '<tr><td>'.$langs->trans("OrderDate").'</td><td>'; $date_com = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); print $form->select_date($date_com,'',1,1,'',"commande",1,0,1); print '</td></tr>'; print '<tr><td>'.$langs->trans("OrderMode").'</td><td>'; $formorder->selectInputMethod(GETPOST('methodecommande'), "methodecommande", 1); print '</td></tr>'; print '<tr><td>'.$langs->trans("Comment").'</td><td><input size="40" type="text" name="comment" value="'.GETPOST('comment').'"></td></tr>'; print '<tr><td align="center" colspan="2"><input type="submit" class="button" value="'.$langs->trans("ToOrder").'"></td></tr>'; print '</table>'; print '</form>'; print "<br>"; } if ($user->rights->fournisseur->commande->receptionner && ($object->statut == 3 || $object->statut == 4)) { /* * Receptionner (action=livraison) */ print '<!-- form to record supplier order received -->'."\n"; print '<form action="card.php?id='.$object->id.'" method="post">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="action" value="livraison">'; print_fiche_titre($langs->trans("Receive"),'',''); print '<table class="border" width="100%">'; //print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Receive").'</td></tr>'; print '<tr><td>'.$langs->trans("DeliveryDate").'</td><td>'; print $form->select_date('','',1,1,'',"commande",1,0,1); print "</td></tr>\n"; print "<tr><td>".$langs->trans("Delivery")."</td><td>\n"; $liv = array(); $liv[''] = '&nbsp;'; $liv['tot'] = $langs->trans("TotalWoman"); $liv['par'] = $langs->trans("PartialWoman"); $liv['nev'] = $langs->trans("NeverReceived"); $liv['can'] = $langs->trans("Canceled"); print $form->selectarray("type",$liv); print '</td></tr>'; print '<tr><td>'.$langs->trans("Comment").'</td><td><input size="40" type="text" name="comment"></td></tr>'; print '<tr><td align="center" colspan="2"><input type="submit" class="button" value="'.$langs->trans("Receive").'"></td></tr>'; print "</table>\n"; print "</form>\n"; print "<br>"; } // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions=new FormActions($db); $somethingshown=$formactions->showactions($object,'order_supplier',$socid); // List of actions on element /* Hidden because" available into "Log" tab print '<br>'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions=new FormActions($db); $somethingshown=$formactions->showactions($object,'order_supplier',$socid); */ print '</div></div></div>'; } print '</td></tr></table>'; } // End of page llxFooter(); $db->close();
maestrano/dolibarr
htdocs/fourn/commande/card.php
PHP
gpl-3.0
110,475
import random from cloudbot.util import http, formatting def api_get(kind, query): """Use the RESTful Google Search API""" url = 'http://ajax.googleapis.com/ajax/services/search/%s?' \ 'v=1.0&safe=moderate' return http.get_json(url % kind, q=query) # @hook.command("googleimage", "gis", "image") def googleimage(text): """<query> - returns the first google image result for <query>""" parsed = api_get('images', text) if not 200 <= parsed['responseStatus'] < 300: raise IOError('error searching for images: {}: {}'.format(parsed['responseStatus'], '')) if not parsed['responseData']['results']: return 'no images found' return random.choice(parsed['responseData']['results'][:10])['unescapedUrl'] # @hook.command("google", "g", "search") def google(text): """<query> - returns the first google search result for <query>""" parsed = api_get('web', text) if not 200 <= parsed['responseStatus'] < 300: raise IOError('error searching for pages: {}: {}'.format(parsed['responseStatus'], '')) if not parsed['responseData']['results']: return 'No results found.' result = parsed['responseData']['results'][0] title = http.unescape(result['titleNoFormatting']) title = formatting.truncate_str(title, 60) content = http.unescape(result['content']) if not content: content = "No description available." else: content = http.html.fromstring(content).text_content() content = formatting.truncate_str(content, 150).replace('\n', '') return '{} -- \x02{}\x02: "{}"'.format(result['unescapedUrl'], title, content)
weylin/CloudBot
plugins/google.py
Python
gpl-3.0
1,653
/***************************************************************************** * Copyright (c) 2014-2019 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 * * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ #pragma once #include <openrct2/common.h> #include <openrct2/interface/Window.h> enum { UITHEME_FLAG_PREDEFINED = 1 << 0, UITHEME_FLAG_USE_LIGHTS_RIDE = 1 << 1, UITHEME_FLAG_USE_LIGHTS_PARK = 1 << 2, UITHEME_FLAG_USE_ALTERNATIVE_SCENARIO_SELECT_FONT = 1 << 3, UITHEME_FLAG_USE_FULL_BOTTOM_TOOLBAR = 1 << 4, }; void colour_scheme_update(rct_window* window); void colour_scheme_update_all(); void colour_scheme_update_by_class(rct_window* window, rct_windowclass classification); void theme_manager_initialise(); void theme_manager_load_available_themes(); size_t theme_manager_get_num_available_themes(); const utf8* theme_manager_get_available_theme_path(size_t index); const utf8* theme_manager_get_available_theme_config_name(size_t index); const utf8* theme_manager_get_available_theme_name(size_t index); size_t theme_manager_get_active_available_theme_index(); void theme_manager_set_active_available_theme(size_t index); size_t theme_get_index_for_name(const utf8* name); colour_t theme_get_colour(rct_windowclass wc, uint8_t index); void theme_set_colour(rct_windowclass wc, uint8_t index, colour_t colour); uint8_t theme_get_flags(); void theme_set_flags(uint8_t flags); void theme_save(); void theme_rename(const utf8* name); void theme_duplicate(const utf8* name); void theme_delete(); uint8_t theme_desc_get_num_colours(rct_windowclass wc); rct_string_id theme_desc_get_name(rct_windowclass wc);
IntelOrca/OpenRCT2
src/openrct2-ui/interface/Theme.h
C
gpl-3.0
1,863
# Oracle Database puppet module [![Build Status](https://travis-ci.org/biemond/biemond-oradb.png)](https://travis-ci.org/biemond/biemond-oradb) [![Coverage Status](https://coveralls.io/repos/biemond/biemond-oradb/badge.png?branch=master)](https://coveralls.io/r/biemond/biemond-oradb?branch=master) created by Edwin Biemond [biemond.blogspot.com](http://biemond.blogspot.com) [Github homepage](https://github.com/biemond/puppet) Dependency with - puppetlabs/concat >= 1.0.0 - puppetlabs/stdlib >= 3.2.0 Should work on Docker, for Solaris and on all Linux version like RedHat, CentOS, Ubuntu, Debian, Suse SLES or OracleLinux - Docker image of Oracle Database 12.1 SE [Docker Oracle Database 12.1.0.1](https://github.com/biemond/docker-database-puppet) - CentOS 6.5 vagrant box with Oracle Database 12.1 and Enterprise Manager 12.1.0.4 [Enterprise vagrant box](https://github.com/biemond/biemond-em-12c) - CentOS 6.6 vagrant box with Oracle Database 11.2.0.4 on NFS ASM [ASM vagrant box](https://github.com/biemond/biemond-oradb-vagrant-11.2-ASM) - CentOS 6.6 vagrant box with Oracle Database 12.1.0.1 with pluggable databases [12c pluggable db vagrant box](https://github.com/biemond/biemond-oradb-vagrant-12.1-CDB) - Solaris 11.2 vagrant box with Oracle Database 12.1 [solaris 11.2 vagrant box](https://github.com/biemond/biemond-oradb-vagrant-12.1-solaris11.2) - Solaris 10 vagrant box with Oracle Database 12.1 [solaris 10 vagrant box](https://github.com/biemond/biemond-orawls-vagrant-solaris-soa) - CentOS 6.5 vagrant box with Oracle Database 11.2.0.4 and GoldenGate 12.1.2 [coherence goldengate vagrant box]( https://github.com/biemond/vagrant-wls12.1.2-coherence-goldengate) Example of Opensource Puppet 3.4.3 Puppet master configuration in a vagrant box [puppet master](https://github.com/biemond/vagrant-puppetmaster) - oradb (oracle database 11.2.0.1 ) with GoldenGate 12.1.2 Should work for Puppet 2.7 & 3.0 ## Oracle Database Features - Oracle Grid 11.2.0.4, 12.1.0.1 Linux / Solaris installation - Oracle Database 12.1.0.1,12.1.0.2 Linux / Solaris installation - Oracle Database 11.2.0.1,11.2.0.3,11.2.0.4 Linux / Solaris installation - Oracle Database Instance 11.2 & 12.1 with pluggable database or provide your own db template - Oracle Database Client 12.1.0.1,12.1.0.2,11.2.0.4,11.2.0.1 Linux / Solaris installation - Oracle Database Net configuration - Oracle Database Listener - Tnsnames entry - Oracle ASM - Oracle RAC - OPatch upgrade - Apply OPatch also for Clusterware - Create database instances - Stop/Start database instances with db_control puppet resource type ## Enterprise Manager - Enterprise Manager Server 12.1.0.4 12c cloud installation / configuration - Agent installation via AgentPull.sh & AgentDeploy.sh ## GoldenGate - GoldenGate 12.1.2, 11.2.1 ## Repository Creation Utility (RCU) - Installs RCU repositoy for Oracle SOA Suite / Webcenter ( 11.1.1.6.0 and 11.1.1.7.0 ) / Oracle Identity Management ( 11.1.2.1 ) ## Oracle RAC In combination with the [ora_rac](https://forge.puppetlabs.com/hajee/ora_rac) module of Bert Hajee (https://forge.puppetlabs.com/hajee/ora_rac) ## Oracle Database resource types - db_control, start stop or a restart a database instance also used by dbactions manifest.pp - db_opatch, used by the opatch.pp manifest - db_rcu, used by the rcu.pp manifest - db_listener, start stop or a restart the oracle listener ( supports refreshonly ) In combination with the [oracle](http://forge.puppetlabs.com/hajee/oracle) module of Bert Hajee (http://forge.puppetlabs.com/hajee/oracle) you can also create - create a tablespace - create a user with the required grants and quota's - create one or more roles - create one or more services - change a database init parameter (Memory or SPFILE) Some manifests like installdb.pp, opatch.pp or rcusoa.pp supports an alternative mountpoint for the big oracle files. When not provided it uses the files location of the oradb puppet module else you can use $puppetDownloadMntPoint => "/mnt" or "puppet:///modules/xxxx/" ## Oracle Big files and alternate download location Some manifests like oradb:installdb, opatch or rcu supports an alternative mountpoint for the big oracle setup/install files. When not provided it uses the files folder located in the orawls puppet module else you can use $source => - "/mnt" - "/vagrant" - "puppet:///modules/oradb/" (default) - "puppet:///database/" when the files are also locally accessible then you can also set $remote_file => false this will not move the files to the download folder, just extract or install ## templates.pp The databaseType value should contain only one of these choices. - EE = Enterprise Edition - SE = Standard Edition - SEONE = Standard Edition One ## ## Installation, Disk or memory issues # hiera hosts: 'emdb.example.com': ip: "10.10.10.15" host_aliases: 'emdb' 'localhost': ip: "127.0.0.1" host_aliases: 'localhost.localdomain,localhost4,localhost4.localdomain4' $host_instances = hiera('hosts', {}) create_resources('host',$host_instances) # disable the firewall service { iptables: enable => false, ensure => false, hasstatus => true, } # set the swap ,forge puppet module petems-swap_file class { 'swap_file': swapfile => '/var/swap.1', swapfilesize => '8192000000' } # set the tmpfs mount { '/dev/shm': ensure => present, atboot => true, device => 'tmpfs', fstype => 'tmpfs', options => 'size=3500m', } see this chapter "Linux kernel, ulimits and required packages" for more important information ## Linux kernel, ulimits and required packages install the following module to set the database kernel parameters *puppet module install fiddyspence-sysctl* install the following module to set the database user limits parameters *puppet module install erwbgy-limits* $all_groups = ['oinstall','dba' ,'oper'] group { $all_groups : ensure => present, } user { 'oracle' : ensure => present, uid => 500, gid => 'oinstall', groups => ['oinstall','dba','oper'], shell => '/bin/bash', password => '$1$DSJ51vh6$4XzzwyIOk6Bi/54kglGk3.', home => "/home/oracle", comment => "This user oracle was created by Puppet", require => Group[$all_groups], managehome => true, } sysctl { 'kernel.msgmnb': ensure => 'present', permanent => 'yes', value => '65536',} sysctl { 'kernel.msgmax': ensure => 'present', permanent => 'yes', value => '65536',} sysctl { 'kernel.shmmax': ensure => 'present', permanent => 'yes', value => '2588483584',} sysctl { 'kernel.shmall': ensure => 'present', permanent => 'yes', value => '2097152',} sysctl { 'fs.file-max': ensure => 'present', permanent => 'yes', value => '6815744',} sysctl { 'net.ipv4.tcp_keepalive_time': ensure => 'present', permanent => 'yes', value => '1800',} sysctl { 'net.ipv4.tcp_keepalive_intvl': ensure => 'present', permanent => 'yes', value => '30',} sysctl { 'net.ipv4.tcp_keepalive_probes': ensure => 'present', permanent => 'yes', value => '5',} sysctl { 'net.ipv4.tcp_fin_timeout': ensure => 'present', permanent => 'yes', value => '30',} sysctl { 'kernel.shmmni': ensure => 'present', permanent => 'yes', value => '4096', } sysctl { 'fs.aio-max-nr': ensure => 'present', permanent => 'yes', value => '1048576',} sysctl { 'kernel.sem': ensure => 'present', permanent => 'yes', value => '250 32000 100 128',} sysctl { 'net.ipv4.ip_local_port_range': ensure => 'present', permanent => 'yes', value => '9000 65500',} sysctl { 'net.core.rmem_default': ensure => 'present', permanent => 'yes', value => '262144',} sysctl { 'net.core.rmem_max': ensure => 'present', permanent => 'yes', value => '4194304', } sysctl { 'net.core.wmem_default': ensure => 'present', permanent => 'yes', value => '262144',} sysctl { 'net.core.wmem_max': ensure => 'present', permanent => 'yes', value => '1048576',} class { 'limits': config => { '*' => { 'nofile' => { soft => '2048' , hard => '8192', },}, 'oracle' => { 'nofile' => { soft => '65536' , hard => '65536', }, 'nproc' => { soft => '2048' , hard => '16384', }, 'stack' => { soft => '10240' ,},}, }, use_hiera => false, } $install = [ 'binutils.x86_64', 'compat-libstdc++-33.x86_64', 'glibc.x86_64','ksh.x86_64','libaio.x86_64', 'libgcc.x86_64', 'libstdc++.x86_64', 'make.x86_64','compat-libcap1.x86_64', 'gcc.x86_64', 'gcc-c++.x86_64','glibc-devel.x86_64','libaio-devel.x86_64','libstdc++-devel.x86_64', 'sysstat.x86_64','unixODBC-devel','glibc.i686','libXext.x86_64','libXtst.x86_64'] package { $install: ensure => present, } ## Database install $puppetDownloadMntPoint = "puppet:///modules/oradb/" oradb::installdb{ '12.1.0.2_Linux-x86-64': version => '12.1.0.2', file => 'V46095-01', databaseType => 'SE', oracleBase => '/oracle', oracleHome => '/oracle/product/12.1/db', bashProfile => true, user => 'oracle', group => 'dba', group_install => 'oinstall', group_oper => 'oper', downloadDir => '/data/install', zipExtract => true, puppetDownloadMntPoint => $puppetDownloadMntPoint, } or with zipExtract ( does not download or extract , software is in /install/linuxamd64_12c_database ) oradb::installdb{ '12.1.0.1_Linux-x86-64': version => '12.1.0.1', file => 'linuxamd64_12c_database', databaseType => 'SE', oracleBase => '/oracle', oracleHome => '/oracle/product/12.1/db', bashProfile => true, user => 'oracle', group => 'dba', group_install => 'oinstall', group_oper => 'oper', downloadDir => '/install', zipExtract => false, } or oradb::installdb{ '112040_Linux-x86-64': version => '11.2.0.4', file => 'p13390677_112040_Linux-x86-64', databaseType => 'SE', oracleBase => '/oracle', oracleHome => '/oracle/product/11.2/db', eeOptionsSelection => true, eeOptionalComponents => 'oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0', user => 'oracle', group => 'dba', group_install => 'oinstall', group_oper => 'oper', downloadDir => '/install', zipExtract => true, puppetDownloadMntPoint => $puppetDownloadMntPoint, } or oradb::installdb{ '112030_Linux-x86-64': version => '11.2.0.3', file => 'p10404530_112030_Linux-x86-64', databaseType => 'SE', oracleBase => '/oracle', oracleHome => '/oracle/product/11.2/db', user => 'oracle', group => 'dba', group_install => 'oinstall', group_oper => 'oper', downloadDir => '/install', zipExtract => true, puppetDownloadMntPoint => $puppetDownloadMntPoint, } or oradb::installdb{ '112010_Linux-x86-64': version => '11.2.0.1', file => 'linux.x64_11gR2_database', databaseType => 'SE', oracleBase => '/oracle', oracleHome => '/oracle/product/11.2/db', user => 'oracle', group => 'dba', group_install => 'oinstall', group_oper => 'oper', downloadDir => '/install', zipExtract => true, } Patching For opatchupgrade you need to provide the Oracle support csiNumber and supportId and need to be online. Or leave them empty but it needs the Expect rpm to emulate OCM # use this on a Grid or Database home oradb::opatchupgrade{'112000_opatch_upgrade': oracleHome => '/oracle/product/11.2/db', patchFile => 'p6880880_112000_Linux-x86-64.zip', # csiNumber => '11111', # supportId => 'biemond@gmail.com', csiNumber => undef, supportId => undef, opversion => '11.2.0.3.6', user => 'oracle', group => 'dba', downloadDir => '/install', puppetDownloadMntPoint => $puppetDownloadMntPoint, require => Oradb::Installdb['112030_Linux-x86-64'], } Opatch # october 2014 11.2.0.4.4 patch oradb::opatch{'19121551_db_patch': ensure => 'present', oracleProductHome => hiera('oracle_home_dir'), patchId => '19121551', patchFile => 'p19121551_112040_Linux-x86-64.zip', user => hiera('oracle_os_user'), group => 'oinstall', downloadDir => hiera('oracle_download_dir'), ocmrf => true, require => Oradb::Opatchupgrade['112000_opatch_upgrade_db'], puppetDownloadMntPoint => hiera('oracle_source'), } or for clusterware aka opatch auto oradb::opatch{'18706472_grid_patch': ensure => 'present', oracleProductHome => hiera('grid_home_dir'), patchId => '18706472', patchFile => 'p18706472_112040_Linux-x86-64.zip', clusterWare => true, bundleSubPatchId => '18522515', sub patchid of bundle patch ( else I can't detect it if it is already applied) user => hiera('grid_os_user'), group => 'oinstall', downloadDir => hiera('oracle_download_dir'), ocmrf => true, require => Oradb::Opatchupgrade['112000_opatch_upgrade'], puppetDownloadMntPoint => hiera('oracle_source'), } # this 19791420 patch contains 2 patches (in different sub folders), one bundle and a normal one. # we want to apply the bundle and need to provide the right value for bundleSubFolder oradb::opatch{'19791420_grid_patch': ensure => 'present', oracleProductHome => hiera('grid_home_dir'), patchId => '19791420', patchFile => 'p19791420_112040_Linux-x86-64.zip', clusterWare => true, bundleSubPatchId => '19121552', # sub patchid of bundle patch ( else I can't detect it if it is already applied) bundleSubFolder => '19380115', # optional subfolder inside the patch zip user => hiera('grid_os_user'), group => 'oinstall', downloadDir => hiera('oracle_download_dir'), ocmrf => true, require => Oradb::Opatchupgrade['112000_opatch_upgrade_asm'], puppetDownloadMntPoint => hiera('oracle_source'), } # the same patch applied with opatch auto to an oracle database home, this time we need to use the 19121551 as bundleSubPatchId # this is the october 2014 11.2.0.4.4 patch oradb::opatch{'19791420_grid_patch': ensure => 'present', oracleProductHome => hiera('oracle_home_dir'), patchId => '19791420', patchFile => 'p19791420_112040_Linux-x86-64.zip', clusterWare => true, bundleSubPatchId => '19121551', # sub patchid of bundle patch ( else I can't detect it if it is already applied) bundleSubFolder => '19380115', # optional subfolder inside the patch zip user => hiera('grid_os_user'), group => 'oinstall', downloadDir => hiera('oracle_download_dir'), ocmrf => true, require => Oradb::Opatchupgrade['112000_opatch_upgrade_asm'], puppetDownloadMntPoint => hiera('oracle_source'), } # same patch 19791420 but then for the oracle db home, this patch requires the bundle patch of 19791420 or # 19121551 october 2014 11.2.0.4.4 patch oradb::opatch{'19791420_db_patch': ensure => 'present', oracleProductHome => hiera('oracle_home_dir'), patchId => '19791420', patchFile => 'p19791420_112040_Linux-x86-64.zip', clusterWare => false, bundleSubPatchId => '19282021', # sub patchid of bundle patch ( else I can't detect it) bundleSubFolder => '19282021', # optional subfolder inside the patch zip user => hiera('oracle_os_user'), group => 'oinstall', downloadDir => hiera('oracle_download_dir'), ocmrf => true, require => Oradb::Opatch['19121551_db_patch'], puppetDownloadMntPoint => hiera('oracle_source'), } Oracle net oradb::net{ 'config net8': oracleHome => '/oracle/product/11.2/db', version => '11.2' or "12.1", user => 'oracle', group => 'dba', downloadDir => '/install', dbPort => '1521', #optional require => Oradb::Opatch['14727310_db_patch'], } Listener db_listener{ 'startlistener': ensure => 'running', # running|start|abort|stop oracle_base_dir => '/oracle', oracle_home_dir => '/oracle/product/11.2/db', os_user => 'oracle', listener_name => 'listener' # which is the default and optional } # subscribe to changes db_listener{ 'startlistener': ensure => 'running', # running|start|abort|stop oracle_base_dir => '/oracle', oracle_home_dir => '/oracle/product/11.2/db', os_user => 'oracle', listener_name => 'listener' # which is the default and optional refreshonly => true, subscribe => XXXXX, } # the old way which also calls db_listener type oradb::listener{'start listener': action => 'start', # running|start|abort|stop oracleBase => '/oracle', oracleHome => '/oracle/product/11.2/db', user => 'oracle', group => 'dba', listenername => 'listener' # which is the default and optional } Database instance oradb::database{ 'testDb_Create': oracleBase => '/oracle', oracleHome => '/oracle/product/11.2/db', version => '11.2', user => 'oracle', group => 'dba', downloadDir => '/install', action => 'create', dbName => 'test', dbDomain => 'oracle.com', dbPort => '1521', sysPassword => 'Welcome01', systemPassword => 'Welcome01', dataFileDestination => "/oracle/oradata", recoveryAreaDestination => "/oracle/flash_recovery_area", characterSet => "AL32UTF8", nationalCharacterSet => "UTF8", initParams => {'open_cursors' => '1000', 'processes' => '600', 'job_queue_processes' => '4' }, sampleSchema => 'TRUE', memoryPercentage => "40", memoryTotal => "800", databaseType => "MULTIPURPOSE", emConfiguration => "NONE", require => Oradb::Listener['start listener'], } you can also use a comma separated string for initParams initParams => "open_cursors=1000,processes=600,job_queue_processes=4", or based on your own template The template must be have the following extension dbt.erb like dbtemplate_12.1.dbt.erb, use puppetDownloadMntPoint parameter for the template location or add your template to the template dir of the oradb module - Click here for an [12.1 db instance template example](https://github.com/biemond/biemond-oradb/blob/master/templates/dbtemplate_12.1.dbt.erb) - Click here for an [11.2 db asm instance template example](https://github.com/biemond/biemond-oradb/blob/master/templates/dbtemplate_11gR2_asm.dbt.erb) with a template of the oradb module oradb::database{ 'testDb_Create': oracleBase => '/oracle', oracleHome => '/oracle/product/12.1/db', version => '12.1', user => 'oracle', group => 'dba', template => 'dbtemplate_12.1', # or dbtemplate_11gR2_asm, this will use dbtemplate_12.1.dbt.erb example template downloadDir => '/install', action => 'create', dbName => 'test', dbDomain => 'oracle.com', dbPort => '1521', sysPassword => 'Welcome01', systemPassword => 'Welcome01', dataFileDestination => "/oracle/oradata", recoveryAreaDestination => "/oracle/flash_recovery_area", characterSet => "AL32UTF8", nationalCharacterSet => "UTF8", memoryPercentage => "40", memoryTotal => "800", require => Oradb::Listener['start listener'], } or your own template on your own location template => 'my_dbtemplate_11gR2_asm', puppetDownloadMntPoint => '/vagrant', # 'oradb' etc 12c container and pluggable databases oradb::database{ 'oraDb': oracleBase => '/oracle', oracleHome => '/oracle/product/12.1/db', version => '12.1', user => 'oracle', group => 'dba' downloadDir => '/install', action => 'create', dbName => 'orcl', dbDomain => 'example.com', sysPassword => 'Welcome01', systemPassword => 'Welcome01', characterSet => 'AL32UTF8', nationalCharacterSet => 'UTF8', sampleSchema => 'FALSE', memoryPercentage => '40', memoryTotal => '800', databaseType => 'MULTIPURPOSE', emConfiguration => 'NONE', dataFileDestination => '/oracle/oradata', recoveryAreaDestination => '/oracle/flash_recovery_area', initParams => {'open_cursors' => '1000', 'processes' => '600', 'job_queue_processes' => '4' }, containerDatabase => true, <|------- } oradb::database_pluggable{'pdb1': ensure => 'present', version => '12.1', oracle_home_dir => '/oracle/product/12.1/db', user => 'oracle', group => 'dba', source_db => 'orcl', pdb_name => 'pdb1', pdb_admin_username => 'pdb_adm', pdb_admin_password => 'Welcome01', pdb_datafile_destination => "/oracle/oradata/orcl/pdb1", create_user_tablespace => true, log_output => true, } # remove the pluggable database oradb::database_pluggable{'pdb1': ensure => 'absent', version => '12.1', oracle_home_dir => '/oracle/product/12.1/db', user => 'oracle', group => 'dba', source_db => 'orcl', pdb_name => 'pdb1', pdb_datafile_destination => "/oracle/oradata/orcl/pdb1", log_output => true, } or delete a database oradb::database{ 'testDb_Delete': oracleBase => '/oracle', oracleHome => '/oracle/product/11.2/db', user => 'oracle', group => 'dba', downloadDir => '/install', action => 'delete', dbName => 'test', sysPassword => 'Welcome01', require => Oradb::Dbactions['start testDb'], } Database instance actions db_control{'emrepos start': ensure => 'running', #running|start|abort|stop instance_name => 'test', oracle_product_home_dir => '/oracle/product/11.2/db', os_user => 'oracle', } db_control{'emrepos stop': ensure => 'stop', #running|start|abort|stop instance_name => 'test', oracle_product_home_dir => '/oracle/product/11.2/db', os_user => 'oracle', } # the old way oradb::dbactions{ 'stop testDb': oracleHome => '/oracle/product/11.2/db', user => 'oracle', group => 'dba', action => 'stop', dbName => 'test', require => Oradb::Database['testDb'], } oradb::dbactions{ 'start testDb': oracleHome => '/oracle/product/11.2/db', user => 'oracle', group => 'dba', action => 'start', dbName => 'test', require => Oradb::Dbactions['stop testDb'], } # subscribe to changes db_control{'emrepos restart': ensure => 'running', #running|start|abort|stop instance_name => 'test', oracle_product_home_dir => '/oracle/product/11.2/db', os_user => 'oracle', refreshonly => true, subscribe => Init_param['emrepos/memory_target'], } oradb::autostartdatabase{ 'autostart oracle': oracleHome => '/oracle/product/12.1/db', user => 'oracle', dbName => 'test', require => Oradb::Dbactions['start testDb'], } Tnsnames.ora oradb::tnsnames{'orcl': oracleHome => '/oracle/product/11.2/db', user => 'oracle', group => 'dba', server => { myserver => { host => soadb.example.nl, port => '1521', protocol => 'TCP' }}, connectServiceName => 'soarepos.example.nl', require => Oradb::Dbactions['start oraDb'], } oradb::tnsnames{'test': oracleHome => '/oracle/product/11.2/db', user => 'oracle', group => 'dba', server => { myserver => { host => soadb.example.nl, port => '1525', protocol => 'TCP' }, { host => soadb2.example.nl, port => '1526', protocol => 'TCP' }}, connectServiceName => 'soarepos.example.nl', connectServer => 'DEDICATED', require => Oradb::Dbactions['start oraDb'], } ## Grid install with ASM $all_groups = ['oinstall','dba' ,'oper','asmdba','asmadmin','asmoper'] group { $all_groups : ensure => present, } user { 'oracle' : ensure => present, uid => 500, gid => 'oinstall', groups => ['oinstall','dba','oper','asmdba'], shell => '/bin/bash', password => '$1$DSJ51vh6$4XzzwyIOk6Bi/54kglGk3.', home => "/home/oracle", comment => "This user oracle was created by Puppet", require => Group[$all_groups], managehome => true, } user { 'grid' : ensure => present, uid => 501, gid => 'oinstall', groups => ['oinstall','dba','asmadmin','asmdba','asmoper'], shell => '/bin/bash', password => '$1$DSJ51vh6$4XzzwyIOk6Bi/54kglGk3.', home => "/home/grid", comment => "This user grid was created by Puppet", require => Group[$all_groups], managehome => true, } ####### NFS example file { '/home/nfs_server_data': ensure => directory, recurse => false, replace => false, mode => '0775', owner => 'grid', group => 'asmadmin', require => User['grid'], } class { 'nfs::server': package => latest, service => running, enable => true, } nfs::export { '/home/nfs_server_data': options => [ 'rw', 'sync', 'no_wdelay','insecure_locks','no_root_squash' ], clients => [ "*" ], require => [File['/home/nfs_server_data'],Class['nfs::server'],], } file { '/nfs_client': ensure => directory, recurse => false, replace => false, mode => '0775', owner => 'grid', group => 'asmadmin', require => User['grid'], } mounts { 'Mount point for NFS data': ensure => present, source => 'soadbasm:/home/nfs_server_data', dest => '/nfs_client', type => 'nfs', opts => 'rw,bg,hard,nointr,tcp,vers=3,timeo=600,rsize=32768,wsize=32768,actimeo=0 0 0', require => [File['/nfs_client'],Nfs::Export['/home/nfs_server_data'],] } exec { "/bin/dd if=/dev/zero of=/nfs_client/asm_sda_nfs_b1 bs=1M count=7520": user => 'grid', group => 'asmadmin', logoutput => true, unless => "/usr/bin/test -f /nfs_client/asm_sda_nfs_b1", require => Mounts['Mount point for NFS data'], } exec { "/bin/dd if=/dev/zero of=/nfs_client/asm_sda_nfs_b2 bs=1M count=7520": user => 'grid', group => 'asmadmin', logoutput => true, unless => "/usr/bin/test -f /nfs_client/asm_sda_nfs_b2", require => [Mounts['Mount point for NFS data'], Exec["/bin/dd if=/dev/zero of=/nfs_client/asm_sda_nfs_b1 bs=1M count=7520"]], } exec { "/bin/dd if=/dev/zero of=/nfs_client/asm_sda_nfs_b3 bs=1M count=7520": user => 'grid', group => 'asmadmin', logoutput => true, unless => "/usr/bin/test -f /nfs_client/asm_sda_nfs_b3", require => [Mounts['Mount point for NFS data'], Exec["/bin/dd if=/dev/zero of=/nfs_client/asm_sda_nfs_b1 bs=1M count=7520"], Exec["/bin/dd if=/dev/zero of=/nfs_client/asm_sda_nfs_b2 bs=1M count=7520"],], } exec { "/bin/dd if=/dev/zero of=/nfs_client/asm_sda_nfs_b4 bs=1M count=7520": user => 'grid', group => 'asmadmin', logoutput => true, unless => "/usr/bin/test -f /nfs_client/asm_sda_nfs_b4", require => [Mounts['Mount point for NFS data'], Exec["/bin/dd if=/dev/zero of=/nfs_client/asm_sda_nfs_b1 bs=1M count=7520"], Exec["/bin/dd if=/dev/zero of=/nfs_client/asm_sda_nfs_b2 bs=1M count=7520"], Exec["/bin/dd if=/dev/zero of=/nfs_client/asm_sda_nfs_b3 bs=1M count=7520"],], } $nfs_files = ['/nfs_client/asm_sda_nfs_b1','/nfs_client/asm_sda_nfs_b2','/nfs_client/asm_sda_nfs_b3','/nfs_client/asm_sda_nfs_b4'] file { $nfs_files: ensure => present, owner => 'grid', group => 'asmadmin', mode => '0664', require => Exec["/bin/dd if=/dev/zero of=/nfs_client/asm_sda_nfs_b4 bs=1M count=7520"], } ###### end of NFS example oradb::installasm{ 'db_linux-x64': version => hiera('db_version'), file => hiera('asm_file'), gridType => 'HA_CONFIG', gridBase => hiera('grid_base_dir'), gridHome => hiera('grid_home_dir'), oraInventoryDir => hiera('oraInventory_dir'), userBaseDir => '/home', user => hiera('grid_os_user'), group => 'asmdba', group_install => 'oinstall', group_oper => 'asmoper', group_asm => 'asmadmin', sys_asm_password => 'Welcome01', asm_monitor_password => 'Welcome01', asm_diskgroup => 'DATA', disk_discovery_string => "/nfs_client/asm*", disks => "/nfs_client/asm_sda_nfs_b1,/nfs_client/asm_sda_nfs_b2", # disk_discovery_string => "ORCL:*", # disks => "ORCL:DISK1,ORCL:DISK2", disk_redundancy => "EXTERNAL", downloadDir => hiera('oracle_download_dir'), remoteFile => false, puppetDownloadMntPoint => hiera('oracle_source'), } oradb::opatchupgrade{'112000_opatch_upgrade_asm': oracleHome => hiera('grid_home_dir'), patchFile => 'p6880880_112000_Linux-x86-64.zip', csiNumber => undef, supportId => undef, opversion => '11.2.0.3.6', user => hiera('grid_os_user'), group => 'oinstall', downloadDir => hiera('oracle_download_dir'), puppetDownloadMntPoint => hiera('oracle_source'), require => Oradb::Installasm['db_linux-x64'], } oradb::opatch{'19791420_grid_patch': ensure => 'present', oracleProductHome => hiera('grid_home_dir'), patchId => '19791420', patchFile => 'p19791420_112040_Linux-x86-64.zip', clusterWare => true, bundleSubPatchId => '19121552', # sub patchid of bundle patch ( else I can't detect it) bundleSubFolder => '19380115', # optional subfolder inside the patch zip user => hiera('grid_os_user'), group => 'oinstall', downloadDir => hiera('oracle_download_dir'), ocmrf => true, require => Oradb::Opatchupgrade['112000_opatch_upgrade_asm'], puppetDownloadMntPoint => hiera('oracle_source'), } oradb::installdb{ 'db_linux-x64': version => hiera('db_version'), file => hiera('db_file'), databaseType => 'EE', oraInventoryDir => hiera('oraInventory_dir'), oracleBase => hiera('oracle_base_dir'), oracleHome => hiera('oracle_home_dir'), userBaseDir => '/home', user => hiera('oracle_os_user'), group => 'dba', group_install => 'oinstall', group_oper => 'oper', downloadDir => hiera('oracle_download_dir'), remoteFile => false, puppetDownloadMntPoint => hiera('oracle_source'), # require => Oradb::Opatch['18706472_grid_patch'], require => Oradb::Opatch['19791420_grid_patch'], } oradb::opatchupgrade{'112000_opatch_upgrade_db': oracleHome => hiera('oracle_home_dir'), patchFile => 'p6880880_112000_Linux-x86-64.zip', csiNumber => undef, supportId => undef, opversion => '11.2.0.3.6', user => hiera('oracle_os_user'), group => hiera('oracle_os_group'), downloadDir => hiera('oracle_download_dir'), puppetDownloadMntPoint => hiera('oracle_source'), require => Oradb::Installdb['db_linux-x64'], } oradb::opatch{'19791420_db_patch': ensure => 'present', oracleProductHome => hiera('oracle_home_dir'), patchId => '19791420', patchFile => 'p19791420_112040_Linux-x86-64.zip', clusterWare => true, bundleSubPatchId => '19121551', #,'19121552', # sub patchid of bundle patch ( else I can't detect it) bundleSubFolder => '19380115', # optional subfolder inside the patch zip user => hiera('oracle_os_user'), group => 'oinstall', downloadDir => hiera('oracle_download_dir'), ocmrf => true, require => Oradb::Opatchupgrade['112000_opatch_upgrade_db'], puppetDownloadMntPoint => hiera('oracle_source'), } oradb::opatch{'19791420_db_patch_2': ensure => 'present', oracleProductHome => hiera('oracle_home_dir'), patchId => '19791420', patchFile => 'p19791420_112040_Linux-x86-64.zip', clusterWare => false, bundleSubPatchId => '19282021', # sub patchid of bundle patch ( else I can't detect it) bundleSubFolder => '19282021', # optional subfolder inside the patch zip user => hiera('oracle_os_user'), group => 'oinstall', downloadDir => hiera('oracle_download_dir'), ocmrf => true, require => Oradb::Opatch['19791420_db_patch'], puppetDownloadMntPoint => hiera('oracle_source'), } # with the help of the oracle and easy-type module of Bert Hajee ora_asm_diskgroup{ 'RECO@+ASM': ensure => 'present', au_size => '1', compat_asm => '11.2.0.0.0', compat_rdbms => '10.1.0.0.0', diskgroup_state => 'MOUNTED', disks => {'RECO_0000' => {'diskname' => 'RECO_0000', 'path' => '/nfs_client/asm_sda_nfs_b3'}, 'RECO_0001' => {'diskname' => 'RECO_0001', 'path' => '/nfs_client/asm_sda_nfs_b4'}}, redundancy_type => 'EXTERNAL', require => Oradb::Opatch['19791420_db_patch_2'], } # based on a template oradb::database{ 'oraDb': oracleBase => hiera('oracle_base_dir'), oracleHome => hiera('oracle_home_dir'), version => hiera('dbinstance_version'), user => hiera('oracle_os_user'), group => hiera('oracle_os_group'), downloadDir => hiera('oracle_download_dir'), action => 'create', dbName => hiera('oracle_database_name'), dbDomain => hiera('oracle_database_domain_name'), sysPassword => hiera('oracle_database_sys_password'), systemPassword => hiera('oracle_database_system_password'), template => 'dbtemplate_11gR2_asm', characterSet => "AL32UTF8", nationalCharacterSet => "UTF8", sampleSchema => 'FALSE', memoryPercentage => "40", memoryTotal => "800", databaseType => "MULTIPURPOSE", emConfiguration => "NONE", storageType => "ASM", asmSnmpPassword => 'Welcome01', asmDiskgroup => 'DATA', recoveryDiskgroup => 'RECO', recoveryAreaDestination => 'RECO', require => [Oradb::Opatch['19791420_db_patch_2'], Ora_asm_diskgroup['RECO@+ASM'],], } # or not based on a template oradb::database{ 'oraDb': oracleBase => hiera('oracle_base_dir'), oracleHome => hiera('oracle_home_dir'), version => hiera('dbinstance_version'), user => hiera('oracle_os_user'), group => hiera('oracle_os_group'), downloadDir => hiera('oracle_download_dir'), action => 'create', dbName => hiera('oracle_database_name'), dbDomain => hiera('oracle_database_domain_name'), sysPassword => hiera('oracle_database_sys_password'), systemPassword => hiera('oracle_database_system_password'), characterSet => "AL32UTF8", nationalCharacterSet => "UTF8", sampleSchema => 'FALSE', memoryPercentage => "40", memoryTotal => "800", databaseType => "MULTIPURPOSE", emConfiguration => "NONE", storageType => "ASM", asmSnmpPassword => 'Welcome01', asmDiskgroup => 'DATA', recoveryAreaDestination => 'DATA', require => Oradb::Opatch['19791420_db_patch_2'], } ## Oracle Database Client oradb::client{ '12.1.0.1_Linux-x86-64': version => '12.1.0.1', file => 'linuxamd64_12c_client.zip', oracleBase => '/oracle', oracleHome => '/oracle/product/12.1/client', user => 'oracle', group => 'dba', group_install => 'oinstall', downloadDir => '/install', remoteFile => true, puppetDownloadMntPoint => "puppet:///modules/oradb/", logoutput => true, } or oradb::client{ '11.2.0.1_Linux-x86-64': version => '11.2.0.1', file => 'linux.x64_11gR2_client.zip', oracleBase => '/oracle', oracleHome => '/oracle/product/11.2/client', user => 'oracle', group => 'dba', group_install => 'oinstall', downloadDir => '/install', remoteFile => false, puppetDownloadMntPoint => "/software", logoutput => true, } ## Enteprise Mananager oradb::installem{ 'em12104': version => '12.1.0.4', file => 'em12104_linux64', oracle_base_dir => '/oracle', oracle_home_dir => '/oracle/product/12.1/em', agent_base_dir => '/oracle/product/12.1/agent', software_library_dir => '/oracle/product/12.1/swlib', weblogic_user => 'weblogic', weblogic_password => 'Welcome01', database_hostname => 'emdb.example.com', database_listener_port => 1521, database_service_sid_name => 'emrepos.example.com', database_sys_password => 'Welcome01', sysman_password => 'Welcome01', agent_registration_password => 'Welcome01', deployment_size => 'SMALL', user => 'oracle', group => 'oinstall', download_dir => '/install', zip_extract => true, puppet_download_mnt_point => '/software', remote_file => false, log_output => true, } oradb::installem_agent{ 'em12104_agent': version => '12.1.0.4', source => 'https://10.10.10.25:7802/em/install/getAgentImage', install_type => 'agentPull', install_platform => 'Linux x86-64', oracle_base_dir => '/oracle', agent_base_dir => '/oracle/product/12.1/agent', agent_instance_home_dir => '/oracle/product/12.1/agent/agent_inst', sysman_user => 'sysman', sysman_password => 'Welcome01', agent_registration_password => 'Welcome01', agent_port => 1830, oms_host => '10.10.10.25', oms_port => 7802, em_upload_port => 4903, user => 'oracle', group => 'dba', download_dir => '/var/tmp/install', log_output => true, } oradb::installem_agent{ 'em12104_agent2': version => '12.1.0.4', source => '/var/tmp/install/agent.zip', install_type => 'agentDeploy', oracle_base_dir => '/oracle', agent_base_dir => '/oracle/product/12.1/agent2', agent_instance_home_dir => '/oracle/product/12.1/agent2/agent_inst', agent_registration_password => 'Welcome01', agent_port => 1832, oms_host => '10.10.10.25', em_upload_port => 4903, user => 'oracle', group => 'dba', download_dir => '/var/tmp/install', log_output => true, } ## Database configuration In combination with the oracle puppet module from hajee you can create/change a database init parameter, tablespace,role or an oracle user ora_init_param{'SPFILE/processes@soarepos': ensure => 'present', value => '1000', } ora_init_param{'SPFILE/job_queue_processes@soarepos': ensure => present, value => '4', } db_control{'soarepos restart': ensure => 'running', #running|start|abort|stop instance_name => hiera('oracle_database_name'), oracle_product_home_dir => hiera('oracle_home_dir'), os_user => hiera('oracle_os_user'), refreshonly => true, subscribe => [Ora_init_param['SPFILE/processes@soarepos'], Ora_init_param['SPFILE/job_queue_processes@soarepos'],], } ora_tablespace {'JMS_TS@soarepos': ensure => present, datafile => 'jms_ts.dbf', size => 100M, logging => yes, autoextend => on, next => 100M, max_size => 1G, extent_management => local, segment_space_management => auto, } ora_role {'APPS@soarepos': ensure => present, } ora_user{'JMS@soarepos': ensure => present, temporary_tablespace => temp, default_tablespace => 'JMS_TS', password => 'jms', require => [Ora_tablespace['JMS_TS@soarepos'], Ora_role['APPS@soarepos']], grants => ['SELECT ANY TABLE', 'CONNECT', 'CREATE TABLE', 'CREATE TRIGGER','APPS'], quotas => { "JMS_TS" => 'unlimited' }, } ## Oracle GoldenGate 12.1.2 and 11.2.1 $groups = ['oinstall','dba'] group { $groups : ensure => present, before => User['ggate'], } user { 'ggate' : ensure => present, gid => 'dba', groups => $groups, shell => '/bin/bash', password => '$1$DSJ51vh6$4XzzwyIOk6Bi/54kglGk3.', home => "/home/ggate", comment => "This user ggate was created by Puppet", managehome => true, } oradb::goldengate{ 'ggate12.1.2': version => '12.1.2', file => '121200_fbo_ggs_Linux_x64_shiphome.zip', databaseType => 'Oracle', databaseVersion => 'ORA11g', databaseHome => '/oracle/product/12.1/db', oracleBase => '/oracle', goldengateHome => "/oracle/product/12.1/ggate", managerPort => 16000, user => 'ggate', group => 'dba', group_install => 'oinstall', downloadDir => '/install', puppetDownloadMntPoint => hiera('oracle_source'), require => User['ggate'], } file { "/oracle/product/11.2.1" : ensure => directory, recurse => false, replace => false, mode => '0775', owner => 'ggate', group => 'dba', require => Oradb::Goldengate['ggate12.1.2'], } oradb::goldengate{ 'ggate11.2.1': version => '11.2.1', file => 'ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip', tarFile => 'fbo_ggs_Linux_x64_ora11g_64bit.tar', goldengateHome => "/oracle/product/11.2.1/ggate", user => 'ggate', group => 'dba', downloadDir => '/install', puppetDownloadMntPoint => hiera('oracle_source'), require => File["/oracle/product/11.2.1"], } oradb::goldengate{ 'ggate11.2.1_java': version => '11.2.1', file => 'V38714-01.zip', tarFile => 'ggs_Adapters_Linux_x64.tar', goldengateHome => "/oracle/product/11.2.1/ggate_java", user => 'ggate', group => 'dba', group_install => 'oinstall', downloadDir => '/install', puppetDownloadMntPoint => hiera('oracle_source'), require => File["/oracle/product/11.2.1"], } ## Oracle SOA Suite Repository Creation Utility (RCU) product = - soasuite - webcenter - all RCU examples soa suite repository oradb::rcu{'DEV_PS6': rcuFile => 'ofm_rcu_linux_11.1.1.7.0_32_disk1_1of1.zip', product => 'soasuite', version => '11.1.1.7', oracleHome => '/oracle/product/11.2/db', user => 'oracle', group => 'dba', downloadDir => '/install', action => 'create', dbServer => 'dbagent1.alfa.local:1521', dbService => 'test.oracle.com', sysPassword => 'Welcome01', schemaPrefix => 'DEV', reposPassword => 'Welcome02', } webcenter repository with a fixed temp tablespace oradb::rcu{'DEV2_PS6': rcuFile => 'ofm_rcu_linux_11.1.1.7.0_32_disk1_1of1.zip', product => 'webcenter', version => '11.1.1.7', oracleHome => '/oracle/product/11.2/db', user => 'oracle', group => 'dba', downloadDir => '/install', action => 'create', dbServer => 'dbagent1.alfa.local:1521', dbService => 'test.oracle.com', sysPassword => 'Welcome01', schemaPrefix => 'DEV', tempTablespace => 'TEMP', reposPassword => 'Welcome02', } delete a repository oradb::rcu{'Delete_DEV3_PS5': rcuFile => 'ofm_rcu_linux_11.1.1.6.0_disk1_1of1.zip', product => 'soasuite', version => '11.1.1.6', oracleHome => '/oracle/product/11.2/db', user => 'oracle', group => 'dba', downloadDir => '/install', action => 'delete', dbServer => 'dbagent1.alfa.local:1521', dbService => 'test.oracle.com', sysPassword => 'Welcome01', schemaPrefix => 'DEV3', reposPassword => 'Welcome02', } OIM, OAM repository, OIM needs an Oracle Enterprise Edition database oradb::rcu{'DEV_1112': rcuFile => 'V37476-01.zip', product => 'oim', version => '11.1.2.1', oracleHome => '/oracle/product/11.2/db', user => 'oracle', group => 'dba', downloadDir => '/data/install', action => 'create', dbServer => 'oimdb.alfa.local:1521', dbService => 'oim.oracle.com', sysPassword => hiera('database_test_sys_password'), schemaPrefix => 'DEV', reposPassword => hiera('database_test_rcu_dev_password'), puppetDownloadMntPoint => $puppetDownloadMntPoint, logoutput => true, require => Oradb::Dbactions['start oimDb'], } ## Solaris 10 kernel, ulimits and required packages exec { "create /cdrom/unnamed_cdrom": command => "/usr/bin/mkdir -p /cdrom/unnamed_cdrom", creates => "/cdrom/unnamed_cdrom", } mount { "/cdrom/unnamed_cdrom": device => "/dev/dsk/c0t1d0s2", fstype => "hsfs", ensure => "mounted", options => "ro", atboot => true, remounts => false, require => Exec["create /cdrom/unnamed_cdrom"], } $install = [ 'SUNWarc','SUNWbtool','SUNWcsl', 'SUNWdtrc','SUNWeu8os','SUNWhea', 'SUNWi1cs', 'SUNWi15cs', 'SUNWlibC','SUNWlibm','SUNWlibms', 'SUNWsprot','SUNWpool','SUNWpoolr', 'SUNWtoo','SUNWxwfnt' ] package { $install: ensure => present, adminfile => "/vagrant/pkgadd_response", source => "/cdrom/unnamed_cdrom/Solaris_10/Product/", require => [Exec["create /cdrom/unnamed_cdrom"], Mount["/cdrom/unnamed_cdrom"] ], } package { 'SUNWi1of': ensure => present, adminfile => "/vagrant/pkgadd_response", source => "/cdrom/unnamed_cdrom/Solaris_10/Product/", require => Package[$install], } # pkginfo -i SUNWarc SUNWbtool SUNWhea SUNWlibC SUNWlibm SUNWlibms SUNWsprot SUNWtoo SUNWi1of SUNWi1cs SUNWi15cs SUNWxwfnt SUNWcsl SUNWdtrc # pkgadd -d /cdrom/unnamed_cdrom/Solaris_10/Product/ -r response -a response SUNWarc SUNWbtool SUNWhea SUNWlibC SUNWlibm SUNWlibms SUNWsprot SUNWtoo SUNWi1of SUNWi1cs SUNWi15cs SUNWxwfnt SUNWcsl SUNWdtrc $all_groups = ['oinstall','dba' ,'oper'] group { $all_groups : ensure => present, } user { 'oracle' : ensure => present, uid => 500, gid => 'oinstall', groups => ['oinstall','dba','oper'], shell => '/bin/bash', password => '$1$DSJ51vh6$4XzzwyIOk6Bi/54kglGk3.', home => "/home/oracle", comment => "This user oracle was created by Puppet", require => Group[$all_groups], managehome => true, } $execPath = "/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:" exec { "projadd max-shm-memory": command => "projadd -p 102 -c 'ORADB' -U oracle -G dba -K 'project.max-shm-memory=(privileged,4G,deny)' ORADB", require => [ User["oracle"], Package['SUNWi1of'], Package[$install], ], unless => "projects -l | grep -c ORADB", path => $execPath, } exec { "projmod max-sem-ids": command => "projmod -s -K 'project.max-sem-ids=(privileged,100,deny)' ORADB", subscribe => Exec["projadd max-shm-memory"], require => Exec["projadd max-shm-memory"], refreshonly => true, path => $execPath, } exec { "projmod max-shm-ids": command => "projmod -s -K 'project.max-shm-ids=(privileged,100,deny)' ORADB", require => Exec["projmod max-sem-ids"], subscribe => Exec["projmod max-sem-ids"], refreshonly => true, path => $execPath, } exec { "projmod max-sem-nsems": command => "projmod -s -K 'process.max-sem-nsems=(privileged,256,deny)' ORADB", require => Exec["projmod max-shm-ids"], subscribe => Exec["projmod max-shm-ids"], refreshonly => true, path => $execPath, } exec { "projmod max-file-descriptor": command => "projmod -s -K 'process.max-file-descriptor=(basic,65536,deny)' ORADB", require => Exec["projmod max-sem-nsems"], subscribe => Exec["projmod max-sem-nsems"], refreshonly => true, path => $execPath, } exec { "projmod max-stack-size": command => "projmod -s -K 'process.max-stack-size=(privileged,32MB,deny)' ORADB", require => Exec["projmod max-file-descriptor"], subscribe => Exec["projmod max-file-descriptor"], refreshonly => true, path => $execPath, } exec { "usermod oracle": command => "usermod -K project=ORADB oracle", require => Exec["projmod max-stack-size"], subscribe => Exec["projmod max-stack-size"], refreshonly => true, path => $execPath, } exec { "ndd 1": command => "ndd -set /dev/tcp tcp_smallest_anon_port 9000", require => Exec["usermod oracle"], path => $execPath, } exec { "ndd 2": command => "ndd -set /dev/tcp tcp_largest_anon_port 65500", require => Exec["ndd 1"], path => $execPath, } exec { "ndd 3": command => "ndd -set /dev/udp udp_smallest_anon_port 9000", require => Exec["ndd 2"], path => $execPath, } exec { "ndd 4": command => "ndd -set /dev/udp udp_largest_anon_port 65500", require => Exec["ndd 3"], path => $execPath, } exec { "ulimit -S": command => "ulimit -S -n 4096", require => Exec["ndd 4"], path => $execPath, } exec { "ulimit -H": command => "ulimit -H -n 65536", require => Exec["ulimit -S"], path => $execPath, } ## Solaris 11 kernel, ulimits and required packages package { ['shell/ksh', 'developer/assembler']: ensure => present, } $install = "pkg:/group/prerequisite/oracle/oracle-rdbms-server-12-1-preinstall" package { $install: ensure => present, } $groups = ['oinstall','dba' ,'oper' ] group { $groups : ensure => present, } user { 'oracle' : ensure => present, uid => 500, gid => 'dba', groups => $groups, shell => '/bin/bash', password => '$1$DSJ51vh6$4XzzwyIOk6Bi/54kglGk3.', home => "/export/home/oracle", comment => "This user oracle was created by Puppet", require => Group[$groups], managehome => true, } $execPath = "/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:" exec { "projadd group.dba": command => "projadd -U oracle -G dba -p 104 group.dba", require => User["oracle"], unless => "projects -l | grep -c group.dba", path => $execPath, } exec { "usermod oracle": command => "usermod -K project=group.dba oracle", require => [User["oracle"],Exec["projadd group.dba"],], path => $execPath, } exec { "projmod max-shm-memory": command => "projmod -sK 'project.max-shm-memory=(privileged,4G,deny)' group.dba", require => [User["oracle"],Exec["projadd group.dba"],], path => $execPath, } exec { "projmod max-sem-ids": command => "projmod -sK 'project.max-sem-ids=(privileged,100,deny)' group.dba", require => Exec["projadd group.dba"], path => $execPath, } exec { "projmod max-shm-ids": command => "projmod -s -K 'project.max-shm-ids=(privileged,100,deny)' group.dba", require => Exec["projadd group.dba"], path => $execPath, } exec { "projmod max-sem-nsems": command => "projmod -sK 'process.max-sem-nsems=(privileged,256,deny)' group.dba", require => Exec["projadd group.dba"], path => $execPath, } exec { "projmod max-file-descriptor": command => "projmod -sK 'process.max-file-descriptor=(basic,65536,deny)' group.dba", require => Exec["projadd group.dba"], path => $execPath, } exec { "projmod max-stack-size": command => "projmod -sK 'process.max-stack-size=(privileged,32MB,deny)' group.dba", require => Exec["projadd group.dba"], path => $execPath, } exec { "ipadm smallest_anon_port tcp": command => "ipadm set-prop -p smallest_anon_port=9000 tcp", path => $execPath, } exec { "ipadm smallest_anon_port udp": command => "ipadm set-prop -p smallest_anon_port=9000 udp", path => $execPath, } exec { "ipadm largest_anon_port tcp": command => "ipadm set-prop -p largest_anon_port=65500 tcp", path => $execPath, } exec { "ipadm largest_anon_port udp": command => "ipadm set-prop -p largest_anon_port=65500 udp", path => $execPath, } exec { "ulimit -S": command => "ulimit -S -n 4096", path => $execPath, } exec { "ulimit -H": command => "ulimit -H -n 65536", path => $execPath, }
biemond/puppet
modules/oradb/README.md
Markdown
gpl-3.0
62,824
/** * Marlin 3D Printer Firmware * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * 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/>. * */ #pragma once #include <Arduino.h> class Servo { static const int MIN_ANGLE = 0, MAX_ANGLE = 180, MIN_PULSE_WIDTH = 544, // Shortest pulse sent to a servo MAX_PULSE_WIDTH = 2400, // Longest pulse sent to a servo TAU_MSEC = 20, TAU_USEC = (TAU_MSEC * 1000), MAX_COMPARE = ((1 << 16) - 1), // 65535 CHANNEL_MAX_NUM = 16; public: Servo(); int8_t attach(const int pin); // attach the given pin to the next free channel, set pinMode, return channel number (-1 on fail) void detach(); void write(int degrees); // set angle void move(const int degrees); // attach the servo, then move to value int read(); // returns current pulse width as an angle between 0 and 180 degrees private: static int channel_next_free; int channel; int pin; int degrees; };
petrzjunior/Marlin
Marlin/src/HAL/HAL_ESP32/Servo.h
C
gpl-3.0
1,800
/* gl-client Client library for the URI-based RESTful service for the gl project. Copyright (c) 2012-2015 National Marrow Donor Program (NMDP) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 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; with out even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser 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. > http://www.fsf.org/licensing/licenses/lgpl.html > http://www.opensource.org/licenses/lgpl-license.php */ /** * Caching support for gl client implementations. */ package org.nmdp.gl.client.cache;
epearson-nmdp/genotype-list
gl-client/src/main/java/org/nmdp/gl/client/cache/package-info.java
Java
gpl-3.0
1,106
<html><body>Pet Manager Cooper:<br> All I asked was for you to make the path safer for my sister... And you've actually brought the Map!<br> Mr. Galladucci was very pleased! You shall be well-rewarded for this, my friend.<br> This is the most valuable thing I own. It was originally reserved for those of the upper class... But this one is yours!<br> <font color="LEVEL">It's a coupon you can exchange for a pet. </font>It won't be easy to raise. You must be very careful! </body></html>
karolusw/l2j
game/data/scripts/quests/Q00043_HelpTheSister/30829-09.html
HTML
gpl-3.0
487
/* This file is part of LilyPond, the GNU music typesetter. Copyright (C) 1997--2015 Han-Wen Nienhuys <hanwen@xs4all.nl> LilyPond 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. LilyPond 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 LilyPond. If not, see <http://www.gnu.org/licenses/>. */ #include "timing-translator.hh" #include "warn.hh" #include "translator-group.hh" #include "global-context.hh" #include "moment.hh" void Timing_translator::stop_translation_timestep () { Global_context *global = get_global_context (); if (to_boolean (get_property ("timing")) && !to_boolean (get_property ("skipBars"))) { Moment barleft = (measure_length () - measure_position (context ())); Moment now = now_mom (); if (barleft > Moment (0)) { Moment nextmom = now + barleft; nextmom.grace_part_ = Rational (0); global->add_moment_to_process (nextmom); } } } void Timing_translator::initialize () { Context *timing = Context::unsmob (scm_call_2 (ly_lily_module_constant ("ly:context-find"), context ()->self_scm (), ly_symbol2scm ("Timing"))); if (timing != context ()) { context ()->add_alias (ly_symbol2scm ("Timing")); if (!timing) { programming_error ("Can't find Timing context template"); timing = context (); } } SCM barnumber = timing->get_property ("currentBarNumber"); if (!scm_is_integer (barnumber)) barnumber = scm_from_int (1); context ()->set_property ("currentBarNumber", barnumber); context ()->set_property ("internalBarNumber", barnumber); SCM timeSignatureFraction = timing->get_property ("timeSignatureFraction"); if (!scm_is_pair (timeSignatureFraction)) { programming_error ("missing timeSignatureFraction"); timeSignatureFraction = scm_cons (scm_from_int (4), scm_from_int (4)); } context ()->set_property ("timeSignatureFraction", timeSignatureFraction); SCM measureLength = timing->get_property ("measureLength"); if (!Moment::is_smob (measureLength)) { measureLength = Moment (ly_scm2rational (scm_divide (scm_car (timeSignatureFraction), scm_cdr (timeSignatureFraction)))).smobbed_copy (); } context ()->set_property ("measureLength", measureLength); /* Do not init measurePosition; this should be done from global context. */ SCM timeSignatureSettings = timing->get_property ("timeSignatureSettings"); if (!scm_is_pair (timeSignatureSettings)) { programming_error ("missing timeSignatureSettings"); // A memoized constant is not the prettiest thing as a fallback // since it does not track changes of the variable. However, // this is still better than nothing, and we already complained // via a programming_error timeSignatureSettings = ly_lily_module_constant ("default-time-signature-settings"); } context ()->set_property ("timeSignatureSettings", timeSignatureSettings); SCM beamExceptions = timing->get_property ("beamExceptions"); if (!scm_is_pair (beamExceptions)) { beamExceptions = scm_call_2 (ly_lily_module_constant ("beam-exceptions"), timeSignatureFraction, timeSignatureSettings); } context ()->set_property ("beamExceptions", beamExceptions); SCM baseMoment = timing->get_property ("baseMoment"); if (!Moment::is_smob (baseMoment)) { baseMoment = Moment (ly_scm2rational (scm_call_2 (ly_lily_module_constant ("base-length"), timeSignatureFraction, timeSignatureSettings))).smobbed_copy (); } context ()->set_property ("baseMoment", baseMoment); SCM beatStructure = timing->get_property ("beatStructure"); if (!scm_is_pair (beatStructure)) { beatStructure = scm_call_3 (ly_lily_module_constant ("beat-structure"), ly_rational2scm (Moment::unsmob (baseMoment)->main_part_), timeSignatureFraction, timeSignatureSettings); } context ()->set_property ("beatStructure", beatStructure); context ()->set_property ("beamHalfMeasure", timing->get_property ("beamHalfMeasure")); context ()->set_property ("autoBeaming", timing->get_property ("autoBeaming")); } Rational Timing_translator::measure_length () const { SCM l = get_property ("measureLength"); if (Moment::is_smob (l)) return Moment::unsmob (l)->main_part_; else return Rational (1); } Timing_translator::Timing_translator () { } void Timing_translator::start_translation_timestep () { Global_context *global = get_global_context (); Moment now = global->now_mom (); Moment dt = now - global->previous_moment (); if (dt < Moment (0)) { programming_error ("moving backwards in time"); dt = 0; } else if (dt.main_part_.is_infinity ()) { programming_error ("moving infinitely to future"); dt = 0; } if (!dt.to_bool ()) return; Moment measposp; SCM s = get_property ("measurePosition"); if (Moment::is_smob (s)) measposp = *Moment::unsmob (s); else { measposp = now; } int current_barnumber = robust_scm2int (get_property ("currentBarNumber"), 0); int internal_barnumber = robust_scm2int (get_property ("internalBarNumber"), 0); SCM cad = get_property ("timing"); bool c = to_boolean (cad); if (c) { Rational len = measure_length (); measposp += dt; while (measposp.main_part_ >= len) { measposp.main_part_ -= len; current_barnumber++; internal_barnumber++; } } // Because "timing" can be switched on and off asynchronously with // graces, measurePosition might get into strange settings of // grace_part_. It does not actually make sense to have it diverge // from the main timing. Updating the grace part outside of the // actual check for "timing" looks strange and will lead to changes // of grace_part_ even when timing is off. However, when timing is // switched back on again, this will generally happen in an override // that does _not_ in itself advance current_moment. So the whole // timing advance logic will only get triggered while "timing" is // still of. Maybe we should keep measurePosition.grace_part_ // constantly at zero anyway? measposp.grace_part_ = now.grace_part_; context ()->set_property ("currentBarNumber", scm_from_int (current_barnumber)); context ()->set_property ("internalBarNumber", scm_from_int (internal_barnumber)); context ()->set_property ("measurePosition", measposp.smobbed_copy ()); } #include "translator.icc" ADD_TRANSLATOR (Timing_translator, /* doc */ "This engraver adds the alias @code{Timing} to its containing" " context. Responsible for synchronizing timing information" " from staves. Normally in @code{Score}. In order to create" " polyrhythmic music, this engraver should be removed from" " @code{Score} and placed in @code{Staff}.", /* create */ "", /* read */ "baseMoment " "currentBarNumber " "internalBarNumber " "measureLength " "measurePosition " "timeSignatureFraction ", /* write */ "baseMoment " "currentBarNumber " "internalBarNumber " "measureLength " "measurePosition " "timeSignatureFraction " );
CarlSorensen/lilypond-standards
lily/timing-translator.cc
C++
gpl-3.0
8,362
/** * @preserve This file is part of Mibew Messenger project. * http://mibew.org * * Copyright (c) 2005-2013 Mibew Messenger Community * License: http://mibew.org/license.php */ var FrameUtils = { getDocument: function(frm) { if (frm.contentDocument) { return frm.contentDocument; } else if (frm.contentWindow) { return frm.contentWindow.document; } else if (frm.document) { return frm.document; } else { return null; } }, initFrame: function(frm) { var doc = this.getDocument(frm); doc.open(); doc.write("<html><head>"); doc.write("<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\""+Chat.cssfile+"\">"); doc.write("</head><body bgcolor=\"#FFFFFF\" text=#000000\" link=\"#C28400\" vlink=\"#C28400\" alink=\"#C28400\">"); doc.write("<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr><td valign=\"top\" class=\"message\" id=\"content\"></td></tr></table><a id=\"bottom\" name=\"bottom\"></a>"); doc.write("</body></html>"); doc.close(); frm.onload = function() { if( frm.myHtml ) { FrameUtils.getDocument(frm).getElementById('content').innerHTML += frm.myHtml; FrameUtils.scrollDown(frm); } }; }, insertIntoFrame: function(frm, htmlcontent) { var vcontent = this.getDocument(frm).getElementById('content'); if( vcontent == null ) { if( !frm.myHtml ) frm.myHtml = ""; frm.myHtml += htmlcontent; } else { vcontent.innerHTML += htmlcontent; } }, scrollDown: function(frm) { var vbottom = this.getDocument(frm).getElementById('bottom'); if( myAgent == 'opera' ) { try { frm.contentWindow.scrollTo(0,this.getDocument(frm).getElementById('content').clientHeight); } catch(e) {} } if( vbottom ) { vbottom.scrollIntoView(false); } } }; Ajax.ChatThreadUpdater = Class.create(); Class.inherit( Ajax.ChatThreadUpdater, Ajax.Base, { initialize: function(_options) { this.setOptions(_options); this._options.onComplete = this.requestComplete.bind(this); this._options.onException = this.handleException.bind(this); this._options.onTimeout = this.handleTimeout.bind(this); this._options.timeout = 5000; this.updater = {}; this.frequency = (this._options.frequency || 2); this.lastupdate = 0; this.cansend = true; this.skipNextsound = true; this.focused = true; this.ownThread = this._options.message != null; FrameUtils.initFrame(this._options.container); if( this._options.message ) { this._options.message.onkeydown = this.handleKeyDown.bind(this); this._options.message.onfocus = (function() { this.focused = true; }).bind(this); this._options.message.onblur = (function() { this.focused = false; }).bind(this) } this.update(); }, handleException: function(_request, ex) { this.setStatus("offline, reconnecting"); this.stopUpdate(); this.timer = setTimeout(this.update.bind(this), 1000); }, handleTimeout: function(_request) { this.setStatus("timeout, reconnecting"); this.stopUpdate(); this.timer = setTimeout(this.update.bind(this), 1000); }, updateOptions: function(act) { this._options.parameters = 'act='+act+'&thread=' + (this._options.threadid || 0) + '&token=' + (this._options.token || 0)+ '&lastid=' + (this._options.lastid || 0); if( this._options.user ) this._options.parameters += "&user=true"; if( act == 'refresh' && this._options.message && this._options.message.value != '' ) this._options.parameters += "&typed=1"; }, enableInput: function(val) { if( this._options.message ) this._options.message.disabled = !val; }, stopUpdate: function() { this.enableInput(true); if( this.updater._options ) this.updater._options.onComplete = undefined; clearTimeout(this.timer); }, update: function() { this.updateOptions("refresh"); this.updater = new Ajax.Request(this._options.servl, this._options); }, requestComplete: function(_response) { try { this.enableInput(true); this.cansend = true; var xmlRoot = Ajax.getXml(_response); if( xmlRoot && xmlRoot.tagName == 'thread' ) { this.updateContent( xmlRoot ); } else { this.handleError(_response, xmlRoot, 'refresh messages failed'); } } catch (e) { } this.skipNextsound = false; this.timer = setTimeout(this.update.bind(this), this.frequency * 1000); }, postMessage: function(msg) { if( msg == "" || !this.cansend) { return; } this.cansend = false; this.stopUpdate(); this.skipNextsound = true; this.updateOptions("post"); var postOptions = {}.extend(this._options); postOptions.parameters += "&message=" + encodeURIComponent(msg); postOptions.onComplete = (function(presponse) { this.requestComplete( presponse ); if( this._options.message ) { this._options.message.value = ''; this._options.message.focus(); } }).bind(this); if( myRealAgent != 'opera' ) this.enableInput(false); this.updater = new Ajax.Request(this._options.servl, postOptions); }, changeName: function(newname) { this.skipNextsound = true; new Ajax.Request(this._options.servl, {parameters:'act=rename&thread=' + (this._options.threadid || 0) + '&token=' + (this._options.token || 0) + '&name=' + encodeURIComponent(newname)}); }, onThreadClosed: function(_response) { var xmlRoot = Ajax.getXml(_response); if( xmlRoot && xmlRoot.tagName == 'closed' ) { setTimeout('window.close()', 2000); } else { this.handleError(_response, xmlRoot, 'cannot close'); } }, closeThread: function() { var _params = 'act=close&thread=' + (this._options.threadid || 0) + '&token=' + (this._options.token || 0); if( this._options.user ) _params += "&user=true"; new Ajax.Request(this._options.servl, {parameters:_params, onComplete: this.onThreadClosed.bind(this)}); }, processMessage: function(_target, message) { var destHtml = NodeUtils.getNodeText(message); FrameUtils.insertIntoFrame(_target, destHtml ); }, showTyping: function(istyping) { if( $("typingdiv") ) { $("typingdiv").style.display=istyping ? 'inline' : 'none'; } }, setupAvatar: function(avatar) { var imageLink = NodeUtils.getNodeText(avatar); if( this._options.avatar && this._options.user ) { this._options.avatar.innerHTML = imageLink != "" ? "<img src=\""+Chat.mibewRoot+"/images/free.gif\" width=\"7\" height=\"1\" border=\"0\" alt=\"\" /><img src=\"" +imageLink+ "\" border=\"0\" alt=\"\"/>" : ""; } }, updateContent: function(xmlRoot) { var haveMessage = false; var result_div = this._options.container; var _lastid = NodeUtils.getAttrValue(xmlRoot, "lastid"); if( _lastid ) { this._options.lastid = _lastid; } var typing = NodeUtils.getAttrValue(xmlRoot, "typing"); if( typing ) { this.showTyping(typing == '1'); } var canpost = NodeUtils.getAttrValue(xmlRoot, "canpost"); if( canpost ) { if( canpost == '1' && !this.ownThread || this.ownThread && canpost != '1' ) { window.location.href = window.location.href; } } for( var i = 0; i < xmlRoot.childNodes.length; i++ ) { var node = xmlRoot.childNodes[i]; if( node.tagName == 'message' ) { haveMessage = true; this.processMessage(result_div, node); } else if( node.tagName == 'avatar' ) { this.setupAvatar(node); } } if(window.location.search.indexOf('trace=on')>=0) { var val = "updated"; if(this.lastupdate > 0) { var seconds = ((new Date()).getTime() - this.lastupdate)/1000; val = val + ", " + seconds + " secs"; if(seconds > 10) { alert(val); } } this.lastupdate = (new Date()).getTime(); this.setStatus(val); } else { this.clearStatus(); } if( haveMessage ) { FrameUtils.scrollDown(this._options.container); if(!this.skipNextsound) { var tsound = $('soundimg'); if(tsound == null || tsound.className.match(new RegExp("\\bisound\\b")) ) { playSound(Chat.mibewRoot+'/sounds/new_message.wav'); } } if( !this.focused ) { window.focus(); } } }, isSendkey: function(ctrlpressed, key) { return ((key==13 && (ctrlpressed || this._options.ignorectrl)) || (key==10)); }, handleKeyDown: function(k) { if( k ){ ctrl=k.ctrlKey;k=k.which; } else { k=event.keyCode;ctrl=event.ctrlKey; } if( this._options.message && this.isSendkey(ctrl, k) ) { var mmsg = this._options.message.value; if( this._options.ignorectrl ) { mmsg = mmsg.replace(/[\r\n]+$/,''); } this.postMessage( mmsg ); return false; } return true; }, handleError: function(_response, xmlRoot, _action) { if( xmlRoot && xmlRoot.tagName == 'error' ) { this.setStatus(NodeUtils.getNodeValue(xmlRoot,"descr")); } else { this.setStatus("reconnecting"); } }, showStatusDiv: function(k) { if( $("engineinfo") ) { $("engineinfo").style.display='inline'; $("engineinfo").innerHTML = k; } }, setStatus: function(k) { if( this.statusTimeout ) clearTimeout(this.statusTimeout); this.showStatusDiv(k); this.statusTimeout = setTimeout(this.clearStatus.bind(this), 4000); }, clearStatus: function() { $("engineinfo").style.display='none'; } }); var Chat = { threadUpdater : {}, applyName: function() { if ( !$('uname').value.match(/^\s*$/) ) { Chat.threadUpdater.changeName($('uname').value); $('changename1').style.display='none'; $('changename2').style.display='inline'; $('unamelink').innerHTML = htmlescape($('uname').value); } }, showNameField: function() { $('changename1').style.display='inline'; $('changename2').style.display='none'; } }; Behaviour.register({ '#postmessage a' : function(el) { el.onclick = function() { var message = $('msgwnd'); if( message ) Chat.threadUpdater.postMessage(message.value); }; }, 'select#predefined' : function(el) { el.onchange = function() { var message = $('msgwnd'); if(this.selectedIndex!=0) { message.value = this.options[this.selectedIndex].innerText || this.options[this.selectedIndex].innerHTML; } this.selectedIndex = 0; message.focus(); }; }, 'div#changename2 a' : function(el) { el.onclick = function() { Chat.showNameField(); return false; }; }, 'div#changename1 a' : function(el) { el.onclick = function() { Chat.applyName(); return false; }; }, 'div#changename1 input#uname' : function(el) { el.onkeydown = function(e) { var ev = e || event; if( ev.keyCode == 13 ) { Chat.applyName(); } }; }, 'a#refresh' : function(el) { el.onclick = function() { Chat.threadUpdater.stopUpdate(); Chat.threadUpdater.update(); }; }, 'a#togglesound' : function(el) { el.onclick = function() { var tsound = $('soundimg'); if(!tsound) { return; } if(tsound.className.match(new RegExp("\\bisound\\b"))) { tsound.className = "tplimage inosound"; } else { tsound.className = "tplimage isound"; } var messagePane = $('msgwnd'); if(messagePane) messagePane.focus(); }; }, 'a.closethread' : function(el) { el.onclick = function() { Chat.threadUpdater.closeThread(); }; } }); EventHelper.register(window, 'onload', function(){ Chat.mibewRoot = threadParams.wroot; Chat.cssfile = threadParams.cssfile; Chat.threadUpdater = new Ajax.ChatThreadUpdater(({ignorectrl:-1,container:myRealAgent=='safari'?self.frames[0]:$("chatwnd"),avatar:$("avatarwnd"),message:$("msgwnd")}).extend( threadParams || {} )); });
mrtuvn/WRU_Final_Project
js/source/chat.js
JavaScript
gpl-3.0
11,369
all: help help: echo help babel: babel lib/ -d src/ test: babel mocha -R spec eslint: DEBUG="eslint:cli-engine" eslint . watch: watchd lib/**.js test/**.js package.json -c 'bake babel' release: version push publish version: standard-version -m '%s' push: git push origin master --tags publish: npm publish
marcusfaccion/unnamed_app
vendor/bower/mapbox-directions.js/node_modules/template-copy/Makefile
Makefile
gpl-3.0
324
using System; using System.Collections.Generic; using System.Linq; namespace PeerCastStation.UI { [PeerCastStation.Core.PecaSettings] public class UISettings { private BroadcastInfo[] broadcastHistory = new BroadcastInfo[0]; public BroadcastInfo[] BroadcastHistory { get { return broadcastHistory; } set { broadcastHistory = value; } } public Dictionary<string, Dictionary<string, string>> UserConfig { get; set; } public UISettings() { this.UserConfig = new Dictionary<string,Dictionary<string,string>>(); } public void AddBroadcastHistory(BroadcastInfo info) { if (FindBroadcastHistroryItem(info)!=null) return; var fav = BroadcastHistory.Where(i => i.Favorite); var others = BroadcastHistory.Where(i => !i.Favorite); BroadcastHistory = fav.Concat(Enumerable.Repeat(info, 1).Concat(others.Take(19))).ToArray(); } public BroadcastInfo FindBroadcastHistroryItem(BroadcastInfo info) { return BroadcastHistory.FirstOrDefault(i => i.StreamType == info.StreamType && i.StreamUrl == info.StreamUrl && i.Bitrate == info.Bitrate && i.ContentType == info.ContentType && i.YellowPage == info.YellowPage && i.ChannelName == info.ChannelName && i.Genre == info.Genre && i.Description == info.Description && i.Comment == info.Comment && i.ContactUrl == info.ContactUrl && i.TrackTitle == info.TrackTitle && i.TrackAlbum == info.TrackAlbum && i.TrackArtist == info.TrackArtist && i.TrackGenre == info.TrackGenre && i.TrackUrl == info.TrackUrl); } } [PeerCastStation.Core.PecaSettings] public class BroadcastInfo { public string StreamType { get; set; } public string StreamUrl { get; set; } public int Bitrate { get; set; } public string ContentType { get; set; } public string YellowPage { get; set; } public string ChannelName { get; set; } public string Genre { get; set; } public string Description { get; set; } public string Comment { get; set; } public string ContactUrl { get; set; } public string TrackTitle { get; set; } public string TrackAlbum { get; set; } public string TrackArtist { get; set; } public string TrackGenre { get; set; } public string TrackUrl { get; set; } public bool Favorite { get; set; } } }
deepbeepsleep/peercaststation
PeerCastStation/PeerCastStation.UI/UISettings.cs
C#
gpl-3.0
2,530
var namespace_py_a_r_t_o_s_1_1_g_u_i_1_1_annotation_dialog = [ [ "AnnotationDialog", "class_py_a_r_t_o_s_1_1_g_u_i_1_1_annotation_dialog_1_1_annotation_dialog.html", "class_py_a_r_t_o_s_1_1_g_u_i_1_1_annotation_dialog_1_1_annotation_dialog" ] ];
cvjena/artos
docs/PyARTOS/html/namespace_py_a_r_t_o_s_1_1_g_u_i_1_1_annotation_dialog.js
JavaScript
gpl-3.0
249
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A // PARTICULAR PURPOSE. // // Copyright (c) Microsoft Corporation. All rights reserved #ifndef __FILTERBASE_H__ #define __FILTERBASE_H__ #include <strsafe.h> #include <propkey.h> #include <propsys.h> #include <filter.h> #include <filterr.h> class CChunkValue { public: CChunkValue() : m_fIsValid(false), m_pszValue(NULL) { PropVariantInit(&m_propVariant); Clear(); } ~CChunkValue() { Clear(); }; void Clear() { m_fIsValid = false; ZeroMemory(&m_chunk, sizeof(m_chunk)); PropVariantClear(&m_propVariant); CoTaskMemFree(m_pszValue); m_pszValue = NULL; } BOOL IsValid() { return m_fIsValid; } HRESULT GetValue(PROPVARIANT **ppPropVariant) { if (!ppPropVariant) return E_INVALIDARG; *ppPropVariant = NULL; PROPVARIANT *pPropVariant = static_cast<PROPVARIANT*>(CoTaskMemAlloc(sizeof(PROPVARIANT))); if (!pPropVariant) return E_OUTOFMEMORY; HRESULT hr = PropVariantCopy(pPropVariant, &m_propVariant); if (SUCCEEDED(hr)) *ppPropVariant = pPropVariant; else CoTaskMemFree(pPropVariant); return hr; } PWSTR GetString() { return m_pszValue; }; HRESULT CopyChunk(STAT_CHUNK *pStatChunk) { if (!pStatChunk) return E_INVALIDARG; *pStatChunk = m_chunk; return S_OK; } CHUNKSTATE GetChunkType() { return m_chunk.flags; } HRESULT SetTextValue(REFPROPERTYKEY pkey, PCWSTR pszValue, CHUNKSTATE chunkType = CHUNK_VALUE, LCID locale = 0, DWORD cwcLenSource = 0, DWORD cwcStartSource = 0, CHUNK_BREAKTYPE chunkBreakType = CHUNK_NO_BREAK) { if (pszValue == NULL) return E_INVALIDARG; HRESULT hr = SetChunk(pkey, chunkType, locale, cwcLenSource, cwcStartSource, chunkBreakType); if (FAILED(hr)) return hr; size_t cch = wcslen(pszValue) + 1; PWSTR pszCoTaskValue = static_cast<PWSTR>(CoTaskMemAlloc(cch * sizeof(WCHAR))); if (!pszCoTaskValue) return E_OUTOFMEMORY; StringCchCopyW(pszCoTaskValue, cch, pszValue); m_fIsValid = true; if (chunkType == CHUNK_VALUE) { m_propVariant.vt = VT_LPWSTR; m_propVariant.pwszVal = pszCoTaskValue; } else { m_pszValue = pszCoTaskValue; } return hr; }; HRESULT SetFileTimeValue(REFPROPERTYKEY pkey, FILETIME dtVal, CHUNKSTATE chunkType = CHUNK_VALUE, LCID locale = 0, DWORD cwcLenSource = 0, DWORD cwcStartSource = 0, CHUNK_BREAKTYPE chunkBreakType = CHUNK_NO_BREAK) { HRESULT hr = SetChunk(pkey, chunkType, locale, cwcLenSource, cwcStartSource, chunkBreakType); if (FAILED(hr)) return hr; m_propVariant.vt = VT_FILETIME; m_propVariant.filetime = dtVal; m_fIsValid = true; return hr; }; protected: HRESULT SetChunk(REFPROPERTYKEY pkey, CHUNKSTATE chunkType=CHUNK_VALUE, LCID locale=0, DWORD cwcLenSource=0, DWORD cwcStartSource=0, CHUNK_BREAKTYPE chunkBreakType=CHUNK_NO_BREAK); private: bool m_fIsValid; STAT_CHUNK m_chunk; PROPVARIANT m_propVariant; PWSTR m_pszValue; }; inline HRESULT CChunkValue::SetChunk(REFPROPERTYKEY pkey, CHUNKSTATE chunkType/*=CHUNK_VALUE*/, LCID locale /*=0*/, DWORD cwcLenSource /*=0*/, DWORD cwcStartSource /*=0*/, CHUNK_BREAKTYPE chunkBreakType /*= CHUNK_NO_BREAK */) { Clear(); m_chunk.attribute.psProperty.ulKind = PRSPEC_PROPID; m_chunk.attribute.psProperty.propid = pkey.pid; m_chunk.attribute.guidPropSet = pkey.fmtid; m_chunk.flags = chunkType; m_chunk.locale = locale; m_chunk.cwcLenSource = cwcLenSource; m_chunk.cwcStartSource = cwcStartSource; m_chunk.breakType = chunkBreakType; return S_OK; } class CFilterBase : public IFilter, public IInitializeWithStream, public IPersistStream, public IPersistFile { public: // OnInit() is called when the IFilter is initialized (at the end of IFilter::Init) virtual HRESULT OnInit() = 0; // When GetNextChunkValue() is called you should fill in the ChunkValue by calling SetXXXValue() with the property. // example: chunkValue.SetTextValue(PKYE_ItemName, L"foo bar"); // return FILTER_E_END_OF_CHUNKS when there are no more chunks virtual HRESULT GetNextChunkValue(CChunkValue &chunkValue) = 0; protected: inline DWORD GetChunkId() const { return m_dwChunkId; } public: CFilterBase(long *plRefCount) : m_lRef(1), m_plModuleRef(plRefCount), m_dwChunkId(0), m_iText(0), m_pStream(NULL) { InterlockedIncrement(m_plModuleRef); } virtual ~CFilterBase() { if (m_pStream) m_pStream->Release(); InterlockedDecrement(m_plModuleRef); } // IUnknown IFACEMETHODIMP QueryInterface(REFIID riid, void **ppv) { static const QITAB qit[] = { QITABENT(CFilterBase, IPersistStream), QITABENT(CFilterBase, IPersistFile), QITABENTMULTI(CFilterBase, IPersist, IPersistStream), QITABENT(CFilterBase, IInitializeWithStream), QITABENT(CFilterBase, IFilter), { 0 } }; return QISearch(this, qit, riid, ppv); } IFACEMETHODIMP_(ULONG) AddRef() { return InterlockedIncrement(&m_lRef); } IFACEMETHODIMP_(ULONG) Release() { long cRef = InterlockedDecrement(&m_lRef); if (cRef == 0) delete this; return cRef; } // IFilter IFACEMETHODIMP Init(ULONG grfFlags, ULONG cAttributes, const FULLPROPSPEC *aAttributes, ULONG *pFlags) { if (cAttributes > 0 && !aAttributes) return E_INVALIDARG; m_dwChunkId = 0; m_iText = 0; m_currentChunk.Clear(); if (pFlags) *pFlags = 0; return OnInit(); } IFACEMETHODIMP GetChunk(STAT_CHUNK *pStat) { m_currentChunk.Clear(); HRESULT hr = GetNextChunkValue(m_currentChunk); if (hr != S_OK) return hr; if (!m_currentChunk.IsValid()) return E_INVALIDARG; m_iText = 0; m_currentChunk.CopyChunk(pStat); pStat->idChunk = ++m_dwChunkId; if (pStat->flags == CHUNK_TEXT) pStat->idChunkSource = pStat->idChunk; return hr; } IFACEMETHODIMP GetText(ULONG *pcwcBuffer, WCHAR *awcBuffer) { if (!pcwcBuffer || !*pcwcBuffer) return E_INVALIDARG; if (!m_currentChunk.IsValid()) return FILTER_E_NO_MORE_TEXT; if (m_currentChunk.GetChunkType() != CHUNK_TEXT) return FILTER_E_NO_TEXT; ULONG cchTotal = static_cast<ULONG>(wcslen(m_currentChunk.GetString())); ULONG cchLeft = cchTotal - m_iText; ULONG cchToCopy = min(*pcwcBuffer - 1, cchLeft); if (!cchToCopy) return FILTER_E_NO_MORE_TEXT; PCWSTR psz = m_currentChunk.GetString() + m_iText; StringCchCopyNW(awcBuffer, *pcwcBuffer, psz, cchToCopy); awcBuffer[cchToCopy] = '\0'; *pcwcBuffer = cchToCopy; m_iText += cchToCopy; cchLeft -= cchToCopy; if (!cchLeft) return FILTER_S_LAST_TEXT; return S_OK; } IFACEMETHODIMP GetValue(PROPVARIANT **ppPropValue) { if (!m_currentChunk.IsValid()) return FILTER_E_NO_MORE_VALUES; if (m_currentChunk.GetChunkType() != CHUNK_VALUE) return FILTER_E_NO_VALUES; if (ppPropValue == NULL) return E_INVALIDARG; HRESULT hr = m_currentChunk.GetValue(ppPropValue); m_currentChunk.Clear(); return hr; } IFACEMETHODIMP BindRegion(FILTERREGION, REFIID, void **) { return E_NOTIMPL; } // IInitializeWithStream IFACEMETHODIMP Initialize(IStream *pStm, DWORD grfMode) { if (m_pStream) m_pStream->Release(); m_pStream = pStm; if (!m_pStream) return E_INVALIDARG; m_pStream->AddRef(); return S_OK; }; // IPersistStream IFACEMETHODIMP IsDirty(void) { return E_NOTIMPL; } IFACEMETHODIMP Load(IStream *pStm) { return Initialize(pStm, 0); } IFACEMETHODIMP Save(IStream *pStm, BOOL fClearDirty) { return E_NOTIMPL; } IFACEMETHODIMP GetSizeMax(ULARGE_INTEGER *pcbSize) { return E_NOTIMPL; } // IPersistFile (for compatibility with older Windows Desktop Search versions and ifilttst.exe) IFACEMETHODIMP Load(LPCOLESTR pszFileName, DWORD dwMode) { HANDLE hFile = CreateFileW(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) return E_INVALIDARG; DWORD size = GetFileSize(hFile, NULL), read; HGLOBAL data = GlobalAlloc(GMEM_MOVEABLE, size); if (!data) return E_OUTOFMEMORY; BOOL ok = ReadFile(hFile, GlobalLock(data), size, &read, NULL); GlobalUnlock(data); CloseHandle(hFile); IStream *pStm; if (!ok || FAILED(CreateStreamOnHGlobal(data, TRUE, &pStm))) { GlobalFree(data); return E_FAIL; } HRESULT res = Initialize(pStm, 0); pStm->Release(); return res; } IFACEMETHODIMP Save(LPCOLESTR pszFileName, BOOL bRemember) { return E_NOTIMPL; } IFACEMETHODIMP SaveCompleted(LPCOLESTR pszFileName) { return E_NOTIMPL; } IFACEMETHODIMP GetCurFile(LPOLESTR *ppszFileName) { return E_NOTIMPL; } protected: IStream* m_pStream; private: long m_lRef, * m_plModuleRef; DWORD m_dwChunkId; DWORD m_iText; CChunkValue m_currentChunk; }; #endif
ofanoyi/sumatrapdf
src/ifilter/FilterBase.h
C
gpl-3.0
10,334
/* FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. This file is part of the FreeRTOS distribution. FreeRTOS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (version 2) as published by the Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception. *************************************************************************** >>! NOTE: The modification to the GPL is included to allow you to !<< >>! distribute a combined work that includes FreeRTOS without being !<< >>! obliged to provide the source code for proprietary components !<< >>! outside of the FreeRTOS kernel. !<< *************************************************************************** FreeRTOS 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. Full license text is available on the following link: http://www.freertos.org/a00114.html *************************************************************************** * * * FreeRTOS provides completely free yet professionally developed, * * robust, strictly quality controlled, supported, and cross * * platform software that is more than just the market leader, it * * is the industry's de facto standard. * * * * Help yourself get started quickly while simultaneously helping * * to support the FreeRTOS project by purchasing a FreeRTOS * * tutorial book, reference manual, or both: * * http://www.FreeRTOS.org/Documentation * * * *************************************************************************** http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading the FAQ page "My application does not run, what could be wrong?". Have you defined configASSERT()? http://www.FreeRTOS.org/support - In return for receiving this top quality embedded software for free we request you assist our global community by participating in the support forum. http://www.FreeRTOS.org/training - Investing in training allows your team to be as productive as possible as early as possible. Now you can receive FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers Ltd, and the world's leading authority on the world's leading RTOS. http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, including FreeRTOS+Trace - an indispensable productivity tool, a DOS compatible FAT file system, and our tiny thread aware UDP/IP stack. http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS licenses offer ticketed support, indemnification and commercial middleware. http://www.SafeRTOS.com - High Integrity Systems also provide a safety engineered and independently SIL3 certified version for use in safety and mission critical applications that require provable dependability. 1 tab == 4 spaces! */ #include <stdio.h> #include <conio.h> #include <string.h> /* Scheduler include files. */ #include "FreeRTOS.h" #include "task.h" /* Demo program include files. */ #include "fileio.h" void vDisplayMessage( const char * const pcMessageToPrint ) { #ifdef USE_STDIO taskENTER_CRITICAL(); printf( "%s", pcMessageToPrint ); fflush( stdout ); taskEXIT_CRITICAL(); #else /* Stop warnings. */ ( void ) pcMessageToPrint; #endif } /*-----------------------------------------------------------*/ void vWriteMessageToDisk( const char * const pcMessage ) { #ifdef USE_STDIO const char * const pcFileName = "c:\\RTOSlog.txt"; const char * const pcSeparator = "\r\n-----------------------\r\n"; FILE *pf; taskENTER_CRITICAL(); { pf = fopen( pcFileName, "a" ); if( pf != NULL ) { fwrite( pcMessage, strlen( pcMessage ), ( unsigned short ) 1, pf ); fwrite( pcSeparator, strlen( pcSeparator ), ( unsigned short ) 1, pf ); fclose( pf ); } } taskEXIT_CRITICAL(); #else /* Stop warnings. */ ( void ) pcMessage; #endif /*USE_STDIO*/ } /*-----------------------------------------------------------*/ void vWriteBufferToDisk( const char * const pcBuffer, unsigned long ulBufferLength ) { #ifdef USE_STDIO const char * const pcFileName = "c:\\trace.bin"; FILE *pf; taskENTER_CRITICAL(); { pf = fopen( pcFileName, "wb" ); if( pf ) { fwrite( pcBuffer, ( size_t ) ulBufferLength, ( unsigned short ) 1, pf ); fclose( pf ); } } taskEXIT_CRITICAL(); #else /* Stop warnings. */ ( void ) pcBuffer; ( void ) ulBufferLength; #endif /*USE_STDIO*/ }
RobsonRojas/frertos-udemy
Keil-FreeRTOS-Sample-Project/Keil-FreeRTOS/FreeRTOSv9.0.0/FreeRTOS/Demo/Flshlite/FileIO/fileIO.c
C
gpl-3.0
5,414
# ##### BEGIN GPL LICENSE BLOCK ##### # # 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 2 # 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, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### import bpy from bpy.props import IntProperty, FloatProperty import mathutils from sverchok.node_tree import SverchCustomTreeNode from sverchok.data_structure import updateNode # documentation/blender_python_api_2_70_release/mathutils.kdtree.html class SvKDTreeEdgesNodeMK2(bpy.types.Node, SverchCustomTreeNode): bl_idname = 'SvKDTreeEdgesNodeMK2' bl_label = 'KDT Closest Edges MK2' bl_icon = 'OUTLINER_OB_EMPTY' mindist = FloatProperty( name='mindist', description='Minimum dist', min=0.0, default=0.1, update=updateNode) maxdist = FloatProperty( name='maxdist', description='Maximum dist', min=0.0, default=2.0, update=updateNode) maxNum = IntProperty( name='maxNum', description='max edge count', default=4, min=1, update=updateNode) skip = IntProperty( name='skip', description='skip first n', default=0, min=0, update=updateNode) def sv_init(self, context): self.inputs.new('VerticesSocket', 'Verts') self.inputs.new('StringsSocket', 'mindist').prop_name = 'mindist' self.inputs.new('StringsSocket', 'maxdist').prop_name = 'maxdist' self.inputs.new('StringsSocket', 'maxNum').prop_name = 'maxNum' self.inputs.new('StringsSocket', 'skip').prop_name = 'skip' self.outputs.new('StringsSocket', 'Edges') def process(self): inputs = self.inputs outputs = self.outputs try: verts = inputs['Verts'].sv_get()[0] linked = outputs['Edges'].is_linked except (IndexError, KeyError) as e: return optional_sockets = [ ['mindist', self.mindist, float], ['maxdist', self.maxdist, float], ['maxNum', self.maxNum, int], ['skip', self.skip, int]] socket_inputs = [] for s, s_default_value, dtype in optional_sockets: if s in inputs and inputs[s].is_linked: sock_input = dtype(inputs[s].sv_get()[0][0]) else: sock_input = s_default_value socket_inputs.append(sock_input) self.run_kdtree(verts, socket_inputs) def run_kdtree(self, verts, socket_inputs): mindist, maxdist, maxNum, skip = socket_inputs # make kdtree # documentation/blender_python_api_2_78_release/mathutils.kdtree.html size = len(verts) kd = mathutils.kdtree.KDTree(size) for i, xyz in enumerate(verts): kd.insert(xyz, i) kd.balance() # set minimum values maxNum = max(maxNum, 1) skip = max(skip, 0) # makes edges e = set() for i, vtx in enumerate(verts): num_edges = 0 # this always returns closest first followed by next closest, etc. # co index dist for edge_idx, (_, index, dist) in enumerate(kd.find_range(vtx, abs(maxdist))): if skip > 0: if edge_idx < skip: continue if (dist <= abs(mindist)) or (i == index): continue edge = tuple(sorted([i, index])) if not edge in e: e.add(edge) num_edges += 1 if num_edges == maxNum: break self.outputs['Edges'].sv_set([list(e)]) def register(): bpy.utils.register_class(SvKDTreeEdgesNodeMK2) def unregister(): bpy.utils.unregister_class(SvKDTreeEdgesNodeMK2)
elfnor/sverchok
nodes/analyzer/kd_tree_edges_mk2.py
Python
gpl-3.0
4,347
#include "extras.h" #include "emu.h" #include "mem.h" #include "defines.h" /* A few needed locations */ #define CE_kbdScanCode 0xD00587 #define CE_kbdFlags 0xD00080 #define CE_kbdSCR (1 << 3) #define CE_kbdKey 0xD0058C #define CE_keyExtend 0xD0058E #define CE_graphFlags2 0xD0009F #define CE_keyReady (1 << 5) bool EMSCRIPTEN_KEEPALIVE sendCSC(uint8_t csc) { uint8_t flags = mem_peek_byte(CE_kbdFlags); if (flags & CE_kbdSCR) { return false; } mem_poke_byte(CE_kbdScanCode, csc); mem_poke_byte(CE_kbdFlags, flags | CE_kbdSCR); return true; } bool EMSCRIPTEN_KEEPALIVE sendKey(uint16_t key) { uint8_t flags = mem_peek_byte(CE_graphFlags2); if (flags & CE_keyReady) { return false; } if (key < 0x100) { key <<= 8; } mem_poke_byte(CE_kbdKey, (uint8_t)(key >> 8)); mem_poke_byte(CE_keyExtend, (uint8_t)(key & 0xFF)); mem_poke_byte(CE_graphFlags2, flags | CE_keyReady); return true; } bool EMSCRIPTEN_KEEPALIVE sendLetterKeyPress(char letter) { uint16_t key; if (letter >= '0' && letter <= '9') { key = 0x8E + letter - '0'; } else if (letter >= 'A' && letter <= 'Z') { key = 0x9A + letter - 'A'; } else if (letter == 'Z' + 1 || letter == '@') { /* [ or @ for theta (caller should replace it) */ key = 0xCC; } else { return true; } return sendKey(key); }
MateoConLechuga/CEmu
core/extras.c
C
gpl-3.0
1,422
<div class="directus-module-header">Item Messsages</div>
SMC-digital/directus
app/templates/modules/messages/module-messages.html
HTML
gpl-3.0
56
""" UserProfileDB class is a front-end to the User Profile Database """ __RCSID__ = "$Id$" import types import os import sys import hashlib from DIRAC import S_OK, S_ERROR, gLogger, gConfig from DIRAC.Core.Utilities import Time from DIRAC.ConfigurationSystem.Client.Helpers import Registry from DIRAC.Core.Base.DB import DB class UserProfileDB( DB ): """ UserProfileDB class is a front-end to the User Profile Database """ tableDict = { 'up_Users' : { 'Fields' : { 'Id' : 'INTEGER AUTO_INCREMENT NOT NULL', 'UserName' : 'VARCHAR(32) NOT NULL', 'LastAccess' : 'DATETIME', }, 'PrimaryKey' : 'Id', 'UniqueIndexes' : { 'U' : [ 'UserName' ] }, 'Engine': 'InnoDB', }, 'up_Groups': { 'Fields' : { 'Id' : 'INTEGER AUTO_INCREMENT NOT NULL', 'UserGroup' : 'VARCHAR(32) NOT NULL', 'LastAccess' : 'DATETIME', }, 'PrimaryKey' : 'Id', 'UniqueIndexes' : { 'G' : [ 'UserGroup' ] }, 'Engine': 'InnoDB', }, 'up_VOs': { 'Fields' : { 'Id' : 'INTEGER AUTO_INCREMENT NOT NULL', 'VO' : 'VARCHAR(32) NOT NULL', 'LastAccess' : 'DATETIME', }, 'PrimaryKey' : 'Id', 'UniqueIndexes' : { 'VO' : [ 'VO' ] }, 'Engine': 'InnoDB', }, 'up_ProfilesData': { 'Fields' : { 'UserId' : 'INTEGER', 'GroupId' : 'INTEGER', 'VOId' : 'INTEGER', 'Profile' : 'VARCHAR(255) NOT NULL', 'VarName' : 'VARCHAR(255) NOT NULL', 'Data' : 'BLOB', 'ReadAccess' : 'VARCHAR(10) DEFAULT "USER"', 'PublishAccess' : 'VARCHAR(10) DEFAULT "USER"', }, 'PrimaryKey' : [ 'UserId', 'GroupId', 'Profile', 'VarName' ], 'Indexes' : { 'ProfileKey' : [ 'UserId', 'GroupId', 'Profile' ], 'UserKey' : [ 'UserId' ] , }, 'Engine': 'InnoDB', }, 'up_HashTags': { 'Fields' : { 'UserId' : 'INTEGER', 'GroupId' : 'INTEGER', 'VOId' : 'INTEGER', 'HashTag' : 'VARCHAR(32) NOT NULL', 'TagName' : 'VARCHAR(255) NOT NULL', 'LastAccess' : 'DATETIME', }, 'PrimaryKey' : [ 'UserId', 'GroupId', 'TagName' ], 'Indexes' : { 'HashKey' : [ 'UserId', 'HashTag' ] }, 'Engine': 'InnoDB', }, } def __init__( self ): """ Constructor """ self.__permValues = [ 'USER', 'GROUP', 'VO', 'ALL' ] self.__permAttrs = [ 'ReadAccess', 'PublishAccess' ] DB.__init__( self, 'UserProfileDB', 'Framework/UserProfileDB', 10 ) retVal = self.__initializeDB() if not retVal[ 'OK' ]: raise Exception( "Can't create tables: %s" % retVal[ 'Message' ] ) def _checkTable( self ): """ Make sure the tables are created """ return self.__initializeDB() def __initializeDB( self ): """ Create the tables """ retVal = self._query( "show tables" ) if not retVal[ 'OK' ]: return retVal tablesInDB = [ t[0] for t in retVal[ 'Value' ] ] tablesD = {} if 'up_Users' not in tablesInDB: tablesD[ 'up_Users' ] = self.tableDict['up_Users'] if 'up_Groups' not in tablesInDB: tablesD[ 'up_Groups' ] = self.tableDict[ 'up_Groups'] if 'up_VOs' not in tablesInDB: tablesD[ 'up_VOs' ] = self.tableDict['up_VOs'] if 'up_ProfilesData' not in tablesInDB: tablesD[ 'up_ProfilesData' ] = self.tableDict['up_ProfilesData'] if 'up_HashTags' not in tablesInDB: tablesD[ 'up_HashTags' ] = self.tableDict['up_HashTags'] return self._createTables( tablesD ) def __getUserId( self, userName, insertIfMissing = True ): return self.__getObjId( userName, 'UserName', 'up_Users', insertIfMissing ) def __getGroupId( self, groupName, insertIfMissing = True ): return self.__getObjId( groupName, 'UserGroup', 'up_Groups', insertIfMissing ) def __getVOId( self, voName, insertIfMissing = True ): return self.__getObjId( voName, 'VO', 'up_VOs', insertIfMissing ) def __getObjId( self, objValue, varName, tableName, insertIfMissing = True ): result = self.getFields( tableName, ['Id'], { varName: objValue } ) if not result[ 'OK' ]: return result data = result[ 'Value' ] if len( data ) > 0: objId = data[0][0] self.updateFields( tableName, ['LastAccess'], ['UTC_TIMESTAMP()'], { 'Id': objId } ) return S_OK( objId ) if not insertIfMissing: return S_ERROR( "No entry %s for %s defined in the DB" % ( objValue, varName ) ) result = self.insertFields( tableName, [ varName, 'LastAccess' ], [ objValue, 'UTC_TIMESTAMP()' ] ) if not result[ 'OK' ]: return result return S_OK( result[ 'lastRowId' ] ) def getUserGroupIds( self, userName, userGroup, insertIfMissing = True ): result = self.__getUserId( userName, insertIfMissing ) if not result[ 'OK' ]: return result userId = result[ 'Value' ] result = self.__getGroupId( userGroup, insertIfMissing ) if not result[ 'OK' ]: return result groupId = result[ 'Value' ] userVO = Registry.getVOForGroup( userGroup ) if not userVO: userVO = "undefined" result = self.__getVOId( userVO, insertIfMissing ) if not result[ 'OK' ]: return result voId = result[ 'Value' ] return S_OK( ( userId, groupId, voId ) ) def deleteUserProfile( self, userName, userGroup = False ): """ Delete the profiles for a user """ result = self.__getUserId( userName ) if not result[ 'OK' ]: return result userId = result[ 'Value' ] condDict = { 'UserId': userId } if userGroup: result = self.__getGroupId( userGroup ) if not result[ 'OK' ]: return result groupId = result[ 'Value' ] condDict['GroupId'] = groupId result = self.deleteEntries( 'up_ProfilesData', condDict ) if not result[ 'OK' ] or not userGroup: return result return self.deleteEntries( 'up_Users', { 'Id': userId } ) def __webProfileUserDataCond( self, userIds, sqlProfileName = False, sqlVarName = False ): condSQL = [ '`up_ProfilesData`.UserId=%s' % userIds[0], '`up_ProfilesData`.GroupId=%s' % userIds[1], '`up_ProfilesData`.VOId=%s' % userIds[2] ] if sqlProfileName: condSQL.append( '`up_ProfilesData`.Profile=%s' % sqlProfileName ) if sqlVarName: condSQL.append( '`up_ProfilesData`.VarName=%s' % sqlVarName ) return " AND ".join( condSQL ) def __webProfileReadAccessDataCond( self, userIds, ownerIds, sqlProfileName, sqlVarName = False, match = False ): permCondSQL = [] sqlCond = [] if match: sqlCond.append( '`up_ProfilesData`.UserId = %s AND `up_ProfilesData`.GroupId = %s' % ( ownerIds[0], ownerIds[1] ) ) else: permCondSQL.append( '`up_ProfilesData`.UserId = %s AND `up_ProfilesData`.GroupId = %s' % ( ownerIds[0], ownerIds[1] ) ) permCondSQL.append( '`up_ProfilesData`.GroupId=%s AND `up_ProfilesData`.ReadAccess="GROUP"' % userIds[1] ) permCondSQL.append( '`up_ProfilesData`.VOId=%s AND `up_ProfilesData`.ReadAccess="VO"' % userIds[2] ) permCondSQL.append( '`up_ProfilesData`.ReadAccess="ALL"' ) sqlCond.append( '`up_ProfilesData`.Profile = %s' % sqlProfileName ) if sqlVarName: sqlCond.append( "`up_ProfilesData`.VarName = %s" % ( sqlVarName ) ) #Perms sqlCond.append( "( ( %s ) )" % " ) OR ( ".join( permCondSQL ) ) return " AND ".join( sqlCond ) def __parsePerms( self, perms, addMissing = True ): normPerms = {} for pName in self.__permAttrs: if not perms or pName not in perms: if addMissing: normPerms[ pName ] = self.__permValues[0] continue else: permVal = perms[ pName ].upper() for nV in self.__permValues: if nV == permVal: normPerms[ pName ] = nV break if pName not in normPerms and addMissing: normPerms[ pName ] = self.__permValues[0] return normPerms def retrieveVarById( self, userIds, ownerIds, profileName, varName ): """ Get a data entry for a profile """ result = self._escapeString( profileName ) if not result[ 'OK' ]: return result sqlProfileName = result[ 'Value' ] result = self._escapeString( varName ) if not result[ 'OK' ]: return result sqlVarName = result[ 'Value' ] sqlCond = self.__webProfileReadAccessDataCond( userIds, ownerIds, sqlProfileName, sqlVarName, True ) #when we retrieve the user profile we have to take into account the user. selectSQL = "SELECT data FROM `up_ProfilesData` WHERE %s" % sqlCond result = self._query( selectSQL ) if not result[ 'OK' ]: return result data = result[ 'Value' ] if len( data ) > 0: return S_OK( data[0][0] ) return S_ERROR( "No data for userIds %s profileName %s varName %s" % ( userIds, profileName, varName ) ) def retrieveAllUserVarsById( self, userIds, profileName ): """ Get a data entry for a profile """ result = self._escapeString( profileName ) if not result[ 'OK' ]: return result sqlProfileName = result[ 'Value' ] sqlCond = self.__webProfileUserDataCond( userIds, sqlProfileName ) selectSQL = "SELECT varName, data FROM `up_ProfilesData` WHERE %s" % sqlCond result = self._query( selectSQL ) if not result[ 'OK' ]: return result data = result[ 'Value' ] return S_OK( dict( data ) ) def retrieveUserProfilesById( self, userIds ): """ Get all profiles and data for a user """ sqlCond = self.__webProfileUserDataCond( userIds ) selectSQL = "SELECT Profile, varName, data FROM `up_ProfilesData` WHERE %s" % sqlCond result = self._query( selectSQL ) if not result[ 'OK' ]: return result data = result[ 'Value' ] dataDict = {} for row in data: if row[0] not in dataDict: dataDict[ row[0] ] = {} dataDict[ row[0] ][ row[1] ] = row[2 ] return S_OK( dataDict ) def retrieveVarPermsById( self, userIds, ownerIds, profileName, varName ): """ Get a data entry for a profile """ result = self._escapeString( profileName ) if not result[ 'OK' ]: return result sqlProfileName = result[ 'Value' ] result = self._escapeString( varName ) if not result[ 'OK' ]: return result sqlVarName = result[ 'Value' ] sqlCond = self.__webProfileReadAccessDataCond( userIds, ownerIds, sqlProfileName, sqlVarName ) selectSQL = "SELECT %s FROM `up_ProfilesData` WHERE %s" % ( ", ".join( self.__permAttrs ), sqlCond ) result = self._query( selectSQL ) if not result[ 'OK' ]: return result data = result[ 'Value' ] if len( data ) > 0: permDict = {} for i in range( len( self.__permAttrs ) ): permDict[ self.__permAttrs[ i ] ] = data[0][i] return S_OK( permDict ) return S_ERROR( "No data for userIds %s profileName %s varName %s" % ( userIds, profileName, varName ) ) def deleteVarByUserId( self, userIds, profileName, varName ): """ Remove a data entry for a profile """ result = self._escapeString( profileName ) if not result[ 'OK' ]: return result sqlProfileName = result[ 'Value' ] result = self._escapeString( varName ) if not result[ 'OK' ]: return result sqlVarName = result[ 'Value' ] sqlCond = self.__webProfileUserDataCond( userIds, sqlProfileName, sqlVarName ) selectSQL = "DELETE FROM `up_ProfilesData` WHERE %s" % sqlCond return self._update( selectSQL ) def storeVarByUserId( self, userIds, profileName, varName, data, perms ): """ Set a data entry for a profile """ sqlInsertValues = [] sqlInsertKeys = [] sqlInsertKeys.append( ( 'UserId', userIds[0] ) ) sqlInsertKeys.append( ( 'GroupId', userIds[1] ) ) sqlInsertKeys.append( ( 'VOId', userIds[2] ) ) result = self._escapeString( profileName ) if not result[ 'OK' ]: return result sqlProfileName = result[ 'Value' ] sqlInsertKeys.append( ( 'Profile', sqlProfileName ) ) result = self._escapeString( varName ) if not result[ 'OK' ]: return result sqlVarName = result[ 'Value' ] sqlInsertKeys.append( ( 'VarName', sqlVarName ) ) result = self._escapeString( data ) if not result[ 'OK' ]: return result sqlInsertValues.append( ( 'Data', result[ 'Value' ] ) ) normPerms = self.__parsePerms( perms ) for k in normPerms: sqlInsertValues.append( ( k, '"%s"' % normPerms[ k ] ) ) sqlInsert = sqlInsertKeys + sqlInsertValues insertSQL = "INSERT INTO `up_ProfilesData` ( %s ) VALUES ( %s )" % ( ", ".join( [ f[0] for f in sqlInsert ] ), ", ".join( [ str( f[1] ) for f in sqlInsert ] ) ) result = self._update( insertSQL ) if result[ 'OK' ]: return result #If error and not duplicate -> real error if result[ 'Message' ].find( "Duplicate entry" ) == -1: return result updateSQL = "UPDATE `up_ProfilesData` SET %s WHERE %s" % ( ", ".join( [ "%s=%s" % f for f in sqlInsertValues ] ), self.__webProfileUserDataCond( userIds, sqlProfileName, sqlVarName ) ) return self._update( updateSQL ) def setUserVarPermsById( self, userIds, profileName, varName, perms ): result = self._escapeString( profileName ) if not result[ 'OK' ]: return result sqlProfileName = result[ 'Value' ] result = self._escapeString( varName ) if not result[ 'OK' ]: return result sqlVarName = result[ 'Value' ] nPerms = self.__parsePerms( perms, False ) if not nPerms: return S_OK() sqlPerms = ",".join( [ "%s='%s'" % ( k, nPerms[k] ) for k in nPerms ] ) updateSql = "UPDATE `up_ProfilesData` SET %s WHERE %s" % ( sqlPerms, self.__webProfileUserDataCond( userIds, sqlProfileName, sqlVarName ) ) return self._update( updateSql ) def retrieveVar( self, userName, userGroup, ownerName, ownerGroup, profileName, varName ): """ Get a data entry for a profile """ result = self.getUserGroupIds( userName, userGroup ) if not result[ 'OK' ]: return result userIds = result[ 'Value' ] result = self.getUserGroupIds( ownerName, ownerGroup ) if not result[ 'OK' ]: return result ownerIds = result[ 'Value' ] return self.retrieveVarById( userIds, ownerIds, profileName, varName ) def retrieveUserProfiles( self, userName, userGroup ): """ Helper for getting data """ result = self.getUserGroupIds( userName, userGroup ) if not result[ 'OK' ]: return result userIds = result[ 'Value' ] return self.retrieveUserProfilesById( userIds ) def retrieveAllUserVars( self, userName, userGroup, profileName ): """ Helper for getting data """ result = self.getUserGroupIds( userName, userGroup ) if not result[ 'OK' ]: return result userIds = result[ 'Value' ] return self.retrieveAllUserVarsById( userIds, profileName ) def retrieveVarPerms( self, userName, userGroup, ownerName, ownerGroup, profileName, varName ): result = self.getUserGroupIds( userName, userGroup ) if not result[ 'OK' ]: return result userIds = result[ 'Value' ] result = self.getUserGroupIds( ownerName, ownerGroup, False ) if not result[ 'OK' ]: return result ownerIds = result[ 'Value' ] return self.retrieveVarPermsById( userIds, ownerIds, profileName, varName ) def setUserVarPerms( self, userName, userGroup, profileName, varName, perms ): result = self.getUserGroupIds( userName, userGroup ) if not result[ 'OK' ]: return result userIds = result[ 'Value' ] return self.setUserVarPermsById( userIds, profileName, varName, perms ) def storeVar( self, userName, userGroup, profileName, varName, data, perms = None ): """ Helper for setting data """ try: result = self.getUserGroupIds( userName, userGroup ) if not result[ 'OK' ]: return result userIds = result[ 'Value' ] return self.storeVarByUserId( userIds, profileName, varName, data, perms = perms ) finally: pass def deleteVar( self, userName, userGroup, profileName, varName ): """ Helper for deleting data """ try: result = self.getUserGroupIds( userName, userGroup ) if not result[ 'OK' ]: return result userIds = result[ 'Value' ] return self.deleteVarByUserId( userIds, profileName, varName ) finally: pass def __profilesCondGenerator( self, value, varType, initialValue = False ): if type( value ) in types.StringTypes: value = [ value ] ids = [] if initialValue: ids.append( initialValue ) for val in value: if varType == 'user': result = self.__getUserId( val, insertIfMissing = False ) elif varType == 'group': result = self.__getGroupId( val, insertIfMissing = False ) else: result = self.__getVOId( val, insertIfMissing = False ) if not result[ 'OK' ]: continue ids.append( result[ 'Value' ] ) if varType == 'user': fieldName = 'UserId' elif varType == 'group': fieldName = 'GroupId' else: fieldName = 'VOId' return "`up_ProfilesData`.%s in ( %s )" % ( fieldName, ", ".join( [ str( iD ) for iD in ids ] ) ) def listVarsById( self, userIds, profileName, filterDict = None ): result = self._escapeString( profileName ) if not result[ 'OK' ]: return result sqlProfileName = result[ 'Value' ] sqlCond = [ "`up_Users`.Id = `up_ProfilesData`.UserId", "`up_Groups`.Id = `up_ProfilesData`.GroupId", "`up_VOs`.Id = `up_ProfilesData`.VOId", self.__webProfileReadAccessDataCond( userIds, userIds, sqlProfileName ) ] if filterDict: fD = {} for k in filterDict: fD[ k.lower() ] = filterDict[ k ] filterDict = fD for k in ( 'user', 'group', 'vo' ): if k in filterDict: sqlCond.append( self.__profilesCondGenerator( filterDict[ k ], k ) ) sqlVars2Get = [ "`up_Users`.UserName", "`up_Groups`.UserGroup", "`up_VOs`.VO", "`up_ProfilesData`.VarName" ] sqlQuery = "SELECT %s FROM `up_Users`, `up_Groups`, `up_VOs`, `up_ProfilesData` WHERE %s" % ( ", ".join( sqlVars2Get ), " AND ".join( sqlCond ) ) return self._query( sqlQuery ) def listVars( self, userName, userGroup, profileName, filterDict = None ): result = self.getUserGroupIds( userName, userGroup ) if not result[ 'OK' ]: return result userIds = result[ 'Value' ] return self.listVarsById( userIds, profileName, filterDict ) def storeHashTagById( self, userIds, tagName, hashTag = False ): """ Set a data entry for a profile """ if not hashTag: hashTag = hashlib.md5() hashTag.update( "%s;%s;%s" % ( Time.dateTime(), userIds, tagName ) ) hashTag = hashTag.hexdigest() result = self.insertFields( 'up_HashTags', [ 'UserId', 'GroupId', 'VOId', 'TagName', 'HashTag' ], [ userIds[0], userIds[1], userIds[2], tagName, hashTag ] ) if result[ 'OK' ]: return S_OK( hashTag ) #If error and not duplicate -> real error if result[ 'Message' ].find( "Duplicate entry" ) == -1: return result result = self.updateFields( 'up_HashTags', ['HashTag'], [hashTag], { 'UserId': userIds[0], 'GroupId': userIds[1], 'VOId': userIds[2], 'TagName': tagName } ) if not result[ 'OK' ]: return result return S_OK( hashTag ) def retrieveHashTagById( self, userIds, hashTag ): """ Get a data entry for a profile """ result = self.getFields( 'up_HashTags', ['TagName'], { 'UserId': userIds[0], 'GroupId': userIds[1], 'VOId': userIds[2], 'HashTag': hashTag } ) if not result[ 'OK' ]: return result data = result[ 'Value' ] if len( data ) > 0: return S_OK( data[0][0] ) return S_ERROR( "No data for combo userId %s hashTag %s" % ( userIds, hashTag ) ) def retrieveAllHashTagsById( self, userIds ): """ Get a data entry for a profile """ result = self.getFields( 'up_HashTags', ['HashTag', 'TagName'], { 'UserId': userIds[0], 'GroupId': userIds[1], 'VOId': userIds[2] } ) if not result[ 'OK' ]: return result data = result[ 'Value' ] return S_OK( dict( data ) ) def storeHashTag( self, userName, userGroup, tagName, hashTag = False ): """ Helper for storing HASH """ try: result = self.getUserGroupIds( userName, userGroup ) if not result[ 'OK' ]: return result userIds = result[ 'Value' ] return self.storeHashTagById( userIds, tagName, hashTag ) finally: pass def retrieveHashTag( self, userName, userGroup, hashTag ): """ Helper for retrieving HASH """ try: result = self.getUserGroupIds( userName, userGroup ) if not result[ 'OK' ]: return result userIds = result[ 'Value' ] return self.retrieveHashTagById( userIds, hashTag ) finally: pass def retrieveAllHashTags( self, userName, userGroup ): """ Helper for retrieving HASH """ try: result = self.getUserGroupIds( userName, userGroup ) if not result[ 'OK' ]: return result userIds = result[ 'Value' ] return self.retrieveAllHashTagsById( userIds ) finally: pass def getUserProfileNames( self, permission ): """ it returns the available profile names by not taking account the permission: ReadAccess and PublishAccess """ result = None permissions = self.__parsePerms( permission, False ) if not permissions: return S_OK() condition = ",".join( [ "%s='%s'" % ( k, permissions[k] ) for k in permissions ] ) query = "SELECT distinct Profile from `up_ProfilesData` where %s" % condition retVal = self._query( query ) if retVal['OK']: result = S_OK( [i[0] for i in retVal['Value']] ) else: result = retVal return result def testUserProfileDB(): """ Some test cases """ # building up some fake CS values gConfig.setOptionValue( 'DIRAC/Setup', 'Test' ) gConfig.setOptionValue( '/DIRAC/Setups/Test/Framework', 'Test' ) host = '127.0.0.1' user = 'Dirac' pwd = 'Dirac' db = 'AccountingDB' gConfig.setOptionValue( '/Systems/Framework/Test/Databases/UserProfileDB/Host', host ) gConfig.setOptionValue( '/Systems/Framework/Test/Databases/UserProfileDB/DBName', db ) gConfig.setOptionValue( '/Systems/Framework/Test/Databases/UserProfileDB/User', user ) gConfig.setOptionValue( '/Systems/Framework/Test/Databases/UserProfileDB/Password', pwd ) db = UserProfileDB() assert db._connect()['OK'] userName = 'testUser' userGroup = 'testGroup' profileName = 'testProfile' varName = 'testVar' tagName = 'testTag' hashTag = '237cadc4af90277e9524e6386e264630' data = 'testData' perms = 'USER' try: if False: for tableName in db.tableDict.keys(): result = db._update( 'DROP TABLE `%s`' % tableName ) assert result['OK'] gLogger.info( '\n Creating Table\n' ) # Make sure it is there and it has been created for this test result = db._checkTable() assert result == {'OK': True, 'Value': None } result = db._checkTable() assert result == {'OK': True, 'Value': 0} gLogger.info( '\n Adding some data\n' ) result = db.storeVar( userName, userGroup, profileName, varName, data, perms ) assert result['OK'] assert result['Value'] == 1 gLogger.info( '\n Some queries\n' ) result = db.getUserGroupIds( userName, userGroup ) assert result['OK'] assert result['Value'] == ( 1, 1, 1 ) result = db.listVars( userName, userGroup, profileName ) assert result['OK'] assert result['Value'][0][3] == varName result = db.retrieveUserProfiles( userName, userGroup ) assert result['OK'] assert result['Value'] == { profileName: { varName: data } } result = db.storeHashTag( userName, userGroup, tagName, hashTag ) assert result['OK'] assert result['Value'] == hashTag result = db.retrieveAllHashTags( userName, userGroup ) assert result['OK'] assert result['Value'] == { hashTag: tagName } result = db.retrieveHashTag( userName, userGroup, hashTag ) assert result['OK'] assert result['Value'] == tagName gLogger.info( '\n OK\n' ) except AssertionError: print 'ERROR ', if not result['OK']: print result['Message'] else: print result sys.exit( 1 ) if __name__ == '__main__': from DIRAC.Core.Base import Script Script.parseCommandLine() gLogger.setLevel( 'VERBOSE' ) if 'PYTHONOPTIMIZE' in os.environ and os.environ['PYTHONOPTIMIZE']: gLogger.info( 'Unset pyhthon optimization "PYTHONOPTIMIZE"' ) sys.exit( 0 ) testUserProfileDB()
arrabito/DIRAC
FrameworkSystem/DB/UserProfileDB.py
Python
gpl-3.0
27,552
/**************************************************************************** * Copyright (C) 2010 * by Dimok * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any * damages arising from the use of this software. * * Permission is granted to anyone to use this software for any * purpose, including commercial applications, and to alter it and * redistribute it freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you * must not claim that you wrote the original software. If you use * this software in a product, an acknowledgment in the product * documentation would be appreciated but is not required. * * 2. Altered source versions must be plainly marked as such, and * must not be misrepresented as being the original software. * * 3. This notice may not be removed or altered from any source * distribution. ***************************************************************************/ #include <algorithm> #include <string> #include <malloc.h> #include "GUI/gui_searchbar.h" #include "usbloader/wbfs.h" #include "GameCube/GCGames.h" #include "settings/newtitles.h" #include "settings/CSettings.h" #include "settings/CGameSettings.h" #include "settings/CGameStatistics.h" #include "settings/GameTitles.h" #include "settings/CGameCategories.hpp" #include "FreeTypeGX.h" #include "GameList.h" #include "memory/memory.h" #include "Channels/channels.h" enum { DISABLED, ENABLED, HIDEFORBIDDEN }; GameList gameList; void GameList::clear() { GameFilter.clear(); FullGameList.clear(); GamePartitionList.clear(); FilteredList.clear(); //! Clear memory of the vector completely std::vector<struct discHdr *>().swap(FilteredList); std::vector<struct discHdr>().swap(FullGameList); std::vector<int>().swap(GamePartitionList); } struct discHdr * GameList::GetDiscHeader(const char * gameID) const { if(!gameID) return NULL; for (u32 i = 0; i < FilteredList.size(); ++i) { if(strncasecmp(gameID, (const char *) FilteredList[i]->id, 6) == 0) return FilteredList[i]; } return NULL; } int GameList::GetPartitionNumber(const u8 *gameID) const { if(!gameID) return -1; for (u32 i = 0; i < FullGameList.size(); ++i) { if(strncasecmp((const char *) gameID, (const char *) FullGameList[i].id, 6) == 0) return GamePartitionList[i]; } return -1; } void GameList::RemovePartition(int part) { for(u32 i = 0; i < GamePartitionList.size(); ++i) { if(GamePartitionList[i] == part) { FullGameList.erase(FullGameList.begin()+i); GamePartitionList.erase(GamePartitionList.begin()+i); --i; } } if(FullGameList.size() > 0) FilterList(); } int GameList::InternalReadList(int part) { // Retrieve all stuff from WBFS u32 cnt = 0; int ret = WBFS_GetCount(part, &cnt); if (ret < 0) return -1; // We are done here if no games are there if(cnt == 0) return 0; /* Buffer length */ u32 len = sizeof(struct discHdr) * cnt; /* Allocate memory */ struct discHdr *buffer = (struct discHdr *) allocate_memory( len ); if (!buffer) return -1; /* Clear buffer */ memset(buffer, 0, len); /* Get header list */ ret = WBFS_GetHeaders(part, buffer, cnt, sizeof(struct discHdr)); if (ret < 0) { free(buffer); return -1; } u32 oldSize = FullGameList.size(); std::vector<struct discHdr> PartGameList(cnt); memcpy(&PartGameList[0], buffer, len); free(buffer); for (u32 i = 0; i < PartGameList.size(); i++) { for(u32 j = 0; j < FullGameList.size(); j++) { if(strncasecmp((const char *) PartGameList[i].id, (const char *) FullGameList[j].id, 6) == 0) { PartGameList.erase(PartGameList.begin()+i); --i; break; } } } FullGameList.resize(oldSize+PartGameList.size()); memcpy(&FullGameList[oldSize], &PartGameList[0], PartGameList.size()*sizeof(struct discHdr)); GamePartitionList.resize(oldSize+PartGameList.size()); for(u32 i = oldSize; i < GamePartitionList.size(); ++i) GamePartitionList[i] = part; return PartGameList.size(); } int GameList::ReadGameList() { // Clear list FullGameList.clear(); GamePartitionList.clear(); //! Clear memory of the vector completely std::vector<struct discHdr>().swap(FullGameList); std::vector<int>().swap(GamePartitionList); int cnt = 0; if(!Settings.MultiplePartitions) { cnt = InternalReadList(Settings.partition); } else { int partitions = DeviceHandler::GetUSBPartitionCount(); for(int part = 0; part < partitions; ++part) { int ret = InternalReadList(part); if(ret > 0) cnt += ret; } } return cnt; } void GameList::InternalFilterList(std::vector<struct discHdr> &FullList) { for (u32 i = 0; i < FullList.size(); ++i) { struct discHdr *header = &FullList[i]; /* Register game */ NewTitles::Instance()->CheckGame(header->id); /* Filters */ if (Settings.GameSort & SORT_FAVORITE) { GameStatus * GameStats = GameStatistics.GetGameStatus(header->id); if (Settings.marknewtitles) { bool isNew = NewTitles::Instance()->IsNew(header->id); if (!isNew && (!GameStats || GameStats->FavoriteRank == 0)) continue; } else { if (!GameStats || GameStats->FavoriteRank == 0) continue; } } //ignore uLoader cfg "iso". i was told it is "__CFG_" but not confirmed if (strncasecmp((char*) header->id, "__CFG_", 6) == 0) continue; GameCFG * GameConfig = GameSettings.GetGameCFG(header); /* Rating based parental control method */ if (Settings.parentalcontrol != PARENTAL_LVL_ADULT && !Settings.godmode) { if (GameConfig && GameConfig->parentalcontrol > Settings.parentalcontrol) continue; // Check game rating in GameTDB, since the default Wii parental control setting is enabled int rating = GameTitles.GetParentalRating((char *) header->id); if (rating > Settings.parentalcontrol) continue; } //! Per game lock method if(!Settings.godmode && GameConfig && GameConfig->Locked) continue; //! Category filter u32 n; int allType = DISABLED; // verify the display mode for category "All" for(n = 0; n < Settings.EnabledCategories.size(); ++n) { if(Settings.EnabledCategories[n] == 0) { allType = ENABLED; // All = Enabled break; } } for(n = 0; n < Settings.ForbiddenCategories.size(); ++n) { if(Settings.ForbiddenCategories[n] == 0) { allType = HIDEFORBIDDEN; // All = Enabled but hide Forbidden categories break; } } if(allType == DISABLED) { // Remove TitleID if it contains a forbidden categories for(n = 0; n < Settings.ForbiddenCategories.size(); ++n) { if(GameCategories.isInCategory((char *) header->id, Settings.ForbiddenCategories[n])) break; } if(n < Settings.ForbiddenCategories.size()) continue; // Remove TitleID is it doesn't contain a required categories for(n = 0; n < Settings.RequiredCategories.size(); ++n) { if(!GameCategories.isInCategory((char *) header->id, Settings.RequiredCategories[n])) break; } if(n < Settings.RequiredCategories.size()) continue; // If there's no required categories, verify if the TitleID should be kept or removed if(Settings.RequiredCategories.size() == 0) { for(n = 0; n < Settings.EnabledCategories.size(); ++n) { if(GameCategories.isInCategory((char *) header->id, Settings.EnabledCategories[n])) break; } if(n == Settings.EnabledCategories.size()) continue; } } if(allType == HIDEFORBIDDEN) { // Remove TitleID if it contains a forbidden categories for(n = 0; n < Settings.ForbiddenCategories.size(); ++n) { if(GameCategories.isInCategory((char *) header->id, Settings.ForbiddenCategories[n])) if(Settings.ForbiddenCategories[n] >0) break; } if(n < Settings.ForbiddenCategories.size()) continue; } FilteredList.push_back(header); } } int GameList::FilterList(const wchar_t * gameFilter) { if((Settings.LoaderMode & MODE_WIIGAMES) && (FullGameList.size() == 0)) ReadGameList(); if (gameFilter) GameFilter.assign(gameFilter); FilteredList.clear(); // Filter current game list if selected if(Settings.LoaderMode & MODE_WIIGAMES) InternalFilterList(FullGameList); // Filter gc game list if selected if(Settings.LoaderMode & MODE_GCGAMES) InternalFilterList(GCGames::Instance()->GetHeaders()); // Filter nand channel list if selected if(Settings.LoaderMode & MODE_NANDCHANNELS) InternalFilterList(Channels::Instance()->GetNandHeaders()); // Filter emu nand channel list if selected if(Settings.LoaderMode & MODE_EMUCHANNELS) InternalFilterList(Channels::Instance()->GetEmuHeaders()); NewTitles::Instance()->Save(); GuiSearchBar::FilterList(FilteredList, GameFilter); SortList(); return FilteredList.size(); } void GameList::InternalLoadUnfiltered(std::vector<struct discHdr> &FullList) { for (u32 i = 0; i < FullList.size(); ++i) { struct discHdr *header = &FullList[i]; /* Register game */ NewTitles::Instance()->CheckGame(header->id); FilteredList.push_back(header); } } int GameList::LoadUnfiltered() { if((Settings.LoaderMode & MODE_WIIGAMES) && (FullGameList.size() == 0)) ReadGameList(); GameFilter.clear(); FilteredList.clear(); // Filter current game list if selected if(Settings.LoaderMode & MODE_WIIGAMES) InternalLoadUnfiltered(FullGameList); // Filter gc game list if selected if(Settings.LoaderMode & MODE_GCGAMES) InternalLoadUnfiltered(GCGames::Instance()->GetHeaders()); // Filter nand channel list if selected if(Settings.LoaderMode & MODE_NANDCHANNELS) InternalLoadUnfiltered(Channels::Instance()->GetNandHeaders()); // Filter emu nand channel list if selected if(Settings.LoaderMode & MODE_EMUCHANNELS) InternalLoadUnfiltered(Channels::Instance()->GetEmuHeaders()); NewTitles::Instance()->Save(); GuiSearchBar::FilterList(FilteredList, GameFilter); SortList(); return FilteredList.size(); } void GameList::SortList() { if (FilteredList.size() < 2) return; if (Settings.GameSort & SORT_PLAYCOUNT) { std::sort(FilteredList.begin(), FilteredList.end(), PlaycountSortCallback); } else if(Settings.GameSort & SORT_RANKING) { std::sort(FilteredList.begin(), FilteredList.end(), RankingSortCallback); } else if(Settings.GameSort & SORT_PLAYERS) { std::sort(FilteredList.begin(), FilteredList.end(), PlayersSortCallback); } else { std::sort(FilteredList.begin(), FilteredList.end(), NameSortCallback); } } bool GameList::NameSortCallback(const struct discHdr *a, const struct discHdr *b) { return (strcasecmp(GameTitles.GetTitle((struct discHdr *) a), GameTitles.GetTitle((struct discHdr *) b)) < 0); } bool GameList::PlaycountSortCallback(const struct discHdr *a, const struct discHdr *b) { int count1 = GameStatistics.GetPlayCount(a->id); int count2 = GameStatistics.GetPlayCount(b->id); if (count1 == count2) return NameSortCallback(a, b); return (count1 > count2); } bool GameList::RankingSortCallback(const struct discHdr *a, const struct discHdr *b) { int fav1 = GameStatistics.GetFavoriteRank(a->id); int fav2 = GameStatistics.GetFavoriteRank(b->id); if (fav1 == fav2) return NameSortCallback(a, b); return (fav1 > fav2); } bool GameList::PlayersSortCallback(const struct discHdr *a, const struct discHdr *b) { int count1 = GameTitles.GetPlayersCount((const char *) a->id); int count2 = GameTitles.GetPlayersCount((const char *) b->id); if (count1 == count2) return NameSortCallback(a, b); return (count1 > count2); }
SuperrSonic/ULGX
source/usbloader/GameList.cpp
C++
gpl-3.0
11,531
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>Time-out for test cases</title> <link rel="stylesheet" href="../../boostbook.css" type="text/css"> <meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> <link rel="home" href="../../index.html" title="Boost.Test"> <link rel="up" href="../testing_tools.html" title="Writing unit tests"> <link rel="prev" href="exception_correctness.html" title="Exception correctness"> <link rel="next" href="expected_failures.html" title="Expected failures specification"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table cellpadding="2" width="100%"><tr> <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> <td align="center"><a href="../../../../../../index.html">Home</a></td> <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> <td align="center"><a href="../../../../../../more/index.htm">More</a></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="exception_correctness.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../testing_tools.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="expected_failures.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> <a name="boost_test.testing_tools.timeout"></a><a class="link" href="timeout.html" title="Time-out for test cases">Time-out for test cases</a> </h3></div></div></div> <p> The <span class="emphasis"><em>Unit Test Framework</em></span> provides the decorator <a class="link" href="../utf_reference/testing_tool_ref/decorator_timeout.html" title="timeout (decorator)"><code class="computeroutput"><span class="identifier">timeout</span></code></a> that specifies a time-out for a specific <span class="bold"><strong>test case</strong></span>, The argument time (in seconds) sets the maximum allowed duration of a test case. If this time is exceeded the test case is forced to stop and is reported as failure. </p> <h6> <a name="boost_test.testing_tools.timeout.h0"></a> <span class="phrase"><a name="boost_test.testing_tools.timeout.example_descr"></a></span><a class="link" href="timeout.html#boost_test.testing_tools.timeout.example_descr">Example: decorator timeout</a> </h6> <div class="informaltable"><table class="table"> <colgroup><col></colgroup> <thead><tr><th> <p> Code </p> </th></tr></thead> <tbody><tr><td> <pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_MODULE</span> <span class="identifier">decorator_11</span> <span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">test</span><span class="special">/</span><span class="identifier">included</span><span class="special">/</span><span class="identifier">unit_test</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span> <span class="keyword">namespace</span> <span class="identifier">utf</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">unit_test</span><span class="special">;</span> <span class="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span><span class="identifier">test1</span><span class="special">,</span> <span class="special">*</span> <span class="identifier">utf</span><span class="special">::</span><span class="identifier">timeout</span><span class="special">(</span><span class="number">2</span><span class="special">))</span> <span class="special">{</span> <span class="preprocessor">#ifdef</span> <span class="identifier">BOOST_SIGACTION_BASED_SIGNAL_HANDLING</span> <span class="keyword">for</span><span class="special">(;;)</span> <span class="special">{}</span> <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="keyword">true</span><span class="special">);</span> <span class="preprocessor">#else</span> <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="keyword">false</span><span class="special">);</span> <span class="preprocessor">#endif</span> <span class="special">}</span> </pre> </td></tr></tbody> </table></div> <div class="informaltable"><table class="table"> <colgroup><col></colgroup> <thead><tr><th> <p> Output </p> </th></tr></thead> <tbody><tr><td> <pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">&gt;</span> <span class="identifier">decorator_11</span> <span class="identifier">Running</span> <span class="number">1</span> <span class="identifier">test</span> <span class="keyword">case</span><span class="special">...</span> <span class="identifier">unknown</span> <span class="identifier">location</span><span class="special">(</span><span class="number">0</span><span class="special">):</span> <span class="identifier">fatal</span> <span class="identifier">error</span><span class="special">:</span> <span class="identifier">in</span> <span class="string">"test1"</span><span class="special">:</span> <span class="identifier">signal</span><span class="special">:</span> <span class="identifier">SIGALRM</span> <span class="special">(</span><span class="identifier">timeout</span> <span class="keyword">while</span> <span class="identifier">executing</span> <span class="identifier">function</span><span class="special">)</span> <span class="identifier">test</span><span class="special">.</span><span class="identifier">cpp</span><span class="special">(</span><span class="number">5</span><span class="special">):</span> <span class="identifier">last</span> <span class="identifier">checkpoint</span><span class="special">:</span> <span class="string">"test1"</span> <span class="identifier">entry</span><span class="special">.</span> <span class="special">***</span> <span class="number">1</span> <span class="identifier">failures</span> <span class="identifier">is</span> <span class="identifier">detected</span> <span class="identifier">in</span> <span class="identifier">test</span> <span class="identifier">module</span> <span class="string">"decorator_11"</span> </pre> </td></tr></tbody> </table></div> <div class="note"><table border="0" summary="Note"> <tr> <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td> <th align="left">Note</th> </tr> <tr><td align="left" valign="top"><p> Applied at test suite level, this decorator has no effect. </p></td></tr> </table></div> <div class="caution"><table border="0" summary="Caution"> <tr> <td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../../doc/src/images/caution.png"></td> <th align="left">Caution</th> </tr> <tr><td align="left" valign="top"><p> Decorator <code class="computeroutput"><span class="identifier">timeout</span></code> has no effect on Windows build. This feature is not implemented on Windows yet. </p></td></tr> </table></div> </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> <td align="right"><div class="copyright-footer">Copyright &#169; 2001-2015 Boost.Test contributors<p> Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) </p> </div></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="exception_correctness.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../testing_tools.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="expected_failures.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> </div> </body> </html>
gwq5210/litlib
thirdparty/sources/boost_1_60_0/libs/test/doc/html/boost_test/testing_tools/timeout.html
HTML
gpl-3.0
8,901
/* Copyright 2010, 2011 Semantic Web Research Center, KAIST This file is part of JHanNanum. JHanNanum 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. JHanNanum 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 JHanNanum. If not, see <http://www.gnu.org/licenses/> */ package kr.ac.kaist.swrc.jhannanum.plugin.SupplementPlugin.PosProcessor.NounExtractor; import java.util.LinkedList; import kr.ac.kaist.swrc.jhannanum.comm.Eojeol; import kr.ac.kaist.swrc.jhannanum.comm.Sentence; import kr.ac.kaist.swrc.jhannanum.plugin.SupplementPlugin.PosProcessor.PosProcessor; /** * This plug-in extracts the morphemes recognized as a noun after Part Of Speech tagging was done. * * It is a POS Processor plug-in which is a supplement plug-in of phase 3 in HanNanum work flow. * * @author Sangwon Park (hudoni@world.kaist.ac.kr), CILab, SWRC, KAIST */ public class NounExtractor implements PosProcessor { /** the buffer for noun morphemes */ private LinkedList<String> nounMorphemes = null; /** the buffer for tags of the morphemes */ private LinkedList<String> nounTags = null; @Override public void initialize(String baseDir, String configFile) throws Exception { nounMorphemes = new LinkedList<String>(); nounTags = new LinkedList<String>(); } @Override public void shutdown() { } /** * It extracts the morphemes which were recognized as noun after POS tagging. * @param st - the POS tagged sentence * @return the sentence in which only nouns were remained */ @Override public Sentence doProcess(Sentence st) { Eojeol[] eojeols = st.getEojeols(); for (int i = 0; i < eojeols.length; i++) { String[] morphemes = eojeols[i].getMorphemes(); String[] tags = eojeols[i].getTags(); nounMorphemes.clear(); nounTags.clear(); for (int j = 0; j < tags.length; j++) { char c = tags[j].charAt(0); if (c == 'n') { nounMorphemes.add(morphemes[j]); nounTags.add(tags[j]); } else if (c == 'f') { nounMorphemes.add(morphemes[j]); nounTags.add("ncn"); } } eojeols[i].setMorphemes(nounMorphemes.toArray(new String[0])); eojeols[i].setTags(nounTags.toArray(new String[0])); } st.setEojeols(eojeols); return st; } }
haven-jeon/HanNanum-Analyzer
src/kr/ac/kaist/swrc/jhannanum/plugin/SupplementPlugin/PosProcessor/NounExtractor/NounExtractor.java
Java
gpl-3.0
2,741
/* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.cts.tradefed.result; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import javax.annotation.Nullable; /** * Class that sends a HTTP POST multipart/form-data request containing * the test result XML. */ class ResultReporter { private static final int RESULT_XML_BYTES = 500 * 1024; private final String mServerUrl; private final String mSuiteName; ResultReporter(String serverUrl, String suiteName) { mServerUrl = serverUrl; mSuiteName = suiteName; } public void reportResult(File reportFile, @Nullable String referenceUrl) throws IOException { if (isEmpty(mServerUrl)) { return; } InputStream input = new FileInputStream(reportFile); try { byte[] data = IssueReporter.getBytes(input, RESULT_XML_BYTES); MultipartForm multipartForm = new MultipartForm(mServerUrl) .addFormValue("suite", mSuiteName) .addFormFile("resultXml", "testResult.xml.gz", data); if (!isEmpty(referenceUrl)) { multipartForm.addFormValue("referenceUrl", referenceUrl); } multipartForm.submit(); } finally { input.close(); } } private static boolean isEmpty(String value) { return value == null || value.trim().isEmpty(); } }
s20121035/rk3288_android5.1_repo
cts/tools/tradefed-host/src/com/android/cts/tradefed/result/ResultReporter.java
Java
gpl-3.0
2,059
// Copyright 2016 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "core/fxcrt/fx_stream.h" bool IFX_SeekableWriteStream::WriteBlock(const void* pData, size_t size) { return WriteBlock(pData, GetSize(), size); } bool IFX_SeekableReadStream::IsEOF() { return false; } FX_FILESIZE IFX_SeekableReadStream::GetPosition() { return 0; } size_t IFX_SeekableReadStream::ReadBlock(void* buffer, size_t size) { return 0; } bool IFX_SeekableStream::WriteBlock(const void* buffer, size_t size) { return WriteBlock(buffer, GetSize(), size); }
geminy/aidear
oss/qt/qt-everywhere-opensource-src-5.9.0/qtwebengine/src/3rdparty/chromium/third_party/pdfium/core/fxcrt/fxcrt_stream.cpp
C++
gpl-3.0
729
<h3>Résumé</h3> <p>The résumé area allows you to build an online résumé or CV.</p>
plymouthstate/mahara
htdocs/artefact/resume/lang/en.utf8/help/pages/index.html
HTML
gpl-3.0
90
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>relation</title> <link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css"> <meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> <link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Geometry"> <link rel="up" href="../algorithms.html" title="Algorithms"> <link rel="prev" href="relate.html" title="relate"> <link rel="next" href="reverse.html" title="reverse"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table cellpadding="2" width="100%"><tr> <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td> <td align="center"><a href="../../../../../../../index.html">Home</a></td> <td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td> <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> <td align="center"><a href="../../../../../../../more/index.htm">More</a></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="relate.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../algorithms.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="reverse.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> </div> <div class="section"> <div class="titlepage"><div><div><h4 class="title"> <a name="geometry.reference.algorithms.relation"></a><a class="link" href="relation.html" title="relation">relation</a> </h4></div></div></div> <p> <a class="indexterm" name="idm44837181550272"></a> Calculates the relation between a pair of geometries as defined in DE-9IM. </p> <h6> <a name="geometry.reference.algorithms.relation.h0"></a> <span class="phrase"><a name="geometry.reference.algorithms.relation.synopsis"></a></span><a class="link" href="relation.html#geometry.reference.algorithms.relation.synopsis">Synopsis</a> </h6> <p> </p> <pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Geometry1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Geometry2</span><span class="special">&gt;</span> <span class="identifier">de9im</span><span class="special">::</span><span class="identifier">matrix</span> <span class="identifier">relation</span><span class="special">(</span><span class="identifier">Geometry1</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">geometry1</span><span class="special">,</span> <span class="identifier">Geometry2</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">geometry2</span><span class="special">)</span></pre> <p> </p> <h6> <a name="geometry.reference.algorithms.relation.h1"></a> <span class="phrase"><a name="geometry.reference.algorithms.relation.parameters"></a></span><a class="link" href="relation.html#geometry.reference.algorithms.relation.parameters">Parameters</a> </h6> <div class="informaltable"><table class="table"> <colgroup> <col> <col> <col> <col> </colgroup> <thead><tr> <th> <p> Type </p> </th> <th> <p> Concept </p> </th> <th> <p> Name </p> </th> <th> <p> Description </p> </th> </tr></thead> <tbody> <tr> <td> <p> Geometry1 const &amp; </p> </td> <td> <p> Any type fulfilling a Geometry Concept </p> </td> <td> <p> geometry1 </p> </td> <td> <p> A model of the specified concept </p> </td> </tr> <tr> <td> <p> Geometry2 const &amp; </p> </td> <td> <p> Any type fulfilling a Geometry Concept </p> </td> <td> <p> geometry2 </p> </td> <td> <p> A model of the specified concept </p> </td> </tr> </tbody> </table></div> <h6> <a name="geometry.reference.algorithms.relation.h2"></a> <span class="phrase"><a name="geometry.reference.algorithms.relation.returns"></a></span><a class="link" href="relation.html#geometry.reference.algorithms.relation.returns">Returns</a> </h6> <p> The DE-9IM matrix expressing the relation between geometries. </p> <h6> <a name="geometry.reference.algorithms.relation.h3"></a> <span class="phrase"><a name="geometry.reference.algorithms.relation.header"></a></span><a class="link" href="relation.html#geometry.reference.algorithms.relation.header">Header</a> </h6> <p> Either </p> <p> <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code> </p> <p> Or </p> <p> <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">algorithms</span><span class="special">/</span><span class="identifier">relation</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code> </p> <h6> <a name="geometry.reference.algorithms.relation.h4"></a> <span class="phrase"><a name="geometry.reference.algorithms.relation.conformance"></a></span><a class="link" href="relation.html#geometry.reference.algorithms.relation.conformance">Conformance</a> </h6> <p> This function is additional and not described in the OGC standard. The spatial relation is represented by DE-9IM matrix. </p> <h6> <a name="geometry.reference.algorithms.relation.h5"></a> <span class="phrase"><a name="geometry.reference.algorithms.relation.example"></a></span><a class="link" href="relation.html#geometry.reference.algorithms.relation.example">Example</a> </h6> <p> Shows how to calculate the spatial relation between a point and a polygon </p> <p> </p> <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span> <span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;</span> <span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span> <span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">point_xy</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span> <span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">polygon</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span> <span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span> <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">d2</span><span class="special">::</span><span class="identifier">point_xy</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">point_type</span><span class="special">;</span> <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">polygon</span><span class="special">&lt;</span><span class="identifier">point_type</span><span class="special">&gt;</span> <span class="identifier">polygon_type</span><span class="special">;</span> <span class="identifier">polygon_type</span> <span class="identifier">poly</span><span class="special">;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">read_wkt</span><span class="special">(</span> <span class="string">"POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)"</span> <span class="string">"(4.0 2.0, 4.2 1.4, 4.8 1.9, 4.4 2.2, 4.0 2.0))"</span><span class="special">,</span> <span class="identifier">poly</span><span class="special">);</span> <span class="identifier">point_type</span> <span class="identifier">p</span><span class="special">(</span><span class="number">4</span><span class="special">,</span> <span class="number">1</span><span class="special">);</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">de9im</span><span class="special">::</span><span class="identifier">matrix</span> <span class="identifier">matrix</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">relation</span><span class="special">(</span><span class="identifier">p</span><span class="special">,</span> <span class="identifier">poly</span><span class="special">);</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">code</span> <span class="special">=</span> <span class="identifier">matrix</span><span class="special">.</span><span class="identifier">str</span><span class="special">();</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"relation: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">code</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> <span class="special">}</span> </pre> <p> </p> <p> Output: </p> <pre class="programlisting">relation: 0FFFFF212 <img src="../../../img/algorithms/within.png" alt="within"> </pre> <h6> <a name="geometry.reference.algorithms.relation.h6"></a> <span class="phrase"><a name="geometry.reference.algorithms.relation.see_also"></a></span><a class="link" href="relation.html#geometry.reference.algorithms.relation.see_also">See also</a> </h6> <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> <a class="link" href="../de9im/de9im_matrix.html" title="de9im::matrix">de9im::matrix</a> </li> <li class="listitem"> <a class="link" href="relate.html" title="relate">relate</a> </li> </ul></div> </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> <td align="right"><div class="copyright-footer">Copyright &#169; 2009-2015 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam Wulkiewicz, Oracle and/or its affiliates<p> Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) </p> </div></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="relate.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../algorithms.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="reverse.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> </div> </body> </html>
gwq5210/litlib
thirdparty/sources/boost_1_60_0/libs/geometry/doc/html/geometry/reference/algorithms/relation.html
HTML
gpl-3.0
14,232
; for a description, what can be done in this ; file see ../template/template.asm. You may want to ; copy that file to this one and edit it afterwards. .include "preamble.inc" ; letters the same. Set to 0 if you do not want it .set WANT_IGNORECASE = 1 ; cpu clock in hertz .equ F_CPU = 16000000 .include "drivers/usart_1.asm" .include "amforth.asm"
andrewtholt/My-amforth-6.1
appl/myArduino/leonardo.asm
Assembly
gpl-3.0
354
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <!-- This manual is for FFTW (version 3.3.9, 10 December 2020). Copyright (C) 2003 Matteo Frigo. Copyright (C) 2003 Massachusetts Institute of Technology. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Free Software Foundation. --> <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>More DFTs of Real Data (FFTW 3.3.9)</title> <meta name="description" content="More DFTs of Real Data (FFTW 3.3.9)"> <meta name="keywords" content="More DFTs of Real Data (FFTW 3.3.9)"> <meta name="resource-type" content="document"> <meta name="distribution" content="global"> <meta name="Generator" content="makeinfo"> <link href="index.html#Top" rel="start" title="Top"> <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> <link href="Tutorial.html#Tutorial" rel="up" title="Tutorial"> <link href="The-Halfcomplex_002dformat-DFT.html#The-Halfcomplex_002dformat-DFT" rel="next" title="The Halfcomplex-format DFT"> <link href="Multi_002dDimensional-DFTs-of-Real-Data.html#Multi_002dDimensional-DFTs-of-Real-Data" rel="prev" title="Multi-Dimensional DFTs of Real Data"> <style type="text/css"> <!-- a.summary-letter {text-decoration: none} blockquote.indentedblock {margin-right: 0em} blockquote.smallindentedblock {margin-right: 0em; font-size: smaller} blockquote.smallquotation {font-size: smaller} div.display {margin-left: 3.2em} div.example {margin-left: 3.2em} div.lisp {margin-left: 3.2em} div.smalldisplay {margin-left: 3.2em} div.smallexample {margin-left: 3.2em} div.smalllisp {margin-left: 3.2em} kbd {font-style: oblique} pre.display {font-family: inherit} pre.format {font-family: inherit} pre.menu-comment {font-family: serif} pre.menu-preformatted {font-family: serif} pre.smalldisplay {font-family: inherit; font-size: smaller} pre.smallexample {font-size: smaller} pre.smallformat {font-family: inherit; font-size: smaller} pre.smalllisp {font-size: smaller} span.nolinebreak {white-space: nowrap} span.roman {font-family: initial; font-weight: normal} span.sansserif {font-family: sans-serif; font-weight: normal} ul.no-bullet {list-style: none} --> </style> </head> <body lang="en"> <a name="More-DFTs-of-Real-Data"></a> <div class="header"> <p> Previous: <a href="Multi_002dDimensional-DFTs-of-Real-Data.html#Multi_002dDimensional-DFTs-of-Real-Data" accesskey="p" rel="prev">Multi-Dimensional DFTs of Real Data</a>, Up: <a href="Tutorial.html#Tutorial" accesskey="u" rel="up">Tutorial</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> </div> <hr> <a name="More-DFTs-of-Real-Data-1"></a> <h3 class="section">2.5 More DFTs of Real Data</h3> <table class="menu" border="0" cellspacing="0"> <tr><td align="left" valign="top">&bull; <a href="The-Halfcomplex_002dformat-DFT.html#The-Halfcomplex_002dformat-DFT" accesskey="1">The Halfcomplex-format DFT</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top"> </td></tr> <tr><td align="left" valign="top">&bull; <a href="Real-even_002fodd-DFTs-_0028cosine_002fsine-transforms_0029.html#Real-even_002fodd-DFTs-_0028cosine_002fsine-transforms_0029" accesskey="2">Real even/odd DFTs (cosine/sine transforms)</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top"> </td></tr> <tr><td align="left" valign="top">&bull; <a href="The-Discrete-Hartley-Transform.html#The-Discrete-Hartley-Transform" accesskey="3">The Discrete Hartley Transform</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top"> </td></tr> </table> <p>FFTW supports several other transform types via a unified <em>r2r</em> (real-to-real) interface, <a name="index-r2r"></a> so called because it takes a real (<code>double</code>) array and outputs a real array of the same size. These r2r transforms currently fall into three categories: DFTs of real input and complex-Hermitian output in halfcomplex format, DFTs of real input with even/odd symmetry (a.k.a. discrete cosine/sine transforms, DCTs/DSTs), and discrete Hartley transforms (DHTs), all described in more detail by the following sections. </p> <p>The r2r transforms follow the by now familiar interface of creating an <code>fftw_plan</code>, executing it with <code>fftw_execute(plan)</code>, and destroying it with <code>fftw_destroy_plan(plan)</code>. Furthermore, all r2r transforms share the same planner interface: </p> <div class="example"> <pre class="example">fftw_plan fftw_plan_r2r_1d(int n, double *in, double *out, fftw_r2r_kind kind, unsigned flags); fftw_plan fftw_plan_r2r_2d(int n0, int n1, double *in, double *out, fftw_r2r_kind kind0, fftw_r2r_kind kind1, unsigned flags); fftw_plan fftw_plan_r2r_3d(int n0, int n1, int n2, double *in, double *out, fftw_r2r_kind kind0, fftw_r2r_kind kind1, fftw_r2r_kind kind2, unsigned flags); fftw_plan fftw_plan_r2r(int rank, const int *n, double *in, double *out, const fftw_r2r_kind *kind, unsigned flags); </pre></div> <a name="index-fftw_005fplan_005fr2r_005f1d"></a> <a name="index-fftw_005fplan_005fr2r_005f2d"></a> <a name="index-fftw_005fplan_005fr2r_005f3d"></a> <a name="index-fftw_005fplan_005fr2r"></a> <p>Just as for the complex DFT, these plan 1d/2d/3d/multi-dimensional transforms for contiguous arrays in row-major order, transforming (real) input to output of the same size, where <code>n</code> specifies the <em>physical</em> dimensions of the arrays. All positive <code>n</code> are supported (with the exception of <code>n=1</code> for the <code>FFTW_REDFT00</code> kind, noted in the real-even subsection below); products of small factors are most efficient (factorizing <code>n-1</code> and <code>n+1</code> for <code>FFTW_REDFT00</code> and <code>FFTW_RODFT00</code> kinds, described below), but an <i>O</i>(<i>n</i>&nbsp;log&nbsp;<i>n</i>) algorithm is used even for prime sizes. </p> <p>Each dimension has a <em>kind</em> parameter, of type <code>fftw_r2r_kind</code>, specifying the kind of r2r transform to be used for that dimension. <a name="index-kind-_0028r2r_0029"></a> <a name="index-fftw_005fr2r_005fkind"></a> (In the case of <code>fftw_plan_r2r</code>, this is an array <code>kind[rank]</code> where <code>kind[i]</code> is the transform kind for the dimension <code>n[i]</code>.) The kind can be one of a set of predefined constants, defined in the following subsections. </p> <p>In other words, FFTW computes the separable product of the specified r2r transforms over each dimension, which can be used e.g. for partial differential equations with mixed boundary conditions. (For some r2r kinds, notably the halfcomplex DFT and the DHT, such a separable product is somewhat problematic in more than one dimension, however, as is described below.) </p> <p>In the current version of FFTW, all r2r transforms except for the halfcomplex type are computed via pre- or post-processing of halfcomplex transforms, and they are therefore not as fast as they could be. Since most other general DCT/DST codes employ a similar algorithm, however, FFTW&rsquo;s implementation should provide at least competitive performance. </p> <hr> <div class="header"> <p> Previous: <a href="Multi_002dDimensional-DFTs-of-Real-Data.html#Multi_002dDimensional-DFTs-of-Real-Data" accesskey="p" rel="prev">Multi-Dimensional DFTs of Real Data</a>, Up: <a href="Tutorial.html#Tutorial" accesskey="u" rel="up">Tutorial</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> </div> </body> </html>
anetasie/sherpa
extern/fftw-3.3.9/doc/html/More-DFTs-of-Real-Data.html
HTML
gpl-3.0
8,678
// SuperTux // Copyright (C) 2006 Matthias Braun <matze@braunis.de> // // 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 HEADER_SUPERTUX_VIDEO_LIGHTMAP_HPP #define HEADER_SUPERTUX_VIDEO_LIGHTMAP_HPP #include <SDL_video.h> #include <memory> #include <obstack.h> #include <stdint.h> #include <string> #include <vector> #include "math/rectf.hpp" #include "math/vector.hpp" #include "video/color.hpp" #include "video/drawing_request.hpp" #include "video/font.hpp" #include "video/glutil.hpp" #include "video/surface.hpp" class Texture; struct DrawingRequest; class Lightmap { public: virtual ~Lightmap() {} virtual void start_draw(const Color &ambient_color) = 0; virtual void end_draw() = 0; virtual void do_draw() = 0; virtual void draw_surface(const DrawingRequest& request) = 0; virtual void draw_surface_part(const DrawingRequest& request) = 0; virtual void draw_gradient(const DrawingRequest& request) = 0; virtual void draw_filled_rect(const DrawingRequest& request) = 0; virtual void get_light(const DrawingRequest& request) const = 0; }; #endif /* EOF */
ehsan/supertux
src/video/lightmap.hpp
C++
gpl-3.0
1,702
/*************************************************************************** * TextLabelAsciiCropped.cs * * 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. * ***************************************************************************/ using Microsoft.Xna.Framework; using UltimaXNA.Core.Graphics; using UltimaXNA.Core.UI; namespace UltimaXNA.Ultima.UI.Controls { class TextLabelAsciiCropped : AControl { public int Hue; public int FontID; private RenderedText m_Rendered; private string m_Text; public string Text { get { return m_Text; } set { m_Text = value; m_Rendered.Text = string.Format("<span style=\"font-family=ascii{0}\">{1}", FontID, m_Text); } } TextLabelAsciiCropped(AControl parent) : base(parent) { } public TextLabelAsciiCropped(AControl parent, int x, int y, int width, int height, int font, int hue, string text) : this(parent) { BuildGumpling(x, y, width, height, font, hue, text); } void BuildGumpling(int x, int y, int width, int height, int font, int hue, string text) { Position = new Point(x, y); Size = new Point(width, height); m_Rendered = new RenderedText(string.Empty, width); Hue = hue; FontID = font; Text = text; } public override void Draw(SpriteBatchUI spriteBatch, Point position, double frameMS) { m_Rendered.Draw(spriteBatch, position, Utility.GetHueVector(Hue, true, false, true)); base.Draw(spriteBatch, position, frameMS); } } }
jorsi/UltimaXNA
dev/Ultima/UI/Controls/TextLabelAsciiCropped.cs
C#
gpl-3.0
2,016
/* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2016 - Daniel De Matteis * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. * * RetroArch 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 RetroArch. * If not, see <http://www.gnu.org/licenses/>. */ #ifndef __RETROARCH_ACCESSIBILITY_H #define __RETROARCH_ACCESSIBILITY_H #include <stdint.h> #include <stddef.h> #include <sys/types.h> #include <stdlib.h> #include <boolean.h> #include <retro_inline.h> #include <retro_common_api.h> #ifdef HAVE_CONFIG_H #include "config.h" #endif #endif
spec-chum/RetroArch
accessibility.h
C
gpl-3.0
1,080
#!/bin/bash rm -rf work transcript vsim.wlf vlib work vlog ../argmax.v testbench.v #w/o gui vsim -c -do test.do testbench #w/ gui #vsim -do test.do testbench
esonghori/TinyGarble
circuit_synthesis/argmax/test/test.sh
Shell
gpl-3.0
164