Beispiel #1
0
        /// <summary>
        /// 生成箭头
        /// </summary>
        /// <param name="type">线路类型</param>
        /// <param name="startPt">起始点</param>
        /// <param name="endPt">结束点</param>
        /// <param name="direction">线路起始和结束点和绘制起始结束点是否相同</param>
        /// <returns></returns>
        public Path DrawArrow(CircuitType type, Point startPt, Point endPt, bool direction)
        {
            double Differ_X = startPt.X - endPt.X;
            double Differ_Y = startPt.Y - endPt.Y;


            Point point1 = new Point();
            Point point2 = new Point();
            Point point3 = new Point();

            if (type == CircuitType.Line)
            {
                if (Differ_X == 0 && Differ_Y > 0)
                {
                    point1 = new Point()
                    {
                        Y = endPt.Y, X = endPt.X + 8
                    };
                    point2 = new Point()
                    {
                        Y = endPt.Y, X = endPt.X - 8
                    };
                    point3 = new Point()
                    {
                        Y = endPt.Y - 17, X = endPt.X
                    };
                }
                if (Differ_X == 0 && Differ_Y < 0)
                {
                    point1 = new Point()
                    {
                        Y = endPt.Y, X = endPt.X + 8
                    };
                    point2 = new Point()
                    {
                        Y = endPt.Y, X = endPt.X - 8
                    };
                    point3 = new Point()
                    {
                        Y = endPt.Y + 17, X = endPt.X
                    };
                }
                else if (Differ_Y == 0 && Differ_X < 0)
                {
                    point1 = new Point()
                    {
                        Y = endPt.Y - 8, X = endPt.X
                    };
                    point2 = new Point()
                    {
                        Y = endPt.Y + 8, X = endPt.X
                    };
                    point3 = new Point()
                    {
                        Y = endPt.Y, X = endPt.X + 17
                    };
                }
                else if (Differ_Y == 0 && Differ_X > 0)
                {
                    point1 = new Point()
                    {
                        Y = endPt.Y - 8, X = endPt.X
                    };
                    point2 = new Point()
                    {
                        Y = endPt.Y + 8, X = endPt.X
                    };
                    point3 = new Point()
                    {
                        Y = endPt.Y, X = endPt.X - 17
                    };
                }
                if (direction)
                {
                    if ((Differ_X < 0 && Differ_Y > 0 && Math.Abs(Differ_X) < 20) || (Differ_X > 0 && Differ_Y > 0 && Math.Abs(Differ_X) < 20))
                    {
                        point1 = new Point()
                        {
                            Y = endPt.Y, X = endPt.X - 8
                        };
                        point2 = new Point()
                        {
                            Y = endPt.Y, X = endPt.X + 8
                        };
                        point3 = new Point()
                        {
                            Y = endPt.Y - 17, X = endPt.X
                        };
                    }
                    else if ((Differ_X < 0 && Differ_Y < 0 && Math.Abs(Differ_X) < 20) || (Differ_X > 0 && Differ_Y < 0 && Math.Abs(Differ_X) < 20))
                    {
                        point1 = new Point()
                        {
                            Y = endPt.Y, X = endPt.X - 8
                        };
                        point2 = new Point()
                        {
                            Y = endPt.Y, X = endPt.X + 8
                        };
                        point3 = new Point()
                        {
                            Y = endPt.Y + 17, X = endPt.X
                        };
                    }
                }
            }
            else if (type == CircuitType.Broken)
            {
                if (direction)
                {
                    if (Differ_X < 0 && Differ_Y < 0)
                    {
                        point1 = new Point()
                        {
                            Y = endPt.Y, X = endPt.X - 8
                        };
                        point2 = new Point()
                        {
                            Y = endPt.Y, X = endPt.X + 8
                        };
                        point3 = new Point()
                        {
                            Y = endPt.Y + 17, X = endPt.X
                        };
                    }
                    else if (Differ_X < 0 && Differ_Y > 0)
                    {
                        point1 = new Point()
                        {
                            Y = endPt.Y, X = endPt.X - 8
                        };
                        point2 = new Point()
                        {
                            Y = endPt.Y, X = endPt.X + 8
                        };
                        point3 = new Point()
                        {
                            Y = endPt.Y - 17, X = endPt.X
                        };
                    }
                    else if (Differ_X > 0 && Differ_Y > 0)
                    {
                        point1 = new Point()
                        {
                            Y = endPt.Y, X = endPt.X - 8
                        };
                        point2 = new Point()
                        {
                            Y = endPt.Y, X = endPt.X + 8
                        };
                        point3 = new Point()
                        {
                            Y = endPt.Y - 17, X = endPt.X
                        };
                    }
                    else if (Differ_X > 0 && Differ_Y < 0)
                    {
                        point1 = new Point()
                        {
                            Y = endPt.Y, X = endPt.X - 8
                        };
                        point2 = new Point()
                        {
                            Y = endPt.Y, X = endPt.X + 8
                        };
                        point3 = new Point()
                        {
                            Y = endPt.Y + 17, X = endPt.X
                        };
                    }
                }
                else
                {
                    if (Differ_X < 0 && Differ_Y < 0)
                    {
                        point1 = new Point()
                        {
                            Y = endPt.Y - 8, X = endPt.X
                        };
                        point2 = new Point()
                        {
                            Y = endPt.Y + 8, X = endPt.X
                        };
                        point3 = new Point()
                        {
                            Y = endPt.Y, X = endPt.X + 17
                        };
                    }
                    if (Differ_X > 0 && Differ_Y > 0 || Differ_X > 0 && Differ_Y < 0)
                    {
                        point1 = new Point()
                        {
                            Y = endPt.Y - 8, X = endPt.X
                        };
                        point2 = new Point()
                        {
                            Y = endPt.Y + 8, X = endPt.X
                        };
                        point3 = new Point()
                        {
                            Y = endPt.Y, X = endPt.X - 17
                        };
                    }
                    else if (Differ_X > 0 && Differ_Y < 0 || Differ_X > 0 && Differ_Y > 0)
                    {
                        point1 = new Point()
                        {
                            Y = endPt.Y - 8, X = endPt.X
                        };
                        point2 = new Point()
                        {
                            Y = endPt.Y + 8, X = endPt.X
                        };
                        point3 = new Point()
                        {
                            Y = endPt.Y, X = endPt.X - 17
                        };
                    }
                }
            }
            Path x_axisArrow = new Path();//x轴箭头

            //x_axisArrow.Fill = new SolidColorBrush(Color.FromRgb(0, 0, 0));
            x_axisArrow.Fill = new SolidColorBrush(Colors.Green);
            PathFigure x_axisFigure = new PathFigure();

            x_axisFigure.IsClosed   = true;
            x_axisFigure.StartPoint = point1;                          //路径的起点
            x_axisFigure.Segments.Add(new LineSegment(point2, false)); //第2个点
            x_axisFigure.Segments.Add(new LineSegment(point3, false)); //第3个点
            PathGeometry x_axisGeometry = new PathGeometry();

            x_axisGeometry.Figures.Add(x_axisFigure);
            x_axisArrow.Data = x_axisGeometry;
            Panel.SetZIndex(x_axisArrow, 9996);
            this.CanvasMain.Children.Add(x_axisArrow);
            return(x_axisArrow);
        }
Beispiel #2
0
        private void CalculateNewCharacteristics(out Double R, out Double L, out Double C, CircuitType type, String name)
        {
            R = 0.0d;
            L = 0.0d;
            C = 0.0d;
            String key = "";

            switch (type)
            {
            case CircuitType.SRL:
            case CircuitType.SRC:
            case CircuitType.SRLC:
                key = "Zmeas" + name;
                break;

            case CircuitType.PRL:
            case CircuitType.PRC:
            case CircuitType.PRLC:
                key = "Ymeas" + name;
                break;

            case CircuitType.NONE:
            default:
                break;
            }

            Generator.CalculateNewCharacter(
                out R,
                out L,
                out C,
                freqs.ToArray(),
                GetArrayOfReal(allVectors[key]),
                GetArrayOfImag(allVectors[key]),
                type);
        }
Beispiel #3
0
        public static Complex CalculateResistance(Double Rs, Double Ls, Double Cs, double freq, CircuitType type)
        {
            Double X = 0.0d;
            Double R = Rs;

            switch (type)
            {
            case CircuitType.SRL:
                X = 2.0d * Math.PI * freq * Ls;
                break;

            case CircuitType.SRC:
                X = -1.0d / (2.0d * Math.PI * freq * Cs);      // УЧИТЫВАЕТСЯ МИНУС МНИМОЙ ЧАСТИ
                break;

            case CircuitType.SRLC:
                X = (2.0d * Math.PI * freq * Ls) - (1.0d / (2.0d * Math.PI * freq * Cs));
                break;

            default:
                break;
            }

            return(new Complex(R, X));
        }
Beispiel #4
0
        public static Complex CalculateConduction(Double Rp, Double Lp, Double Cp, double freq, CircuitType type)
        {
            Double B = 0.0d;
            Double G = 1.0d / Rp;

            switch (type)
            {
            case CircuitType.PRL:
                B = 2.0d * Math.PI * freq * Cp;
                break;

            case CircuitType.PRC:
                B = -1.0d / (2.0d * Math.PI * freq * Lp);     // УЧИТЫВАЕТСЯ МИНУС МНИМОЙ ЧАСТИ
                break;

            case CircuitType.PRLC:
                B = (2.0d * Math.PI * freq * Cp) - 1.0d / (2.0d * Math.PI * freq * Lp);
                break;

            default:
                break;
            }

            return(new Complex(G, B));
        }
Beispiel #5
0
        public static Dictionary <int, Label> MainvaluePairs = new Dictionary <int, Label>(); //Main信标集合


        /// <summary>
        /// 载入地图数据
        /// </summary>
        /// <param name="Times"></param>
        /// <param name="MapIN"></param>
        public void SelectMap(long Times, Canvas MapIN, bool type)
        {
            if (ther != true || theg != true || thms != true)
            {
                return;
            }
            Thread thread = new Thread(() =>
            {
                lock (_locker)
                {
                    ther         = false;
                    DataTable da = tagInfo.RataTable(Times.ToString());
                    foreach (DataRow item in da.Rows)
                    {
                        MapIN.Dispatcher.BeginInvoke(new Action <DataRow>(S =>
                        {
                            Label label = TagCreate(new Point()
                            {
                                X = (Convert.ToDouble(S["X"].ToString()) * Sise) - 19, Y = (Convert.ToDouble(S["Y"].ToString()) * Sise) - 11.5
                            }, Convert.ToInt32(S["TagName"].ToString()), false);
                            if (type)//编辑地图线路添加单击事件,否则不需要
                            {
                                label.MouseDown += Label_MouseDown;
                            }
                            MapIN.Children.Add(label);
                        }), item);
                    }
                    ther = true;
                }
            });

            thread.IsBackground = true;
            thread.Start();

            Thread th = new Thread(() =>
            {
                lock (_locker)
                {
                    theg         = false;
                    DataTable dt = infoBLL.LinelistArrer(Times.ToString());
                    foreach (DataRow data in dt.Rows)
                    {
                        MapIN.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            if (Convert.ToInt32(data["LineStyel"].ToString()) == 1)
                            {
                                GetCircuitType = (CircuitType.Line);
                            }
                            else if (Convert.ToInt32(data["LineStyel"].ToString()) == 2)
                            {
                                GetCircuitType = (CircuitType.Broken);
                            }
                            else if (Convert.ToInt32(data["LineStyel"].ToString()) == 3)
                            {
                                GetCircuitType = (CircuitType.Semicircle);
                            }
                            Pairsarray.Add(new WirePoint()
                            {
                                TagID = Convert.ToInt32(data["Tag1"].ToString().Substring(2)), SetPoint = new Point()
                                {
                                    X = Convert.ToDouble(data["StartX"].ToString()) * Sise, Y = Convert.ToDouble(data["StartY"].ToString()) * Sise
                                }
                            });
                            Pairsarray.Add(new WirePoint()
                            {
                                TagID = Convert.ToInt32(data["Tag2"].ToString().Substring(2)), SetPoint = new Point()
                                {
                                    X = Convert.ToDouble(data["EndX"].ToString()) * Sise, Y = Convert.ToDouble(data["EndY"].ToString()) * Sise
                                }
                            });
                            AddLine(MapIN, false);
                            Pairsarray.Clear();
                        }));
                    }
                    theg = true;
                }
            });

            th.IsBackground = true;
            th.Start();

            Thread ts = new Thread(() =>
            {
                lock (_locker)
                {
                    thms         = false;
                    DataTable ta = widgetInfos.WidgetLIst(Times.ToString());
                    foreach (DataRow tables in ta.Rows)
                    {
                        MapIN.Dispatcher.BeginInvoke(new Action <DataRow>(table =>
                        {
                            if (table["WidgetNo"].ToString().Substring(0, 2).Equals("AR"))
                            {
                                MapIN.Children.Add(NewArea(new Point()
                                {
                                    X = (Convert.ToDouble(table["X"].ToString()) * Sise), Y = (Convert.ToDouble(table["Y"].ToString()) * Sise)
                                }, table["Name"].ToString(), Convert.ToInt32(table["WidgetNo"].ToString().Substring(2)), table["BackColor"].ToString(), table["ForeColor"].ToString(), table["BorderColor"].ToString(), Convert.ToDouble(table["FontSize"].ToString()), Convert.ToDouble(table["Width"].ToString()), Convert.ToDouble(table["Height"].ToString()), table["FontPosition"].ToString()));
                            }
                            else
                            {
                                MapIN.Children.Add(FontTextNew(new Point()
                                {
                                    X = (Convert.ToDouble(table["X"].ToString()) * Sise), Y = (Convert.ToDouble(table["Y"].ToString()) * Sise)
                                }, table["Name"].ToString(), Convert.ToInt32(table["WidgetNo"].ToString().Substring(2)), Convert.ToDouble(table["FontSize"].ToString()), table["ForeColor"].ToString()));
                            }
                        }), tables);
                    }
                    thms = true;
                }
            });

            ts.IsBackground = true;
            ts.Start();
        }
Beispiel #6
0
        public static void CalculateNewCharacter(
            out Double R,
            out Double L,
            out Double C,
            Double[] freq,
            Double[] measReal,
            Double[] measImag,
            CircuitType type)
        {
            double dP = 2.0d * Math.PI;
            double d1 = 0.0d;
            double d2 = 0.0d;

            double[] powF       = new double[freq.Count()];
            double[] multiXF    = new double[freq.Count()];
            double[] dividePowF = new double[freq.Count()];
            double[] divideXF   = new double[freq.Count()];

            for (int i = 0; i < freq.Count(); i++)
            {
                powF[i]       = Math.Pow(freq[i], 2.0d);
                multiXF[i]    = measImag[i] * freq[i];
                divideXF[i]   = measImag[i] / freq[i];
                dividePowF[i] = 1.0d / powF[i];
            }

            matrixDivideAB(
                out d1,
                out d2,
                powF.Sum(),
                freq.Count(),
                freq.Count(),
                dividePowF.Sum(),
                multiXF.Sum(),
                divideXF.Sum());

            R = measReal.Sum() / measReal.Count();
            L = 0.0d;
            C = 0.0d;

            switch (type)
            {
            case CircuitType.SRL:
                L = multiXF.Sum() / powF.Sum() / dP;
                break;

            case CircuitType.PRL:
                R = 1 / R;
                C = multiXF.Sum() / powF.Sum() / dP;
                break;

            case CircuitType.SRC:
                C = -1.0d / (dP * (divideXF.Sum() / dividePowF.Sum()));
                break;

            case CircuitType.PRC:
                R = 1 / R;
                L = -1.0d / (dP * (divideXF.Sum() / dividePowF.Sum()));
                break;

            case CircuitType.SRLC:
                L = d1 / dP;
                C = -1.0d / (d2 * dP);
                break;

            case CircuitType.PRLC:
                R = 1 / R;
                C = d1 / dP;
                L = -1.0d / (d2 * dP);
                break;

            default:
                break;
            }
        }
Beispiel #7
0
        /// <summary>
        /// 载入Main地图数据
        /// </summary>
        /// <param name="Times"></param>
        /// <param name="MapIN"></param>
        public void SelectMapLOad(long Times, Canvas MapIN)
        {
            if (MapsTige != true || LineMaps != true)
            {
                return;
            }
            MapInstrument.keyValuePairs.Clear();
            MapInstrument.valuePairs.Clear();
            MapInstrument.wirePointArrays.Clear();
            MapInstrument.GetKeyValues.Clear();
            MainwirePoint.Clear();
            MainvaluePairs.Clear();
            Painting.siseWin = 1;
            Thread th = new Thread(() =>
            {
                lock (_locker)
                {
                    MapsTige     = false;
                    DataTable dt = infoBLL.LinelistArrer(Times.ToString());
                    foreach (DataRow data in dt.Rows)
                    {
                        MapIN.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            if (Convert.ToInt32(data["LineStyel"].ToString()) == 1)
                            {
                                GetCircuitType = (CircuitType.Line);
                            }
                            else if (Convert.ToInt32(data["LineStyel"].ToString()) == 2)
                            {
                                GetCircuitType = (CircuitType.Broken);
                            }
                            else if (Convert.ToInt32(data["LineStyel"].ToString()) == 3)
                            {
                                GetCircuitType = (CircuitType.Semicircle);
                            }
                            Pairsarray.Add(new WirePoint()
                            {
                                TagID = Convert.ToInt32(data["Tag1"].ToString().Substring(2)), SetPoint = new Point()
                                {
                                    X = Convert.ToDouble(data["StartX"].ToString()) * Sise, Y = Convert.ToDouble(data["StartY"].ToString()) * Sise
                                }
                            });
                            Pairsarray.Add(new WirePoint()
                            {
                                TagID = Convert.ToInt32(data["Tag2"].ToString().Substring(2)), SetPoint = new Point()
                                {
                                    X = Convert.ToDouble(data["EndX"].ToString()) * Sise, Y = Convert.ToDouble(data["EndY"].ToString()) * Sise
                                }
                            });
                            AddLine(MapIN, true);
                            Pairsarray.Clear();
                        }));
                    }
                    MapsTige = true;
                }
            });

            th.IsBackground = true;
            th.Start();


            Thread thread = new Thread(() =>
            {
                lock (_locker)
                {
                    LineMaps     = false;
                    DataTable da = tagInfo.RataTable(Times.ToString());
                    foreach (DataRow item in da.Rows)
                    {
                        MapIN.Dispatcher.BeginInvoke(new Action <DataRow>(S =>
                        {
                            TagCreate(new Point()
                            {
                                X = (Convert.ToDouble(S["X"].ToString()) * Sise) - 19, Y = (Convert.ToDouble(S["Y"].ToString()) * Sise) - 11.5
                            }, Convert.ToInt32(S["TagName"].ToString()), true);
                        }), item);
                    }
                    LineMaps = true;;
                }
            });

            thread.IsBackground = true;
            thread.Start();
        }
Beispiel #8
0
 /// <summary>
 /// 清除
 /// </summary>
 public void ClearTen()
 {
     PathStatic     = true;
     GetCircuitType = CircuitType.Clear;//清除
     TagFormer();
 }
Beispiel #9
0
 /// <summary>
 /// 折线
 /// </summary>
 public void Brokene()
 {
     PathStatic     = true;
     GetCircuitType = CircuitType.Broken;//折线绘制
     TagFormer();
 }
Beispiel #10
0
 /// <summary>
 /// 半圆线路
 /// </summary>
 public void Semicircles()
 {
     PathStatic     = true;
     GetCircuitType = CircuitType.Semicircle;//绘制半圆
     TagFormer();
 }
Beispiel #11
0
 /// <summary>
 /// 直线线路点击
 /// </summary>
 public void Mapstraight()
 {
     PathStatic     = true;
     GetCircuitType = CircuitType.Line;//绘制直线
     TagFormer();
 }