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) { // parameters version for TESTING 1.5.3.5 string description = ""; ConfigurationParameters configurationParameters = new ConfigurationParameters(); description += "Version 1.5.3.5"; 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; // 7 minutes - long prepare for 5 cycles build 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 = 1010; //temperature band 1000 = 100% - thresholds for job start around target temprature - DC configurationParameters.DCHeatersLowerOperationLimit = 978; configurationParameters.DCHeatersUpperOperationLimit = 1020; // mid tank reading offset to add to the readout (OBSOLETE!) configurationParameters.MidTankPressureCorrection = 0.0; //waste factor for intersegment pressure building configurationParameters.DispenserPresegmentWFCF = 40; 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 = 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 description = description+" Cl"+configurationParameters.IDSCleaningStopBeforeSegmentTime/1000+"-"+configurationParameters.IDSCleaningStartSprayPreSegmentTime/1000; 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; description = description+"-"+Tup+"."+Tdelay1+"."+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 = 1.0; configurationParameters.GeneralParameters.Add(checkCurrentAlarms); //check the tamper alarms /*3*/ Double checkTamperAlarms = new Double(); checkTamperAlarms = 0.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); 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 = 0.07; configurationParameters.GeneralParameters.Add(AllowedRangeForHeadBlowerDeviation); /*12*/ double AllowedRangeForWasteBlowerDeviation = new Double(); AllowedRangeForWasteBlowerDeviation = 0.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; //stubManager.Write("\n\n"+description); stubManager.Write("\n\n"+configurationParameters.Description+"\n\n"); File.WriteAllBytes("C:/temp/EmbParam.cfg",configurationParameters.ToBytes()); byte[] fileBytes = configurationParameters.ToBytes(); 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(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(fileUploadRequest); Thread.Sleep(1000); long chunk_size = response2.MaxChunkLength; stubManager.Write("Chunk size "+ chunk_size + " file size "+ fileBytes.Length +"\n\n"); FileChunkUploadRequest fileChunkUploadRequest = new FileChunkUploadRequest(); fileChunkUploadRequest.UploadID = response2.UploadID; fileChunkUploadRequest.Buffer = ByteString.CopyFrom(fileBytes); var response3 = stubManager.Run(fileChunkUploadRequest); // activating the new file ProgressRequest progressRequest = new ProgressRequest(); progressRequest.Amount = 0xCD; progressRequest.Delay = 0xCD; var response1 = stubManager.Run(progressRequest); }