#include "mydatatest.h"
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include "MyModule/MainModel.h"
using namespace MyModule;
using namespace std;
namespace {
    MainModel &mainModel = MainModel::instance();
}

MyDataTest &MyDataTest::instance()
{
    static MyDataTest instance;
    return instance;
}

#define ID3_BUF_SIZE 60
static bool flag;
//uint8_t *usbMusicTitle=nullptr;
static uint8_t usbMusicTitle[ID3_BUF_SIZE];
static uint8_t usbMusicArtist[ID3_BUF_SIZE];
static uint8_t usbMusicAlbum[ID3_BUF_SIZE];

void handle92(unsigned char *pdata_, int len){
//    delete [] usbMusicTitle;
//    usbMusicTitle = nullptr;
      //usbMusicTitle=new uint8_t[ID3_BUF_SIZE];


    printf("==================handle92 len: %d\n", len);
    uint8_t datalen = len-1;
    uint8_t index = pdata_[0];
    uint8_t *data = &pdata_[1];
    if (0x03 == index && datalen>3) {
        int tmp1 = data[0]&0xff, tmp2=0, tmp3=0;
        printf("usbMusic datalen: %d\n", datalen);
        printf("usbMusic tmp1: %d\n", tmp1);
        if(tmp1>0 && (1+tmp1)<=datalen){
            int n = tmp1 > ID3_BUF_SIZE ? ID3_BUF_SIZE : tmp1;
            memset(usbMusicTitle, 0, ID3_BUF_SIZE);
            memcpy(usbMusicTitle, &data[1], n);
            if(flag)
              mainModel.musicTitle.setValue(Qul::Private::String((const char*)usbMusicTitle, n));
           else
              mainModel.musicTitle.setValue(Qul::Private::String((const char*)usbMusicTitle, n) + " ");
        } else {
            mainModel.musicTitle.setValue("");
        }
        printf("usbMusic usbMusicTitle: %s\n", (const char*)usbMusicTitle);
        if(datalen>(1+tmp1)) {
            tmp2 = data[1+tmp1]&0xff;
            printf("usbMusic tmp2: %d\n", tmp2);
            if(tmp2>0 && datalen>=(2+tmp1+tmp2)){
                int n = tmp2>ID3_BUF_SIZE?ID3_BUF_SIZE:tmp2;
                memset(usbMusicArtist, 0, ID3_BUF_SIZE);
                memcpy(usbMusicArtist, &data[2+tmp1], n);
                if(flag)
                  mainModel.musicArtist.setValue(Qul::Private::String((const char*)usbMusicArtist, n));
               else
                  mainModel.musicArtist.setValue(Qul::Private::String((const char*)usbMusicArtist, n) + " ");
            } else {
                mainModel.musicArtist.setValue("");
            }
        } else {
            mainModel.musicArtist.setValue("");
        }
        flag = !flag;
        printf("usbMusic usbMusicArtist: %s\n", (const char*)usbMusicArtist);
    }
}

