示例#1
1
void DecodeVideo::run()
{
    int frameFinished = 0;
    AVFrame *pFrame = avcodec_alloc_frame();
    SDL_LockMutex(mutex);
    avcodec_decode_video(pCodecCtx, pFrame, &frameFinished,packet.data,packet.size);
    SDL_UnlockMutex(mutex);

    AVFrame *pFrameRGB;
    pFrameRGB = avcodec_alloc_frame();
    avpicture_fill((AVPicture *)pFrameRGB, bufferRGB, PIX_FMT_RGB24,pCodecCtx->width, pCodecCtx->height);

    /*
     * 最後再整理一次,要使用swscale,
     * 只要使用 sws_getContext() 進行初始化、
     * sws_scale() 進行主要轉換、
     * sws_freeContext() 結束,即可完成全部動作。
     */


    /*
     * SwsContext *
     * sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat,
     *                int dstW, int dstH, enum PixelFormat dstFormat,
     *                int flags, SwsFilter *srcFilter,
     *                SwsFilter *dstFilter, const double *param)
     * 總共有十個參數,其中,較重要的是前七個;
     * 前三個參數分別代表 原视频 的寬、高及PixelFormat;
     * 四到六個參數分別代表 目标视频 的寬、高及PixelFormat;
     * 第七個參數則代表要使用哪種scale的方法;此參數可用的方法可在 libswscale/swscale.h 內找到。
     *
     *
     * 个人建议,如果对图像的缩放,要追求高效,比如说是视频图像的处理,在不明确是放大还是缩小时,
     * 直接使用 SWS_FAST_BILINEAR 算法即可。
     * 如果明确是要缩小并显示,建议使用Point算法,如果是明确要放大并显示,其实使用CImage的Strech更高效。
     * 当然,如果不计速度追求画面质量。在上面的算法中,选择帧率最低的那个即可,画面效果一般是最好的。
     *
     * 最後三個參數,如無使用,可以都填上NULL。
     */

    SwsContext *convert_ctx = sws_getContext(width,height,pix_fmt,
                              width,height,PIX_FMT_RGB24,
                              SWS_BICUBIC,         // SWS_FAST_BILINEAR or SWS_BICUBIC
                              NULL,NULL,NULL);
    /*
     * int
     * sws_scale(SwsContext *c,
     *           uint8_t* src[],
     *           int srcStride[],
     *           int srcSliceY,
     *           int srcSliceH,
     *           uint8_t* dst[],
     *           int dstStride[]);
     * 總共有七個參數;
     * 第一個參數即是由 sws_getContext 所取得的參數。
     *
     * 第二個 src 及第六個 dst 分別指向input 和 output 的 buffer。
     * 第三個 srcStride 及第七個 dstStride 分別指向 input 及 output 的 stride
     *
     *    如果不知道什麼是 stride,姑且可以先把它看成是每一列的 byte 數。
     * 第四個 srcSliceY,就註解的意思來看,是指第一列要處理的位置;這裡我是從頭處理,所以直接填0。
     *    想知道更詳細說明的人,可以參考 swscale.h 的註解。
     * 第五個srcSliceH指的是 source slice 的高度。
     */

    sws_scale(convert_ctx,
              (const uint8_t*  const*)pFrame->data,
              pFrame->linesize,
              0,
              height,
              pFrameRGB->data,
              pFrameRGB->linesize);

    //! 这里正式获取视频帧

    QImage tmpImage((uchar *)bufferRGB,width,height,QImage::Format_RGB888);
    emit readOneFrame(QPixmap::fromImage(tmpImage),width,height);

    av_free(pFrameRGB);
    sws_freeContext(convert_ctx);

    av_free_packet(&packet);
}
示例#2
0
UINT8 xl618::muTest(pMUTYPE mu)
{

        UINT8 retValue = ERR_UNIVERSAL;
        char *pSend = (char*)sendBuf;
        strcpy(pSend,STR_MU CR);
        pSend += strlen(STR_MU CR);

        UINT16 frameSize = pSend - (char*)sendBuf;

        if((retValue = readOneFrame(frameSize,(char*)"MU",NULL,(char*)"MUACK",0)) == ERR_RIGHT)
        {//解析帧
                char *temp = 0;

                temp = strstr((char*)recvBuf,"FRAME_DELAY;");
                if(temp)
                        mu->frame_delay = (FLOAT32)atof(&temp[strlen("FRAME_DELAY;")]);

                temp = strstr((char*)recvBuf,"CLOCLK_DELT;");
                if(temp)
                        mu->cloclk_delay = (FLOAT32)atof(&temp[strlen("CLOCLK_DELT;")]);

                temp = strstr((char*)recvBuf,"DELAYSHAKE;");
                if(temp)
                        mu->delayshake = (FLOAT32)atof(&temp[strlen("DELAYSHAKE;")]);
        }

        return retValue;
}
示例#3
0
 UINT8 xl618:: setUPG(GSE_UPGTYPE data[],int rowCount)
{
    // char * temp="100000000000";

     UINT8 retValue = ERR_UNIVERSAL;
     char *pSend = (char*)sendBuf;
     strcpy(pSend,STR_UPG CR "ALLDATA0;");
     pSend += strlen(STR_UPG CR "ALLDATA0;");

    // printf("rowCount=%d\n",rowCount);

     for(int i=0;i<rowCount;i++)
     {
      //  pSend += sprintf(pSend,"%s",temp);
       memcpy(pSend, &data[i], sizeof(data[i]));
       //printf("GSE_UPGTYPE%d\n", data[i].DA1.stVal );
       pSend += sizeof(data[i]);
       //printf(" sizeof(&data[i])=%d", sizeof(data[i]));
     }
      memcpy(pSend, CR , sizeof(CR));

    UINT16 frameSize = pSend - (char*)sendBuf;
    retValue = readOneFrame(frameSize,(char*)"UPG",NULL,(char*)"CRACK",0);

     return retValue;

}
示例#4
0
 UINT8 xl618::GSEFrame(pGSE_FRAMETYPE data)
 {
     UINT8 retValue = ERR_UNIVERSAL;
     char *pSend = (char*)sendBuf;
     UINT16 frameSize;
     char *temp;

     pSend += sprintf(pSend,"GOOSEFRAME\r\n");

     frameSize = pSend - (char*)sendBuf;

    if((retValue = readOneFrame(frameSize,(char*)"GOOSEFRAME",NULL,NULL,1)) == ERR_RIGHT)
    {
        temp = strstr((char*)recvBuf,"DATA;");
        INT32 size = dataSize - (temp - (char*)recvBuf);//不要前面几个字节

         if(temp)
         {
                 if(size <= 3000) //判断是否够存放
                 {
                     memcpy(data->frame,&temp[strlen("DATA;")],size-20);//去掉GOOSEFRAME字节
                    // data->frame_size=size-12;
                         //memcpy(data->frame,&temp[strlen("DATA;")],size);
                 }else

                         retValue = ERR_BUFFER;
         }

    }else
         retValue = ERR_BUFFER;
     return retValue;
 }
