Esempio n. 1
0
 internal byte[] ReadDataBlock(Gurux.DLMS.GXDLMSClient cosem, Gurux.Common.IGXMedia media, byte[] data, int wt, int scaler)
 {            
     byte[] reply = ReadDLMSPacket(cosem, media, data, wt);
     byte[] allData = null;
     RequestTypes moredata = cosem.GetDataFromPacket(reply, ref allData);
     int max = cosem.GetMaxProgressStatus(allData);
     int current = 0;
     while (moredata != 0)
     {
         while ((moredata & RequestTypes.Frame) != 0)
         {
             data = cosem.ReceiverReady(RequestTypes.Frame);
             reply = ReadDLMSPacket(cosem, media, data, wt);                    
             if ((cosem.GetDataFromPacket(reply, ref allData) & RequestTypes.Frame) == 0)
             {
                 current = cosem.GetCurrentProgressStatus(allData);
                 if (max != 0 && scaler != 0)
                 {
                     double tmp = current;
                     tmp /= max;
                     tmp *= max;
                     tmp += scaler * max;
                     Progress((int)tmp, 5 * max);
                 }
                 moredata &= ~RequestTypes.Frame;
                 break;
             }
             current = cosem.GetCurrentProgressStatus(allData);
             if (max != 0 && scaler != 0)
             {
                 double tmp = current;
                 tmp /= max;
                 tmp *= max;
                 tmp += scaler * max;
                 Progress((int)tmp, 5 * max);
             }
         }
         if ((moredata & RequestTypes.DataBlock) != 0)
         {
             //Send Receiver Ready.
             data = cosem.ReceiverReady(RequestTypes.DataBlock);
             reply = ReadDLMSPacket(cosem, media, data, wt);
             moredata = cosem.GetDataFromPacket(reply, ref allData);
             current = cosem.GetCurrentProgressStatus(allData);
             if (max != 0 && scaler != 0)
             {
                 double tmp = current;
                 tmp /= max;
                 tmp *= max;
                 tmp += scaler * max;
                 Progress((int)tmp, 5 * max);
             }
         }
     }
     return allData;
 }