using System; using System.Text; using System.Linq; using System.Drawing; using System.Diagnostics; using System.Windows.Forms; using System.Threading; using System.Threading.Tasks; using System.Collections.Generic; using Tango.PMR.Hardware; using Tango.PMR.Stubs; using Tango.PMR.IO; using Google.Protobuf; using System.IO; using Tango.Stubs; public void OnExecute(StubManager stubManager) { UploadHardwareConfigurationRequest uploadHardwareConfigurationRequest = new UploadHardwareConfigurationRequest(); /* FileChunkDownloadResponse fileChunkDownloadResponse = new FileChunkDownloadResponse(); ByteString byteString = new ByteString(); byteString.Length = 0; byteString.IsEmpty = false; byteString.Item = 0; fileChunkDownloadResponse.Buffer = buffer; fileChunkDownloadResponse.IsCanceled = false; */ FileDownloadRequest fileDownloadRequest = new FileDownloadRequest(); fileDownloadRequest.FileName = "0://SysInfo//GenHwCfg.cfg"; FileDownloadResponse response2 = stubManager.Run(fileDownloadRequest); long chunk_size = response2.MaxChunkLength; stubManager.Write( chunk_size+" \r\n"); byte[] chunk = new byte[chunk_size]; FileStream fs = new FileStream("C:\\Temp\\GenHwCfg.cfg",FileMode.Create); bool done = false; int location = 0; while (done == false) { stubManager.Write("Position "+ fs.Position+ " Length "+ fs.Length +"\n\n"); FileChunkDownloadRequest fileChunkDownloadRequest = new FileChunkDownloadRequest(); fileChunkDownloadRequest.DownloadID = response2.DownloadID; var response3 = stubManager.Run(fileChunkDownloadRequest); response3.Buffer.CopyTo(chunk,location); stubManager.Write("Length "+ response3.Buffer.Length + "\n\n"); fs.Write(chunk,location,response3.Buffer.Length); if (response3.Buffer.Length