示例#5
0
UINT8 xl618::getSvID(char* svID)
{
    UINT8 retValue = ERR_UNIVERSAL;
    char *pSend = (char*)sendBuf;
    UINT16 frameSize;
    char *temp;
    char *temp2;

    pSend += sprintf(pSend,(char*)"GETSVID"CR);

    frameSize = pSend - (char*)sendBuf;
    if((retValue = readOneFrame(frameSize,(char*)"GETSVID",NULL,NULL,0)) == ERR_RIGHT)
    {
            temp = strstr((char*)recvBuf,(char*)"SVID;");
            if(temp)
            {
                    temp2 = strstr(temp,CR);
                    if(temp2)
                    {
                            memcpy(svID,&temp[strlen("SVID;")],1 + temp2 - &temp[strlen("SVID;")]);
                            svID[temp2 - &temp[strlen("SVID;")]] = 0;
                    }
            }else
            {
                    retValue = ERR_RECV;
            }
    }

    return retValue;
}
示例#6
0
UINT8 xl618::getAppid(UINT16 *appid)
{

    UINT8 retValue = ERR_UNIVERSAL;
    char *pSend = (char*)sendBuf;
    UINT16 frameSize;
    char *temp;

    pSend += sprintf(pSend,(char*)"GETAPPID"CR);

    frameSize = pSend - (char*)sendBuf;
    if((retValue = readOneFrame(frameSize,(char*)"GETAPPID",NULL,NULL,0)) == ERR_RIGHT)
    {
            temp = strstr((char*)recvBuf,(char*)"APPID;");
            if(temp)
            {
                    sscanf(&temp[strlen("APPID;")],"0x%x",(unsigned int *)appid);
            }else
            {
                    retValue = ERR_RECV;
            }
    }

    return retValue;
}
示例#7
0
 UINT8 xl618:: setGSE_RGDATA(pGSE_RGDATATYPE data)
{

     UINT8 retValue = ERR_UNIVERSAL;
     char *pSend = (char*)sendBuf;
     UINT16 frameSize;
     char *temp;

     pSend += sprintf(pSend,"RGDATA\r\n");

     frameSize = pSend - (char*)sendBuf;

      if((retValue = readOneFrame(frameSize,(char*)"RGDATA",NULL,NULL,0)) == ERR_RIGHT)
      {
              temp = strstr((char*)recvBuf,"STNUM;");
              if(temp)
                      data->STNUM = atoi(&temp[strlen("STNUM;")]);
              else
                      data->STNUM = 0;

              temp = strstr((char*)recvBuf,"SQNUM;");
              if(temp)
                      data->SQNUM = atoi(&temp[strlen("SQNUM;")]);
              else
                      data->SQNUM = 0;

              temp = strstr((char*)recvBuf,"CHLNUM;");
              if(temp)
                      data->CHLNUM = atoi(&temp[strlen("CHLNUM;")]);
              else
                      data->CHLNUM = 0;

              temp = strstr((char*)recvBuf,"ALLDATA;");
              INT32 size = dataSize - (temp - (char*)recvBuf);//不要前面几个字节

               if(temp)
               {
                   if(size <= 3000) //判断是否够存放
                   {
                       memcpy(data->ALLDATA,&temp[strlen("ALLDATA;")],size-20);//去掉RGDATAACK字节
                       //qDebug("data->ALLDATA==%s\n",data->ALLDATA);
                      // data->frame_size=size-12;
                           //memcpy(data->frame,&temp[strlen("DATA;")],size);
                   }else

                           retValue = ERR_BUFFER;
               }
      }else
          retValue = ERR_BUFFER;

     return retValue;

}
示例#8
0
 UINT8 xl618::setHRVirtual(pSET_HARMONIC_TYPE harmonic)
 {

     UINT8 retValue = ERR_UNIVERSAL;
     char *pSend = (char*)sendBuf;
     pSend += sprintf(pSend,"SETHR"CR);
     memcpy(pSend,harmonic,sizeof(SET_HARMONIC_TYPE));
     pSend += sizeof(SET_HARMONIC_TYPE);
     UINT16 frameSize = pSend - (char*)sendBuf;
     retValue = readOneFrame(frameSize,(char*)"SETHR",NULL,(char*)"SETHRACK",1);

     return retValue;
 }
