Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QAxBase.Object -> dynamicCall() Data type
Forum Updated to NodeBB v4.3 + New Features

QAxBase.Object -> dynamicCall() Data type

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 4.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    deleted395
    wrote on last edited by
    #1

    Hi guys. I need your help.
    I'm trying to get some data from mx component(mitsubishi) using ActiveQt

    I succeed in writing a data to output s/w, but getting data is too difficult.

    The data reading method format is
    ReadDeviceBlock(String *szDevice, int iSize, int *iplData)

    I wanna how call this function correctly.
    Please tell me your idea.

    Under is my test source

    void MainWindow::on_pushButton_clicked() {

    ActLlt = new QAxObject;
    bool bStatus = false;
    bool bTemp = false;
    int nStatus = 0;
    int nTemp = 0;
    short hTemp = 0;
    long lTemp = 0;
    QString sTemp("");
    QStringList qsl_Temp;
    QVariant qv_Temp;
    QVariant qv_bTemp;
    QVariant qv_nTemp;
    QVariant qv_sTemp;
    QVariantList qvl_Temp;
    
    bStatus = ActLlt->setControl("{235CFC02-AE9E-11D3-83AE-00A024BDBF2B}");
    
    /* Property */
    //CpuType
    nTemp = ActLlt->property("ActCpuType").toInt();
    bTemp = ActLlt->setProperty("ActCpuType", CPU_Q26UDEHCPU);  //Cpu type change
    //NetworkNumber
    nTemp = ActLlt->property("ActNetworkNumber").toInt();
    //StationNumber
    nTemp = ActLlt->property("ActStationNumber").toInt();
    //TimeOut
    nTemp = ActLlt->property("ActTimeOut").toInt();
    
    QMap<QString, QVariant> qm_Temp;
    qm_Temp = ActLlt->propertyBag();
    QStringList qsl_PropertyKeys;
    QVariantList qsl_PropertyValue;
    qsl_PropertyKeys = qm_Temp.keys();
    qsl_PropertyValue = qm_Temp.values();
    /*----OK----*/
    
    nStatus = ActLlt->dynamicCall("Open()").toInt();
    
    //Here is my problem "ReadDeviceBlock"
    //try 1
    qv_Temp = ActLlt->dynamicCall("ReadDeviceBlock(QString,int,int&)", "D0", 1, qv_nTemp);
    
    //try 2
    int nReadData[10] = {0};
    void *ptrReadData = nReadData;
    qv_Temp.setValue(ptrReadData);
    qv_Temp = ActLlt->dynamicCall("ReadDeviceBlock(QString,int,int&)", "D0", 1, qv_nTemp);
    
    // I tried it with QVariantList, QVariant->fromValue() , etc.
    // Help me T.T
    /* -------------------------------------------------------- */
    
    
    /* WriteDeviceBlock */
    nTemp = 123;
    qv_nTemp.setValue(nTemp);
    qv_Temp = ActLlt->dynamicCall("WriteDeviceBlock(QString,int,int&)", "D0", 1, qv_nTemp);
    /* -------OK------- */
    
    /* End */
    nStatus = ActLlt->dynamicCall("Close()").toInt();
    delete ActLlt;
    

    }

    1 Reply Last reply
    0
    • hskoglundH Online
      hskoglundH Online
      hskoglund
      wrote on last edited by hskoglund
      #2

      Hi, it seems Mitsubushi made this more difficult by not using a SAFEARRAY for returning values, instead they are using an int array, which dynamicCall() doesn't like :-(

      But I think you can get one integer at the time like this, using the same pattern as for WriteDeviceBlock:

      //try 2
      int nReadData = 0;
      qv_nTemp.setValue(nReadData);
      qv_temp = ActLlt->dynamicCall("ReadDeviceBlock(QString,int,int&)", "D0", 1, qv_nTemp);
      // check if qv_ntemp got something...
      qDebug() << qv_nTemp;
      
      1 Reply Last reply
      0
      • D Offline
        D Offline
        deleted395
        wrote on last edited by deleted395
        #3

        Thanks gooooooood man

        I've just got a way to get one data like this

        QVariantList qvl_Temp;
        QString sRDB = "ReadDeviceBlock(QString,int,int&)";
        
        qvl_Temp << "D0" << 1 << 0;
        qv_Temp = ActLlt->dynamicCall(sRDB.toLatin1(), qvl_Temp);
        

        // qvl_Temp has "D0", (int) 3, !!!! Data !!!!!
        // It stored the one data into qvl_Temp.at(2)

        but I need getting more seems

        qvl_Temp << "D0" << 3 << 0 << 0 << 0;
        qv_Temp = ActLlt->dynamicCall(sRDB.toLatin1(), qvl_Temp);
        

        I expected it works to get 3 datas of [D0,D1,D2] but it doesn't T_T

        so, I tried this

        QVariantList qvl_Temp;
        QVariantList qvl_Data;
        QString sRDB = "ReadDeviceBlock(QString,int,int&)";
        
        qvl_Data << 0 << 0 << 0;
        qvl_Temp << "D0" << 3 << qvl_Data;
        qv_Temp = ActLlt->dynamicCall(sRDB.toLatin1(), qvl_Temp);
        

        but.......it could get just one data.

        I'm still finding ^^;;;;

        Thanks for your idea.

        1 Reply Last reply
        0
        • hskoglundH Online
          hskoglundH Online
          hskoglund
          wrote on last edited by
          #4

          I think as long as you have "ReadDeviceBlock(QString,int,int&)" then one data value is all you are getting (because Mitsubishi didn't read the COM manual properly) but you could try cheating:

          QString sRDB = "ReadDeviceBlock(QString,int,QList<QVariant>&)";
          
          qvl_Data << 0 << 0 << 0;
          qvl_Temp << "D0" << 3 << qvl_Data;
          qv_Temp = ActLlt->dynamicCall(sRDB.toLatin1(), qvl_Temp);
          
          1 Reply Last reply
          0
          • D Offline
            D Offline
            deleted395
            wrote on last edited by
            #5

            I found an easy way to use ActiveX in qt if you had *.tlb

            I did dumpcpp.exe with *.tlb file.
            It makes filenametlb.h and filenametlb.cpp files.
            It has a namespace and there are some classes wanna use.

            Look follow article. He is a genius
            http://www.codeproject.com/Tips/751240/Using-COM-Binary-Interface-with-Cplusplus

            Have good a day.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved