Delphi XE7已经内建了蓝牙功能,提供了System.Bluetooth.pas单元

顾名思义,System表示XE7的蓝牙功能可以在Windows,Android,IOS系统内使用

System.Bluetooth单元中主要包含一下几个类,其中带LE的支持所有系统,不带LE的类不支持Ios系统,带与不带LE功能是一样的。

TBluetoothManager
TBluetoothDeviceList
TBluetoothAdapter
TBluetoothDevice
TBluetoothService
TBluetoothServiceList
TBluetoothSocket

TBluetoothLEManager
TBluetoothLEDeviceList
TBluetoothLEAdapter
TBluetoothLEDevice
TBluetoothLEService
TBluetoothLEServiceList
TBluetoothLESocket

其中:

TBluetoothManager是蓝牙管理器,用于蓝牙设备管理,包括发现蓝牙设备,获取配对设备,处理远程配对请求等功能

TBluetoothDeviceList是蓝牙设备列表,TBluetoothDeviceList = class(TObjectList<TBluetoothDevice>),可以通过TBluetoothManager.GetPairedDevices获得配对设备列表

TBluetoothAdapter本机蓝牙设备,实现配对、取消配对等功能,可通过TBluetoothManager.CurrentAdapter得到当前蓝牙设备

TBluetoothDevice远端蓝牙设备,每个远端设备可以提供若干个服务(TBluetoothService),

TBluetoothService远端蓝牙设备服务,包括服务名和UUID

  TBluetoothService = record
Name: string;
UUID: TBluetoothUUID;
end;

TBluetoothServiceList服务列表 = class(TList<TBluetoothService>);可通过TBluetoothDevice.GetServices获得远端设备服务列表

TBluetoothSocket蓝牙通讯套接字,通过 TBluetoothDevice.CreateClientSocket(StringToGUID(ServiceGUI), True/False)创建,

下面是一个XE7自带的例子,记得在Android下把相关权限添加到工程设置中。

unit Unit1;

interface

uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, System.Bluetooth,
FMX.Layouts, FMX.ListBox, FMX.StdCtrls, FMX.Memo, FMX.Controls.Presentation,
FMX.Edit, FMX.TabControl; type TServerConnectionTH = class(TThread)
private
{ Private declarations }
FServerSocket: TBluetoothServerSocket;
FSocket: TBluetoothSocket;
FData: TBytes;
protected
procedure Execute; override;
public
{ Public declarations }
constructor Create(ACreateSuspended: Boolean);
destructor Destroy; override;
end; TForm1 = class(TForm)
ButtonDiscover: TButton;
ButtonPair: TButton;
ButtonUnPair: TButton;
ButtonPairedDevices: TButton;
DisplayR: TMemo;
Edit1: TEdit;
Button2: TButton;
FreeSocket: TButton;
Labeldiscoverable: TLabel;
ComboBoxDevices: TComboBox;
ComboBoxPaired: TComboBox;
Panel1: TPanel;
TabControl1: TTabControl;
TabItem1: TTabItem;
TabItem2: TTabItem;
LabelNameSarver: TLabel;
ButtonServices: TButton;
ComboBoxServices: TComboBox;
PanelClient: TPanel;
LabelClient: TLabel;
ButtonConnectToRFCOMM: TButton;
PanelServer: TPanel;
ButtonCloseReadingSocket: TButton;
ButtonOpenReadingSocket: TButton;
LabelServer: TLabel;
procedure ButtonDiscoverClick(Sender: TObject);
procedure ButtonPairClick(Sender: TObject);
procedure ButtonUnPairClick(Sender: TObject);
procedure ButtonPairedDeviceClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ButtonOpenReadingSocketClick(Sender: TObject);
procedure ButtonConnectToRFCOMMClick(Sender: TObject);
procedure ButtonCloseReadingSocketClick(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FreeSocketClick(Sender: TObject);
function ManagerConnected:Boolean;
function GetServiceName(GUID: string): string;
procedure ComboBoxPairedChange(Sender: TObject);
procedure ButtonServicesClick(Sender: TObject);
private
{ Private declarations }
FBluetoothManager: TBluetoothManager;
FDiscoverDevices: TBluetoothDeviceList;
FPairedDevices: TBluetoothDeviceList;
FAdapter: TBluetoothAdapter;
FData: TBytes;
FSocket: TBluetoothSocket;
ItemIndex: Integer;
ServerConnectionTH: TServerConnectionTH;
procedure DevicesDiscoveryEnd(const Sender: TObject; const ADevices: TBluetoothDeviceList);
procedure PairedDevices;
procedure SendData;
public
{ Public declarations }
end; Const
ServiceName = 'Basic Text Server';
ServiceGUI = '{B62C4E8D-62CC-404B-BBBF-BF3E3BBB1378}';
var
Form1: TForm1; implementation {$R *.fmx}
{$R *.NmXhdpiPh.fmx ANDROID}
{$R *.LgXhdpiPh.fmx ANDROID}
{$R *.SmXhdpiPh.fmx ANDROID}
{$R *.Macintosh.fmx MACOS}
{$R *.iPhone4in.fmx IOS}
{$R *.Windows.fmx MSWINDOWS} procedure TForm1.ButtonPairClick(Sender: TObject);
begin
if ManagerConnected then
if ComboboxDevices.ItemIndex > - then
FAdapter.Pair(FDiscoverDevices[ComboboxDevices.ItemIndex])
else
ShowMessage('No device selected');
end; procedure TForm1.ButtonUnPairClick(Sender: TObject);
begin
if ManagerConnected then
if ComboboxPaired.ItemIndex > - then
FAdapter.UnPair(FPairedDevices[ComboboxPaired.ItemIndex])
else
ShowMessage('No Paired device selected');
end; procedure TForm1.ComboBoxPairedChange(Sender: TObject);
begin
LabelNameSarver.Text := ComboBoxPaired.Items[ComboBoxPaired.ItemIndex];
end; procedure TForm1.PairedDevices;
var
I: Integer;
begin
ComboboxPaired.Clear;
if ManagerConnected then
begin
FPairedDevices := FBluetoothManager.GetPairedDevices;
if FPairedDevices.Count > then
for I:= to FPairedDevices.Count - do
ComboboxPaired.Items.Add(FPairedDevices[I].DeviceName)
else
ComboboxPaired.Items.Add('No Paired Devices');
end;
end; procedure TForm1.ButtonPairedDeviceClick(Sender: TObject);
begin
PairedDevices;
ComboboxPaired.DropDown;
end; procedure TForm1.ButtonServicesClick(Sender: TObject);
var
LServices: TBluetoothServiceList;
LDevice: TBluetoothDevice;
I: Integer;
begin
ComboBoxServices.Clear;
if ManagerConnected then
if ComboboxPaired.ItemIndex > - then
begin
LDevice := FPairedDevices[ComboboxPaired.ItemIndex] as TBluetoothDevice;
LServices := LDevice.GetServices;
for I := to LServices.Count - do
ComboBoxServices.Items.Add(LServices[I].Name + ' --> ' + GUIDToString(LServices[I].UUID));
ComboBoxServices.ItemIndex := ;
ComboBoxServices.DropDown;
end
else
ShowMessage('No paired device selected');
end; procedure TForm1.FreeSocketClick(Sender: TObject);
begin
FreeAndNil(FSocket);
DisplayR.Lines.Add('Client socket set free');
DisplayR.GoToLineEnd;
end; procedure TForm1.Button2Click(Sender: TObject);
begin
DisplayR.ReadOnly := False;
DisplayR.SelectAll;
DisplayR.DeleteSelection;
DisplayR.ReadOnly := True;
end; function TForm1.GetServiceName(GUID: string): string;
var
LServices: TBluetoothServiceList;
LDevice: TBluetoothDevice;
I: Integer;
begin
LDevice := FPairedDevices[ComboboxPaired.ItemIndex] as TBluetoothDevice;
LServices := LDevice.GetServices;
for I := to LServices.Count - do
begin
if StringToGUID(GUID) = LServices[I].UUID then
begin
Result := LServices[I].Name;
break;
end;
end;
end; procedure TForm1.ButtonConnectToRFCOMMClick(Sender: TObject);
begin
if ManagerConnected then
try
SendData;
except
on E : Exception do
begin
DisplayR.Lines.Add(E.Message);
DisplayR.GoToTextEnd;
FreeAndNil(FSocket);
end;
end;
end; function TForm1.ManagerConnected:Boolean;
begin
if FBluetoothManager.ConnectionState = TBluetoothConnectionState.Connected then
begin
Labeldiscoverable.Text := 'Device discoverable as "'+FBluetoothManager.CurrentAdapter.AdapterName+'"';
Result := True;
end
else
begin
Result := False;
DisplayR.Lines.Add('No Bluetooth device Found');
DisplayR.GoToTextEnd;
end
end; procedure TForm1.SendData;
var
ToSend: TBytes;
LDevice: TBluetoothDevice;
begin
if (FSocket = nil) or (ItemIndex <> ComboboxPaired.ItemIndex) then
begin
if ComboboxPaired.ItemIndex > - then
begin
LDevice := FPairedDevices[ComboboxPaired.ItemIndex] as TBluetoothDevice;
DisplayR.Lines.Add(GetServiceName(ServiceGUI));
DisplayR.GoToTextEnd;
FSocket := LDevice.CreateClientSocket(StringToGUID(ServiceGUI), False);
if FSocket <> nil then
begin
ItemIndex := ComboboxPaired.ItemIndex;
FSocket.Connect;
ToSend := TEncoding.UTF8.GetBytes(Edit1.Text);
FSocket.SendData(ToSend);
DisplayR.Lines.Add('Text Sent');
DisplayR.GoToTextEnd;
end
else
ShowMessage('Out of time -15s-');
end
else
ShowMessage('No paired device selected');
end
else
begin
ToSend := TEncoding.UTF8.GetBytes(Edit1.Text);
FSocket.SendData(ToSend);
DisplayR.Lines.Add('Text Sent');
DisplayR.GoToTextEnd;
end;
end; procedure TForm1.ButtonDiscoverClick(Sender: TObject);
begin
ComboboxDevices.Clear;
if ManagerConnected then
begin
FAdapter := FBluetoothManager.CurrentAdapter;
FBluetoothManager.StartDiscovery();
FBluetoothManager.OnDiscoveryEnd := DevicesDiscoveryEnd;
end;
end; procedure TForm1.DevicesDiscoveryEnd(const Sender: TObject; const ADevices: TBluetoothDeviceList);
var
I: Integer;
begin
FDiscoverDevices := ADevices;
for I := to ADevices.Count - do
ComboboxDevices.Items.Add(ADevices[I].DeviceName + ' -> ' + ADevices[I].Address);
ComboboxDevices.ItemIndex := ;
end; procedure TForm1.ButtonOpenReadingSocketClick(Sender: TObject);
begin
if (ServerConnectionTH = nil) and ManagerConnected then
begin
try
FAdapter := FBluetoothManager.CurrentAdapter;
ServerConnectionTH := TServerConnectionTH.Create(True);
ServerConnectionTH.FServerSocket := FAdapter.CreateServerSocket(ServiceName, StringToGUID(ServiceGUI), False);
ServerConnectionTH.Start;
DisplayR.Lines.Add(' - Service created: "'+ServiceName+'"');
DisplayR.GoToTextEnd;
except
on E : Exception do
begin
DisplayR.Lines.Add(E.Message);
DisplayR.GoToTextEnd;
end;
end;
end;
end; procedure TForm1.ButtonCloseReadingSocketClick(Sender: TObject);
begin
if ServerConnectionTH <> nil then
begin
ServerConnectionTH.Terminate;
ServerConnectionTH.WaitFor;
FreeAndNil(ServerConnectionTH);
DisplayR.Lines.Add(' - Service removed -');
DisplayR.GoToTextEnd;
end
end; procedure TForm1.FormShow(Sender: TObject);
begin
try
LabelServer.Text := ServiceName;
LabelClient.Text := 'Client of '+ServiceName;
FBluetoothManager := TBluetoothManager.Current;
FAdapter := FBluetoothManager.CurrentAdapter;
if ManagerConnected then
begin
PairedDevices;
ComboboxPaired.ItemIndex := ;
end;
except
on E : Exception do
begin
ShowMessage(E.Message);
end;
end;
end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if ServerConnectionTH <> nil then
begin
ServerConnectionTH.Terminate;
ServerConnectionTH.WaitFor;
FreeAndNil(ServerConnectionTH);
end
end; {TServerConnection} constructor TServerConnectionTH.Create(ACreateSuspended: Boolean);
begin
inherited;
end; destructor TServerConnectionTH.Destroy;
begin
FSocket.Free;
FServerSocket.Free;
inherited;
end; procedure TServerConnectionTH.execute;
var
ASocket: TBluetoothSocket;
Msg: string;
begin
while not Terminated do
try
ASocket := nil;
while not Terminated and (ASocket = nil) do
ASocket := FServerSocket.Accept();
if(ASocket <> nil) then
begin
FSocket := ASocket;
while not Terminated do
begin
FData := ASocket.ReadData;
if length(FData) > then
Synchronize(procedure
begin
Form1.DisplayR.Lines.Add(TEncoding.UTF8.GetString(FData));
Form1.DisplayR.GoToTextEnd;
end);
sleep();
end;
end;
except
on E : Exception do
begin
Msg := E.Message;
Synchronize(procedure
begin
Form1.DisplayR.Lines.Add('Server Socket closed: ' + Msg);
Form1.DisplayR.GoToTextEnd;
end);
end;
end;
end; end.

窗体文件

object Form1: TForm1
Left =
Top =
Caption = 'Basic Classic Bluetooth Demo'
ClientHeight =
ClientWidth =
FormFactor.Width =
FormFactor.Height =
FormFactor.Devices = [Desktop]
OnClose = FormClose
OnShow = FormShow
DesignerMasterStyle =
object Panel1: TPanel
Align = Client
Size.Width = 360.000000000000000000
Size.Height = 570.000000000000000000
Size.PlatformDefault = False
TabOrder =
object TabControl1: TTabControl
Align = Client
FullSize = True
Size.Width = 360.000000000000000000
Size.Height = 570.000000000000000000
Size.PlatformDefault = False
TabHeight = 49.000000000000000000
TabIndex =
TabOrder =
TabPosition = Bottom
object TabItem1: TTabItem
CustomIcon = <
item
end>
IsSelected = True
Size.Width = 180.000000000000000000
Size.Height = 49.000000000000000000
Size.PlatformDefault = False
TabOrder =
Text = 'Bluetooth settings'
object ButtonDiscover: TButton
Position.X = 4.000000000000000000
Position.Y = 59.000000000000000000
Size.Width = 158.000000000000000000
Size.Height = 31.000000000000000000
Size.PlatformDefault = False
TabOrder =
Text = 'Discover devices'
OnClick = ButtonDiscoverClick
end
object ButtonPair: TButton
Position.X = 191.000000000000000000
Position.Y = 59.000000000000000000
Size.Width = 78.000000000000000000
Size.Height = 31.000000000000000000
Size.PlatformDefault = False
TabOrder =
Text = 'Pair'
OnClick = ButtonPairClick
end
object ButtonPairedDevices: TButton
Position.X = 4.000000000000000000
Position.Y = 140.000000000000000000
Size.Width = 158.000000000000000000
Size.Height = 31.000000000000000000
Size.PlatformDefault = False
TabOrder =
Text = 'Paired Devices'
OnClick = ButtonPairedDeviceClick
end
object ButtonUnPair: TButton
Position.X = 277.000000000000000000
Position.Y = 67.000000000000000000
Size.Width = 80.000000000000000000
Size.Height = 22.000000000000000000
Size.PlatformDefault = False
TabOrder =
Text = 'UnPair'
OnClick = ButtonUnPairClick
end
object ComboBoxDevices: TComboBox
Position.X = 4.000000000000000000
Position.Y = 92.000000000000000000
Size.Width = 352.000000000000000000
Size.Height = 32.000000000000000000
Size.PlatformDefault = False
TabOrder =
end
object ComboBoxPaired: TComboBox
Position.X = 4.000000000000000000
Position.Y = 173.000000000000000000
Size.Width = 352.000000000000000000
Size.Height = 32.000000000000000000
Size.PlatformDefault = False
TabOrder =
OnChange = ComboBoxPairedChange
end
object ButtonServices: TButton
Position.X = 4.000000000000000000
Position.Y = 221.000000000000000000
Size.Width = 158.000000000000000000
Size.Height = 31.000000000000000000
Size.PlatformDefault = False
TabOrder =
Text = 'Services'
OnClick = ButtonServicesClick
end
object ComboBoxServices: TComboBox
Position.X = 4.000000000000000000
Position.Y = 254.000000000000000000
Size.Width = 352.000000000000000000
Size.Height = 32.000000000000000000
Size.PlatformDefault = False
TabOrder =
end
end
object TabItem2: TTabItem
CustomIcon = <
item
end>
IsSelected = False
Size.Width = 180.000000000000000000
Size.Height = 49.000000000000000000
Size.PlatformDefault = False
TabOrder =
Text = 'Service demo'
object PanelClient: TPanel
Position.Y = 134.000000000000000000
Size.Width = 360.000000000000000000
Size.Height = 153.000000000000000000
Size.PlatformDefault = False
TabOrder =
object Button2: TButton
Position.X = 4.000000000000000000
Position.Y = 115.000000000000000000
Size.Width = 73.000000000000000000
Size.Height = 25.000000000000000000
Size.PlatformDefault = False
TabOrder =
Text = 'Clear'
OnClick = Button2Click
end
object Edit1: TEdit
Touch.InteractiveGestures = [LongTap, DoubleTap]
TabOrder =
Text = 'I am the text sent'
Position.X = 4.000000000000000000
Position.Y = 71.000000000000000000
Size.Width = 343.000000000000000000
Size.Height = 32.000000000000000000
Size.PlatformDefault = False
end
object FreeSocket: TButton
Position.X = 190.000000000000000000
Position.Y = 115.000000000000000000
Size.Width = 157.000000000000000000
Size.Height = 25.000000000000000000
Size.PlatformDefault = False
TabOrder =
Text = 'Free Client Socket'
OnClick = FreeSocketClick
end
object LabelNameSarver: TLabel
Position.X = 157.000000000000000000
Position.Y = 22.000000000000000000
Size.Width = 180.000000000000000000
Size.Height = 40.000000000000000000
Size.PlatformDefault = False
end
object LabelClient: TLabel
StyledSettings = [Family, Size, FontColor]
Position.X = 4.000000000000000000
Size.Width = 227.000000000000000000
Size.Height = 20.000000000000000000
Size.PlatformDefault = False
Text = 'Client'
end
object ButtonConnectToRFCOMM: TButton
Position.X = 4.000000000000000000
Position.Y = 28.000000000000000000
Size.Width = 143.000000000000000000
Size.Height = 33.000000000000000000
Size.PlatformDefault = False
TabOrder =
Text = 'Send text to ->'
OnClick = ButtonConnectToRFCOMMClick
end
end
object PanelServer: TPanel
Position.Y = 40.000000000000000000
Size.Width = 360.000000000000000000
Size.Height = 93.000000000000000000
Size.PlatformDefault = False
TabOrder =
object ButtonCloseReadingSocket: TButton
Position.X = 195.000000000000000000
Position.Y = 32.000000000000000000
Size.Width = 160.000000000000000000
Size.Height = 36.000000000000000000
Size.PlatformDefault = False
TabOrder =
Text = 'Remove text service'
OnClick = ButtonCloseReadingSocketClick
end
object ButtonOpenReadingSocket: TButton
Position.X = 4.000000000000000000
Position.Y = 32.000000000000000000
Size.Width = 160.000000000000000000
Size.Height = 36.000000000000000000
Size.PlatformDefault = False
TabOrder =
Text = 'Create text service'
OnClick = ButtonOpenReadingSocketClick
end
object LabelServer: TLabel
StyledSettings = [Family, Size, FontColor]
Position.X = 4.000000000000000000
Size.Width = 227.000000000000000000
Size.Height = 20.000000000000000000
Size.PlatformDefault = False
Text = 'Server'
end
end
end
end
object Labeldiscoverable: TLabel
StyledSettings = [Family, Style, FontColor]
Position.X = 16.000000000000000000
Position.Y = 8.000000000000000000
Size.Width = 321.000000000000000000
Size.Height = 23.000000000000000000
Size.PlatformDefault = False
end
object DisplayR: TMemo
Touch.InteractiveGestures = [Pan, LongTap, DoubleTap]
Anchors = [akLeft, akTop, akRight]
Position.Y = 288.000000000000000000
Size.Width = 360.000000000000000000
Size.Height = 232.000000000000000000
Size.PlatformDefault = False
TabOrder =
TabStop = False
ReadOnly = True
ShowSizeGrip = True
end
end
end

Delphi XE7的蓝牙 Bluetooth的更多相关文章

  1. 蓝牙Bluetooth技术小知识

    蓝牙Bluetooth技术以及广泛的应用于各种设备,并将继续在物联网IoT领域担任重要角色.下面搜集整理了一些关于蓝牙技术的小知识,以备参考. 蓝牙Bluetooth技术始创于1994年,其名字来源于 ...

  2. 蓝牙(Bluetooth) IEEE 802.15.1 协议学习

    catalogue . 蓝牙概念 . 配对和连接 . 机密安全性 . 蓝牙协议分类 . 蓝牙协议栈 1. 蓝牙概念 蓝牙(Bluetooth)是一种无线技术标准,可实现固定设备.移动设备和楼宇个人域网 ...

  3. RemObjects SDK Source For Delphi XE7

    原文:http://blog.csdn.net/tht2009/article/details/39545545 1.目前官网最新版本是RemObjects SDK for Delphi and al ...

  4. delphi XE7 中的消息

    在delphi XE7的程序开发中,消息机制保证进程间的通信. 在程序中,消息来自: 1)系统: 通知你的程序用户输入,涂画以及其他的系统范围的事件: 2)你的程序:不同的程序部分之间的通信信息.   ...

  5. 关于delphi XE7中的动态数组和并行编程(第一部分)

    本文引自:http://www.danieleteti.it/category/embarcadero/delphi-xe7-embarcadero/ 并行编程库是delphi XE7中引进的最受期待 ...

  6. 咏南CS多层插件式开发框架支持最新的DELPHI XE7

    DATASNAP中间件: 中间件已经在好几个实际项目中应用,长时间运行异常稳定,可无人值守: 可编译环境:DELPHI XE5~DELPHI XE7,无需变动代码: 支持传统TCP/IP方式也支持RE ...

  7. Delphi XE7中新并行库

    Delphi XE7中添加了新的并行库,和.NET的Task和Parellel相似度99%. 详细内容能够看以下的文章: http://www.delphifeeds.com/go/s/119574 ...

  8. android -- 蓝牙 bluetooth (四)OPP文件传输

    在前面android -- 蓝牙 bluetooth (一) 入门文章结尾中提到了会按四个方面来写这系列的文章,前面已写了蓝牙打开和蓝牙搜索,这次一起来看下蓝牙文件分享的流程,也就是蓝牙应用opp目录 ...

  9. android -- 蓝牙 bluetooth (三)搜索蓝牙

    接上篇打开蓝牙继续,来一起看下蓝牙搜索的流程,触发蓝牙搜索的条件形式上有两种,一是在蓝牙设置界面开启蓝牙会直接开始搜索,另一个是先打开蓝牙开关在进入蓝牙设置界面也会触发搜索,也可能还有其它触发方式,但 ...

