Esempio n. 1
0
 public NewValue(String code, DateTime time, string signal, NewEnumSignalStatus status)
 {
     Code   = code;
     Time   = time;
     Signal = signal;
     Status = status;
 }
Esempio n. 2
0
        public override void CalcVal(string signal, ref NewEnumSignalStatus status, out double?val)
        {
            val = null;

            if (status == NewEnumSignalStatus.NoError)
            {
                if (signal != null)
                {
                    if ((signal != "+888888") && (signal != "888888"))
                    {
                        double value;
                        if (double.TryParse(signal, NumberStyles.Number, CultureInfo.InvariantCulture.NumberFormat, out value))
                        {
                            val = value;
                        }
                        else
                        {
                            status = NewEnumSignalStatus.SignalValueError;
                        }
                    }
                    else
                    {
                        status = NewEnumSignalStatus.SignalValueError;
                    }
                }
                else
                {
                    status = NewEnumSignalStatus.ReadError;
                }
            }
        }
Esempio n. 3
0
 public NewValue(String code, DateTime time, string signal)
 {
     Code   = code;
     Time   = time;
     Signal = signal;
     Status = NewEnumSignalStatus.NoError;
 }
Esempio n. 4
0
        }                                                          //код ошибки сигнала или его обработки
        #endregion

        #region Constructors/Destructors
        public NewValue(String code, DateTime time)
        {
            Code   = code;
            Time   = time;
            Signal = null;
            Status = NewEnumSignalStatus.NoRead;
        }
Esempio n. 5
0
        public NewChannelValue(NewChannelAbstract channel, DateTime time, NewEnumSignalStatus status) : base(channel.Code, time, status)
        {
            Channel = channel;

            //Time = time;
            //Signal = null;
            Val          = null;
            CurrentValue = null;
            //Status = status;
            ValueChanged = false; //true;

            //заменить на рассчёт CalcValue
        }
Esempio n. 6
0
        protected /*override*/ double?SignalTransform(double value, out NewEnumSignalStatus status)
        {
            double?val = value;
            NewEnumSignalStatus stat = NewEnumSignalStatus.NoError;

            switch (ChannelRange)
            {
            case "02":
                if ((InLevel != null) && (InLevel.StartsWith("ТХК ")))
                {
                    string thType = InLevel.Substring(4);

                    NewChannelAdamAbstract cjc = ((NewModuleAdam4019Plus)Module).Cjc;
                    if ((cjc != null) && (cjc.ChannelValue != null) && (cjc.ChannelValue.Status == NewEnumSignalStatus.NoError) && (cjc.ChannelValue.Value != null))
                    {
                        val = MVtoTh(thType, value, (double)cjc.ChannelValue.Value, out stat);
                    }
                    else
                    {
                        val  = null;
                        stat = NewEnumSignalStatus.TransformCjcError;
                    }
                }
                break;

            //switch (InLevel)
            //{
            //    case "ТХК L":
            //        ClassAbstractAdamChannel cjc = Module.Cjc;
            //        if ((cjc != null) && (cjc.Status == EChannelStatus.NoError) && (cjc.Value != null))
            //            val = MVtoThL(value, (double)cjc.Value, out stat);
            //        else
            //        {
            //            val = null;
            //            stat = EChannelStatus.TransformCjcError;
            //        }
            //        break;

            //    case "ТХК K":
            //        //cjc = Module.Cjc();
            //        cjc = Module.Cjc;
            //        if ((cjc != null) && (cjc.Status == EChannelStatus.NoError) && (cjc.Value != null))
            //            val = MVtoThK(value, (double)cjc.Value, out stat);
            //        else
            //        {
            //            val = null;
            //            stat = EChannelStatus.TransformCjcError;
            //        }
            //        break;

            //    default:
            //        value = newValue;
            //        status = EChannelStatus.NoError;
            //        break;
            //}
            //break;

            case "05":
                switch (InLevel)
                {
                case "4-20 mA":
                    if ((Min != null) && (Max != null))
                    {
                        val = LinearTransform(value, 0.5, 2.5, (double)Min, (double)Max);
                    }
                    break;
                }
                break;

            case "07":
                switch (InLevel)
                {
                case "4-20 mA":
                    if ((Min != null) && (Max != null))
                    {
                        val = LinearTransform(value, 4, 20, (double)Min, (double)Max);
                    }
                    break;
                }
                break;
            }

            status = stat;
            return(val);
        }
Esempio n. 7
0
        public override void CalcVal(string signal, ref NewEnumSignalStatus status, out double?val)
        {
            val = null;

            if (status == NewEnumSignalStatus.NoError)
            {
                if (signal != null)
                {
                    switch (ChannelRange)
                    {
                    case "0E":     // Type J Thermocouple 0 ~ 760 C
                    case "0F":     // Type K Thermocouple 0 ~1370 C
                    case "10":     // Type T Thermocouple -100 ~ 400 C
                    case "11":     // Type E Thermocouple 0 ~ 1000 C
                    case "12":     // Type R Thermocouple 500 ~ 1750 C
                    case "13":     // Type S Thermocouple 500 ~ 1750 C
                    case "14":     // Type B Thermocouple 500 ~ 1800 C
                        if ((signal == "-0000") || (signal == "+9999"))
                        {
                            status = NewEnumSignalStatus.SignalOutOfRange;
                            return;
                        }
                        break;
                    }

                    if ((signal != "+888888") && (signal != "888888"))
                    {
                        double value;
                        if (double.TryParse(signal, NumberStyles.Number, CultureInfo.InvariantCulture.NumberFormat,
                                            out value))
                        {
                            val = SignalTransform(value, out status);

                            //if ((status == EChannelStatus.NoError)&&(val!=null))
                            //    val = SignalConversion((double)val, out status);
                        }
                        else
                        {
                            status = NewEnumSignalStatus.SignalValueError;
                        }
                    }
                    else
                    {
                        status = NewEnumSignalStatus.SignalValueError;
                    }
                }
                else
                {
                    status = NewEnumSignalStatus.ReadError;
                }
            }

            /*if (status != EChannelStatus.NoError)
             * {
             *  NewValue = null;
             *  ValueChanged = (Channel.Value != null);
             *  Val = null;
             *  Value = null;
             *  Status = status;
             * }*/
        }