Beispiel #1
0
        /// <summary>
        /// 添加航迹点
        /// </summary>
        /// <param name="modelName"></param>
        /// <param name="point"></param>
        public void AddTrackPoint(string modelName, byte type, MapLngLat point)
        {
            try
            {
                if (modelDic.ContainsKey(modelName))
                {
                    TrackPoint tp = new TrackPoint();
                    tp.Index     = index;
                    tp.PointName = modelName + "point_" + index;
                    tp.Position  = point;

                    modelDic[modelName].Points.Add(tp);

                    if (modelDic[modelName].Points.Count > Utils.TrackPointNum)
                    {
                        modelDic[modelName].Points.RemoveAt(0);
                    }
                }
                else
                {
                    TrackPoint tp = new TrackPoint();
                    tp.Index     = index;
                    tp.PointName = modelName + "point_" + index;
                    tp.Position  = point;

                    TrackLine line = new TrackLine();
                    line.LineName  = modelName + "line";
                    line.ModelName = modelName;
                    line.Points    = new List <TrackPoint>();
                    line.Points.Add(tp);
                    line.TargetType = type;

                    modelDic.Add(modelName, line);
                }

                index++;
            }
            catch (Exception ex)
            {
                Log4Allen.WriteLog(typeof(TrackLineManager), ex.Message);
            }
        }
Beispiel #2
0
 private void refreshListViews(PowerSupplyModel _psModel)
 {//传空为清空表格
     containPoints_lv.Items.Clear();
     containTracks_lv.Items.Clear();
     containsFunctionalPoints_lv.Items.Clear();
     if (_psModel != null)
     {
         foreach (TrackPoint _tp in _psModel.containedTrackPoint)
         {
             ListViewItem lvi_Point = new ListViewItem(_tp.trackPointID.ToString());
             lvi_Point.SubItems.Add(_tp.trackPoint.ToString());
             if (_tp.switchDirection == 1)
             {
                 lvi_Point.SubItems.Add("定位");
             }
             else if (_tp.switchDirection == 2)
             {
                 lvi_Point.SubItems.Add("反位");
             }
             bool hasGotIt = false;
             for (int ij = 0; ij < tPoint.Count; ij++)
             {
                 if (tPoint[ij].trackPointID.Equals(_tp.trackPointID))
                 {
                     lvi_Point.SubItems.Add(ij.ToString());
                     hasGotIt = true;
                 }
                 if (hasGotIt)
                 {
                     break;
                 }
             }
             if (hasGotIt)
             {
                 containPoints_lv.Items.Add(lvi_Point);
             }
         }
         for (int i = 0; i < _psModel.containedTrackLine.Count; i++)
         {
             TrackLine    _tl      = (TrackLine)_psModel.containedTrackLine[i];
             ListViewItem lvi_Line = new ListViewItem(_tl.trackLineID.ToString());
             lvi_Line.SubItems.Add(_tl.trackText.ToString());
             if (_tl.containsInPS == 0)
             {
                 lvi_Line.SubItems.Add("全部");
             }
             else if (_tl.containsInPS == 1)
             {
                 lvi_Line.SubItems.Add("左半");
             }
             else if (_tl.containsInPS == 2)
             {
                 lvi_Line.SubItems.Add("右半");
             }
             bool hasGotIt = false;
             for (int ij = 0; ij < tLine.Count; ij++)
             {
                 if (tLine[ij].trackLineID.Equals(_tl.trackLineID))
                 {
                     lvi_Line.SubItems.Add(ij.ToString());
                     hasGotIt = true;
                 }
                 if (hasGotIt)
                 {
                     break;
                 }
             }
             if (hasGotIt)
             {
                 containTracks_lv.Items.Add(lvi_Line);
             }
         }
         foreach (Signal _s in _psModel.functionalTrackPoint)
         {
             ListViewItem lvi_Signal = new ListViewItem(_s.signalID.ToString());
             lvi_Signal.SubItems.Add(_s.signalPoint.ToString());
             bool hasGotIt = false;
             for (int ij = 0; ij < signal.Count; ij++)
             {
                 if (signal[ij].signalID.Equals(_s.signalID))
                 {
                     lvi_Signal.SubItems.Add(ij.ToString());
                     hasGotIt = true;
                 }
                 if (hasGotIt)
                 {
                     break;
                 }
             }
             if (hasGotIt)
             {
                 containsFunctionalPoints_lv.Items.Add(lvi_Signal);
             }
         }
         containsFunctionalPoints_lv.Update();
         containPoints_lv.Update();
         containTracks_lv.Update();
     }
     else
     {
         return;
     }
 }
