Exemplo n.º 1
0
        private UnitValue(string s)
        {
            //Cut numbers to the left, from unit to the riht
            var regex      = new System.Text.RegularExpressions.Regex("([-]|[.,]|[-.,]|[0-9])[0-9]*[.,]*[0-9]*");
            var collection = regex.Matches(s);

            if (collection.Count != 1)
            {
                throw new InvalidOperationException(string.Format("Cannot parse {0}.", s));
            }
            if (collection[0].Index != 0)
            {
                throw new InvalidOperationException(string.Format("Cannot parse {0}.", s));
            }

            //Get the value part
            var    value = s.Substring(0, collection[0].Length);
            double d;

            value = value.Replace(".", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
            if (!double.TryParse(value, out d))
            {
                throw new InvalidOperationException(string.Format("Cannot parse {0} to a double.", value));
            }
            _value = d;

            //Get the unit part
            _unit = s.Substring(collection[0].Length).ToUnit();
        }
Exemplo n.º 2
0
 public FSensors(string _title, EUnit _Tp)
 {
     InitializeComponent();
     needRecalc = false;
     title      = _title;
     Tp         = _Tp;
 }
Exemplo n.º 3
0
    public void AddEventListener(string evt, GameEventCallBack callback, object owner)
    {
        List <EUnit> tList = null;

        if (!mGameEvent2Listeners.TryGetValue(evt, out tList))
        {
            tList = BorrowList();
            mGameEvent2Listeners.Add(evt, tList);
        }

        bool bHas = false;

        for (int i = 0; i < tList.Count; i++)
        {
            if (tList[i].callback == callback)
            {
                bHas = true;
                break;
            }
        }
        if (!bHas)
        {
            EUnit tEUnit = BorrowEUnit();
            tEUnit.Set((owner == null ? 0 : owner.GetHashCode()), callback);
            tList.Add(tEUnit);
        }
    }
Exemplo n.º 4
0
        public void Init(EUnit _Tp, DOnRecalc _OnRecalc)
        {
            Tp       = _Tp;
            OnRecalc = _OnRecalc;
            if (RK.ST.cDef(Tp).Zone == null)
            {
                return;
            }
            H = ParAll.ST.Defect.Some.SensorHeight;
            Zone z = RK.ST.cDef(Tp).result.MZone[0];

            for (int i = 0; i < z.MSensor.Length; i++)
            {
                USensor p = new USensor();
                p.OnStep       += new UCalibr.DOnStep(p_OnStep);
                p.OnCalibrate  += new USensor.DOnCalibrate(p_OnCalibrate);
                p.OnGain       += new USensor.DOnGain(p_OnGain);
                p.CalibrVisible = false;
                p.IsWheel       = false;
                p.CanFocused    = true;
                L.Add(p);
                Controls.Add(p);
            }
            RResize();
            ResizeCharts();
            SetGainsFromPars();
            IsScroll = true;
        }
Exemplo n.º 5
0
 BankZoneDataA GetNextZoneA(EUnit _Tp)
 {
     lock (cs)
     {
         BankCLUnitA MUnit = null;
         if (_Tp == EUnit.Cross)
         {
             MUnit = MCross;
         }
         else if (_Tp == EUnit.Line)
         {
             MUnit = MLine;
         }
         if (MUnit != null)
         {
             BankZoneDataA z = MUnit.GetNextDataUnitZoneA(TubeLength, MTP);
             if (z != null)
             {
                 MZR.confirmed = GetConfirmed();
                 pr("!!!GetNextZoneA: " + z.ToString());
             }
             return(z);
         }
         return(null);
     }
 }
Exemplo n.º 6
0
        public void ReadXml(XmlReader reader)
        {
            reader.ReadStartElement();
            var readNode = Parse(reader.ReadContentAsString());

            time = readNode.time; unit = readNode.unit;
            reader.ReadEndElement();
        }
Exemplo n.º 7
0
 private void ReturnEUnit(EUnit unit)
 {
     if (unit != null)
     {
         unit.Reset();
         mEUnitPool.Add(unit);
     }
 }
Exemplo n.º 8
0
        public BankCLUnitA(EUnit _type, cIW _IW)
            : base(_type)
        {
            Clear();
            DefCL dcl = new DefCL(Tp);

            //            f_acq = (dcl.LCh.Count + (_IW.SG ? 2 : 0)) * dcl.L502.FrequencyPerChannel;
            f_acq = dcl.LCh.Count * dcl.L502.FrequencyPerChannel;
        }
Exemplo n.º 9
0
//        public double Level { get; private set; }

        public Sensor(EUnit _Tp, int _size)
        {
            Tp    = _Tp;
            MMeas = new Meas[_size];
            for (int im = 0; im < MMeas.Length; im++)
            {
                MMeas[im] = new Meas();
            }
        }
Exemplo n.º 10
0
 public void AddGroup(EUnit _Tp, double[] _data)
 {
     lock (cs)
     {
         if (_data == null)
         {
             return;
         }
         //BankCLUnitA MUnit=null;
         if (_Tp == EUnit.Cross)
         {
             int lsize        = 0;
             int crossSensors = 0;
             if (MCross != null)
             {
                 crossSensors = MCross.Sensors;
                 lsize       += MCross.Sensors;
             }
             if (MSG != null)
             {
                 lsize += MSG.Sensors;
             }
             if (MCross != null)
             {
                 MCross.Add(_data, 0, lsize);
                 pr(string.Format("AddGroup++: {0} size={1} count={2} f_acq={3}",
                                  Current.EUnitToString(_Tp),
                                  _data.Length.ToString(),
                                  MCross.Count.ToString(),
                                  MCross.f_acq.ToString()));
             }
             if (MSG != null)
             {
                 if (MSG.LastData)
                 {
                     return;
                 }
                 MSG.Add(_data, crossSensors, lsize);
                 pr(string.Format("AddGroupSG++: {0} count={1}",
                                  Current.EUnitToString(EUnit.SG),
                                  MSG.Count.ToString()));
             }
         }
         else if (_Tp == EUnit.Line)
         {
             if (MLine != null)
             {
                 MLine.Add(_data, 0, MLine.Sensors);
                 pr(string.Format("AddGroup++: {0} count={1} f_acq={2}",
                                  Current.EUnitToString(_Tp),
                                  MLine.Count.ToString(),
                                  MLine.f_acq.ToString()));
             }
         }
     }
 }
Exemplo n.º 11
0
 public void Init(EUnit _Tp)
 {
     Tp                   = _Tp;
     fData                = new FData(Tp, Title, 0, cursorBorder);
     fDataRange           = new FData(Tp, Title, 3, cursorBorder);
     fDataRange.SaveName += "Range";
     fMeases              = new FMeases(Title, cursorBorder, Tp);
     typeView             = ParAll.ST.Defect.Some.TypeView;
     LoadSettings();
 }
Exemplo n.º 12
0
 public FData(EUnit _Tp, string _title, int _range, CursorBorder _cursorBorder)
 {
     InitializeComponent();
     Tp           = _Tp;
     label2.Text  = null;
     title        = _title;
     range        = _range;
     cursorBorder = _cursorBorder;
     OnHide       = ExecHide;
 }
Exemplo n.º 13
0
 public int Size(EUnit _Tp)
 {
     if (_Tp == EUnit.Cross)
     {
         return(this[EUnit.Cross].size + this[EUnit.SG].size);
     }
     if (_Tp == EUnit.Line)
     {
         return(this[EUnit.Line].size);
     }
     return(0);
 }
Exemplo n.º 14
0
Arquivo: RK.cs Projeto: andreyV512/rag
 public CDef cDef(EUnit _type)
 {
     if (_type == EUnit.Cross)
     {
         return(Cross);
     }
     if (_type == EUnit.Line)
     {
         return(Line);
     }
     return(null);
 }
Exemplo n.º 15
0
        private void OnDownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            if (UpdateDownloadStatus.Visibility == Visibility.Collapsed)
            {
                CheckForUpdateButton.IsEnabled  = false;
                UpdateDownloadStatus.Visibility = Visibility.Visible;
            }

            EUnit unit = EUnit.Byte;

            UpdateDownloadStatus.Text =
                $"Downloading Update file '{NebulaClient.Updater.CurrentDownloadedFile}' {new ByteUnit(e.BytesReceived).ToHumanReadable(unit)} / {new ByteUnit(e.TotalBytesToReceive).ToHumanReadable(unit)} {e.ProgressPercentage}%";
        }
