text:
#ifndef YOUBOT_YOUBOTGRIPPERPARAMETER_H
#define YOUBOT_YOUBOTGRIPPERPARAMETER_H

#include <vector>
#include <sstream>
#include "generic/Logger.hpp"
#include "generic/Units.hpp"
#include "generic/Time.hpp"
#include "generic/Exceptions.hpp"
#include "generic-joint/JointParameter.hpp"
#include "generic-gripper/GripperParameter.hpp"
#include "youbot/ProtocolDefinitions.hpp"
#include "youbot/YouBotSlaveMsg.hpp"
#include "youbot/YouBotSlaveMailboxMsg.hpp"
namespace youbot {

///////////////////////////////////////////////////////////////////////////////
/// abstract youBot gripper parameter
///////////////////////////////////////////////////////////////////////////////
class YouBotGripperParameter : public GripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  protected:
    YouBotGripperParameter();

  public:
    virtual ~YouBotGripperParameter();

    virtual void toString(std::string& value) const = 0;

  protected:
    virtual ParameterType getType() const = 0;

    virtual std::string getName() const = 0;

    virtual void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const = 0;

    virtual void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message) = 0;

    std::string name;

  private:
    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// the firmware version of the gripper
///////////////////////////////////////////////////////////////////////////////
class GripperFirmwareVersion : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    GripperFirmwareVersion();

    virtual ~GripperFirmwareVersion();

    void getParameter(int& controllerType, double& firmwareVersion) const;

    void setParameter(const int controllerType, const double firmwareVersion);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    int controllerType;

    double firmwareVersion;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// The name for a gripper bar or finger
///////////////////////////////////////////////////////////////////////////////
class GripperBarName : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;

  public:
    GripperBarName();

    virtual ~GripperBarName();

    void getParameter(std::string& parameter) const;

    void setParameter(const std::string parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    std::string value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Calibrate the gripper
///////////////////////////////////////////////////////////////////////////////
class CalibrateGripper : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    CalibrateGripper();

    virtual ~CalibrateGripper();

    void getParameter(bool& parameter) const;

    void setParameter(const bool parameter);

    void toString(std::string& value) const;

  private:
    virtual void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    virtual void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    ParameterType getType() const {return this->parameterType;};

    std::string getName() const {return this->name;};

    bool value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Represents a bar spacing offset. It could be useful if the gripper can not be totally closed.
///////////////////////////////////////////////////////////////////////////////
class BarSpacingOffset : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    BarSpacingOffset();

    virtual ~BarSpacingOffset();

    void getParameter(quantity<si::length>& parameter) const;

    void setParameter(const quantity<si::length>& parameter);

    void toString(std::string& value) const;

  private:
    virtual void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    virtual void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    ParameterType getType() const {return this->parameterType;};

    std::string getName() const {return this->name;};

    quantity<si::length> value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// The encoder value when the gripper has reached it's maximum bar spacing position
///////////////////////////////////////////////////////////////////////////////
class MaxEncoderValue : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    MaxEncoderValue();

    virtual ~MaxEncoderValue();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int parameter);

    void toString(std::string& value) const;

  private:
    virtual void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    virtual void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    ParameterType getType() const {return this->parameterType;};

    std::string getName() const {return this->name;};

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// The maximum bar spacing distance of the gripper
///////////////////////////////////////////////////////////////////////////////
class MaxTravelDistance : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    MaxTravelDistance();

    virtual ~MaxTravelDistance();

    void getParameter(quantity<si::length>& parameter) const;

    void setParameter(const quantity<si::length>& parameter);

    void toString(std::string& value) const;

  private:
    virtual void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    virtual void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    ParameterType getType() const {return this->parameterType;};

    std::string getName() const {return this->name;};

    quantity<si::length> value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Actual position of one gripper bar