Beispiel #3
0
 private void save_btn_Click(object sender, EventArgs e)
 {
     if (id_tb.Text.Length != 0 &&
         name_tb.Text.Length != 0)
     {
         try
         {
             PowerSupplyModel _psModel = new PowerSupplyModel();
             _psModel.powerSupplyID    = int.Parse(id_tb.Text);
             _psModel.powerSupplyName  = name_tb.Text;
             _psModel.powerSupplyRange = psRange_tb.Text;
             List <TrackPoint> _tpList     = new List <TrackPoint>();
             List <TrackLine>  _tlList     = new List <TrackLine>();
             List <Signal>     _signalList = new List <Signal>();
             if (containPoints_lv.Items.Count != 0)
             {
                 foreach (ListViewItem lvi in containPoints_lv.Items)
                 {
                     TrackPoint _tp = new TrackPoint();
                     _tp = (TrackPoint)tPoint[int.Parse(lvi.SubItems[3].Text)].Clone();
                     if (lvi.SubItems[2] != null)
                     {
                         if (lvi.SubItems[2].Text.Contains("定"))
                         {
                             _tp.switchDirection = 1;
                         }
                         else if (lvi.SubItems[2].Text.Contains("反"))
                         {
                             _tp.switchDirection = 2;
                         }
                     }
                     _tpList.Add(_tp);
                 }
             }
             if (containTracks_lv.Items.Count != 0)
             {
                 foreach (ListViewItem lvi in containTracks_lv.Items)
                 {
                     TrackLine _tline = new TrackLine();
                     _tline = (TrackLine)tLine[int.Parse(lvi.SubItems[3].Text)].Clone();
                     if (lvi.SubItems[2].Text.Contains("全部"))
                     {
                         _tline.containsInPS = 0;
                     }
                     else if (lvi.SubItems[2].Text.Contains("左"))
                     {
                         _tline.containsInPS = 1;
                     }
                     else if (lvi.SubItems[2].Text.Contains("右"))
                     {
                         _tline.containsInPS = 2;
                     }
                     _tlList.Add(_tline);
                 }
             }
             if (containsFunctionalPoints_lv.Items.Count != 0)
             {
                 foreach (ListViewItem lvi in containsFunctionalPoints_lv.Items)
                 {
                     Signal _s = new Signal();
                     _s = (Signal)signal[int.Parse(lvi.SubItems[2].Text)].Clone();
                     _signalList.Add(_s);
                 }
             }
             _psModel.containedTrackLine   = _tlList;
             _psModel.containedTrackPoint  = _tpList;
             _psModel.functionalTrackPoint = _signalList;
             if (ps_lv.SelectedItems.Count != 0)
             {
                 psModel.RemoveAt(ps_lv.SelectedItems[0].Index);
             }
             psModel.Add(_psModel);
             initUI(true);
             removeText();
         }
         catch (Exception e1)
         {
             MessageBox.Show(e1.ToString().Split('。')[0] + "。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     else
     {
         MessageBox.Show("请填写左边框内ID和名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #4
0
        public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData)
        {
            Console.WriteLine("DEBUG: {0} : {1}", p.http_method, p.http_url);
            //string jsonData = inputData.ReadToEnd();
            string data = inputData.ReadToEnd();

            string[] param = data.Split(';');

            // Recording Route
            if (p.http_url_split[1].Equals("Route"))
            {
                // TrackLine
                if (p.http_url_split[2].Equals("TrackLine"))
                {
                    TrackLine trackLine = new TrackLine(float.Parse(param[1]));
                    Console.WriteLine("DEBUG: TrackLine: ValueL - " + trackLine.ValueL.ToString());
                    p.writeSuccess();
                    ActionLogger.writeActionLog(trackLine.ToString());

                    MyHttpServer.Fahrbefehle.addAction(trackLine);
                    Console.WriteLine("Fahrbefehl hinzugefügt");
                }

                // TrackTurnLeft
                else if (p.http_url_split[2].Equals("TrackTurnLeft"))
                {
                    TrackTurnLeft trackTurnLeft = new TrackTurnLeft(float.Parse(param[1]));
                    Console.WriteLine("DEBUG: TrackTurnLeft: ValueA - " + trackTurnLeft.ValueA.ToString());
                    p.writeSuccess();
                    ActionLogger.writeActionLog(trackTurnLeft.ToString());
                }

                // TrackTurnRight
                else if (p.http_url_split[2].Equals("TrackTurnRight"))
                {
                    TrackTurnRight trackTurnRight = new TrackTurnRight(float.Parse(param[1]));
                    Console.WriteLine("DEBUG: TrackTurnRight: ValueA - " + trackTurnRight.ValueA.ToString());
                    p.writeSuccess();
                    ActionLogger.writeActionLog(trackTurnRight.ToString());
                }

                // TrackArcLeft
                else if (p.http_url_split[2].Equals("TrackArcLeft"))
                {
                    TrackArcLeft trackArcLeft = new TrackArcLeft(float.Parse(param[1]), float.Parse(param[3]));
                    Console.WriteLine("DEBUG: TrackArcLeft: ValueA - " + trackArcLeft.ValueA.ToString());
                    Console.WriteLine("DEBUG: TrackArcLeft: ValueL - " + trackArcLeft.ValueL.ToString());
                    p.writeSuccess();
                    ActionLogger.writeActionLog(trackArcLeft.ToString());
                }

                // TrackArcRight
                else if (p.http_url_split[2].Equals("TrackArcRight"))
                {
                    TrackArcRight trackArcRight = new TrackArcRight(float.Parse(param[1]), float.Parse(param[3]));
                    Console.WriteLine("DEBUG: TrackArcRight: ValueA - " + trackArcRight.ValueA.ToString());
                    Console.WriteLine("DEBUG: TrackArcRight: ValueL - " + trackArcRight.ValueL.ToString());
                    p.writeSuccess();
                    ActionLogger.writeActionLog(trackArcRight.ToString());
                }

                // Error
                else
                {
                    p.writeFailure();
                }
            }
            // Start
            else if (p.http_url_split[1].Equals("Start"))
            {
                Console.WriteLine("DEBUG: Tuck Tuck");
                p.writeSuccess();

                //Alle Befehle abarbeiten
                bool BefehleErfolgreich = Fahrbefehle.executeActions();
                if (BefehleErfolgreich)
                {
                    Console.WriteLine("Alle Befehle abgearbeitet");
                }
                else
                {
                    Console.WriteLine("Fehler bei der Verarbeitung");
                }
            }
            else
            {
                p.writeFailure();
            }
        }
Beispiel #5
0
 public TrackLineDragger(TrackLine line)
 {
     this.line = line;
 }