Exemplo n.º 16
0
 public RItem this[EUnit _Tp]
 {
     get
     {
         foreach (RItem it in L)
         {
             if (it.Tp == _Tp)
             {
                 return(it);
             }
         }
         return(null);
     }
 }
Exemplo n.º 17
0
        public Angle ToRadian(EUnit newUnit)
        {
            switch (newUnit)
            {
            case EUnit.DEGREE: return(new Angle(angle / degreeRadian, EUnit.RADIAN));

            case EUnit.RADIAN: return(this);

            case EUnit.GRADIAN: return(new Angle(angle / radianGradian, EUnit.RADIAN));

            case EUnit.QUADRANT: return(new Angle((angle * quadDegree) / degreeRadian, EUnit.RADIAN));

            default: return(this);
            }
        }
Exemplo n.º 18
0
    private EUnit BorrowEUnit()
    {
        EUnit tEUnit = null;

        if (mEUnitPool.Count > 0)
        {
            tEUnit = mEUnitPool[0];
            mEUnitPool.RemoveAt(0);
        }
        else
        {
            tEUnit = new EUnit();
        }
        return(tEUnit);
    }
Exemplo n.º 19
0
        public static string ETypeStr(EUnit _tp)
        {
            switch (_tp)
            {
            case EUnit.Cross:
                return("Поперечн.");

            case EUnit.Line:
                return("Продольн.");

            case EUnit.Thick:
                return("Толщиномер.");

            default:
                return("Неопределенн.");
            }
        }
