VERSION 5.00 Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "comctl32.ocx" Begin VB.Form frmRead Caption = "Read" ClientHeight = 10875 ClientLeft = 60 ClientTop = 345 ClientWidth = 15240 LinkTopic = "Form1" ScaleHeight = 10875 ScaleWidth = 15240 Begin VB.Timer tmrStore Interval = 30000 Left = 13680 Top = 120 End Begin VB.ComboBox cboVariable Height = 315 Index = 5 ItemData = "Fichero.frx":0000 Left = 11280 List = "Fichero.frx":0016 TabIndex = 84 Text = "V" Top = 9720 Width = 615 End Begin VB.ComboBox cboVariable Height = 315 Index = 4 ItemData = "Fichero.frx":002C Left = 11280 List = "Fichero.frx":0042 TabIndex = 83 Text = "T" Top = 8160 Width = 615 End Begin VB.ComboBox cboVariable Height = 315 Index = 3 ItemData = "Fichero.frx":0058 Left = 11280 List = "Fichero.frx":006E TabIndex = 82 Text = "P" Top = 6480 Width = 615 End Begin VB.ComboBox cboVariable Height = 315 Index = 2 ItemData = "Fichero.frx":0084 Left = 11280 List = "Fichero.frx":009A TabIndex = 81 Text = "Z" Top = 4680 Width = 615 End Begin VB.ComboBox cboVariable Height = 315 Index = 1 ItemData = "Fichero.frx":00B0 Left = 11280 List = "Fichero.frx":00C6 TabIndex = 80 Text = "Y" Top = 3120 Width = 615 End Begin VB.ComboBox cboVariable Height = 315 Index = 0 ItemData = "Fichero.frx":00DC Left = 11280 List = "Fichero.frx":00F2 TabIndex = 79 Text = "X" Top = 1560 Width = 615 End Begin VB.ComboBox cboSensor Height = 315 Index = 5 ItemData = "Fichero.frx":0108 Left = 11280 List = "Fichero.frx":010A TabIndex = 78 Top = 9360 Width = 615 End Begin VB.ComboBox cboSensor Height = 315 Index = 4 ItemData = "Fichero.frx":010C Left = 11280 List = "Fichero.frx":010E TabIndex = 77 Top = 7800 Width = 615 End Begin VB.ComboBox cboSensor Height = 315 Index = 3 ItemData = "Fichero.frx":0110 Left = 11280 List = "Fichero.frx":0112 TabIndex = 76 Top = 6120 Width = 615 End Begin VB.ComboBox cboSensor Height = 315 Index = 2 ItemData = "Fichero.frx":0114 Left = 11280 List = "Fichero.frx":0116 TabIndex = 75 Top = 4320 Width = 615 End Begin VB.ComboBox cboSensor Height = 315 Index = 1 ItemData = "Fichero.frx":0118 Left = 11280 List = "Fichero.frx":011A TabIndex = 74 Top = 2760 Width = 615 End Begin VB.ComboBox cboSensor Height = 315 Index = 0 ItemData = "Fichero.frx":011C Left = 11280 List = "Fichero.frx":011E TabIndex = 73 Top = 1200 Width = 615 End Begin VB.PictureBox pctGraph AutoRedraw = -1 'True BackColor = &H00FFFFFF& Height = 1455 Index = 5 Left = 5640 ScaleHeight = 1395 ScaleWidth = 4515 TabIndex = 51 Top = 9240 Width = 4575 End Begin VB.PictureBox pctGraph AutoRedraw = -1 'True BackColor = &H00FFFFFF& Height = 1455 Index = 4 Left = 5640 ScaleHeight = 1395 ScaleWidth = 4515 TabIndex = 50 Top = 7680 Width = 4575 End Begin VB.PictureBox pctGraph AutoRedraw = -1 'True BackColor = &H00FFFFFF& Height = 1455 Index = 3 Left = 5640 ScaleHeight = 1395 ScaleWidth = 4515 TabIndex = 49 Top = 6120 Width = 4575 End Begin VB.PictureBox pctGraph AutoRedraw = -1 'True BackColor = &H00FFFFFF& Height = 1455 Index = 2 Left = 5640 ScaleHeight = 1395 ScaleWidth = 4515 TabIndex = 48 Top = 4200 Width = 4575 End Begin VB.PictureBox pctGraph AutoRedraw = -1 'True BackColor = &H00FFFFFF& Height = 1455 Index = 1 Left = 5640 ScaleHeight = 1395 ScaleWidth = 4515 TabIndex = 47 Top = 2640 Width = 4575 End Begin ComctlLib.Slider sldZoom Height = 495 Index = 0 Left = 10440 TabIndex = 27 Top = 2040 Width = 1695 _ExtentX = 2990 _ExtentY = 873 _Version = 327682 Min = 1 SelStart = 1 Value = 1 End Begin VB.PictureBox pctGraph AutoRedraw = -1 'True BackColor = &H00FFFFFF& Height = 1455 Index = 0 Left = 5640 ScaleHeight = 1395 ScaleWidth = 4515 TabIndex = 24 Top = 1080 Width = 4575 End Begin VB.Timer tmrTime Interval = 10 Left = 5160 Top = 240 End Begin VB.TextBox txtTime Height = 495 Left = 6360 TabIndex = 15 Text = "0" Top = 240 Width = 975 End Begin VB.ListBox lstMsg_T Height = 3570 ItemData = "Fichero.frx":0120 Left = 1080 List = "Fichero.frx":0122 TabIndex = 10 TabStop = 0 'False Top = 6720 Width = 3855 End Begin VB.ListBox lstMsg_V Height = 3570 ItemData = "Fichero.frx":0124 Left = 1080 List = "Fichero.frx":0126 TabIndex = 6 TabStop = 0 'False Top = 1680 Width = 3855 End Begin VB.Timer tmrRead Interval = 10 Left = 2280 Top = 720 End Begin VB.CommandButton cmdExit Caption = "Exit" Height = 495 Left = 14280 TabIndex = 2 Top = 720 Width = 855 End Begin VB.CommandButton cmdCAN_Close Caption = "CAN_Close" Height = 495 Left = 2400 TabIndex = 1 Top = 120 Width = 1095 End Begin VB.CommandButton cmdCAN_Init Caption = "CAN_Init" Height = 495 Left = 240 TabIndex = 0 Top = 120 Width = 1095 End Begin ComctlLib.Slider sldZoom Height = 495 Index = 1 Left = 10440 TabIndex = 68 Top = 3600 Width = 1695 _ExtentX = 2990 _ExtentY = 873 _Version = 327682 Min = 1 SelStart = 1 Value = 1 End Begin ComctlLib.Slider sldZoom Height = 495 Index = 2 Left = 10440 TabIndex = 69 Top = 5160 Width = 1695 _ExtentX = 2990 _ExtentY = 873 _Version = 327682 Min = 1 SelStart = 1 Value = 1 End Begin ComctlLib.Slider sldZoom Height = 495 Index = 3 Left = 10440 TabIndex = 70 Top = 7080 Width = 1695 _ExtentX = 2990 _ExtentY = 873 _Version = 327682 Min = 1 SelStart = 1 Value = 1 End Begin ComctlLib.Slider sldZoom Height = 495 Index = 4 Left = 10440 TabIndex = 71 Top = 8640 Width = 1695 _ExtentX = 2990 _ExtentY = 873 _Version = 327682 Min = 1 SelStart = 1 Value = 1 End Begin ComctlLib.Slider sldZoom Height = 495 Index = 5 Left = 10440 TabIndex = 72 Top = 10200 Width = 1695 _ExtentX = 2990 _ExtentY = 873 _Version = 327682 Min = 1 SelStart = 1 Value = 1 End Begin VB.Label lblMin Height = 375 Index = 5 Left = 5160 TabIndex = 67 Top = 10320 Width = 375 End Begin VB.Label lblMin Height = 375 Index = 4 Left = 5160 TabIndex = 66 Top = 8760 Width = 375 End Begin VB.Label lblMin Height = 375 Index = 3 Left = 5160 TabIndex = 65 Top = 7200 Width = 375 End Begin VB.Label lblMin Height = 375 Index = 2 Left = 5160 TabIndex = 64 Top = 5280 Width = 375 End Begin VB.Label lblMin Height = 375 Index = 1 Left = 5160 TabIndex = 63 Top = 3720 Width = 375 End Begin VB.Label lblMin Height = 375 Index = 0 Left = 5160 TabIndex = 62 Top = 2160 Width = 375 End Begin VB.Label lblMax Height = 375 Index = 5 Left = 5160 TabIndex = 61 Top = 9360 Width = 375 End Begin VB.Label lblMax Height = 375 Index = 4 Left = 5160 TabIndex = 60 Top = 7800 Width = 375 End Begin VB.Label lblMax Height = 375 Index = 3 Left = 5160 TabIndex = 59 Top = 6240 Width = 375 End Begin VB.Label lblMax Height = 375 Index = 2 Left = 5160 TabIndex = 58 Top = 4320 Width = 375 End Begin VB.Label lblMax Height = 375 Index = 1 Left = 5160 TabIndex = 57 Top = 2760 Width = 375 End Begin VB.Label lblvble Caption = "V" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Index = 5 Left = 5280 TabIndex = 56 Top = 9840 Width = 255 End Begin VB.Label lblvble Caption = "T" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Index = 4 Left = 5280 TabIndex = 55 Top = 8280 Width = 255 End Begin VB.Label lblvble Caption = "P" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Index = 3 Left = 5280 TabIndex = 54 Top = 6720 Width = 255 End Begin VB.Label lblvble Caption = "Z" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Index = 2 Left = 5280 TabIndex = 53 Top = 4800 Width = 255 End Begin VB.Label lblvble Caption = "Y" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Index = 1 Left = 5280 TabIndex = 52 Top = 3240 Width = 255 End Begin VB.Label lblVariable Caption = "Variable" Height = 255 Index = 5 Left = 10440 TabIndex = 46 Top = 9720 Width = 615 End Begin VB.Label lblVariable Caption = "Variable" Height = 255 Index = 4 Left = 10440 TabIndex = 45 Top = 8160 Width = 615 End Begin VB.Label lblVariable Caption = "Variable" Height = 255 Index = 3 Left = 10440 TabIndex = 44 Top = 6600 Width = 615 End Begin VB.Label lblVariable Caption = "Variable" Height = 255 Index = 2 Left = 10440 TabIndex = 43 Top = 4680 Width = 615 End Begin VB.Label lblVariable Caption = "Variable" Height = 255 Index = 1 Left = 10440 TabIndex = 42 Top = 3120 Width = 615 End Begin VB.Label lblVariable Caption = "Variable" Height = 255 Index = 0 Left = 10440 TabIndex = 41 Top = 1560 Width = 615 End Begin VB.Label lblSensor Caption = "Sensor" Height = 255 Index = 5 Left = 10440 TabIndex = 40 Top = 9360 Width = 615 End Begin VB.Label lblSensor Caption = "Sensor" Height = 255 Index = 4 Left = 10440 TabIndex = 39 Top = 7800 Width = 615 End Begin VB.Label lblSensor Caption = "Sensor" Height = 255 Index = 3 Left = 10440 TabIndex = 38 Top = 6240 Width = 615 End Begin VB.Label lblSensor Caption = "Sensor" Height = 255 Index = 2 Left = 10440 TabIndex = 37 Top = 4320 Width = 615 End Begin VB.Label lblSensor Caption = "Sensor" Height = 255 Index = 1 Left = 10440 TabIndex = 36 Top = 2760 Width = 615 End Begin VB.Label lblSensor Caption = "Sensor" Height = 255 Index = 0 Left = 10440 TabIndex = 35 Top = 1200 Width = 615 End Begin VB.Label lblSec Caption = "0" BeginProperty Font Name = "MS Sans Serif" Size = 12 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 8640 TabIndex = 34 Top = 480 Width = 135 End Begin VB.Label lblMinute Caption = "0" BeginProperty Font Name = "MS Sans Serif" Size = 12 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 7800 TabIndex = 33 Top = 480 Width = 135 End Begin VB.Label lblpoints2 Caption = ":" BeginProperty Font Name = "MS Sans Serif" Size = 18 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Left = 9000 TabIndex = 32 Top = 360 Width = 135 End Begin VB.Label lblpoints1 Caption = ":" BeginProperty Font Name = "MS Sans Serif" Size = 18 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Left = 8160 TabIndex = 31 Top = 360 Width = 135 End Begin VB.Label lblTenmsec Caption = "0" BeginProperty Font Name = "MS Sans Serif" Size = 12 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 9240 TabIndex = 30 Top = 480 Width = 375 End Begin VB.Label lblTensec Caption = "0" BeginProperty Font Name = "MS Sans Serif" Size = 12 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 8400 TabIndex = 29 Top = 480 Width = 135 End Begin VB.Label lblTenmin Caption = "0" BeginProperty Font Name = "MS Sans Serif" Size = 12 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 7560 TabIndex = 28 Top = 480 Width = 135 End Begin VB.Label lblMax Height = 375 Index = 0 Left = 5160 TabIndex = 26 Top = 1200 Width = 375 End Begin VB.Label lblMissed Caption = "Missed messages" Height = 495 Left = 1560 TabIndex = 25 Top = 5880 Width = 735 End Begin VB.Label lblCounterMsg_Strange BorderStyle = 1 'Fixed Single Height = 495 Left = 3840 TabIndex = 23 Top = 5880 Width = 615 End Begin VB.Label lblCunter_Strange Caption = "Another LEN" Height = 255 Left = 3840 TabIndex = 22 Top = 5520 Width = 975 End Begin VB.Label lblCounterMsg_5 BorderStyle = 1 'Fixed Single Height = 495 Left = 3120 TabIndex = 21 Top = 5880 Width = 615 End Begin VB.Label lblCounterMsg_7 BorderStyle = 1 'Fixed Single Height = 495 Left = 2400 TabIndex = 20 Top = 5880 Width = 615 End Begin VB.Label lblCounter_5 Caption = "LEN=5" Height = 255 Left = 3120 TabIndex = 19 Top = 5520 Width = 615 End Begin VB.Label lblCounter_7 Caption = "LEN=7" Height = 255 Left = 2400 TabIndex = 18 Top = 5520 Width = 615 End Begin VB.Label lblvble Caption = "X" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Index = 0 Left = 5280 TabIndex = 17 Top = 1680 Width = 255 End Begin VB.Label lblTime Caption = "Time" Height = 255 Left = 5760 TabIndex = 16 Top = 120 Width = 495 End Begin VB.Label lblCounterMsg BorderStyle = 1 'Fixed Single Height = 495 Left = 240 TabIndex = 14 Top = 10200 Width = 615 End Begin VB.Label lblCounter Caption = "Counter" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 120 TabIndex = 13 Top = 9840 Width = 735 End Begin VB.Label lblCounterMsg_T BorderStyle = 1 'Fixed Single Height = 495 Left = 240 TabIndex = 12 Top = 7200 Width = 615 End Begin VB.Label lblCounter_T Caption = "Counter_T" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 120 TabIndex = 11 Top = 6840 Width = 975 End Begin VB.Label lblCounterMsg_V BorderStyle = 1 'Fixed Single Height = 495 Left = 240 TabIndex = 9 Top = 2160 Width = 615 End Begin VB.Label lblCounter_V Caption = "Counter_V" BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 120 TabIndex = 8 Top = 1800 Width = 975 End Begin VB.Label Label2 Caption = "CAN_Read" Height = 255 Left = 240 TabIndex = 7 Top = 840 Width = 975 End Begin VB.Label lblCAN_Read BorderStyle = 1 'Fixed Single Height = 495 Left = 1440 TabIndex = 5 Top = 720 Width = 735 End Begin VB.Label lblCAN_Close BorderStyle = 1 'Fixed Single Height = 495 Left = 3600 TabIndex = 4 Top = 120 Width = 735 End Begin VB.Label lblCAN_Init BorderStyle = 1 'Fixed Single Height = 495 Left = 1440 TabIndex = 3 Top = 120 Width = 735 End End Attribute VB_Name = "frmRead" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False 'ASSUMPTIONS: 'Each sensor is going to send the information in 2 messages: the first one has LEN=7 and 'the second one has LEN=5. The CAN ID of the messages will be consecutive. 'First message: 'Byte 0: header. 'Bytes 1-4: sensor ID, although we are only looking at the byte 4. 'Bytes 5-6: X or P data. 'Second message: 'Bytes 0-1: Y or T data. 'Bytes 2-3: Z or V data. 'Byte 4: status, 0->XYZ or 1->PTV. 'Each receiver is reading the data of each sensor, so it is possible to know which sensor 'is sending data with the CAN ID. '------------------------------------------------------------------------------------------ 'POSSIBLE MISTAKES: 'The file PCAN_USB.DLL should be in the same directory as the program. 'The program has to be modified at two points with the route where the user wants to store 'the text files. Those two points are into two different Sub procedure which are 'Private Sub cmdExit_Click() and Private Sub tmrStore_Timer(). 'It may be necesssary to check the baud rate in the fuction CAN_Ini in the Sub procedure 'called Private Sub cmdCAN_Init_Click(). It changes depending on the sensors. '------------------------------------------------------------------------------------------ 'DESCRIPTIONS OF THE PUBLIC VARIABLES: 'Variable which stores how many sensors are sending data. Public n_sensors As Integer 'This variable is used to count how much time has passed since the application started, 'it is increased each 10 msec. Public tenmsec_aux As Double 'These variables are also used to count how much time has passed since the application 'started, but broking down the information into small parts. Public tenmsec As Integer Public sec As Integer Public tensec As Integer Public minute As Integer Public tenmin As Integer 'These variables are used to relate the time with the beginning of PTV graphs. Public tensec_aux As Integer Public flag_aux As Integer 'Auxiliary variable to plot the data: they are necessary because the variables which count 'the time cannot restart when the graphs reach the end, so the time variables carry on 'increasing and these variables restart with the graphs. Public aux_XYZ As Integer Public aux_PTV As Integer 'In the program an array of structs is used to store all the information about a sensor in 'each struct. "Beginning" is used to redimension that array at the beginning of the program 'but just once. Public beginning As Integer Private Sub cboSensor_Change(Index As Integer) 'The user cannot write the number of the sensor which he wants it to be plotted, the user 'has to choose the number in the list. cboSensor(Index).Text = Format(graph_sensor(Index)) End Sub Private Sub cboSensor_Click(Index As Integer) 'When the user chooses the number of the sensor in the list, the plotted data has to change, 'so in the graph its scale, its labels and its axis have to change as well. graph_sensor(Index) = cboSensor(Index).Text pctGraph(Index).Cls 'The scale is different depending on the variable which has to be plotted. Select Case graph_variable(Index) Case 0 min(Index) = scale_minx max(Index) = scale_maxx Case 1 min(Index) = scale_miny max(Index) = scale_maxy Case 2 min(Index) = scale_minz max(Index) = scale_maxz Case 3 min(Index) = scale_minp max(Index) = scale_maxp Case 4 min(Index) = scale_mint max(Index) = scale_maxt Case 5 min(Index) = scale_minv max(Index) = scale_maxv End Select lblMin(Index).Caption = min(Index) lblMax(Index).Caption = max(Index) sldZoom(Index).value = 1 'Plot x and y axis Select Case graph_variable(Index) Case 0, 1, 2 pctGraph(Index).Scale (-1, max(Index))-(scalet_XYZ, min(Index)) 'Vibration graphs x,y,z pctGraph(Index).Line (-1, 0)-(scalet_XYZ, 0), vbRed 'x axis pctGraph(Index).Line (0, min(Index))-(0, max(Index)), vbRed 'y axis pctGraph(Index).PSet (0, 0), vbRed 'origin Case 3, 4, 5 pctGraph(Index).Scale (-1, max(Index))-(scalet_PTV, min(Index)) 'Pressure, temperature and voltage graphs p,t,v pctGraph(Index).Line (-1, 0)-(scalet_PTV, 0), vbRed 'x axis pctGraph(Index).Line (0, min(Index))-(0, max(Index)), vbRed 'y axis pctGraph(Index).PSet (0, 0), vbRed 'origin End Select End Sub Private Sub cboSensor_KeyPress(Index As Integer, KeyAscii As Integer) 'The user cannot write the number of the sensor which he wants it to be plotted, the user 'has to choose the number in the list. result = MsgBox("Please select a sensor in the list", 64, "Invalid value") End Sub Private Sub cboVariable_Change(Index As Integer) 'The user cannot write the name of the variable which he wants it to be plotted, the user 'has to choose the name in the list. Select Case graph_variable(Index) Case 0 cboVariable(Index).Text = "X" Case 1 cboVariable(Index).Text = "Y" Case 2 cboVariable(Index).Text = "Z" Case 3 cboVariable(Index).Text = "P" Case 4 cboVariable(Index).Text = "T" Case 5 cboVariable(Index).Text = "V" End Select End Sub Private Sub cboVariable_Click(Index As Integer) 'When the user chooses the name of the variable in the list, the plotted data has to change, 'so in the graph its scale, its labels and its axis have to change as well. For k = 0 To 5 If cboVariable(Index).Text = cboVariable(Index).List(k) Then graph_variable(Index) = k pctGraph(Index).Cls 'The scale is different depending on the variable which has to be plotted. Select Case graph_variable(Index) Case 0 min(Index) = scale_minx max(Index) = scale_maxx lblvble(Index).Caption = "X" Case 1 min(Index) = scale_miny max(Index) = scale_maxy lblvble(Index).Caption = "Y" Case 2 min(Index) = scale_minz max(Index) = scale_maxz lblvble(Index).Caption = "Z" Case 3 min(Index) = scale_minp max(Index) = scale_maxp lblvble(Index).Caption = "P" Case 4 min(Index) = scale_mint max(Index) = scale_maxt lblvble(Index).Caption = "T" Case 5 min(Index) = scale_minv max(Index) = scale_maxv lblvble(Index).Caption = "V" End Select lblMin(Index).Caption = min(Index) lblMax(Index).Caption = max(Index) sldZoom(Index).value = 1 'Plot x and y axis Select Case graph_variable(Index) Case 0, 1, 2 pctGraph(Index).Scale (-1, max(Index))-(scalet_XYZ, min(Index)) 'Vibration graphs x,y,z pctGraph(Index).Line (-1, 0)-(scalet_XYZ, 0), vbRed 'x axis pctGraph(Index).Line (0, min(Index))-(0, max(Index)), vbRed 'y axis pctGraph(Index).PSet (0, 0), vbRed 'origin Case 3, 4, 5 pctGraph(Index).Scale (-1, max(Index))-(scalet_PTV, min(Index)) 'Pressure, temperature and voltage graphs p,t,v pctGraph(Index).Line (-1, 0)-(scalet_PTV, 0), vbRed 'x axis pctGraph(Index).Line (0, min(Index))-(0, max(Index)), vbRed 'y axis pctGraph(Index).PSet (0, 0), vbRed 'origin End Select End If Next k End Sub Private Sub cboVariable_KeyPress(Index As Integer, KeyAscii As Integer) 'The user cannot write the name of the variable which he wants it to be plotted, the user 'has to choose the name in the list. result = MsgBox("Please select a variable in the list", 64, "Invalid value") End Sub Private Sub cmdCAN_Close_Click() 'Disconnect from CAN-Hardware. ret = CAN_Close() 'Display the return code. lblCAN_Close.Caption = ret End Sub Private Sub cmdCAN_Init_Click() 'Activate de hardware and reserve a send and receive buffer: 'First parameter = register for the baud rate. 'Second parameter = standard or extended message. 'In this case: 500 kBit/s and standard. ret = CAN_Init(CAN_BAUD_500K, CAN_INIT_TYPE_ST) 'Display the return code. lblCAN_Init.Caption = ret 'Plot x and y axis For Index = 0 To 5 Select Case graph_variable(Index) Case 0, 1, 2 'Vibration graphs x,y,z pctGraph(Index).Line (-1, 0)-(scalet_XYZ, 0), vbRed 'x axis pctGraph(Index).Line (0, min(Index))-(0, max(Index)), vbRed 'y axis pctGraph(Index).PSet (0, 0), vbRed 'origin Case 3, 4, 5 'Pressure, temperature and voltage graphs p,t,v pctGraph(Index).Line (-1, 0)-(scalet_PTV, 0), vbRed 'x axis pctGraph(Index).Line (0, min(Index))-(0, max(Index)), vbRed 'y axis pctGraph(Index).PSet (0, 0), vbRed 'origin End Select Next Index End Sub Private Sub cmdExit_Click() 'Before finishing the program, all the general information is stored in a text file. For 'each sensor: the sensor ID, its associated CAN ID, its associated text files and the total 'number of received messages. For i = 1 To n_sensors Open _ "C:\Documents and Settings\uos\Desktop\programs\Visual Basic\last one\General Information.txt" _ For Append As #i Print #i, "Sensor:", sensors_vble(i - 1).iden Print #i, "CAN ID:", sensors_vble(i - 1).IDcan, sensors_vble(i - 1).IDcan + 1, Tab(14) Print #i, "Text files associated: XYZ_" & CStr(i) & ".txt and PTV_" & CStr(i) & _ ".txt", Tab(14) Print #i, "Messages", Tab(14) Print #i, "XYZ:", sensors_vble(i - 1).MsgCounter_V Print #i, "PTV:", sensors_vble(i - 1).MsgCounter_T, Tab(14) Print #i, " ", Tab(14) Print #i, " ", Tab(14) Close #i 'If there is some no stored information, it is stored before finishing. Open _ "C:\Documents and Settings\uos\Desktop\programs\Visual Basic\last one\XYZ_" & CStr(i) & ".txt" _ For Append As #i If sensors_vble(i - 1).MsgCounter_V_aux <> 0 Then For j = 1 To sensors_vble(i - 1).MsgCounter_V_aux - 1 Print #i, sensors_vble(i - 1).MatrixV(3, j - 1), sensors_vble(i - 1).MatrixV(0, _ j - 1), sensors_vble(i - 1).MatrixV(1, j - 1), sensors_vble(i - 1).MatrixV(2, j - 1) Next j Print #i, sensors_vble(i - 1).MatrixV(3, sensors_vble(i - 1).MsgCounter_V_aux _ - 1), sensors_vble(i - 1).MatrixV(0, sensors_vble(i - 1).MsgCounter_V_aux - 1), _ sensors_vble(i - 1).MatrixV(1, sensors_vble(i - 1).MsgCounter_V_aux - 1), _ sensors_vble(i - 1).MatrixV(2, sensors_vble(i - 1).MsgCounter_V_aux - 1) End If Close #i 'If there is some no stored information, it is stored before finishing. Open _ "C:\Documents and Settings\uos\Desktop\programs\Visual Basic\last one\PTV_" & CStr(i) & ".txt" _ For Append As #i + 1 If sensors_vble(i - 1).MsgCounter_T_aux <> 0 Then For j = 1 To sensors_vble(i - 1).MsgCounter_T_aux - 1 Print #i + 1, sensors_vble(i - 1).MatrixT(3, j - 1), _ sensors_vble(i - 1).MatrixT(0, j - 1), sensors_vble(i - 1).MatrixT(1, j - 1), _ sensors_vble(i - 1).MatrixT(2, j - 1) Next j Print #i + 1, sensors_vble(i - 1).MatrixT(3, sensors_vble(i - 1).MsgCounter_T_aux _ - 1), sensors_vble(i - 1).MatrixT(0, sensors_vble(i - 1).MsgCounter_T_aux - 1), _ sensors_vble(i - 1).MatrixT(1, sensors_vble(i - 1).MsgCounter_T_aux - 1), _ sensors_vble(i - 1).MatrixT(2, sensors_vble(i - 1).MsgCounter_T_aux - 1) End If Close #i + 1 Next i 'To finish the program. End End Sub Private Sub Form_Load() 'The application starts asking the number of sensors. n_sensors = InputBox("How many sensors?", "Welcome", "1") 'At the beginning the variables for the graph scales, the scales and the labels have the 'default value. graph_variable(0) = 0 graph_variable(1) = 1 graph_variable(2) = 2 graph_variable(3) = 3 graph_variable(4) = 4 graph_variable(5) = 5 min(0) = scale_minx lblMin(0).Caption = min(0) max(0) = scale_maxx lblMax(0).Caption = max(0) min(1) = scale_miny lblMin(1).Caption = min(1) max(1) = scale_maxy lblMax(1).Caption = max(1) min(2) = scale_minz lblMin(2).Caption = min(2) max(2) = scale_maxz lblMax(2).Caption = max(2) min(3) = scale_minp lblMin(3).Caption = min(3) max(3) = scale_maxp lblMax(3).Caption = max(3) min(4) = scale_mint lblMin(4).Caption = min(4) max(4) = scale_maxt lblMax(4).Caption = max(4) min(5) = scale_minv lblMin(5).Caption = min(5) max(5) = scale_maxv lblMax(5).Caption = max(5) 'Graphs scale, first the top left corner and then the bottom right one. For i = 0 To 2 pctGraph(i).Scale (-1, max(i))-(scalet_XYZ, min(i)) Next i For i = 3 To 5 pctGraph(i).Scale (-1, max(i))-(scalet_PTV, min(i)) Next i End Sub Private Sub sldZoom_Change(Index As Integer) 'The graph scales are changed depending on the zoom. The change is different according to 'the variable. Select Case graph_variable(Index) Case 0 min(Index) = scale_minx / sldZoom(Index).value max(Index) = scale_maxx / sldZoom(Index).value Case 1 min(Index) = scale_miny / sldZoom(Index).value max(Index) = scale_maxy / sldZoom(Index).value Case 2 max(Index) = scale_maxz / sldZoom(Index).value Case 3 max(Index) = scale_maxp / sldZoom(Index).value Case 4 max(Index) = scale_maxt / sldZoom(Index).value Case 5 max(Index) = scale_maxv / sldZoom(Index).value End Select 'The labels and the scale have to change as well. lblMin(Index).Caption = min(Index) lblMax(Index).Caption = max(Index) pctGraph(Index).Cls Select Case graph_variable(Index) Case 0, 1, 2 pctGraph(Index).Scale (-1, max(Index))-(scalet_XYZ, min(Index)) pctGraph(Index).Line (-1, 0)-(scalet_XYZ, 0), vbRed 'x axis Case 3, 4, 5 pctGraph(Index).Scale (-1, max(Index))-(scalet_PTV, min(Index)) pctGraph(Index).Line (-1, 0)-(scalet_PTV, 0), vbRed 'x axis End Select pctGraph(Index).Line (0, min(j))-(0, max(j)), vbRed 'y axis pctGraph(Index).PSet (0, 0), vbRed 'origin End Sub Private Sub tmrTime_Timer() 'This variable is increased each 10 ms and then it is displayed. tenmsec_aux = tenmsec_aux + 1 txtTime.Text = tenmsec_aux 'This variable is increased each 10 ms. tenmsec = tenmsec + 1 'When tenmsec=100, one second has passed. If tenmsec = 100 Then tenmsec = 0 sec = sec + 1 'When sec=10, ten seconds have passed. If sec = 10 Then sec = 0 tensec = tensec + 1 'Auxiliary variable to relate the time with the beginning of PTV graphs. tensec_aux = tensec_aux + 1 'When tensec=6, one minute has passed. If tensec = 6 Then tensec = 0 minute = minute + 1 'When min=10, ten minutes have passed. If minute = 10 Then minute = 0 tenmin = tenmin + 1 'When tenmin=6, one hour has passed and the clock begins again. If tenmin = 6 Then tenmin = 0 End If End If End If 'When tensec_aux=10, it is indicated by flag_aux=1 to delete the information 'plotted in the PTV graphs and rebegin ploting from the origin. If tensec_aux = 10 Then tensec_aux = 0 flag_aux = 1 End If End If End If 'The time variables are displayed. lblTenmsec.Caption = tenmsec lblSec.Caption = sec lblTensec.Caption = tensec lblMinute.Caption = minute lblTenmin.Caption = tenmin 'Auxiliary variable to plot the data. aux_XYZ = aux_XYZ + 1 aux_PTV = aux_PTV + 1 'The graphs have a limit so the information is deleted and ploting rebegins. If tenmsec = 0 Then aux_XYZ = 0 For j = 0 To 5 If graph_variable(j) = 0 Or graph_variable(j) = 1 Or graph_variable(j) = 2 Then pctGraph(j).Cls pctGraph(j).Line (-1, 0)-(scalet_XYZ, 0), vbRed 'x axis pctGraph(j).Line (0, min(j))-(0, max(j)), vbRed 'y axis pctGraph(j).PSet (0, 0), vbRed 'origin End If Next j End If If flag_aux = 1 Then aux_PTV = 0 For j = 0 To 5 If graph_variable(j) = 3 Or graph_variable(j) = 4 Or graph_variable(j) = 5 Then pctGraph(j).Cls pctGraph(j).Line (-1, 0)-(scalet_PTV, 0), vbRed 'x axis pctGraph(j).Line (0, min(j))-(0, max(j)), vbRed 'y axis pctGraph(j).PSet (0, 0), vbRed 'origin End If Next j flag_aux = 0 End If End Sub Private Sub tmrRead_Timer() 'Struct to store the received information. Dim myMsg As TPCANMsg 'General counters: Static Counter As Double 'It counts received messages. Static MsgCounter_V As Double 'It counts received messages of vibration(XYZ). Static MsgCounter_T As Integer 'It counts received messages of pressure, temperature 'and voltage(PTV). 'Variables to count the missed messages: Static MsgCounter_7 As Integer 'with LEN=7. Static MsgCounter_5 As Integer 'with LEN=5. Static MsgCounter_strange As Integer 'with another LEN. 'When the application starts a registering process is necessary: 'This variable indicates if all the sensors have been registered. Static registered As Integer 'This variable counts how many sensors have been registered. Static count_registered As Integer 'This variable indicates if the sensor which is treated at the moment has already 'been registered. Static sensors_registered As Integer 'Array of structs: to store all the information about a sensor in each struct. If beginning = 0 Then ReDim Preserve sensors_vble(n_sensors - 1) beginning = 1 End If 'Get the next message or error out of the receive queue of the device driver. ret = CAN_Read(myMsg) 'The return value from CAN_Read() is CAN_ERR_OK when the message contents a 'normal message. While (ret = CAN_ERR_OK) 'It is known which sensor is sending the data with the CAN ID. which_sensor = myMsg.ID 'Registering process: If registered = 0 And myMsg.LEN = 7 Then For i = 1 To n_sensors If sensors_vble(i - 1).IDcan = which_sensor Then sensors_registered = 1 'This sensor has already been registered. End If Next i For i = 1 To n_sensors 'If the sensor has not been registered yet, an empty place is looked for. If sensors_registered = 0 Then If sensors_vble(i - 1).firstMsg = 0 Then 'In the empty place, CAN ID and sensor identifier are stored, and it is 'indicated that the place is occupied by firstMsg=1. sensors_vble(i - 1).IDcan = which_sensor sensors_vble(i - 1).iden = myMsg.DATA(4) 'The number of the sensor is added to the list of the sensors at each graph. d = Format(myMsg.DATA(4)) For m = 0 To 5 cboSensor(m).AddItem (d), i - 1 Next m sensors_vble(i - 1).firstMsg = 1 result = MsgBox("Sensor registered", 64, "Registering Process") sensors_registered = 1 count_registered = count_registered + 1 'At the beginning all the variables of the first sensor registered are 'plotted. If count_registered = 1 Then For k = 0 To 5 graph_sensor(k) = sensors_vble(i - 1).iden cboSensor(k).Text = d Next k End If 'The registering process will have been finished when all the sensors will 'have been registered. If count_registered = n_sensors Then registered = 1 result = MsgBox("Registering process finished", 0 + 64, "Registering Process") End If End If End If Next i sensors_registered = 0 End If For k = 1 To n_sensors 'It is known which sensor is sending the data with the CAN ID. If which_sensor = sensors_vble(k - 1).IDcan Or which_sensor = _ sensors_vble(k - 1).IDcan + 1 Then 'The sensors send a message with LEN=7 and then another one with LEN=5. 'If the message with LEN=7 is received, it is indicated by flag1=1 and the 'information is stored. If myMsg.LEN = 7 Then sensors_vble(k - 1).flag1 = 1 sensors_vble(k - 1).vector(0) = myMsg.DATA(5) sensors_vble(k - 1).vector(1) = myMsg.DATA(6) 'buffer1 is used to write the message with LEN=7 in a list. sensors_vble(k - 1).buffer1 = "ID: " + Format(myMsg.ID, "###000 ") + "LEN: " _ + Format(myMsg.LEN, "#0 ") For i = 0 To myMsg.LEN - 1 sensors_vble(k - 1).buffer1 = sensors_vble(k - 1).buffer1 + " " + _ Format(myMsg.DATA(i), "###000") Next i Else 'The message after a message with LEN=7 should have LEN=5. If it does not happen 'the message with LEN=7 is missed so the missed counter of message with LEN=7 is 'increased and displayed, and it is indicated that there isn't any message with LEN=7 'stored by flag1=0. If myMsg.LEN <> 5 And sensors_vble(k - 1).flag1 = 1 Then sensors_vble(k - 1).MsgCounter_7 = sensors_vble(k - 1).MsgCounter_7 + 1 MsgCounter_7 = MsgCounter_7 + 1 lblCounterMsg_7.Caption = MsgCounter_7 sensors_vble(k - 1).flag1 = 0 End If End If 'If the message LEN is not 7 and neither 5 the strange message counter is increased 'and displayed. If myMsg.LEN <> 7 And myMsg.LEN <> 5 Then sensors_vble(k - 1).MsgCounter_strange = sensors_vble(k - 1).MsgCounter_strange + 1 MsgCounter_strange = MsgCounter_strange + 1 lblCounterMsg_Strange.Caption = MsgCounter_strange End If 'It is checked if the message with LEN=5 is received and if a message with LEN=7 'has already been received. If myMsg.LEN = 5 Then If sensors_vble(k - 1).flag1 = 1 Then 'The last byte of the message with LEN=5 is checked to find out the type of 'the complete message. sensors_vble(k - 1).n = myMsg.DATA(myMsg.LEN - 1) sensors_vble(k - 1).n = sensors_vble(k - 1).n And 128 If sensors_vble(k - 1).n = 128 Then sensors_vble(k - 1).n = 1 End If 'Counter is increased and displayed. sensors_vble(k - 1).Counter = sensors_vble(k - 1).Counter + 1 Counter = Counter + 1 lblCounterMsg.Caption = Counter 'To know if a point or a line has to be plotted, the type of the last message has 'to be known. N_anterior is used with this objective, storing this information. 'The problem is with the first message, because no previous message exists. If sensors_vble(k - 1).Counter = 1 Then sensors_vble(k - 1).n_anterior = sensors_vble(k - 1).n End If 'The data is stored. sensors_vble(k - 1).vector(2) = myMsg.DATA(0) sensors_vble(k - 1).vector(3) = myMsg.DATA(1) sensors_vble(k - 1).vector(4) = myMsg.DATA(2) sensors_vble(k - 1).vector(5) = myMsg.DATA(3) 'buffer2 is used to write the message with LEN=5 in a list. sensors_vble(k - 1).buffer2 = "ID: " + Format(myMsg.ID, "###000 ") + "LEN: " _ + Format(myMsg.LEN, "#0 ") For i = 0 To myMsg.LEN - 1 sensors_vble(k - 1).buffer2 = sensors_vble(k - 1).buffer2 + " " + _ Format(myMsg.DATA(i), "###000") Next 'The message type is checked to store and plot the data in a different place. 'The transformation of the data will be also different. 'If n=0 it is XYZ data. If sensors_vble(k - 1).n = 0 Then 'XYZ data arrive stored in 2 bytes sensors_vble(k - 1).value(0) = sensors_vble(k - 1).vector(0) * 256 + _ sensors_vble(k - 1).vector(1) sensors_vble(k - 1).value(1) = sensors_vble(k - 1).vector(2) * 256 + _ sensors_vble(k - 1).vector(3) sensors_vble(k - 1).value(2) = sensors_vble(k - 1).vector(4) * 256 + _ sensors_vble(k - 1).vector(5) 'X data transformation sensors_vble(k - 1).value(0) = (350 / 1024) * _ (sensors_vble(k - 1).value(0) - 1024) 'Y data transformation sensors_vble(k - 1).value(1) = (350 / 1024) * _ (sensors_vble(k - 1).value(1) - 1024) 'Z data transformation sensors_vble(k - 1).value(2) = 10 * sensors_vble(k - 1).value(2) 'The received messages XYZ counter is increased and displayed. sensors_vble(k - 1).MsgCounter_V = sensors_vble(k - 1).MsgCounter_V + 1 sensors_vble(k - 1).MsgCounter_V_aux = sensors_vble(k - 1).MsgCounter_V_aux + 1 MsgCounter_V = MsgCounter_V + 1 lblCounterMsg_V.Caption = MsgCounter_V 'The complete information is written on the XYZ list. lstMsg_V.AddItem (sensors_vble(k - 1).buffer1) lstMsg_V.AddItem (sensors_vble(k - 1).buffer2) 'The information is stored in the XYZ array, redimensioning it each time. 'The array has a fixed number of rows: x,y,z,time. 'Each time a column is added by using the XYZ received messages 'counter (taking into account that VS begins to count from 0). ReDim Preserve sensors_vble(k - 1).MatrixV(3, _ sensors_vble(k - 1).MsgCounter_V_aux - 1) For i = 0 To 2 sensors_vble(k - 1).MatrixV(i, sensors_vble(k - 1).MsgCounter_V_aux - 1) = _ sensors_vble(k - 1).value(i) Next sensors_vble(k - 1).MatrixV(3, sensors_vble(k - 1).MsgCounter_V_aux - 1) = _ tenmsec_aux 'To plot the data: 'Look at each graph to know if the data have to be plotted. For h = 1 To 6 'First look at the sensor identifier. If graph_sensor(h - 1) = sensors_vble(k - 1).iden Then 'Second look at the variable type. Select Case graph_variable(h - 1) Case 0 If sensors_vble(k - 1).n_anterior = sensors_vble(k - 1).n Then 'If the last message was a XYZ message a line is plotted. pctGraph(h - 1).Line -(aux_XYZ, sensors_vble(k - 1).value(0)) Else 'If the last message was a XYZ message a point is plotted. pctGraph(h - 1).PSet (aux_XYZ, sensors_vble(k - 1).value(0)) End If 'Plots a vertical line to know the exact received data. pctGraph(h - 1).Line (aux_XYZ, 0)-(aux_XYZ, sensors_vble(k - 1).value(0)), vbRed Case 1 If sensors_vble(k - 1).n_anterior = sensors_vble(k - 1).n Then 'If the last message was a XYZ message a line is plotted. pctGraph(h - 1).Line -(aux_XYZ, sensors_vble(k - 1).value(1)) Else 'If the last message was a XYZ message a point is plotted. pctGraph(h - 1).PSet (aux_XYZ, sensors_vble(k - 1).value(1)) End If 'Plots a vertical line to know the exact received data. pctGraph(h - 1).Line (aux_XYZ, 0)-(aux_XYZ, sensors_vble(k - 1).value(1)), vbRed Case 2 If sensors_vble(k - 1).n_anterior = sensors_vble(k - 1).n Then 'If the last message was a XYZ message a line is plotted. pctGraph(h - 1).Line -(aux_XYZ, sensors_vble(k - 1).value(2)) Else 'If the last message was a XYZ message a point is plotted. pctGraph(h - 1).PSet (aux_XYZ, sensors_vble(k - 1).value(2)) End If 'Plots a vertical line to know the exact received data. pctGraph(h - 1).Line (aux_XYZ, 0)-(aux_XYZ, sensors_vble(k - 1).value(2)), vbRed End Select End If Next h Else 'If n=1 it is PTV data. If sensors_vble(k - 1).n = 1 Then 'PTV data arrive stored in 1 byte sensors_vble(k - 1).value(0) = sensors_vble(k - 1).vector(1) sensors_vble(k - 1).value(1) = sensors_vble(k - 1).vector(3) sensors_vble(k - 1).value(2) = sensors_vble(k - 1).vector(5) 'P data transformation sensors_vble(k - 1).value(0) = (500 / 255) * sensors_vble(k - 1).value(0) 'T data transformation sensors_vble(k - 1).value(1) = (80 / 255) * sensors_vble(k - 1).value(1) 'V data transformation sensors_vble(k - 1).value(2) = (3 / 255) * sensors_vble(k - 1).value(2) 'The PTV received messages counter is increased and displayed. sensors_vble(k - 1).MsgCounter_T = sensors_vble(k - 1).MsgCounter_T + 1 sensors_vble(k - 1).MsgCounter_T_aux = sensors_vble(k - 1).MsgCounter_T_aux + 1 MsgCounter_T = MsgCounter_T + 1 lblCounterMsg_T.Caption = MsgCounter_T 'The complete information is written on the PTV list. lstMsg_T.AddItem (sensors_vble(k - 1).buffer1) lstMsg_T.AddItem (sensors_vble(k - 1).buffer2) 'The information is stored in the PTV array, redimensioning it each time. 'The array has a fixed number of rows: p,t,v,time. 'Each time a column is added by using the PTV received messages 'counter (taking into account that VS begins to count from 0). ReDim Preserve sensors_vble(k - 1).MatrixT(3, _ sensors_vble(k - 1).MsgCounter_T_aux - 1) For i = 0 To 2 sensors_vble(k - 1).MatrixT(i, sensors_vble(k - 1).MsgCounter_T_aux - 1) = _ sensors_vble(k - 1).value(i) Next sensors_vble(k - 1).MatrixT(3, sensors_vble(k - 1).MsgCounter_T_aux - 1) = _ tenmsec_aux 'To plot the data: 'Look at each graph to know if the data have to be plotted. For h = 1 To 6 'First look at the sensor identifier. If graph_sensor(h - 1) = sensors_vble(k - 1).iden Then 'Second look at the variable type. Select Case graph_variable(h - 1) Case 3 If sensors_vble(k - 1).n_anterior = sensors_vble(k - 1).n Then 'If the last message was a PTV message a line is plotted. pctGraph(h - 1).Line -(aux_PTV, sensors_vble(k - 1).value(0)) Else 'If the last message was a PTV message a point is plotted. pctGraph(h - 1).PSet (aux_PTV, sensors_vble(k - 1).value(0)) End If 'Plots a vertical line to know the exact received data. pctGraph(h - 1).Line (aux_PTV, 0)-(aux_PTV, sensors_vble(k - 1).value(0)), vbRed Case 4 If sensors_vble(k - 1).n_anterior = sensors_vble(k - 1).n Then 'If the last message was a PTV message a line is plotted. pctGraph(h - 1).Line -(aux_PTV, sensors_vble(k - 1).value(1)) Else 'If the last message was a PTV message a point is plotted. pctGraph(h - 1).PSet (aux_PTV, sensors_vble(k - 1).value(1)) End If 'Plots a vertical line to know the exact received data. pctGraph(h - 1).Line (aux_PTV, 0)-(aux_PTV, sensors_vble(k - 1).value(1)), vbRed Case 5 If sensors_vble(k - 1).n_anterior = sensors_vble(k - 1).n Then 'If the last message was a PTV message a line is plotted. pctGraph(h - 1).Line -(aux_PTV, sensors_vble(k - 1).value(2)) Else 'If the last message was a PTV message a point is plotted. pctGraph(h - 1).PSet (aux_PTV, sensors_vble(k - 1).value(2)) End If 'Plots a vertical line to know the exact received data. pctGraph(h - 1).Line (aux_PTV, 0)-(aux_PTV, sensors_vble(k - 1).value(2)), vbRed End Select End If Next h End If End If 'Before finishing, the current message type is stored to use it in the next message. sensors_vble(k - 1).n_anterior = sensors_vble(k - 1).n 'In addition, it is indicated that a message with LEN=7 is not stored. sensors_vble(k - 1).flag1 = 0 Else 'If flag1=0 when the message with LEN=5 is received, it is missed so the missed 'counter of message with LEN=5 is increased and displayed. sensors_vble(k - 1).MsgCounter_5 = sensors_vble(k - 1).MsgCounter_5 + 1 MsgCounter_5 = MsgCounter_5 + 1 lblCounterMsg_5.Caption = MsgCounter_5 End If End If End If Next k ret = CAN_Read(myMsg) Wend 'If the program arrives to this line a failure in CAN_Read has been made so the 'return code is displayed. lblCAN_Read.Caption = ret End Sub Private Sub tmrStore_Timer() 'The information is stored each 30 seconds in a text file, afterwards the arrays which 'stored this information can be reused. In this way the memory is saved and the speed is 'increased. For i = 1 To n_sensors Open _ "C:\Documents and Settings\uos\Desktop\programs\Visual Basic\last one\XYZ_" & CStr(i) & ".txt" _ For Append As #i For j = 1 To sensors_vble(i - 1).MsgCounter_V_aux Print #i, sensors_vble(i - 1).MatrixV(3, j - 1), sensors_vble(i - 1).MatrixV(0, j _ - 1), sensors_vble(i - 1).MatrixV(1, j - 1), sensors_vble(i - 1).MatrixV(2, j - 1) Next j sensors_vble(i - 1).MsgCounter_V_aux = 0 lstMsg_V.Clear Close #i Open _ "C:\Documents and Settings\uos\Desktop\programs\Visual Basic\last one\PTV_" & CStr(i) & ".txt" _ For Append As #i + 1 For j = 1 To sensors_vble(i - 1).MsgCounter_T_aux Print #i + 1, sensors_vble(i - 1).MatrixT(3, j - 1), sensors_vble(i - 1).MatrixT(0, j _ - 1), sensors_vble(i - 1).MatrixT(1, j - 1), sensors_vble(i - 1).MatrixT(2, j - 1) Next j sensors_vble(i - 1).MsgCounter_T_aux = 0 lstMsg_T.Clear Close #i + 1 Next i End Sub e-REdING. Biblioteca de la Escuela Superior de Ingenieros de Sevilla.


SISTEMA DE MONITORIZACIÓN DE TURBINAS DE GAS AERONÁUTICAS

: Rodríguez Barquero, María
: Ingeniería Industrial
Contenido del proyecto: