コード例 #1
0
        public static string Convertcode(PointLatLng data, double bearing, double altitude, double speed, int id, char statu, DataDecoder decoder)
        {
            //track
            char   status = statu;
            int    posX;
            int    posY;
            string radarkey = "";
            double min      = 99999;

            Dictionary <string, RecievedRadarData> radars = decoder.Radars;

            foreach (string key in radars.Keys)
            {
                RecievedRadarData radar    = radars[key];
                PointLatLng       point    = new PointLatLng(radar.Lat, radar.Lng);
                double            distance = CPC.GetDistance(data, point);
                if (distance < min)
                {
                    min      = distance;
                    radarkey = key;
                }
            }
            posY = Convert.ToInt16(((double)data.Lat - radars[radarkey].Lat) * 480);
            posX = Convert.ToInt16(((double)data.Lng - radars[radarkey].Lng) * 480);
            int speedX;
            int speedY;

            speedX = (int)Convert.ToInt16(speed * Math.Sin(bearing)) * 8;
            speedY = (int)Convert.ToInt16(speed * Math.Cos(bearing)) * 8;

            string codedata = "0201" + checkcode(posX) + checkcode(posY) + checkcode(speedX)
                              + checkcode(speedY) + id.ToString("0000") + (int)status + radars[radarkey].Number.ToString("00");
            string blocklength = checkcode((codedata.Length / 2) + 4);

            return("0202" + blocklength + codedata.ToUpper());
        }
コード例 #2
0
 public static List <Area> CountrysProvinces(byte countryID)
 {
     return(CPC.GetProvinces(countryID));
 }
コード例 #3
0
ファイル: CPCBase.Input.cs プロジェクト: xy2iii/BizHawk
        /// <summary>
        /// Cycles through all the input callbacks
        /// This should be done once per frame
        /// </summary>
        public void PollInput()
        {
            CPC.InputCallbacks.Call();

            lock (this)
            {
                // parse single keyboard matrix keys.
                // J1 and J2 are scanned as part of the keyboard
                for (var i = 0; i < KeyboardDevice.KeyboardMatrix.Length; i++)
                {
                    string key       = KeyboardDevice.KeyboardMatrix[i];
                    bool   prevState = KeyboardDevice.GetKeyStatus(key);
                    bool   currState = CPC._controller.IsPressed(key);

                    if (currState != prevState)
                    {
                        KeyboardDevice.SetKeyStatus(key, currState);
                    }
                }

                // non matrix keys (J2)
                foreach (string k in KeyboardDevice.NonMatrixKeys)
                {
                    if (!k.StartsWith("P2"))
                    {
                        continue;
                    }

                    bool currState = CPC._controller.IsPressed(k);

                    switch (k)
                    {
                    case "P2 Up":
                        if (currState)
                        {
                            KeyboardDevice.SetKeyStatus("Key 6", true);
                        }
                        else if (!KeyboardDevice.GetKeyStatus("Key 6"))
                        {
                            KeyboardDevice.SetKeyStatus("Key 6", false);
                        }
                        break;

                    case "P2 Down":
                        if (currState)
                        {
                            KeyboardDevice.SetKeyStatus("Key 5", true);
                        }
                        else if (!KeyboardDevice.GetKeyStatus("Key 5"))
                        {
                            KeyboardDevice.SetKeyStatus("Key 5", false);
                        }
                        break;

                    case "P2 Left":
                        if (currState)
                        {
                            KeyboardDevice.SetKeyStatus("Key R", true);
                        }
                        else if (!KeyboardDevice.GetKeyStatus("Key R"))
                        {
                            KeyboardDevice.SetKeyStatus("Key R", false);
                        }
                        break;

                    case "P2 Right":
                        if (currState)
                        {
                            KeyboardDevice.SetKeyStatus("Key T", true);
                        }
                        else if (!KeyboardDevice.GetKeyStatus("Key T"))
                        {
                            KeyboardDevice.SetKeyStatus("Key T", false);
                        }
                        break;

                    case "P2 Fire":
                        if (currState)
                        {
                            KeyboardDevice.SetKeyStatus("Key G", true);
                        }
                        else if (!KeyboardDevice.GetKeyStatus("Key G"))
                        {
                            KeyboardDevice.SetKeyStatus("Key G", false);
                        }
                        break;
                    }
                }
            }

            // Tape control
            if (CPC._controller.IsPressed(Play))
            {
                if (!pressed_Play)
                {
                    CPC.OSD_FireInputMessage(Play);
                    TapeDevice.Play();
                    pressed_Play = true;
                }
            }
            else
            {
                pressed_Play = false;
            }

            if (CPC._controller.IsPressed(Stop))
            {
                if (!pressed_Stop)
                {
                    CPC.OSD_FireInputMessage(Stop);
                    TapeDevice.Stop();
                    pressed_Stop = true;
                }
            }
            else
            {
                pressed_Stop = false;
            }

            if (CPC._controller.IsPressed(RTZ))
            {
                if (!pressed_RTZ)
                {
                    CPC.OSD_FireInputMessage(RTZ);
                    TapeDevice.RTZ();
                    pressed_RTZ = true;
                }
            }
            else
            {
                pressed_RTZ = false;
            }

            if (CPC._controller.IsPressed(Record))
            {
            }
            if (CPC._controller.IsPressed(NextTape))
            {
                if (!pressed_NextTape)
                {
                    CPC.OSD_FireInputMessage(NextTape);
                    TapeMediaIndex++;
                    pressed_NextTape = true;
                }
            }
            else
            {
                pressed_NextTape = false;
            }

            if (CPC._controller.IsPressed(PrevTape))
            {
                if (!pressed_PrevTape)
                {
                    CPC.OSD_FireInputMessage(PrevTape);
                    TapeMediaIndex--;
                    pressed_PrevTape = true;
                }
            }
            else
            {
                pressed_PrevTape = false;
            }

            if (CPC._controller.IsPressed(NextBlock))
            {
                if (!pressed_NextBlock)
                {
                    CPC.OSD_FireInputMessage(NextBlock);
                    TapeDevice.SkipBlock(true);
                    pressed_NextBlock = true;
                }
            }
            else
            {
                pressed_NextBlock = false;
            }

            if (CPC._controller.IsPressed(PrevBlock))
            {
                if (!pressed_PrevBlock)
                {
                    CPC.OSD_FireInputMessage(PrevBlock);
                    TapeDevice.SkipBlock(false);
                    pressed_PrevBlock = true;
                }
            }
            else
            {
                pressed_PrevBlock = false;
            }

            if (CPC._controller.IsPressed(TapeStatus))
            {
                if (!pressed_TapeStatus)
                {
                    //Spectrum.OSD_FireInputMessage(TapeStatus);
                    CPC.OSD_ShowTapeStatus();
                    pressed_TapeStatus = true;
                }
            }
            else
            {
                pressed_TapeStatus = false;
            }

            if (CPC._controller.IsPressed(HardResetStr))
            {
                if (!pressed_HardReset)
                {
                    HardReset();
                    pressed_HardReset = true;
                }
            }
            else
            {
                pressed_HardReset = false;
            }

            if (CPC._controller.IsPressed(SoftResetStr))
            {
                if (!pressed_SoftReset)
                {
                    SoftReset();
                    pressed_SoftReset = true;
                }
            }
            else
            {
                pressed_SoftReset = false;
            }

            // disk control
            if (CPC._controller.IsPressed(NextDisk))
            {
                if (!pressed_NextDisk)
                {
                    CPC.OSD_FireInputMessage(NextDisk);
                    DiskMediaIndex++;
                    pressed_NextDisk = true;
                }
            }
            else
            {
                pressed_NextDisk = false;
            }

            if (CPC._controller.IsPressed(PrevDisk))
            {
                if (!pressed_PrevDisk)
                {
                    CPC.OSD_FireInputMessage(PrevDisk);
                    DiskMediaIndex--;
                    pressed_PrevDisk = true;
                }
            }
            else
            {
                pressed_PrevDisk = false;
            }

            if (CPC._controller.IsPressed(EjectDisk))
            {
                if (!pressed_EjectDisk)
                {
                    CPC.OSD_FireInputMessage(EjectDisk);
                    //if (UPDDiskDevice != null)
                    //  UPDDiskDevice.FDD_EjectDisk();
                }
            }
            else
            {
                pressed_EjectDisk = false;
            }

            if (CPC._controller.IsPressed(DiskStatus))
            {
                if (!pressed_DiskStatus)
                {
                    //Spectrum.OSD_FireInputMessage(TapeStatus);
                    CPC.OSD_ShowDiskStatus();
                    pressed_DiskStatus = true;
                }
            }
            else
            {
                pressed_DiskStatus = false;
            }
        }