void MyDataTest::init(){
    //timer.onTimeout(Functor());
    static int count = 0;
    srand(time(0));

    //bruning.mp3
    static uint8_t dataMusic0[] = {0x03,0x0b,0x62,0x72,0x75,0x6e,0x69,0x6e,0x67,0x2e,0x6d,0x70,0x33,0x0f,0x4d,0x61,0x72,0x69,0x61,0x20,0x41,0x72,0x72,0x65,\
                                    0x64,0x6f,0x6e,0x64,0x6f,0x0f,0x4e,0x6f,0x74,0x20,0x47,0x6f,0x69,0x6e,0x67,0x20,0x55,0x6e,0x64,0x65,0x72};
    //Dancing With Your Ghost-Sasha Sloan.mp3
    static uint8_t dataMusic1[] = {0x03,0x27,0x44,0x61,0x6e,0x63,0x69,0x6e,0x67,0x20,0x57,0x69,0x74,0x68,0x20,0x59,0x6f,0x75,0x72,0x20,0x47,0x68,0x6f,0x73,\
                                    0x74,0x2d,0x53,0x61,0x73,0x68,0x61,0x20,0x53,0x6c,0x6f,0x61,0x6e,0x2e,0x6d,0x70,0x33,0x3b,0x37,0xe6,0x9c,0x88,0xe7,0x83,\
                                    0xad,0xe6,0xad,0x8c,0xe6,0xa6,0x9c,0x37,0xe6,0x9c,0x88,0xe7,0x83,0xad,0xe6,0xad,0x8c,0xe6,0xa6,0x9c,0x37,0xe6,0x9c,0x88,\
                                    0xe7,0x83,0xad,0xe6,0xad,0x8c,0xe6,0xa6,0x9c,0x37,0xe6,0x9c,0x88,0xe7,0x83,0xad,0xe6,0xad,0x8c,0xe6,0xa6,0x9c,0x37,0xe6,\
                                    0x9c,0x88,0xe7,0x83,0xad,0x39,0xe6,0x97,0xa0,0xe7,0xa2,0x9f,0xe6,0x9c,0xba,0xe9,0x9f,0xb3,0xe4,0xb9,0x90,0xe7,0x83,0xad,\
                                    0xe6,0xad,0x8c,0x6,0xa6,0x9c,0xe6,0x97,0xa0,0xe7,0xa2,0x9f,0xe6,0x9c,0xba,0xe9,0x9f,0xb3,0xe4,0xb9,0x90,0xe7,0x83,0xad,\
                                    0xe6,0xad,0x8c,0xe6,0xa6,0x9c,0xe6,0x97,0xa0,0xe7,0xa2,0x9f,0xe6,0x9c,0xba};

    //JW、苏永康 - 性情中人.mp3
    static uint8_t dataMusic2[] ={0x03,0x21,0x4a,0x57,0xe3,0x80,0x81,0xe8,0x8b,0x8f,0xe6,0xb0,0xb8,0xe5,0xba,0xb7,0x20,0x2d,0x20,0xe6,0x80,0xa7,0xe6,0x83,\
                                  0x85,0xe4,0xb8,0xad,0xe4,0xba,0xba,0x2e,0x6d,0x70,0x33,0x07,0x75,0x6e,0x6b,0x6e,0x6f,0x77,0x6e,0x07,0x75,0x6e,0x6b,\
                                  0x6e,0x6f,0x77,0x6e};

    //M2M - Pretty Boy.mp3
    static uint8_t dataMusic3[] ={0x03,0x14,0x4d,0x32,0x4d,0x20,0x2d,0x20,0x50,0x72,0x65,0x74,0x74,0x79,0x20,0x42,0x6f,0x79,0x2e,0x6d,0x70,0x33,0x03,0x4d,\
                                  0x32,0x4d,0x07,0x75,0x6e,0x6b,0x6e,0x6f,0x77,0x6e};

    //Stretch up down.mp3
    static uint8_t dataMusic4[] = {0x03,0x13,0x53,0x74,0x72,0x65,0x74,0x63,0x68,0x20,0x75,0x70,0x20,0x64,0x6f,0x77,0x6e,0x2e,0x6d,0x70,0x33,0x07,0x75,\
                                   0x6e,0x6b,0x6e,0x6f,0x77,0x6e,0x07,0x75,0x6e,0x6b,0x6e,0x6f,0x77,0x6e};

    //t尹美莱 - memories…(smiling tears).mp3
    static uint8_t dataMusic5[] = {0x03,0x2b,0x74,0xe5,0xb0,0xb9,0xe7,0xbe,0x8e,0xe8,0x8e,0xb1,0x20,0x2d,0x20,0x6d,0x65,0x6d,0x6f,0x72,0x69,0x65,0x73,0xe2,\
                                    0x80,0xa6,0x28,0x73,0x6d,0x69,0x6c,0x69,0x6e,0x67,0x20,0x74,0x65,0x61,0x72,0x73,0x29,0x2e,0x6d,0x70,0x33,0x15,0xe9,0x9d,\
                                    0x9e,0xe4,0xb8,0xbb,0xe6,0xb5,0x81,0xe4,0xbc,0xa4,0xe6,0x84,0x9f,0xe6,0xad,0x8c,0xe6,0x9b,0xb2,0x0d,0x77,0x77,0x77,0x2e,\
                                    0x71,0x71,0x31,0x39,0x30,0x2e,0x63,0x6f,0x6d};
    //t尹美莱 - 爱你.mp3
    static uint8_t dataMusic6[] = {0x03,0x17,0x74,0xe5,0xb0,0xb9,0xe7,0xbe,0x8e,0xe8,0x8e,0xb1,0x20,0x2d,0x20,0xe7,0x88,0xb1,0xe4,0xbd,0xa0,0x2e,0x6d,\
                                   0x70,0x33,0x07,0x75,0x6e,0x6b,0x6e,0x6f,0x77,0x6e,0x07,0x75,0x6e,0x6b,0x6e,0x6f,0x77,0x6e};

    //彩音 (あやね) - いつもこの場所で (一直在这
   static uint8_t dataMusic7[] = {0x03,0x3b,0xe5,0xbd,0xa9,0xe9,0x9f,0xb3,0x20,0x28,0xe3,0x81,0x82,0xe3,0x82,0x84,0xe3,0x81,0xad,0x29,0x20,0x2d,0x20,0xe3,0x81,\
                                   0x84,0xe3,0x81,0xa4,0xe3,0x82,0x82,0xe3,0x81,0x93,0xe3,0x81,0xae,0xe5,0xa0,0xb4,0xe6,0x89,0x80,0xe3,0x81,0xa7,0x20,0x28,\
                                   0xe4,0xb8,0x80,0xe7,0x9b,0xb4,0xe5,0x9c,0xa8,0xe8,0xbf,0x99,0x12,0xe5,0xbd,0xa9,0xe9,0x9f,0xb3,0x20,0x28,0xe3,0x81,\
                                   0x82,0xe3,0x82,0x84,0xe3,0x81,0xad,0x29,0x3a,0xe3,0x80,0x8c,0xe5,0x8a,0x87,0xe5,0xa0,0xb4,0xe7,0x89,0x88,0x20,0x53,\
                                   0x54,0x45,0x49,0x4e,0x53,0x3b,0x47,0x41,0x54,0x45,0x20,0xe8,0xb2,0xa0,0xe8,0x8d,0xb7,0xe9,0xa0,0x98,0xe5,0x9f,0x9f,\
                                   0xe3,0x81,0xae,0xe3,0x83,0x87,0xe3,0x82,0xb8,0xe3,0x83,0xa3,0xe3,0x83,0xb4,0xe3,0x80,0x8d,0xe3,0x82,0xa8};

   //动漫音乐 - 想大声说爱你.mp3
   static uint8_t dataMusic8[] = {0x03,0x25,0xe5,0x8a,0xa8,0xe6,0xbc,0xab,0xe9,0x9f,0xb3,0xe4,0xb9,0x90,0x20,0x2d,0x20,0xe6,0x83,0xb3,0xe5,0xa4,0xa7,0xe5,\
                                   0xa3,0xb0,0xe8,0xaf,0xb4,0xe7,0x88,0xb1,0xe4,0xbd,0xa0,0x2e,0x6d,0x70,0x33,0x12,0xe7,0x81,0x8c,0xe7,0xaf,0xae,0xe9,0xab,\
                                   0x98,0xe6,0x89,0x8b,0xe6,0x8f,0x92,0xe6,0x9b,0xb2,0x07,0x75,0x6e,0x6b,0x6e,0x6f,0x77,0x6e};

   //范逸臣 - 不说出的温柔 - 说不出的温柔.mp3
   static uint8_t dataMusic9[] = {0x03,0x37,0xe8,0x8c,0x83,0xe9,0x80,0xb8,0xe8,0x87,0xa3,0x20,0x2d,0x20,0xe4,0xb8,0x8d,0xe8,0xaf,0xb4,0xe5,0x87,0xba,0xe7,\
                                   0x9a,0x84,0xe6,0xb8,0xa9,0xe6,0x9f,0x94,0x20,0x2d,0x20,0xe8,0xaf,0xb4,0xe4,0xb8,0x8d,0xe5,0x87,0xba,0xe7,0x9a,0x84,0xe6,\
                                   0xb8,0xa9,0xe6,0x9f,0x94,0x2e,0x6d,0x70,0x33,0x09,0xe8,0x8c,0x83,0xe9,0x80,0xb8,0xe8,0x87,0xa3,0x07,0x75,0x6e,0x6b,0x6e,\
                                   0x6f,0x77,0x6e};

   //郭富城 - 没有你的爱.mp3
   static uint8_t dataMusic10[] ={0x03,0x1f,0xe9,0x83,0xad,0xe5,0xaf,0x8c,0xe5,0x9f,0x8e,0x20,0x2d,0x20,0xe6,0xb2,0xa1,0xe6,0x9c,0x89,0xe4,0xbd,0xa0,0xe7,\
                                 0x9a,0x84,0xe7,0x88,0xb1,0x2e,0x6d,0x70,0x33,0x09,0xe9,0x83,0xad,0xe5,0xaf,0x8c,0xe5,0x9f,0x8e,0x07,0x75,0x6e,0x6b,0x6e,
                                 0x6f,0x77,0x6e};

   //郭富城、绝对美丽.mp3
   static uint8_t dataMusic11[] = {0x03,0x1c,0xe9,0x83,0xad,0xe5,0xaf,0x8c,0xe5,0x9f,0x8e,0xe3,0x80,0x81,0xe7,0xbb,0x9d,0xe5,0xaf,0xb9,0xe7,0xbe,0x8e,\
                                   0xe4,0xb8,0xbd,0x2e,0x6d,0x70,0x33,0x09,0xe9,0x83,0xad,0xe5,0xaf,0x8c,0xe5,0x9f,0x8e,0x20,0xe7,0xb2,0xa4,0xe8,0xaf,\
                                   0xad,0x2d,0xe9,0x83,0xad,0xe5,0xaf,0x8c,0xe5,0x9f,0x8e,0x2d,0xe7,0x88,0xb1,0xe6,0x83,0x85,0xe5,0xa4,0xa7,0xe8,0x88,\
                                   0x9e,0xe5,0x8f,0xb0};

   //李承允 (이승윤) - 언덕나무.mp3
       static uint8_t dataMusic12[] ={0x03,0x28,0xe6,0x9d,0x8e,0xe6,0x89,0xbf,0xe5,0x85,0x81,0x20,0x28,0xec,0x9d,0xb4,0xec,0x8a,0xb9,0xec,0x9c,0xa4,0x29,0x20,\
                                     0x2d,0x20,0xec,0x96,0xb8,0xeb,0x8d,0x95,0xeb,0x82,0x98,0xeb,0xac,0xb4,0x2e,0x6d,0x70,0x33,0x15,0xe6,0x9d,0x8e,0xe6,0x89,\
                                     0xbf,0xe5,0x85,0x81,0x20,0x28,0xec,0x9d,0xb4,0xec,0x8a,0xb9,0xec,0x9c,0xa4,0x29,0x3b,0xea,0xb7,0xb8,0x20,0xed,0x95,0xb4,\
                                     0x20,0xec,0x9a,0xb0,0xeb,0xa6,0xac,0xeb,0x8a,0x94,0x20,0x4f,0x53,0x54,0x20,0x50,0x61,0x72,0x74,0x2e,0x37,0x20,0x28,0xe9,\
                                     0x82,0xa3,0xe5,0xb9,0xb4,0xef,0xbc,0x8c,0xe6,0x88,0x91,0xe4,0xbb,0xac,0xe7,0x9a,0x84,0xe5,0xa4,0x8f,0xe5,0xa4,0xa9,0x20,\
                                     0x4f,0x53,0x54,0x20};

    //水星记-郭顶
    static uint8_t dataMusic13[] ={0x03,0x14,0xe6,0xb0,0xb4,0xe6,0x98,0x9f,0xe8,0xae,0xb0,0x2d,0xe9,0x83,0xad,0xe9,0xa1,0xb6,0x2e,0x6d,0x70,\
                                        0x33,0x06,0xe9,0x83,0xad,0xe9,0xa1,0xb6,0x09,0xe6,0xb0,0xb4,0xe6,0x98,0x9f,0xe8,0xae,0xb0};
    //傻子_林宥嘉
    static uint8_t dataMusic14[] ={0x03,0x14,0xe5,0x82,0xbb,0xe5,0xad,0x90,0x5f,0xe6,0x9e,0x97,0xe5,0xae,0xa5,0xe5,0x98,0x89,0x2e,0x6d,0x70,0x33,0x09,\
                                  0xe6,0x9e,0x97,0xe5,0xae,0xa5,0xe5,0x98,0x89,0x0c,0xe5,0xa4,0xa7,0xe5,0xb0,0x8f,0xe8,0xaf,0xb4,0xe5,0xae,0xb6};


    //提提提提提提提提提提提提提提提提提提提
    static uint8_t dataMusic15[] = {0x03,0x03,0x02,0xe6,0x8f,0x02,0xe6,0x8f,0x02,0xe8,0x88/*0x39,0xe6,0x8f,0x90,0xe6,0x8f,0x90,0xe6,0x8f,0x90,0xe6,0x8f,0x90,0xe6,0x8f,0x90,0xe6,0x8f,0x90,0xe6,0x8f,0x90,0xe6,\
                                                                  0x8f,0x90,0xe6,0x8f,0x90,0xe6,0x8f,0x90,0xe6,0x8f,0x90,0xe6,0x8f,0x90,0xe6,0x8f,0x90,0xe6,0x8f,0x90,0xe6,0x8f,0x90,0xe6,\
                                                                   0x8f,0x90,0xe6,0x8f,0x90,0xe6,0x8f,0x90,0xe6,0x8f,0x90,0x39,0xe8,0x88,0x9e,0xe8,0x88,0x9e,0xe8,0x88,0x9e,0xe8,0x88,0x9e,\
                                                                   0xe8,0x88,0x9e,0xe8,0x88,0x9e,0xe8,0x88,0x9e,0xe8,0x88,0x9e,0xe8,0x88,0x9e,0xe8,0x88,0x9e,0xe8,0x88,0x9e,0xe8,0x88,0x9e,\
                                                                   0xe8,0x88,0x9e,0xe8,0x88,0x9e,0xe8,0x88,0x9e,0xe8,0x88,0x9e,0xe8,0x88,0x9e,0xe8,0x88,0x9e,0xe8,0x88,0x9e,0x39,0xe5,0x94,\
                                                                   0xb1,0xe5,0x94,0xb1,0xe5,0x94,0xb1,0xe5,0x94,0xb1,0xe5,0x94,0xb1,0xe5,0x94,0xb1,0xe5,0x94,0xb1,0xe5,0x94,0xb1,0xe5,0x94,\
                                                                   0xb1,0xe5,0x94,0xb1,0xe5,0x94,0xb1,0xe5,0x94,0xb1,0xe5,0x94,0xb1,0xe5,0x94,0xb1,0xe5,0x94,0xb1,0xe5,0x94,0xb1,0xe5,0x94,\
                                                                   0xb1,0xe5,0x94,0xb1,0xe5,0x94,0xb1*/};
    // static uint8_t dataMusic15[] = {0x03,0x02,0xe6,0x8f,0x02,0xe6,0x8f,0x02,0xe8,0x88};

    //汪苏泷-不分手的恋爱.mp3
    static uint8_t dataMusic16[] = {0x03,0x20,0xe6,0xb1,0xaa,0xe8,0x8b,0x8f,0xe6,0xb3,0xb7,0x2d,0xe4,0xb8,0x8d,0xe5,0x88,0x86,0xe6,0x89,0x8b,0xe7,0x9a,0x84,\
                                    0xe6,0x81,0x8b,0xe7,0x88,0xb1,0x2e,0x6d,0x70,0x33,0x3b,0x37,0xe6,0x9c,0x88,0xe7,0x83,0xad,0xe6,0xad,0x8c,0xe6,0xa6,0x9c,\
                                    0x37,0xe6,0x9c,0x88,0xe7,0x83,0xad,0xe6,0xad,0x8c,0xe6,0xa6,0x9c,0x37,0xe6,0x9c,0x88,0xe7,0x83,0xad,0xe6,0xad,0x8c,0xe6,\
                                    0xa6,0x9c,0x37,0xe6,0x9c,0x88,0xe7,0x83,0xad,0xe6,0xad,0x8c,0xe6,0xa6,0x9c,0x37,0xe6,0x9c,0x88,0xe7,0x83,0xad,0x39,0xe6,\
                                    0x97,0xa0,0xe7,0xa2,0x9f,0xe6,0x9c,0xba,0xe9,0x9f,0xb3,0xe4,0xb9,0x90,0xe7,0x83,0xad,0xe6,0xad,0x8c,0xe6,0xa6,0x9c,0xe6,\
                                    0x97,0xa0,0xe7,0xa2,0x9f,0xe6,0x9c,0xba,0xe9,0x9f,0xb3,0xe4,0xb9,0x90,0xe7,0x83,0xad,0xe6,0xad,0x8c,0xe6,0xa6,0x9c,0xe6,\
                                    0x97,0xa0,0xe7,0xa2,0x9f,0xe6,0x9c,0xba};


   static uint8_t testdata1[] = {"水星记_郭顶.mp3"};
   static uint8_t testdata2[] = {"傻子_林宥嘉.mp3"};
    static uint8_t testdata11[ID3_BUF_SIZE];
   static uint8_t testdata22[ID3_BUF_SIZE];
  static uint8_t testdataTemp[ID3_BUF_SIZE];
    memset(testdata11, 0, ID3_BUF_SIZE);
    memset(testdata22, 0, ID3_BUF_SIZE);
    memcpy(testdata11, &testdata1[10], 6);
    memcpy(testdata22, &testdata2[7], 9);


    //    static uint8_t dataMusicArtist0[6] ={0xe9,0x83,0xad,0xe9,0xa1,0xb6};
//    static uint8_t dataMusicArtist1[9] ={0xe6,0x9e,0x97,0xe5,0xae,0xa5,0xe5,0x98,0x89};
//    static uint8_t dataMusicTitile0[20] ={0xe6,0xb0,0xb4,0xe6,0x98,0x9f,0xe8,0xae,0xb0,0x2d,0xe9,0x83,0xad,0xe9,0xa1,0xb6,0x2e,0x6d,0x70,0x33};
//    static uint8_t dataMusicTitile1[20] ={0xe5,0x82,0xbb,0xe5,0xad,0x90,0x5f,0xe6,0x9e,0x97,0xe5,0xae,0xa5,0xe5,0x98,0x89,0x2e,0x6d,0x70,0x33};
    timer.onTimeout([]() {
        count = 15;//(rand() % (17-0))+ 0;
        printf("lzy..............triggered, count:%d\n",count);
        switch(count){
        case 0:
              handle92(&dataMusic0[0],sizeof(dataMusic0));
//            memset(testdataTemp, 0, ID3_BUF_SIZE);
//            memcpy(testdataTemp, testdata1, sizeof(testdata1));
//            mainModel.musicTitle.setValue(Qul::Private::String((const char*)testdataTemp, sizeof(testdataTemp)-1));
//            mainModel.musicArtist.setValue(Qul::Private::String((const char*)testdata11, sizeof(testdata11)-1));
//            memset(usbMusicArtist, 0, ID3_BUF_SIZE);
//            memcpy(usbMusicArtist, dataMusicArtist0, sizeof(dataMusicArtist0));
//            mainModel.musicArtist.setValue(Qul::Private::String((const char*)usbMusicArtist, 6/*sizeof(dataMusicArtist0)*/));

//            memset(usbMusicTitle, 0, ID3_BUF_SIZE);
//            memcpy(usbMusicTitle, dataMusicTitile0, sizeof(dataMusicTitile0));
//            mainModel.musicTitle.setValue(Qul::Private::String((const char*)usbMusicTitle, 20/*sizeof(dataMusicTitile0)*/));
            //printf("lzy..............musicArtist: %s,musicTitle: %s\n", (const char*)testdata11, (const char*)testdataTemp);
            break;
        case 1:
                handle92(&dataMusic1[0],sizeof(dataMusic1));
//            memset(testdataTemp, 0, ID3_BUF_SIZE);
//            memcpy(testdataTemp, testdata2, sizeof(testdata2));
//            mainModel.musicTitle.setValue(Qul::Private::String((const char*)testdataTemp, sizeof(testdataTemp)-1));
//            mainModel.musicArtist.setValue(Qul::Private::String((const char*)testdata22, sizeof(testdata22)-1));
//            memset(usbMusicArtist, 0, ID3_BUF_SIZE);
//            memcpy(usbMusicArtist, dataMusicArtist1, sizeof(dataMusicArtist1));
//            mainModel.musicArtist.setValue(Qul::Private::String((const char*)usbMusicArtist, 9/*sizeof(dataMusicArtist1)*/));

//            memset(usbMusicTitle, 0, ID3_BUF_SIZE);
//            memcpy(usbMusicTitle, dataMusicTitile1, sizeof(dataMusicTitile1));
//            mainModel.musicTitle.setValue(Qul::Private::String((const char*)usbMusicTitle, 20/*sizeof(dataMusicTitile1)*/));
            //printf("lzy..............musicArtist: %s,musicTitle: %s\n", (const char*)testdata22, (const char*)testdataTemp);
            break;
        case 2:
            handle92(&dataMusic2[0],sizeof(dataMusic2));
            break;
        case 3:
            handle92(&dataMusic3[0],sizeof(dataMusic3));
            break;
        case 4:
            handle92(&dataMusic4[0],sizeof(dataMusic4));
            break;
        case 5:
            handle92(&dataMusic5[0],sizeof(dataMusic5));
            break;
        case 6:
            handle92(&dataMusic6[0],sizeof(dataMusic6));
            break;
        case 7:
            handle92(&dataMusic7[0],sizeof(dataMusic7));
            break;
        case 8:
            handle92(&dataMusic8[0],sizeof(dataMusic8));
            break;
        case 9:
            handle92(&dataMusic9[0],sizeof(dataMusic9));
            break;
        case 10:
            handle92(&dataMusic10[0],sizeof(dataMusic10));
            break;
        case 11:
            handle92(&dataMusic11[0],sizeof(dataMusic11));
            break;
        case 12:
            handle92(&dataMusic12[0],sizeof(dataMusic12));
            break;
        case 13:
            handle92(&dataMusic13[0],sizeof(dataMusic13));
            break;
        case 14:
            handle92(&dataMusic14[0],sizeof(dataMusic14));
            break;
        case 15:
            handle92(&dataMusic15[0],sizeof(dataMusic15));
            break;
        case 16:
            handle92(&dataMusic16[0],sizeof(dataMusic16));
            break;

        }
//        count++;
//        if (count>16)
//            count = 0;
    });
    //timer.setSingleShot(true);
    //timer.setInterval(1000);
    timer.start(200); // trigger once in a minute
    printf(".....................lzy MyDataTest::init success!\n");
}