Exemplo n.º 20
0
        internal static double ConvertToUnit(double value, EUnit sourceUnit, EUnit targetUnit)
        {
            int numberOfStepsWithDirection = (int)sourceUnit - (int)targetUnit;
            int numberOfSteps = Math.Abs(numberOfStepsWithDirection);

            if (numberOfStepsWithDirection < 0)
            {
                return(ConvertToUnitByDivision(value, numberOfSteps));
            }
            else if (numberOfStepsWithDirection > 0)
            {
                return(ConvertToUnitByMultiplication(value, numberOfSteps));
            }
            else
            {
                return(value);
            }
        }
Exemplo n.º 21
0
 public FMeases(string _title, CursorBorder _cursorBorder, EUnit _tp)
 {
     InitializeComponent();
     title         = _title;
     Source        = new RUnit(RUnit.EType.Source, chart1.Series[0], chart1.ChartAreas[0].AxisY, CBSource, "Исходный сигнал", toolTip1);
     Median        = new RUnit(RUnit.EType.Median, chart1.Series[1], chart1.ChartAreas[0].AxisY, CBMedian, "Медианный сигнал", toolTip1);
     Filter        = new RUnit(RUnit.EType.Filter, chart1.Series[2], chart1.ChartAreas[0].AxisY, CBFilter, "Фильтрованный сигнал", toolTip1);
     FilterIn      = new RUnit(RUnit.EType.FilterIn, chart1.Series[3], chart1.ChartAreas[0].AxisY, CBFilterIn, "Фильтрованный внутренний сигнал", toolTip1);
     OnHide        = null;
     cursor        = new RCursor(chart1);
     cursor.OnMove = OnMove;
     label1.Text   = null;
     label2.Text   = null;
     cursorBorder  = _cursorBorder;
     OnHide        = ExecHide;
     Tp            = _tp;
     dcl           = new DefCL(_tp);
 }
Exemplo n.º 22
0
        public JCollect(Bank _bank, EUnit _Tp, cIW _IW)
        {
            bank = _bank;
            IW   = _IW;
            Tp   = _Tp;
#if LCARD_VIRTUAL
            lcard = new L502virtual();
#else
            if (Tp == EUnit.Cross)
            {
                lcard = new LCard502(ParAll.ST.Defect.Cross.L502, pr);
            }
            else if (Tp == EUnit.Line)
            {
                lcard = new LCard502E(ParAll.ST.Defect.Line.L502, pr);
            }
#endif
            started   = false;
            LastError = null;
            LastExec  = Environment.TickCount;
        }