示例#9
0
UINT8 xl618::setCR(FLOAT32 type)
{
    UINT8 retValue = ERR_UNIVERSAL;
    char *pSend = (char*)sendBuf;
    strcpy(pSend,STR_CR);
    pSend += strlen(STR_CR);

    if(type < 0.001)
            pSend += sprintf(pSend,"AUTO;");
    else
            pSend += sprintf(pSend,"%f;",type);

    UINT16 frameSize = pSend - (char*)sendBuf;

    retValue = readOneFrame(frameSize,(char*)"CR",NULL,(char*)"CRACK",0);


    return retValue;
}
示例#10
0
 UINT8 xl618::RWAVEALL(UINT32 *samnum,UINT32 *chnum,INT32 *data,UINT32 dataSize)
 {
         UINT8 retValue = ERR_UNIVERSAL;
 #if 1
         char *pSend = (char*)sendBuf;

         strcpy(pSend,STR_RWAVEALL);
         pSend += strlen(STR_RWAVEALL);

         UINT16 frameSize = pSend - (char*)sendBuf;

         UINT32 iSize;
         char *temp;


         if((retValue = readOneFrame(frameSize,(char*)"RWAVEALL",NULL,(char*)"RWAVEALLACK",3)) == ERR_RIGHT)
         {//解析帧
                 temp = strstr((char*)&recvBuf[8],"SAMNUM;");
                 if(temp)
                         *samnum = atoi((char*)&temp[strlen("SAMNUM;")]);

                 temp = strstr((char*)&recvBuf[8],"CHNUM;");
                 if(temp)
                         *chnum = atoi((char*)&temp[strlen("CHNUM;")]);

                 temp = strstr(temp,CR);

                 iSize = (*samnum) * (*chnum) * 4;
                // iSize = *samnum * *chnum * 8;

                 if(dataSize >= iSize)
                 {
                         memcpy(data,&temp[strlen(CR)],iSize);
                 }else
                 {
                         retValue = ERR_BUFFER;
                 }
         }
 #endif

         return retValue;
 }
