blob: 599cb66ecb3cf135ffe5bc1cd16c6fcade6ddb6e (
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
|
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;
const byte YES = 0x01;
const byte NO = 0x00;
//--------------------------------------------------------------------------------------------------------------
// ------ Request Parameters ------
const byte CODE_STRING = 0x01;//BTSR ID
const byte FUNCTION_STRING = 0x4B;
const Int32 Auto_Calc_CheckSum = YES;//1 YES, 0 NO //if YES Don't send the checksum Bytes!!!!
// ------ Response Parameters ------
const Int32 BytesToRead = 1;//Number of the expected Bytes to read (iclude CHECK_STRING if available)
const Int32 Verify_Received_CheckSum = NO;//1 YES, 0 NO --- TBD NA ---
//--------------------------------------------------------------------------------------------------------------
int BTSR_Write_and_Read()
{
StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest();
stubI2CWriteBytesRequest.I2CId = 0xFEED; // - Don't Change!! BTSR FEEDR (Script identification)
stubI2CWriteBytesRequest.SlaveAddress = Auto_Calc_CheckSum;
UInt32 uInt32 = new UInt32();
//--------------------------------------------------------------
stubI2CWriteBytesRequest.BytesTWrite.Add(CODE_STRING);//Byte 0 to write CODE_STRING
stubI2CWriteBytesRequest.BytesTWrite.Add(FUNCTION_STRING);//Byte 1 to write FUNCTION_STRING
//DATA_STRING
stubI2CWriteBytesRequest.BytesTWrite.Add(0xCD);//1° BYTE WORK TENSION (LSB)
stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//2° BYTE WORK TENSION (MSB)
stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//3° BYTE OUTPUT TENSION (LSB)
stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//4° BYTE OUTPUT TENSION (MSB)
stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//5° BYTE RELAX YARN (LSB)
stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//6° BYTE RELAX YARN (MSB)
stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//7° BYTE INC DEC TENSION
stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//8° BYTE INC DEC STRETCH
stubI2CWriteBytesRequest.BytesTWrite.Add(0x02);//9° BYTE TENSION ERROR (LSB)
stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//10° BYTE TENSION ERROR (MSB)
stubI2CWriteBytesRequest.BytesTWrite.Add(0x04);//11° BYTE TIME ALARM (LSB)
stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//12° BYTE TIME ALARM (MSB)
stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//13° BYTE RELAX SPEED
stubI2CWriteBytesRequest.BytesTWrite.Add(10);//14° BYTE APPLICATION
stubI2CWriteBytesRequest.BytesTWrite.Add(3);//15° BYTE YARN TYPE
stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//16° BYTE SPARE
stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//17° BYTE SPARE
stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//18° BYTE SPARE
stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//19° BYTE SPARE
stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//20° BYTE ALARM ENABLING
stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//21° BYTE ABILITAZIONE
var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest);
return 1;
}
int BTSR_Get()
{
StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest();
stubI2CReadBytesRequest.I2CId = 0xFEED; // - Don't Change!! BTSR FEEDR (Script indentify)
stubI2CReadBytesRequest.SlaveAddress = Verify_Received_CheckSum;
stubI2CReadBytesRequest.NumberOfBytesToRead = BytesToRead;
var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest);
uint temph=0;
for(int i=0; i<stubI2CReadBytesRequest.NumberOfBytesToRead;i++)
{
temph=response1.ReadBytes[i];
stubManager.WriteLineHex(temph,2);
}
return 1;
}
public void OnExecute(StubManager stubManager)
{
BTSR_Write_and_Read();
Thread.Sleep(15); //wait 10mSec in the embedded to read all at once so this value must be > 10 milli.
stubManager.WriteLine("\n --- ADVANCED STYLE LOAD --- \n");
BTSR_Get();
}
|