Exemplo n.º 23
0
        public int GetRealSize(EUnit _Tp)
        {
            lock (cs)
            {
                switch (_Tp)
                {
                case EUnit.Thick:
                    return(0);

                case EUnit.Cross:
                    return(MCross == null ? 0 : MCross.GetRealSize());

                case EUnit.Line:
                    return(MLine == null ? 0 : MLine.GetRealSize());

                case EUnit.SG:
                    return(MSG == null ? 0 : MSG.GetRealSize());
                }
                return(0);
            }
        }
Exemplo n.º 24
0
        public void Start(EUnit _Tp, int _startTick)
        {
            lock (cs)
            {
                switch (_Tp)
                {
                case EUnit.Thick:

                    if (MThick != null)
                    {
                        MThick.isStarted = true;
                    }
                    break;

                case EUnit.Cross:

                    if (MCross != null)
                    {
                        MCross.isStarted = true;
                        MZR.WaitZones    = MCross.deadEnd;
                    }
                    break;

                case EUnit.Line:
                    if (MLine != null)
                    {
                        MLine.isStarted = true;
                        MZR.WaitZones   = MLine.deadEnd;
                    }
                    break;

                case EUnit.SG:
                    if (MSG != null)
                    {
                        MSG.isStarted = true;
                    }
                    break;
                }
            }
        }
Exemplo n.º 25
0
        //        public void RawStrobesReport() { MLineThick.rawStrobes.Report(); }

        //        public RawStrobes ThickData { get { return (MThick == null ? null : MThick.rawStrobes); } }
        public int GetCountOfUnit(EUnit _Tp)
        {
            lock (cs)
            {
                BankDataUnit bu = null;
                switch (_Tp)
                {
                case EUnit.Cross:
                    bu = MCross;
                    break;

                case EUnit.Line:
                    bu = MLine;
                    break;

                case EUnit.SG:
                    bu = MSG;
                    break;
                }
                return(bu == null ? 0 : bu.Count);
            }
        }
Exemplo n.º 26
0
        public static EType EUnitToEType(EUnit _Tp)
        {
            switch (_Tp)
            {
            case EUnit.Cross:
                return(EType.CROSS);

            case EUnit.Line:
                return(EType.LINE);

            case EUnit.None:
                return(EType.BASE);

            case EUnit.SG:
                return(EType.SG);

            case EUnit.Thick:
                return(EType.THICK);

            default:
                return(EType.BASE);
            }
        }
Exemplo n.º 27
0
        public static string EUnitToString(EUnit _type)
        {
            switch (_type)
            {
            case EUnit.Cross:
                return("Пеперечный");

            case EUnit.Line:
                return("Продольный");

            case EUnit.None:
                return("Неопределенный");

            case EUnit.SG:
                return("ГП");

            case EUnit.Thick:
                return("Толщиномер");

            default:
                return("Неопределенный");
            }
        }
Exemplo n.º 28
0
    public SHugeNumber(double dNumber, EUnit eUnit = EUnit.None)
    {
        bool bIsNegative = dNumber < 0;

        if (bIsNegative)
        {
            dNumber *= -1;
        }

        decimal dNumberDecimal = (decimal)dNumber;
        int     iUnitOffset    = 0;

        while (dNumberDecimal < 1)
        {
            if ((int)eUnit - iUnitOffset <= 0)
            {
                break;
            }

            dNumberDecimal = dNumberDecimal * 1000;
            iUnitOffset--;
        }

        while (dNumberDecimal >= 1000)
        {
            dNumberDecimal = dNumberDecimal / 1000;
            iUnitOffset++;
        }

        _dNumber = (double)dNumberDecimal;
        _eUnit   = eUnit + iUnitOffset;

        if (bIsNegative)
        {
            _dNumber *= -1;
        }
    }
Exemplo n.º 29
0
 public FSensorsColCalibr(EUnit _Tp, string _title)
 {
     InitializeComponent();
     Tp    = _Tp;
     title = _title;
 }
Exemplo n.º 30
0
 public void SetDisplayUnits(EUnitType inType, EUnit units)
 => E_FUnitSettings_SetDisplayUnits(this, (byte)inType, (byte)units);