示例#11
0
UINT8 xl618::getKL(UINT8 type,pRKLTYPE data)
{
    UINT8 retValue = ERR_UNIVERSAL;

    char *pSend = (char*)sendBuf;

    strcpy(pSend,"KL\n\rCHANNAL;U1R"CR);
    pSend += strlen("KL\n\rCHANNAL;U1R"CR);
    strcpy(pSend,"CHANNAL;I1R"CR);
    pSend += strlen("CHANNAL;I1R"CR);

    UINT16 frameSize = pSend - (char*)sendBuf;
    char *temp;

    if((retValue = readOneFrame(frameSize,(char*)"KL",NULL,(char*)"KLACK",800)) == ERR_RIGHT)
    {
        temp = strstr((char*)recvBuf,"U1R;");
        if(temp)
        {
            for(UINT32 j = 0; j < 256; j ++)
            {
                sscanf(temp,"%E"CR,&data->U1R[j]); //取到指定字符集为止的字符串
                while(*(temp++) != '\n');
            }
        }

        temp = strstr((char*)recvBuf,"I1R;");
        if(temp)
        {
            for(UINT32 j = 0; j < 64; j ++)
            {
                sscanf(temp,"%E"CR,&data->I1R[j]);     //以指数形式输出单精度
                while(*(temp++) != '\n');
               //qDebug("xxxx%d==%f\n",j,data->U1[j]);
            }
        }
    }else
    retValue = ERR_RIGHT;

    return retValue;
}
示例#12
0
void DecodeVideo::run()
{
    int frameFinished = 0;
    AVFrame *pFrame = avcodec_alloc_frame();
    SDL_LockMutex(mutex);
    avcodec_decode_video(pCodecCtx, pFrame, &frameFinished,packet.data,packet.size);
    SDL_UnlockMutex(mutex);

    AVFrame *pFrameRGB;
    pFrameRGB = avcodec_alloc_frame();
    avpicture_fill((AVPicture *)pFrameRGB, bufferRGB, PIX_FMT_RGB24,pCodecCtx->width, pCodecCtx->height);
    SwsContext *convert_ctx = sws_getContext(width,height,pix_fmt,width,height,PIX_FMT_RGB24,SWS_BICUBIC, NULL,NULL,NULL);
    sws_scale(convert_ctx,(const uint8_t*  const*)pFrame->data,pFrame->linesize,0,height,pFrameRGB->data,pFrameRGB->linesize);
    QImage tmpImage((uchar *)bufferRGB,width,height,QImage::Format_RGB888);
    QImage image  = tmpImage.copy();
    av_free(pFrameRGB);
    sws_freeContext(convert_ctx);
    emit readOneFrame(image);

    av_free_packet(&packet);
}
示例#13
0
UINT8 xl618::setFramerr(pSETFRAMERR_TYPE data)
{
        UINT8 retValue = ERR_UNIVERSAL;
        char *pSend = (char*)sendBuf;

        if(data)
        {
                strcpy(pSend,STR_SETFRAMERR CR);
                pSend += strlen(STR_SETFRAMERR CR);

                pSend += sprintf(pSend,"RATIO;%f"CR"MODE;%u"CR"INT;%u"CR"CALCUTYPE;%u"CR"ONOFF;%u"CR,
                        data->ratio,data->mode,data->intTimes,data->calcutype,data->onoff);

                UINT16 frameSize = pSend - (char*)sendBuf;

                retValue = readOneFrame(frameSize,(char*)"SETFRAMERR",NULL,(char*)"SETFRAMERRACK",0);
        }else
                retValue = ERR_BUFFER;

        return retValue;
}
示例#14
0
UINT8 xl618::getSyn(UINT8 *syn)
{
        UINT8 retValue = ERR_UNIVERSAL;
        char *pSend = (char*)sendBuf;

        pSend += sprintf(pSend,STR_GETSYN);

        UINT16 frameSize = pSend - (char*)sendBuf;
        char* temp;

        if((retValue = readOneFrame(frameSize,(char*)"GETSYN",NULL,(char*)"GETSYNACK",0)) == ERR_RIGHT)
        {
                temp = (char*)&recvBuf[6];

                temp = strstr(temp,"SYNTIME;");
                if(temp)
                        *syn = atoi(&temp[8]);
        }

        return retValue;
}
示例#15
0
 UINT8 xl618::scanGSE(pGSE_SCANTYPE data) //get appid
 {

    UINT8 retValue = ERR_UNIVERSAL;
    char *pSend = (char*)sendBuf;
    UINT16 frameSize;
    char *temp;
    QString strTemp ;
    pSend += sprintf(pSend,"GOOSESCAN\r\nEN;1\r\n");

    frameSize = pSend - (char*)sendBuf;

     if((retValue = readOneFrame(frameSize,(char*)"GOOSESCAN",NULL,NULL,2)) == ERR_RIGHT)
     {
             temp = strstr((char*)recvBuf,"GNUM;");
             if(temp)
                     data->GNUM = atoi(&temp[strlen("GNUM;")]);
             else
                     data->GNUM = 0;

             for(int i =0;i<16;i++)
             {
                 strTemp =  QObject::trUtf8("ID%1;").arg(i+1);

                 temp = strstr((char*)recvBuf,(char *)strTemp.toLatin1().data());
                 if(temp)
                         data->APPID[i] = atoi(&temp[strlen((char *)strTemp.toLatin1().data())]);
                 else
                         data->APPID[i] = 0;

             }
     }


    return retValue;
 }
