Example #1
0
        public byte[] GetBytes(bool skipSignature = false)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Write(PreviousBlockId.ToByteArray());
                    writer.Write(Height);
                    writer.Write(Timestamp);

                    writer.Write(PayloadLength);
                    writer.Write(PayloadHash.FromHex());
                    writer.Write(Delegate.FromHex());
                    writer.Write(PointId.ToByteArray());
                    writer.Write(PointHeight);
                    writer.Write(BlockCount);
                    writer.Write(Height);

                    if (!skipSignature && !string.IsNullOrWhiteSpace(Signature))
                    {
                        writer.Write(Signature.FromHex());
                    }
                }
                return(stream.ToArray());
            }
        }
Example #2
0
        public Point(
            PointId id,
            double longitude,
            double latitude,
            double distance,
            double speedInLongitude,
            double speedInLatitude,
            double speedInDistance,
            Sign sign,
            ClassicHouse classicHouse,
            double degree,
            bool isDirect)
        {
            Id               = id;
            Longitude        = longitude;
            Latitude         = latitude;
            Distance         = distance;
            SpeedInLongitude = speedInLongitude;
            SpeedInLatitude  = speedInLatitude;
            SpeedInDistance  = speedInDistance;

            Sign         = sign;
            ClassicHouse = classicHouse;
            Degree       = degree;
            IsDirect     = isDirect;
        }
