81 lines
3.1 KiB
C#
81 lines
3.1 KiB
C#
using System.Collections.Generic;
|
||
using Newtonsoft.Json;
|
||
|
||
namespace FlieOperate
|
||
{
|
||
/// <summary>
|
||
/// 飞行魔方地面站 fcgm Json文件层级 结构模型
|
||
/// </summary>
|
||
public class FcgmJsonModel
|
||
{
|
||
public string ID { get; set; }
|
||
public string ver { get; set; }
|
||
public int coptercount { get; set; }
|
||
public int taskcount { get; set; }
|
||
public List<Groups> groups { get; set; }
|
||
public class Groups
|
||
{
|
||
public string groupName { get; set; }
|
||
public List<int> copterIndexList { get; set; }
|
||
}
|
||
public List<List<double>> locate { get; set; }
|
||
public List<Tasks> tasks { get; set; }
|
||
public class Tasks
|
||
{
|
||
public int type { get; set; }//100:起飞 0:普通航点 6:降落
|
||
public int takeoffnumber { get; set; }//起飞任务独有
|
||
public int takeoffTime { get; set; }//起飞任务独有
|
||
public bool staggerRoutes { get; set; }
|
||
public int flytoTime { get; set; }
|
||
public int loiterTime { get; set; }
|
||
public string taskname { get; set; }
|
||
public List<SingleCopterInfos> singleCopterInfos { get; set; }
|
||
public class SingleCopterInfos
|
||
{
|
||
public int waitTime { get; set; }//起飞降落 独有
|
||
public double x { get; set; }
|
||
public double y { get; set; }
|
||
public double targetAlt { get; set; }
|
||
public List<LedInfos> ledInfos { get; set; }
|
||
public class LedInfos
|
||
{
|
||
public double Delay { get; set; }
|
||
public int LEDMode { get; set; }
|
||
public double LEDInterval { get; set; }
|
||
public int LEDRate { get; set; }
|
||
public int LEDTimes { get; set; }
|
||
public string LEDRGB { get; set; }
|
||
}
|
||
public bool isLandWaypoint { get; set; }//返航点
|
||
public bool isChangeSpeed { get; set; }//改变速度
|
||
public double levelSpeed { get; set; }
|
||
public double upSpeed { get; set; }
|
||
public double downSpeed { get; set; }
|
||
}
|
||
}
|
||
}
|
||
public class JsonBase
|
||
{
|
||
/// <summary>
|
||
/// 航点文件转存到FcgmJsonModel对象里面 反序列化
|
||
/// </summary>
|
||
/// <param name="FliePath">航点文件路径</param>
|
||
/// <returns>航点FcgmJsonModel对象</returns>
|
||
public static FcgmJsonModel JsonToModel(string FliePath)
|
||
{
|
||
string str = FileBase.ReadFlieToStr(FliePath);
|
||
FcgmJsonModel fcgmModel = JsonConvert.DeserializeObject<FcgmJsonModel>(str);//反系列化
|
||
return fcgmModel;
|
||
}
|
||
/// <summary>
|
||
/// FcgmJsonModel对象 序列化 成 json
|
||
/// </summary>
|
||
/// <param name="fcgmJsonModel"></param>
|
||
/// <returns></returns>
|
||
public static string ModelTojson(FcgmJsonModel fcgmJsonModel)
|
||
{
|
||
return JsonConvert.SerializeObject(fcgmJsonModel); //转为字符串
|
||
}
|
||
}
|
||
}
|