示例#16
0
/***
 ***VideoPlayer类的成员
 ***/
VideoPlayer::VideoPlayer()
{
    initAvcodec();
    audioq = new PacketQueue;
    packet_queue_init(audioq);

    mutex = SDL_CreateMutex();
    decodeVideoMutex = SDL_CreateMutex();

    aCodecCtx  = NULL;
    pFormatCtx = NULL;
    eventloop  = NULL;
    curState = StoppedState;
    curType = NoneType;

    decodeVideoThread = new DecodeVideo;
    decodeVideoThread_2 = new DecodeVideo;
    decodeVideoThread_3 = new DecodeVideo;
    connect(decodeVideoThread,SIGNAL(readOneFrame(QImage)),this,SIGNAL(readOneFrame(QImage)));
    connect(decodeVideoThread_2,SIGNAL(readOneFrame(QImage)),this,SIGNAL(readOneFrame(QImage)));
    connect(decodeVideoThread_3,SIGNAL(readOneFrame(QImage)),this,SIGNAL(readOneFrame(QImage)));

    setVolume(128);
}
示例#17
0
UINT8 xl618::getHRN(UINT8 channel,pHARMONIC_TYPE data,UINT32 H1,UINT32 H2)
{

        UINT8 retValue = ERR_UNIVERSAL;
        char tempBuf[10];

        if(data && data->fN && data->qN && *(data->fN) && *(data->qN))
        {

                if(channel >= 1 && channel <= 6)
                {
                        char *pSend = (char*)sendBuf;
                        pSend += sprintf(pSend,STR_HRN"%d"CR"H1;%d"CR"H2;%d"CR,channel,H1,H2);

                        FLOAT32 *f = (*(data->fN))->elt;
                        FLOAT32 *q = (*(data->qN))->elt;

                        char* temp;
                        //UINT32 tempSam = data->samdot;

                        UINT16 frameSize = pSend - (char*)sendBuf;

                        if((retValue = readOneFrame(frameSize,(char*)"HRN",NULL,(char*)"HRNACK",1000)) == ERR_RIGHT)
                        {//解析帧
                                temp = (char*)recvBuf;

                                temp = strstr(temp,"RMS;");
                                if(temp)
                                        data->rms = (FLOAT32)atof(&temp[strlen("RMS;")]);

                                temp = strstr(temp,"RMS1;");
                                if(temp)
                                        data->rms1 = (FLOAT32)atof(&temp[strlen("RMS1;")]);

                                temp = strstr(temp,"SAMDOT;");
                                if(temp)
                                        data->samdot = atoi(&temp[strlen("SAMDOT;")]);

//                                if(data->samdot > tempSam)
//                                {
//                                        retValue = ERR_BUFFER;

//                                        return retValue;
//                                }

                                //UINT32 size = data->samdot / 2 - 1;
                                for(UINT32 i = H1; i <= H2; i ++)
                                {
                                        sprintf(tempBuf,"F%d;",i);
                                        temp = strstr(temp,tempBuf);
                                        if(temp)
                                        {
                                                f[i - H1] = (FLOAT32)atof(&temp[strlen(tempBuf)]);

                                                sprintf(tempBuf,"Q%d;",i);
                                                temp = strstr(temp,tempBuf);
                                                if(temp)
                                                {
                                                        q[i - H1] = (FLOAT32)atof(&temp[strlen(tempBuf)]);
                                                }else
                                                        break;
                                        }else
                                                break;
                                }
                                retValue = ERR_RIGHT;
                        }

                }else
                        retValue = ERR_PARA;
        }else
                retValue = ERR_BUFFER;

        qDebug("retValue----%d",retValue);
        return retValue;
}
示例#18
0
UINT8 xl618::getLKL(UINT8 type,pLKLTYPE data)//	type:0~5位分别表示通道1~6 Ua~Ic,位置1表示读取该通道 data:存储通道数据缓冲区
{

        UINT8 retValue = ERR_UNIVERSAL;
        char *pSend = (char*)sendBuf;

        strcpy(pSend,STR_LKL);
        pSend += strlen(STR_LKL);

        UINT8 i;
        for(i= 0; i < 6; i ++)
        {
                if(type & (1 << i))
                {
                        *pSend = (i + '1');
                        pSend += 1;
                }
        }
        strcpy(pSend,";"CR);
        pSend += strlen(";"CR);

        UINT16 frameSize = pSend - (char*)sendBuf;

        IntHandle pH;
        INT32 *delay;
        INT32 *iData;
        INT32 iSize;
        char *temp;

        if((retValue = readOneFrame(frameSize,(char*)"LKL",NULL,(char*)"LKLACK",2)) == ERR_RIGHT)
        {//解析帧
                temp = (char*)&recvBuf[3];
                for(i = 0; i < 6; i ++)
                {
                        if((type & (1 << i)) == 0)
                                continue;

                        if(i == 0)
                        {
                                pH = data->CH1;
                                delay = &data->delay1;
                        }
                        else if(i == 1)
                        {
                                pH = data->CH2;
                                delay = &data->delay2;
                        }
                        else if(i == 2)
                        {
                                pH = data->CH3;
                                delay = &data->delay3;
                        }
                        else if(i == 3)
                        {
                                pH = data->CH4;
                                delay = &data->delay4;
                        }
                        else if(i == 4)
                        {
                                pH = data->CH5;
                                delay = &data->delay5;
                        }
                        else if(i == 5)
                        {
                                pH = data->CH6;
                                delay = &data->delay6;
                        }
                        else
                        {
                                retValue = ERR_KLDATA;

                                return retValue;
                        }

                        if(pH && *pH)
                        {
                                iData = (*pH)->elt;
                                iSize = (*pH)->dimSize * 4;

                                *delay = *((INT32*)temp);
                                memcpy(iData,&temp[sizeof(INT32)],iSize);
                                temp += iSize + 4;
                        }else
                        {
                                retValue = ERR_BUFFER;
                        }
                }
        }
        return retValue;
}
示例#19
0
 UINT8 xl618:: setSGP_part(pGSE_SPTYPE data,pISABLE_GSE_SP isAble)
{

    UINT8 retValue = ERR_UNIVERSAL;
    char *pSend = (char*)sendBuf;
    strcpy(pSend,STR_SGP CR);
    pSend += strlen(STR_SGP CR);
    pGSE_SPTYPE p = data;
    if(isAble->GOOSENUM)
        pSend += sprintf(pSend,"GOOSENUM;%d"CR,p->GOOSENUM);
    if(isAble->DADDR)
        pSend += sprintf(pSend,"DADDR0;%d,%d,%d,%d,%d,%d"CR,p->DADDR[0],p->DADDR[1],p->DADDR[2],p->DADDR[3],p->DADDR[4],p->DADDR[5]);
    if(isAble->TCIPRI)
        pSend += sprintf(pSend,"TCIPRI;%d"CR,p->TCIPRI);
    if(isAble->TCIVID)
            pSend += sprintf(pSend,"TCIVID;%d"CR,p->TCIVID);
    if(isAble->APPID)
            pSend += sprintf(pSend,"APPID;%d"CR,p->APPID);
    if(isAble->GOCBREF)
            pSend += sprintf(pSend,"GOCBREF0;%s"CR,p->GOCBREF);
    if(isAble->DATASET)
            pSend += sprintf(pSend,"DATASET0;%s"CR,p->DATASET);
    if(isAble->GOID)
            pSend += sprintf(pSend,"GOID0;%s"CR,p->GOID);
    if(isAble->TEST)
            pSend += sprintf(pSend,"TEST;%d"CR,p->TEST);
    if(isAble->CONFREV)
            pSend += sprintf(pSend,"CONFREV;%d"CR,p->CONFREV);
    if(isAble->CHANNLENUM)
            pSend += sprintf(pSend,"CHANNLENUM;%d"CR,p->CHANNLENUM);
    if(isAble->TIME0)
            pSend += sprintf(pSend,"TIME0;%d"CR,p->TIME0);
    if(isAble->TIME1)
            pSend += sprintf(pSend,"TIME1;%d"CR,p->TIME1);
    if(isAble->TIME2)
            pSend += sprintf(pSend,"TIME2;%d"CR,p->TIME2);
    if(isAble->TIME3)
            pSend += sprintf(pSend,"TIME3;%d"CR,p->TIME3);
    if(isAble->TINVERSE)
            pSend += sprintf(pSend,"TINVERSE;%d"CR,p->TINVERSE);
    if(isAble->INVEREN)
            pSend += sprintf(pSend,"INVEREN;%d"CR,p->INVEREN);

    if(isAble->DATAFORMAT)
                    pSend += sprintf(pSend,"DATAFORMAT0;");
#if 0
             pSend += sprintf(pSend,"DATAFORMAT0;%d",p->DATAFORMAT[0]);
            for(int i =1;i<p->CHANNLENUM;i++)
            {
              pSend += sprintf(pSend,"%d",p->DATAFORMAT[0]);
            }
      #endif
            for(int i=0;i<p->CHANNLENUM;i++)
            {
                 //  pSend += sprintf(pSend,"%s",temp);
                  memcpy(pSend, &(p->DATAFORMAT)[i], sizeof(UINT8));
                  //printf("DATAFORMAT == %d\n", *(&(p->DATAFORMAT)[i]) );
                  pSend += sizeof(UINT8);
                  //printf(" sizeof(&data[i])=%d", sizeof(data[i]));
            }
            memcpy(pSend, CR , sizeof(CR));
             // pSend += sprintf(pSend,"DATAFORMAT0;%02x"CR,charTemp);

    UINT16 frameSize = pSend - (char*)sendBuf;
    retValue = readOneFrame(frameSize,(char*)"SGP",NULL,(char*)"SPACK",0);

    return retValue;
}
示例#20
0
UINT8 xl618::IEC61850Frame(pIECTYPE data)
{
        UINT8 retValue = ERR_UNIVERSAL;
        char *pSend = (char*)sendBuf;

        if(data && data->frame)
        {
                strcpy(pSend,STR_IEC61850 CR);
                pSend += strlen(STR_IEC61850 CR);
                char *temp;

                UINT16 frameSize = pSend - (char*)sendBuf;

                if((retValue = readOneFrame(frameSize,(char*)"IEC61850",NULL,(char*)"IEC61850ACK",1)) == ERR_RIGHT)
                {//解析帧
                        temp = strstr((char*)recvBuf,"SAMNUM;");
                        if(temp)
                                data->samNum = atoi(&temp[strlen("SAMNUM;")]);

                        temp = strstr((char*)recvBuf,"PRODUCT;");
                        if(temp)
                                data->product = (memcmp(&temp[strlen("PRODUCT;")],"WEISHENG",strlen("WEISHENG")) != 0);

                        temp = strstr((char*)recvBuf,"ASDUNUM;");
                        if(temp)
                                data->asduNum = atoi(&temp[strlen("ASDUNUM;")]);

                        temp = strstr((char*)recvBuf,"RATEDDELAY;");
                        if(temp)
                                data->ratedDelay = atoi(&temp[strlen("RATEDDELAY;")]);

                        temp = strstr((char*)recvBuf,"VOLTAGERANGE;");
                        if(temp)
                                data->voltagerange = (FLOAT32)atof(&temp[strlen("VOLTAGERANGE;")]);

                        temp = strstr((char*)recvBuf,"CURRENTRANGE;");
                        if(temp)
                                data->currentrange = (FLOAT32)atof(&temp[strlen("CURRENTRANGE;")]);

                        temp = strstr((char*)recvBuf,"MAXSAMCNT;");
                        if(temp)
                                data->maxSamcnt = atoi(&temp[strlen("MAXSAMCNT;")]);

                        temp = strstr((char*)recvBuf,"FRAM;");

                        if(temp)
                        {
                                INT32 size = dataSize - (temp - (char*)recvBuf) - 18;//不要前面几个字节
                                if(size <= 3000) //判断是否够存放
                                {
                                        memcpy(data->frame,&temp[strlen("FRAM;")+12],size-12);
                                        data->frame_size=size-12;
                                }else

                                        retValue = ERR_BUFFER;
                        }

                }else
                        retValue = ERR_BUFFER;
        }

        return retValue;
}