本文整理汇总了C#中IPConnection.Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C# IPConnection.Disconnect方法的具体用法?C# IPConnection.Disconnect怎么用?C# IPConnection.Disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPConnection
的用法示例。
在下文中一共展示了IPConnection.Disconnect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
private static string UID = "XYZ"; // Change XYZ to the UID of your Tilt Bricklet
#endregion Fields
#region Methods
static void Main()
{
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickletTilt t = new BrickletTilt(UID, ipcon); // Create device object
ipcon.Connect(HOST, PORT); // Connect to brickd
// Don't use device before ipcon is connected
// Get current tilt state
byte state = t.GetTiltState();
switch(state)
{
case BrickletTilt.TILT_STATE_CLOSED:
Console.WriteLine("Tilt State: Closed");
break;
case BrickletTilt.TILT_STATE_OPEN:
Console.WriteLine("Tilt State: Open");
break;
case BrickletTilt.TILT_STATE_CLOSED_VIBRATING:
Console.WriteLine("Tilt State: Closed Vibrating");
break;
}
Console.WriteLine("Press enter to exit");
Console.ReadLine();
ipcon.Disconnect();
}
示例2: Main
private static string UID = "XYZ"; // Change XYZ to the UID of your Industrial Digital Out 4 Bricklet
#endregion Fields
#region Methods
static void Main()
{
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickletIndustrialDigitalOut4 ido4 =
new BrickletIndustrialDigitalOut4(UID, ipcon); // Create device object
ipcon.Connect(HOST, PORT); // Connect to brickd
// Don't use device before ipcon is connected
// Turn pins alternating high/low 10 times with 100ms delay
for(int i = 0; i < 10; i++)
{
Thread.Sleep(100);
ido4.SetValue(1 << 0);
Thread.Sleep(100);
ido4.SetValue(1 << 1);
Thread.Sleep(100);
ido4.SetValue(1 << 2);
Thread.Sleep(100);
ido4.SetValue(1 << 3);
}
Console.WriteLine("Press enter to exit");
Console.ReadLine();
ipcon.Disconnect();
}
示例3: Main
private static string UID = "XYZ"; // Change XYZ to the UID of your Multi Touch Bricklet
#endregion Fields
#region Methods
static void Main()
{
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickletMultiTouch mt = new BrickletMultiTouch(UID, ipcon); // Create device object
ipcon.Connect(HOST, PORT); // Connect to brickd
// Don't use device before ipcon is connected
// Get current touch state
int state = mt.GetTouchState();
string str = "";
if((state & (1 << 12)) == (1 << 12)) {
str += "In proximity, ";
}
if((state & 0xfff) == 0) {
str += "No electrodes touched";
} else {
str += "Electrodes ";
for(int i = 0; i < 12; i++) {
if((state & (1 << i)) == (1 << i)) {
str += i + " ";
}
}
str += "touched";
}
Console.WriteLine(str);
Console.WriteLine("Press enter to exit");
Console.ReadLine();
ipcon.Disconnect();
}
示例4: Main
private static string UID = "XXYYZZ"; // Change XXYYZZ to the UID of your Servo Brick
#endregion Fields
#region Methods
static void Main()
{
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickServo servo = new BrickServo(UID, ipcon); // Create device object
ipcon.Connect(HOST, PORT); // Connect to brickd
// Don't use device before ipcon is connected
// Register position reached callback to function PositionReachedCB
servo.PositionReached += PositionReachedCB;
// Enable position reached callback
servo.EnablePositionReachedCallback();
// Set velocity to 100°/s. This has to be smaller or equal to the
// maximum velocity of the servo you are using, otherwise the position
// reached callback will be called too early
servo.SetVelocity(0, 10000);
servo.SetPosition(0, 9000);
servo.Enable(0);
Console.WriteLine("Press enter to exit");
Console.ReadLine();
servo.Disable(0);
ipcon.Disconnect();
}
示例5: Main
private static string UID = "XYZ"; // Change XYZ to the UID of your Real-Time Clock Bricklet
#endregion Fields
#region Methods
static void Main()
{
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickletRealTimeClock rtc = new BrickletRealTimeClock(UID, ipcon); // Create device object
ipcon.Connect(HOST, PORT); // Connect to brickd
// Don't use device before ipcon is connected
// Get current date and time
int year; byte month, day, hour, minute, second, centisecond, weekday;
rtc.GetDateTime(out year, out month, out day, out hour, out minute, out second,
out centisecond, out weekday);
Console.WriteLine("Year: " + year);
Console.WriteLine("Month: " + month);
Console.WriteLine("Day: " + day);
Console.WriteLine("Hour: " + hour);
Console.WriteLine("Minute: " + minute);
Console.WriteLine("Second: " + second);
Console.WriteLine("Centisecond: " + centisecond);
Console.WriteLine("Weekday: " + weekday);
// Get current timestamp (unit is ms)
long timestamp = rtc.GetTimestamp();
Console.WriteLine("Timestamp: " + timestamp + " ms");
Console.WriteLine("Press enter to exit");
Console.ReadLine();
ipcon.Disconnect();
}
示例6: Main
static void Main()
{
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickletCAN can = new BrickletCAN(UID, ipcon); // Create device object
ipcon.Connect(HOST, PORT); // Connect to brickd
// Don't use device before ipcon is connected
// Configure transceiver for loopback mode
can.SetConfiguration(BrickletCAN.BAUD_RATE_1000KBPS,
BrickletCAN.TRANSCEIVER_MODE_LOOPBACK, 0);
// Register frame read callback to function FrameReadCB
can.FrameRead += FrameReadCB;
// Enable frame read callback
can.EnableFrameReadCallback();
// Write standard data frame with identifier 1742 and 3 bytes of data
byte[] data = new byte[8]{42, 23, 17, 0, 0, 0, 0, 0};
can.WriteFrame(BrickletCAN.FRAME_TYPE_STANDARD_DATA, 1742, data, 3);
Console.WriteLine("Press enter to exit");
Console.ReadLine();
can.DisableFrameReadCallback();
ipcon.Disconnect();
}
示例7: Main
private static int VALUE_B_ON = (1 << 1) | (1 << 2); // Pin 1 and 2 high
#endregion Fields
#region Methods
static void Main()
{
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickletIndustrialQuadRelay iqr = new BrickletIndustrialQuadRelay(UID, ipcon); // Create device object
ipcon.Connect(HOST, PORT); // Connect to brickd
// Don't use device before ipcon is connected
iqr.SetMonoflop(VALUE_A_ON, 15, 1500); // Set pins to high for 1.5 seconds
ipcon.Disconnect();
}
示例8: Main
private static string UID = "XYZ"; // Change XYZ to the UID of your Analog Out Bricklet
#endregion Fields
#region Methods
static void Main()
{
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickletAnalogOut ao = new BrickletAnalogOut(UID, ipcon); // Create device object
ipcon.Connect(HOST, PORT); // Connect to brickd
// Don't use device before ipcon is connected
// Set output voltage to 3.3V
ao.SetVoltage(3300);
Console.WriteLine("Press enter to exit");
Console.ReadLine();
ipcon.Disconnect();
}
示例9: Main
private static string UID = "XYZ"; // Change XYZ to the UID of your Piezo Buzzer Bricklet
#endregion Fields
#region Methods
static void Main()
{
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickletPiezoBuzzer pb = new BrickletPiezoBuzzer(UID, ipcon); // Create device object
ipcon.Connect(HOST, PORT); // Connect to brickd
// Don't use device before ipcon is connected
// Make 2 second beep
pb.Beep(2000);
Console.WriteLine("Press enter to exit");
Console.ReadLine();
ipcon.Disconnect();
}
示例10: Main
private static string UID = "XYZ"; // Change XYZ to the UID of your Multi Touch Bricklet
#endregion Fields
#region Methods
static void Main()
{
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickletMultiTouch mt = new BrickletMultiTouch(UID, ipcon); // Create device object
ipcon.Connect(HOST, PORT); // Connect to brickd
// Don't use device before ipcon is connected
// Register touch state callback to function TouchStateCB
mt.TouchState += TouchStateCB;
Console.WriteLine("Press enter to exit");
Console.ReadLine();
ipcon.Disconnect();
}
示例11: Main
private static string UID = "XYZ"; // Change XYZ to the UID of your Piezo Buzzer Bricklet
#endregion Fields
#region Methods
static void Main()
{
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickletPiezoBuzzer pb = new BrickletPiezoBuzzer(UID, ipcon); // Create device object
ipcon.Connect(HOST, PORT); // Connect to brickd
// Don't use device before ipcon is connected
// Morse SOS
pb.MorseCode("... --- ...");
Console.WriteLine("Press enter to exit");
Console.ReadLine();
ipcon.Disconnect();
}
示例12: Main
private static string UID = "XYZ"; // Change XYZ to the UID of your RGB LED Bricklet
#endregion Fields
#region Methods
static void Main()
{
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickletRGBLED rl = new BrickletRGBLED(UID, ipcon); // Create device object
ipcon.Connect(HOST, PORT); // Connect to brickd
// Don't use device before ipcon is connected
// Set light blue color
rl.SetRGBValue(0, 170, 234);
Console.WriteLine("Press enter to exit");
Console.ReadLine();
ipcon.Disconnect();
}
示例13: Main
private static string UID = "XYZ"; // Change XYZ to the UID of your Dual Button Bricklet
#endregion Fields
#region Methods
static void Main()
{
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickletDualButton db = new BrickletDualButton(UID, ipcon); // Create device object
ipcon.Connect(HOST, PORT); // Connect to brickd
// Don't use device before ipcon is connected
// Register state changed callback to function StateChangedCB
db.StateChanged += StateChangedCB;
Console.WriteLine("Press enter to exit");
Console.ReadLine();
ipcon.Disconnect();
}
示例14: Main
private static string UID = "XYZ"; // Change XYZ to the UID of your Piezo Speaker Bricklet
#endregion Fields
#region Methods
static void Main()
{
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickletPiezoSpeaker ps = new BrickletPiezoSpeaker(UID, ipcon); // Create device object
ipcon.Connect(HOST, PORT); // Connect to brickd
// Don't use device before ipcon is connected
// Morse SOS with a frequency of 2kHz
ps.MorseCode("... --- ...", 2000);
Console.WriteLine("Press enter to exit");
Console.ReadLine();
ipcon.Disconnect();
}
示例15: Main
private static string UID = "XYZ"; // Change XYZ to the UID of your Linear Poti Bricklet
#endregion Fields
#region Methods
static void Main()
{
IPConnection ipcon = new IPConnection(); // Create IP connection
BrickletLinearPoti lp = new BrickletLinearPoti(UID, ipcon); // Create device object
ipcon.Connect(HOST, PORT); // Connect to brickd
// Don't use device before ipcon is connected
// Get current position (range is 0 to 100)
int position = lp.GetPosition();
Console.WriteLine("Position: " + position);
Console.WriteLine("Press enter to exit");
Console.ReadLine();
ipcon.Disconnect();
}