Compare commits
No commits in common. 'master' and 'simulator-backend' have entirely different histories.
master
...
simulator-
@ -1,53 +0,0 @@
|
||||
# ---> Eagle
|
||||
# Ignore list for Eagle, a PCB layout tool
|
||||
|
||||
# Backup files
|
||||
*.s#?
|
||||
*.b#?
|
||||
*.l#?
|
||||
*.b$?
|
||||
*.s$?
|
||||
*.l$?
|
||||
|
||||
# Eagle project file
|
||||
# It contains a serial number and references to the file structure
|
||||
# on your computer.
|
||||
# comment the following line if you want to have your project file included.
|
||||
eagle.epf
|
||||
|
||||
# Autorouter files
|
||||
*.pro
|
||||
*.job
|
||||
|
||||
# CAM files
|
||||
*.$$$
|
||||
*.cmp
|
||||
*.ly2
|
||||
*.l15
|
||||
*.sol
|
||||
*.plc
|
||||
*.stc
|
||||
*.sts
|
||||
*.crc
|
||||
*.crs
|
||||
|
||||
*.dri
|
||||
*.drl
|
||||
*.gpi
|
||||
*.pls
|
||||
*.ger
|
||||
*.xln
|
||||
|
||||
*.drd
|
||||
*.drd.*
|
||||
|
||||
*.s#*
|
||||
*.b#*
|
||||
|
||||
*.info
|
||||
|
||||
*.eps
|
||||
|
||||
# file locks introduced since 7.x
|
||||
*.lck
|
||||
|
||||
@ -1,208 +0,0 @@
|
||||
Apache License
|
||||
|
||||
Version 2.0, January 2004
|
||||
|
||||
http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION,
|
||||
AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and distribution
|
||||
as defined by Sections 1 through 9 of this document.
|
||||
|
||||
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
||||
owner that is granting the License.
|
||||
|
||||
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities
|
||||
that control, are controlled by, or are under common control with that entity.
|
||||
For the purposes of this definition, "control" means (i) the power, direct
|
||||
or indirect, to cause the direction or management of such entity, whether
|
||||
by contract or otherwise, or (ii) ownership of fifty percent (50%) or more
|
||||
of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions
|
||||
granted by this License.
|
||||
|
||||
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including
|
||||
but not limited to software source code, documentation source, and configuration
|
||||
files.
|
||||
|
||||
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation
|
||||
or translation of a Source form, including but not limited to compiled object
|
||||
code, generated documentation, and conversions to other media types.
|
||||
|
||||
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form,
|
||||
made available under the License, as indicated by a copyright notice that
|
||||
is included in or attached to the work (an example is provided in the Appendix
|
||||
below).
|
||||
|
||||
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form,
|
||||
that is based on (or derived from) the Work and for which the editorial revisions,
|
||||
annotations, elaborations, or other modifications represent, as a whole, an
|
||||
original work of authorship. For the purposes of this License, Derivative
|
||||
Works shall not include works that remain separable from, or merely link (or
|
||||
bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version
|
||||
of the Work and any modifications or additions to that Work or Derivative
|
||||
Works thereof, that is intentionally submitted to Licensor for inclusion in
|
||||
the Work by the copyright owner or by an individual or Legal Entity authorized
|
||||
to submit on behalf of the copyright owner. For the purposes of this definition,
|
||||
"submitted" means any form of electronic, verbal, or written communication
|
||||
sent to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems, and
|
||||
issue tracking systems that are managed by, or on behalf of, the Licensor
|
||||
for the purpose of discussing and improving the Work, but excluding communication
|
||||
that is conspicuously marked or otherwise designated in writing by the copyright
|
||||
owner as "Not a Contribution."
|
||||
|
||||
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
||||
of whom a Contribution has been received by Licensor and subsequently incorporated
|
||||
within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this
|
||||
License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
|
||||
no-charge, royalty-free, irrevocable copyright license to reproduce, prepare
|
||||
Derivative Works of, publicly display, publicly perform, sublicense, and distribute
|
||||
the Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License,
|
||||
each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
|
||||
no-charge, royalty-free, irrevocable (except as stated in this section) patent
|
||||
license to make, have made, use, offer to sell, sell, import, and otherwise
|
||||
transfer the Work, where such license applies only to those patent claims
|
||||
licensable by such Contributor that are necessarily infringed by their Contribution(s)
|
||||
alone or by combination of their Contribution(s) with the Work to which such
|
||||
Contribution(s) was submitted. If You institute patent litigation against
|
||||
any entity (including a cross-claim or counterclaim in a lawsuit) alleging
|
||||
that the Work or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses granted to You
|
||||
under this License for that Work shall terminate as of the date such litigation
|
||||
is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or
|
||||
Derivative Works thereof in any medium, with or without modifications, and
|
||||
in Source or Object form, provided that You meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or Derivative Works a copy
|
||||
of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices stating that
|
||||
You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works that You distribute,
|
||||
all copyright, patent, trademark, and attribution notices from the Source
|
||||
form of the Work, excluding those notices that do not pertain to any part
|
||||
of the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its distribution,
|
||||
then any Derivative Works that You distribute must include a readable copy
|
||||
of the attribution notices contained within such NOTICE file, excluding those
|
||||
notices that do not pertain to any part of the Derivative Works, in at least
|
||||
one of the following places: within a NOTICE text file distributed as part
|
||||
of the Derivative Works; within the Source form or documentation, if provided
|
||||
along with the Derivative Works; or, within a display generated by the Derivative
|
||||
Works, if and wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and do not modify the
|
||||
License. You may add Your own attribution notices within Derivative Works
|
||||
that You distribute, alongside or as an addendum to the NOTICE text from the
|
||||
Work, provided that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and may provide
|
||||
additional or different license terms and conditions for use, reproduction,
|
||||
or distribution of Your modifications, or for any such Derivative Works as
|
||||
a whole, provided Your use, reproduction, and distribution of the Work otherwise
|
||||
complies with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
||||
Contribution intentionally submitted for inclusion in the Work by You to the
|
||||
Licensor shall be under the terms and conditions of this License, without
|
||||
any additional terms or conditions. Notwithstanding the above, nothing herein
|
||||
shall supersede or modify the terms of any separate license agreement you
|
||||
may have executed with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade names,
|
||||
trademarks, service marks, or product names of the Licensor, except as required
|
||||
for reasonable and customary use in describing the origin of the Work and
|
||||
reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to
|
||||
in writing, Licensor provides the Work (and each Contributor provides its
|
||||
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied, including, without limitation, any warranties
|
||||
or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness
|
||||
of using or redistributing the Work and assume any risks associated with Your
|
||||
exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether
|
||||
in tort (including negligence), contract, or otherwise, unless required by
|
||||
applicable law (such as deliberate and grossly negligent acts) or agreed to
|
||||
in writing, shall any Contributor be liable to You for damages, including
|
||||
any direct, indirect, special, incidental, or consequential damages of any
|
||||
character arising as a result of this License or out of the use or inability
|
||||
to use the Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all other commercial
|
||||
damages or losses), even if such Contributor has been advised of the possibility
|
||||
of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work
|
||||
or Derivative Works thereof, You may choose to offer, and charge a fee for,
|
||||
acceptance of support, warranty, indemnity, or other liability obligations
|
||||
and/or rights consistent with this License. However, in accepting such obligations,
|
||||
You may act only on Your own behalf and on Your sole responsibility, not on
|
||||
behalf of any other Contributor, and only if You agree to indemnify, defend,
|
||||
and hold each Contributor harmless for any liability incurred by, or claims
|
||||
asserted against, such Contributor by reason of your accepting any such warranty
|
||||
or additional liability. END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following boilerplate
|
||||
notice, with the fields enclosed by brackets "[]" replaced with your own identifying
|
||||
information. (Don't include the brackets!) The text should be enclosed in
|
||||
the appropriate comment syntax for the file format. We also recommend that
|
||||
a file or class name and description of purpose be included on the same "printed
|
||||
page" as the copyright notice for easier identification within third-party
|
||||
archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
you may not use this file except in compliance with the License.
|
||||
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
See the License for the specific language governing permissions and
|
||||
|
||||
limitations under the License.
|
||||
@ -1,19 +0,0 @@
|
||||
#### 从命令行创建一个新的仓库
|
||||
|
||||
```bash
|
||||
touch README.md
|
||||
git init
|
||||
git add README.md
|
||||
git commit -m "first commit"
|
||||
git remote add origin https://bdgit.educoder.net/pa4hzw8mg/MySmartHome.git
|
||||
git push -u origin master
|
||||
|
||||
```
|
||||
|
||||
#### 从命令行推送已经创建的仓库
|
||||
|
||||
```bash
|
||||
git remote add origin https://bdgit.educoder.net/pa4hzw8mg/MySmartHome.git
|
||||
git push -u origin master
|
||||
|
||||
```
|
||||
Binary file not shown.
@ -0,0 +1,21 @@
|
||||
air.humidity should increase->humidifier.hon
|
||||
allow sweeping the floor->vacuum.von
|
||||
allow monitoring the room->camera.con
|
||||
forbid monitoring the room->camera.coff
|
||||
s:TemperatureSensor->air.temperature
|
||||
s:HumiditySensor->air.humidity
|
||||
s:LightSensor->light.brightness
|
||||
s:CO2Sensor->co2.ppm
|
||||
s:InfraredSensor->person.number
|
||||
s:InfraredSensor->person.distancefrommc
|
||||
s:InfraredSensor->person.distancefrompro
|
||||
s:RainSensor->weather.raining
|
||||
r:ac.coldon->power=700//cooler=1
|
||||
r:ac.hoton->power=1500//heater=1
|
||||
r:mc.mon->power=20
|
||||
r:projector.pon->power=350
|
||||
r:light.lon->power=5
|
||||
r:af.afon->power=500
|
||||
r:ah.ahon->power=500
|
||||
r:fan.fon->power=15//cooler=1
|
||||
r:heater.hon->power=2000//heater=1
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,58 @@
|
||||
客厅->living_room
|
||||
玄关->entryway
|
||||
屋内->home
|
||||
温度->temperature
|
||||
湿度->humidity
|
||||
亮度->brightness
|
||||
二氧化碳浓度->co2ppm
|
||||
关灯->Bulb.turn_bulb_off
|
||||
开灯->Bulb.turn_bulb_on
|
||||
开冷空调->AirConditioner.turn_ac_cool
|
||||
开热空调->AirConditioner.turn_ac_heat
|
||||
关空调->AirConditioner.turn_ac_off
|
||||
开门->Door.open_door
|
||||
关门->Door.close_door
|
||||
开窗->Window.open_window
|
||||
关窗->Window.close_window
|
||||
开窗帘->Blind.open_blind
|
||||
关窗帘->Blind.close_blind
|
||||
关闭空气净化器->AirPurifier.turn_ap_off
|
||||
打开空气净化器->AirPurifier.turn_ap_on
|
||||
关闭加湿器->Humidifier.turn_hum_off
|
||||
打开加湿器->Humidifier.turn_hum_on
|
||||
关闭干燥器->Dehumidifier_0.turn_dehum_off
|
||||
打开干燥器->Dehumidifier_0.turn_dehum_on
|
||||
关电扇->Fan.turn_fan_off
|
||||
开电扇->Fan.turn_fan_on
|
||||
启动扫地机器人->Robot.start_robot
|
||||
停止扫地机器人->Robot.dock_robot
|
||||
允许监视室内->Camera.turn_camera_on
|
||||
禁止监视室内->Camera.turn_camera_off
|
||||
二氧化碳浓度需要降低->co2.ppm-
|
||||
天黑->brightness<50
|
||||
有人->NOT_Person.Out
|
||||
没人->Person.Out
|
||||
下雨->Rain.isRain
|
||||
灯打开->Bulb.bon
|
||||
灯关闭->Bulb.boff
|
||||
门打开->Door.dopen
|
||||
门关闭->Door.dclosed
|
||||
窗打开->Window.wopen
|
||||
窗关闭->Window.wclosed
|
||||
窗帘打开->Blind.bopen
|
||||
窗帘关闭->Blind.bclosed
|
||||
空调制冷->AirConditioner.cool
|
||||
空调制热->AirConditioner.heat
|
||||
空调关闭->AirConditioner.acoff
|
||||
空气净化器关闭->AirPurifier.apoff
|
||||
空气净化器打开->AirPurifier.apon
|
||||
加湿器关闭->Humidifier.hoff
|
||||
加湿器打开->Humidifier.hon
|
||||
干燥器关闭->Dehumidifier.dhoff
|
||||
干燥器打开->Dehumidifier.dhon
|
||||
电扇关闭->Fan.foff
|
||||
电扇打开->Fan.fon
|
||||
扫地机器人启动->Robot.roff
|
||||
扫地机器人停止->Robot.ron
|
||||
摄像头关闭->Camera.coff
|
||||
摄像头打开->Camera.con
|
||||
@ -0,0 +1,20 @@
|
||||
#d:domain->event->state->service->type->effect
|
||||
#s:binary->device_class->monitored entity->true type->false type
|
||||
#s:numeric->device_class->monitored entity
|
||||
d:light->lturnon->lon->turn_on->turned_on->light.brightness+
|
||||
d:light->lturnoff->loff->turn_off->turned_off->light.brightness-
|
||||
d:fan.fan->fturnon->fon->turn_on->turned_on->air.temperature-
|
||||
d:fan.fan->fturnoff->foff->turn_off->turned_off->air.temperature+
|
||||
d:fan.humidifier->hturnon->hon->turn_on->turned_on->air.humidity+
|
||||
d:fan.humidifier->hturnoff->hoff->turn_off->turned_off->air.humidity-
|
||||
d:fan.purifier->pturnon->pon->turn_on->turned_on->CO2.ppm-
|
||||
d:fan.purifier->pturnoff->poff->turn_off->turned_off->CO2.ppm+
|
||||
d:vacuum->vturnon->von->start->null->null
|
||||
d:vacuum->vturnoff->voff->stop->null->null
|
||||
d:camera->cturnon->con->turn_on->turned_on->null
|
||||
d:camera->cturnoff->coff->turn_off->turned_off->null
|
||||
s:binary->opening->door.open->opened->not_opened
|
||||
s:binary->motion->person.in->motion->no_motion
|
||||
s:numeric->temperature->air.temperature
|
||||
s:numeric->illuminance->light.brightness
|
||||
s:numeric->humidity->air.humidity
|
||||
@ -0,0 +1,57 @@
|
||||
import sys
|
||||
import json
|
||||
|
||||
# 保证兼容python2以及python3
|
||||
IS_PY3 = sys.version_info.major == 3
|
||||
if IS_PY3:
|
||||
from urllib.request import urlopen
|
||||
from urllib.request import Request
|
||||
from urllib.error import URLError
|
||||
from urllib.parse import urlencode
|
||||
from urllib.parse import quote_plus
|
||||
else:
|
||||
import urllib2
|
||||
from urllib import quote_plus
|
||||
from urllib2 import urlopen
|
||||
from urllib2 import Request
|
||||
from urllib2 import URLError
|
||||
from urllib import urlencode
|
||||
|
||||
|
||||
|
||||
# 替换你的 API_KEY
|
||||
|
||||
API_KEY = 'uhKo4AmwYbRmgmR4So7jAQsV'
|
||||
|
||||
# 替换你的 SECRET_KEY
|
||||
SECRET_KEY = 'oA56u220ScasGhy2dQ3UBSksNq4Oc2W0'
|
||||
|
||||
TOKEN_URL = 'http://openapi.baidu.com/oauth/2.0/token'
|
||||
|
||||
def fetch_token():
|
||||
params = {'grant_type': 'client_credentials',
|
||||
'client_id': API_KEY,
|
||||
'client_secret': SECRET_KEY}
|
||||
post_data = urlencode(params)
|
||||
if (IS_PY3):
|
||||
post_data = post_data.encode('utf-8')
|
||||
req = Request(TOKEN_URL, post_data)
|
||||
try:
|
||||
f = urlopen(req, timeout=5)
|
||||
result_str = f.read()
|
||||
except URLError as err:
|
||||
print('token http response http code : ' + str(err.code))
|
||||
result_str = err.read()
|
||||
if (IS_PY3):
|
||||
result_str = result_str.decode()
|
||||
|
||||
result = json.loads(result_str)
|
||||
|
||||
if ('access_token' in result.keys() and 'scope' in result.keys()):
|
||||
if not 'audio_tts_post' in result['scope'].split(' '):
|
||||
print ('please ensure has check the tts ability')
|
||||
return ''
|
||||
return result['access_token']
|
||||
else:
|
||||
print ('please overwrite the correct API_KEY and SECRET_KEY')
|
||||
return ''
|
||||
@ -0,0 +1,3 @@
|
||||
living room->living room
|
||||
entryway->entryway
|
||||
home->entryway,living room
|
||||
@ -0,0 +1,40 @@
|
||||
IF temperature<=15 THEN AirConditioner_0.turn_ac_heat
|
||||
IF temperature>=28 THEN AirConditioner_0.turn_ac_cool,Heater_0.turn_heat_off
|
||||
IF Person.Location1 AND temperature>25 THEN AirConditioner_0.turn_ac_cool
|
||||
IF Person.Location1 AND temperature<25 THEN AirConditioner_0.turn_ac_heat
|
||||
IF humidity<20 THEN Humidifier_0.turn_hum_on,Dehumidifier_0.turn_dehum_off
|
||||
IF Person.Location1 THEN Bulb_0.turn_bulb_on,Bulb_1.turn_bulb_on
|
||||
IF Person.Location1 THEN Window_1.open_window,Window_2.open_window
|
||||
IF Person.Location1 THEN TV_0.turn_tv_on
|
||||
IF TV_0.tvon THEN Bulb_0.turn_bulb_on,Bulb_1.turn_bulb_on
|
||||
IF Person.Location2 THEN Bulb_2.turn_bulb_on,Bulb_3.turn_bulb_on,Window_3.open_window
|
||||
IF Person.Location4 THEN Bulb_6.turn_bulb_on,Bulb_7.turn_bulb_on,Window_0.open_window
|
||||
IF Person.Location3 THEN Bulb_4.turn_bulb_on,Bulb_5.turn_bulb_on
|
||||
IF Person.Location5 THEN Bulb_8.turn_bulb_on,Window_4.open_window
|
||||
IF Person.Out THEN Bulb_0.turn_bulb_off,Bulb_1.turn_bulb_off,Bulb_2.turn_bulb_off,Bulb_3.turn_bulb_off,Bulb_4.turn_bulb_off,Bulb_5.turn_bulb_off
|
||||
IF Person.Out THEN Window_0.close_window,Window_1.close_window,Window_2.close_window,Window_3.close_window,Window_4.close_window
|
||||
IF Person.Out THEN AirConditioner_0.turn_ac_off,Humidifier_0.turn_hum_off,Fan_0.turn_fan_off,TV_0.turn_tv_off
|
||||
IF Rain.isRain THEN Window_0.close_window,Window_1.close_window,Window_2.close_window,Window_3.close_window
|
||||
IF AirConditioner_0.cool THEN Window_0.close_window,Window_1.close_window,Window_2.close_window,Window_3.close_window,Window_4.close_window
|
||||
IF AirConditioner_0.heat THEN Window_0.close_window,Window_1.close_window,Window_2.close_window,Window_3.close_window,Window_4.close_window
|
||||
IF Wind.Gale THEN Window_3.close_window
|
||||
IF Person.Out THEN Robot_0.dock_robot
|
||||
IF NOT_Person.Out THEN Robot_0.start_robot
|
||||
IF humidity>50 THEN Humidifier_0.turn_hum_off
|
||||
IF Fire.OnFire THEN Alarm_0.turn_alarm_on
|
||||
IF Fire.NoFire THEN Alarm_0.turn_alarm_off
|
||||
IF co2ppm>800 THEN AirPurifier_0.turn_ap_on
|
||||
IF pm_2_5>75 THEN AirPurifier_0.turn_ap_on
|
||||
IF aqi>=150 THEN Window_0.close_window,Window_1.close_window,Window_2.close_window,Window_3.close_window
|
||||
IF co2ppm<400 AND pm_2_5<20 THEN AirPurifier_0.turn_ap_off
|
||||
IF NOT_Person.Location1 THEN Bulb_0.turn_bulb_off,Bulb_1.turn_bulb_off,Window_1.close_window,Window_2.close_window
|
||||
IF NOT_Person.Location1 THEN TV_0.turn_tv_off
|
||||
IF NOT_Person.Location2 THEN Bulb_2.turn_bulb_off,Bulb_3.turn_bulb_off
|
||||
IF NOT_Person.Location4 THEN Bulb_6.turn_bulb_off,Bulb_7.turn_bulb_off,Window_0.close_window
|
||||
IF NOT_Person.Location3 THEN Bulb_4.turn_bulb_off,Bulb_5.turn_bulb_off
|
||||
IF NOT_Person.Location5 THEN Bulb_8.turn_bulb_off
|
||||
IF NOT_Person.Out THEN Blind_0.open_blind,Blind_1.open_blind
|
||||
IF temperature<10 THEN Heater_0.turn_heat_on
|
||||
IF humidity>75 THEN Dehumidifier_0.turn_dehum_on,Humidifier_0.turn_hum_off
|
||||
IF Door_0.dopen THEN Camera_0.turn_camera_on
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
location={living_room,entryway}
|
||||
device1={deviceName:Bulb_0,deviceType:Bulb,location:living_room}
|
||||
device2={deviceName:Bulb_1,deviceType:Bulb,location:entryway}
|
||||
device3={deviceName:Window_0,deviceType:Window,location:living_room}
|
||||
device4={deviceName:Window_1,deviceType:Window,location:entryway}
|
||||
device5={deviceName:AirConditioner_0,deviceType:AirConditioner,location:living_room}
|
||||
device6={deviceName:Blind_0,deviceType:Blind,location:living_room}
|
||||
device7={deviceName:Blind_1,deviceType:Blind,location:entryway}
|
||||
device8={deviceName:TV_0,deviceType:TV,location:living_room}
|
||||
device9={deviceName:Door_0,deviceType:Door,location:entryway}
|
||||
device10={deviceName:Dehumidifier_0,deviceType:Dehumidifier,location:living_room}
|
||||
device11={deviceName:Fan_0,deviceType:Fan,location:living_room}
|
||||
device12={deviceName:Humidifier_0,deviceType:Humidifier,location:living_room}
|
||||
device13={deviceName:Camera_0,deviceType:Camera,location:entryway}
|
||||
device14={deviceName:Robot_0,deviceType:Robot,location:living_room}
|
||||
device15={deviceName:AirPurifier_0,deviceType:AirPurifier,location:living_room}
|
||||
@ -0,0 +1,229 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ontology>
|
||||
<environment>
|
||||
<attribute name="person.number"/>
|
||||
<attribute name="air.temperature"/>
|
||||
<attribute name="air.humidity"/>
|
||||
<attribute name="air.smoke"/>
|
||||
<attribute name="light.brightness"/>
|
||||
<attribute name="sound.loudness"/>
|
||||
<attribute name="sound.ultrasonic"/>
|
||||
<attribute name="co2.ppm"/>
|
||||
</environment>
|
||||
<devices>
|
||||
<device name="bulb">
|
||||
<states>
|
||||
<state name="bon" init="false">
|
||||
<adjust_entity name="light.brightness" energy="5" rate="50000" method="prompt"/>
|
||||
</state>
|
||||
</states>
|
||||
</device>
|
||||
<device name="heater">
|
||||
<states>
|
||||
<state name="hon" init="false">
|
||||
<adjust_entity name="air.temperature" energy="2000" rate="0.4" method="/second"/>
|
||||
</state>
|
||||
</states>
|
||||
</device>
|
||||
<device name="ac">
|
||||
<states>
|
||||
<state name="coldon" init="false">
|
||||
<adjust_entity name="air.temperature" energy="700" rate="-0.2" method="/second"/>
|
||||
</state>
|
||||
<state name="hoton" init="false">
|
||||
<adjust_entity name="air.temperature" energy="1500" rate="0.2" method="/second"/>
|
||||
</state>
|
||||
</states>
|
||||
</device>
|
||||
<device name="fan">
|
||||
<states>
|
||||
<state name="fon" init="false">
|
||||
<adjust_entity name="air.temperature" energy="30" rate="-0.05" method="/second"/>
|
||||
</state>
|
||||
</states>
|
||||
</device>
|
||||
<device name="af">
|
||||
<states>
|
||||
<state name="afon" init="false">
|
||||
<adjust_entity name="co2.ppm" energy="500" rate="-10" method="/second"/>
|
||||
</state>
|
||||
</states>
|
||||
</device>
|
||||
<device name="ah">
|
||||
<states>
|
||||
<state name="ahon" init="false">
|
||||
<adjust_entity name="air.humidity" energy="500" rate="0.2" method="/second"/>
|
||||
</state>
|
||||
</states>
|
||||
</device>
|
||||
</devices>
|
||||
<statemachines>
|
||||
<device name="bulb">
|
||||
<events>
|
||||
<event>bturnon</event>
|
||||
<event>bturnoff</event>
|
||||
</events>
|
||||
<states>
|
||||
<state init="false">bon</state>
|
||||
<state init="true">boff</state>
|
||||
</states>
|
||||
<transitions>
|
||||
<transition from="bon" event="bturnoff" action="boffpulse" to="boff"/>
|
||||
<transition from="boff" event="bturnoff" action="boffpulse" to="boff"/>
|
||||
<transition from="bon" event="bturnon" action="bonpulse" to="bon"/>
|
||||
<transition from="boff" event="bturnon" action="bonpulse" to="bon"/>
|
||||
</transitions>
|
||||
</device>
|
||||
<device name="blind">
|
||||
<events>
|
||||
<event>bopen</event>
|
||||
<event>bclose</event>
|
||||
</events>
|
||||
<states>
|
||||
<state init="false">bopen</state>
|
||||
<state init="true">bclosed</state>
|
||||
</states>
|
||||
<transitions>
|
||||
<transition from="bopen" event="bclose" action="bclosepulse" to="bclosed"/>
|
||||
<transition from="bclosed" event="bclose" action="bclosepulse" to="bclosed"/>
|
||||
<transition from="bopen" event="bopen" action="bopenpulse" to="bopen"/>
|
||||
<transition from="bclosed" event="bopen" action="bopenpulse" to="bopen"/>
|
||||
</transitions>
|
||||
</device>
|
||||
<device name="projector">
|
||||
<events>
|
||||
<event>pturnon</event>
|
||||
<event>pturnoff</event>
|
||||
</events>
|
||||
<states>
|
||||
<state init="false">pon</state>
|
||||
<state init="true">poff</state>
|
||||
</states>
|
||||
<transitions>
|
||||
<transition from="pon" event="pturnoff" action="poffpulse" to="poff"/>
|
||||
<transition from="poff" event="pturnoff" action="poffpulse" to="poff"/>
|
||||
<transition from="pon" event="pturnon" action="ponpulse" to="pon"/>
|
||||
<transition from="poff" event="pturnon" action="ponpulse" to="pon"/>
|
||||
</transitions>
|
||||
</device>
|
||||
<device name="mc">
|
||||
<events>
|
||||
<event>mturnon</event>
|
||||
<event>mturnoff</event>
|
||||
</events>
|
||||
<states>
|
||||
<state init="false">mon</state>
|
||||
<state init="true">moff</state>
|
||||
</states>
|
||||
<transitions>
|
||||
<transition from="mon" event="mturnoff" action="moffpulse" to="moff"/>
|
||||
<transition from="moff" event="mturnoff" action="moffpulse" to="moff"/>
|
||||
<transition from="mon" event="mturnon" action="monpulse" to="mon"/>
|
||||
<transition from="moff" event="mturnon" action="monpulse" to="mon"/>
|
||||
</transitions>
|
||||
</device>
|
||||
<device name="window">
|
||||
<events>
|
||||
<event>wopen</event>
|
||||
<event>wclose</event>
|
||||
</events>
|
||||
<states>
|
||||
<state init="false">wopen</state>
|
||||
<state init="true">wclosed</state>
|
||||
</states>
|
||||
<transitions>
|
||||
<transition from="wopen" event="wclose" action="wclosepulse" to="wclosed"/>
|
||||
<transition from="wclosed" event="wclose" action="wclosepulse" to="wclosed"/>
|
||||
<transition from="wopen" event="wopen" action="wopenpulse" to="wopen"/>
|
||||
<transition from="wclosed" event="wopen" action="wopenpulse" to="wopen"/>
|
||||
</transitions>
|
||||
</device>
|
||||
<device name="ac">
|
||||
<events>
|
||||
<event>turnoncold</event>
|
||||
<event>turnonhot</event>
|
||||
<event>aturnoff</event>
|
||||
</events>
|
||||
<states>
|
||||
<state init="false">coldon</state>
|
||||
<state init="false">hoton</state>
|
||||
<state init="true">aoff</state>
|
||||
</states>
|
||||
<transitions>
|
||||
<transition from="aoff" event="aturnoff" action="aoffpulse" to="aoff"/>
|
||||
<transition from="aoff" event="turnoncold" action="coldpulse" to="coldon"/>
|
||||
<transition from="aoff" event="turnonhot" action="hotpulse" to="hoton"/>
|
||||
<transition from="coldon" event="aturnoff" action="aoffpulse" to="aoff"/>
|
||||
<transition from="coldon" event="turnoncold" action="coldpulse" to="coldon"/>
|
||||
<transition from="coldon" event="turnonhot" action="hotpulse" to="hoton"/>
|
||||
<transition from="hoton" event="aturnoff" action="aoffpulse" to="aoff"/>
|
||||
<transition from="hoton" event="turnoncold" action="coldpulse" to="coldon"/>
|
||||
<transition from="hoton" event="turnonhot" action="hotpulse" to="hoton"/>
|
||||
</transitions>
|
||||
</device>
|
||||
<device name="af">
|
||||
<events>
|
||||
<event>afturnon</event>
|
||||
<event>afturnoff</event>
|
||||
</events>
|
||||
<states>
|
||||
<state init="false">afon</state>
|
||||
<state init="true">afoff</state>
|
||||
</states>
|
||||
<transitions>
|
||||
<transition from="afon" event="afturnoff" action="afoffpulse" to="afoff"/>
|
||||
<transition from="afoff" event="afturnoff" action="afoffpulse" to="afoff"/>
|
||||
<transition from="afon" event="afturnon" action="afonpulse" to="afon"/>
|
||||
<transition from="afoff" event="afturnon" action="afonpulse" to="afon"/>
|
||||
</transitions>
|
||||
</device>
|
||||
<device name="ah">
|
||||
<events>
|
||||
<event>ahturnon</event>
|
||||
<event>ahturnoff</event>
|
||||
</events>
|
||||
<states>
|
||||
<state init="false">ahon</state>
|
||||
<state init="true">ahoff</state>
|
||||
</states>
|
||||
<transitions>
|
||||
<transition from="ahon" event="ahturnoff" action="ahoffpulse" to="ahoff"/>
|
||||
<transition from="ahoff" event="ahturnoff" action="ahoffpulse" to="ahoff"/>
|
||||
<transition from="ahon" event="ahturnon" action="ahonpulse" to="ahon"/>
|
||||
<transition from="ahoff" event="ahturnon" action="ahonpulse" to="ahon"/>
|
||||
</transitions>
|
||||
</device>
|
||||
<device name="fan">
|
||||
<events>
|
||||
<event>fturnon</event>
|
||||
<event>fturnoff</event>
|
||||
</events>
|
||||
<states>
|
||||
<state init="false">fon</state>
|
||||
<state init="true">foff</state>
|
||||
</states>
|
||||
<transitions>
|
||||
<transition from="fon" event="fturnoff" action="foffpulse" to="foff"/>
|
||||
<transition from="foff" event="fturnoff" action="foffpulse" to="foff"/>
|
||||
<transition from="fon" event="fturnon" action="fonpulse" to="fon"/>
|
||||
<transition from="foff" event="fturnon" action="fonpulse" to="fon"/>
|
||||
</transitions>
|
||||
</device>
|
||||
<device name="heater">
|
||||
<events>
|
||||
<event>hturnon</event>
|
||||
<event>hturnoff</event>
|
||||
</events>
|
||||
<states>
|
||||
<state init="false">hon</state>
|
||||
<state init="true">hoff</state>
|
||||
</states>
|
||||
<transitions>
|
||||
<transition from="hon" event="hturnoff" action="hoffpulse" to="hoff"/>
|
||||
<transition from="hoff" event="hturnoff" action="hoffpulse" to="hoff"/>
|
||||
<transition from="hon" event="hturnon" action="honpulse" to="hon"/>
|
||||
<transition from="hoff" event="hturnon" action="honpulse" to="hon"/>
|
||||
</transitions>
|
||||
</device>
|
||||
</statemachines>
|
||||
</ontology>
|
||||
@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ontology>
|
||||
<environment>
|
||||
<attribute name="person.number"/>
|
||||
<attribute name="air.temperature" fluctuation="3"/>
|
||||
<attribute name="air.humidity" fluctuation="10"/>
|
||||
<attribute name="co2.ppm" fluctuation="30"/>
|
||||
<attribute name="light.brightness" fluctuation="50"/>
|
||||
<attribute name="person.in"/>
|
||||
</environment>
|
||||
<devices>
|
||||
<device name="light">
|
||||
<states>
|
||||
<state name="lon" init="false">
|
||||
<adjust_entity name="light.brightness" energy="5" rate="200" method="prompt"/>
|
||||
</state>
|
||||
</states>
|
||||
</device>
|
||||
<device name="fan">
|
||||
<states>
|
||||
<state name="fon" init="false">
|
||||
<adjust_entity name="air.temperature" energy="30" rate="-0.05" method="/second"/>
|
||||
</state>
|
||||
</states>
|
||||
</device>
|
||||
<device name="humidifier">
|
||||
<states>
|
||||
<state name="hon" init="false">
|
||||
<adjust_entity name="air.humidity" energy="30" rate="+1" method="/second"/>
|
||||
</state>
|
||||
</states>
|
||||
</device>
|
||||
<device name="purifier">
|
||||
<states>
|
||||
<state name="pon" init="false">
|
||||
<adjust_entity name="co2.ppm" energy="30" rate="-3" method="/second"/>
|
||||
</state>
|
||||
</states>
|
||||
</device>
|
||||
</devices>
|
||||
<statemachines>
|
||||
<device name="light">
|
||||
<events>
|
||||
<event>lturnon</event>
|
||||
<event>lturnoff</event>
|
||||
</events>
|
||||
<states>
|
||||
<state init="false">lon</state>
|
||||
<state init="true">loff</state>
|
||||
</states>
|
||||
<transitions>
|
||||
<transition from="lon" event="lturnoff" action="loffpulse" to="loff"/>
|
||||
<transition from="loff" event="lturnoff" action="loffpulse" to="loff"/>
|
||||
<transition from="lon" event="lturnon" action="lonpulse" to="lon"/>
|
||||
<transition from="loff" event="lturnon" action="lonpulse" to="lon"/>
|
||||
</transitions>
|
||||
</device>
|
||||
<device name="fan">
|
||||
<events>
|
||||
<event>fturnon</event>
|
||||
<event>fturnoff</event>
|
||||
</events>
|
||||
<states>
|
||||
<state init="false">fon</state>
|
||||
<state init="true">foff</state>
|
||||
</states>
|
||||
<transitions>
|
||||
<transition from="fon" event="fturnoff" action="foffpulse" to="foff"/>
|
||||
<transition from="foff" event="fturnoff" action="foffpulse" to="foff"/>
|
||||
<transition from="fon" event="fturnon" action="fonpulse" to="fon"/>
|
||||
<transition from="foff" event="fturnon" action="fonpulse" to="fon"/>
|
||||
</transitions>
|
||||
</device>
|
||||
<device name="purifier">
|
||||
<events>
|
||||
<event>pturnon</event>
|
||||
<event>pturnoff</event>
|
||||
</events>
|
||||
<states>
|
||||
<state init="false">pon</state>
|
||||
<state init="true">poff</state>
|
||||
</states>
|
||||
<transitions>
|
||||
<transition from="pon" event="pturnoff" action="poffpulse" to="poff"/>
|
||||
<transition from="poff" event="pturnoff" action="poffpulse" to="poff"/>
|
||||
<transition from="pon" event="pturnon" action="ponpulse" to="pon"/>
|
||||
<transition from="poff" event="pturnon" action="ponpulse" to="pon"/>
|
||||
</transitions>
|
||||
</device>
|
||||
<device name="humidifier">
|
||||
<events>
|
||||
<event>hturnon</event>
|
||||
<event>hturnoff</event>
|
||||
</events>
|
||||
<states>
|
||||
<state init="false">hon</state>
|
||||
<state init="true">hoff</state>
|
||||
</states>
|
||||
<transitions>
|
||||
<transition from="hon" event="hturnoff" action="hoffpulse" to="hoff"/>
|
||||
<transition from="hoff" event="hturnoff" action="hoffpulse" to="hoff"/>
|
||||
<transition from="hon" event="hturnon" action="honpulse" to="hon"/>
|
||||
<transition from="hoff" event="hturnon" action="honpulse" to="hon"/>
|
||||
</transitions>
|
||||
</device>
|
||||
</statemachines>
|
||||
</ontology>
|
||||
@ -0,0 +1,11 @@
|
||||
fan.humidifier->null->fan.xiaomi_air_humidifier->office
|
||||
vacuum->null->vacuum.xiaomi_vacuum_1c->office
|
||||
fan.purifier->null->fan.xiaomi_air_purifier_2s->office
|
||||
light->2aa2d30f3b24d1a598d18d7a566a1de4->light.aqara_hub_m1s_4729->nonono
|
||||
temperature->0e1726f9704dc3cfbf7c038f477d6be0->sensor.temperature_sensor_c5e1_temperature->office
|
||||
opening->d894c20c03ba7e40263b8889e7e24b07->binary_sensor.window_and_door_sensor_2825->office
|
||||
motion->3572f4248b12b2470d199d027a23d1b4->binary_sensor.motion_sensor_6dc9->office
|
||||
light->0e9aaa2b980c2309c87d3f4720b1bcf4->light.midesklamppro_7a9b->office
|
||||
illuminance->223eedf22b004368e7b9950dc7710c1e->sensor.light_sensor_2773_light_level->office
|
||||
fan.fan->null->fan.xiaomi_smart_fan->office
|
||||
humidity->0e1726f9704dc3cfbf7c038f477d6be0->sensor.temperature_sensor_c5e1_humidity->office
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,72 @@
|
||||
diff -Naur avs-sensory/pi.sh avs-kitt/pi.sh
|
||||
--- pi.sh 2019-05-03 18:09:18.063849909 -0700
|
||||
+++ pi.sh 2019-05-03 18:09:39.273744305 -0700
|
||||
@@ -20,18 +20,19 @@
|
||||
|
||||
SOUND_CONFIG="$HOME/.asoundrc"
|
||||
START_SCRIPT="$INSTALL_BASE/startsample.sh"
|
||||
-CMAKE_PLATFORM_SPECIFIC=(-DSENSORY_KEY_WORD_DETECTOR=ON \
|
||||
+CMAKE_PLATFORM_SPECIFIC=(-DKITTAI_KEY_WORD_DETECTOR=ON \
|
||||
-DGSTREAMER_MEDIA_PLAYER=ON -DPORTAUDIO=ON \
|
||||
-DPORTAUDIO_LIB_PATH="$THIRD_PARTY_PATH/portaudio/lib/.libs/libportaudio.$LIB_SUFFIX" \
|
||||
-DPORTAUDIO_INCLUDE_DIR="$THIRD_PARTY_PATH/portaudio/include" \
|
||||
- -DSENSORY_KEY_WORD_DETECTOR_LIB_PATH=$THIRD_PARTY_PATH/alexa-rpi/lib/libsnsr.a \
|
||||
- -DSENSORY_KEY_WORD_DETECTOR_INCLUDE_DIR=$THIRD_PARTY_PATH/alexa-rpi/include)
|
||||
+ -DKITTAI_KEY_WORD_DETECTOR_LIB_PATH=$THIRD_PARTY_PATH/snowboy/lib/rpi/libsnowboy-detect.a \
|
||||
+ -DKITTAI_KEY_WORD_DETECTOR_INCLUDE_DIR=$THIRD_PARTY_PATH/snowboy/include \
|
||||
+ -DCMAKE_BUILD_TYPE=MINSIZEREL)
|
||||
|
||||
GSTREAMER_AUDIO_SINK="alsasink"
|
||||
|
||||
install_dependencies() {
|
||||
sudo apt-get update
|
||||
- sudo apt-get -y install git gcc cmake build-essential libsqlite3-dev libcurl4-openssl-dev libssl-dev libfaad-dev libsoup2.4-dev libgcrypt20-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-good libasound2-dev sox gedit vim python3-pip
|
||||
+ sudo apt-get -y install git gcc cmake build-essential libsqlite3-dev libcurl4-openssl-dev libssl-dev libfaad-dev libsoup2.4-dev libgcrypt20-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-good libasound2-dev sox gedit vim python3-pip python-pip libatlas-base-dev
|
||||
pip install flask commentjson
|
||||
}
|
||||
|
||||
@@ -64,18 +65,18 @@
|
||||
build_kwd_engine() {
|
||||
- #get sensory and build
|
||||
+ #get kittai and build
|
||||
echo
|
||||
- echo "==============> CLONING AND BUILDING SENSORY =============="
|
||||
+ echo "==============> CLONING AND BUILDING KITTAI =============="
|
||||
echo
|
||||
|
||||
cd $THIRD_PARTY_PATH
|
||||
- git clone git://github.com/Sensory/alexa-rpi.git
|
||||
- bash ./alexa-rpi/bin/license.sh
|
||||
+ git clone https://github.com/Kitt-AI/snowboy.git
|
||||
+ cp snowboy/resources/alexa/alexa-avs-sample-app/alexa.umdl snowboy/resources/alexa.umdl
|
||||
}
|
||||
|
||||
generate_start_script() {
|
||||
cat << EOF > "$START_SCRIPT"
|
||||
cd "$BUILD_PATH/SampleApp/src"
|
||||
|
||||
- ./SampleApp "$OUTPUT_CONFIG_FILE" "$THIRD_PARTY_PATH/alexa-rpi/models" DEBUG9
|
||||
+ ./SampleApp "$OUTPUT_CONFIG_FILE" "$THIRD_PARTY_PATH/snowboy/resources" DEBUG9
|
||||
EOF
|
||||
}
|
||||
diff -Naur avs-sensory/setup.sh avs-kitt/setup.sh
|
||||
--- setup.sh 2019-05-03 18:09:24.383818365 -0700
|
||||
+++ setup.sh 2019-05-03 18:09:35.193764563 -0700
|
||||
@@ -50,6 +50,8 @@
|
||||
LIB_SUFFIX="a"
|
||||
ANDROID_CONFIG_FILE=""
|
||||
|
||||
+BUILDTYPE="MINSIZEREL"
|
||||
+
|
||||
# Default device serial number if nothing is specified
|
||||
DEVICE_SERIAL_NUMBER="123456"
|
||||
|
||||
@@ -242,7 +244,7 @@
|
||||
cmake "$SOURCE_PATH/avs-device-sdk" \
|
||||
-DCMAKE_BUILD_TYPE=DEBUG \
|
||||
"${CMAKE_PLATFORM_SPECIFIC[@]}"
|
||||
-
|
||||
+ sed -E -i "s:CXX_PLATFORM_DEPENDENT_FLAGS_"$BUILDTYPE"\s+\"(.*)\":CXX_PLATFORM_DEPENDENT_FLAGS_"$BUILDTYPE" \"\1 -D_GLIBCXX_USE_CXX11_ABI=0 -pg\":" ../avs-device-sdk/build/cmake/BuildOptions.cmake
|
||||
cd $BUILD_PATH
|
||||
make SampleApp -j1
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,179 @@
|
||||
import math
|
||||
import pickle
|
||||
import re
|
||||
|
||||
import Levenshtein
|
||||
import cn2an
|
||||
import pypinyin
|
||||
|
||||
place_list = ['卧室一', '卧室二', '卧室', '厕所一', '厕所二', '厕所', '走廊', '餐厅', '客厅', '厨房', '书房', '阳台', '户外', '屋内']
|
||||
action_list = ['关灯', '开灯', '灯变亮', '灯变暗', '开热空调', '开冷空调', '空调升温', '空调降温', '关空调', '开电视', '发出警告', '开窗帘', '关窗帘', '开窗', '关窗',
|
||||
'开门', '关门', '开氛围灯', '关氛围灯', '亮一点', '暗一点', '热一点', '冷一点', '温度高一点', '温度低一点', '允许通风',
|
||||
'禁止通风', '开启回家模式', '开启离家模式', '开启观影模式']
|
||||
trigger_list = ['下雨', '不下雨', '天晴', '有人', '按门铃', '没人', '有人移动', '没人移动', '着火', '起风', '起烟', '天黑', '灯打开', '灯关闭', '门打开',
|
||||
'门关闭', '窗打开', '窗关闭', '窗帘打开', '窗帘关闭', '空调制冷', '空调制热', '空调关闭', '电视打开', '电视关闭']
|
||||
time_list = ['超过?小时', '超过?分钟', '超过?秒']
|
||||
|
||||
re_chn = re.compile("([\u4E00-\u9Fa5a-zA-Z0-9+#&]+)")
|
||||
|
||||
|
||||
def chn_to_arabic(text: str):
|
||||
chn_numbers = re.findall(r'.*超过(.+)(秒|分钟|小时)时', text)
|
||||
if len(chn_numbers) > 0:
|
||||
arabic_number = cn2an.transform(chn_numbers[0][0], 'cn2an')
|
||||
return text.replace('超过' + ''.join(chn_numbers[0]) + '时', '超过' + str(arabic_number) + chn_numbers[0][1] + '时')
|
||||
else:
|
||||
return text
|
||||
|
||||
|
||||
def text_extract(sent: str):
|
||||
text = ""
|
||||
blks = re_chn.split(sent)
|
||||
for blk in blks:
|
||||
if not blk:
|
||||
continue
|
||||
if re_chn.match(blk):
|
||||
text += blk
|
||||
return text
|
||||
|
||||
|
||||
def num_extract(text: str):
|
||||
return re.sub(r'[\d]+', '', text), re.findall(r'[\d]+', text)
|
||||
|
||||
|
||||
class Retrieval(object):
|
||||
def __init__(self):
|
||||
self.map_length_to_sent_and_pinyin = {}
|
||||
self.initialized = False
|
||||
|
||||
def _initialize(self):
|
||||
|
||||
for action in action_list:
|
||||
sent = action
|
||||
sent_pinyin = pypinyin.slug(sent, separator='')
|
||||
if len(sent_pinyin) in self.map_length_to_sent_and_pinyin:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)].append((sent_pinyin, sent))
|
||||
else:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)] = [(sent_pinyin, sent)]
|
||||
|
||||
for place in place_list:
|
||||
for action in action_list:
|
||||
sent = place + action
|
||||
sent_pinyin = pypinyin.slug(sent, separator='')
|
||||
if len(sent_pinyin) in self.map_length_to_sent_and_pinyin:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)].append((sent_pinyin, sent))
|
||||
else:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)] = [(sent_pinyin, sent)]
|
||||
for trigger in trigger_list:
|
||||
for action in action_list:
|
||||
sent = trigger + '时' + action
|
||||
sent_pinyin = pypinyin.slug(sent, separator='')
|
||||
if len(sent_pinyin) in self.map_length_to_sent_and_pinyin:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)].append((sent_pinyin, sent))
|
||||
else:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)] = [(sent_pinyin, sent)]
|
||||
for place in place_list:
|
||||
for action in action_list:
|
||||
sent = trigger + '时' + place + action
|
||||
sent_pinyin = pypinyin.slug(sent, separator='')
|
||||
if len(sent_pinyin) in self.map_length_to_sent_and_pinyin:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)].append((sent_pinyin, sent))
|
||||
else:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)] = [(sent_pinyin, sent)]
|
||||
for place_one in place_list:
|
||||
for trigger in trigger_list:
|
||||
for action in action_list:
|
||||
sent = place_one + trigger + '时' + action
|
||||
sent_pinyin = pypinyin.slug(sent, separator='')
|
||||
if len(sent_pinyin) in self.map_length_to_sent_and_pinyin:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)].append((sent_pinyin, sent))
|
||||
else:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)] = [(sent_pinyin, sent)]
|
||||
for place_two in place_list:
|
||||
for action in action_list:
|
||||
sent = place_one + trigger + '时' + place_two + action
|
||||
sent_pinyin = pypinyin.slug(sent, separator='')
|
||||
if len(sent_pinyin) in self.map_length_to_sent_and_pinyin:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)].append((sent_pinyin, sent))
|
||||
else:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)] = [(sent_pinyin, sent)]
|
||||
for trigger in trigger_list:
|
||||
for time in time_list:
|
||||
for action in action_list:
|
||||
sent = trigger + time + '时' + action
|
||||
sent_pinyin = pypinyin.slug(sent, separator='')
|
||||
if len(sent_pinyin) in self.map_length_to_sent_and_pinyin:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)].append((sent_pinyin, sent))
|
||||
else:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)] = [(sent_pinyin, sent)]
|
||||
for place in place_list:
|
||||
for action in action_list:
|
||||
sent = trigger + time + '时' + place + action
|
||||
sent_pinyin = pypinyin.slug(sent, separator='')
|
||||
if len(sent_pinyin) in self.map_length_to_sent_and_pinyin:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)].append((sent_pinyin, sent))
|
||||
else:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)] = [(sent_pinyin, sent)]
|
||||
for place_one in place_list:
|
||||
for trigger in trigger_list:
|
||||
for time in time_list:
|
||||
for action in action_list:
|
||||
sent = place_one + trigger + time + '时' + action
|
||||
sent_pinyin = pypinyin.slug(sent, separator='')
|
||||
if len(sent_pinyin) in self.map_length_to_sent_and_pinyin:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)].append((sent_pinyin, sent))
|
||||
else:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)] = [(sent_pinyin, sent)]
|
||||
for place_two in place_list:
|
||||
for action in action_list:
|
||||
sent = place_one + trigger + time + '时' + place_two + action
|
||||
sent_pinyin = pypinyin.slug(sent, separator='')
|
||||
if len(sent_pinyin) in self.map_length_to_sent_and_pinyin:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)].append((sent_pinyin, sent))
|
||||
else:
|
||||
self.map_length_to_sent_and_pinyin[len(sent_pinyin)] = [(sent_pinyin, sent)]
|
||||
self.initialized = True
|
||||
|
||||
def save_sent_data(self):
|
||||
self._initialize()
|
||||
with open('data/sent_data.pickle', 'wb+') as f:
|
||||
pickle.dump(self.map_length_to_sent_and_pinyin, f, pickle.DEFAULT_PROTOCOL)
|
||||
|
||||
def load_sent_data(self):
|
||||
with open('data/sent_data.pickle', 'rb') as f:
|
||||
self.map_length_to_sent_and_pinyin = pickle.load(f)
|
||||
self.initialized = True
|
||||
|
||||
def retrieve(self, sent):
|
||||
if not sent:
|
||||
return sent
|
||||
text = text_extract(sent)
|
||||
text = chn_to_arabic(text)
|
||||
text, nums = num_extract(text)
|
||||
number = ''
|
||||
if len(nums) > 0:
|
||||
number = nums[0]
|
||||
if not text:
|
||||
return text
|
||||
if not self.initialized:
|
||||
self.load_sent_data()
|
||||
sent_pinyin = pypinyin.slug(text, separator='')
|
||||
length = len(sent_pinyin)
|
||||
interval = 10
|
||||
top_sent = text
|
||||
min_distance = math.inf
|
||||
for cl in range(max(0, length - interval), length + interval):
|
||||
if cl in self.map_length_to_sent_and_pinyin:
|
||||
pair_list = self.map_length_to_sent_and_pinyin[cl]
|
||||
for pair in pair_list:
|
||||
distance = Levenshtein.distance(pair[0], sent_pinyin)
|
||||
if min_distance > distance:
|
||||
min_distance = distance
|
||||
top_sent = pair[1]
|
||||
res = top_sent.replace('超过?', '超过' + number)
|
||||
return res
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = Retrieval()
|
||||
r.save_sent_data()
|
||||
@ -0,0 +1,277 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import collections
|
||||
import pyaudio
|
||||
import snowboydetect
|
||||
import time
|
||||
import wave
|
||||
import os
|
||||
import logging
|
||||
from ctypes import *
|
||||
from contextlib import contextmanager
|
||||
|
||||
logging.basicConfig()
|
||||
logger = logging.getLogger("snowboy")
|
||||
logger.setLevel(logging.INFO)
|
||||
TOP_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
RESOURCE_FILE = os.path.join(TOP_DIR, "resources/common.res")
|
||||
DETECT_DING = os.path.join(TOP_DIR, "resources/ding.wav")
|
||||
DETECT_DONG = os.path.join(TOP_DIR, "resources/dong.wav")
|
||||
|
||||
def py_error_handler(filename, line, function, err, fmt):
|
||||
pass
|
||||
|
||||
ERROR_HANDLER_FUNC = CFUNCTYPE(None, c_char_p, c_int, c_char_p, c_int, c_char_p)
|
||||
|
||||
c_error_handler = ERROR_HANDLER_FUNC(py_error_handler)
|
||||
|
||||
@contextmanager
|
||||
def no_alsa_error():
|
||||
try:
|
||||
asound = cdll.LoadLibrary('libasound.so')
|
||||
asound.snd_lib_error_set_handler(c_error_handler)
|
||||
yield
|
||||
asound.snd_lib_error_set_handler(None)
|
||||
except:
|
||||
yield
|
||||
pass
|
||||
|
||||
class RingBuffer(object):
|
||||
"""Ring buffer to hold audio from PortAudio"""
|
||||
|
||||
def __init__(self, size=4096):
|
||||
self._buf = collections.deque(maxlen=size)
|
||||
|
||||
def extend(self, data):
|
||||
"""Adds data to the end of buffer"""
|
||||
self._buf.extend(data)
|
||||
|
||||
def get(self):
|
||||
"""Retrieves data from the beginning of buffer and clears it"""
|
||||
tmp = bytes(bytearray(self._buf))
|
||||
self._buf.clear()
|
||||
return tmp
|
||||
|
||||
|
||||
def play_audio_file(fname=DETECT_DING):
|
||||
"""Simple callback function to play a wave file. By default it plays
|
||||
a Ding sound.
|
||||
|
||||
:param str fname: wave file name
|
||||
:return: None
|
||||
"""
|
||||
ding_wav = wave.open(fname, 'rb')
|
||||
ding_data = ding_wav.readframes(ding_wav.getnframes())
|
||||
with no_alsa_error():
|
||||
audio = pyaudio.PyAudio()
|
||||
stream_out = audio.open(
|
||||
format=audio.get_format_from_width(ding_wav.getsampwidth()),
|
||||
channels=ding_wav.getnchannels(),
|
||||
rate=ding_wav.getframerate(), input=False, output=True)
|
||||
stream_out.start_stream()
|
||||
stream_out.write(ding_data)
|
||||
time.sleep(0.2)
|
||||
stream_out.stop_stream()
|
||||
stream_out.close()
|
||||
audio.terminate()
|
||||
|
||||
|
||||
class HotwordDetector(object):
|
||||
"""
|
||||
Snowboy decoder to detect whether a keyword specified by `decoder_model`
|
||||
exists in a microphone input stream.
|
||||
|
||||
:param decoder_model: decoder model file path, a string or a list of strings
|
||||
:param resource: resource file path.
|
||||
:param sensitivity: decoder sensitivity, a float of a list of floats.
|
||||
The bigger the value, the more senstive the
|
||||
decoder. If an empty list is provided, then the
|
||||
default sensitivity in the model will be used.
|
||||
:param audio_gain: multiply input volume by this factor.
|
||||
:param apply_frontend: applies the frontend processing algorithm if True.
|
||||
"""
|
||||
|
||||
def __init__(self, decoder_model,
|
||||
resource=RESOURCE_FILE,
|
||||
sensitivity=[],
|
||||
audio_gain=1,
|
||||
apply_frontend=False):
|
||||
|
||||
tm = type(decoder_model)
|
||||
ts = type(sensitivity)
|
||||
if tm is not list:
|
||||
decoder_model = [decoder_model]
|
||||
if ts is not list:
|
||||
sensitivity = [sensitivity]
|
||||
model_str = ",".join(decoder_model)
|
||||
|
||||
self.detector = snowboydetect.SnowboyDetect(
|
||||
resource_filename=resource.encode(), model_str=model_str.encode())
|
||||
self.detector.SetAudioGain(audio_gain)
|
||||
self.detector.ApplyFrontend(apply_frontend)
|
||||
self.num_hotwords = self.detector.NumHotwords()
|
||||
|
||||
if len(decoder_model) > 1 and len(sensitivity) == 1:
|
||||
sensitivity = sensitivity * self.num_hotwords
|
||||
if len(sensitivity) != 0:
|
||||
assert self.num_hotwords == len(sensitivity), \
|
||||
"number of hotwords in decoder_model (%d) and sensitivity " \
|
||||
"(%d) does not match" % (self.num_hotwords, len(sensitivity))
|
||||
sensitivity_str = ",".join([str(t) for t in sensitivity])
|
||||
if len(sensitivity) != 0:
|
||||
self.detector.SetSensitivity(sensitivity_str.encode())
|
||||
|
||||
self.ring_buffer = RingBuffer(
|
||||
self.detector.NumChannels() * self.detector.SampleRate() * 5)
|
||||
|
||||
def start(self, detected_callback=play_audio_file,
|
||||
interrupt_check=lambda: False,
|
||||
sleep_time=0.03,
|
||||
audio_recorder_callback=None,
|
||||
silent_count_threshold=15,
|
||||
recording_timeout=100):
|
||||
"""
|
||||
Start the voice detector. For every `sleep_time` second it checks the
|
||||
audio buffer for triggering keywords. If detected, then call
|
||||
corresponding function in `detected_callback`, which can be a single
|
||||
function (single model) or a list of callback functions (multiple
|
||||
models). Every loop it also calls `interrupt_check` -- if it returns
|
||||
True, then breaks from the loop and return.
|
||||
|
||||
:param detected_callback: a function or list of functions. The number of
|
||||
items must match the number of models in
|
||||
`decoder_model`.
|
||||
:param interrupt_check: a function that returns True if the main loop
|
||||
needs to stop.
|
||||
:param float sleep_time: how much time in second every loop waits.
|
||||
:param audio_recorder_callback: if specified, this will be called after
|
||||
a keyword has been spoken and after the
|
||||
phrase immediately after the keyword has
|
||||
been recorded. The function will be
|
||||
passed the name of the file where the
|
||||
phrase was recorded.
|
||||
:param silent_count_threshold: indicates how long silence must be heard
|
||||
to mark the end of a phrase that is
|
||||
being recorded.
|
||||
:param recording_timeout: limits the maximum length of a recording.
|
||||
:return: None
|
||||
"""
|
||||
self._running = True
|
||||
|
||||
def audio_callback(in_data, frame_count, time_info, status):
|
||||
self.ring_buffer.extend(in_data)
|
||||
play_data = chr(0) * len(in_data)
|
||||
return play_data, pyaudio.paContinue
|
||||
|
||||
with no_alsa_error():
|
||||
self.audio = pyaudio.PyAudio()
|
||||
self.stream_in = self.audio.open(
|
||||
input=True, output=False,
|
||||
format=self.audio.get_format_from_width(
|
||||
self.detector.BitsPerSample() / 8),
|
||||
channels=self.detector.NumChannels(),
|
||||
rate=self.detector.SampleRate(),
|
||||
frames_per_buffer=2048,
|
||||
stream_callback=audio_callback)
|
||||
|
||||
if interrupt_check():
|
||||
logger.debug("detect voice return")
|
||||
return
|
||||
|
||||
tc = type(detected_callback)
|
||||
if tc is not list:
|
||||
detected_callback = [detected_callback]
|
||||
if len(detected_callback) == 1 and self.num_hotwords > 1:
|
||||
detected_callback *= self.num_hotwords
|
||||
|
||||
assert self.num_hotwords == len(detected_callback), \
|
||||
"Error: hotwords in your models (%d) do not match the number of " \
|
||||
"callbacks (%d)" % (self.num_hotwords, len(detected_callback))
|
||||
|
||||
logger.debug("detecting...")
|
||||
|
||||
state = "PASSIVE"
|
||||
while self._running is True:
|
||||
if interrupt_check():
|
||||
logger.debug("detect voice break")
|
||||
break
|
||||
data = self.ring_buffer.get()
|
||||
if len(data) == 0:
|
||||
time.sleep(sleep_time)
|
||||
continue
|
||||
|
||||
status = self.detector.RunDetection(data)
|
||||
if status == -1:
|
||||
logger.warning("Error initializing streams or reading audio data")
|
||||
|
||||
#small state machine to handle recording of phrase after keyword
|
||||
if state == "PASSIVE":
|
||||
if status > 0: #key word found
|
||||
self.recordedData = []
|
||||
self.recordedData.append(data)
|
||||
silentCount = 0
|
||||
recordingCount = 0
|
||||
message = "Keyword " + str(status) + " detected at time: "
|
||||
message += time.strftime("%Y-%m-%d %H:%M:%S",
|
||||
time.localtime(time.time()))
|
||||
logger.info(message)
|
||||
callback = detected_callback[status-1]
|
||||
if callback is not None:
|
||||
callback()
|
||||
|
||||
if audio_recorder_callback is not None:
|
||||
state = "ACTIVE"
|
||||
continue
|
||||
|
||||
elif state == "ACTIVE":
|
||||
stopRecording = False
|
||||
if recordingCount > recording_timeout:
|
||||
stopRecording = True
|
||||
elif status == -2: #silence found
|
||||
if silentCount > silent_count_threshold:
|
||||
stopRecording = True
|
||||
else:
|
||||
silentCount = silentCount + 1
|
||||
elif status == 0: #voice found
|
||||
silentCount = 0
|
||||
|
||||
if stopRecording == True:
|
||||
fname = self.saveMessage()
|
||||
audio_recorder_callback(fname)
|
||||
state = "PASSIVE"
|
||||
continue
|
||||
|
||||
recordingCount = recordingCount + 1
|
||||
self.recordedData.append(data)
|
||||
|
||||
logger.debug("finished.")
|
||||
|
||||
def saveMessage(self):
|
||||
"""
|
||||
Save the message stored in self.recordedData to a timestamped file.
|
||||
"""
|
||||
filename = 'output' + str(int(time.time())) + '.wav'
|
||||
data = b''.join(self.recordedData)
|
||||
|
||||
#use wave to save data
|
||||
wf = wave.open(filename, 'wb')
|
||||
wf.setnchannels(1)
|
||||
wf.setsampwidth(self.audio.get_sample_size(
|
||||
self.audio.get_format_from_width(
|
||||
self.detector.BitsPerSample() / 8)))
|
||||
wf.setframerate(self.detector.SampleRate())
|
||||
wf.writeframes(data)
|
||||
wf.close()
|
||||
logger.debug("finished saving: " + filename)
|
||||
return filename
|
||||
|
||||
def terminate(self):
|
||||
"""
|
||||
Terminate audio stream. Users can call start() again to detect.
|
||||
:return: None
|
||||
"""
|
||||
self.stream_in.stop_stream()
|
||||
self.stream_in.close()
|
||||
self.audio.terminate()
|
||||
self._running = False
|
||||
@ -0,0 +1,144 @@
|
||||
# This file was automatically generated by SWIG (http://www.swig.org).
|
||||
# Version 4.0.2
|
||||
#
|
||||
# Do not make changes to this file unless you know what you are doing--modify
|
||||
# the SWIG interface file instead.
|
||||
|
||||
from sys import version_info as _swig_python_version_info
|
||||
if _swig_python_version_info < (2, 7, 0):
|
||||
raise RuntimeError("Python 2.7 or later required")
|
||||
|
||||
# Import the low-level C/C++ module
|
||||
if __package__ or "." in __name__:
|
||||
from . import _snowboydetect
|
||||
else:
|
||||
import _snowboydetect
|
||||
|
||||
try:
|
||||
import builtins as __builtin__
|
||||
except ImportError:
|
||||
import __builtin__
|
||||
|
||||
def _swig_repr(self):
|
||||
try:
|
||||
strthis = "proxy of " + self.this.__repr__()
|
||||
except __builtin__.Exception:
|
||||
strthis = ""
|
||||
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
|
||||
|
||||
|
||||
def _swig_setattr_nondynamic_instance_variable(set):
|
||||
def set_instance_attr(self, name, value):
|
||||
if name == "thisown":
|
||||
self.this.own(value)
|
||||
elif name == "this":
|
||||
set(self, name, value)
|
||||
elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
|
||||
set(self, name, value)
|
||||
else:
|
||||
raise AttributeError("You cannot add instance attributes to %s" % self)
|
||||
return set_instance_attr
|
||||
|
||||
|
||||
def _swig_setattr_nondynamic_class_variable(set):
|
||||
def set_class_attr(cls, name, value):
|
||||
if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
|
||||
set(cls, name, value)
|
||||
else:
|
||||
raise AttributeError("You cannot add class attributes to %s" % cls)
|
||||
return set_class_attr
|
||||
|
||||
|
||||
def _swig_add_metaclass(metaclass):
|
||||
"""Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
|
||||
def wrapper(cls):
|
||||
return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
|
||||
return wrapper
|
||||
|
||||
|
||||
class _SwigNonDynamicMeta(type):
|
||||
"""Meta class to enforce nondynamic attributes (no new attributes) for a class"""
|
||||
__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)
|
||||
|
||||
|
||||
class SnowboyDetect(object):
|
||||
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
||||
__repr__ = _swig_repr
|
||||
|
||||
def __init__(self, resource_filename, model_str):
|
||||
_snowboydetect.SnowboyDetect_swiginit(self, _snowboydetect.new_SnowboyDetect(resource_filename, model_str))
|
||||
|
||||
def Reset(self):
|
||||
return _snowboydetect.SnowboyDetect_Reset(self)
|
||||
|
||||
def RunDetection(self, *args):
|
||||
return _snowboydetect.SnowboyDetect_RunDetection(self, *args)
|
||||
|
||||
def SetSensitivity(self, sensitivity_str):
|
||||
return _snowboydetect.SnowboyDetect_SetSensitivity(self, sensitivity_str)
|
||||
|
||||
def SetHighSensitivity(self, high_sensitivity_str):
|
||||
return _snowboydetect.SnowboyDetect_SetHighSensitivity(self, high_sensitivity_str)
|
||||
|
||||
def GetSensitivity(self):
|
||||
return _snowboydetect.SnowboyDetect_GetSensitivity(self)
|
||||
|
||||
def SetAudioGain(self, audio_gain):
|
||||
return _snowboydetect.SnowboyDetect_SetAudioGain(self, audio_gain)
|
||||
|
||||
def UpdateModel(self):
|
||||
return _snowboydetect.SnowboyDetect_UpdateModel(self)
|
||||
|
||||
def NumHotwords(self):
|
||||
return _snowboydetect.SnowboyDetect_NumHotwords(self)
|
||||
|
||||
def ApplyFrontend(self, apply_frontend):
|
||||
return _snowboydetect.SnowboyDetect_ApplyFrontend(self, apply_frontend)
|
||||
|
||||
def SampleRate(self):
|
||||
return _snowboydetect.SnowboyDetect_SampleRate(self)
|
||||
|
||||
def NumChannels(self):
|
||||
return _snowboydetect.SnowboyDetect_NumChannels(self)
|
||||
|
||||
def BitsPerSample(self):
|
||||
return _snowboydetect.SnowboyDetect_BitsPerSample(self)
|
||||
__swig_destroy__ = _snowboydetect.delete_SnowboyDetect
|
||||
|
||||
# Register SnowboyDetect in _snowboydetect:
|
||||
_snowboydetect.SnowboyDetect_swigregister(SnowboyDetect)
|
||||
|
||||
class SnowboyVad(object):
|
||||
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
||||
__repr__ = _swig_repr
|
||||
|
||||
def __init__(self, resource_filename):
|
||||
_snowboydetect.SnowboyVad_swiginit(self, _snowboydetect.new_SnowboyVad(resource_filename))
|
||||
|
||||
def Reset(self):
|
||||
return _snowboydetect.SnowboyVad_Reset(self)
|
||||
|
||||
def RunVad(self, *args):
|
||||
return _snowboydetect.SnowboyVad_RunVad(self, *args)
|
||||
|
||||
def SetAudioGain(self, audio_gain):
|
||||
return _snowboydetect.SnowboyVad_SetAudioGain(self, audio_gain)
|
||||
|
||||
def ApplyFrontend(self, apply_frontend):
|
||||
return _snowboydetect.SnowboyVad_ApplyFrontend(self, apply_frontend)
|
||||
|
||||
def SampleRate(self):
|
||||
return _snowboydetect.SnowboyVad_SampleRate(self)
|
||||
|
||||
def NumChannels(self):
|
||||
return _snowboydetect.SnowboyVad_NumChannels(self)
|
||||
|
||||
def BitsPerSample(self):
|
||||
return _snowboydetect.SnowboyVad_BitsPerSample(self)
|
||||
__swig_destroy__ = _snowboydetect.delete_SnowboyVad
|
||||
|
||||
# Register SnowboyVad in _snowboydetect:
|
||||
_snowboydetect.SnowboyVad_swigregister(SnowboyVad)
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
@ -0,0 +1,310 @@
|
||||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="`which javac`"
|
||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=`which readlink`
|
||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||
else
|
||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||
fi
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`which java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=`cd "$wdir/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
##########################################################################################
|
||||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
##########################################################################################
|
||||
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found .mvn/wrapper/maven-wrapper.jar"
|
||||
fi
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
||||
fi
|
||||
if [ -n "$MVNW_REPOURL" ]; then
|
||||
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
else
|
||||
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
fi
|
||||
while IFS="=" read key value; do
|
||||
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
||||
esac
|
||||
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Downloading from: $jarUrl"
|
||||
fi
|
||||
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
if $cygwin; then
|
||||
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
|
||||
fi
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found wget ... using wget"
|
||||
fi
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
wget "$jarUrl" -O "$wrapperJarPath"
|
||||
else
|
||||
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
|
||||
fi
|
||||
elif command -v curl > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found curl ... using curl"
|
||||
fi
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
curl -o "$wrapperJarPath" "$jarUrl" -f
|
||||
else
|
||||
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
|
||||
fi
|
||||
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Falling back to using Java to download"
|
||||
fi
|
||||
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
# For Cygwin, switch paths to Windows format before running javac
|
||||
if $cygwin; then
|
||||
javaClass=`cygpath --path --windows "$javaClass"`
|
||||
fi
|
||||
if [ -e "$javaClass" ]; then
|
||||
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Compiling MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
# Compiling the Java class
|
||||
("$JAVA_HOME/bin/javac" "$javaClass")
|
||||
fi
|
||||
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
# Running the downloader
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Running MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
##########################################################################################
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
fi
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
fi
|
||||
|
||||
# Provide a "standardized" way to retrieve the CLI args that will
|
||||
# work with both Windows and non-Windows executions.
|
||||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
|
||||
export MAVEN_CMD_LINE_ARGS
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||
@ -0,0 +1,182 @@
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM https://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
|
||||
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
|
||||
)
|
||||
|
||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
if exist %WRAPPER_JAR% (
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Found %WRAPPER_JAR%
|
||||
)
|
||||
) else (
|
||||
if not "%MVNW_REPOURL%" == "" (
|
||||
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
)
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %DOWNLOAD_URL%
|
||||
)
|
||||
|
||||
powershell -Command "&{"^
|
||||
"$webclient = new-object System.Net.WebClient;"^
|
||||
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
|
||||
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
|
||||
"}"^
|
||||
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
|
||||
"}"
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
@REM Provide a "standardized" way to retrieve the CLI args that will
|
||||
@REM work with both Windows and non-Windows executions.
|
||||
set MAVEN_CMD_LINE_ARGS=%*
|
||||
|
||||
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||
|
||||
exit /B %ERROR_CODE%
|
||||
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.5.2</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>simulation-visualization</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>simulation-visualization</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<version>1.6.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,13 @@
|
||||
package com.example.demo;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SimulationVisualizationApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SimulationVisualizationApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Action {
|
||||
public String action=""; ////////Bulb_0.turn_bulb_on
|
||||
public String actionPulse=""; ////////turn_bulb_on
|
||||
public String device=""; ////////Bulb_0
|
||||
public String toState=""; ////////bon
|
||||
public String value=""; ////////1 bulb=1
|
||||
public String actionNum=""; ////////action1 用在生成IFD上作为节点id
|
||||
////////////是不是会改变属性 attrVal[0]=attribute,attrVal[1]="'"||"=",attrVal[2]=value
|
||||
// public List<String[]> attrVal=new ArrayList<String[]>();
|
||||
public List<Rule> rules=new ArrayList<Rule>();
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
public String getDevice() {
|
||||
return device;
|
||||
}
|
||||
public String getActionPulse() {
|
||||
return actionPulse;
|
||||
}
|
||||
public void setActionPulse(String actionPulse) {
|
||||
this.actionPulse = actionPulse;
|
||||
}
|
||||
public String getActionNum() {
|
||||
return actionNum;
|
||||
}
|
||||
public void setActionNum(String actionNum) {
|
||||
this.actionNum = actionNum;
|
||||
}
|
||||
public void setDevice(String device) {
|
||||
this.device = device;
|
||||
}
|
||||
public String getToState() {
|
||||
return toState;
|
||||
}
|
||||
public void setToState(String toState) {
|
||||
this.toState = toState;
|
||||
}
|
||||
// public List<String[]> getAttrVal() {
|
||||
// return attrVal;
|
||||
// }
|
||||
// public void setAttrVal(List<String[]> attrVal) {
|
||||
// this.attrVal = attrVal;
|
||||
// }
|
||||
public List<Rule> getRules() {
|
||||
return rules;
|
||||
}
|
||||
public void setRules(List<Rule> rules) {
|
||||
this.rules = rules;
|
||||
}
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// TODO Auto-generated method stub
|
||||
return this.actionNum+" : "+this.action;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BiddableType extends Entity{
|
||||
|
||||
//////lobby position 1
|
||||
public List<String[]> stateAttributeValues =new ArrayList<String[]>();
|
||||
|
||||
public List<String[]> getStateAttributeValues() {
|
||||
return stateAttributeValues;
|
||||
}
|
||||
|
||||
public void setStateAttributeValues(List<String[]> stateAttributeValues) {
|
||||
this.stateAttributeValues = stateAttributeValues;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CauseRule {
|
||||
/////导致某个状态的原因规则
|
||||
private String state=""; ///状态
|
||||
private int value=-1; ////对应的值
|
||||
private List<RuleNode> stateCausingRules=new ArrayList<RuleNode>(); ////对应的规则
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
public void setValue(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
public List<RuleNode> getStateCausingRules() {
|
||||
return stateCausingRules;
|
||||
}
|
||||
public void setStateCausingRules(List<RuleNode> stateCausingRules) {
|
||||
this.stateCausingRules = stateCausingRules;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Conflict {
|
||||
////状态冲突
|
||||
private double time; ///冲突时间
|
||||
private List<Integer> conflictValues=new ArrayList<>(); //////冲突的值(对应状态)
|
||||
public double getTime() {
|
||||
return time;
|
||||
}
|
||||
public void setTime(double time) {
|
||||
this.time = time;
|
||||
}
|
||||
public List<Integer> getConflictValues() {
|
||||
return conflictValues;
|
||||
}
|
||||
public void setConflictValues(List<Integer> conflictValues) {
|
||||
this.conflictValues = conflictValues;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConflictReason {
|
||||
/////冲突即原因
|
||||
private Conflict conflict=new Conflict(); /////某个冲突
|
||||
private List<CauseRule> causingRules=new ArrayList<>(); //////原因
|
||||
public Conflict getConflict() {
|
||||
return conflict;
|
||||
}
|
||||
public void setConflict(Conflict conflict) {
|
||||
this.conflict = conflict;
|
||||
}
|
||||
public List<CauseRule> getCausingRules() {
|
||||
return causingRules;
|
||||
}
|
||||
public void setCausingRules(List<CauseRule> causingRules) {
|
||||
this.causingRules = causingRules;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DataTimeValue {
|
||||
/////仿真结果数据格式
|
||||
public String name=""; ////////数据名
|
||||
public List<double[]> timeValues=new ArrayList<double[]>(); ////(time,value)列表,为仿真结果
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public List<double[]> getTimeValues() {
|
||||
return timeValues;
|
||||
}
|
||||
public void setTimeValues(List<double[]> timeValues) {
|
||||
this.timeValues = timeValues;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DeviceAnalysisResult {
|
||||
///////设备分析结果
|
||||
private String deviceName=""; ////设备名
|
||||
private List<ConflictReason> conflictReasons=new ArrayList<>(); ////是否有冲突及原因
|
||||
private List<JitterReason> jitterReasons=new ArrayList<>(); /////是否有抖动及原因
|
||||
public String getDeviceName() {
|
||||
return deviceName;
|
||||
}
|
||||
public void setDeviceName(String deviceName) {
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
public List<ConflictReason> getConflictReasons() {
|
||||
return conflictReasons;
|
||||
}
|
||||
public void setConflictReasons(List<ConflictReason> conflictReasons) {
|
||||
this.conflictReasons = conflictReasons;
|
||||
}
|
||||
public List<JitterReason> getJitterReasons() {
|
||||
return jitterReasons;
|
||||
}
|
||||
public void setJitterReasons(List<JitterReason> jitterReasons) {
|
||||
this.jitterReasons = jitterReasons;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DeviceType extends Entity{
|
||||
// [0] state, [1]action [2]value
|
||||
//Bulb------bon, turn_bulb_on, 1
|
||||
public List<String[]> stateActionValues=new ArrayList<String[]>();
|
||||
public int deviceNumber=0;
|
||||
public List<StateEffect> stateEffects=new ArrayList<>();
|
||||
|
||||
public List<StateEffect> getStateEffects() {
|
||||
return stateEffects;
|
||||
}
|
||||
public void setStateEffects(List<StateEffect> stateEffects) {
|
||||
this.stateEffects = stateEffects;
|
||||
}
|
||||
public int getDeviceNumber() {
|
||||
return deviceNumber;
|
||||
}
|
||||
public void setDeviceNumber(int deviceNumber) {
|
||||
this.deviceNumber = deviceNumber;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public List<String[]> getStateActionValues() {
|
||||
return stateActionValues;
|
||||
}
|
||||
public void setStateActionValues(List<String[]> stateActionValues) {
|
||||
this.stateActionValues = stateActionValues;
|
||||
}
|
||||
|
||||
public static class StateEffect{
|
||||
private String state="";
|
||||
private List<String[]> effects=new ArrayList<>();
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
public List<String[]> getEffects() {
|
||||
return effects;
|
||||
}
|
||||
public void setEffects(List<String[]> effects) {
|
||||
this.effects = effects;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
public class Entity {
|
||||
////实体类
|
||||
protected String name="";
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class EnvironmentModel {
|
||||
|
||||
private List<DeviceDetail> devices=new ArrayList<DeviceDetail>();
|
||||
private List<SensorType> sensors=new ArrayList<SensorType>();
|
||||
private List<BiddableType> biddables=new ArrayList<BiddableType>();
|
||||
private List<DeviceType> deviceTypes=new ArrayList<>();
|
||||
/////添加Attribute
|
||||
private List<Attribute> attributes=new ArrayList<>();
|
||||
|
||||
public List<Attribute> getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
public void setAttributes(List<Attribute> attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
public List<DeviceType> getDeviceTypes() {
|
||||
return deviceTypes;
|
||||
}
|
||||
public void setDeviceTypes(List<DeviceType> deviceTypes) {
|
||||
this.deviceTypes = deviceTypes;
|
||||
}
|
||||
public List<DeviceDetail> getDevices() {
|
||||
return devices;
|
||||
}
|
||||
public void setDevices(List<DeviceDetail> devices) {
|
||||
this.devices = devices;
|
||||
}
|
||||
public List<SensorType> getSensors() {
|
||||
return sensors;
|
||||
}
|
||||
public void setSensors(List<SensorType> sensors) {
|
||||
this.sensors = sensors;
|
||||
}
|
||||
public List<BiddableType> getBiddables() {
|
||||
return biddables;
|
||||
}
|
||||
public void setBiddables(List<BiddableType> biddables) {
|
||||
this.biddables = biddables;
|
||||
}
|
||||
public EnvironmentModel() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
public class ErrorReason {
|
||||
////用于静态分析
|
||||
public Rule rule=new Rule(); ///错误的规则
|
||||
public String reason=""; /////规则错误原因
|
||||
public Rule getRule() {
|
||||
return rule;
|
||||
}
|
||||
public void setRule(Rule rule) {
|
||||
this.rule = rule;
|
||||
}
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,121 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class IFDGraph {
|
||||
public static class GraphNode {
|
||||
|
||||
private String name=""; ///////节点名 trigger1
|
||||
private String shape=""; ///////节点形状 oval
|
||||
private String fillcolor=""; ////节点填充色
|
||||
private String label=""; //////节点内容
|
||||
public boolean flag=false;
|
||||
private List<GraphNodeArrow> pNodeList=new ArrayList<GraphNodeArrow>();
|
||||
private List<GraphNodeArrow> cNodeList=new ArrayList<GraphNodeArrow>();
|
||||
|
||||
|
||||
public void addpNodeList(GraphNodeArrow pNodeList) {
|
||||
this.pNodeList.add(pNodeList);
|
||||
}
|
||||
|
||||
public void addcNodeList(GraphNodeArrow cNodeList) {
|
||||
this.cNodeList.add(cNodeList);
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String getShape() {
|
||||
return shape;
|
||||
}
|
||||
|
||||
|
||||
public void setShape(String shape) {
|
||||
this.shape = shape;
|
||||
}
|
||||
|
||||
|
||||
public String getFillcolor() {
|
||||
return fillcolor;
|
||||
}
|
||||
|
||||
|
||||
public void setFillcolor(String fillcolor) {
|
||||
this.fillcolor = fillcolor;
|
||||
}
|
||||
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
|
||||
public List<GraphNodeArrow> getpNodeList() {
|
||||
return pNodeList;
|
||||
}
|
||||
|
||||
|
||||
public void setpNodeList(List<GraphNodeArrow> pNodeList) {
|
||||
this.pNodeList = pNodeList;
|
||||
}
|
||||
|
||||
|
||||
public List<GraphNodeArrow> getcNodeList() {
|
||||
return cNodeList;
|
||||
}
|
||||
|
||||
|
||||
public void setcNodeList(List<GraphNodeArrow> cNodeList) {
|
||||
this.cNodeList = cNodeList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class GraphNodeArrow {
|
||||
/////节点的边
|
||||
private GraphNode graphNode=new GraphNode();
|
||||
private String label="";
|
||||
private String color="";
|
||||
private String style="";
|
||||
public GraphNode getGraphNode() {
|
||||
return graphNode;
|
||||
}
|
||||
public void setGraphNode(GraphNode graphNode) {
|
||||
this.graphNode = graphNode;
|
||||
}
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
public String getStyle() {
|
||||
return style;
|
||||
}
|
||||
public void setStyle(String style) {
|
||||
this.style = style;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class InputConstruct {
|
||||
|
||||
|
||||
public static class EnvironmentRule{
|
||||
private EnvironmentModel environmentModel;
|
||||
private List<Rule> rules=new ArrayList<Rule>();
|
||||
public EnvironmentModel getEnvironmentModel() {
|
||||
return environmentModel;
|
||||
}
|
||||
public void setEnvironmentModel(EnvironmentModel environmentModel) {
|
||||
this.environmentModel = environmentModel;
|
||||
}
|
||||
public List<Rule> getRules() {
|
||||
return rules;
|
||||
}
|
||||
public void setRules(List<Rule> rules) {
|
||||
this.rules = rules;
|
||||
}
|
||||
public EnvironmentRule(EnvironmentModel environmentModel, List<Rule> rules) {
|
||||
super();
|
||||
this.environmentModel = environmentModel;
|
||||
this.rules = rules;
|
||||
}
|
||||
public EnvironmentRule() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static class SceneEnvironmentProperty{
|
||||
private List<Scene> scenes=new ArrayList<>();
|
||||
private EnvironmentModel environmentModel;
|
||||
private List<String> properties=new ArrayList<>();
|
||||
private List<Rule> rules=new ArrayList<>();
|
||||
|
||||
public List<Rule> getRules() {
|
||||
return rules;
|
||||
}
|
||||
public void setRules(List<Rule> rules) {
|
||||
this.rules = rules;
|
||||
}
|
||||
public List<String> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
public void setProperties(List<String> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
public List<Scene> getScenes() {
|
||||
return scenes;
|
||||
}
|
||||
public void setScenes(List<Scene> scenes) {
|
||||
this.scenes = scenes;
|
||||
}
|
||||
public EnvironmentModel getEnvironmentModel() {
|
||||
return environmentModel;
|
||||
}
|
||||
public void setEnvironmentModel(EnvironmentModel environmentModel) {
|
||||
this.environmentModel = environmentModel;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static class SceneEnvironmentRule{
|
||||
private Scene scene;
|
||||
private EnvironmentModel environmentModel;
|
||||
private List<Rule> rules=new ArrayList<>();
|
||||
public Scene getScene() {
|
||||
return scene;
|
||||
}
|
||||
public void setScene(Scene scene) {
|
||||
this.scene = scene;
|
||||
}
|
||||
public EnvironmentModel getEnvironmentModel() {
|
||||
return environmentModel;
|
||||
}
|
||||
public void setEnvironmentModel(EnvironmentModel environmentModel) {
|
||||
this.environmentModel = environmentModel;
|
||||
}
|
||||
public List<Rule> getRules() {
|
||||
return rules;
|
||||
}
|
||||
public void setRules(List<Rule> rules) {
|
||||
this.rules = rules;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class JitterReason {
|
||||
//////抖动及原因
|
||||
private List<double[]> jitter=new ArrayList<>(); ///某段抖动 time-value,time-value...
|
||||
private List<CauseRule> causingRules=new ArrayList<>(); //////原因
|
||||
public List<double[]> getJitter() {
|
||||
return jitter;
|
||||
}
|
||||
public void setJitter(List<double[]> jitter) {
|
||||
this.jitter = jitter;
|
||||
}
|
||||
public List<CauseRule> getCausingRules() {
|
||||
return causingRules;
|
||||
}
|
||||
public void setCausingRules(List<CauseRule> causingRules) {
|
||||
this.causingRules = causingRules;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,159 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ModelGraph {
|
||||
//////表示uppaal模型的类
|
||||
public static class TemplGraph {
|
||||
private String name=""; /////模型名
|
||||
private String declaration="";
|
||||
private String parameter="";
|
||||
private String init="";
|
||||
private List<TemplGraphNode> templGraphNodes=new ArrayList<TemplGraphNode>();
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getDeclaration() {
|
||||
return declaration;
|
||||
}
|
||||
public void setDeclaration(String declaration) {
|
||||
this.declaration = declaration;
|
||||
}
|
||||
public String getParameter() {
|
||||
return parameter;
|
||||
}
|
||||
public void setParameter(String parameter) {
|
||||
this.parameter = parameter;
|
||||
}
|
||||
public String getInit() {
|
||||
return init;
|
||||
}
|
||||
public void setInit(String init) {
|
||||
this.init = init;
|
||||
}
|
||||
public List<TemplGraphNode> getTemplGraphNodes() {
|
||||
return templGraphNodes;
|
||||
}
|
||||
public void setTemplGraphNodes(List<TemplGraphNode> templGraphNodes) {
|
||||
this.templGraphNodes = templGraphNodes;
|
||||
}
|
||||
|
||||
public void addTemplGraphNode(TemplGraphNode node) {
|
||||
this.templGraphNodes.add(node);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////节点类
|
||||
public static class TemplGraphNode {
|
||||
public String name="";
|
||||
public String id="";
|
||||
public String invariant="";
|
||||
public String style=""; //location or branchpoint or committed urgent?
|
||||
public boolean flag=false;
|
||||
public List<TemplTransition> inTransitions=new ArrayList<TemplTransition>();
|
||||
public List<TemplTransition> outTransitions=new ArrayList<TemplTransition>();
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getInvariant() {
|
||||
return invariant;
|
||||
}
|
||||
public void setInvariant(String invariant) {
|
||||
this.invariant = invariant;
|
||||
}
|
||||
public String getStyle() {
|
||||
return style;
|
||||
}
|
||||
public void setStyle(String style) {
|
||||
this.style = style;
|
||||
}
|
||||
public boolean isFlag() {
|
||||
return flag;
|
||||
}
|
||||
public void setFlag(boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
public List<TemplTransition> getInTransitions() {
|
||||
return inTransitions;
|
||||
}
|
||||
public void setInTransitions(List<TemplTransition> inTransitions) {
|
||||
this.inTransitions = inTransitions;
|
||||
}
|
||||
public List<TemplTransition> getOutTransitions() {
|
||||
return outTransitions;
|
||||
}
|
||||
public void setOutTransitions(List<TemplTransition> outTransitions) {
|
||||
this.outTransitions = outTransitions;
|
||||
}
|
||||
}
|
||||
|
||||
/////边类
|
||||
public static class TemplTransition {
|
||||
public String source="";
|
||||
public String target="";
|
||||
public TemplGraphNode node=new TemplGraphNode();
|
||||
public String assignment="";
|
||||
public String synchronisation="";
|
||||
public String guard="";
|
||||
public String probability=""; //source or target中有branchpoint则有这一项
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
public String getTarget() {
|
||||
return target;
|
||||
}
|
||||
public void setTarget(String target) {
|
||||
this.target = target;
|
||||
}
|
||||
public TemplGraphNode getNode() {
|
||||
return node;
|
||||
}
|
||||
public void setNode(TemplGraphNode node) {
|
||||
this.node = node;
|
||||
}
|
||||
public String getAssignment() {
|
||||
return assignment;
|
||||
}
|
||||
public void setAssignment(String assignment) {
|
||||
this.assignment = assignment;
|
||||
}
|
||||
public String getSynchronisation() {
|
||||
return synchronisation;
|
||||
}
|
||||
public void setSynchronisation(String synchronisation) {
|
||||
this.synchronisation = synchronisation;
|
||||
}
|
||||
public String getGuard() {
|
||||
return guard;
|
||||
}
|
||||
public void setGuard(String guard) {
|
||||
this.guard = guard;
|
||||
}
|
||||
public String getProbability() {
|
||||
return probability;
|
||||
}
|
||||
public void setProbability(String probability) {
|
||||
this.probability = probability;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class OutputConstruct {
|
||||
public static class EnvironmentStatic{
|
||||
private EnvironmentModel environmentModel;
|
||||
private StaticAnalysisResult staticAnalysisResult;
|
||||
|
||||
public EnvironmentStatic() {
|
||||
super();
|
||||
}
|
||||
public EnvironmentStatic(EnvironmentModel environmentModel, StaticAnalysisResult staticAnalysisResult) {
|
||||
super();
|
||||
this.environmentModel = environmentModel;
|
||||
this.staticAnalysisResult = staticAnalysisResult;
|
||||
}
|
||||
public EnvironmentModel getEnvironmentModel() {
|
||||
return environmentModel;
|
||||
}
|
||||
public void setEnvironmentModel(EnvironmentModel environmentModel) {
|
||||
this.environmentModel = environmentModel;
|
||||
}
|
||||
public StaticAnalysisResult getStaticAnalysisResult() {
|
||||
return staticAnalysisResult;
|
||||
}
|
||||
public void setStaticAnalysisResult(StaticAnalysisResult staticAnalysisResult) {
|
||||
this.staticAnalysisResult = staticAnalysisResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ReachableReason {
|
||||
///property可达原因
|
||||
private double[] satisfyIntervalTime; ////满足的区间
|
||||
private String scenarioName="";
|
||||
private List<CauseRule> causingRules=new ArrayList<CauseRule>();
|
||||
public double[] getSatisfyIntervalTime() {
|
||||
return satisfyIntervalTime;
|
||||
}
|
||||
public void setSatisfyIntervalTime(double[] satisfyIntervalTime) {
|
||||
this.satisfyIntervalTime = satisfyIntervalTime;
|
||||
}
|
||||
public List<CauseRule> getCausingRules() {
|
||||
return causingRules;
|
||||
}
|
||||
public void setCausingRules(List<CauseRule> causingRules) {
|
||||
this.causingRules = causingRules;
|
||||
}
|
||||
public String getScenarioName() {
|
||||
return scenarioName;
|
||||
}
|
||||
public void setScenarioName(String scenarioName) {
|
||||
this.scenarioName = scenarioName;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Rule {
|
||||
|
||||
private String ruleName=""; ///规则名序号 rulei
|
||||
private String ruleContent=""; ///规则内容
|
||||
private List<String> trigger=new ArrayList<String>(); ////所有triggers
|
||||
private List<String> action=new ArrayList<String>(); ////所有actions
|
||||
public String getRuleName() {
|
||||
return ruleName;
|
||||
}
|
||||
public void setRuleName(String ruleName) {
|
||||
this.ruleName = ruleName;
|
||||
}
|
||||
public String getRuleContent() {
|
||||
return ruleContent;
|
||||
}
|
||||
public void setRuleContent(String ruleContent) {
|
||||
this.ruleContent = ruleContent;
|
||||
}
|
||||
public List<String> getTrigger() {
|
||||
return trigger;
|
||||
}
|
||||
public void setTrigger(List<String> trigger) {
|
||||
this.trigger = trigger;
|
||||
}
|
||||
public List<String> getAction() {
|
||||
return action;
|
||||
}
|
||||
public void setAction(List<String> action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public boolean contentEquals(Rule rule) {
|
||||
if(ruleName.equals(rule.getRuleName())) {
|
||||
return true;
|
||||
}
|
||||
if(ruleContent.equals(rule.getRuleContent())) {
|
||||
return true;
|
||||
}
|
||||
if(trigger.size()==rule.getTrigger().size()&&action.size()==rule.getAction().size()) {
|
||||
boolean equal=true;
|
||||
for(String tri:trigger) {
|
||||
boolean exist=false;
|
||||
for(String tri2:rule.getTrigger()) {
|
||||
if(tri.equals(tri2)) {
|
||||
exist=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!exist) {
|
||||
equal=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(equal) {
|
||||
for(String act:action) {
|
||||
boolean exist=false;
|
||||
for(String act2:rule.getAction()) {
|
||||
if(act.equals(act2)) {
|
||||
exist=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!exist) {
|
||||
equal=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(equal) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RuleNode {
|
||||
/////用于locate error ,当前规则和会引发这个规则的其他规则
|
||||
private Rule rule=new Rule(); //////当前规则
|
||||
private List<RuleNode> preRules=new ArrayList<RuleNode>(); ////会触发该规则的规则
|
||||
public Rule getRule() {
|
||||
return rule;
|
||||
}
|
||||
public void setRule(Rule rule) {
|
||||
this.rule = rule;
|
||||
}
|
||||
public List<RuleNode> getPreRules() {
|
||||
return preRules;
|
||||
}
|
||||
public void setPreRules(List<RuleNode> preRules) {
|
||||
this.preRules = preRules;
|
||||
}
|
||||
public void setPreRules(int i,RuleNode preRule) {
|
||||
this.preRules.set(i, preRule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder preRules=new StringBuilder();
|
||||
for(RuleNode ruleNode:this.preRules) {
|
||||
preRules.append(ruleNode.getRule().getRuleName()+" ");
|
||||
}
|
||||
return this.rule.getRuleName()+"<---"+preRules.toString();
|
||||
}
|
||||
|
||||
////删除某个pre
|
||||
public void removePreRule(String ruleName) {
|
||||
for(RuleNode ruleNode:this.preRules) {
|
||||
if(ruleNode.getRule().getRuleName().equals(ruleName)) {
|
||||
this.preRules.remove(ruleNode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean equals(Object obj) {
|
||||
// if(obj instanceof RuleNode) {
|
||||
// RuleNode otherRuleNode=(RuleNode) obj;
|
||||
// if(otherRuleNode.getRule().getRuleName().equals(otherRuleNode.getRule().getRuleName())) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
public class SensorType extends Entity{
|
||||
public String attribute=""; ///传感器检测什么属性
|
||||
public String style=""; ///该属性的类型
|
||||
public String getStyle() {
|
||||
return style;
|
||||
}
|
||||
public void setStyle(String style) {
|
||||
this.style = style;
|
||||
}
|
||||
public String getAttribute() {
|
||||
return attribute;
|
||||
}
|
||||
public void setAttribute(String attribute) {
|
||||
this.attribute = attribute;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class StaticAnalysisResult {
|
||||
////静态分析结果
|
||||
private List<ErrorReason> incorrectRules=new ArrayList<ErrorReason>();
|
||||
private List<ErrorReason> unusedRules=new ArrayList<ErrorReason>();
|
||||
private List<List<Rule>> redundantRules=new ArrayList<List<Rule>>();
|
||||
private List<String> incompleteness=new ArrayList<String>();
|
||||
private List<Rule> usableRules=new ArrayList<Rule>();
|
||||
private List<Rule> totalRules=new ArrayList<>();
|
||||
public List<Rule> getTotalRules() {
|
||||
return totalRules;
|
||||
}
|
||||
public void setTotalRules(List<Rule> totalRules) {
|
||||
this.totalRules = totalRules;
|
||||
}
|
||||
public List<ErrorReason> getIncorrectRules() {
|
||||
return incorrectRules;
|
||||
}
|
||||
public void setIncorrectRules(List<ErrorReason> incorrectRules) {
|
||||
this.incorrectRules = incorrectRules;
|
||||
}
|
||||
public List<ErrorReason> getUnusedRules() {
|
||||
return unusedRules;
|
||||
}
|
||||
public void setUnusedRules(List<ErrorReason> unusedRules) {
|
||||
this.unusedRules = unusedRules;
|
||||
}
|
||||
public List<List<Rule>> getRedundantRules() {
|
||||
return redundantRules;
|
||||
}
|
||||
public void setRedundantRules(List<List<Rule>> redundantRules) {
|
||||
this.redundantRules = redundantRules;
|
||||
}
|
||||
public List<String> getIncompleteness() {
|
||||
return incompleteness;
|
||||
}
|
||||
public void setIncompleteness(List<String> incompleteness) {
|
||||
this.incompleteness = incompleteness;
|
||||
}
|
||||
public List<Rule> getUsableRules() {
|
||||
return usableRules;
|
||||
}
|
||||
public void setUsableRules(List<Rule> usableRules) {
|
||||
this.usableRules = usableRules;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package com.example.demo.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Trigger {
|
||||
public String trigger=""; ///////temperature>=30 //////Bulb_0.bon ///Person.lobby(人在客厅)
|
||||
public String triggerNum=""; ///////trigger1 //////trigger2 ///trigger3
|
||||
public String device=""; ///////temperature_sensor //////Bulb_0 ///person_sensor
|
||||
public String[] attrVal=new String[3]; ///////temperature >= 30 //////Bulb_0 . bon ///position = 1
|
||||
public List<Rule> rules=new ArrayList<Rule>();
|
||||
public String getTrigger() {
|
||||
return trigger;
|
||||
}
|
||||
public void setTrigger(String trigger) {
|
||||
this.trigger = trigger;
|
||||
}
|
||||
public String getTriggerNum() {
|
||||
return triggerNum;
|
||||
}
|
||||
public void setTriggerNum(String triggerNum) {
|
||||
this.triggerNum = triggerNum;
|
||||
}
|
||||
public String[] getAttrVal() {
|
||||
return attrVal;
|
||||
}
|
||||
public void setAttrVal(String[] attrVal) {
|
||||
this.attrVal = attrVal;
|
||||
}
|
||||
public List<Rule> getRules() {
|
||||
return rules;
|
||||
}
|
||||
public void setRules(List<Rule> rules) {
|
||||
this.rules = rules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// TODO Auto-generated method stub
|
||||
return this.triggerNum+" : "+this.trigger;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.example.demo.service;
|
||||
|
||||
public class AddressService {
|
||||
public final static String MODEL_FILE_PATH= "D:\\workspace\\modelFile\\";
|
||||
public final static String UPPAAL_PATH="D:\\tools\\uppaal-4.1.24\\uppaal-4.1.24\\bin-Windows\\";
|
||||
public final static String IFD_FILE_PATH="D:\\workspace\\ifdFile\\";
|
||||
public final static String IFD_FILE_NAME="ifd.dot";
|
||||
public final static String SIMULATE_RESULT_FILE_PATH="D:\\workspace\\resultFile\\";
|
||||
public final static String VIDEO_PATH="D:\\workspace\\videoFile\\";
|
||||
public final static String CONVERT_TOOL_PATH="D:\\workspace\\c2t\\c2t\\";
|
||||
|
||||
// public final static String MODEL_FILE_PATH= "/root/TAPs-Visual/workspace/modelFile/";
|
||||
// public final static String UPPAAL_PATH="/root/TAPs/workspace/uppaal64-4.1.24/bin-Linux/";
|
||||
// public final static String IFD_FILE_PATH="/root/TAPs-Visual/workspace/ifdFile/";
|
||||
// public final static String IFD_FILE_NAME="ifd.dot";
|
||||
// public final static String SIMULATE_RESULT_FILE_PATH="/root/TAPs-Visual/workspace/resultFile/";
|
||||
// public final static String VIDEO_PATH="/root/public_html/TAPs-Visual/assets/";
|
||||
|
||||
public final static String ONTOLOGY_FILE_NAME="ontology.xml";
|
||||
public final static String DEVICE_POSITION_INFORMATION_FILE_NAME="devicePositionInformation.properties";
|
||||
|
||||
public static String changed_model_file_Name;
|
||||
public static String best_model_file_name;
|
||||
public static String getBest_model_file_name() {
|
||||
return best_model_file_name;
|
||||
}
|
||||
public static void setBest_model_file_name(String initModelFileName) {
|
||||
AddressService.best_model_file_name = initModelFileName.substring(0, initModelFileName.lastIndexOf(".xml"))+"-scenario-best.xml";
|
||||
}
|
||||
private AddressService() {
|
||||
|
||||
}
|
||||
public final static void setChangedModelFileName(String initModelFileName) {
|
||||
changed_model_file_Name=initModelFileName.substring(0, initModelFileName.lastIndexOf(".xml"))+"-changed.xml";
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,17 @@
|
||||
package com.example.demo.service;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class PropertyService {
|
||||
|
||||
public static Properties getProperties(String filePath,String propertyFileName) throws FileNotFoundException, IOException {
|
||||
Properties properties=new Properties();
|
||||
properties.load(new FileInputStream(filePath+propertyFileName));
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,4 @@
|
||||
server.port=8085
|
||||
|
||||
spring.servlet.multipart.max-request-size=200MB
|
||||
spring.servlet.multipart.max-file-size=200MB
|
||||
@ -0,0 +1,13 @@
|
||||
package com.example.demo;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class SimulationVisualizationApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue