aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Stubs Collection/stubs/embeddedparametersbuild_w_cleaning.cs
blob: 7319b8f41539b2a5efa25df3c930fbd9d8b65652 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
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();

configurationParameters.BreakSensorLimit = 10;

//how many samples to collect in diagnostics before sending
configurationParameters.DiagnosticCollectionLimit = 1;

//how many consecutive readout before declaring DC over/underheat alarm
configurationParameters.OverHeatCountLimit = 3;
configurationParameters.UnderHeatCountLimit = 3;

// time of motor activity before opening the valve or after closing the valve, in milliseconds
configurationParameters.CloseValveTimeout = 20;
configurationParameters.OpenValveTimeout = 20;

//backlash after filling - target pressure, timoeout, time staps (speed will be added in general parameters)
configurationParameters.InitialDispenserPressure = 3.85; //used for initial pre-run maximal pressure
configurationParameters.InitialDispenserTimeout = 120000; ////used for initial pre-run target number of steps
configurationParameters.InitialDispenserTimeLag = 100;

//job prepare - build pressure in dispensers - target pressure, timoeout, time staps, speed
configurationParameters.DispenserBuildPressureSpeed = 950; //no more than 1000
configurationParameters.DispenserBuildPressureLimit = 0.85; 
configurationParameters.DispenserBuildPressureTimeout = 420000; // 7 minutes - long prepare for 5 cycles build
configurationParameters.DispenserBuildPressureLag = 100;

//temperature band 1000 = 100% - thresholds for job start around target temprature - AC
configurationParameters.ACHeatersLowerOperationLimit = 995;
configurationParameters.ACHeatersUpperOperationLimit = 1005;

//temperature band 1000 = 100% - thresholds for job start around target temprature - DC
configurationParameters.DCHeatersLowerOperationLimit = 978;
configurationParameters.DCHeatersUpperOperationLimit = 1005;

// mid tank reading offset to add to the readout (OBSOLETE!)
configurationParameters.MidTankPressureCorrection = 0.0;

//waste factor for intersegment pressure building
configurationParameters.DispenserPresegmentWFCF = 40;
//how much time to start the WFCF process (pressure buildup) before segment start
configurationParameters.IDSPreSegmentWFCFTimeBeforeSegment = 12000;

//flag: start heaters according to saved process parameters upon init?
configurationParameters.StartHeatingOnInitSequence = true;

// current test for the heaters - alarm thresholds
configurationParameters.CurrentAlarmLowLimit = 0.78;
configurationParameters.CurrentAlarmHighLimit = 1.07;

//currently not in use
configurationParameters.IDSSegmentRefillTimeout = 5000;
configurationParameters.IDSPreSegmentBuildupTime = 5000;
//cleaning!!!!!!!!!!
configurationParameters.IDSCleaningSpeed = 800;
configurationParameters.IDSCleaningStopBeforeSegmentTime = 10000;  //end of presegemnt
configurationParameters.IDSCleaningStartSprayPreSegmentTime =2000; //beginning of presegment

int Tup = 10,Tdelay1 = 98,Tdelay2 = 198; //350nsec up, 1 second delay, 2 seconds before up again
//   Tup = LeftRockerSpeed/100;
//    Tdelay1 = LeftRockerSpeed%100;
//    Tdelay2 = RightRockerSpeed;
int LeftRockerSpeed = Tup*100+Tdelay1;
int RightRockerSpeed = Tdelay2;

configurationParameters.IDSLeftCleaningMotorSpeed = LeftRockerSpeed;
configurationParameters.IDSRightCleaningMotorSpeed = RightRockerSpeed;

configurationParameters.SwitchToIdleTimeinSeconds = 3600;
configurationParameters.IdleDrierTemperature = 80;
configurationParameters.IdleHeadTemperature = 80;
configurationParameters.IdleMixerTemperature = 0;
configurationParameters.PowerOffTemperatureLimit = 60;

//general parameters, ORDER MUST BE PRESERVED!!!!
//check the dispensers hard limit alarms
/*1*/
Double checkHardLimitAlarms = new Double();

checkHardLimitAlarms = 1.0;
configurationParameters.GeneralParameters.Add(checkHardLimitAlarms);

/*2*/
Double checkCurrentAlarms = new Double();
checkCurrentAlarms = 0.0;
configurationParameters.GeneralParameters.Add(checkCurrentAlarms);
//check the tamper alarms

/*3*/
Double checkTamperAlarms = new Double();
checkTamperAlarms = 1.0;
configurationParameters.GeneralParameters.Add(checkTamperAlarms);

/*4*/
Double checkMotorAlarms = new Double();
checkMotorAlarms = 1.0;
configurationParameters.GeneralParameters.Add(checkMotorAlarms);

/*5*/
Double WinderBackToBaseTime = new Double();
WinderBackToBaseTime = 820.0;
configurationParameters.GeneralParameters.Add(WinderBackToBaseTime);

/*6*/
Double DispenserInitialPressureSpeed = new Double();
DispenserInitialPressureSpeed = 1050.0;
configurationParameters.GeneralParameters.Add(DispenserInitialPressureSpeed);

/*7*/
Double SetDiagnosticMode = new Double();
SetDiagnosticMode = 3.0;
configurationParameters.GeneralParameters.Add(SetDiagnosticMode);

/*8*/
Double SetAutoFill = new Double();
SetAutoFill = 3.0;
configurationParameters.GeneralParameters.Add(SetAutoFill);

double PowerOffDisableCleaning = new Double();
PowerOffDisableCleaning = 0.0;
configurationParameters.GeneralParameters.Add(PowerOffDisableCleaning);

double SublimationBlowTime = new Double();
SublimationBlowTime = 30.0;
configurationParameters.GeneralParameters.Add(SublimationBlowTime);

double AllowedRangeForHeadBlowerDeviation = new Double();
AllowedRangeForHeadBlowerDeviation = 7;
configurationParameters.GeneralParameters.Add(AllowedRangeForHeadBlowerDeviation);

double AllowedRangeForWasteBlowerDeviation = new Double();
AllowedRangeForWasteBlowerDeviation = 10;
configurationParameters.GeneralParameters.Add(AllowedRangeForWasteBlowerDeviation);



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);


stubManager.Write("\n\n Deleting old file");

DeleteRequest deleteRequest = new DeleteRequest();
deleteRequest.Path = "SYSINFO//EmbParam.cfg";
deleteRequest.Attribute = Tango.PMR.IO.FileAttribute.Unspecified;
DeleteResponse response5 = stubManager.Run<DeleteResponse>(deleteRequest);


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

FileUploadRequest fileUploadRequest = new FileUploadRequest();
fileUploadRequest.Path = "SYSINFO//EmbParam.cfg";
fileUploadRequest.Length = (int)fileBytes.Length;
FileUploadResponse response2 = stubManager.Run<FileUploadResponse>(fileUploadRequest);
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);

}

// activating the new file
ProgressRequest progressRequest = new ProgressRequest();
progressRequest.Amount = 0xCD;
progressRequest.Delay = 0xCD;
var response1 = stubManager.Run<ProgressResponse>(progressRequest);


/*
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 } */


}