Phidgetsのプログラミング例 |
import Phidgets.*; public class IFKex1 extends _IPhidgetInterfaceKitEventsAdapter { public void OnSensorChange(_IPhidgetInterfaceKitEvents_OnSensorChangeEvent ke) { System.out.println("SensorChange: " + ke.get_SensorValue()); } public void OnInputChange(_IPhidgetInterfaceKitEvents_OnInputChangeEvent ke) { System.out.println("InputChange: " + ke.get_Index() + " " + ke.get_NewState()); } public void OnDetach(_IPhidgetInterfaceKitEvents_OnDetachEvent ke) { System.out.println("FINISHED!"); } public static void main(String[] args) { new IFKex1(); } public IFKex1() { PhidgetInterfaceKit phid = new PhidgetInterfaceKit(); phid.add_IPhidgetInterfaceKitEventsListener(this); if (phid.Open(false) == false) { System.out.println("Could not find a PhidgetInterfaceKit"); return; } System.out.println(phid.GetDeviceType()); System.out.println("Serial Number " + phid.GetSerialNumber()); System.out.println("Device Version " + phid.GetDeviceVersion()); phid.SetSensorChangeTrigger(7, 1); phid.start(); for(int i = 0; i < 1000; ++i) { phid.SetOutputState(0,true); } // Turn the output on, and rudely leave it turned on! phid.Close(); System.out.println("Closed and exitting..."); } }