aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/embeddedparametersbuild.cs
blob: 6627a4d60a1339236ba8211ee7607efc12109b87 (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
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.Web
{
    [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
    publicpre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
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 = 20;
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 } */


}