void MyDataTest::testData(){
    static uint8_t testdata[] = {"中华人民,共和国"};
    mainModel.musicArtist.setValue(Qul::Private::String((const char*)testdata, sizeof(testdata)-1));
    vector<int> obj;//创建一个向量存储容器 int
//    for(int i=0;i<10;i++) // push_back(elem)在数组最后添加数据
//    {
//        obj.push_back(i);
//        printf("lzy vector .......%d\n",obj[i]);
//    }

//    for(int i=0;i<5;i++)//去掉数组最后一个数据
//    {
//        obj.pop_back();
//    }


    obj.push_back(4);
    obj.push_back(3);
    obj.push_back(1);
    obj.push_back(12);

    //sort(obj.begin(),obj.end());//从小到大

    //find(obj.begin(),obj.end(),12);
    //obj.erase(obj.begin()+2);

    std::vector<int>::iterator it;
    it = find(obj.begin(),obj.end(), 3);
    //obj.erase(it);
    if(it == obj.end())
        obj.insert(it, 12);
    else
        obj.insert(it+1, 12);

    //it = obj.end();

    //std::swap(*it, obj.back());

    //obj.insert(it, 18);

    //obj.pop_back();
    //obj.push_back(18);

    //sort(obj.begin(),obj.end());//从小到大

//    it = find(obj.begin(),obj.end(),12);

//    obj.erase(it);

    printf("lzy vector obj ****~~~~it...................%d\n", *it);


//    if(it == obj.begin()){
//        it = obj.end() - 1;
//    }else{
//        it -= 1;
//    }

    if(it == obj.end()){
        //it = obj.end() - 1;
        printf("lzy vector obj ****~~~~it...................obj.end()\n");
    }else{
        //it -= 1;
    }

    printf("lzy vector obj.size() .......%ld\n", obj.size());
    if(obj.size() > 0)
       printf("lzy vector obj ****~~~~it...................%d\n", *it);

    if (it != obj.end())
       printf("lzy vector find .......successed!\n");
    else
       printf("lzy vector find ........failed\n");

    it = obj.begin();

    for(int i=0;i < obj.size();i++)//size()容器中实际数据个数
    {
        printf("lzy vector obj[%d] .......%d\n", i, obj[i]);
        printf("lzy vector obj[%d] .......%d\n",i, *(it+i));
    }

    printf("lzy vector obj.begin() .......%d\n", *obj.begin());
    printf("lzy vector obj.end() .......%d\n", *obj.end());


//    for(int i = 0;i < obj.size(); i++)//size()容器中实际数据个数
//    {
//        if(it == obj.begin()){
//           printf("lzy vector obj ****~~~~1...................%d\n", *it);
//           it = obj.end()-1;
//        }else{
//           printf("lzy vector obj ****~~~~2..................%d\n", *it);
//           it -= 1;
//        }
//    }

    for(int i = 0;i < obj.size(); i++)//size()容器中实际数据个数
    {
        if(it == obj.end()){
           it = obj.begin();
           printf("lzy vector obj ****~~~~1...................%d\n", *it);
           it += 1;
        }else{
           printf("lzy vector obj ****~~~~2..................%d\n", *it);
           it += 1;
        }
    }



//    reverse(obj.begin(),obj.end());//从大到小

//    for(int i=0;i<obj.size();i++)//size()容器中实际数据个数
//    {
//       printf("lzy vector sort reverse.......%d\n",obj[i]);
//    }

}


