コード例 #1
0
        //public virtual void ReadModuleNoRead(Queue<NewChannelValue> queue, DateTime time)
        //{
        //    if (Address != null)
        //    {
        //        foreach (NewChannelAbstract channel in Channels)
        //        {
        //            var signalValue = new NewChannelValue(channel, time, NewEnumSignalStatus.NoRead);
        //            lock (queue) { queue.Enqueue(signalValue); }
        //        }
        //    }
        //}

        public virtual void ReadModuleNoRead(Queue <NewChannelValue> queue, DateTime time)
        {
            if (Address != null)
            {
                foreach (NewChannelAbstract channel in Channels)
                {
                    var signalValue = new NewChannelValue(channel, time, NewEnumSignalStatus.NoRead);
                    lock (queue) { queue.Enqueue(signalValue); }
                }
            }
        }
コード例 #2
0
        //public /*override*/ void ReadModuleOld(bool readOnlySelected = true)
        //{
        //    if (Address != null)
        //    {
        //        string stOut;
        //        string stIn;
        //        NewChannelValue signalValue;

        //        Time = DateTime.Now;

        //        //CJC
        //        if (Cjc.Selected)
        //        {
        //            stOut = "$" + Address + "3";
        //            stIn = SendCommand(stOut);

        //            if ((stIn.Length == 8) && (stIn.StartsWith(">")))
        //                signalValue = new NewChannelValue(Cjc, (DateTime)Time, stIn.Substring(1));
        //            else
        //            {
        //                ClassLog.AddLog(ELogType.ErrorModuleRead, "NewModuleAdam4019Plus.ReadModule",
        //                                "Ошибка чтения ТХС модуля " + Address, (DateTime)Time);

        //                signalValue = new NewChannelValue(Cjc, (DateTime)Time, NewEnumSignalStatus.ReadError);
        //            }
        //        }
        //        else
        //            signalValue = new NewChannelValue(Cjc, (DateTime)Time, NewEnumSignalStatus.NoRead);

        //        signalValue.CalcValue();

        //        //Channels
        //        stOut = "#" + Address;
        //        stIn = SendCommand(stOut);

        //        if ((stIn.Length == 57) && (stIn.StartsWith(">")))
        //        {
        //            //for (byte channel = 0; channel < ChannelCount; channel++)
        //            //{
        //            //    if ((!readOnlySelected) || (Channels[channel].Selected))
        //            //    {
        //            //        string signal = stIn.Substring(1 + (channel) * 7, 7);
        //            //        signalValue = new NewChannelValue(Channels[channel], (DateTime)Time, signal);
        //            //    }
        //            //    else
        //            //        signalValue = new NewChannelValue(Channels[channel], (DateTime)Time, NewEnumSignalStatus.NoRead);

        //            //    signalValue.CalcValue();
        //            //}

        //            foreach (NewChannelAdamAbstract channel in Channels)
        //            {
        //                if (!channel.IsCjc)
        //                {
        //                    if ((!readOnlySelected) || (channel.Selected))
        //                    {
        //                        string signal = stIn.Substring(1 + channel.Channel*7, 7);
        //                        signalValue = new NewChannelValue(channel, (DateTime) Time, signal);
        //                    }
        //                    else
        //                        signalValue = new NewChannelValue(channel, (DateTime) Time, NewEnumSignalStatus.NoRead);

        //                    signalValue.CalcValue();
        //                }
        //            }
        //        }
        //        else
        //        {
        //            ClassLog.AddLog(ELogType.ErrorModuleRead, "NewModuleAdam4019Plus.ReadModule",
        //                            "Ошибка чтения сигналов модуля " + Address, (DateTime)Time);

        //            //for (byte channel = 0; channel < ChannelCount; channel++)
        //            //{
        //            //    if ((!readOnlySelected) || (Channels[channel].Selected))
        //            //        signalValue = new NewChannelValue(Channels[channel], (DateTime)Time, NewEnumSignalStatus.ReadError);
        //            //    else
        //            //        signalValue = new NewChannelValue(Channels[channel], (DateTime)Time, NewEnumSignalStatus.NoRead);

        //            //    signalValue.CalcValue();
        //            //}

        //            foreach (NewChannelAdamAbstract channel in Channels)
        //            {
        //                if (!channel.IsCjc)
        //                {
        //                    if ((!readOnlySelected) || (channel.Selected))
        //                        signalValue = new NewChannelValue(channel, (DateTime)Time, NewEnumSignalStatus.ReadError);
        //                    else
        //                        signalValue = new NewChannelValue(channel, (DateTime)Time, NewEnumSignalStatus.NoRead);

        //                    signalValue.CalcValue();
        //                }
        //            }
        //        }
        //    }
        //}

        public override void ReadModule(Queue <NewChannelValue> queue, bool readOnlySelected = true)
        {
            if (Address != null)
            {
                string          stOut;
                string          stIn;
                NewChannelValue signalValue;

                Time = DateTime.Now;

                //CJC
                if ((!readOnlySelected) || (Cjc.Selected))
                {
                    stOut = "$" + Address + "3";
                    stIn  = SendCommand(stOut);

                    if ((stIn.Length == 8) && (stIn.StartsWith(">")))
                    {
                        signalValue = new NewChannelValue(Cjc, (DateTime)Time, stIn.Substring(1));
                    }
                    else
                    {
                        ClassLog.AddLog(ELogType.ErrorModuleRead, "NewModuleAdam4019Plus.ReadModule",
                                        "Ошибка чтения ТХС модуля " + Address, (DateTime)Time);

                        signalValue = new NewChannelValue(Cjc, (DateTime)Time, NewEnumSignalStatus.ReadError);
                    }
                }
                else
                {
                    signalValue = new NewChannelValue(Cjc, (DateTime)Time, NewEnumSignalStatus.NoRead);
                }

                //signalValue.CalcValue();
                lock (queue) { queue.Enqueue(signalValue); }

                //Channels
                stOut = "#" + Address;
                stIn  = SendCommand(stOut);

                if ((stIn.Length == 57) && (stIn.StartsWith(">")))
                {
                    //for (byte channel = 0; channel < ChannelCount; channel++)
                    //{
                    //    if ((!readOnlySelected) || (Channels[channel].Selected))
                    //    {
                    //        string signal = stIn.Substring(1 + (channel) * 7, 7);
                    //        signalValue = new NewChannelValue(Channels[channel], (DateTime)Time, signal);
                    //    }
                    //    else
                    //        signalValue = new NewChannelValue(Channels[channel], (DateTime)Time, NewEnumSignalStatus.NoRead);

                    //    //signalValue.CalcValue();
                    //    lock (queue) { Program.Net.QueueChannelValues.Enqueue(signalValue); }
                    //}

                    foreach (NewChannelAdamAbstract channel in Channels)
                    {
                        if (!channel.IsCjc)
                        {
                            if ((!readOnlySelected) || (channel.Selected))
                            {
                                string signal = stIn.Substring(1 + channel.Channel * 7, 7);
                                signalValue = new NewChannelValue(channel, (DateTime)Time, signal);
                            }
                            else
                            {
                                signalValue = new NewChannelValue(channel, (DateTime)Time, NewEnumSignalStatus.NoRead);
                            }

                            //signalValue.CalcValue();
                            lock (queue) { queue.Enqueue(signalValue); }
                        }
                    }
                }
                else
                {
                    ClassLog.AddLog(ELogType.ErrorModuleRead, "NewModuleAdam4019Plus.ReadModule",
                                    "Ошибка чтения сигналов модуля " + Address, (DateTime)Time);

                    //for (byte channel = 0; channel < ChannelCount; channel++)
                    //{
                    //    if ((!readOnlySelected) || (Channels[channel].Selected))
                    //        signalValue = new NewChannelValue(Channels[channel], (DateTime)Time, NewEnumSignalStatus.ReadError);
                    //    else
                    //        signalValue = new NewChannelValue(Channels[channel], (DateTime)Time, NewEnumSignalStatus.NoRead);

                    //    //signalValue.CalcValue();
                    //    lock (queue) { Program.Net.QueueChannelValues.Enqueue(signalValue); }
                    //}

                    foreach (NewChannelAdamAbstract channel in Channels)
                    {
                        if (!channel.IsCjc)
                        {
                            if ((!readOnlySelected) || (channel.Selected))
                            {
                                signalValue = new NewChannelValue(channel, (DateTime)Time, NewEnumSignalStatus.ReadError);
                            }
                            else
                            {
                                signalValue = new NewChannelValue(channel, (DateTime)Time, NewEnumSignalStatus.NoRead);
                            }

                            //signalValue.CalcValue();
                            lock (queue) { queue.Enqueue(signalValue); }
                        }
                    }
                }
            }
        }