blob: 3bd4b1f8444d3c90f7c939f7ebeea1b15a8a4195 (
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
|
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.Drawing;
using Google.Protobuf;
using Tango.BL.Entities;
using Tango.BL.Enumerations;
using Tango.PMR.Stubs;
using Tango.PMR.Diagnostics;
using Tango.FSE.Common.Connection;
using Tango.FSE.Common.Diagnostics;
using Tango.FSE.Procedures;
public class Program
{
double V0_default_ml = 8.7433;
public void OnExecute(IProcedureContext context)
{
var response1 = context.RequestUserInputFor<String>("Warning - you are going to change the value of Vo in the eeprom !!!\nPlease Enter Password to confirme:","");
if (response1=="Aa123456")
{
context.WriteLine(response1);
//Write_0_Vo_in_ml_to_eeprom
context.WriteLine("\nWrite_0_Vo_in_ml_to_eeprom");
StubWhsEEpromRequest stubWhsEEpromRequest = new StubWhsEEpromRequest();
stubWhsEEpromRequest.BurnRequest = true; //write
StubWhsEEpromData stubWhsEEpromData = new StubWhsEEpromData();
stubWhsEEpromData.Orifice1Flow = 0;
stubWhsEEpromRequest.WhsEEprom = stubWhsEEpromData;
var response = context.Send<StubWhsEEpromResponse>(stubWhsEEpromRequest);
//wait_10mSec
context.WriteLine("\nwait_10mSec");
Thread.Sleep(100); //Sleep for 10 milli.
//Read_Vo_in_ml_from_eeprom & verify it is 0
context.WriteLine("\nRead_Vo_in_ml_from_eeprom & verify it is 0");
stubWhsEEpromRequest.BurnRequest = false; //write
stubWhsEEpromRequest.WhsEEprom = stubWhsEEpromData;
var response2 = context.Send<StubWhsEEpromResponse>(stubWhsEEpromRequest);
//Read_Vo_in_mV
context.WriteLine("\nRead_Vo_in_mV");
var response3 = context.Send<ProgressResponse>("ProgressRequest" ,0x3EC, 0x01);
//Print_Vo_in_mV
context.WriteLine(response3.Progress);
//check validity
context.WriteLine("\ncheck validity");
if((response3.Progress <= 800) || (response3.Progress >=1200))
{
response3.Progress = 1076; //default
context.Write("\nERROR ------ Vreading value outside the defined range !!! ------");
context.AddResult(ResultType.Failed , "Error", "ERROR ------ Vreading value outside the defined range !!! ------");
}
else
{
//calculate_V0_in_ml
context.WriteLine("\ncalculate_V0_in_ml");
V0_default_ml = V0_default_ml * response3.Progress;
//print_Vo_in_ml
context.WriteLine("\nprint_Vo_in_ml");
context.WriteLine(V0_default_ml);
context.WriteLine("");
//Write_Vo_in_ml_to_eeprom
context.WriteLine("\nWrite_Vo_in_ml_to_eeprom");
stubWhsEEpromRequest.BurnRequest = true; //write
stubWhsEEpromData.Orifice1Flow = V0_default_ml;
stubWhsEEpromRequest.WhsEEprom = stubWhsEEpromData;
var response4 = context.Send<StubWhsEEpromResponse>(stubWhsEEpromRequest);
//wait_10mSec
context.WriteLine("\nwait_10mSec");
Thread.Sleep(100); //Sleep for 10 milli.
//Read_Vo_in_ml_from_eeprom
context.WriteLine("\nRead_Vo_in_ml_from_eeprom");
stubWhsEEpromRequest.BurnRequest = false; //write
stubWhsEEpromRequest.WhsEEprom = stubWhsEEpromData;
var response5 = context.Send<StubWhsEEpromResponse>(stubWhsEEpromRequest);
//Check if we read the correct value
context.WriteLine("\nVerify that we read the correct value of Orifice1Flow!!");
context.AddResult(ResultType.Passed , "Pass", "Calibration Pass.");
}
}
else
{
context.AddResult(ResultType.Failed , "Error", "Password Fail.");
}
context.WriteLine("\n -- END OF SCRIPT -- ");
}
}
|