aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Stubs Collection/Procedures/EmbeddedParametersBuild.txt
blob: a4d81d3bacafabd4566babc3735fa589a2d5a990 (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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using Google.Protobuf;
using Tango.BL.Enumerations;
using Tango.PMR.Stubs;
using Tango.PMR.Diagnostics;
using Tango.FSE.Common.Diagnostics;
using Tango.PMR.EmbeddedParameters;
using Tango.PMR.IO;
using Tango.FSE.Procedures;


public class Cleaning
{
	[Description("Actuator Going up time")]
	public int Tup;
	[Description("Actuator Wait up time")]
	public int Tdelay1;
	[Description("Actuator Wait Down time")]
	public int Tdelay2;
}
public class Advanced
{
	[Description("Automatic heating on machine StartUp")]
	public bool InitialHeating;
	[Description("Waste pressure buildup factor")]
	public int WFCF;
	[Description("Auto fill mode on/off")]
	public bool Autofill;
}

public class Program
{
    public void OnExecute(IProcedureContext context)
    {
	string description = "";
        context.AddResult(ResultType.Passed, "My Value Name", "Test for this value has passed.");
		ConfigurationParameters configurationParameters = new ConfigurationParameters();

		bool AdvancedParams = context.GetInput<bool>("AdvancedParameters");
		Advanced Advancedparam = new Advanced();
		Advancedparam.InitialHeating = true;
		Advancedparam.WFCF = 40;
		Advancedparam.Autofill = true;
		if (AdvancedParams == true)
        	Advancedparam =	context.RequestUserInputFor<Advanced>(Advancedparam,"Advanced parameters input Required","Please fill in the form");
		description += "Version 1.5.3.3"; 
		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;
		description = description+" "+configurationParameters.InitialDispenserPressure+"-"+configurationParameters.InitialDispenserTimeout/1000;

		//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;
		configurationParameters.DispenserBuildPressureLag = 100;
		description = description+" T "+configurationParameters.DispenserBuildPressureTimeout/1000;

		//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 = Advancedparam.WFCF;
		description = description+" WF"+configurationParameters.DispenserPresegmentWFCF;
		
		//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 = Advancedparam.InitialHeating;

		// 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
		description = description+" Cl"+configurationParameters.IDSCleaningStopBeforeSegmentTime/1000+"-"+configurationParameters.IDSCleaningStartSprayPreSegmentTime/1000;
		
		bool SetCleaning = context.GetInput<bool>("SetCleaningValues");
        Cleaning Clean = new Cleaning();
		Clean.Tup = 10;
		Clean.Tdelay1 = 98;
		Clean.Tdelay2 = 198;//300 milli up, stay 1 sec, stay down 2 sec
		if (SetCleaning == true)
        	Clean =	context.RequestUserInputFor<Cleaning>(Clean,"Cleaning Input Required","Please fill in the form");

		//   Tup = LeftRockerSpeed/100;
		//    Tdelay1 = LeftRockerSpeed%100;
		//    Tdelay2 = RightRockerSpeed;
		int LeftRockerSpeed = Clean.Tup*100+Clean.Tdelay1;
		int RightRockerSpeed = Clean.Tdelay2;

		configurationParameters.IDSLeftCleaningMotorSpeed = LeftRockerSpeed;
		configurationParameters.IDSRightCleaningMotorSpeed = RightRockerSpeed;
		description = description+"-"+Clean.Tup+"."+Clean.Tdelay1+"."+Clean.Tdelay2;

		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 = context.GetInput<double>("CheckTampers");
		configurationParameters.GeneralParameters.Add(checkTamperAlarms);

		/*4*/
		Double checkMotorAlarms = new Double();
		checkMotorAlarms = 1.0;
		configurationParameters.GeneralParameters.Add(checkMotorAlarms);
		description = description+"-Cur"+checkCurrentAlarms+"Tamp"+checkTamperAlarms+"Mot"+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;		
		if (Advancedparam.Autofill == false)
			SetAutoFill = 0.0;
		configurationParameters.GeneralParameters.Add(SetAutoFill);
		description = description+"-AF"+SetAutoFill+"DI"+SetDiagnosticMode;
		/*9*/
		double PowerOffDisableCleaning = new Double();
		PowerOffDisableCleaning = 0.0;
		configurationParameters.GeneralParameters.Add(PowerOffDisableCleaning);
		/*10*/
		double SublimationBlowTime = new Double();
		SublimationBlowTime = 30.0;
		configurationParameters.GeneralParameters.Add(SublimationBlowTime);
		/*11*/
		double AllowedRangeForHeadBlowerDeviation = new Double();
		AllowedRangeForHeadBlowerDeviation = 7;
		configurationParameters.GeneralParameters.Add(AllowedRangeForHeadBlowerDeviation);
		/*12*/
		double AllowedRangeForWasteBlowerDeviation = new Double();
		AllowedRangeForWasteBlowerDeviation = 20;
		configurationParameters.GeneralParameters.Add(AllowedRangeForWasteBlowerDeviation);
		/*13*/
		double Voltage_Hysteresis = new Double();
		Voltage_Hysteresis = 4;
		configurationParameters.GeneralParameters.Add(Voltage_Hysteresis);
		/*14*/
		double Head_Blower_Calculation_C = new Double();
		Head_Blower_Calculation_C = 0.242;
		configurationParameters.GeneralParameters.Add(Head_Blower_Calculation_C);
		/*15*/
		double Head_Blower_Calculation_B = new Double();
		Head_Blower_Calculation_B = -0.134;
		configurationParameters.GeneralParameters.Add(Head_Blower_Calculation_B);
		description = description+"-C"+Head_Blower_Calculation_C+"-B"+Head_Blower_Calculation_B;

		configurationParameters.Description = description;
		

		//configurationParameters	= context.RequestUserInputFor<ConfigurationParameters>(configurationParameters,"ConfigurationParameters Input Required","Please fill in the form");
		/*Directory.CreateDirectory ("C:/Temp");
		File.WriteAllBytes("C:/temp/EmbParam.cfg",configurationParameters.ToBytes());

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


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

		context.Write( config);
		Thread.Sleep(1000);

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

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


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

		FileUploadRequest fileUploadRequest = new FileUploadRequest();
		fileUploadRequest.Path = "SYSINFO//EmbParam.cfg";
		fileUploadRequest.Length = (int)fileBytes.Length;
		FileUploadResponse response2 = context.Send<FileUploadResponse>(fileUploadRequest);
		Thread.Sleep(1000);
		long chunk_size = response2.MaxChunkLength;

		context.Write("Chunk size "+ chunk_size + " file size "+ fileBytes.Length +"\n\n");
		if (chunk_size < fileBytes.Length)
		{
			context.AddResult(ResultType.Failed, "Chunk size too small", chunk_size);
		}
		else
		{
			FileChunkUploadRequest fileChunkUploadRequest = new FileChunkUploadRequest();
			fileChunkUploadRequest.UploadID = response2.UploadID;
			fileChunkUploadRequest.Buffer = ByteString.CopyFrom(fileBytes);	
			var response3 = context.Send<FileChunkUploadResponse>(fileChunkUploadRequest);
		
			//if (response3.

			// activating the new file
			ProgressRequest progressRequest = new ProgressRequest();
			progressRequest.Amount = 0xCD;
			progressRequest.Delay = 0xCD;
			var response1 = context.Send<ProgressResponse>(progressRequest);
			context.AddResult(ResultType.Passed, "parameters loaded", chunk_size);
		}

    }
}