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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 | ' - InterfaceKit full - ' In this example we display the interface kit details including the number of inputs and outputs it allows, ' and displays the values of the inputs and outputs. ' Note: This example was developed and run with an LED in digital output 0 and an LED in digital output 7 to test ' the simulated digital output. ' ' Please note that this example was designed to work with only one Phidget InterfaceKit connected. ' For an example using multiple Phidget InterfaceKits, please see a "multiple" example in the InterfaceKit Examples folder. ' ' Copyright 2007 Phidgets Inc. ' This work is licensed under the Creative Commons Attribution 2.5 Canada License. ' To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/ca/
Public Class Form1 Dim WithEvents phidgetIFK As Phidgets.InterfaceKit 'Kit 8/8/8 Είσοδοι αναλογικοί και είσοδοι/έξοδοι ψηφιακοί
Dim WithEvents phidgetIFK2 As Phidgets.InterfaceKit 'Τα τέσσερα ρελε
Dim WithEvents phidgetLCD As Phidgets.TextLCD 'Η οθόνη
Dim WithEvents phidgetRFID As Phidgets.RFID 'Το RFID Reader
Private digiInArray As CheckBox() Private digiOutArray As CheckBox() Private sensorInArray As TextBox()
Private digiInArray2 As CheckBox() Private digiOutArray2 As CheckBox() Private sensorInArray2 As TextBox()
Public Sub New() ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. End Sub
'initialize the device Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
makeDigiInArray() makeDigiOutArray() makeSensorInArray()
'1 8/8/8
inputTrk.Value = 0 inputTrk.Enabled = False sensitivityTxt.Text = ""
ratioChk.Enabled = False ratioChk.Checked = False
'2 0/0/4 makeDigiInArray2() makeDigiOutArray2() makeSensorInArray2()
inputTrk2.Value = 0 inputTrk2.Enabled = False sensitivityTxt2.Text = ""
ratioChk2.Enabled = False ratioChk2.Checked = False
'3 TextLCD
dispText1.Enabled = False dispText2.Enabled = False clearBtn.Enabled = False backlightChk.Enabled = False cursorChk.Enabled = False contrastTrkBr.Enabled = False
'4 RFID
antennaChk.Enabled = False ledChk.Enabled = False output0Chk.Enabled = False output1chk.Enabled = False
Try 'Ανοίγω τα phidgets phidgetIFK = New Phidgets.InterfaceKit phidgetIFK2 = New Phidgets.InterfaceKit phidgetLCD = New Phidgets.TextLCD phidgetRFID = New Phidgets.RFID
phidgetIFK.open(67381) phidgetIFK2.open(109472) phidgetLCD.open(67381) phidgetRFID.open(92493)
Catch ex As Exception MessageBox.Show(ex.ToString()) End Try
End Sub
'attach event handler... here we'll display the interface kit details as well as determine how many output and input 8/8/8 'fields to display as well as determine the range of values for the output simulator slider Private Sub phidgetIFK_Attach(ByVal sender As Object, ByVal e As Phidgets.Events.AttachEventArgs) Handles phidgetIFK.Attach
attachedTxt.Text = phidgetIFK.Attached.ToString() 'Οι πληροφορίες για το καθέ kit nameTxt.Text = phidgetIFK.Name serialTxt.Text = sender.SerialNumber.ToString() versionTxt.Text = sender.Version.ToString() digiInNumTxt.Text = phidgetIFK.inputs.Count.ToString() digiOutNumTxt.Text = sender.outputs.Count.ToString() sensorInNumTxt.Text = sender.sensors.Count.ToString()
Dim i As Integer For i = 0 To phidgetIFK.inputs.Count - 1 digiInArray(i).Visible = True Next i
For i = 0 To phidgetIFK.outputs.Count - 1 digiOutArray(i).Visible = True digiOutArray(i).Enabled = True Next i
For i = 0 To phidgetIFK.sensors.Count - 1 sensorInArray(i).Visible = True Next i
If phidgetIFK.sensors.Count > 0 Then inputTrk.Enabled = True inputTrk.SetRange(0, 1000) inputTrk.Value = phidgetIFK.sensors(0).Sensitivity sensitivityTxt.Text = inputTrk.Value.ToString()
phidgetIFK.ratiometric = True
ratioChk.Enabled = True ratioChk.Checked = phidgetIFK.ratiometric End If End Sub
'attach event handler... here we'll display the interface kit details as well as determine how many output and input 'fields to display as well as determine the range of values for the output simulator slider Private Sub phidgetIFK2_Attach(ByVal sender As Object, ByVal e As Phidgets.Events.AttachEventArgs) Handles phidgetIFK2.Attach
attachedTxt2.Text = phidgetIFK2.Attached.ToString() 'Πληροφορίες για το δεύτερο κιτ (relay) nameTxt2.Text = phidgetIFK2.Name serialTxt2.Text = sender.SerialNumber.ToString() versionTxt2.Text = sender.Version.ToString() digiInNumTxt2.Text = phidgetIFK2.inputs.Count.ToString() digiOutNumTxt2.Text = sender.outputs.Count.ToString() sensorInNumTxt2.Text = sender.sensors.Count.ToString()
Dim g As Integer For g = 0 To phidgetIFK2.inputs.Count - 1 digiInArray2(g).Visible = True Next g
For g = 0 To phidgetIFK2.outputs.Count - 1 digiOutArray2(g).Visible = True digiOutArray2(g).Enabled = True Next g
For g = 0 To phidgetIFK2.sensors.Count - 1 sensorInArray2(g).Visible = True Next g
If phidgetIFK2.sensors.Count > 0 Then inputTrk2.Enabled = True inputTrk2.SetRange(0, 1000) inputTrk2.Value = phidgetIFK2.sensors(0).Sensitivity sensitivityTxt2.Text = inputTrk2.Value.ToString()
phidgetIFK2.ratiometric = True
ratioChk2.Enabled = True ratioChk2.Checked = phidgetIFK2.ratiometric End If End Sub
'attach event handler...we will display the attach status and the attached TextLCD device's details 'We will also enable the fields used to manipulate the TextLCD as well as do some initializing of 'ranges and maximum values for some of these fields
Private Sub lcd_Attach(ByVal sender As Object, ByVal e As Phidgets.Events.AttachEventArgs) Handles phidgetLCD.Attach
attachedTxt3.Text = sender.Attached.ToString() 'Πληροφορίες για την οθόνη nameTxt3.Text = sender.Name serialTxt3.Text = sender.SerialNumber.ToString() versionTxt3.Text = sender.Version.ToString() dispText1.Enabled = True dispText1.MaxLength = phidgetLCD.rows(0).MaximumLength dispText2.Enabled = True dispText2.MaxLength = phidgetLCD.rows(1).MaximumLength
clearBtn.Enabled = True backlightChk.Enabled = True cursorChk.Enabled = True contrastTrkBr.Enabled = True contrastTrkBr.SetRange(0, 255) contrastTrkBr.Value = 130
phidgetLCD.Backlight = True backlightChk.Checked = phidgetLCD.Backlight phidgetLCD.Cursor = False cursorChk.Checked = phidgetLCD.Cursor phidgetLCD.CursorBlink = False cursorBlinkChk.Checked = phidgetLCD.CursorBlink End Sub
'attach event handler..populate the details fields as well as display the attached status. enable the checkboxes to change 'the values of the attributes of the RFID reader such as enable or disable the antenna and onboard led. Private Sub phidgetRFID_Attach(ByVal sender As Object, ByVal e As Phidgets.Events.AttachEventArgs) Handles phidgetRFID.Attach
attachedTxt4.Text = sender.Attached.ToString() 'Πληροφορίες για το rfid nameTxt4.Text = sender.Name serialTxt4.Text = sender.SerialNumber.ToString() versionTxt4.Text = sender.Version.ToString() outputsTxt4.Text = sender.outputs.Count.ToString()
antennaChk.Checked = True phidgetRFID.Antenna = True antennaChk.Enabled = True ledChk.Enabled = True output0Chk.Enabled = True output1chk.Enabled = True End Sub
''ifkit detach event handler... here we display the statu, which will be false as the device is not attached. We ''will also clear the display fields and hide the inputs and outputs. Private Sub phidgetIFK_Detach(ByVal sender As Object, ByVal e As Phidgets.Events.DetachEventArgs) Handles phidgetIFK.Detach
attachedTxt.Text = phidgetIFK.Attached.ToString() nameTxt.Text = "" serialTxt.Text = "" versionTxt.Text = "" digiInNumTxt.Text = "" digiOutNumTxt.Text = "" sensorInNumTxt.Text = ""
Dim i As Integer
For i = 0 To 15 digiInArray(i).Visible = False digiInArray(i).Checked = False Next
For i = 0 To 15 digiOutArray(i).Visible = False digiOutArray(i).Checked = False digiOutArray(i).Enabled = False Next
For i = 0 To 7 sensorInArray(i).Visible = False sensorInArray(i).Text = "" Next
inputTrk.Value = 0 inputTrk.Enabled = False sensitivityTxt.Text = ""
ratioChk.Enabled = False ratioChk.Checked = False End Sub
''ifkit detach event handler... here we display the statu, which will be false as the device is not attached. We ''will also clear the display fields and hide the inputs and outputs. Private Sub phidgetIFK2_Detach(ByVal sender As Object, ByVal e As Phidgets.Events.DetachEventArgs) Handles phidgetIFK2.Detach
attachedTxt2.Text = phidgetIFK2.Attached.ToString() nameTxt2.Text = "" serialTxt2.Text = "" versionTxt2.Text = "" digiInNumTxt2.Text = "" digiOutNumTxt2.Text = "" sensorInNumTxt2.Text = ""
Dim g As Integer
For g = 0 To 15 digiInArray2(g).Visible = False digiInArray2(g).Checked = False Next
For g = 0 To 15 digiOutArray2(g).Visible = False digiOutArray2(g).Checked = False digiOutArray2(g).Enabled = False Next
For g = 0 To 7 sensorInArray2(g).Visible = False sensorInArray2(g).Text = "" Next
inputTrk2.Value = 0 inputTrk2.Enabled = False sensitivityTxt2.Text = ""
ratioChk2.Enabled = False ratioChk2.Checked = False End Sub
'detach event handler.... we will display the device attach status and clear all the other fields Private Sub lcd_Detach(ByVal sender As Object, ByVal e As Phidgets.Events.DetachEventArgs) Handles phidgetLCD.Detach attachedTxt3.Text = sender.Attached.ToString() nameTxt3.Text = "" serialTxt3.Text = "" versionTxt3.Text = "" dispText1.Enabled = False dispText2.Enabled = False
clearBtn.Enabled = False backlightChk.Enabled = False cursorChk.Enabled = False contrastTrkBr.Enabled = False End Sub
'detach event handler...clear all the fields, display the attached status, and disable the checkboxes. Private Sub phidgetRFID_Detach(ByVal sender As Object, ByVal e As Phidgets.Events.DetachEventArgs) Handles phidgetRFID.Detach
attachedTxt4.Text = sender.Attached.ToString() nameTxt4.Text = "" serialTxt4.Text = "" versionTxt4.Text = "" outputsTxt4.Text = ""
antennaChk.Enabled = False ledChk.Enabled = False output0Chk.Enabled = False output1chk.Enabled = False End Sub
Private Sub phidgetIFK_Error(ByVal sender As Object, ByVal e As Phidgets.Events.ErrorEventArgs) Handles phidgetIFK.Error MessageBox.Show(e.Description) End Sub
Private Sub phidgetIFK2_Error(ByVal sender As Object, ByVal e As Phidgets.Events.ErrorEventArgs) Handles phidgetIFK2.Error MessageBox.Show(e.Description) End Sub
'Error event handler..we will simply display the error details text in a popup message box Private Sub lcd_Error(ByVal sender As Object, ByVal e As Phidgets.Events.ErrorEventArgs) Handles phidgetLCD.Error MessageBox.Show(e.Description) End Sub
Private Sub phidgetRFID_Error(ByVal sender As Object, ByVal e As Phidgets.Events.ErrorEventArgs) Handles phidgetRFID.Error MessageBox.Show(e.Description) End Sub
'digital input change event handler... here we check or uncheck the corresponding input checkbox based on the index of 'the digital input that generated the event Private Sub phidgetIFK_InputChange(ByVal sender As Object, ByVal e As Phidgets.Events.InputChangeEventArgs) Handles phidgetIFK.InputChange digiInArray(e.Index).Checked = e.Value End Sub
'digital input change event handler... here we check or uncheck the corresponding input checkbox based on the index of 'the digital input that generated the event Private Sub phidgetIFK2_InputChange(ByVal sender As Object, ByVal e As Phidgets.Events.InputChangeEventArgs) Handles phidgetIFK2.InputChange digiInArray2(e.Index).Checked = e.Value End Sub
''digital output change event handler... here we check or uncheck the corresponding output checkbox based on the index of ''the output that generated the event Private Sub phidgetIFK_OutputChange(ByVal sender As Object, ByVal e As Phidgets.Events.OutputChangeEventArgs) Handles phidgetIFK.OutputChange digiOutArray(e.Index).Checked = e.Value End Sub
''digital output change event handler... here we check or uncheck the corresponding output checkbox based on the index of ''the output that generated the event Private Sub phidgetIFK2_OutputChange(ByVal sender As Object, ByVal e As Phidgets.Events.OutputChangeEventArgs) Handles phidgetIFK2.OutputChange digiOutArray2(e.Index).Checked = e.Value End Sub
''sensor input change event handler...Set the textbox content based on the input index that is communicating with the ''interface kit Private Sub phidgetIFK_SensorChange(ByVal sender As Object, ByVal e As Phidgets.Events.SensorChangeEventArgs) Handles phidgetIFK.SensorChange sensorInArray(e.Index).Text = e.Value.ToString() End Sub
''sensor input change event handler...Set the textbox content based on the input index that is communicating with the ''interface kit Private Sub phidgetIFK2_SensorChange(ByVal sender As Object, ByVal e As Phidgets.Events.SensorChangeEventArgs) Handles phidgetIFK2.SensorChange sensorInArray2(e.Index).Text = e.Value.ToString() End Sub
'Modify the digital ouputs...Please observe the properties window in the ofrm designer for the digital output checkboxes. 'Each of the output checkboxes CheckedChanged events point to this one event handler, I use the sender object (the checkbox 'triggering the event) to get the checkbox that is changing. Also note that there is a "tag" property that is basically 'user defined data associated with the control. I used this to store the output index that the checkbox is supposed to 'represent for use in the following code to easily index the output we wanted to change. Hopefully this clarifies what 'was done in this method. Private Sub ClickOutputs(ByVal sender As Object, ByVal e As System.EventArgs)
Dim outputIndex As Integer Dim outputState As Boolean outputIndex = DirectCast(sender, CheckBox).Tag outputState = DirectCast(sender, CheckBox).CheckState 'MessageBox.Show(outputIndex.ToString() + " and " + outputState.ToString())
phidgetIFK.outputs(outputIndex) = outputState
End Sub
'Modify the digital ouputs...Please observe the properties window in the ofrm designer for the digital output checkboxes. 'Each of the output checkboxes CheckedChanged events point to this one event handler, I use the sender object (the checkbox 'triggering the event) to get the checkbox that is changing. Also note that there is a "tag" property that is basically 'user defined data associated with the control. I used this to store the output index that the checkbox is supposed to 'represent for use in the following code to easily index the output we wanted to change. Hopefully this clarifies what 'was done in this method. Private Sub ClickOutputs2(ByVal sender As Object, ByVal e As System.EventArgs)
Dim outputIndex2 As Integer Dim outputState2 As Boolean outputIndex2 = DirectCast(sender, CheckBox).Tag outputState2 = DirectCast(sender, CheckBox).CheckState 'MessageBox.Show(outputIndex2.ToString() + " and " + outputState2.ToString())
phidgetIFK2.outputs(outputIndex2) = outputState2
End Sub
'Modify the sensitivity of the analog inputs. In other words, the amount that the inputs must change between 'sensorchange events.
Private Sub inputTrk_Scroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles inputTrk.Scroll Try Dim i As Integer For i = 0 To phidgetIFK.sensors.Count - 1 phidgetIFK.sensors(i).Sensitivity = inputTrk.Value Next sensitivityTxt.Text = inputTrk.Value.ToString() Catch ex As Exception MessageBox.Show(ex.Message.ToString()) End Try End Sub
Private Sub ratioChk_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ratioChk.CheckedChanged If phidgetIFK.Attached Then phidgetIFK.ratiometric = ratioChk.Checked End If End Sub
'Modify the sensitivity of the analog inputs. In other words, the amount that the inputs must change between 'sensorchange events.
Private Sub inputTrk2_Scroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles inputTrk2.Scroll Try Dim g As Integer For g = 0 To phidgetIFK2.sensors.Count - 1 phidgetIFK2.sensors(g).Sensitivity = inputTrk2.Value Next sensitivityTxt2.Text = inputTrk2.Value.ToString() Catch ex As Exception MessageBox.Show(ex.Message.ToString()) End Try End Sub
Private Sub ratioChk2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ratioChk2.CheckedChanged If phidgetIFK2.Attached Then phidgetIFK2.ratiometric = ratioChk2.Checked End If End Sub
'line 1 textChanged event handler...when the user is entering text, pass it on to the textLCD to be displayed Private Sub dispText1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dispText1.TextChanged phidgetLCD.rows(0).DisplayString = sender.Text End Sub
'line 2 textChanged event handler...when the user is entering text, pass it on to the textLCD to be displayed Private Sub dispText2_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dispText2.TextChanged phidgetLCD.rows(1).DisplayString = sender.Text End Sub
'If the clear button is clicked, we want to clear the fields as well as clear the TextLCD screen Private Sub clearBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles clearBtn.Click dispText1.Clear() dispText2.Clear() phidgetLCD.rows(0).DisplayString = "" phidgetLCD.rows(1).DisplayString = "" End Sub
'Enable or disable the backlight by clicking on the checkbox Private Sub backlightChk_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles backlightChk.CheckedChanged phidgetLCD.Backlight = backlightChk.Checked End Sub
'enable or disable the cursor by clicking on the checkbox Private Sub cursorChk_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cursorChk.CheckedChanged phidgetLCD.Cursor = cursorChk.Checked End Sub
'enable or disable a blinking cursor by clicking on the checkbox Private Sub cursorBlinkChk_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cursorBlinkChk.CheckedChanged phidgetLCD.CursorBlink = cursorBlinkChk.Checked End Sub
'display ou simulation of the custom characters when the checkbox is clicked Private Sub customChrChk_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles customChrChk.CheckedChanged If (sender.Checked) Then
phidgetLCD.rows(0).DisplayString = "Testing Custom Chars" phidgetLCD.customCharacters(0).setCustomCharacter(949247, 536) phidgetLCD.customCharacters(1).setCustomCharacter(1015791, 17180) phidgetLCD.customCharacters(2).setCustomCharacter(1048039, 549790) phidgetLCD.customCharacters(3).setCustomCharacter(1031395, 816095) phidgetLCD.customCharacters(4).setCustomCharacter(498785, 949247) phidgetLCD.customCharacters(5).setCustomCharacter(232480, 1015791) phidgetLCD.customCharacters(6).setCustomCharacter(99328, 1048039) phidgetLCD.rows(1).DisplayString = phidgetLCD.customCharacters(0).StringCode & _ phidgetLCD.customCharacters(1).StringCode & _ phidgetLCD.customCharacters(2).StringCode & _ phidgetLCD.customCharacters(3).StringCode & _ phidgetLCD.customCharacters(4).StringCode & _ phidgetLCD.customCharacters(5).StringCode & _ phidgetLCD.customCharacters(6).StringCode()
Else
phidgetLCD.rows(0).DisplayString = "" phidgetLCD.rows(1).DisplayString = "" End If End Sub
'adjust the contast of the screen on the textLCD based on the value selected on the slider (100 to 0) Private Sub contrastTrkBr_Scroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles contrastTrkBr.Scroll phidgetLCD.Contrast = contrastTrkBr.Value End Sub
'Tag event handler...we'll display the tag code in the field on the GUI Private Sub phidgetRFID_Tag(ByVal sender As Object, ByVal e As Phidgets.Events.TagEventArgs) Handles phidgetRFID.Tag tagTxt4.Text = e.Tag
End Sub
'Tag lost event handler...here we simply want to clear our tag field in the GUI Private Sub phidgetRFID_TagLost(ByVal sender As Object, ByVal e As Phidgets.Events.TagEventArgs) Handles phidgetRFID.TagLost tagTxt4.Text = "" tagTxt401.Text = "" phidgetRFID.LED = False End Sub
'Enable or disable the RFID antenna by clicking the checkbox Private Sub antennaChk_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles antennaChk.CheckedChanged phidgetRFID.Antenna = antennaChk.Checked End Sub
'turn on and off the onboard LED by clicking the checkox Private Sub ledChk_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ledChk.CheckedChanged phidgetRFID.LED = ledChk.Checked End Sub
'turn on and off output 0, to light a LED for example Private Sub output0Chk_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles output0Chk.CheckedChanged phidgetRFID.outputs(0) = output0Chk.Checked End Sub
'turn on and off output 1, to light a LED for example Private Sub output1chk_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles output1chk.CheckedChanged phidgetRFID.outputs(1) = output1chk.Checked End Sub
'When the application is terminating, close the Phidget. Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
RemoveHandler phidgetIFK.Attach, AddressOf phidgetIFK_Attach RemoveHandler phidgetIFK.Detach, AddressOf phidgetIFK_Detach RemoveHandler phidgetIFK.Error, AddressOf phidgetIFK_Error RemoveHandler phidgetIFK.InputChange, AddressOf phidgetIFK_InputChange RemoveHandler phidgetIFK.OutputChange, AddressOf phidgetIFK_OutputChange RemoveHandler phidgetIFK.SensorChange, AddressOf phidgetIFK_SensorChange RemoveHandler phidgetIFK2.Attach, AddressOf phidgetIFK2_Attach RemoveHandler phidgetIFK2.Detach, AddressOf phidgetIFK2_Detach RemoveHandler phidgetIFK2.Error, AddressOf phidgetIFK2_Error RemoveHandler phidgetIFK2.InputChange, AddressOf phidgetIFK2_InputChange RemoveHandler phidgetIFK2.OutputChange, AddressOf phidgetIFK2_OutputChange RemoveHandler phidgetIFK2.SensorChange, AddressOf phidgetIFK2_SensorChange RemoveHandler phidgetLCD.Attach, AddressOf lcd_Attach RemoveHandler phidgetLCD.Detach, AddressOf lcd_Detach RemoveHandler phidgetLCD.Error, AddressOf lcd_Error RemoveHandler phidgetRFID.Attach, AddressOf phidgetRFID_Attach RemoveHandler phidgetRFID.Detach, AddressOf phidgetRFID_Detach RemoveHandler phidgetRFID.Error, AddressOf phidgetRFID_Error RemoveHandler phidgetRFID.Tag, AddressOf phidgetRFID_Tag RemoveHandler phidgetRFID.TagLost, AddressOf phidgetRFID_TagLost Application.DoEvents()
phidgetIFK.close() phidgetIFK2.close() phidgetLCD.close() phidgetRFID.close()
End Sub
'this method creates the digital input array that corresponds to the group of checkboxes 'we are suing to represent the state of the digital inputs on the interface kit Sub makeDigiInArray() ReDim digiInArray(15)
digiInArray(0) = checkBox0 digiInArray(1) = checkBox1 digiInArray(2) = checkBox2 digiInArray(3) = checkBox3 digiInArray(4) = checkBox4 digiInArray(5) = checkBox5 digiInArray(6) = checkBox6 digiInArray(7) = checkBox7 digiInArray(8) = checkBox8 digiInArray(9) = checkBox9 digiInArray(10) = checkBox10 digiInArray(11) = checkBox11 digiInArray(12) = checkBox12 digiInArray(13) = checkBox13 digiInArray(14) = checkBox14 digiInArray(15) = checkBox15
Dim i As Integer For i = 0 To 15 digiInArray(i).Visible = False Next i
End Sub
'this method creates the digital input array that corresponds to the group of checkboxes 'we are suing to represent the state of the digital inputs on the interface kit Sub makeDigiInArray2() ReDim digiInArray2(15)
digiInArray2(0) = CheckBox100 digiInArray2(1) = CheckBox101 digiInArray2(2) = CheckBox102 digiInArray2(3) = CheckBox103 digiInArray2(4) = CheckBox104 digiInArray2(5) = CheckBox105 digiInArray2(6) = CheckBox106 digiInArray2(7) = CheckBox107 digiInArray2(8) = CheckBox108 digiInArray2(9) = CheckBox109 digiInArray2(10) = CheckBox110 digiInArray2(11) = CheckBox111 digiInArray2(12) = CheckBox112 digiInArray2(13) = CheckBox113 digiInArray2(14) = CheckBox114 digiInArray2(15) = CheckBox115
Dim g As Integer For g = 0 To 15 digiInArray2(g).Visible = False Next g
End Sub
'this method creates the digital output array that corresponds to the group of checkboxes 'we are using to represent the state of the digital outputs on the interface kit Sub makeDigiOutArray() ReDim digiOutArray(15)
digiOutArray(0) = checkBox16 digiOutArray(1) = checkBox17 digiOutArray(2) = checkBox18 digiOutArray(3) = checkBox19 digiOutArray(4) = checkBox20 digiOutArray(5) = checkBox21 digiOutArray(6) = checkBox22 digiOutArray(7) = checkBox23 digiOutArray(8) = checkBox24 digiOutArray(9) = checkBox25 digiOutArray(10) = checkBox26 digiOutArray(11) = checkBox27 digiOutArray(12) = checkBox28 digiOutArray(13) = checkBox29 digiOutArray(14) = checkBox30 digiOutArray(15) = checkBox31
Dim i As Integer For i = 0 To 15 digiOutArray(i).Visible = False AddHandler digiOutArray(i).Click, AddressOf ClickOutputs Next i
End Sub
'this method creates the digital output array that corresponds to the group of checkboxes 'we are using to represent the state of the digital outputs on the interface kit Sub makeDigiOutArray2() ReDim digiOutArray2(15)
digiOutArray2(0) = CheckBox116 digiOutArray2(1) = CheckBox117 digiOutArray2(2) = CheckBox118 digiOutArray2(3) = CheckBox119 digiOutArray2(4) = CheckBox120 digiOutArray2(5) = CheckBox121 digiOutArray2(6) = CheckBox122 digiOutArray2(7) = CheckBox123 digiOutArray2(8) = CheckBox124 digiOutArray2(9) = CheckBox125 digiOutArray2(10) = CheckBox126 digiOutArray2(11) = CheckBox127 digiOutArray2(12) = CheckBox128 digiOutArray2(13) = CheckBox129 digiOutArray2(14) = CheckBox130 digiOutArray2(15) = CheckBox131
Dim g As Integer For g = 0 To 15 digiOutArray2(g).Visible = False AddHandler digiOutArray2(g).Click, AddressOf ClickOutputs2 Next g
End Sub
'this method creates the analog input array (mst likelely connected to analog sensors) that corresponds to the group 'of textboxes which will be holding the current values of the analog inputs that are being sent to the interface kit Sub makeSensorInArray() ReDim sensorInArray(7)
sensorInArray(0) = textBox1 sensorInArray(1) = textBox2 sensorInArray(2) = textBox3 sensorInArray(3) = textBox4 sensorInArray(4) = textBox5 sensorInArray(5) = textBox6 sensorInArray(6) = textBox7 sensorInArray(7) = textBox8
Dim i As Integer For i = 0 To 7 sensorInArray(i).Visible = False Next i
End Sub
Private Sub groupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles groupBox1.Enter
End Sub
'this method creates the analog input array (mst likelely connected to analog sensors) that corresponds to the group 'of textboxes which will be holding the current values of the analog inputs that are being sent to the interface kit Sub makeSensorInArray2() ReDim sensorInArray2(7)
sensorInArray2(0) = TextBox11 sensorInArray2(1) = TextBox12 sensorInArray2(2) = TextBox13 sensorInArray2(3) = TextBox14 sensorInArray2(4) = TextBox15 sensorInArray2(5) = TextBox16 sensorInArray2(6) = TextBox17 sensorInArray2(7) = TextBox18
Dim g As Integer For g = 0 To 7 sensorInArray2(g).Visible = False Next g
End Sub
Private Sub groupBox10_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox10.Enter
End Sub
Private Sub Label26_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label26.Click
End Sub
Private Sub test_Tag(ByVal sender As Object, ByVal e As Phidgets.Events.TagEventArgs) Handles phidgetRFID.Tag
If e.Tag = "01068e2ae3" Then
tagTxt401.Text = "User1" phidgetLCD.rows(0).DisplayString = "User1" phidgetIFK2.outputs(0) = True 'ΒΡΗΚΑ ΤΗΝ ΛΥΣΗ! ΑΥΤΟ ΧΡΕΙΑΖΕΤΑΙ ΚΑΙ ΕΝΕΡΓΟΠΟΙΕΙΤΑΙ ΤΟ ΡΕΛΕ
Else phidgetLCD.rows(0).DisplayString = "Access Denied"
End If
phidgetRFID.LED = True
End Sub
'Tag lost event handler...here we simply want to clear our tag field in the GUI Private Sub test_TagLost(ByVal sender As Object, ByVal e As Phidgets.Events.TagEventArgs) Handles phidgetRFID.TagLost tagTxt4.Text = "" tagTxt401.Text = "" phidgetLCD.rows(0).DisplayString = "" phidgetRFID.LED = False End Sub
End Class |