///////////////////////////////////////////////////////////////////////////////
class ActualPosition : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    ActualPosition();

    virtual ~ActualPosition();

    void getParameter(int& parameter) const;

    void setParameter(const int parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    int upperLimit;

    int lowerLimit;

    int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Position setpoint for one gripper bar
///////////////////////////////////////////////////////////////////////////////
class PositionSetpoint : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    PositionSetpoint();

    virtual ~PositionSetpoint();

    void getParameter(int& parameter) const;

    void setParameter(const int parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    int upperLimit;

    int lowerLimit;

    int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Indicates that the actual position equals the target position.
///////////////////////////////////////////////////////////////////////////////
class TargetPositionReached : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    TargetPositionReached();

    virtual ~TargetPositionReached();

    void getParameter(bool& parameter) const;

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    bool value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Actual velocity of one gripper bar
///////////////////////////////////////////////////////////////////////////////
class ActualVelocity : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    ActualVelocity();

    virtual ~ActualVelocity();

    void getParameter(int& parameter) const;

    void setParameter(const int parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    int upperLimit;

    int lowerLimit;

    int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Velocity setpoint for one gripper bar
///////////////////////////////////////////////////////////////////////////////
class VelocitySetpoint : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    VelocitySetpoint();

    virtual ~VelocitySetpoint();

    void getParameter(int& parameter) const;

    void setParameter(const int parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    int upperLimit;

    int lowerLimit;

    int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Readout of the actual load value with used for stall detection (stallGuard2).

///////////////////////////////////////////////////////////////////////////////
class ActualLoadValue : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    ActualLoadValue();

    virtual ~ActualLoadValue();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Selects the comparator blank time. This time needs to safely cover the switching event and the duration of the ringing on the sense resistor. For low current drivers, a setting of 1 or 2 is good.

///////////////////////////////////////////////////////////////////////////////
class ChopperBlankTime : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    ChopperBlankTime();

    virtual ~ChopperBlankTime();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Hysteresis decrement setting. This setting determines the slope of the hysteresis during on time and during fast decay time.
/// 0   fast decrement
/// 3   very slow decrement

///////////////////////////////////////////////////////////////////////////////
class ChopperHysteresisDecrement : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    ChopperHysteresisDecrement();

    virtual ~ChopperHysteresisDecrement();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
///  Hysteresis end setting. Sets the hysteresis end value after a number of decrements. Decrement interval time is controlled by axis parameter 164.
///  -3... -1 negative hysteresis end setting
///  0   zero hysteresis end setting
///  1... 12 positive hysteresis end setting
///////////////////////////////////////////////////////////////////////////////
class ChopperHysteresisEnd : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    ChopperHysteresisEnd();

    virtual ~ChopperHysteresisEnd();

    void getParameter(int& parameter) const;

    void setParameter(const int parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    int upperLimit;

    int lowerLimit;

    int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
///  Hysteresis start setting. Please remark, that this  value is an offset to the hysteresis end value.
///////////////////////////////////////////////////////////////////////////////
class ChopperHysteresisStart : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    ChopperHysteresisStart();

    virtual ~ChopperHysteresisStart();

    void getParameter(int& parameter) const;

    void setParameter(const int parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    int upperLimit;

    int lowerLimit;

    int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Selection of the chopper mode:
/// 0   spread cycle
/// 1   classic const. off time

///////////////////////////////////////////////////////////////////////////////
class ChopperMode : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    ChopperMode();

    virtual ~ChopperMode();

    void getParameter(bool& parameter) const;

    void setParameter(const bool parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    bool value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// The off time setting controls the minimum chopper frequency. An off time within the range of 5 s to 20 s will fit.
/// Off time setting for constant tOFF chopper:
/// NCLK= 12 + 32*tOFF (Minimum is 64 clocks)
//// Setting this parameter to zero completely disables all driver transistors and the motor can free-wheel.

///////////////////////////////////////////////////////////////////////////////
class ChopperOffTime : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    ChopperOffTime();

    virtual ~ChopperOffTime();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
///  Every edge of the cycle releases a step/microstep. It does not make sense to activate this parameter for internal use. Double step enable can be used with Step/Dir interface.
/// 0   double step off
/// 1   double step on

///////////////////////////////////////////////////////////////////////////////
class DoubleStepEnable : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;

  public:
    DoubleStepEnable();

    virtual ~DoubleStepEnable();

    void getParameter(bool& parameter) const;

    void setParameter(const bool parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    bool value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Bit 0: stallGuardTM status
/// (1: threshold reached)
/// Bit 1: Overtemperature
/// (1: driver is shut down due to overtemperature)
/// Bit 2: Pre-warning overtemperature
/// (1: Threshold is exceeded)
/// Bit 3: Short to ground A
/// (1: Short condition etected, driver currently shut down)
/// Bit 4: Short to ground B
/// (1: Short condition detected, driver currently shut down)
/// Bit 5: Open load A
/// (1: no chopper event has happened during the last period with constant coil polarity)
/// Bit 6: Open load B
/// (1: no chopper event has happened during the last period with constant coil polarity)
/// Bit 7: Stand still
/// (1: No step impulse occurred on the step input during the last 2^20 clock cycles)
///////////////////////////////////////////////////////////////////////////////
class ErrorFlags : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    ErrorFlags();

    virtual ~ErrorFlags();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Time after which the power to the motor will be cut when its velocity has reached zero.
/// 0... 65535
/// 0 = never
/// [msec]

///////////////////////////////////////////////////////////////////////////////
class Freewheeling : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    Freewheeling();

    virtual ~Freewheeling();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Acceleration parameter for velocity control and position control
///////////////////////////////////////////////////////////////////////////////
class MaximumAcceleration : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    MaximumAcceleration();

    virtual ~MaximumAcceleration();

    void getParameter(int& parameter) const;

    void setParameter(const int parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    int upperLimit;

    int lowerLimit;

    int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// The most important motor setting, since too high values might cause motor damage! The maximum value is 255. This value means 100% of the maximum current of the module. The current adjustment is within the range 0... 255 and can be adjusted in 32 steps (0... 255 divided by eight; e.g. step 0 = 0... 7, step 1 = 8... 15 and so on).

///////////////////////////////////////////////////////////////////////////////
class MaximumCurrent : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    MaximumCurrent();

    virtual ~MaximumCurrent();

    void getParameter(int& parameter) const;

    void setParameter(const int parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    int upperLimit;

    int lowerLimit;

    int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// The limit for acceleration (and deceleration). Changing this parameter requires re-calculation of the acceleration factor (no. 146) and the acceleration divisor (no. 137), which is done automatically.
///////////////////////////////////////////////////////////////////////////////
class MaximumPositioningSpeed : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    MaximumPositioningSpeed();

    virtual ~MaximumPositioningSpeed();

    void getParameter(int& parameter) const;

    void setParameter(const int parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    int upperLimit;

    int lowerLimit;

    int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// 0: full step
/// 1: half step
/// 2: 4 microsteps
/// 3: 8 microsteps
/// 4: 16 microsteps
/// 5: 32 microsteps
/// 6: 64 microsteps
/// 7: 128 microsteps
/// 8: 256 microsteps
///////////////////////////////////////////////////////////////////////////////
class MicrostepResolution : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;

  public:
    MicrostepResolution();

    virtual ~MicrostepResolution();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Standstill period before the current is changed down to standby current. The standard value is 200 (value equates 2000msec).
///////////////////////////////////////////////////////////////////////////////
class PowerDownDelay : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    PowerDownDelay();

    virtual ~PowerDownDelay();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// The exponent of the scaling factor for the pulse (step) generator   should be de/incremented carefully (in steps of one).
///////////////////////////////////////////////////////////////////////////////
class PulseDivisor : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;

  public:
    PulseDivisor();

    virtual ~PulseDivisor();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// The exponent of the scaling factor for the ramp generator- should be de/incremented carefully (in steps of one).
///////////////////////////////////////////////////////////////////////////////
class RampDivisor : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;

  public:
    RampDivisor();

    virtual ~RampDivisor();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Automatically set when using ROR, ROL, MST and MVP.
/// 0: position mode. Steps are generated, when the parameters actual position and target position differ. Trapezoidal speed ramps are provided.
/// 2: velocity mode. The motor will run continuously and the speed will be changed with constant (maximum) acceleration, if the parameter target speed is changed. For special purposes, the soft mode (value 1) with exponential decrease of speed can be selected.
///////////////////////////////////////////////////////////////////////////////
class RampMode : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;

  public:
    RampMode();

    virtual ~RampMode();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// 0: 3.2 s
/// 1: 1.6 s
/// 2: 1.2 s
/// 3: 0.8 s
/// Use default value!

///////////////////////////////////////////////////////////////////////////////
class ShortDetectionTimer : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    ShortDetectionTimer();

    virtual ~ShortDetectionTimer();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// 0: Short to GND protection is on
/// 1: Short to GND protection is disabled
/// Use default value!

///////////////////////////////////////////////////////////////////////////////
class ShortProtectionDisable : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    ShortProtectionDisable();

    virtual ~ShortProtectionDisable();

    void getParameter(bool& parameter) const;

    void setParameter(const bool parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    bool value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Determines the slope of the motor driver outputs. Set to 2 or 3 for this module or rather use the default value.
/// 0: lowest slope
/// 3: fastest slope

///////////////////////////////////////////////////////////////////////////////
class SlopeControlHighSide : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    SlopeControlHighSide();

    virtual ~SlopeControlHighSide();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Determines the slope of the motor driver outputs. Set identical to slope control high side.

///////////////////////////////////////////////////////////////////////////////
class SlopeControlLowSide : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    SlopeControlLowSide();

    virtual ~SlopeControlLowSide();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// This status value provides the actual motor current setting as controlled by coolStepTM. The value goes up to the CS value and down to the portion of CS as specified by SEIMIN.
/// actual motor current scaling factor:
/// 0 ... 31: 1/32, 2/32, ... 32/32

///////////////////////////////////////////////////////////////////////////////
class SmartEnergyActualCurrent : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    SmartEnergyActualCurrent();

    virtual ~SmartEnergyActualCurrent();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Sets the number of stallGuard2 readings current down above the upper threshold necessary for each step current decrement of the motor current.
/// Number of stallGuard2 measurements per decrement:
/// Scaling: 0... 3: 32, 8, 2, 1
/// 0: slow decrement
/// 3: fast decrement
///////////////////////////////////////////////////////////////////////////////
class SmartEnergyCurrentDownStep : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    SmartEnergyCurrentDownStep();

    virtual ~SmartEnergyCurrentDownStep();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Sets the lower motor current limit for current minimum coolStep operation by scaling the CS (Current Scale, see axis parameter 6) value.
/// minimum motor current:
/// 0   1/2 of CS
/// 1   1/4 of CS
///////////////////////////////////////////////////////////////////////////////
class SmartEnergyCurrentMinimum : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    SmartEnergyCurrentMinimum();

    virtual ~SmartEnergyCurrentMinimum();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Sets the current increment step. The current becomes incremented for each measured stallGuard2 value below the lower threshold (see smartEnergy hysteresis start). current increment step size:
/// Scaling: 0... 3: 1, 2, 4, 8
/// 0: slow increment
/// 3: fast increment / fast reaction to rising load

///////////////////////////////////////////////////////////////////////////////
class SmartEnergyCurrentUpStep : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    SmartEnergyCurrentUpStep();

    virtual ~SmartEnergyCurrentUpStep();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Sets the distance between the lower and the upper threshold for stallGuard2TM reading. Above the upper threshold the motor current becomes decreased.
/// Hysteresis: (smartEnergy hysteresis value + 1) * 32
/// Upper stallGuard2 threshold: (smartEnergy hysteresis start + smartEnergy hysteresis + 1) * 32
///////////////////////////////////////////////////////////////////////////////
class SmartEnergyHysteresis : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    SmartEnergyHysteresis();

    virtual ~SmartEnergyHysteresis();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// The lower threshold for the stallGuard2 value (see smart Energy current up step).

///////////////////////////////////////////////////////////////////////////////
class SmartEnergyHysteresisStart : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    SmartEnergyHysteresisStart();

    virtual ~SmartEnergyHysteresisStart();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Sets the motor current which is used below the threshold speed.

///////////////////////////////////////////////////////////////////////////////
class SmartEnergySlowRunCurrent : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    SmartEnergySlowRunCurrent();

    virtual ~SmartEnergySlowRunCurrent();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Above this speed coolStep becomes enabled.

///////////////////////////////////////////////////////////////////////////////
class SmartEnergyThresholdSpeed : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    SmartEnergyThresholdSpeed();

    virtual ~SmartEnergyThresholdSpeed();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Enables the stallGuard2 filter for more precision of the measurement. If set, reduces the measurement frequency to one measurement per four fullsteps. In most cases it is expedient to set the filtered mode before using coolStep. Use the standard mode for step loss detection.
/// 0   standard mode
/// 1   filtered mode
///////////////////////////////////////////////////////////////////////////////
class StallGuard2FilterEnable : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    StallGuard2FilterEnable();

    virtual ~StallGuard2FilterEnable();

    void getParameter(bool& parameter) const;

    void setParameter(const bool parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    bool value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// This signed value controls stallGuard2 threshold level for stall output and sets the optimum measurement range for readout. A lower value gives a higher sensitivity. Zero is the starting value. A higher value makes stallGuard2 less sensitive and requires more torque to indicate a stall.
/// 0 Indifferent value
/// 1... 63 less sensitivity
/// -1... -64 higher sensitivity
///////////////////////////////////////////////////////////////////////////////
class StallGuard2Threshold : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    StallGuard2Threshold();

    virtual ~StallGuard2Threshold();

    void getParameter(int& parameter) const;

    void setParameter(const int parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    int upperLimit;

    int lowerLimit;

    int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// The current limit two seconds after the motor has stopped.

///////////////////////////////////////////////////////////////////////////////
class StandbyCurrent : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;

  public:
    StandbyCurrent();

    virtual ~StandbyCurrent();

    void getParameter(int& parameter) const;

    void setParameter(const int parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    int upperLimit;

    int lowerLimit;

    int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Step interpolation is supported with a 16 microstep setting only. In this setting, each step impulse at the input causes the execution of 16 times 1/256 microsteps. This way, a smooth motor movement like in 256 microstep resolution is achieved.
/// 0   step interpolation off
/// 1   step interpolation on

///////////////////////////////////////////////////////////////////////////////
class StepInterpolationEnable : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;

  public:
    StepInterpolationEnable();

    virtual ~StepInterpolationEnable();

    void getParameter(bool& parameter) const;

    void setParameter(const bool parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    bool value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Motor stop in case of stall.
///////////////////////////////////////////////////////////////////////////////
class StopOnStall : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    StopOnStall();

    virtual ~StopOnStall();

    void getParameter(bool& parameter) const;

    void setParameter(const bool parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    bool value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// sense resistor voltage based current scaling
/// 0: Full scale sense resistor voltage is 1/18 VDD
/// 1: Full scale sense resistor voltage is 1/36 VDD
/// (refers to a current setting of 31 and DAC value 255)
/// Use default value. Do not change!

///////////////////////////////////////////////////////////////////////////////
class Vsense : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    Vsense();

    virtual ~Vsense();

    void getParameter(unsigned int& parameter) const;

    void setParameter(const unsigned int& parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    unsigned int upperLimit;

    unsigned int lowerLimit;

    unsigned int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// The current acceleration (read only).
///////////////////////////////////////////////////////////////////////////////
class ActualAcceleration : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    ActualAcceleration();

    virtual ~ActualAcceleration();

    void getParameter(int& parameter) const;

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    int upperLimit;

    int lowerLimit;

    int value;

    std::string name;

    ParameterType parameterType;

};
///////////////////////////////////////////////////////////////////////////////
/// Should  always  be  set  1  to  ensure  exact reaching  of  the  target  position.  Do  not change!
///////////////////////////////////////////////////////////////////////////////
class MinimumSpeed : public YouBotGripperParameter {
friend class YouBotGripper;
friend class YouBotGripperBar;
  public:
    MinimumSpeed();

    virtual ~MinimumSpeed();

    void getParameter(int& parameter) const;

    void setParameter(const int parameter);

    void toString(std::string& value) const;

  private:
    void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message) const;

    void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message);

    std::string getName() const {return this->name;};

    ParameterType getType() const {return this->parameterType;};

    int upperLimit;

    int lowerLimit;

    int value;

    std::string name;

    ParameterType parameterType;

};

} // namespace youbot
#endif


text:
import urllib
import urllib2
from bs4 import BeautifulSoup
from flask import Flask, request, jsonify

url = "https://www.youtube.com/results?search_query=nirvana"
response = urllib2.urlopen(url)

html = response.read()
soup = BeautifulSoup(html,"html5lib")
result=[]

for vid in soup.findAll(attrs={'class':'yt-lockup-video'}):

	soup = BeautifulSoup(vid.renderContents(),"html5lib")
	tile_div=soup.find(attrs={'class':'yt-uix-tile-link'})
	#img_src=soup.find(attrs={'class':'yt-thumb video-thumb'}).span.img['src']
	desc_html=soup.find(attrs={'class':'yt-lockup-description'}).decode_contents(formatter="html")

	if tile_div:
		link=tile_div['href']
		title=tile_div['title']
		item={"url":'https://www.youtube.com' + link,"title":title, "desc":desc_html}
		result.append(item)

print result

redpajama_set_name: RedPajamaGithub


text:
#include <stdlib.h>
#include <stdint.h>
#include <zlib.h>

#include "../readstat.h"
#include "../readstat_writer.h"
#include "readstat_sav_compress.h"
#include "readstat_zsav_compress.h"
#include "readstat_zsav_write.h"

readstat_error_t zsav_write_compressed_row(void *writer_ctx, void *row, size_t len) {
    readstat_writer_t *writer = (readstat_writer_t *)writer_ctx;
    zsav_ctx_t *zctx = writer->module_ctx;
    /* Kind of frustrating that SPSS does double compression.  If they just
     * z-compressed the uncompressed data, we could calculate the block count
     * in advance and write out the file in a streaming manner. As things stand
     * we have to build up the file in memory until we know the final block
     * count. A possible streaming solution would be to declare the number of
     * blocks required to hold the maximum possible row-compressed size and
     * then fill out the end with no-op zero bytes (that get z-compressed very
     * small).
     */
    size_t row_len = sav_compress_row(zctx->buffer, row, len, writer);
    int deflate_status = zsav_compress_row(zctx->buffer, row_len,
            writer->current_row + 1 == writer->row_count, zctx);

    if (deflate_status != Z_OK && deflate_status != Z_STREAM_END)
        return READSTAT_ERROR_WRITE;

    return  READSTAT_OK;
}

static readstat_error_t zsav_write_data_header(readstat_writer_t *writer, zsav_ctx_t *zctx) {
    readstat_error_t retval = READSTAT_OK;
    uint64_t zheader_ofs = zctx->zheader_ofs;
    uint64_t ztrailer_ofs = zheader_ofs + 24;
    uint64_t ztrailer_len = 24 + zctx->blocks_count * 24;
    int i;

    for (i=0; i<zctx->blocks_count; i++) {
        zsav_block_t *block = zctx->blocks[i];
        ztrailer_ofs += block->compressed_size;
    }

    if ((retval = readstat_write_bytes(writer, &zheader_ofs, sizeof(uint64_t))) != READSTAT_OK)
        goto cleanup;

    if ((retval = readstat_write_bytes(writer, &ztrailer_ofs, sizeof(uint64_t))) != READSTAT_OK)
        goto cleanup;

    if ((retval = readstat_write_bytes(writer, &ztrailer_len, sizeof(uint64_t))) != READSTAT_OK)
        goto cleanup;

cleanup:
    return retval;
}

static readstat_error_t zsav_write_data_blocks(readstat_writer_t *writer, zsav_ctx_t *zctx) {
    readstat_error_t retval = READSTAT_OK;
    int i;
    for (i=0; i<zctx->blocks_count; i++) {
        zsav_block_t *block = zctx->blocks[i];

        if ((retval = readstat_write_bytes(writer, block->compressed_data, block->compressed_size)) != READSTAT_OK)
            goto cleanup;
    }

cleanup:
    return retval;
}

static readstat_error_t zsav_write_data_trailer(readstat_writer_t *writer, zsav_ctx_t *zctx) {
    readstat_error_t retval = READSTAT_OK;
    int64_t bias = -100;
    int64_t zero = 0;
    int32_t block_size = zctx->uncompressed_block_size;
    int32_t n_blocks = zctx->blocks_count;

    if ((retval = readstat_write_bytes(writer, &bias, sizeof(int64_t))) != READSTAT_OK)
        goto cleanup;

    if ((retval = readstat_write_bytes(writer, &zero, sizeof(int64_t))) != READSTAT_OK)
        goto cleanup;

    if ((retval = readstat_write_bytes(writer, &block_size, sizeof(int32_t))) != READSTAT_OK)
        goto cleanup;

    if ((retval = readstat_write_bytes(writer, &n_blocks, sizeof(int32_t))) != READSTAT_OK)
        goto cleanup;

    int i;
    int64_t uncompressed_ofs = zctx->zheader_ofs;
    int64_t compressed_ofs = zctx->zheader_ofs + 24;
    for (i=0; i<zctx->blocks_count; i++) {
        zsav_block_t *block = zctx->blocks[i];
        int32_t uncompressed_size = block->uncompressed_size;
        int32_t compressed_size = block->compressed_size;

        if ((retval = readstat_write_bytes(writer, &uncompressed_ofs, sizeof(int64_t))) != READSTAT_OK)
            goto cleanup;

        if ((retval = readstat_write_bytes(writer, &compressed_ofs, sizeof(int64_t))) != READSTAT_OK)
            goto cleanup;

        if ((retval = readstat_write_bytes(writer, &uncompressed_size, sizeof(int32_t))) != READSTAT_OK)
            goto cleanup;

        if ((retval = readstat_write_bytes(writer, &compressed_size, sizeof(int32_t))) != READSTAT_OK)
            goto cleanup;

        uncompressed_ofs += uncompressed_size;
        compressed_ofs += compressed_size;
    }

cleanup:
    return retval;
}

readstat_error_t zsav_end_data(void *writer_ctx) {
    readstat_writer_t *writer = (readstat_writer_t *)writer_ctx;
    zsav_ctx_t *zctx = writer->module_ctx;
    readstat_error_t retval = READSTAT_OK;

    retval = zsav_write_data_header(writer, zctx);
    if (retval != READSTAT_OK)
        goto cleanup;

    retval = zsav_write_data_blocks(writer, zctx);
    if (retval != READSTAT_OK)
        goto cleanup;

    retval = zsav_write_data_trailer(writer, zctx);
    if (retval != READSTAT_OK)
        goto cleanup;

cleanup:
    return retval;
}


text:
/********************************************************************************
** Form generated from reading UI file 'cal.ui'
**
** Created by: Qt User Interface Compiler version 5.4.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/

#ifndef UI_CAL_H
#define UI_CAL_H

#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QCalendarWidget>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QWidget>

QT_BEGIN_NAMESPACE

class Ui_calClass
{
public:
    QGridLayout *gridLayout;
    QCalendarWidget *calendarWidget;

    void setupUi(QWidget *calClass)
    {
        if (calClass->objectName().isEmpty())
            calClass->setObjectName(QStringLiteral("calClass"));
        calClass->resize(600, 400);
        gridLayout = new QGridLayout(calClass);
        gridLayout->setSpacing(6);
        gridLayout->setContentsMargins(11, 11, 11, 11);
        gridLayout->setObjectName(QStringLiteral("gridLayout"));
        calendarWidget = new QCalendarWidget(calClass);
        calendarWidget->setObjectName(QStringLiteral("calendarWidget"));

        gridLayout->addWidget(calendarWidget, 0, 0, 1, 1);

        retranslateUi(calClass);

        QMetaObject::connectSlotsByName(calClass);
    } // setupUi

    void retranslateUi(QWidget *calClass)
    {
        calClass->setWindowTitle(QApplication::translate("calClass", "cal", 0));
    } // retranslateUi

};

namespace Ui {
    class calClass: public Ui_calClass {};
} // namespace Ui

QT_END_NAMESPACE

#endif // UI_CAL_H


text:
/**
 * Created by sachg on 3/21/2016.
 */
import {
GraphQLBoolean,
GraphQLEnumType,
GraphQLError,
GraphQLFloat,
GraphQLID,
GraphQLInt,
GraphQLInterfaceType,
GraphQLList,
GraphQLString,
GraphQLObjectType
} from 'graphql'

import {globalIdField} from 'graphql-relay';

import {nodeInterface} from '../nodes';
import User from '../Models/User/userSchema';

var UserType =  new GraphQLObjectType({
    name: 'User',
    description: 'A Character within tuntab ecosystem',
    isTypeOf: (user) => {
        return user instanceof User;},
    fields: ()=> ({

        age:{
            type: GraphQLInt,
            description: "age of the user",
            resolve: (user)=> user.age
        },
        gender:{
            type: GraphQLString,
            description: "User gender MALE or FEMALE",
            resolve: (user)=> {
                return (user.gender)?'MALE':'FEMALE';
            }
        },
        username:{
            type:GraphQLString,
            description: "Users unique name used for sign in",
            resolve: (user)=> user.username
        },
        email: {
            type:GraphQLString,
            description: "User Email",
            resolve: (user) => user.email
        },
        password: {
            type:GraphQLString,
            description: "User password for authentication not sure if its a good thing to sent to the user",
            resolve: (user) => user.password
        },
        timeCreated: {
            type: GraphQLString,
            description: "Time when user joined tuntab",
            resolve: (user) => user.timeCreated
        },
        lastLogin: {
            type: GraphQLString,
            description: "Last time when user was seen",
            resolve: (user) => user.lastLogin
        },
        firstname: {
            type: GraphQLString,
            description: "users first name",
            resolve: (user) => user.name.firstname
        },
        lastname: {
            type: GraphQLString,
            description: "users last name",
            resolve: (user) => user.name.lastname
        },
        photoAlbum: {
            type: GraphQLString,
            description: "users profile photo folder path might use cdn later",
            resolve: (user) => user.photoAlbum
        },
        _id: {
            type:GraphQLString,
            description: "user id on mongoDB",
            resolve: (user) => user._id
        },
        //more to come on here later especially connections
        //TODO: not well polished
        id: globalIdField('User'),
    }),
    interfaces: [nodeInterface]
});

export default UserType;


text:
const { Wifi } = require('../src/index');

async function init () {
    const wifi = new Wifi({
        verbose: true
    });

    await wifi.connect({ ipAddress: 'xx.xx.xx.xx' });
    await wifi.start();

    wifi.stream.subscribe(sample =>
        console.log('sample', sample)
    );
}

init();


text:
<title>
The Associated Press: Djokovic D-Joking Around
</title>
<link rel="Stylesheet" type="text/css" media="screen" href="/hostednews/css/1928673458-screen.css">

<link rel="Stylesheet" type="text/css" media="print" href="/hostednews/css/2567130250-print.css">

Go to Google News

Djokovic D-Joking Around

By  JOHN PYE  ?

1 day ago

MELBOURNE, Australia (AP) ? Novak Djokovic gives a different kind of impression on the court.

Most players have been asked for their impression of the new, blue Plexicushion courts at Melbourne Park.

After Djokovic beat Benjamin Becker 6-0, 6-2, 7-6 (5) Tuesday in his first-round match at the Australian Open, the television commentator implored Djokovic to do one of his impressions of another player ? specifically Maria Sharapova ? that have generated huge attention on YouTube.

At first, he resisted ? "I don't want to offend anybody," he said.

But he soon gave in and did a reasonable imitation, right down to the Russian player's tendency to brush strands of her long blonde hair back over her ears as she prepares to serve.

The crowd gave him a standing ovation, and Djokovic later assured a news conference that Sharapova "doesn't mind" the impersonations.

"She's OK with it," he said.

Third-ranked Djokovic raced through the first set in just 22 minutes, generating sympathy for underdog Becker, who couldn't seem to find anything that worked and won only three points on his serve.

About the only pain that Djokovic suffered early was self-inflicted. He had to call for the trainer after the fifth game to treat a small cut on his left knee from hitting himself with his racket.

Becker, looking increasingly disconsolate and frustrated, got a loud ovation when he held to win his first game. But Djokovic ran off the last four games of the second set.

The third set turned into a struggle.

"I lost my momentum," Djokovic said. "I almost lost that third set, then who knows what would happen?"

Becker broke for the first and only time in the first game at love on a rash of Djokovic errors. Djokovic leveled the set at 2-all when Becker double-faulted on break point.

Becker won the first three points of the tiebreaker. He got an ace on a challenge of a line call to make it 5-5, but sent two forehands wide to finish the match.

The loss continued a stretch of five consecutive first-round exits at Grand Slams for Becker since his upset over Andre Agassi in the fourth round at the 2006 U.S. Open ? the last match of Agassi's career.

No. 10 seed David Nalbandian recovered from back spasms that forced him out of the Kooyong exhibition last week to beat Australian Robert Smeets 6-1, 6-1, 7-6 (3).

Other men advancing included No. 21 Juan Monaco of Argentina and No. 25 Fernando Verdasco of Spain, and Amer Delic beat fellow American Robert Kendrick 6-4, 7-5, 6-2.

Women's No. 6 Anna Chakvetadze only played six points before advancing to the second round when Germany's Andrea Petkovic retired with a leg injury.

No. 9 Daniela Hantuchova advanced 6-3, 7-5 over Vania King of the United States; No. 27 Maria Kirilenko beat American Meilen Tu 6-4, 4-6, 6-3; Caroline Wozniacki of Denmark upset Gisela Dulko of Argentina 6-1, 6-1 and Japan's Akiko Morigami beat Michaella Krajicek 6-2, 6-2.

Top-ranked Federer, aiming for a third consecutive Australian title and claiming to be 100 percent recovered from a stomach virus that interrupted his preparation, had a night match scheduled against Diego Hartfield of Argentina.

Venus Williams was to play China's Yan Zi on Rod Laver Arena in the first night match.

Her sister Serena, the defending champion, started off the season's first major with a 6-3, 6-3 win Monday over wild-card entry Jarmila Gajdosova.

It was her first match back at Rod Laver Arena since a 6-1, 6-2 rout of Maria Sharapova in last year's final, when she became only the second unseeded player and third-lowest ranked (81) player to win a Grand Slam title.

"It definitely feels good to be back," Williams said. "I just thought about last year, my last match on that court, I was able to win it.

"That's all I thought about. I didn't think about the ceremony, holding up the trophy. I just got right back into the swing of things and thought, I have to stay focused."

Sharapova had an opening-round 6-4, 6-3 win over Jelena Kostanic Tosic, insisting that her previous match at Melbourne Park was long forgotten.

"You can't think about what you did in the past years," she said. "You can't think about what your results were. You just got to look forward to what's going to come up."

What's coming up for her is a second-round match against 2000 champion Lindsay Davenport, quickly becoming something of a Supermom after holding off Italy's Sara Errani 6-2, 3-6, 7-5.

She lost her temper at the chair umpire on an overrule and worked through bouts of pressure, but had enough experience to extend her record to 19-1 since returning to the tour following the birth of her son, Jagger, last June.

It also made her the richest prize money earner ever in women's tennis, lifting her career tally to $21,897,501 and surpassing Steffi Graf's total.

Top-seeded Justine Henin also was in action Monday, extending her winning streak to 29 matches when she won the last six games of a 6-2, 6-2 victory over Japan's Aiko Nakamura.

On the men's side, No. 2 Rafael Nadal had to recover from service breaks in each of the first two sets to beat Viktor Troicki of Serbia 7-6 (3), 7-5, 6-1 late Monday.

Hosted by

Copyright ©  2008   The Associated Press. All rights reserved.


text:
package com.hualuo.springmvc;

import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration.Dynamic;

/**
 * @author Joseph
 *
 */
public class WebInitializer implements WebApplicationInitializer {

	/* (non-Javadoc)
	 * @see org.springframework.web.WebApplicationInitializer#onStartup(javax.servlet.ServletContext)
	 */
	public void onStartup(ServletContext servletContext) throws ServletException {
		// TODO Auto-generated method stub
		AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
		context.register(MyMvcConfig.class);
		context.setServletContext(servletContext);
		Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(context));
		servlet.addMapping("/");
		servlet.setLoadOnStartup(1);
		servlet.setAsyncSupported(true);//开启异步方法支持
	}

}


text:
namespace swift {

/// Strip off casts/indexing insts/address projections from V until there is
/// nothing left to strip.
SILValue getUnderlyingObject(SILValue V);

/// Strip off indexing and address projections.
///
/// This is similar to getUnderlyingObject, except that it does not strip any
/// object-to-address projections, like ref_element_addr. In other words, the
/// result is always an address value.
SILValue getUnderlyingAddressRoot(SILValue V);

SILValue getUnderlyingObjectStopAtMarkDependence(SILValue V);

SILValue stripSinglePredecessorArgs(SILValue V);

/// Return the underlying SILValue after stripping off all casts from the
/// current SILValue.
SILValue stripCasts(SILValue V);

/// Return the underlying SILValue after stripping off all casts (but
/// mark_dependence) from the current SILValue.
SILValue stripCastsWithoutMarkDependence(SILValue V);

/// Return the underlying SILValue after stripping off all upcasts from the
/// current SILValue.
SILValue stripUpCasts(SILValue V);

/// Return the underlying SILValue after stripping off all
/// upcasts and downcasts.
SILValue stripClassCasts(SILValue V);

/// Return the underlying SILValue after stripping off all address projection
/// instructions.
SILValue stripAddressProjections(SILValue V);

/// Return the underlying SILValue after stripping off all address projection
/// instructions which have a single operand.
SILValue stripUnaryAddressProjections(SILValue V);

/// Return the underlying SILValue after stripping off all aggregate projection
/// instructions.
///
/// An aggregate projection instruction is either a struct_extract or a
/// tuple_extract instruction.
SILValue stripValueProjections(SILValue V);

/// Return the underlying SILValue after stripping off all indexing
/// instructions.
///
/// An indexing inst is either index_addr or index_raw_pointer.
SILValue stripIndexingInsts(SILValue V);

/// Returns the underlying value after stripping off a builtin expect
/// intrinsic call.
SILValue stripExpectIntrinsic(SILValue V);

} // end namespace swift

#endif


text:
/*
 *  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.
 *  under the License.
 */

package org.kie.camel.component;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.drools.core.command.impl.GenericCommand;
import org.drools.core.command.runtime.BatchExecutionCommandImpl;
import org.drools.core.command.runtime.rule.GetObjectCommand;
import org.drools.core.command.runtime.rule.InsertObjectCommand;
import org.drools.core.common.DefaultFactHandle;
import org.junit.Test;
import org.kie.api.command.BatchExecutionCommand;
import org.kie.api.command.Command;
import org.kie.api.runtime.ExecutionResults;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.rule.FactHandle;
import org.kie.internal.command.CommandFactory;
import org.kie.pipeline.camel.Person;

import javax.naming.Context;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CamelEndpointTest extends KieCamelTestSupport {
    private String handle;

    @Test
    public void testSessionInsert() throws Exception {
        Person person = new Person();
        person.setName( "Mauricio" );

        InsertObjectCommand cmd = (InsertObjectCommand) CommandFactory.newInsert( person,
                                                                                "salaboy" );

        ExecutionResults response = (ExecutionResults) template.requestBody( "direct:test-with-session",
                                                                             cmd );
        assertTrue( "Expected valid ExecutionResults object",
                    response != null );
        assertTrue( "ExecutionResults missing expected fact",
                    response.getFactHandle( "salaboy" ) != null );
        assertTrue( "ExecutionResults missing expected fact",
                    response.getFactHandle( "salaboy" ) instanceof FactHandle );
    }

    @Test
    public void testSessionInsertWithHeaders() throws Exception {

        MockEndpoint mockResult = context.getEndpoint( "mock:resultWithHeader",
                                                       MockEndpoint.class );

        Person person = new Person();
        person.setName( "Mauricio" );

        InsertObjectCommand cmd = (InsertObjectCommand) CommandFactory.newInsert( person,
                                                                                "salaboy" );

        Map<String, Object> headers = new HashMap<String, Object>();
        headers.put( "testHeaderName",
                     "testHeaderValue" );

        template.requestBodyAndHeaders( "direct:test-with-session-withHeader",
                              cmd,headers );

        ExecutionResults response = mockResult.getReceivedExchanges().get( 0 ).getIn().getBody( ExecutionResults.class );

        assertTrue( "Expected valid ExecutionResults object",
                    response != null );
        assertTrue( "ExecutionResults missing expected fact",
                    response.getFactHandle( "salaboy" ) != null );
        assertTrue( "ExecutionResults missing expected fact",
                    response.getFactHandle( "salaboy" ) instanceof FactHandle );
        mockResult.assertIsSatisfied();
    }

    @Test
    public void testNoSessionInsert() throws Exception {
        Person person = new Person();
        person.setName( "Mauricio" );

        InsertObjectCommand cmd = (InsertObjectCommand) CommandFactory.newInsert( person,
                                                                                "salaboy" );

        ExecutionResults response = (ExecutionResults) template.requestBodyAndHeader( "direct:test-no-session",
                                                                                cmd,
                                                                                KieComponent.KIE_LOOKUP,
                                                                                "ksession1" );
        assertTrue( "Expected valid ExecutionResults object",
                    response != null );
        assertTrue( "ExecutionResults missing expected fact",
                    response.getFactHandle( "salaboy" ) != null );
    }

    @Test
    public void testNoSessionInsertWithHeaders() throws Exception {

        MockEndpoint mockResult = context.getEndpoint( "mock:resultWithHeader",
                                                       MockEndpoint.class );

        String headerName = "testHeaderName";
        String headerValue = "testHeaderValue";

        Person person = new Person();
        person.setName( "Mauricio" );

        InsertObjectCommand cmd = (InsertObjectCommand) CommandFactory.newInsert( person,
                                                                                "salaboy" );

        Map<String, Object> headers = new HashMap<String, Object>();
        headers.put( headerName,
                     headerValue );
        headers.put( KieComponent.KIE_LOOKUP,
                     "ksession1" );

        // set mock expectations
        mockResult.expectedMessageCount( 1 );
        mockResult.expectedHeaderReceived( headerName,
                                           headerValue );

        template.requestBodyAndHeaders( "direct:test-no-session-withHeader",
                                        cmd,
                                        headers );

        ExecutionResults response = mockResult.getReceivedExchanges().get( 0 ).getIn().getBody( ExecutionResults.class );

        assertTrue( "Expected valid ExecutionResults object",
                    response != null );
        assertTrue( "ExecutionResults missing expected fact",
                    response.getFactHandle( "salaboy" ) != null );

        mockResult.assertIsSatisfied();
    }

    @Test
    public void testSessionBatchExecutionCommand() throws Exception {
        Person john = new Person();
        john.setName( "John Smith" );

        List<Command> commands = new ArrayList<Command>();
        commands.add( CommandFactory.newInsert( john,
                                                "john" ) );
        BatchExecutionCommand batchExecutionCommand = CommandFactory.newBatchExecution( commands );

        ExecutionResults response = (ExecutionResults) template.requestBody( "direct:test-with-session",
                                                                             batchExecutionCommand );
        assertTrue( "Expected valid ExecutionResults object",
                    response != null );
        assertTrue( "ExecutionResults missing expected fact",
                    response.getFactHandle( "john" ) != null );
        assertTrue( "ExecutionResults missing expected fact",
                    response.getFactHandle( "john" ) instanceof FactHandle );
    }

    @Test
    public void testSessionBatchExecutionCommandWithHeader() throws Exception {

        MockEndpoint mockResult = context.getEndpoint( "mock:resultWithHeader",
                                                       MockEndpoint.class );

        String headerName = "testHeaderName";
        String headerValue = "testHeaderValue";

        Person john = new Person();
        john.setName( "John Smith" );

        List<Command> commands = new ArrayList<Command>();
        commands.add( CommandFactory.newInsert( john,
                                                "john" ) );
        BatchExecutionCommand batchExecutionCommand = CommandFactory.newBatchExecution( commands );

        Map<String, Object> headers = new HashMap<String, Object>();
        headers.put( headerName,
                     headerValue );

        // set mock expectations
        mockResult.expectedMessageCount( 1 );
        mockResult.expectedHeaderReceived( headerName,
                                           headerValue );

        //do test
        template.requestBodyAndHeaders( "direct:test-with-session-withHeader",
                                        batchExecutionCommand,
                                        headers );

        ExecutionResults response = mockResult.getReceivedExchanges().get( 0 ).getIn().getBody( ExecutionResults.class );

        assertTrue( "Expected valid ExecutionResults object",
                    response != null );
        assertTrue( "ExecutionResults missing expected fact",
                    response.getFactHandle( "john" ) != null );
        assertTrue( "ExecutionResults missing expected fact",
                    response.getFactHandle( "john" ) instanceof FactHandle );

        mockResult.assertIsSatisfied();
    }

    @Test
    public void testSessionGetObject() throws Exception {
        FactHandle factHandle = DefaultFactHandle.createFromExternalFormat( handle );
        GetObjectCommand cmd = (GetObjectCommand) CommandFactory.newGetObject( factHandle );
        cmd.setOutIdentifier( "rider" );

        ExecutionResults response = (ExecutionResults) template.requestBody( "direct:test-with-session",
                                                                             cmd );
        assertTrue( "Expected valid ExecutionResults object",
                    response != null );
        assertTrue( "ExecutionResults missing expected object",
                    response.getValue( "rider" ) != null );
        assertTrue( "FactHandle object not of expected type",
                    response.getValue( "rider" ) instanceof Person );
        assertEquals( "Hadrian",
                      ((Person) response.getValue( "rider" )).getName() );
    }

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            public void configure() throws Exception {
                from( "direct:test-with-session" ).to( "kie://ksession1" );
                from( "direct:test-no-session" ).to( "kie://dynamic" );
                from( "direct:test-with-session-withHeader" ).to( "kie://ksession1" ).to( "mock:resultWithHeader" );
                from( "direct:test-no-session-withHeader" ).to( "kie://dynamic" ).to( "mock:resultWithHeader" );
            }
        };
    }

    @Override
    protected void configureDroolsContext(Context jndiContext) {
        Person me = new Person();
        me.setName( "Hadrian" );

        KieSession ksession = registerKnowledgeRuntime( "ksession1",
                                                        null );
        InsertObjectCommand cmd = new InsertObjectCommand( me );
        cmd.setOutIdentifier( "camel-rider" );
        cmd.setReturnObject( false );
        BatchExecutionCommandImpl script = new BatchExecutionCommandImpl( Arrays.asList( new GenericCommand< ? >[]{cmd} ) );

        ExecutionResults results = ksession.execute( script );
        handle = ((FactHandle) results.getFactHandle( "camel-rider" )).toExternalForm();
    }
}


text:
/**
 * NotFound
 *
 * This is the view we show when the user visits a url that doesn't have a route
 *
 * NOTE: while this component should technically be a stateless functional
 * component (SFC), hot reloading does not currently support SFCs. If hot
 * reloading is not a necessity for you then you can refactor it and remove
 * the linting exception.
 */

import React from 'react';
import styled from 'styled-components';
import FullWrapper from 'components/FullWrapper';
import SmallWrapper from 'components/SmallWrapper';
import Logo from 'components/Logo';
import H1 from 'components/H1';
import H3 from 'components/H3';
import A from 'components/A';

import messages from './messages';

const Wrapper = styled.section`
  display: flex;
  justify-content: center;
  flex-direction: column;
  min-height: 100vh;
`;

const Header = styled.header`
  flex: 2;
`;

const Body = styled.section`
  flex: 2;
`;

const Footer = styled.section`
  flex: 1;
`;

export default class NotFound extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
  render() {
    return (
      <FullWrapper className={'map-bg full-page'}>
        <FullWrapper className={'gradient-bg opaque'}>
          <SmallWrapper className={'centered-text'} padding>
            <Wrapper>

                <Logo />

{ messages.messages.title.defaultMessage }

{ messages.messages.intro.defaultMessage }

{ messages.messages.desc.defaultMessage }

                { messages.messages.action.defaultMessage }

            </Wrapper>
          </SmallWrapper>
        </FullWrapper>
      </FullWrapper>
    );
  }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <stroke android:width="3px" android:color="#CCCCCC" />
    <padding android:left="2px" android:top="2px"
            android:right="2px" android:bottom="2px" />
    <corners android:radius="2px" />
</shape>


text:
/* */
define(['exports', './dialog-renderer', './ai-dialog', './ai-dialog-header', './ai-dialog-body', './ai-dialog-footer', './attach-focus', './dialog-service', './dialog-controller'], function (exports, _dialogRenderer, _aiDialog, _aiDialogHeader, _aiDialogBody, _aiDialogFooter, _attachFocus, _dialogService, _dialogController) {
  'use strict';

  exports.__esModule = true;
  exports.configure = configure;

  function _interopExportWildcard(obj, defaults) { var newObj = defaults({}, obj); delete newObj['default']; return newObj; }

  function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }

  exports.AiDialog = _aiDialog.AiDialog;
  exports.AiDialogHeader = _aiDialogHeader.AiDialogHeader;
  exports.AiDialogBody = _aiDialogBody.AiDialogBody;
  exports.AiDialogFooter = _aiDialogFooter.AiDialogFooter;
  exports.AttachFocus = _attachFocus.AttachFocus;

  function configure(config, callback) {
    config.globalResources('./ai-dialog', './ai-dialog-header', './ai-dialog-body', './ai-dialog-footer', './attach-focus');
    if (typeof callback === 'function') {
      callback(_dialogRenderer.globalSettings);
    }
  }

  _defaults(exports, _interopExportWildcard(_dialogService, _defaults));

  _defaults(exports, _interopExportWildcard(_dialogController, _defaults));
});


text:
Userbase::Application.configure do
  # Settings specified here will take precedence over those in config/environment.rb

  # In the development environment your application's code is reloaded on
  # every request.  This slows down response time but is perfect for development
  # since you don't have to restart the webserver when you make code changes.
  config.cache_classes = false

  # Log error messages when you accidentally call methods on nil.
  config.whiny_nils = true

  # Show full error reports and disable caching
  config.consider_all_requests_local       = true
  config.action_view.debug_rjs             = true
  config.action_controller.perform_caching = false

  # Mailersetup
  config.action_mailer.raise_delivery_errors = true

  ActionMailer::Base.smtp_settings = {
    :address              => MAILSERVER_ADDRESS,
    :port                 => MAILSERVER_PORT,
    :domain               => MAILSERVER_DOMAIN,
    :user_name            => MAILSERVER_USERNAME,
    :password             => MAILSERVER_PASSWORD,
    :authentication       => "plain",
    :enable_starttls_auto => false
  }

  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
  config.active_support.deprecation = :stderr

  Paperclip.options[:command_path] = "/opt/local/bin"
  #Paperclip.options[:swallow_stderr] = false

end


text:
package intra

import (
	"fmt"

	"golang.org/x/net/context"

	"github.com/poy/loggrebutterfly/api/intra"
)

type Executor interface {
	Execute(fileName, algName string, ctx context.Context, meta []byte) (result map[string][]byte, err error)
}

type Server struct {
	exec Executor
}

func New(e Executor) *Server {
	return &Server{
		exec: e,
	}
}

func (s *Server) Execute(ctx context.Context, info *intra.ExecuteInfo) (resp *intra.ExecuteResponse, err error) {
	if info.File == "" {
		return nil, fmt.Errorf("File is required")
	}

	if info.Alg == "" {
		return nil, fmt.Errorf("Alg is required")
	}

	results, err := s.exec.Execute(info.File, info.Alg, ctx, info.Meta)
	if err != nil {
		return nil, err
	}

	return &intra.ExecuteResponse{
		Result: results,
	}, nil
}


text:
package com.google.code.yanf4j.nio.impl;

import java.io.IOException;
import java.net.InetAddress;
import java.nio.ByteBuffer;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.nio.channels.WritableByteChannel;
import com.google.code.yanf4j.buffer.IoBuffer;
import com.google.code.yanf4j.core.EventType;
import com.google.code.yanf4j.core.WriteMessage;
import com.google.code.yanf4j.core.impl.AbstractSession;
import com.google.code.yanf4j.nio.NioSession;
import com.google.code.yanf4j.nio.NioSessionConfig;
import com.google.code.yanf4j.util.SelectorFactory;

/**
 * Abstract nio session
 *
 * @author dennis
 *
 */
public abstract class AbstractNioSession extends AbstractSession implements NioSession {

  public SelectableChannel channel() {
    return selectableChannel;
  }

  protected SelectorManager selectorManager;
  protected SelectableChannel selectableChannel;

  public AbstractNioSession(NioSessionConfig sessionConfig) {
    super(sessionConfig);
    selectorManager = sessionConfig.selectorManager;
    selectableChannel = sessionConfig.selectableChannel;
  }

  public final void enableRead(Selector selector) {
    SelectionKey key = selectableChannel.keyFor(selector);
    if (key != null && key.isValid()) {
      interestRead(key);
    } else {
      try {
        selectableChannel.register(selector, SelectionKey.OP_READ, this);
      } catch (ClosedChannelException e) {
        // ignore
      } catch (CancelledKeyException e) {
        // ignore
      }
    }
  }

  private void interestRead(SelectionKey key) {
    if (key.attachment() == null) {
      key.attach(this);
    }
    key.interestOps(key.interestOps() | SelectionKey.OP_READ);
  }

  @Override
  protected void start0() {
    registerSession();
  }

  public InetAddress getLocalAddress() {
    return ((SocketChannel) selectableChannel).socket().getLocalAddress();
  }

  protected abstract Object writeToChannel(WriteMessage msg)
      throws ClosedChannelException, IOException;

  protected void onWrite(SelectionKey key) {
    boolean isLockedByMe = false;
    if (currentMessage.get() == null) {
      // get next message
      WriteMessage nextMessage = writeQueue.peek();
      if (nextMessage != null && writeLock.tryLock()) {
        if (!writeQueue.isEmpty() && currentMessage.compareAndSet(null, nextMessage)) {
          writeQueue.remove();
        }
      } else {
        return;
      }
    } else if (!writeLock.tryLock()) {
      return;
    }

    isLockedByMe = true;
    WriteMessage currentMessage = null;

    final long maxWritten = readBuffer.capacity() + readBuffer.capacity() >>> 1;
    try {
      long written = 0;
      while (this.currentMessage.get() != null) {
        currentMessage = this.currentMessage.get();
        currentMessage = preprocessWriteMessage(currentMessage);
        this.currentMessage.set(currentMessage);
        long before = this.currentMessage.get().getWriteBuffer().remaining();
        Object writeResult = null;

        if (written < maxWritten) {
          writeResult = writeToChannel(currentMessage);
          written += this.currentMessage.get().getWriteBuffer().remaining() - before;
        } else {
          // wait for next time to write
        }
        // write complete
        if (writeResult != null) {
          this.currentMessage.set(writeQueue.poll());
          handler.onMessageSent(this, currentMessage.getMessage());
          // try to get next message
          if (this.currentMessage.get() == null) {
            if (isLockedByMe) {
              isLockedByMe = false;
              writeLock.unlock();
            }
            // get next message
            WriteMessage nextMessage = writeQueue.peek();
            if (nextMessage != null && writeLock.tryLock()) {
              isLockedByMe = true;
              if (!writeQueue.isEmpty() && this.currentMessage.compareAndSet(null, nextMessage)) {
                writeQueue.remove();
              }
              continue;
            } else {
              break;
            }
          }
        } else {
          // does't write complete
          if (isLockedByMe) {
            isLockedByMe = false;
            writeLock.unlock();
          }
          // register OP_WRITE event
          selectorManager.registerSession(this, EventType.ENABLE_WRITE);
          break;
        }
      }
    } catch (IOException e) {
      handler.onExceptionCaught(this, e);
      if (currentMessage != null && currentMessage.getWriteFuture() != null) {
        currentMessage.getWriteFuture().failure(e);
      }
      if (isLockedByMe) {
        isLockedByMe = false;
        writeLock.unlock();
      }
      close();
    } finally {
      if (isLockedByMe) {
        writeLock.unlock();
      }
    }
  }

  public final void enableWrite(Selector selector) {
    SelectionKey key = selectableChannel.keyFor(selector);
    if (key != null && key.isValid()) {
      interestWrite(key);
    } else {
      try {
        selectableChannel.register(selector, SelectionKey.OP_WRITE, this);
      } catch (ClosedChannelException e) {
        // ignore
      } catch (CancelledKeyException e) {
        // ignore
      }
    }
  }

  private void interestWrite(SelectionKey key) {
    if (key.attachment() == null) {
      key.attach(this);
    }
    key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
  }

  protected void onRead(SelectionKey key) {
    readFromBuffer();
  }

  protected abstract void readFromBuffer();

  @Override
  protected void closeChannel() throws IOException {
    flush0();
    unregisterSession();
    unregisterChannel();
  }

  protected final void unregisterChannel() throws IOException {
    writeLock.lock();
    try {
      if (getAttribute(SelectorManager.REACTOR_ATTRIBUTE) != null) {
        ((Reactor) getAttribute(SelectorManager.REACTOR_ATTRIBUTE))
            .unregisterChannel(selectableChannel);
      }
      if (selectableChannel.isOpen()) {
        selectableChannel.close();
      }
    } finally {
      writeLock.unlock();
    }
  }

  protected final void registerSession() {
    selectorManager.registerSession(this, EventType.REGISTER);
  }

  protected void unregisterSession() {
    selectorManager.registerSession(this, EventType.UNREGISTER);
  }

  @Override
  public void writeFromUserCode(WriteMessage message) {
    if (schduleWriteMessage(message)) {
      return;
    }
    onWrite(null);
  }

  protected boolean schduleWriteMessage(WriteMessage writeMessage) {
    boolean offered = writeQueue.offer(writeMessage);
    assert offered;
    final Reactor reactor = selectorManager.getReactorFromSession(this);
    if (Thread.currentThread() != reactor) {
      selectorManager.registerSession(this, EventType.ENABLE_WRITE);
      return true;
    }
    return false;
  }

  public void flush() {
    if (isClosed()) {
      return;
    }
    flush0();
  }

  protected final void flush0() {
    SelectionKey tmpKey = null;
    Selector writeSelector = null;
    int attempts = 0;
    try {
      while (true) {
        if (writeSelector == null) {
          writeSelector = SelectorFactory.getSelector();
          if (writeSelector == null) {
            return;
          }
          tmpKey = selectableChannel.register(writeSelector, SelectionKey.OP_WRITE);
        }
        if (writeSelector.select(1000) == 0) {
          attempts++;
          if (attempts > 2) {
            return;
          }
        } else {
          break;
        }
      }
      onWrite(selectableChannel.keyFor(writeSelector));
    } catch (ClosedChannelException cce) {
      onException(cce);
      log.error("Flush error", cce);
      close();
    } catch (IOException ioe) {
      onException(ioe);
      log.error("Flush error", ioe);
      close();
    } finally {
      if (tmpKey != null) {
        // Cancel the key.
        tmpKey.cancel();
        tmpKey = null;
      }
      if (writeSelector != null) {
        try {
          writeSelector.selectNow();
        } catch (IOException e) {
          log.error("Temp selector selectNow error", e);
        }
        // return selector
        SelectorFactory.returnSelector(writeSelector);
      }
    }
  }

  protected final long doRealWrite(SelectableChannel channel, IoBuffer buffer) throws IOException {
    if (log.isDebugEnabled()) {
      StringBuffer bufMsg = new StringBuffer("send buffers:\n[\n");
      final ByteBuffer buff = buffer.buf();
      bufMsg.append(" buffer:position=").append(buff.position()).append(",limit=")
          .append(buff.limit()).append(",capacity=").append(buff.capacity()).append("\n");

      bufMsg.append("]");
      log.debug(bufMsg.toString());
    }
    return ((WritableByteChannel) channel).write(buffer.buf());
  }

  /**
   * �ɷ�IO�¼�
   */
  public final void onEvent(EventType event, Selector selector) {
    if (isClosed()) {
      return;
    }
    SelectionKey key = selectableChannel.keyFor(selector);

    switch (event) {
      case EXPIRED:
        onExpired();
        break;
      case WRITEABLE:
        onWrite(key);
        break;
      case READABLE:
        onRead(key);
        break;
      case ENABLE_WRITE:
        enableWrite(selector);
        break;
      case ENABLE_READ:
        enableRead(selector);
        break;
      case IDLE:
        onIdle();
        break;
      case CONNECTED:
        onConnected();
        break;
      default:
        log.error("Unknown event:" + event.name());
        break;
    }
  }
}