aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Stubs Collection/Procedures/Winder Calibration.txt
blob: a06e94e3141e3e79e387bf811d8ab304c7a32bb5 (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
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.IO;
using Tango.FSE.Procedures;
using System.IO;
using System.Windows.Forms;



public class Program
{
    public void OnExecute(IProcedureContext context)
    {
		uint SCREW_MOTOR = 14;
		int offset = 200;
		int Calibration_Offset = 0;
		bool Located = false;
		string box_msg = "Keep your hands away from the winder";
		MessageBox.Show(box_msg);
		MotorHomingRequest motorHomingRequest = new MotorHomingRequest();
		motorHomingRequest.MotorType = Tango.PMR.Hardware.HardwareMotorType.MotoScrew;
		motorHomingRequest.Speed = 800;
		motorHomingRequest.Direction = Tango.PMR.Diagnostics.MotorDirection.Backward;
		
       	offset = context.GetInput<int>("Initial Offset");

		StubMotorMovRequest stubMotorMovRequest = new StubMotorMovRequest();
		stubMotorMovRequest.MotorID = SCREW_MOTOR;
		stubMotorMovRequest.Direction = true;
		while (Located == false)
		{
			context.Send<MotorHomingResponse>(motorHomingRequest);
			Thread.Sleep(3000);
			stubMotorMovRequest.Position = (uint)(offset + Calibration_Offset);
			context.Send<StubMotorMovResponse>(stubMotorMovRequest);
			Thread.Sleep(3000);


			Located = context.GetInput<bool>("Is Winder located well?");
			if (Located == false)
			{
				offset = context.GetInput<int>("Enter new value for calibration offset (15 steps = 1mm. minus - toward the machine");
			}
		}
		
		ProgressRequest progressRequest = new ProgressRequest();
		progressRequest.Amount = 0xB20;
		progressRequest.Delay = Calibration_Offset;
		context.Send<ProgressResponse>(progressRequest);
		box_msg = "Writing new winder offset " + Calibration_Offset+ "to the main card EEPROM";
		MessageBox.Show(box_msg);

    }
}