Example #3
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = InstanceId;
         hashCode = (hashCode * 397) ^ (Location != null ? Location.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (PointId?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
Example #4
0
        public static DateTime Converge1(
            PointId id,
            double targetLongitude,
            Event ev)
        {
            var result = ConvergeHelper1(id, targetLongitude, ev, 500, false);

            var dt = result;

            result = new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, ev.Time.Second);

            return(result);
        }
Example #5
0
        static DateTime ConvergeHelper1(
            PointId id,
            double targetLongitude,
            Event ev,
            double ms,
            bool reverse)
        {
            DateTime currentGuess = ev.Time;
            var      currentBody  = Points(new PointId[] { id }, ev)[0];

            if (EqDeg(currentBody.Longitude, targetLongitude, ms))
            {
                return(currentGuess);
            }

            DateTime newGuess = default(DateTime);

            double yearPercent = default(double);

            yearPercent = -1d * (currentBody.Longitude - targetLongitude) / 360d;
            if (id == PointId.Ra || id == PointId.Ke || id == PointId.MeanNode || id == PointId.TrueNode)
            {
                yearPercent *= -1d;
            }

            if (reverse)
            {
                yearPercent *= -1d;
            }

            if (id == PointId.Mo)
            {
                newGuess = currentGuess.AddDays(yearPercent * YearLen / 13d);
            }
            else
            {
                newGuess = currentGuess.AddDays(yearPercent * YearLen);
            }

            return(ConvergeHelper1(
                       id,
                       targetLongitude,
                       new Event(
                           newGuess,
                           ev.Position,
                           ev.Conf),
                       ms,
                       reverse));
        }
Example #6
0
    void CalculationPoint(Vector3 Point, int R)
    {
        Vector3 tempPoint = new Vector3(0, 0, 0);

        tempPoint.y = Point.y;
        switch (CurrentPointEnum)
        {
        case PointId.One:
            tempPoint.x = Point.x - R * Mathf.Cos(cosAngle);
            tempPoint.z = Point.z + R * Mathf.Sin(cosAngle);
            //tempPoint.x = Point.x - R;
            // tempPoint.z = Point.z;
            PointList.Add(tempPoint);
            flagposdir.Add(0, tempPoint);
            CurrentPointEnum = PointId.Two;

            break;

        case PointId.Two:
            tempPoint.x = Point.x;
            tempPoint.z = Point.z + R;
            // tempPoint.x = Point.x - R*Mathf.Cos(angle);
            // tempPoint.z = Point.z+R* Mathf.Sin(angle);
            PointList.Add(tempPoint);
            flagposdir.Add(1, tempPoint);
            CurrentPointEnum = PointId.Three;

            break;

        case PointId.Three:
            tempPoint.x = Point.x + R * Mathf.Cos(cosAngle);
            tempPoint.z = Point.z + R * Mathf.Sin(cosAngle);
            // tempPoint.x = Point.x - R * Mathf.Cos(angle*2);
            //tempPoint.z = Point.z + R * Mathf.Sin(angle*2);
            PointList.Add(tempPoint);
            flagposdir.Add(2, tempPoint);
            CurrentPointEnum = PointId.Four;

            break;

        case PointId.Four:
            tempPoint.x = Point.x + R * Mathf.Cos(culAngle);
            tempPoint.z = Point.z - R * Mathf.Sin(culAngle);
            // tempPoint.x = Point.x - R * Mathf.Cos(angle * 3);
            //tempPoint.z = Point.z + R * Mathf.Sin(angle * 3);
            PointList.Add(tempPoint);
            flagposdir.Add(3, tempPoint);
            CurrentPointEnum = PointId.Five;

            break;

        case PointId.Five:
            tempPoint.x = Point.x - R * Mathf.Cos(culAngle);
            tempPoint.z = Point.z - R * Mathf.Sin(culAngle);
            // tempPoint.x = Point.x - R * Mathf.Cos(angle * 4);
            // tempPoint.z = Point.z + R * Mathf.Sin(angle * 4);
            PointList.Add(tempPoint);
            flagposdir.Add(4, tempPoint);
            CurrentPointEnum = PointId.Five;

            break;
        }
    }
Example #7
0
        public async Task <bool> ReadData()
        {
            ResultData = new Dictionary <DateTime, Dictionary <string, double> >();
            DateTime date = DateStart.AddHours(0);

            while (date < DateEnd)
            {
                DateTime de = date.AddHours(0);
                switch (Period)
                {
                case EDSReportPeriod.sec:
                    de = date.AddSeconds(1);
                    break;

                case EDSReportPeriod.minute:
                    de = date.AddMinutes(1);
                    break;

                case EDSReportPeriod.hour:
                    de = date.AddHours(1);
                    break;

                case EDSReportPeriod.day:
                    de = date.AddDays(1);
                    break;

                case EDSReportPeriod.month:
                    de = date.AddMonths(1);
                    break;
                }
                ResultData.Add(date, new Dictionary <string, double>());
                foreach (string id in RequestData.Keys)
                {
                    ResultData[date].Add(id, 0);
                }
                date = de.AddHours(0);
            }


            List <TabularRequestItem> list = new List <TabularRequestItem>();

            foreach (EDSReportRequestRecord rec in RequestData.Values)
            {
                list.Add(new TabularRequestItem()
                {
                    function = EDSClass.getReportFunctionName(rec.Function),
                    pointId  = new PointId()
                    {
                        iess = rec.Point.IESS
                    },
                    shadePriority = rec.Point.IsShade ? ShadePriority.SHADEOVERREGULAR : ShadePriority.REGULAROVERSHADE
                });
            }



            if (!EDSClass.Connected)
            {
                EDSClass.Connect();
            }
            if (EDSClass.Connected)
            {
                if (Period != EDSReportPeriod.month)
                {
                    List <DateTime> dates = ResultData.Keys.ToList();
                    DateTime        ds    = DateStart.AddHours(0);
                    DateTime        de    = DateStart.AddHours(1);
                    while (ds < DateEnd)
                    {
                        if (Period == EDSReportPeriod.minute || Period == EDSReportPeriod.sec)
                        {
                            int i0 = dates.IndexOf(ds);
                            int i1 = i0 + 1000;
                            de = i1 < dates.Count ? dates[i1] : DateEnd;
                        }
                        else
                        {
                            de = de.AddDays(5);
                            try {
                                de = dates.First(d => d >= de);
                            } catch {
                                de = DateEnd;
                            }
                        }

                        EDSClass.Single.GlobalInfo = String.Format("{0}-{1}", ds.ToString("dd.MM.yyyy HH:mm:ss"), de.ToString("dd.MM.yyyy HH:mm:ss"));

                        TabularRequest req = new TabularRequest();
                        req.period = new TimePeriod()
                        {
                            from = new Timestamp()
                            {
                                second = EDSClass.toTS(ds)
                            },
                            till = new Timestamp()
                            {
                                second = EDSClass.toTS(de)
                            }
                        };

                        req.step = new TimeDuration()
                        {
                            seconds = EDSClass.getPeriodSeconds(Period)
                        };
                        req.items = list.ToArray();
                        uint         id = EDSClass.Client.requestTabular(EDSClass.AuthStr, req);
                        TabularRow[] rows;
                        bool         ok = await EDSClass.ProcessQueryAsync(id);

                        if (!ok)
                        {
                            break;
                        }
                        PointId[]     points = EDSClass.Client.getTabular(EDSClass.AuthStr, id, out rows);
                        List <string> keys   = RequestData.Keys.ToList();

                        foreach (TabularRow row in rows)
                        {
                            DateTime dt = EDSClass.fromTS(row.ts.second);
                            for (int i = 0; i < row.values.Count(); i++)
                            {
                                double  val   = EDSClass.getVal(row.values[i].value);
                                PointId point = points[i];
                                string  resId = keys[i];
                                EDSReportRequestRecord request = RequestData[resId];
                                if (request.Function == EDSReportFunction.vyrab && Period == EDSReportPeriod.day)
                                {
                                    val *= 24;
                                }
                                ResultData[dt][resId] = val;
                            }
                        }

                        ds = de.AddHours(0);
                    }
                }
                else
                {
                    DateTime ds = DateStart.AddHours(0);
                    while (ds < DateEnd)
                    {
                        EDSClass.Single.GlobalInfo = String.Format("{0}-{1}", ds.ToString("dd.MM.yyyy"), ds.AddMonths(1).ToString("dd.MM.yyyy"));
                        DateTime       de  = ds.AddMonths(1);
                        TabularRequest req = new TabularRequest();
                        req.period = new TimePeriod()
                        {
                            from = new Timestamp()
                            {
                                second = EDSClass.toTS(ds)
                            },
                            till = new Timestamp()
                            {
                                second = EDSClass.toTS(de)
                            }
                        };


                        int seconds = (int)(EDSClass.toTS(de) - EDSClass.toTS(ds));
                        req.step = new TimeDuration()
                        {
                            seconds = seconds
                        };
                        req.items = list.ToArray();
                        uint         id = EDSClass.Client.requestTabular(EDSClass.AuthStr, req);
                        TabularRow[] rows;
                        bool         ok = await EDSClass.ProcessQueryAsync(id);

                        if (!ok)
                        {
                            break;
                        }
                        PointId[]     points = EDSClass.Client.getTabular(EDSClass.AuthStr, id, out rows);
                        List <string> keys   = RequestData.Keys.ToList();

                        TabularRow row = rows.First();
                        DateTime   dt  = EDSClass.fromTS(row.ts.second);
                        for (int i = 0; i < row.values.Count(); i++)
                        {
                            double  val   = EDSClass.getVal(row.values[i].value);
                            PointId point = points[i];
                            string  resId = keys[i];
                            EDSReportRequestRecord request = RequestData[resId];
                            if (request.Function == EDSReportFunction.vyrab)
                            {
                                val *= seconds / 3600.0;
                            }
                            ResultData[dt][resId] = val;
                        }

                        ds = de.AddHours(0);
                    }
                }
            }

            return(true);
        }
Example #8
0
 public Point(PointId planet, Sign sign, ClassicHouse house) : this(planet, 0, 0, 0, 0, 0, 0, sign, house, 0, true)
 {
 }