private MyObjectBuilder_CubeGrid BuildShipEntity() { var entity = new MyObjectBuilder_CubeGrid { EntityId = SpaceEngineersApi.GenerateEntityId(IDType.ENTITY), PersistentFlags = MyPersistentEntityFlags2.CastShadows | MyPersistentEntityFlags2.InScene, Skeleton = new System.Collections.Generic.List <BoneInfo>(), LinearVelocity = new VRageMath.Vector3(0, 0, 0), AngularVelocity = new VRageMath.Vector3(0, 0, 0) }; var blockPrefix = ""; switch (ClassType) { case ImportModelClassType.SmallShip: entity.GridSizeEnum = MyCubeSize.Small; blockPrefix += "Small"; entity.IsStatic = false; break; case ImportModelClassType.LargeShip: entity.GridSizeEnum = MyCubeSize.Large; blockPrefix += "Large"; entity.IsStatic = false; break; case ImportModelClassType.Station: entity.GridSizeEnum = MyCubeSize.Large; blockPrefix += "Large"; entity.IsStatic = true; Position = Position.RoundOff(MyCubeSize.Large.ToLength()); Forward = Forward.RoundToAxis(); Up = Up.RoundToAxis(); break; } switch (ArmorType) { case ImportArmorType.Heavy: blockPrefix += "HeavyBlockArmor"; break; case ImportArmorType.Light: blockPrefix += "BlockArmor"; break; // TODO: Rounded Armor. // Currently in development, and only specified as 'Light' on the 'Large' structures. //case ImportArmorType.Round: blockPrefix += "RoundArmor_"; break; } // Large|BlockArmor|Corner // Large|RoundArmor_|Corner // Large|HeavyBlockArmor|Block, // Small|BlockArmor|Slope, // Small|HeavyBlockArmor|Corner, var blockType = (SubtypeId)Enum.Parse(typeof(SubtypeId), blockPrefix + "Block"); var slopeBlockType = (SubtypeId)Enum.Parse(typeof(SubtypeId), blockPrefix + "Slope"); var cornerBlockType = (SubtypeId)Enum.Parse(typeof(SubtypeId), blockPrefix + "Corner"); var inverseCornerBlockType = (SubtypeId)Enum.Parse(typeof(SubtypeId), blockPrefix + "CornerInv"); entity.CubeBlocks = new System.Collections.Generic.List <MyObjectBuilder_CubeBlock>(); double multiplier; if (IsMultipleScale) { multiplier = MultipleScale; } else { multiplier = MaxLengthScale / Math.Max(Math.Max(OriginalModelSize.Height, OriginalModelSize.Width), OriginalModelSize.Depth); } var ccubic = Modelling.ReadModelVolmetic(Filename, multiplier, null, TraceType, MainViewModel.ResetProgress, MainViewModel.IncrementProgress); Modelling.BuildStructureFromCubic(entity, ccubic, FillObject, blockType, slopeBlockType, cornerBlockType, inverseCornerBlockType); MainViewModel.ClearProgress(); entity.PositionAndOrientation = new MyPositionAndOrientation { // TODO: reposition based scale. Position = Position.ToVector3D(), Forward = Forward.ToVector3(), Up = Up.ToVector3() }; IsValidModel = entity.CubeBlocks.Count > 0; return(entity); }
public void Write(BinaryWriterEx output) { Aside.Write(output); Up.Write(output); Dir.Write(output); }
public void Rotate(Vector3 axis, float angle) { Direction = Direction.Rotate(axis, angle); Up = Up.Rotate(axis, angle); }
// 处理COUT类型数据 private void DealCOUT(string msg) // private String DealCOUT(string msg) { string result = null; InvokeMessage("通信输出 " + msg, "接收"); SendBackTTCAString = msg; if (msg.Contains("COUT")) { if (msg.Contains("COUT")) { num = num + 1; FileStream fs = new FileStream("numbd.txt", FileMode.Create); StreamWriter sw = new StreamWriter(fs); //开始写入 sw.Write(num); //清空缓冲区 sw.Flush(); //关闭流 sw.Close(); fs.Close(); } } // InvokeString(msg); var cout = BeidouHelper.GetCOUTInfo(msg); if (cout == null) { return; } // return result; // 发送COSS指令 // 必须在1秒内发送给卫星终端,否则会重新发送“通信输出” var coss = new CCOSSStruct(); coss.SuccessStatus = true; // 终端接收到外设通信申请,并校验成功 SendCOSS(coss); // 发送CACA指令 // 每隔一分钟发送回执$CACA // 65秒左右发一条 var caca = new CCACAStruct(); caca.SenderID = "1"; // 发信方ID为1,表示本机ID,默认 caca.RecvType = cout.SenderType; // 回执的收信方类型 == 通信输出中的发信方类型 caca.RecvAddr = cout.SenderAddr; // 回执的收信方地址 == 通信输出中的发信方地址 caca.Requirements = "1"; // 不保密 caca.ReceiptMsgSequenceNum = cout.MsgSequenceNum; // 回执的报文顺序号 == 通信输出中的报文顺序号 caca.ReceiptContent = "1"; SendCACA(caca); // 解析通信输出中的内容 string content = cout.MsgContent; //通信输出gm8 $60131G2201161111040003046112271367 try { string rawMsg = content; string sid = null; string dealMsg = ProtocolHelpers.dealBCD(rawMsg); InvokeMessage("COUT数据 " + dealMsg, "接收"); WriteToFileClass writeClass = new WriteToFileClass("ReceivedLog"); Thread t = new Thread(new ParameterizedThreadStart(writeClass.WriteInfoToFile)); t.Start("COUT Message: " + " " + dealMsg + "\r\n"); string bdid = cout.SenderAddr; //InvokeMessage("gm3 " + content, "接收"); //sid需要根据北斗卫星号获取 try { sid = Manager.XmlStationData.Instance.GetStationByBDID(bdid); } catch (Exception e) { sid = "5712"; Debug.WriteLine("获取站号失败" + e.Message); } EMessageType type = ProtocolMaps.MessageTypeMap.FindKey(dealMsg.Substring(0, 2)); string reportType = dealMsg.Substring(0, 2); if (reportType == "21" || reportType == "22") // 定时报,加报 { // YAC设备的墒情协议: string stationType = dealMsg.Substring(2, 2); switch (stationType) { // 站类为04时墒情站 05墒情雨量站 06,16墒情水位站 07,17墒情水文站 case "04": case "05": case "06": case "07": case "17": { // var station = FindStationByBeidouID(cout.SenderAddr); // string currentMsg = rawMsg.Insert(0, "$" + station.StationID + "1G"); // CEntitySoilData soil = new CEntitySoilData(); // CReportStruct soilReport = new CReportStruct(); // if (Soil.Parse(currentMsg, out soil, out soilReport)) // { // soil.ChannelType = EChannelType.BeiDou; // if (null != this.SoilDataReceived) // this.SoilDataReceived(null, new CEventSingleArgs<CEntitySoilData>(soil)); // if (null != soilReport && null != this.UpDataReceived) // { // soilReport.ChannelType = EChannelType.BeiDou; // soilReport.ListenPort = "COM" + this.Port.PortName; // this.UpDataReceived(null, new UpEventArgs() { RawData = rawMsg, Value = soilReport }); // } // } //} //1111gm string newMsg = dealMsg.Substring(1, dealMsg.Length - 1); CEntitySoilData soil = new CEntitySoilData(); CReportStruct soilReport = new CReportStruct(); if (Soil.Parse(newMsg, out soil, out soilReport)) { soilReport.ChannelType = EChannelType.BeiDou; if (null != this.SoilDataReceived) { this.SoilDataReceived(null, new CEventSingleArgs <CEntitySoilData>(soil)); } if (null != soilReport && null != this.UpDataReceived) { soilReport.ChannelType = EChannelType.GPRS; soilReport.ListenPort = "COM" + this.Port.PortName; soilReport.flagId = bdid; this.UpDataReceived(null, new UpEventArgs() { RawData = newMsg, Value = soilReport }); } } } break; // 站类为01,02,03,12,13时,不是墒情站 case "01": case "02": case "03": case "12": case "13": { //1111gm //string newMsg = dealMsg.Substring(1, dealMsg.Length - 1); //CReportStruct report = new CReportStruct(); //if (Up.Parse(newMsg, out report)) //{ // //6013 $60131G2201161111040003046112271367 // report.ChannelType = EChannelType.BeiDou; // report.ListenPort = "COM" + this.Port.PortName; // if (this.UpDataReceived != null) // { // this.UpDataReceived.Invoke(null, new UpEventArgs() { Value = report, RawData = newMsg }); // } //} CReportStruct report = new CReportStruct(); string protocol = Manager.XmlStationData.Instance.GetProtocolBySId(sid); if (protocol == "YNXY") { Up = new Data.YNXY.UpParser(); } else if (protocol == "ZYJBX") { Up = new UpParser(); } if (Up.Parse_beidou(sid, type, rawMsg, out report)) { //InvokeMessage("gm6 " + rawMsg, "接收"); //$60131G2201161111040003046112271367 report.ChannelType = EChannelType.BeiDou; report.ListenPort = "COM" + this.Port.PortName; report.flagId = bdid; if (this.UpDataReceived != null) { //InvokeMessage("gm7 " + rawMsg, "接收"); this.UpDataReceived.Invoke(null, new UpEventArgs() { Value = report, RawData = rawMsg }); } } } break; default: break; } } else if (reportType == "11") // 人工水位 { } else if (reportType == "23") // 人工流量 { } else if (reportType == "25") { var station = FindStationByBeidouID(cout.SenderAddr); string currentMsg = dealMsg.Insert(0, "$" + station.StationID + "1G"); CEntitySoilData soil = new CEntitySoilData(); CReportStruct soilReport = new CReportStruct(); if (Soil.Parse(currentMsg, out soil, out soilReport)) { soil.ChannelType = EChannelType.BeiDou; if (null != this.SoilDataReceived) { this.SoilDataReceived(null, new CEventSingleArgs <CEntitySoilData>(soil)); } if (null != soilReport && null != this.UpDataReceived) { soilReport.ChannelType = EChannelType.BeiDou; soilReport.ListenPort = "COM" + this.Port.PortName; soilReport.flagId = bdid; this.UpDataReceived(null, new UpEventArgs() { RawData = dealMsg, Value = soilReport }); } } } } catch (Exception exp) { System.Diagnostics.Debug.WriteLine("Beidou 数据解析出错 !" + content + "\r\n" + exp.Message); } //result = msg; //return result; }
public MyObjectBuilder_CubeGrid BuildEntity() { var entity = new MyObjectBuilder_CubeGrid { EntityId = SpaceEngineersApi.GenerateEntityId(IDType.ENTITY), PersistentFlags = MyPersistentEntityFlags2.CastShadows | MyPersistentEntityFlags2.InScene, Skeleton = new System.Collections.Generic.List <BoneInfo>(), LinearVelocity = new VRageMath.Vector3(0, 0, 0), AngularVelocity = new VRageMath.Vector3(0, 0, 0) }; var blockPrefix = ""; switch (ClassType) { case ImportImageClassType.SmallShip: entity.GridSizeEnum = MyCubeSize.Small; blockPrefix += "Small"; entity.IsStatic = false; break; case ImportImageClassType.LargeShip: entity.GridSizeEnum = MyCubeSize.Large; blockPrefix += "Large"; entity.IsStatic = false; break; case ImportImageClassType.Station: entity.GridSizeEnum = MyCubeSize.Large; blockPrefix += "Large"; entity.IsStatic = true; Position = Position.RoundOff(MyCubeSize.Large.ToLength()); Forward = Forward.RoundToAxis(); Up = Up.RoundToAxis(); break; } switch (ArmorType) { case ImportArmorType.Heavy: blockPrefix += "HeavyBlockArmor"; break; case ImportArmorType.Light: blockPrefix += "BlockArmor"; break; } entity.PositionAndOrientation = new MyPositionAndOrientation { // TODO: reposition based scale. Position = Position.ToVector3D(), Forward = Forward.ToVector3(), Up = Up.ToVector3() }; // Large|BlockArmor|Corner // Large|RoundArmor_|Corner // Large|HeavyBlockArmor|Block, // Small|BlockArmor|Slope, // Small|HeavyBlockArmor|Corner, entity.CubeBlocks = new System.Collections.Generic.List <MyObjectBuilder_CubeBlock>(); var image = ImageHelper.ResizeImage(_sourceImage, NewImageSize.Size); using (var palatteImage = new Bitmap(image)) { // Optimal order load. from grid coordinate (0,0,0) and up. for (var x = palatteImage.Width - 1; x >= 0; x--) { for (var y = palatteImage.Height - 1; y >= 0; y--) { const int z = 0; var color = palatteImage.GetPixel(x, y); // Specifically ignore anything with less than half "Transparent" Alpha. if (IsAlphaLevel && color.A < AlphaLevel) { continue; } if (IsKeyColor && color.R == KeyColor.R && color.G == KeyColor.G && color.B == KeyColor.B) { continue; } // Parse the string through the Enumeration to check that the 'subtypeid' is still valid in the game engine. var armor = (SubtypeId)Enum.Parse(typeof(SubtypeId), blockPrefix + "Block"); MyObjectBuilder_CubeBlock newCube; entity.CubeBlocks.Add(newCube = new MyObjectBuilder_CubeBlock()); newCube.SubtypeName = armor.ToString(); newCube.EntityId = 0; newCube.BlockOrientation = Modelling.GetCubeOrientation(CubeType.Cube); newCube.Min = new VRageMath.Vector3I(palatteImage.Width - x - 1, palatteImage.Height - y - 1, z); newCube.ColorMaskHSV = color.ToSandboxHsvColor(); } } } return(entity); }
public void Rotate(RotatingCoordinate coordinate, bool clockwise = true, int count = 1) { for (var i = 0; i < count; i++) { var downCopy = Down.Copy(); var frontCopy = Front.Copy(); var backCopy = Back.Copy(); var upCopy = Up.Copy(); var leftCopy = Left.Copy(); var rightCopy = Right.Copy(); switch (coordinate) { case RotatingCoordinate.X: { if (clockwise) { Front = downCopy; Front.TurnType = downCopy.TurnType; Down = backCopy; Down.TurnType = backCopy.TurnType; Back = upCopy; Back.TurnType = upCopy.TurnType; Up = frontCopy; Up.TurnType = frontCopy.TurnType; Right[0, 0] = rightCopy[0, 2]; Right[0, 1] = rightCopy[1, 2]; Right[0, 2] = rightCopy[2, 2]; Right[1, 2] = rightCopy[2, 1]; Right[2, 2] = rightCopy[2, 0]; Right[2, 1] = rightCopy[1, 0]; Right[2, 0] = rightCopy[0, 0]; Right[1, 0] = rightCopy[0, 1]; Left[0, 0] = leftCopy[2, 0]; Left[1, 0] = leftCopy[2, 1]; Left[2, 0] = leftCopy[2, 2]; Left[2, 1] = leftCopy[1, 2]; Left[2, 2] = leftCopy[0, 2]; Left[1, 2] = leftCopy[0, 1]; Left[0, 2] = leftCopy[0, 0]; Left[0, 1] = leftCopy[1, 0]; } else { Front = upCopy; Front.TurnType = upCopy.TurnType; Up = backCopy; Up.TurnType = backCopy.TurnType; Back = downCopy; Back.TurnType = downCopy.TurnType; Down = frontCopy; Down.TurnType = frontCopy.TurnType; Right[0, 0] = rightCopy[2, 0]; Right[1, 0] = rightCopy[2, 1]; Right[2, 0] = rightCopy[2, 2]; Right[2, 1] = rightCopy[1, 2]; Right[2, 2] = rightCopy[0, 2]; Right[1, 2] = rightCopy[0, 1]; Right[0, 2] = rightCopy[0, 0]; Right[0, 1] = rightCopy[1, 0]; Left[0, 0] = leftCopy[0, 2]; Left[0, 1] = leftCopy[1, 2]; Left[0, 2] = leftCopy[2, 2]; Left[1, 2] = leftCopy[2, 1]; Left[2, 2] = leftCopy[2, 0]; Left[2, 1] = leftCopy[1, 0]; Left[2, 0] = leftCopy[0, 0]; Left[1, 0] = leftCopy[0, 1]; } break; } case RotatingCoordinate.Y: { if (clockwise) { Front = rightCopy; Front.TurnType = rightCopy.TurnType; Right = backCopy; Right.TurnType = backCopy.TurnType; Left = frontCopy; Left.TurnType = frontCopy.TurnType; Back = leftCopy; Back.TurnType = leftCopy.TurnType; Up[0, 0] = upCopy[0, 2]; Up[0, 1] = upCopy[1, 2]; Up[0, 2] = upCopy[2, 2]; Up[1, 2] = upCopy[2, 1]; Up[2, 2] = upCopy[2, 0]; Up[2, 1] = upCopy[1, 0]; Up[2, 0] = upCopy[0, 0]; Up[1, 0] = upCopy[0, 1]; Down[0, 0] = downCopy[2, 0]; Down[1, 0] = downCopy[2, 1]; Down[2, 0] = downCopy[2, 2]; Down[2, 1] = downCopy[1, 2]; Down[2, 2] = downCopy[0, 2]; Down[1, 2] = downCopy[0, 1]; Down[0, 2] = downCopy[0, 0]; Down[0, 1] = downCopy[1, 0]; } else { Front = leftCopy; Front.TurnType = leftCopy.TurnType; Right = frontCopy; Right.TurnType = frontCopy.TurnType; Back = rightCopy; Back.TurnType = rightCopy.TurnType; Left = backCopy; Left.TurnType = backCopy.TurnType; Up[0, 0] = upCopy[2, 0]; Up[1, 0] = upCopy[2, 1]; Up[2, 0] = upCopy[2, 2]; Up[2, 1] = upCopy[1, 2]; Up[2, 2] = upCopy[0, 2]; Up[1, 2] = upCopy[0, 1]; Up[0, 2] = upCopy[0, 0]; Up[0, 1] = upCopy[1, 0]; Down[0, 0] = downCopy[0, 2]; Down[0, 1] = downCopy[1, 2]; Down[0, 2] = downCopy[2, 2]; Down[1, 2] = downCopy[2, 1]; Down[2, 2] = downCopy[2, 0]; Down[2, 1] = downCopy[1, 0]; Down[2, 0] = downCopy[0, 0]; Down[1, 0] = downCopy[0, 1]; } break; } case RotatingCoordinate.Z: { if (clockwise) { Left = downCopy; Left.TurnType = downCopy.TurnType; Down = rightCopy; Down.TurnType = rightCopy.TurnType; Right = upCopy; Right.TurnType = upCopy.TurnType; Up = leftCopy; Up.TurnType = leftCopy.TurnType; Front[0, 0] = frontCopy[2, 0]; Front[1, 0] = frontCopy[2, 1]; Front[2, 0] = frontCopy[2, 2]; Front[2, 1] = frontCopy[1, 2]; Front[2, 2] = frontCopy[0, 2]; Front[1, 2] = frontCopy[0, 1]; Front[0, 2] = frontCopy[0, 0]; Front[0, 1] = frontCopy[1, 0]; Back[0, 0] = backCopy[0, 2]; Back[0, 1] = backCopy[1, 2]; Back[0, 2] = backCopy[2, 2]; Back[1, 2] = backCopy[2, 1]; Back[2, 2] = backCopy[2, 0]; Back[2, 1] = backCopy[1, 0]; Back[2, 0] = backCopy[0, 0]; Back[1, 0] = backCopy[0, 1]; } else { Left = upCopy; Left.TurnType = upCopy.TurnType; Up = rightCopy; Up.TurnType = rightCopy.TurnType; Right = downCopy; Right.TurnType = downCopy.TurnType; Down = leftCopy; Down.TurnType = leftCopy.TurnType; Front[0, 0] = frontCopy[0, 2]; Front[0, 1] = frontCopy[1, 2]; Front[0, 2] = frontCopy[2, 2]; Front[1, 2] = frontCopy[2, 1]; Front[2, 2] = frontCopy[2, 0]; Front[2, 1] = frontCopy[1, 0]; Front[2, 0] = frontCopy[0, 0]; Front[1, 0] = frontCopy[0, 1]; Back[0, 0] = backCopy[2, 0]; Back[1, 0] = backCopy[2, 1]; Back[2, 0] = backCopy[2, 2]; Back[2, 1] = backCopy[1, 2]; Back[2, 2] = backCopy[0, 2]; Back[1, 2] = backCopy[0, 1]; Back[0, 2] = backCopy[0, 0]; Back[0, 1] = backCopy[1, 0]; } break; } } } }
public void Normalize() { Direction.Normalize(); Up.Normalize(); Up = (Direction ^ Up) ^ Direction; }
/// <summary> /// Populate values from the base palette. /// </summary> public void PopulateFromBase() { Up.PopulateFromBase(); Down.PopulateFromBase(); DropDown.PopulateFromBase(); }
private void CalculateUvw() { W = Direction; U = Up.Cross(W).Normalize(); V = W.Cross(U).Normalize(); }
private void OnUp(KeyboardEventArgs value) { Up?.Invoke(this, value, PushToThreadPool); }
public static void OnUp(Point p) { Up?.Invoke(p); _panJustBegun = false; }
/// <summary> /// Strafe up with respect to camera /// </summary> /// <param name="amount"></param> public void StrafeVert(float amount) { Up.Normalize(); Position += Up * amount; }
// 处理通信输出 COUT类型数据 public void DealCOUT(string msg) { InvokeMessage("通信输出 " + msg, "接收"); string str = msg.Trim(); if (str.Contains("COUT")) { if (str.Contains("COUT")) { num = num + 1; FileStream fs = new FileStream("numbd.txt", FileMode.Create); StreamWriter sw = new StreamWriter(fs); //开始写入 sw.Write(num); //清空缓冲区 sw.Flush(); //关闭流 sw.Close(); fs.Close(); } } var cout = Beidou500Helper.GetCOUTInfo(msg); //InvokeMessage("gm1 " + "通过截取", "接收"); if (cout == null) { //InvokeMessage("gm2 " + "通过截取", "接收"); return; } //TODO //需要处理dealbcd码的走这里 // 解析通信输出中的内容 string content = cout.MsgContent; List <CUpReport> reports = new List <CUpReport>(); //TODO //添加调用代码 try { string rawMsg = content; string sid = null; string dealMsg = ProtocolHelpers.dealBCD(rawMsg); InvokeMessage("COUT数据 " + dealMsg, "接收"); WriteToFileClass writeClass = new WriteToFileClass("ReceivedLog"); Thread t = new Thread(new ParameterizedThreadStart(writeClass.WriteInfoToFile)); t.Start("COUT Message: " + " " + dealMsg + "\r\n"); //InvokeMessage("gm3 " + content, "接收"); //sid需要根据北斗卫星号获取 try { string bdid = cout.SenderAddr; sid = Manager.XmlStationData.Instance.GetStationByBDID(bdid); } catch (Exception e) { sid = "5712"; Debug.WriteLine("获取站号失败" + e.Message); } EMessageType type = ProtocolMaps.MessageTypeMap.FindKey(dealMsg.Substring(0, 2)); string reportType = dealMsg.Substring(0, 2); //InvokeMessage("gm4 " + reportType, "接收"); if (reportType == "21" || reportType == "22") // 定时报,加报 { // YAC设备的墒情协议: string stationType = dealMsg.Substring(2, 2); //InvokeMessage("gm5 " + stationType, "接收"); switch (stationType) { // 站类为04时墒情站 05墒情雨量站 06,16墒情水位站 07,17墒情水文站 case "04": case "05": case "06": case "07": case "17": { //var station = FindStationByBeidouID(cout.SenderAddr); //string currentMsg = rawMsg.Insert(0, "$" + station.StationID + "1G"); //CEntitySoilData soil = new CEntitySoilData(); //CReportStruct soilReport = new CReportStruct(); //if (Soil.Parse(currentMsg, out soil, out soilReport)) //{ // soil.ChannelType = EChannelType.BeiDou; // if (null != this.SoilDataReceived) // this.SoilDataReceived(null, new CEventSingleArgs<CEntitySoilData>(soil)); // if (null != soilReport && null != this.UpDataReceived) // { // soilReport.ChannelType = EChannelType.BeiDou; // soilReport.ListenPort = "COM" + this.Port.PortName; // this.UpDataReceived(null, new UpEventArgs() { RawData = rawMsg, Value = soilReport }); // } //} // string newMsg = rawMsg.Substring(1, rawMsg.Length - 1); CEntitySoilData soil = new CEntitySoilData(); CReportStruct soilReport = new CReportStruct(); if (Soil.Parse(rawMsg, out soil, out soilReport)) { soilReport.ChannelType = EChannelType.BeiDou; if (null != this.SoilDataReceived) { this.SoilDataReceived(null, new CEventSingleArgs <CEntitySoilData>(soil)); } if (null != soilReport && null != this.UpDataReceived) { soilReport.ChannelType = EChannelType.GPRS; soilReport.ListenPort = "COM" + this.Port.PortName; this.UpDataReceived(null, new UpEventArgs() { RawData = rawMsg, Value = soilReport }); } } } break; // 站类为01,02,03,12,13时,不是墒情站 case "01": case "02": case "03": case "12": case "13": { //var station = FindStationByBeidouID(cout.SenderAddr); //rawMsg = rawMsg.Insert(0, station.StationID + " "); //CReportStruct report = new CReportStruct(); //if (Up.Parse(rawMsg, out report)) //{ // report.ChannelType = EChannelType.BeiDou; // report.ListenPort = "COM" + this.Port.PortName; // if (this.UpDataReceived != null) // this.UpDataReceived.Invoke(null, new UpEventArgs() { Value = report, RawData = msg }); //} //string newMsg = rawMsg.Substring(1, rawMsg.Length - 1); CReportStruct report = new CReportStruct(); string protocol = Manager.XmlStationData.Instance.GetProtocolBySId(sid); if (protocol == "YNXY") { Up = new Data.YNXY.UpParser(); } else if (protocol == "ZYJBX") { Up = new UpParser(); } if (Up.Parse_beidou(sid, type, rawMsg, out report)) { //InvokeMessage("gm6 " + rawMsg, "接收"); //$60131G2201161111040003046112271367 report.ChannelType = EChannelType.BeiDou; report.ListenPort = "COM" + this.Port.PortName; if (this.UpDataReceived != null) { //InvokeMessage("gm7 " + rawMsg, "接收"); this.UpDataReceived.Invoke(null, new UpEventArgs() { Value = report, RawData = rawMsg }); } } } break; default: break; } } else if (reportType == "11") // 人工水位 { } else if (reportType == "23") // 人工流量 { } else if (reportType == "25") { var station = FindStationByBeidouID(cout.SenderAddr); string currentMsg = rawMsg.Insert(0, "$" + station.StationID + "1G"); CEntitySoilData soil = new CEntitySoilData(); CReportStruct soilReport = new CReportStruct(); if (Soil.Parse(currentMsg, out soil, out soilReport)) { soil.ChannelType = EChannelType.BeiDou; if (null != this.SoilDataReceived) { this.SoilDataReceived(null, new CEventSingleArgs <CEntitySoilData>(soil)); } if (null != soilReport && null != this.UpDataReceived) { soilReport.ChannelType = EChannelType.BeiDou; soilReport.ListenPort = "COM" + this.Port.PortName; this.UpDataReceived(null, new UpEventArgs() { RawData = rawMsg, Value = soilReport }); } } } } catch (Exception exp) { System.Diagnostics.Debug.WriteLine("北斗卫星指挥机 数据解析出错 !" + content + "\r\n" + exp.Message); } }
private void DealData() { while (true) { m_semaphoreData.WaitOne(); //阻塞当前线程,知道被其它线程唤醒 // 获取对data内存缓存的访问权 m_mutexListDatas.WaitOne(); List <HDModemDataStruct> dataListTmp = m_listDatas; m_listDatas = new List <HDModemDataStruct>(); //开辟一快新的缓存区 m_mutexListDatas.ReleaseMutex(); for (int i = 0; i < dataListTmp.Count; ++i) { try { HDModemDataStruct dat = dataListTmp[i]; string data = System.Text.Encoding.Default.GetString(dat.m_data_buf).TrimEnd('\0'); string recvData = data.Trim(); InvokeMessage(data, "原始数据"); string temp = data.Trim(); string gprs = System.Text.Encoding.Default.GetString(dat.m_modemId); gprs = gprs.Replace("\0", ""); string sid = Manager.XmlStationData.Instance.GetStationByGprsID(gprs); string result = null; if (temp.Contains("TRU")) { Debug.WriteLine("接收数据TRU完成,停止计时器"); //m_timer.Stop(); InvokeMessage("TRU " + System.Text.Encoding.Default.GetString(dat.m_modemId), "接收"); if (this.ErrorReceived != null) { this.ErrorReceived.Invoke(null, new ReceiveErrorEventArgs() { // Msg = "TRU " + dat.m_modemId Msg = "TRU " + System.Text.Encoding.Default.GetString(dat.m_modemId) }); } } if (temp.Contains("ATE0")) { Debug.WriteLine("接收数据ATE0完成,停止计时器"); //m_timer.Stop(); // InvokeMessage("ATE0", "接收"); if (this.ErrorReceived != null) { this.ErrorReceived.Invoke(null, new ReceiveErrorEventArgs() { Msg = "ATE0" }); } } if (temp.Contains("$")) { result = temp.Substring(temp.IndexOf("$")); int length = int.Parse(result.Substring(11, 4)); //获取报文长度 if (length > MAX_BUFFER) { continue; } result = result.Substring(0, length); if (!(result.StartsWith("$") && result.EndsWith("\r\n"))) { InvokeMessage(result + "报文开始符结束符不合法", "接收"); } String dataProtocol = Manager.XmlStationData.Instance.GetProtocolBySId(sid); CReportStruct report = new CReportStruct(); CDownConf downReport = new CDownConf(); if (dataProtocol == "RG30") { Up = new Data.RG30.UpParser(); Down = new Data.RG30.DownParser(); } if (dataProtocol == "SM100H") { Up = new Data.SM100H.UpParser(); Down = new Data.SM100H.DownParser(); } //时差法 if (dataProtocol == "TDXY") { Up = new Data.TDXY.UpParser(); Down = new Data.TDXY.DownParser(); } //中游局协议 if (dataProtocol == "ZYJBX") { Up = new Data.ZYJBX.UpParser(); Down = new Data.ZYJBX.DownParser(); } //蒸发协议 if (dataProtocol == "ZFXY") { Up = new Data.ZFXY.UpParse(); Down = new Data.ZFXY.DownParse(); } if (dataProtocol == "EN2B") { Up = new Data.EN2B.UpParser(); Down = new Data.EN2B.DownParser(); } if (dataProtocol == "OBS") { Up = new Protocol.Data.OBS.UpParser(); Down = new Protocol.Data.OBS.DownParser(); } //云南协议 if (dataProtocol == "YNXY") { Up = new Data.YNXY.UpParser(); Down = new Data.YNXY.DownParser(); } //批量传输解析 if (temp.Contains("1K")) { var station = FindStationBySID(sid); if (station == null) { throw new Exception("批量传输,站点匹配错误"); } CBatchStruct batch = new CBatchStruct(); InvokeMessage(String.Format("{0,-10} ", "批量传输") + temp, "接收"); if (Down.Parse_Flash(result, EChannelType.GPRS, out batch)) { if (this.BatchDataReceived != null) { this.BatchDataReceived.Invoke(null, new BatchEventArgs() { Value = batch, RawData = temp }); } } else if (Down.Parse_Batch(result, out batch)) { if (this.BatchDataReceived != null) { this.BatchDataReceived.Invoke(null, new BatchEventArgs() { Value = batch, RawData = temp }); } } } //+ 代表的是蒸发报文,需要特殊处理 //数据报文解析 if (result.Contains("1G21") || result.Contains("1G22") || result.Contains("1G23") || result.Contains("1G25") || result.Contains("1G29") || result.Contains("+")) { //回复TRU InvokeMessage("TRU " + gprs, "发送"); byte[] bts = new byte[] { 84, 82, 85, 13, 10 }; this.sendHex(gprs.Trim(), bts, (uint)bts.Length, null); //根据$将字符串进行分割 var lists = result.Split('$'); foreach (var msg in lists) { if (msg.Length < 10) { continue; } string plusMsg = "$" + msg.TrimEnd(); bool ret = Up.Parse(plusMsg, out report); if (ret && report != null) { report.ChannelType = EChannelType.GPRS; report.ListenPort = this.GetListenPort().ToString(); report.flagId = gprs; string rtype = report.ReportType == EMessageType.EAdditional ? "加报" : "定时报"; InvokeMessage("gprs号码: " + gprs + " " + String.Format("{0,-10} ", rtype) + plusMsg, "接收"); //TODO 重新定义事件 if (this.UpDataReceived != null) { this.UpDataReceived.Invoke(null, new UpEventArgs() { Value = report, RawData = plusMsg }); } } } } //其他报文 else { Down.Parse(result, out downReport); if (downReport != null) { InvokeMessage(String.Format("{0,-10} ", "下行指令读取参数") + result, "接收"); if (this.DownDataReceived != null) { this.DownDataReceived.Invoke(null, new DownEventArgs() { Value = downReport, RawData = result }); } } } } if (temp.Contains("BEG")) { Data.ZYJBX.DownParser down1 = new Data.ZYJBX.DownParser(); CSDStruct sd = new CSDStruct(); string id = Manager.XmlStationData.Instance.GetStationByGprsID(gprs); if (down1.Parse_SD(temp, id, out sd)) { InvokeMessage(String.Format("{0,-10} ", "批量SD传输") + temp, "接收"); if (this.BatchSDDataReceived != null) { this.BatchSDDataReceived.Invoke(null, new BatchSDEventArgs() { Value = sd, RawData = temp }); } } } } catch (Exception e) { Debug.WriteLine("" + e.Message); } } } }
private void Update(EvaluationContext context) { Reference.DirtyFlag.Clear(); LastObjectToWorld = context.ObjectToWorld; float fov = MathUtil.DegreesToRadians(Fov.GetValue(context)); float aspectRatio = AspectRatio.GetValue(context); if (aspectRatio < 0.0001f) { aspectRatio = (float)context.RequestedResolution.Width / context.RequestedResolution.Height; } System.Numerics.Vector2 clip = NearFarClip.GetValue(context); CameraToClipSpace = Matrix.PerspectiveFovRH(fov, aspectRatio, clip.X, clip.Y); Vector3 p = new Vector3(0, 0, Radius.GetValue(context)); var seed = Seed.GetValue(context); var wobbleSpeed = WobbleSpeed.GetValue(context); var wobbleComplexity = (int)MathUtils.Clamp(WobbleComplexity.GetValue(context), 1, 8); var rotOffset = RotationOffset.GetValue(context); // Orbit rotation System.Numerics.Vector3 t = Center.GetValue(context); Vector3 target = new Vector3(t.X, t.Y, t.Z); var rot = Matrix.RotationYawPitchRoll( ComputeAngle(SpinAngleAndWobble, 1) + MathUtil.DegreesToRadians((float)(SpinRate.GetValue(context) * (context.LocalFxTime + SpinOffset.GetValue(context)) * 360 + MathUtils.PerlinNoise(0, 1, 6, seed) * 360)) , -ComputeAngle(OrbitAngleAndWobble, 2), 0); var p2 = Vector3.Transform(p, rot); var eye = new Vector3(p2.X, p2.Y, p2.Z); // View rotation var viewDirection = target - eye; var rotateAim = Matrix.RotationYawPitchRoll( ComputeAngle(AimYawAngleAndWobble, 3) + rotOffset.X * MathUtils.ToRad, ComputeAngle(AimPitchAngleAndWobble, 4) + rotOffset.Y * MathUtils.ToRad, rotOffset.Z * MathUtils.ToRad); var adjustedViewDirection = Vector3.TransformNormal(viewDirection, rotateAim); target = eye + adjustedViewDirection; // Computing matrix var u = Up.GetValue(context); Vector3 up = new Vector3(u.X, u.Y, u.Z); var roll = ComputeAngle(AimRollAngleAndWobble, 5); var rotateAroundViewDirection = Matrix.RotationAxis(adjustedViewDirection, roll); up = Vector3.TransformNormal(up, rotateAroundViewDirection); up.Normalize(); WorldToCamera = Matrix.LookAtRH(eye, target, up); if (context.BypassCameras) { Command.GetValue(context); return; } // Set properties and evaluate sub tree var prevCameraToClipSpace = context.CameraToClipSpace; var prevWorldToCamera = context.WorldToCamera; context.CameraToClipSpace = CameraToClipSpace; context.WorldToCamera = WorldToCamera; Command.GetValue(context); context.CameraToClipSpace = prevCameraToClipSpace; context.WorldToCamera = prevWorldToCamera; float ComputeAngle(Slot <Vector2> angleAndWobbleInput, int seedIndex) { var angleAndWobble = angleAndWobbleInput.GetValue(context); var wobble = Math.Abs(angleAndWobble.Y) < 0.001f ? 0 : (MathUtils.PerlinNoise((float)context.LocalFxTime * wobbleSpeed, 1, wobbleComplexity, seed + 123 * seedIndex) - 0.5f) * 2 * angleAndWobble.Y; return(MathUtil.DegreesToRadians(angleAndWobble.X + wobble)); } }
public override int GetHashCode() { return(Forward.GetHashCode() ^ Up.GetHashCode()); }
public void OnPointerUp(PointerEventData eventData) { Up?.Invoke(eventData.position); }
/// <summary> /// Update the Axis. /// </summary> public override void UpdateFirst() { base.UpdateFirst(); LastX = X; LastY = Y; if (Locked) { return; } if (!Enabled) { X = 0; Y = 0; return; } if (ForcedInput) { return; } X = 0; Y = 0; for (int i = 0; i < Joystick.Count; i++) { foreach (JoyAxis axis in AxesX[i]) { float a = Input.Instance.GetAxis(axis, i) * 0.01f; } foreach (JoyAxis axis in AxesY[i]) { float a = Input.Instance.GetAxis(axis, i) * 0.01f; } foreach (JoyAxis axis in AxesX[i]) { float a = Input.Instance.GetAxis(axis, i) * 0.01f; if (Math.Abs(a) >= DeadZone) { if (RemapRange) { if (a > 0) { X += Util.ScaleClamp(a, 0, 1, 0, 1); } else { X += Util.ScaleClamp(a, -1, -0, -1, 0); } } else { X += a; } } if (RoundInput) { X = (float)Math.Round(X, 2); } } foreach (JoyAxis axis in AxesY[i]) { float a = Input.Instance.GetAxis(axis, i) * 0.01f; if (Math.Abs(a) >= DeadZone) { if (RemapRange) { if (a > 0) { Y += Util.ScaleClamp(a, 0, 1, 0, 1); } else { Y += Util.ScaleClamp(a, -1, -0, -1, 0); } } else { Y += a; } } if (RoundInput) { Y = (float)Math.Round(Y, 2); } } } foreach (Key k in Keys[Direction.Up]) { if (Input.Instance.KeyDown(k)) { Y -= 1; } } foreach (Key k in Keys[Direction.Down]) { if (Input.Instance.KeyDown(k)) { Y += 1; } } foreach (Key k in Keys[Direction.Left]) { if (Input.Instance.KeyDown(k)) { X -= 1; } } foreach (Key k in Keys[Direction.Right]) { if (Input.Instance.KeyDown(k)) { X += 1; } } for (int i = 0; i < Joystick.Count; i++) { foreach (int b in JoyButtons[Direction.Up][i]) { if (Input.Instance.ButtonDown(b, i)) { Y -= 1; } } foreach (int b in JoyButtons[Direction.Down][i]) { if (Input.Instance.ButtonDown(b, i)) { Y += 1; } } foreach (int b in JoyButtons[Direction.Left][i]) { if (Input.Instance.ButtonDown(b, i)) { X -= 1; } } foreach (int b in JoyButtons[Direction.Right][i]) { if (Input.Instance.ButtonDown(b, i)) { X += 1; } } } X = Util.Clamp(X, -1, 1); Y = Util.Clamp(Y, -1, 1); // Update the buttons. This makes it easy to read the Axis as buttons for Up, Right, Left, Down. Right.UpdateFirst(); Up.UpdateFirst(); Left.UpdateFirst(); Down.UpdateFirst(); Right.ForceState(false); Up.ForceState(false); Left.ForceState(false); Down.ForceState(false); if (X > 0.5f) { Right.ForceState(true); } if (X < -0.5f) { Left.ForceState(true); } if (Y > 0.5f) { Down.ForceState(true); } if (Y < -0.5f) { Up.ForceState(true); } }
public override string ToString() { return(Up.ToString() + "/" + Down.ToString()); }
public void Move(TurnType turnType, bool clockwise = true, int count = 1) { for (var i = 0; i < count; i++) { var downCopy = Down.Copy(); var frontCopy = Front.Copy(); var backCopy = Back.Copy(); var upCopy = Up.Copy(); var leftCopy = Left.Copy(); var rightCopy = Right.Copy(); switch (turnType) { case TurnType.Left: if (clockwise) { Down[0, 0] = frontCopy[0, 0]; Down[1, 0] = frontCopy[1, 0]; Down[2, 0] = frontCopy[2, 0]; Back[2, 2] = downCopy[0, 0]; Back[1, 2] = downCopy[1, 0]; Back[0, 2] = downCopy[2, 0]; Up[0, 0] = backCopy[2, 2]; Up[1, 0] = backCopy[1, 2]; Up[2, 0] = backCopy[0, 2]; Front[0, 0] = upCopy[0, 0]; Front[1, 0] = upCopy[1, 0]; Front[2, 0] = upCopy[2, 0]; Left[0, 0] = leftCopy[2, 0]; Left[1, 0] = leftCopy[2, 1]; Left[2, 0] = leftCopy[2, 2]; Left[2, 1] = leftCopy[1, 2]; Left[2, 2] = leftCopy[0, 2]; Left[1, 2] = leftCopy[0, 1]; Left[0, 2] = leftCopy[0, 0]; Left[0, 1] = leftCopy[1, 0]; } else { Up[0, 0] = frontCopy[0, 0]; Up[1, 0] = frontCopy[1, 0]; Up[2, 0] = frontCopy[2, 0]; Back[0, 2] = upCopy[2, 0]; Back[1, 2] = upCopy[1, 0]; Back[2, 2] = upCopy[0, 0]; Down[2, 0] = backCopy[0, 2]; Down[1, 0] = backCopy[1, 2]; Down[0, 0] = backCopy[2, 2]; Front[0, 0] = downCopy[0, 0]; Front[1, 0] = downCopy[1, 0]; Front[2, 0] = downCopy[2, 0]; Left[0, 0] = leftCopy[0, 2]; Left[0, 1] = leftCopy[1, 2]; Left[0, 2] = leftCopy[2, 2]; Left[1, 2] = leftCopy[2, 1]; Left[2, 2] = leftCopy[2, 0]; Left[2, 1] = leftCopy[1, 0]; Left[2, 0] = leftCopy[0, 0]; Left[1, 0] = leftCopy[0, 1]; } break; case TurnType.Right: if (clockwise) { Up[0, 2] = frontCopy[0, 2]; Up[1, 2] = frontCopy[1, 2]; Up[2, 2] = frontCopy[2, 2]; Back[2, 0] = upCopy[0, 2]; Back[1, 0] = upCopy[1, 2]; Back[0, 0] = upCopy[2, 2]; Down[0, 2] = backCopy[2, 0]; Down[1, 2] = backCopy[1, 0]; Down[2, 2] = backCopy[0, 0]; Front[0, 2] = downCopy[0, 2]; Front[1, 2] = downCopy[1, 2]; Front[2, 2] = downCopy[2, 2]; Right[0, 0] = rightCopy[2, 0]; Right[1, 0] = rightCopy[2, 1]; Right[2, 0] = rightCopy[2, 2]; Right[2, 1] = rightCopy[1, 2]; Right[2, 2] = rightCopy[0, 2]; Right[1, 2] = rightCopy[0, 1]; Right[0, 2] = rightCopy[0, 0]; Right[0, 1] = rightCopy[1, 0]; } else { Down[0, 2] = frontCopy[0, 2]; Down[1, 2] = frontCopy[1, 2]; Down[2, 2] = frontCopy[2, 2]; Back[0, 0] = downCopy[2, 2]; Back[1, 0] = downCopy[1, 2]; Back[2, 0] = downCopy[0, 2]; Up[0, 2] = backCopy[2, 0]; Up[1, 2] = backCopy[1, 0]; Up[2, 2] = backCopy[0, 0]; Front[0, 2] = upCopy[0, 2]; Front[1, 2] = upCopy[1, 2]; Front[2, 2] = upCopy[2, 2]; Right[0, 0] = rightCopy[0, 2]; Right[0, 1] = rightCopy[1, 2]; Right[0, 2] = rightCopy[2, 2]; Right[1, 2] = rightCopy[2, 1]; Right[2, 2] = rightCopy[2, 0]; Right[2, 1] = rightCopy[1, 0]; Right[2, 0] = rightCopy[0, 0]; Right[1, 0] = rightCopy[0, 1]; } break; case TurnType.Up: if (clockwise) { Left[0, 0] = frontCopy[0, 0]; Left[0, 1] = frontCopy[0, 1]; Left[0, 2] = frontCopy[0, 2]; Back[0, 0] = leftCopy[0, 0]; Back[0, 1] = leftCopy[0, 1]; Back[0, 2] = leftCopy[0, 2]; Right[0, 0] = backCopy[0, 0]; Right[0, 1] = backCopy[0, 1]; Right[0, 2] = backCopy[0, 2]; Front[0, 0] = rightCopy[0, 0]; Front[0, 1] = rightCopy[0, 1]; Front[0, 2] = rightCopy[0, 2]; Up[0, 0] = upCopy[2, 0]; Up[1, 0] = upCopy[2, 1]; Up[2, 0] = upCopy[2, 2]; Up[2, 1] = upCopy[1, 2]; Up[2, 2] = upCopy[0, 2]; Up[1, 2] = upCopy[0, 1]; Up[0, 2] = upCopy[0, 0]; Up[0, 1] = upCopy[1, 0]; } else { Left[0, 0] = backCopy[0, 0]; Left[0, 1] = backCopy[0, 1]; Left[0, 2] = backCopy[0, 2]; Front[0, 0] = leftCopy[0, 0]; Front[0, 1] = leftCopy[0, 1]; Front[0, 2] = leftCopy[0, 2]; Right[0, 0] = frontCopy[0, 0]; Right[0, 1] = frontCopy[0, 1]; Right[0, 2] = frontCopy[0, 2]; Back[0, 0] = rightCopy[0, 0]; Back[0, 1] = rightCopy[0, 1]; Back[0, 2] = rightCopy[0, 2]; Up[0, 0] = upCopy[0, 2]; Up[0, 1] = upCopy[1, 2]; Up[0, 2] = upCopy[2, 2]; Up[1, 2] = upCopy[2, 1]; Up[2, 2] = upCopy[2, 0]; Up[2, 1] = upCopy[1, 0]; Up[2, 0] = upCopy[0, 0]; Up[1, 0] = upCopy[0, 1]; } break; case TurnType.Down: if (clockwise) { Left[2, 0] = backCopy[2, 0]; Left[2, 1] = backCopy[2, 1]; Left[2, 2] = backCopy[2, 2]; Front[2, 0] = leftCopy[2, 0]; Front[2, 1] = leftCopy[2, 1]; Front[2, 2] = leftCopy[2, 2]; Right[2, 0] = frontCopy[2, 0]; Right[2, 1] = frontCopy[2, 1]; Right[2, 2] = frontCopy[2, 2]; Back[2, 0] = rightCopy[2, 0]; Back[2, 1] = rightCopy[2, 1]; Back[2, 2] = rightCopy[2, 2]; Down[0, 0] = downCopy[2, 0]; Down[1, 0] = downCopy[2, 1]; Down[2, 0] = downCopy[2, 2]; Down[2, 1] = downCopy[1, 2]; Down[2, 2] = downCopy[0, 2]; Down[1, 2] = downCopy[0, 1]; Down[0, 2] = downCopy[0, 0]; Down[0, 1] = downCopy[1, 0]; } else { Left[2, 0] = frontCopy[2, 0]; Left[2, 1] = frontCopy[2, 1]; Left[2, 2] = frontCopy[2, 2]; Back[2, 0] = leftCopy[2, 0]; Back[2, 1] = leftCopy[2, 1]; Back[2, 2] = leftCopy[2, 2]; Right[2, 0] = backCopy[2, 0]; Right[2, 1] = backCopy[2, 1]; Right[2, 2] = backCopy[2, 2]; Front[2, 0] = rightCopy[2, 0]; Front[2, 1] = rightCopy[2, 1]; Front[2, 2] = rightCopy[2, 2]; Down[0, 0] = downCopy[0, 2]; Down[0, 1] = downCopy[1, 2]; Down[0, 2] = downCopy[2, 2]; Down[1, 2] = downCopy[2, 1]; Down[2, 2] = downCopy[2, 0]; Down[2, 1] = downCopy[1, 0]; Down[2, 0] = downCopy[0, 0]; Down[1, 0] = downCopy[0, 1]; } break; case TurnType.Front: if (clockwise) { Front[0, 0] = frontCopy[2, 0]; Front[1, 0] = frontCopy[2, 1]; Front[2, 0] = frontCopy[2, 2]; Front[2, 1] = frontCopy[1, 2]; Front[2, 2] = frontCopy[0, 2]; Front[1, 2] = frontCopy[0, 1]; Front[0, 2] = frontCopy[0, 0]; Front[0, 1] = frontCopy[1, 0]; Up[2, 0] = leftCopy[2, 2]; Up[2, 1] = leftCopy[1, 2]; Up[2, 2] = leftCopy[0, 2]; Right[0, 0] = upCopy[2, 0]; Right[1, 0] = upCopy[2, 1]; Right[2, 0] = upCopy[2, 2]; Down[0, 0] = rightCopy[2, 0]; Down[0, 1] = rightCopy[1, 0]; Down[0, 2] = rightCopy[0, 0]; Left[0, 2] = downCopy[0, 0]; Left[1, 2] = downCopy[0, 1]; Left[2, 2] = downCopy[0, 2]; } else { Front[0, 0] = frontCopy[0, 2]; Front[0, 1] = frontCopy[1, 2]; Front[0, 2] = frontCopy[2, 2]; Front[1, 2] = frontCopy[2, 1]; Front[2, 2] = frontCopy[2, 0]; Front[2, 1] = frontCopy[1, 0]; Front[2, 0] = frontCopy[0, 0]; Front[1, 0] = frontCopy[0, 1]; Up[2, 0] = rightCopy[0, 0]; Up[2, 1] = rightCopy[1, 0]; Up[2, 2] = rightCopy[2, 0]; Right[0, 0] = downCopy[0, 2]; Right[1, 0] = downCopy[0, 1]; Right[2, 0] = downCopy[0, 0]; Down[0, 0] = leftCopy[0, 2]; Down[0, 1] = leftCopy[1, 2]; Down[0, 2] = leftCopy[2, 2]; Left[0, 2] = upCopy[2, 2]; Left[1, 2] = upCopy[2, 1]; Left[2, 2] = upCopy[2, 0]; } break; case TurnType.Back: if (clockwise) { Back[0, 0] = backCopy[2, 0]; Back[1, 0] = backCopy[2, 1]; Back[2, 0] = backCopy[2, 2]; Back[2, 1] = backCopy[1, 2]; Back[2, 2] = backCopy[0, 2]; Back[1, 2] = backCopy[0, 1]; Back[0, 2] = backCopy[0, 0]; Back[0, 1] = backCopy[1, 0]; Up[0, 0] = rightCopy[0, 2]; Up[0, 1] = rightCopy[1, 2]; Up[0, 2] = rightCopy[2, 2]; Left[2, 0] = upCopy[0, 0]; Left[1, 0] = upCopy[0, 1]; Left[0, 0] = upCopy[0, 2]; Down[2, 2] = leftCopy[2, 0]; Down[2, 1] = leftCopy[1, 0]; Down[2, 0] = leftCopy[0, 0]; Right[0, 2] = downCopy[2, 2]; Right[1, 2] = downCopy[2, 1]; Right[2, 2] = downCopy[2, 0]; } else { Back[0, 0] = backCopy[0, 2]; Back[0, 1] = backCopy[1, 2]; Back[0, 2] = backCopy[2, 2]; Back[1, 2] = backCopy[2, 1]; Back[2, 2] = backCopy[2, 0]; Back[2, 1] = backCopy[1, 0]; Back[2, 0] = backCopy[0, 0]; Back[1, 0] = backCopy[0, 1]; Up[0, 2] = leftCopy[0, 0]; Up[0, 1] = leftCopy[1, 0]; Up[0, 0] = leftCopy[2, 0]; Right[0, 2] = upCopy[0, 0]; Right[1, 2] = upCopy[0, 1]; Right[2, 2] = upCopy[0, 2]; Down[2, 2] = rightCopy[0, 2]; Down[2, 1] = rightCopy[1, 2]; Down[2, 0] = rightCopy[2, 2]; Left[2, 0] = downCopy[2, 2]; Left[1, 0] = downCopy[2, 1]; Left[0, 0] = downCopy[2, 0]; } break; } } }
public async void getPaymentGateway_Click(object sender, EventArgs e) { try { await Navigation.PushPopupAsync(new LoadingPopPage()); MyNotificationPage myNotification = new MyNotificationPage(); GetPaymentPayPal _request = new GetPaymentPayPal(); string _response; List <ProductList> _productList = new List <ProductList>(); NotificationFriend notificationFriendList = new NotificationFriend(); notificationFriendList = await getListofInvitedFrnd(); Up uP = new Up(); foreach (var item in notificationFriendList.Response.listofFriends) { if (item.PaymentDone == 0) { ProductList _product = new ProductList(); _product.ProductID = 1; _product.Name = item.FriendsName; _product.Description = item.DeliveryType + "," + item.TotalMonths + "," + item.SubcriptionType; _product.UnitPrice = item.Cost; _product.SKU = item.SKU; _product.OrderQty = 1; _productList.Add(_product); } } //_product.ProductID = 1; //_product.Name = Settings.FriendName; //_product.Description = Settings.DeliveryMethodName + "," + Settings.DurationName + "," + Settings.SubscriptionTypeName; //_product.UnitPrice = Settings.PriceName; //_product.SKU = "1"; //_product.OrderQty = 1; //_productList.Add(_product); _request.ProductList = _productList; uP.Cost = TotalCost; uP.DeliveryMethodId = Settings.DeliveryMethodId; uP.DurationId = Settings.DurationId; uP.SubscriptionTypeId = Settings.SubscriptionTypeId; uP.UserId = Convert.ToInt32(Settings.UserID); _request.up = uP; _request.SiteURL = "null"; _request.InvoiceNumber = Guid.NewGuid().ToString(); _request.Currency = "USD"; _request.OrderDescription = Settings.UserID.ToString(); _request.ShippingFee = "0"; _request.Tax = "0"; _request.PayerID = (Settings.UserID).ToString(); _request.PaymentID = "null"; _request.Count = 1; _request.UserId = (Settings.UserID).ToString(); _request.StartID = "null"; _request.StartIndex = 1; _request.StartTime = "null"; _request.EndTime = "null"; _request.StartDate = "null"; _request.PayeeEmail = Settings.Email; _request.PayeeID = (Settings.UserID).ToString(); _request.SortBy = "Ascending"; _request.SortOrder = "Albhabetical"; string s = JsonConvert.SerializeObject(_request); HttpResponseMessage response = null; string uri = "http://noti.fit:130/api/PayPal/GetPaymentPayPalURL"; using (var stringContent = new StringContent(s, System.Text.Encoding.UTF8, "application/json")) { HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Settings.TokenCode); response = await client.PostAsync(uri, stringContent); if (response.IsSuccessStatusCode) { var SucessResponse = await response.Content.ReadAsStringAsync(); _response = JsonConvert.DeserializeObject <string>(SucessResponse); await Navigation.PopAllPopupAsync(); await Navigation.PushAsync(new PaymentGateway(_response)); //Settings.PriceName = _response.Response.price; //var res = _response.Price; //Settings.PriceName = res; //Cost.Text = "Total New Subscriptions: US $" + res; //return _response; } else { var ErrorResponse = await response.Content.ReadAsStringAsync(); _response = JsonConvert.DeserializeObject <string>(ErrorResponse); await Navigation.PopAllPopupAsync(); DependencyService.Get <IToast>().Show("Error"); //return _response; //Settings.PriceName = _response.Response.price; } } } catch (Exception ex) { var msg = ex.Message; } }
/// <summary> /// Обработать входное значение. /// </summary> /// <param name="input">Входное значение.</param> /// <returns>Результирующее значение.</returns> protected override IIndicatorValue OnProcess(IIndicatorValue input) { var candle = input.GetValue <Candle>(); var buffer = input.IsFinal ? _buffer : _buffer.ToList(); buffer.Add(candle); // если буфер стал достаточно большим (стал больше длины) if (buffer.Count > Length) { // Запоминаем интересующие изменения свечек до буфера if (buffer[0].HighPrice > buffer[1].HighPrice) { _wasHighDown = true; } else if (buffer[0].HighPrice < buffer[1].HighPrice) { _wasHighDown = false; } if (buffer[0].LowPrice < buffer[1].LowPrice) { _wasLowUp = true; } else if (buffer[0].LowPrice > buffer[1].LowPrice) { _wasLowUp = false; } buffer.RemoveAt(0); } // Логика расчета: последующие/предыдущие значения должны быть меньше/больше центрального значения if (buffer.Count >= Length) { // флаги для расчета фракталов (если флаг равен false, то на центральной свече нет фрактала) var isMax = true; var isMin = true; var centerHighPrice = buffer[_numCenter].HighPrice; var centerLowPrice = buffer[_numCenter].LowPrice; for (var i = 0; i < buffer.Count; i++) { if (i == _numCenter) { continue; } // Все значения до и после центральной свечи должны быть // больше для фрактала вверх и меньше для фрактала вниз if (buffer[i].HighPrice > centerHighPrice) { isMax = false; } if (buffer[i].LowPrice < centerLowPrice) { isMin = false; } } // Фильтр для ситуаций где цена у экстремума одинакова за период больше длины буфера if (isMax && _wasHighDown && buffer.GetRange(0, _numCenter).Min(i => i.HighPrice) == centerHighPrice) { isMax = false; } if (isMin && _wasLowUp && buffer.GetRange(0, _numCenter).Max(i => i.LowPrice) == centerLowPrice) { isMin = false; } var shift = buffer.Count - _numCenter - 1; var upValue = isMax ? new ShiftedIndicatorValue(this, shift, new DecimalIndicatorValue(this, centerHighPrice)) : new ShiftedIndicatorValue(this); var downValue = isMin ? new ShiftedIndicatorValue(this, shift, new DecimalIndicatorValue(this, centerLowPrice)) : new ShiftedIndicatorValue(this); upValue.IsFinal = input.IsFinal; downValue.IsFinal = input.IsFinal; var complexValue = new ComplexIndicatorValue(this); complexValue.InnerValues.Add(Up, Up.Process(upValue)); complexValue.InnerValues.Add(Down, Down.Process(downValue)); return(complexValue); } return(base.OnProcess(new ShiftedIndicatorValue(this, 0, input.SetValue(this, 0)))); }
void Update() { if (alive) { timeLeft -= Time.deltaTime; if (timeLeft < 0) { if (Input.touchCount == 1) // user is touching the screen with a single touch { Touch touch = Input.GetTouch(0); // get the touch if (touch.phase == TouchPhase.Began) //check for the first touch { fp = touch.position; lp = touch.position; } else if (touch.phase == TouchPhase.Moved) // update the last position based on where they moved { lp = touch.position; } else if (touch.phase == TouchPhase.Ended) //check if the finger is removed from the screen { lp = touch.position; //last touch position. Ommitted if you use list //Check if drag distance is greater than 15% of the screen height if (Mathf.Abs(lp.x - fp.x) > dragDistance || Mathf.Abs(lp.y - fp.y) > dragDistance) {//It's a drag //check if the drag is vertical or horizontal if ((lp.x - fp.x) > 0 && (lp.y - fp.y) > 0) { if (transform.position.x < xR)//Right swipe { this.transform.Translate(1 * movementScale, 0, 0); } } if ((lp.x - fp.x) < 0 && (lp.y - fp.y) > 0) { //lewo if (transform.position.y < yT) // Debug.Log("Up Swipe"); { this.transform.Translate(0, 1 * movementScale, 0); } } if ((lp.x - fp.x) > 0 && (lp.y - fp.y) < 0) { //gora if (transform.position.y > yB) // Debug.Log("Down Swipe"); { this.transform.Translate(0, -1 * movementScale, 0); } } if ((lp.x - fp.x) < 0 && (lp.y - fp.y) < 0) { //dol if (transform.position.x > xL) // Debug.Log("Left Swipe"); { this.transform.Translate(-1 * movementScale, 0, 0); } } } else { //It's a tap as the drag distance is less than 20% of the screen height //Here we can make tap.postion as desiredPostion to move object rounded to the nearest block //Debug.Log("Tap"); } } } } foreach (GameObject red in CubeRed) { if (red.transform.position.x == transform.position.x && red.transform.position.y == transform.position.y) { Bomb(); alive = false; } } if (transform.position.y == yT && transform.position.x == xR) { RightBottom.GetComponent <FinalGoindUp>().Colour(); RightBottom.GetComponent <FinalGoindUp>().Metod(); Up.GetComponent <MoveGoingUp>().Metod(); Invoke("next", 2); } } }