随机推荐

  1. PyCharm2018 安装及破解方法

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/u012278016/article/details/81738676 目录 1>. 安装 2& ...

  2. python的逻辑运算符

    函数就是特殊的变量(这个变量是不加引号的)  我们 如果直接打印一个函数的名字是直接打印这个函数的内存地址 python的运算符: 首先Python的运算符和其他语言的运算符都是一样的  都有:算数运 ...

  3. Linux 配置samba服务实现与Windows文件共享

    目录: 1.samba服务介绍 2. 安装samba服务和客户端 3.samba配置文件详解 4.配置实例 5.客户端挂载与测试 6.samba排错 1.Samba服务介绍     Samba 最先在 ...

  4. 沉淀再出发:ELK使用初探

    沉淀再出发:ELK使用初探 一.前言 ELK是Elasticsearch.Logstash.Kibana的简称,这三者是核心套件,但并非全部. 最近ElasticSearch可以说是非常火的一款开源软 ...

  5. 最优化 KKT条件

    对于约束优化问题: 拉格朗日公式: 其KKT条件为: 求解 x.α.β 其中β*g(x)为互补松弛条件 KKT条件是使一组解成为最优解的必要条件,当原问题是凸问题的时候,KKT条件也是充分条件.

  6. Eclipse+Maven 项目创建

    ★:jar包下载不了的话可能是镜像里没有这个版本,换个低版本的就行 ★:eclipse工程validating很慢,可以先关掉验证(一般对项目没什么影响) ★:eclipse工程pom.xml文件报错 ...

  7. 编程题A+B Format的总结(第二次作业<一>)

    Github链接地址:https://github.com/Startup-try/object-oriented 这个题目现在想想没有那么难,其实还挺简单的,但是中午花了好长的时间还不懂得怎么做,感 ...

  8. 12、Node.js 路由

    这里实现的好像就是把路由和服务器相结合起来.具体需要引入 url 模块和 http 模块为路由提供请求的 URL 和其他需要的 GET 及 POST 参数,随后路由需要根据这些数据来执行相应的代码需要 ...

  9. js判断鼠标滚轴方向(向上或向下)

    var num=1; $(document).on("mousewheel DOMMouseScroll", function (e) { var delta = (e.origi ...

  10. JAVA中正则表达式学习总结

    一.JAVA中正则表达式相关的类 1. java.util.regex.Pattern 该类用于编译模式,模式可以理解为一个正则表达式,比如:a*b. 用法如下: // 创建模式 Pattern p ...