Files
zmkgC/third/plane/dj/dj.go

1218 lines
35 KiB
Go
Raw Normal View History

2025-07-07 20:11:59 +08:00
package dj
import (
"context"
"github.com/gogf/gf/v2/crypto/gmd5"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"github.com/tiger1103/gfast/v3/api/v1/common/coryCommon"
"math/rand"
"time"
)
const (
Drone_open = "drone_open"
Drone_close = "drone_close"
Cover_open = "cover_open"
Cover_close = "cover_close"
Device_reboot = "device_reboot"
Putter_open = "putter_open"
Putter_close = "putter_close"
Airport_organization_bind = "airport_organization_bind" //设备绑定到组织
Airport_organization_get = "airport_organization_get" //查询设备绑定对应的组织信息
Airport_bind_status = "airport_bind_status" //获取设备绑定信息
Update_topo = "update_topo" //设备拓扑更新
Flighttask_ready = "flighttask_ready" //任务就绪通知
Flighttask_resource_get = "flighttask_resource_get" //任务资源获取
Return_home_info = "return_home_info" //返航信息
Flighttask_progress = "flighttask_progress" //上报航线任务进度
Flighttask_prepare = "flighttask_prepare" //下发任务
Storage_config_get = "storage_config_get" //获取上传临时凭证
File_upload_callback = "file_upload_callback" //媒体文件上传结果上报
Takeoff_to_point = "takeoff_to_point" //一键起飞
Fly_to_point_stop = "fly_to_point_stop" //结束飞向目标点
Fly_to_point = "fly_to_point" //飞向目标点
Fly_to_point_progress = "fly_to_point_progress" //flyto 执行结果事件通知
Flight_authority_grab = "flight_authority_grab" //飞行控制权抢夺
Speaker_tts_play_start = "speaker_tts_play_start" //喊话器-开始播放TTS文本
Speaker_audio_play_start = "speaker_audio_play_start" //喊话器-开始播放音频
Fileupload_progress = "fileupload_progress" //文件上传进度通知(远程日志)
Config = "config" //config
//cory
OtaCreate = "ota_create" //固件升级
OtaProgress = "ota_progress" //固件升级进度通知
FileuploadList = "fileupload_list" //获取设备可上传的文件列表
FileuploadStart = "fileupload_start" //发起日志文件上传
DeviceFormat = "device_format" //机场数据格式化
DroneFormat = "drone_format" //飞行器数据格式化
ReturnHome1 = "return_home" //返航
)
// CoryAirportOrAircraft 机场or飞机
type CoryAirportOrAircraft struct {
Airport interface{} `json:"airport" dc:"机场数据"`
Aircraft interface{} `json:"aircraft" dc:"飞机数据"`
HangarSn string `json:"hangarSn" dc:"机仓sn"`
AircraftSn string `json:"aircraftSn" dc:"飞机sn"`
Coordinates string `json:"coordinates" dc:"无人机最后一次发送的坐标信息"`
}
/*共有类*/
type Public struct {
Tid string `json:"tid"`
Bid string `json:"bid"`
Timestamp int64 `json:"timestamp"`
Gateway string `json:"gateway"`
Method string `json:"method"`
}
type PublicTwo struct {
Public
Data struct {
Result int `json:"result"`
Output struct {
Status string `json:"status"`
} `json:"output"`
} `json:"data"`
}
func (receiver *Public) SetDefault() {
//randString := RandString(32)
//receiver.Bid = randString
//receiver.Tid = randString
receiver.Bid = RandString(32)
receiver.Tid = RandString(32)
receiver.Timestamp = gtime.Now().TimestampMilli()
}
func RandString(len int) string {
time.Sleep(time.Nanosecond)
r := rand.New(rand.NewSource(time.Now().UnixNano()))
bytes := make([]byte, len)
for i := 0; i < len; i++ {
b := r.Intn(26) + 65
bytes[i] = byte(b)
}
return gmd5.MustEncryptString(string(bytes))
}
// 属性信息1
type OSD1 struct {
Public
Data struct {
JobNumber int `json:"job_number"`
AccTime int `json:"acc_time"`
ActivationTime int `json:"activation_time"`
MaintainStatus struct {
MaintainStatusArray []struct {
State int `json:"state"`
LastMaintainType int `json:"last_maintain_type"`
LastMaintainTime int `json:"last_maintain_time"`
LastMaintainWorkSorties int `json:"last_maintain_work_sorties"`
} `json:"maintain_status_array"`
} `json:"maintain_status"`
ElectricSupplyVoltage int `json:"electric_supply_voltage"`
WorkingVoltage int `json:"working_voltage"`
WorkingCurrent int `json:"working_current"`
BackupBattery struct {
Voltage int `json:"voltage"`
Temperature float64 `json:"temperature"`
Switch int `json:"switch"`
} `json:"backup_battery"`
DroneBatteryMaintenanceInfo struct {
MaintenanceState int `json:"maintenance_state"`
MaintenanceTimeLeft int `json:"maintenance_time_left"`
} `json:"drone_battery_maintenance_info"`
} `json:"data"`
}
// 属性信息2
type OSD2 struct {
Public
Data struct {
FlighttaskPrepareCapacity int `json:"flighttask_prepare_capacity"`
FlighttaskStepCode int `json:"flighttask_step_code"`
MediaFileDetail struct {
RemainUpload int `json:"remain_upload"`
} `json:"media_file_detail"`
WirelessLink struct {
GFreqBand float64 `json:"4g_freq_band"`
GGndQuality int `json:"4g_gnd_quality"`
GLinkState int `json:"4g_link_state"`
GQuality int `json:"4g_quality"`
GUavQuality int `json:"4g_uav_quality"`
DongleNumber int `json:"dongle_number"`
LinkWorkmode int `json:"link_workmode"`
SdrFreqBand float64 `json:"sdr_freq_band"`
SdrLinkState int `json:"sdr_link_state"`
SdrQuality int `json:"sdr_quality"`
} `json:"wireless_link"`
} `json:"data"`
}
// 属性信息3
type OSD3 struct {
Public
Data struct {
NetworkState struct {
Type int `json:"type"`
Quality int `json:"quality"`
Rate float64 `json:"rate"`
} `json:"network_state"`
DroneChargeState struct {
State int `json:"state"`
CapacityPercent int `json:"capacity_percent"`
} `json:"drone_charge_state"`
DroneInDock int `json:"drone_in_dock"`
Rainfall int `json:"rainfall"`
WindSpeed float64 `json:"wind_speed"`
EnvironmentTemperature float64 `json:"environment_temperature"`
Temperature float64 `json:"temperature"`
Humidity int `json:"humidity"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Height float64 `json:"height"`
AlternateLandPoint struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
SafeLandHeight int `json:"safe_land_height"`
IsConfigured int `json:"is_configured"`
} `json:"alternate_land_point"`
FirstPowerOn int64 `json:"first_power_on"`
PositionState struct {
IsCalibration int `json:"is_calibration"`
IsFixed int `json:"is_fixed"`
Quality int `json:"quality"`
GpsNumber int `json:"gps_number"`
RtkNumber int `json:"rtk_number"`
} `json:"position_state"`
Storage struct {
Total int `json:"total"`
Used int `json:"used"`
} `json:"storage"`
ModeCode int `json:"mode_code"`
CoverState int `json:"cover_state"`
SupplementLightState int `json:"supplement_light_state"`
EmergencyStopState int `json:"emergency_stop_state"`
AirConditionerMode int `json:"air_conditioner_mode"`
BatteryStoreMode int `json:"battery_store_mode"`
AlarmState int `json:"alarm_state"`
PutterState int `json:"putter_state"`
SubDevice struct {
DeviceSn string `json:"device_sn"`
DeviceModelKey string `json:"device_model_key"`
DeviceOnlineStatus int `json:"device_online_status"`
DevicePaired int `json:"device_paired"`
} `json:"sub_device"`
} `json:"data"`
}
// M30/M30T 设备属性
type M30tEntity struct {
Public
Data struct {
Battery struct {
CapacityPercent int `json:"capacity_percent" dc:"电池的总剩余电量"`
RemainFlightTime int `json:"remain_flight_time" dc:"剩余飞行时间"`
ReturnHomePower int `json:"return_home_power" dc:"返航所需电量百分比 "`
} `json:"battery" dc:"飞行器电池信息"`
Storage struct {
Total int `json:"total" dc:"总容量"`
Used int `json:"used" dc:"已使用容量"`
} `json:"storage" dc:"存储容量"`
cameras struct {
RemainPhotoNum int `json:"remain_photo_num" dc:"剩余拍照张数"`
} `json:"cameras" dc:"飞行器相机信息"`
HorizontalSpeed float64 `json:"horizontal_speed" dc:"水平速度"`
VerticalSpeed float64 `json:"vertical_speed" dc:"垂直速度 "`
Latitude float64 `json:"latitude" dc:"当前位置经度"`
Longitude float64 `json:"longitude" dc:"当前位置纬度"`
Elevation float64 `json:"elevation" dc:"相对起飞点高度"`
TrackId float64 `json:"track_id" dc:"航迹ID"`
} `json:"data"`
}
// 大疆机场 设备属性
type DjiAirportEntity struct {
Public
Data struct {
Battery struct {
VideoQuality int `json:"video_quality" dc:"直播状态 (0自动,1流畅,2高清,3超清)"`
Status int `json:"status" dc:"直播状态"`
} `json:"live_status" dc:"网关当前整体直播状态推送"`
} `json:"data"`
}
// AircraftInformation 飞机状态信息 Cory
type AircraftInformation struct {
Public
Data struct {
CommanderFlightHeight float64 `json:"commander_flight_height" dc:"指点飞行高度"`
HorizontalSpeed float64 `json:"horizontal_speed" dc:"水平速度"`
VerticalSpeed float64 `json:"vertical_speed" dc:"垂直速度"`
} `json:"data"`
}
// FileUploadCallbackEntity 媒体文件上传结果上报
type FileUploadCallbackEntity struct {
Public
Data struct {
File struct {
Extension struct {
DroneModelKey string `json:"drone_model_key"`
FlightID string `json:"flight_id"`
IsOriginal bool `json:"is_original"`
PayloadModelKey string `json:"payload_model_key"`
} `json:"ext"`
Metadata struct {
AbsoluteAltitude float64 `json:"absolute_altitude"`
CreateTime string `json:"create_time"`
GimbalYawDegree float64 `json:"gimbal_yaw_degree"`
RelativeAltitude float64 `json:"relative_altitude"`
ShootPosition struct {
Latitude float64 `json:"lat"`
Longitude float64 `json:"lng"`
} `json:"shoot_position"`
} `json:"metadata"`
Name string `json:"name"`
ObjectKey string `json:"object_key"`
Path string `json:"path"`
} `json:"file"`
} `json:"data"`
}
type State struct {
Public
Data interface{} `json:"data"`
}
type Service struct {
Public
Method string `json:"method"`
Data interface{} `json:"data"`
}
type Event struct {
Public
Method string `json:"method"`
NeedReply int `json:"need_reply"`
Data interface{} `json:"data"`
}
type Status struct {
Public
Data struct {
Domain string `json:"domain"`
Type int `json:"type"`
SubType int `json:"sub_type"`
DeviceSecret string `json:"device_secret"`
Nonce string `json:"nonce"`
Version int `json:"version"`
SubDevices []struct {
Sn string `json:"sn"`
Type int `json:"type"`
SubType int `json:"sub_type"`
Index string `json:"index"`
DeviceSecret string `json:"device_secret"`
Nonce string `json:"nonce"`
Version int `json:"version"`
} `json:"sub_devices"`
} `json:"data"`
}
type StatusReply struct {
Public
Data struct {
Result int `json:"result"`
} `json:"data"`
}
type Reboot struct {
Usual
}
func (receiver *Reboot) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "device_reboot"
}
/*打开调试模式*/
type DebugOpen struct {
Usual
}
func (receiver *DebugOpen) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "debug_mode_open"
}
/*关闭调试模式*/
type DebugClose struct {
Usual
}
func (receiver *DebugClose) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "debug_mode_close"
}
type Usual struct {
Public
Data interface{} `json:"data"`
}
/*停止直播*/
type StopLive struct {
Public
Data struct {
VideoId string `json:"video_id"`
} `json:"data"`
}
func (receiver *StopLive) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "live_stop_push"
}
/*开始直播*/
type StartLive struct {
Public
Data struct {
UrlType int `json:"url_type"`
Url string `json:"url"`
VideoId string `json:"video_id"`
VideoQuality int `json:"video_quality"`
} `json:"data"`
}
func (receiver *StartLive) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "live_start_push"
}
/*打开舱盖*/
type CoverOpen struct {
Usual
}
func (receiver *CoverOpen) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "cover_open"
}
/*关闭舱盖*/
type CoverClose struct {
Usual
}
func (receiver *CoverClose) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "cover_close"
}
/*飞行器开机*/
type DroneOpen struct {
Usual
}
func (receiver *DroneOpen) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "drone_open"
}
/*飞行器开机*/
type DroneClose struct {
Usual
}
func (receiver *DroneClose) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "drone_close"
}
/*打开充电*/
type PutterOpen struct {
Usual
}
func (receiver *PutterOpen) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "putter_open"
}
type PutterClose struct {
Usual
}
func (receiver *PutterClose) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "putter_close"
}
/*打开充电*/
type ChargeOpen struct {
Usual
}
func (receiver *ChargeOpen) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "charge_open"
}
/*关闭充电*/
type ChargeClose struct {
Usual
}
func (receiver *ChargeClose) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "charge_close"
}
/*云平台向设备发送的服务具体service identifier 见物模型内容)。*/
func GetServiceTopic(gateway_sn string) string {
return "thing/product/" + gateway_sn + "/services"
}
func GetRequestsReplyTopic(gateway_sn string) string {
return "thing/product/" + gateway_sn + "/requests_reply"
}
func GetEventsReplyTopic(gateway_sn string) string {
return "thing/product/" + gateway_sn + "/StatusReply"
}
/*开始直播响应*/
type StartLiveReply struct {
Public
Data struct {
Result int `json:"result"`
Url string `json:"url"`
} `json:"data"`
}
/*开始直播响应*/
type StopLiveReply struct {
UsualReply
}
type UsualReply struct {
Public
Data struct {
Result int `json:"result"`
Output struct {
Status string `json:"status"`
} `json:"output"`
} `json:"data"`
}
/*打开补光灯*/
type Supplement_light_open struct {
Usual
}
func (receiver *Supplement_light_open) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "supplement_light_open"
}
/*关闭补光灯*/
type Supplement_light_close struct {
Usual
}
func (receiver *Supplement_light_close) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "supplement_light_close"
}
/*声光报警开关*/
type Alarm_state_switch struct {
Public
Data struct {
Action int `json:"action"` //{"0":"关闭","1":"开启"}
} `json:"data"`
}
func (receiver *Alarm_state_switch) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "alarm_state_switch"
}
/*执行任务*/
type FlighttaskExecute struct {
Public
Data struct {
FlightId string `json:"flight_id"`
} `json:"data"`
}
func (receiver *FlighttaskExecute) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "flighttask_execute"
}
/*取消任务*/
type FlighttaskUndo struct {
Public
Data struct {
Flight_ids []string `json:"flight_ids"`
} `json:"data"`
}
func (receiver *FlighttaskUndo) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "flighttask_undo"
}
/*航线暂停*/
type FlighttaskPause struct {
Usual
}
func (receiver *FlighttaskPause) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "flighttask_pause"
}
/*航线恢复*/
type FlighttaskRecovery struct {
Usual
}
func (receiver *FlighttaskRecovery) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "flighttask_recovery"
}
/*一键返航*/
type ReturnHome struct {
Usual
}
func (receiver *ReturnHome) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "return_home"
}
/*取消返航*/
type ReturnHomeCancel struct {
Usual
}
func (receiver *ReturnHomeCancel) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "return_home_cancel"
}
/*设备绑定到组织*/
type AirportOrganizationBind struct {
Public
Data struct {
BindDevices []struct {
DeviceBindingCode string `json:"device_binding_code"` //设备绑定码
OrganizationId string `json:"organization_id"` //组织id
DeviceCallsign string `json:"device_callsign"` //设备在组织的名称
Sn string `json:"sn"` //设备序列号
DeviceModelKey string `json:"device_model_key"` //产品枚举值
} `json:"bind_devices"` //绑定参数列表
} `json:"data"`
}
/*设备绑定到组织回复*/
type AirportOrganizationBindReplay struct {
Public
Data struct {
Result int `json:"result"` //直接填0
Output struct {
ErrInfos []struct {
Sn string `json:"sn"` //设备序列号
ErrCode int `json:"err_code"` //错误码 自定义,非 0 表示绑定不成功
} `json:"err_infos"`
} `json:"output"`
} `json:"data"`
}
/*查询设备绑定对应的组织信息*/
type AirportOrganizationGet struct {
Public
Data struct {
DeviceBindingCode string `json:"device_binding_code"` //设备绑定码
OrganizationId string `json:"organization_id"` //组织id
} `json:"data"`
} /*查询设备绑定对应的组织信息回复*/
type AirportOrganizationGetReplay struct {
Public
Data struct {
Result int `json:"result"`
Output struct {
OrganizationName string `json:"organization_name"` //组织名称
} `json:"output"`
} `json:"data"`
}
/*获取设备绑定信息*/
type AirportBindStatus struct {
Public
Data []struct {
Devices []struct {
Sn string `json:"sn"`
} `json:"devices"`
} `json:"data"`
}
/*获取设备绑定信息回复*/
type AirportBindStatusReplay struct {
Public
Data []struct {
Result int `json:"result"` //默认0
Output struct {
BindStatus []struct {
Sn string `json:"sn"` //设备序列号
IsDeviceBindOrganization bool `json:"is_device_bind_organization"` //设备是否绑定到组织
OrganizationId string `json:"organization_id"` //组织id
OrganizationName string `json:"organization_name"` //组织名称
DeviceCallsign string `json:"device_callsign"` //设备在组织中的名称
} `json:"bind_status"`
} `json:"output"`
} `json:"data"`
}
type FlighttaskReady struct {
Public
Data struct {
FlightIds []string `json:"flight_ids"` //当前满足任务就绪条件的任务 ID 集合
} `json:"data"`
}
type ReturnHomeInfo struct {
Public
Data struct {
FlightId string `json:"flight_id"`
LastPointType int `json:"last_point_type"`
PlannedPathPoints []struct {
Height float64 `json:"height"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
} `json:"planned_path_points"`
} `json:"data"`
}
/*下发任务*/
type FlighttaskPrepare struct {
Public
Data struct {
BreakPoint struct {
Index int `json:"index"`
Progress float64 `json:"progress"`
State int `json:"state"`
WaylineId int `json:"wayline_id"`
} `json:"break_point"`
ExecutableConditions struct {
StorageCapacity int `json:"storage_capacity"`
} `json:"executable_conditions"`
ExecuteTime int64 `json:"execute_time"`
ExitWaylineWhenRcLost int `json:"exit_wayline_when_rc_lost"`
File struct {
Fingerprint string `json:"fingerprint"`
Url string `json:"url"`
} `json:"file"`
FlightId string `json:"flight_id"`
OutOfControlAction int `json:"out_of_control_action"`
ReadyConditions struct {
BatteryCapacity int `json:"battery_capacity"`
BeginTime int64 `json:"begin_time"`
EndTime int64 `json:"end_time"`
} `json:"ready_conditions"`
RthAltitude int `json:"rth_altitude"`
RthMode int `json:"rth_mode"`
SimulateMission struct {
IsEnable int `json:"is_enable"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
} `json:"simulate_mission"`
TaskType int `json:"task_type"`
WaylineType int `json:"wayline_type"`
} `json:"data"`
}
func (receiver *FlighttaskPrepare) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = Flighttask_prepare
}
// FlighttaskPrepareRes 任务下发 cory
type FlighttaskPrepareRes struct {
Public
Data struct {
FlightId string `json:"flight_id" dc:"计划 ID"`
TaskType int `json:"task_type" dc:"任务类型"`
ExecuteTime int64 `json:"execute_time" dc:"任务类型"`
WaylineType int `json:"wayline_type" dc:"航线类型"`
File *FileEntity `json:"file" dc:"航线文件对象"`
RthAltitude int `json:"rth_altitude" dc:"返航高度" `
RthMode int `json:"rth_mode" dc:"返航高度模式"`
OutOfControlAction int `json:"out_of_control_action" dc:"遥控器失控动作"`
ExitWaylineWhenRcLost int `json:"exit_wayline_when_rc_lost" dc:"航线失控动作"`
BreakPoint *BreakPoint `json:"break_point" dc:"断点信息" `
} `json:"data"`
}
type BreakPoint struct {
Index int `json:"index" dc:"断点状态"`
State int `json:"state" dc:"返航高度模式"`
Progress float32 `json:"progress" dc:"遥控器失控动作"`
WaylineId int `json:"wayline_id" dc:"航线失控动作"`
}
type FileEntity struct {
Url string `json:"url" `
Fingerprint string `json:"fingerprint" `
}
//type FlighttaskResourceGetEntity struct {
// Data struct {
// Output *FlighttaskResourceGetTutputEntity `json:"output" `
// } `json:"data"`
//}
//type FlighttaskResourceGetTutputEntity struct {
// File *FileEntity `json:"file" dc:"航线文件对象"`
//}
func (receiver *FlighttaskPrepareRes) SetDefaultValueCory() {
receiver.SetDefault()
receiver.Method = Flighttask_prepare
}
/*任务资源获取*/
type FlighttaskResourcGet struct {
Public
Data struct {
FlightId string `json:"flight_id"`
} `json:"data"`
}
/*任务资源获取回复*/
type FlighttaskResourcGetReply struct {
Public
Data struct {
Output struct {
File struct {
Fingerprint string `json:"fingerprint"`
Url string `json:"url"`
} `json:"file"`
} `json:"output"`
Result int `json:"result"`
} `json:"data"`
}
func (receiver *FlighttaskResourcGetReply) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "flighttask_resource_get"
}
/*获取上传临时凭证*/
type StorageConfigGet struct {
Public
Data struct {
Module int `json:"module"`
} `json:"data"`
}
/*获取上传临时凭证回复*/
type StorageConfigGetReply struct {
Public
Data struct {
Output struct {
Bucket string `json:"bucket"`
Credentials struct {
AccessKeyId string `json:"access_key_id"`
AccessKeySecret string `json:"access_key_secret"`
Expire int `json:"expire"`
SecurityToken string `json:"security_token"`
} `json:"credentials"`
Endpoint string `json:"endpoint"`
ObjectKeyPrefix string `json:"object_key_prefix"`
Provider string `json:"provider"`
Region string `json:"region"`
} `json:"output"`
Result int `json:"result"`
} `json:"data"`
}
/*配置更新回复*/
type ConfigReply struct {
Public
Data struct {
AppId string `json:"app_id"`
AppKey string `json:"app_key"`
AppLicense string `json:"app_license"`
NtpServerHost string `json:"ntp_server_host"`
NtpServerPort int `json:"ntp_server_port"`
} `json:"data"`
}
// FileUpLoadListDown 获取设备可上传的文件列表 发送到mqtt
type FileUpLoadListDown struct {
Public
Data struct {
ModuleList []string `json:"module_list" dc:"文件所属过滤列表"`
} `json:"data"`
}
func (receiver *FileUpLoadListDown) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "fileupload_list"
}
// FileUpLoadListDownUp 获取设备可上传的文件列表 mqtt下发到本地服务
type FileUpLoadListDownUp struct {
Public
Data struct {
Files []struct {
DeviceSN string `json:"device_sn" dc:"设备序列号"`
List []struct {
BootIndex int `json:"boot_index" dc:"文件索引"`
EndTime int64 `json:"end_time" dc:"日志结束时间"`
Size int `json:"size" dc:"日志文件大小"`
StartTime int64 `json:"start_time" dc:"日志开始时间"`
} `json:"list" dc:"文件索引列表"`
Module string `json:"module" dc:"所属设备类型(0飞行器 2机场)"`
Result int `json:"result" dc:"返回码"`
} `json:"files" dc:"文件所属过滤列表"`
} `json:"data"`
}
// LogFileUploadReply 远程日志结构体
type LogFileUploadReply struct {
Public
Data struct {
Bucket string `json:"bucket"`
Credentials struct {
AccessKeyId string `json:"access_key_id"`
AccessKeySecret string `json:"access_key_secret"`
Expire int `json:"expire"`
SecurityToken string `json:"security_token"`
} `json:"credentials"`
Endpoint string `json:"endpoint"`
Params struct {
Files []File `json:"files"`
//Files []struct {
// List []struct {
// BootIndex int `json:"boot_index"`
// } `json:"list"`
// Module string `json:"module"`
// ObjectKey string `json:"object_key"`
//} `json:"files"`
} `json:"params"`
Provider string `json:"provider"`
Region string `json:"region"`
} `json:"data"`
}
type File struct {
List []FileList `json:"list"`
Module string `json:"module"`
ObjectKey string `json:"object_key"`
}
type FileList struct {
BootIndex int `json:"boot_index"`
}
// SetDefaultValue Minio存储服务配置
func (receiver *StorageConfigGetReply) SetDefaultValue() {
token, access, secret := MinioVoucher()
Endpoint = g.Cfg().MustGet(context.Background(), "minio.endpoint").String()
receiver.SetDefault()
receiver.Method = "storage_config_get"
receiver.Data.Result = 0
receiver.Data.Output.Bucket = BucketName
receiver.Data.Output.Credentials.AccessKeyId = access
receiver.Data.Output.Credentials.AccessKeySecret = secret
receiver.Data.Output.Credentials.Expire = int(DurationSeconds)
receiver.Data.Output.Credentials.SecurityToken = token
receiver.Data.Output.Endpoint = "http://" + Endpoint
receiver.Data.Output.Provider = "minio"
receiver.Data.Output.Region = Region
receiver.Data.Output.ObjectKeyPrefix = "uav"
}
// SetDefaultValue 配置更新
func (receiver *ConfigReply) SetDefaultValue() {
ctx := context.Background()
receiver.SetDefault()
receiver.Method = "config"
receiver.Data.AppId = g.Cfg().MustGet(ctx, "uav.config.appId").String()
receiver.Data.AppKey = g.Cfg().MustGet(ctx, "uav.config.appKey").String()
receiver.Data.AppLicense = g.Cfg().MustGet(ctx, "uav.config.appLicense").String()
receiver.Data.NtpServerHost = g.Cfg().MustGet(ctx, "uav.config.ntpServerHost").String()
receiver.Data.NtpServerPort = g.Cfg().MustGet(ctx, "uav.config.ntpServerPort").Int()
}
func (receiver *LogFileUploadReply) SetDefaultValue(rdata *FileUpLoadListDownUp) {
token, access, secret := MinioVoucher()
receiver.SetDefault()
receiver.Method = "fileupload_start"
receiver.Data.Bucket = BucketName
receiver.Data.Region = Region
receiver.Data.Credentials.AccessKeyId = access
receiver.Data.Credentials.AccessKeySecret = secret
receiver.Data.Credentials.Expire = int(DurationSeconds)
receiver.Data.Credentials.SecurityToken = token
receiver.Data.Endpoint = "http://" + coryCommon.Global + ":9999"
receiver.Data.Provider = "minio"
//fileOne := LogFileUploadReplySetDefaultValue(rdata, "0", "cory-create/log") //飞行器
fileTwo := LogFileUploadReplySetDefaultValue(rdata, "3", "log") //机场
var files []File
//files = append(files, fileOne, fileTwo)
files = append(files, fileTwo)
receiver.Data.Params.Files = files
}
func LogFileUploadReplySetDefaultValue(rdata *FileUpLoadListDownUp, num string, objectKey string) (file File) {
var fileList []FileList
for _, data := range rdata.Data.Files {
if data.Module == num {
list := data.List
for i := range list {
if list[i].BootIndex == 3743 { //从2024-04-28 15:15:19 开始
fileList = append(fileList, FileList{
BootIndex: list[i].BootIndex,
})
}
}
//err := copier.Copy(&fileList, &list)
//if err != nil {
// return
//}
}
}
file.List = fileList
file.Module = num
file.ObjectKey = objectKey
return
}
/*负载控制—单拍*/
type CameraPhotoTake struct {
Public
Data struct {
PayloadIndex string `json:"payload_index"`
} `json:"data"`
}
func (receiver *CameraPhotoTake) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "camera_photo_take"
}
/*负载控制—重置云台*/
type GimbalReset struct {
Public
Data struct {
PayloadIndex string `json:"payload_index" dc:"负载编号,相机枚举值。非标准的 device_mode_key格式为 {type-subtype-gimbalindex}"`
ResetMode int `json:"reset_mode" dc:"{0回中 1向下 2偏航回中 3俯仰向下}"`
} `json:"data"`
}
func (receiver *GimbalReset) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "gimbal_reset"
}
/*设置直播清晰度*/
type LiveSetQuality struct {
Public
Data struct {
VideoId string `json:"video_id"`
VideoQuality int `json:"video_quality"`
} `json:"data"`
}
func (receiver *LiveSetQuality) SetDefaultValue() {
receiver.SetDefault()
receiver.Method = "live_set_quality"
}
/*负载控制—单拍 响应恢复*/
type CameraPhotoTakeReply struct {
Public
Data struct {
Result int `json:"result"`
} `json:"data"`
}
/*航线执行进度上报*/
type WaylineProgress struct {
Public
Data struct {
Output struct {
Ext struct {
BreakPoint struct {
AttitudeHead float64 `json:"attitude_head"`
BreakReason int `json:"break_reason"`
Height float64 `json:"height"`
Index int `json:"index"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Progress float64 `json:"progress"`
State int `json:"state"`
WaylineId int `json:"wayline_id"`
} `json:"break_point"`
CurrentWaypointIndex int `json:"current_waypoint_index"`
FlightId string `json:"flight_id"`
MediaCount int `json:"media_count"`
TrackId string `json:"track_id"`
WaylineId int `json:"wayline_id"`
WaylineMissionState int `json:"wayline_mission_state"`
} `json:"ext"`
Progress struct {
CurrentStep int `json:"current_step"`
Percent int `json:"percent"`
} `json:"progress"`
Status string `json:"status"`
} `json:"output"`
Result int `json:"result"`
} `json:"data"`
}
type CoordinateEntity struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
}
type Point struct {
CoordinateEntity
Height float64 `json:"height"`
}
// TakeoffToPoint /*飞向目标点*/
type TakeoffToPoint struct {
Public
Data struct {
CommanderFlightHeight int `json:"commander_flight_height"`
CommanderModeLostAction int `json:"commander_mode_lost_action"`
FlightId string `json:"flight_id"`
MaxSpeed int `json:"max_speed"`
RcLostAction int `json:"rc_lost_action"`
RthAltitude int `json:"rth_altitude"`
SecurityTakeoffHeight int `json:"security_takeoff_height"`
TargetHeight int `json:"target_height"`
TargetLatitude float64 `json:"target_latitude"`
TargetLongitude float64 `json:"target_longitude"`
} `json:"data"`
}
func (t *TakeoffToPoint) SetDefaultValue() {
t.SetDefault()
t.Method = Takeoff_to_point
}
/*飞向目标点*/
type FlyToPoint struct {
Public
Data struct {
FlyToId string `json:"fly_to_id"`
MaxSpeed int `json:"max_speed"`
Points []Point `json:"points"`
} `json:"data"`
}
func (t *FlyToPoint) SetDefaultValue() {
t.SetDefault()
t.Method = Fly_to_point
}
type FlyToPointStop struct {
Public
Data struct{} `json:"data"`
}
func (t *FlyToPointStop) SetDefaultValue() {
t.SetDefault()
t.Method = Fly_to_point_stop
}
// FlyToPointProgress /*飞向目标点的结果通知*/
type FlyToPointProgress struct {
Public
Data struct {
FlyToId string `json:"fly_to_id"`
PlannedPathPoints []struct {
Height float64 `json:"height"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
} `json:"planned_path_points"`
RemainingDistance int `json:"remaining_distance"`
RemainingTime int `json:"remaining_time"`
Result int `json:"result"`
Status string `json:"status"`
WayPointIndex int `json:"way_point_index"`
} `json:"data"`
}
type FlightAuthorityGrab struct {
Public
Data struct{} `json:"data"`
}
func (t *FlightAuthorityGrab) SetDefaultValue() {
t.SetDefault()
t.Method = Flight_authority_grab
}
type SpeakerTtsPlayStart struct {
Public
Data struct {
PsdkIndex int `json:"psdk_index"`
Tts struct {
Md5 string `json:"md5"`
Name string `json:"name"`
Text string `json:"text"`
} `json:"tts"`
} `json:"data"`
}
func (t *SpeakerTtsPlayStart) SetDefaultValue() {
t.SetDefault()
t.Method = Speaker_tts_play_start
}
type SpeakerAudioPlayStart struct {
Public
Data struct {
PsdkIndex int `json:"psdk_index" dc:"psdk 负载设备索引默认0"`
File struct {
Name string `json:"name"`
Url string `json:"url"`
Md5 string `json:"md5"`
Format string `json:"format"`
} `json:"file"`
} `json:"data"`
}
func (t *SpeakerAudioPlayStart) SetDefaultValue() {
t.SetDefault()
t.Method = Speaker_audio_play_start
}
// OtaCreateEntity 固件升级实体
type OtaCreateEntity struct {
Public
Data struct {
DeviceList []OtaCreateDevice `json:"devices"`
} `json:"data"`
}
type OtaCreateDevice struct {
FileName string `json:"file_name"` // 文件名(可选字段)
FileSize int64 `json:"file_size"` // 文件大小(可选字段,建议使用 int64 表示字节)
FileURL string `json:"file_url"` // 文件 URL可选字段
FirmwareUpgradeType int `json:"firmware_upgrade_type"` // 固件升级类型(必填字段)
MD5 string `json:"md5"` // MD5 校验码(可选字段)
ProductVersion string `json:"product_version"` // 产品版本(必填字段)
SN string `json:"sn"` // 设备序列号(必填字段)
}
func (t *OtaCreateEntity) SetDefaultValue() {
t.SetDefault()
t.Method = OtaCreate
}