コード例 #4
0
        public ActionResult AddAnswer(int PollTypes, int PollID, string Options, int Rate, string Text, int MaxMulti)
        {
            if (Text == "")
            {
                Text = null;
            }

            if (PollTypes == 1 && Options == "0")
            {
                var result = new { Result = " การเพิ่มคำตอบไม่สำเร็จ", Check = 0 };

                return(Json(result));
            }
            if (PollTypes == 4 && Rate == 0)
            {
                var result = new { Result = " การเพิ่มคำตอบไม่สำเร็จ", Check = 0 };

                return(Json(result));
            }
            if (PollTypes == 2 && Text == null)
            {
                var result = new { Result = " การเพิ่มคำตอบไม่สำเร็จ", Check = 0 };

                return(Json(result));
            }
            if (PollTypes == 3 && Text == null)
            {
                var result = new { Result = " การเพิ่มคำตอบไม่สำเร็จ", Check = 0 };

                return(Json(result));
            }
            if (PollTypes == 1)
            {
                string[] OPtsr    = Options.Trim().Split(' ');
                int      CheckMax = OPtsr.Length;
                if (CheckMax > MaxMulti)
                {
                    var result = new { Result = "กรุณาเลือกตัวเลือกแค่ " + MaxMulti + " ตัวเลือก", Check = 0 };

                    return(Json(result));
                }
            }

            if (PollTypes == 3 && Text != null)
            {
                Text = Text.ToLower();
            }


            using (ProjectJobEntities db = new ProjectJobEntities())
            {
                CPC  bussiness  = new CPC();
                bool IsDupicate = bussiness.CheckPollClose(PollID);
                if (IsDupicate)
                {
                    Outer Pmodel = new Outer()
                    {
                        Polls_ID     = PollID,
                        Outer_Text   = Text,
                        Outer_Rating = Rate,
                        Outer_Name   = Convert.ToString(Session["FirstName"]),
                        OuterSes_ID  = Convert.ToString(Session["Ses_ID"])
                    };
                    db.Outer.Add(Pmodel);
                    if (PollTypes == 1)
                    {
                        string[] OPtsr = Options.Trim().Split(' ');
                        foreach (var poo in OPtsr)
                        {
                            int          Op     = Convert.ToInt32(poo);
                            OuterOptions Omodel = new OuterOptions()
                            {
                                Outer_ID   = Pmodel.Outer_ID,
                                Options_ID = Op
                            };

                            db.OuterOptions.Add(Omodel);
                        }
                    }
                    db.SaveChanges();


                    var result = new { Result = " การเพิ่มคำตอบสำเร็จ", id = Pmodel.Polls_ID, type = PollTypes, Check = 1 };

                    return(Json(result));
                }
                else
                {
                    var result = new { Result = " กิจกรรมนี้ปิดไปแล้ว, กรุณาหากิจกรรมอื่น", Check = 2 };

                    return(Json(result));
                }
            }
        }