Beispiel #1
0
TVariant::TVariant(Tango::DeviceAttribute &attr){
    isAttribute = true;
    dataFormat = attr.get_data_format();

    if (attr.is_empty())
    {
        //qDebug() << QThread::currentThread() << ":" << this << "setDeviceAttribute() - device attribute is empty";
       // setMessage("device attribute is empty");
        d_quality = Tango::ATTR_INVALID;
        return;
    }
    /* attribute data type, if attribute is not empty */
    d_type = (Tango::CmdArgType) attr.get_type();

    if (attr.has_failed())
    {
        //qDebug() << QThread::currentThread() << ":" << this << "setDeviceAttribute() - read_attribute has failed";
       // setMessage(attr.get_err_stack());
        d_quality = Tango::ATTR_INVALID;
        return;
    }
 try {
   // if (dataFormat == Tango::IMAGE){
       // vec.clear();

        dimX = attr.get_dim_x();
        dimY = attr.get_dim_y();
       // if (d_type != DEV_UCHAR){  ///DEV_USHORT
        if (d_type == Tango::DEV_USHORT){  ///DEV_USHORT

           dataReadUShortVector.clear();
            vector<unsigned short> tempVector16;
            attr >> tempVector16;
            int count = tempVector16.size();
            unsigned short *ushortPtr = &tempVector16[0];
            dataReadUShortVector.resize(count);
            unsigned short * ptrData = &dataReadUShortVector[0];

            for(int i=0; i<count; i++){
               *ptrData = *(ushortPtr+i); ptrData++;}

        //    attr >> tempVector16;//dataReadUShortVector;
            return;
        }
        if (d_type == Tango::DEV_UCHAR){
            dataReadUCharVector.clear();
           vector<unsigned char> tempVector;
           tempVector.resize(dimX*dimY);
            attr >> tempVector;
            int count = tempVector.size();
            dataReadUCharVector.resize(count);
            unsigned char * ptrData = &dataReadUCharVector[0];
            unsigned char *ucharPtr = &tempVector[0];
            for(int i=0; i<count; i++){
                *ptrData = *(ucharPtr+i); ptrData++;}

         //   attr >> dataReadUCharVector;
            return;
   //     }
    }
void TrendDataCollector::updateCurve()
{
    qDebug() << "Update of " << this->mAttributeName << " with ";
    Tango::DeviceAttribute attr;
    if (this->mAttribute != nullptr)
    {
        attr=this->mAttribute->read();
        Tango::TimeVal tv;
        tv = attr.get_date();
        double data, t;
        int ty = attr.get_type();
        if (ty == Tango::DEV_DOUBLE || ty == Tango::DEV_FLOAT)
        {
            attr >> data;
        }