diff --git a/assets/script/FakeData.ts b/assets/script/FakeData.ts index 2bbef3c..63f1017 100644 --- a/assets/script/FakeData.ts +++ b/assets/script/FakeData.ts @@ -1,4 +1,4 @@ -import { IDroneInfo, IDroneLocationInfo } from "./define/Interface"; +import { IDroneDetailValueInfo, IDroneInfo, IDroneLocationInfo, IDroneWeatherValueInfo } from "./define/Interface"; export const FakeDroneListInfo: Array = [ { @@ -93,4 +93,101 @@ export const FakeDroneDetail: Array = [ locationN: `8'7'8.7""`, locationE: `3'3'1.2""` }, -] \ No newline at end of file +] + +export const FakeDroneDetailValue: Array = [ + { + id: 'Fly-A', + high: '60公分', + speed: '20m/s', + acceleration: '1m/s', + direction: '東南', + pitch: 'J三小窩不知道peko', + yaw: 'J三小窩不知道peko', + roll: '45 degree', + mode: 'auto' + }, + { + id: 'Fly-B', + high: '6公尺', + speed: '80m/s', + acceleration: '2m/s', + direction: '西北', + pitch: 'J三小窩不知道peko', + yaw: 'J三小窩不知道peko', + roll: '90 degree', + mode: 'manual' + }, + { + id: 'Fly-C', + high: '30公分', + speed: '7m/s', + acceleration: '0.52m/s', + direction: '南', + pitch: 'J三小窩不知道peko', + yaw: 'J三小窩不知道peko', + roll: '33.33 degree', + mode: 'loiter' + }, + { + id: 'Fly-D', + high: '73公分', + speed: '13m/s', + acceleration: '0.8m/s', + direction: '北北東', + pitch: 'J三小窩不知道peko', + yaw: 'J三小窩不知道peko', + roll: '20 degree', + mode: 'attitude' + }, + { + id: 'Fly-E', + high: '30公尺', + speed: '40m/s', + acceleration: '8m/s', + direction: '西', + pitch: 'J三小窩不知道peko', + yaw: 'J三小窩不知道peko', + roll: '60 degree', + mode: 'manual' + }, + { + id: 'Fly-F', + high: '100公分', + speed: '6.6m/s', + acceleration: '3m/s', + direction: '南', + pitch: 'J三小窩不知道peko', + yaw: 'J三小窩不知道peko', + roll: '22.5 degree', + mode: 'auto' + }, + { + id: 'Fly-G', + high: '300公尺', + speed: '200m/s', + acceleration: '10m/s', + direction: '北', + pitch: 'J三小窩不知道peko', + yaw: 'J三小窩不知道peko', + roll: '0 degree', + mode: 'auto' + }, + { + id: 'Fly-H', + high: '45公分', + speed: '0.8m/s', + acceleration: '0.02m/s', + direction: '南南西', + pitch: 'J三小窩不知道peko', + yaw: 'J三小窩不知道peko', + roll: '10 degree', + mode: 'attitude' + } +] + +export const FakeWeatherValue: IDroneWeatherValueInfo = { + atmosphericPressure: '1.2', + windDirection: '西北', + windSpeed: '20km/s' +} \ No newline at end of file diff --git a/assets/script/TestFakeData.ts b/assets/script/TestFakeData.ts index ce27d6a..74b3f79 100644 --- a/assets/script/TestFakeData.ts +++ b/assets/script/TestFakeData.ts @@ -1,6 +1,6 @@ import { Drone_Event } from "./define/Event"; import BaseComp from "./external/BaseComp"; -import { FakeDroneDetail, FakeDroneListInfo } from "./FakeData"; +import { FakeDroneDetail, FakeDroneDetailValue, FakeDroneListInfo, FakeWeatherValue } from "./FakeData"; const { ccclass, property } = cc._decorator; @ccclass @@ -9,21 +9,37 @@ export default class TestFakeData extends BaseComp { protected onLoad(): void { console.log('ken666::TestFakeData::onLoad()') + cc.tween(new cc.Node()) + .delay(1) + .call(() => { + console.log('ken666::delay3 send Drone_Event.DRONE_DETAIL') + this.emit(Drone_Event.DRONE_DETAIL, FakeDroneDetail) + }) + .start() + cc.tween(new cc.Node()) .delay(3) .call(() => { console.log('ken666::delay3 send Drone_Event.DRONE_LIST') this.emit(Drone_Event.DRONE_LIST, FakeDroneListInfo) }) - .start() + .start() - cc.tween(new cc.Node()) - .delay(1) + cc.tween(new cc.Node()) + .delay(3) .call(() => { - console.log('ken666::delay3 send Drone_Event.DRONE_DETAIL') - this.emit(Drone_Event.DRONE_DETAIL, FakeDroneDetail) + console.log('ken666::delay3 send Drone_Event.DRONE_DETAIL_VALUE') + this.emit(Drone_Event.DRONE_DETAIL_VALUE, FakeDroneDetailValue) }) - .start() + .start() + + cc.tween(new cc.Node()) + .delay(3) + .call(() => { + console.log('ken666::delay3 send Drone_Event.WEATHER') + this.emit(Drone_Event.WEATHER, FakeWeatherValue) + }) + .start() } } diff --git a/assets/script/define/Event.ts b/assets/script/define/Event.ts index 038aa3f..42f29dc 100644 --- a/assets/script/define/Event.ts +++ b/assets/script/define/Event.ts @@ -1,5 +1,7 @@ export enum Drone_Event { DRONE_LIST = "DRONE_LIST", DRONE_CLICK = "DRONE_CLICK", - DRONE_DETAIL = "DRONE_DETAIL" + DRONE_DETAIL = "DRONE_DETAIL", + DRONE_DETAIL_VALUE = "DRONE_DETAIL_VALUE", + WEATHER = 'WEATHER' } \ No newline at end of file diff --git a/assets/script/define/Interface.ts b/assets/script/define/Interface.ts index 14570e7..8e35f99 100644 --- a/assets/script/define/Interface.ts +++ b/assets/script/define/Interface.ts @@ -11,6 +11,24 @@ export interface IDroneLocationInfo { locationE: string } +export interface IDroneDetailValueInfo { + id: string + high: string + speed: string + acceleration: string + direction: string + pitch: string + yaw: string + roll: string + mode: string +} + +export interface IDroneWeatherValueInfo { + atmosphericPressure: string + windDirection: string + windSpeed: string +} + // export interface IRespose { // success: boolean // msg: string diff --git a/assets/script/drone/CommonModel.ts b/assets/script/drone/CommonModel.ts index 048023c..98a6a67 100644 --- a/assets/script/drone/CommonModel.ts +++ b/assets/script/drone/CommonModel.ts @@ -1,5 +1,5 @@ import { Drone_Event } from "../define/Event"; -import { IDroneInfo, IDroneLocationInfo } from "../define/Interface"; +import { IDroneDetailValueInfo, IDroneInfo, IDroneLocationInfo, IDroneWeatherValueInfo } from "../define/Interface"; import EmitterBase from "../external/EmitterBase"; import { Utils } from "../external/Utils"; import { makeAutoObservable } from "../Library/mobx/mobx"; @@ -15,10 +15,14 @@ export class CommonModel extends EmitterBase { droneInfo: Array = [] droneDetail: Array = [] + droneDetailValue: Array = [] + weather: IDroneWeatherValueInfo = null constructor() { super(); this.on(Drone_Event.DRONE_LIST, this.setDrone.bind(this)) this.on(Drone_Event.DRONE_DETAIL, this.setDroneDetail.bind(this)) + this.on(Drone_Event.DRONE_DETAIL, this.setDroneDetailValue.bind(this)) + this.on(Drone_Event.DRONE_DETAIL, this.setWeather.bind(this)) makeAutoObservable(this) } @@ -33,6 +37,16 @@ export class CommonModel extends EmitterBase { console.log('setDroneDetail') this.droneDetail = Utils.deepClone(droneDetail) } + + private setDroneDetailValue(droneDetailValue: Array) { + console.log('setDroneDetail') + this.droneDetailValue = Utils.deepClone(droneDetailValue) + } + + private setWeather(weather: IDroneWeatherValueInfo) { + console.log('setDroneDetail') + this.weather = Utils.deepClone(weather) + } // async init() { // const response = await httpSender.sendGet('/api/front/index/init', { deviceType: DeviceTypeCode[Common.curSkin] }) // if (response && response.success) {