aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Stubs Collection/stubs/embParamDownload.cs
blob: afdc14c92427687a6f6775f2c410827f82d28b5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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.Stubs;
using Tango.Stubs;
using Google.Protobuf;
using Tango.PMR.EmbeddedParameters;
using System.IO;
using Tango.PMR.IO;


public void OnExecute(StubManager stubManager)
{


ConfigurationParameters configurationParameters = new ConfigurationParameters();

File.WriteAllBytes("C:/temp/EmbParam.cfg",configurationParameters.ToBytes());

byte[] fileBytes = File.ReadAllBytes("C:/temp/EmbParam.cfg");


var config = ConfigurationParameters.Parser.ParseFrom(fileBytes);

	stubManager.Write( config);
		Thread.Sleep(1000);
		
//1. read		
stubManager.Write("\n\n Deleting old file");

stubManager.Write("\n\n Loading new file file");


FileDownloadRequest fileDownloadRequest = new FileDownloadRequest();
fileDownloadRequest.FileName = "SYSINFO//EmbParam.cfg";;

FileDownloadResponse response = stubManager.Run<FileDownloadResponse>(fileDownloadRequest);


FileChunkDownloadRequest fileChunkDownloadRequest = new FileChunkDownloadRequest();
fileChunkDownloadRequest.DownloadID = response.
fileChunkDownloadRequest.FileName = null;
fileChunkDownloadRequest.Position = 0;

Thread.Sleep(1000);
long chunk_size = response2.MaxChunkLength;

FileStream fs = new FileStream("C:/temp/EmbParam.cfg",FileMode.Open);

while (fs.Position < fs.Length)
{
		stubManager.Write("Position "+ fs.Position+ " Length "+ fs.Length +"\n\n");
		FileChunkUploadRequest fileChunkUploadRequest = new FileChunkUploadRequest();
		fileChunkUploadRequest.UploadID = response2.UploadID;
		byte[] chunk = new byte[Math.Min(chunk_size,fs.Length - fs.Position)];
		fs.Read(chunk,0,chunk.Length);
		fileChunkUploadRequest.Buffer = ByteString.CopyFrom(chunk);	
		var response3 = stubManager.Run<FileChunkUploadResponse>(fileChunkUploadRequest);
		Thread.Sleep(2000);

}
	
/*
13:46:42.38: Executing script 'embeddedparametersbuild.cs'...
{ "BreakSensorLimit": 10, "DiagnosticCollectionLimit": 1, "OverHeatCountLimit": 3, "UnderHeatCountLimit": 3, "CloseValveTimeout": 255, "OpenValveTimeout": 255, "InitialDispenserPressure": 1.5, "InitialDispenserTimeout": 60000, "InitialDispenserTimeLag": 100, "DispenserBuildPressureSpeed": 800, "DispenserBuildPressureLimit": 0.9, "DispenserBuildPressureTimeout": 80000, "DispenserBuildPressureLag": 50, "ACHeatersLowerOperationLimit": 995, "ACHeatersUpperOperationLimit": 1005, "DCHeatersLowerOperationLimit": 978, "DCHeatersUpperOperationLimit": 1005, "DispenserPresegmentWFCF": 80, "StartHeatingOnInitSequence": true, "GeneralParameters": [ 1, 1, 1, 1, 800, 1000 ], "CurrentAlarmLowLimit": 0.8, "CurrentAlarmHighLimit": 1.07, "IDSSegmentRefillTimeout": 5000, "IDSPreSegmentBuildupTime": 5000, "IDSCleaningSpeed": 50, "IDSCleaningStopBeforeSegmentTime": 3000, "IDSCleaningStartSprayPreSegmentTime": 1000, "IDSLeftCleaningMotorSpeed": 30, "IDSRightCleaningMotorSpeed": 23, "SwitchToIdleTimeinSeconds": 3600, "IdleDrierTemperature": 80, "IdleHeadTemperature": 80, "PowerOffTemperatureLimit": 50, "IDSPreSegmentWFCFTimeBeforeSegment": 1500 } */


}