Ejemplo n.º 1
0
 /// <summary>
 /// Конструктор класс GET для RS-го битового сигнала
 /// </summary>
 /// <param name="_source">Указываемый дефайн RS. Описан в XML платы.</param>
 /// <param name="_ValueOn">Значение битового сигнала для его проверки. TRUE/FALSE</param>
 /// <param name="_IndexByte">Индекс байта, с которого начинают лежать данные.</param>
 /// <param name="_IndexBit">Индекс бита в нужном байте, с которого лежат данные.</param>
 public Get_RS_BIT(BaseRS _source, BoardRS _boardRs, bool _valueon, byte _indexbyte, byte _indexbit)
 {
     source    = _source;
     boardRs   = _boardRs;
     valueon   = _valueon;
     indexbyte = _indexbyte;
     indexbit  = _indexbit;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Конструктор класс GET для RS-го аналогового сигнала
 /// </summary>
 /// <param name="_source">Указываемый дефайн RS. Описан в XML платы.</param>
 /// <param name="_min">Нижняя граница проверяемого диапазона.</param>
 /// <param name="_max">Верхняя граница проверяемого диапазона.</param>
 /// <param name="_sizebyte">Размер сигнала в байтах.</param>
 /// <param name="_indexbyte">Индекс байта с которого начинают лежать данные.</param>
 public Get_RS_ANALOG(BaseRS _source, uint _min, uint _max, ushort _sizebyte, ushort _indexbyte)
 {
     source    = _source;
     min       = _min;
     max       = _max;
     sizebyte  = _sizebyte;
     indexbyte = _indexbyte;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Конструктор класса SET для RS-го битового сигнала
 /// </summary>
 /// <param name="_source">Указываемый дефайн RS. Описан в XML платы.</param>
 /// <param name="_boardRs"></param>
 /// <param name="_valueon">Значение битового сигнала для его проверки. TRUE/FALSE</param>
 /// <param name="_indexbyte">Индекс байта, с которого начинают лежать данные.</param>
 /// <param name="_indexbit">Индекс бита в нужном байте, с которого лежат данные.</param>
 /// <param name="_comment">Комментарий относительно установки данного сигнала.</param>
 /// <param name="_imagelink">Ссылка на картинку, описывающая сигнал.</param>
 public Set_RS_BIT(BaseRS _source, BoardRS _boardRs, bool _valueon, byte _indexbyte, byte _indexbit, string _comment, string _imagelink)
 {
     source    = _source;
     boardRs   = _boardRs;
     valueon   = _valueon;
     indexbyte = _indexbyte;
     indexbit  = _indexbit;
     comment   = _comment;
     imagelink = _imagelink;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Конструктор класса SET для RS-го аналогового сигнала
 /// </summary>
 /// <param name="_source">Указываемый дефайн RS. Описан в XML платы.</param>
 /// <param name="_valueon">Числовое значение аналогового сигнала для его включения.</param>
 /// <param name="_sizebyte">Размер сигнала в байтах.</param>
 /// <param name="_indexbyte">Индекс байта с которого начинают лежать данные.</param>
 /// <param name="_comment">Комментарий относительно установки данного сигнала.</param>
 /// <param name="_imagelink">Ссылка на картинку, описывающая сигнал.</param>
 /// <param name="_valueoff">Числовое значение аналогового сигнала для его выключения.</param>
 public Set_RS_ANALOG(BaseRS _source, BoardRS _boardRs, uint _valueon, ushort _sizebyte, ushort _indexbyte, string _comment, string _imagelink, uint _valueoff)
 {
     source    = _source;
     boardRs   = _boardRs;
     valueon   = _valueon;
     sizebyte  = _sizebyte;
     indexbyte = _indexbyte;
     comment   = _comment;
     imagelink = _imagelink;
     valueoff  = _valueoff;
 }
Ejemplo n.º 5
0
        public StandSignals openStandXML(string XMLname)
        {
            BaseSignal   baseSignal   = null;
            GroupSignals groupSignal  = null;
            StandSignals standSignals = new StandSignals();
            string       str;
            string       paramName = "";

            standSignals.listSignals.Clear();
            //lstBxXML.Items.Clear();
            int    errors          = 0;
            BaseRS baseRS          = null;
            string baseRSname      = null;
            uint   rsPort          = 0;
            ushort setRSaddress    = 0;
            ushort bufRSaddress    = 0;
            string baseSigValueStr = null;
            bool   bRS             = false;
            //XmlTextReader reader = new XmlTextReader("StandSignals.xml");
            XmlTextReader reader = new XmlTextReader(XMLname);

            //           XmlTextReader reader = new XmlTextReader("Books.xml");
            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:     // Узел является элементом.
                    paramName = reader.Name;

                    if (reader.Name == "SIGNAL")
                    {
                        reader.MoveToNextAttribute();
                        if (reader.Name == "NAME")
                        {
                            baseSignal      = new BaseSignal(reader.Value);
                            baseSigValueStr = null;
                        }
                    }

                    if (reader.Name == "RS")
                    {
                        bRS = true;
                        reader.MoveToNextAttribute();
                        if (reader.Name == "NAME")
                        {
                            baseRSname = reader.Value;
                        }
                    }

                    break;

                case XmlNodeType.Text:     // Вывести текст в каждом элементе.
                    str = reader.Value;
                    //lstBxXML.Items.Add(str);
                    //Console.WriteLine(reader.Value);

                    if (paramName == "PORT")
                    {
                        UInt32 port;
                        if (UInt32.TryParse(reader.Value, out port))
                        {
                            if (!bRS)
                            {
                                if (baseSignal != null)
                                {
                                    baseSignal.port = port;
                                }
                            }
                            else
                            {
                                rsPort = port;
                            }
                        }
                    }

                    if (paramName == "ADDRESS")
                    {
                        UInt32 addr;
                        if (UInt32.TryParse(reader.Value, out addr))
                        {
                            if (baseSignal != null)
                            {
                                baseSignal.address = addr;
                            }
                        }
                    }


                    if (paramName == "TYPE")
                    {
                        switch (reader.Value)
                        {
                        case "LOGIC":
                            signalType = SIGNALTYPE.LOGIC;
                            break;

                        case "ANALOG":
                            signalType = SIGNALTYPE.ANALOG;
                            break;

                        case "ARRAY":
                            signalType = SIGNALTYPE.ARRAY;
                            break;

                        case "COMPOUND":
                            signalType = SIGNALTYPE.COMPOUND;
                            break;

                        default:
                            signalType = SIGNALTYPE.UNDEFINED;
                            break;
                        }
                        if (baseSignal != null)
                        {
                            baseSignal.type = signalType;
                        }
                    }


                    if (paramName == "SETADDRESS")
                    {
                        UInt16 addr;
                        if (UInt16.TryParse(reader.Value, out addr))
                        {
                            if (bRS)
                            {
                                setRSaddress = addr;
                            }
                        }
                    }

                    if (paramName == "BUFADDRESS")
                    {
                        UInt16 addr;
                        if (UInt16.TryParse(reader.Value, out addr))
                        {
                            if (bRS)
                            {
                                bufRSaddress = addr;
                            }
                        }
                    }

                    if (paramName == "SIZEINBITS")
                    {
                        UInt16 sizebits;
                        if (UInt16.TryParse(reader.Value, out sizebits))
                        {
                            if (baseSignal != null)
                            {
                                baseSignal.sizeInBits = sizebits;
                            }
                        }
                    }

                    if (paramName == "INDEXBIT")
                    {
                        UInt16 indexbit;
                        if (UInt16.TryParse(reader.Value, out indexbit))
                        {
                            if (baseSignal != null)
                            {
                                baseSignal.indexBit = indexbit;
                            }
                        }
                    }

                    if (paramName == "GROUP")
                    {
                        //                            if (UInt16.TryParse(reader.Value, out indexbit))
                        {
                            if (baseSignal != null)
                            {
                                baseSignal.groupName = reader.Value;
                            }
                        }
                    }


                    if (paramName == "VALUE")
                    {
                        UInt32 value;
                        if (baseSignal != null)
                        {
                            baseSignal.iValue = 0;
                            switch (baseSignal.type)
                            {
                            case SIGNALTYPE.LOGIC:
                                baseSignal.bValue = false;
                                if (reader.Value == "TRUE")
                                {
                                    baseSignal.bValue = true;
                                    baseSignal.iValue = (uint)(1 << baseSignal.indexBit);
                                }
                                else
                                {
                                    if (reader.Value != "FALSE")
                                    {
                                        errors++;
                                    }
                                    else
                                    {
                                        baseSignal.iValue = (uint)(~(1 << baseSignal.indexBit));
                                    }
                                }
                                break;

                            case SIGNALTYPE.ANALOG:
                                if (UInt32.TryParse(reader.Value, out value))
                                {
                                    if (baseSignal != null)
                                    {
                                        baseSignal.iValue = value;
                                    }
                                }
                                break;

                            case SIGNALTYPE.ARRAY:
                                // baseSignal.bValue = true;
                                baseSigValueStr = reader.Value;
                                break;
                            }
                        }
                    }


                    paramName = "";
                    break;

                case XmlNodeType.EndElement:     // Вывести конец элемента.
                    //Console.Write("</" + reader.Name);
                    if (reader.Name == "RS")
                    {
                        bRS = false;
                        //GroupSignals groupSignals=new GroupSignals
                        baseRS = new BaseRS(baseRSname, rsPort, setRSaddress, bufRSaddress, baseRSname);
                        standSignals.listRS.Add(baseRS);
                    }
                    if (reader.Name == "SIGNAL")
                    {
                        if (baseSignal.groupName == null)
                        {
                            baseSignal.groupName = "NONE";
                        }

                        bool groupExist = false;
                        if (standSignals.listSignals.Count != 0)
                        {
                            foreach (GroupSignals grSignals in standSignals.listSignals)
                            {
                                if (grSignals.name == baseSignal.groupName)
                                {
                                    grSignals.baseSignals.Add(baseSignal);
                                    if (!baseSignal.bValue)
                                    {
                                        uint groupVal = 0;
                                        for (int i = 0; i < grSignals.valueTX.Length; i++)
                                        {
                                            groupVal += (uint)(grSignals.valueTX[i] << (8 * i));
                                        }

                                        groupVal |= ~baseSignal.iValue;

                                        for (int i = 0; i < grSignals.valueTX.Length; i++)
                                        {
                                            grSignals.valueTX[i] = (byte)((groupVal >> (8 * i)) & 0xFF);
                                        }
                                    }
                                    baseSignal.group = grSignals;
                                    groupExist       = true;
                                    break;
                                }
                            }
                        }
                        if (!groupExist)
                        {
                            groupSignal = new GroupSignals(baseSignal.groupName, (ushort)(baseSignal.sizeInBits / 8));
                            if (signalType == SIGNALTYPE.ARRAY)
                            {
                                if (baseSigValueStr != null)
                                {
                                    byte[] buf = baseSigValueStr.Split('-').Select(n => Convert.ToByte(n, 16)).ToArray();
                                    groupSignal.valueTX = buf;
                                }
                            }
                            groupSignal.baseSignals.Add(baseSignal);
                            if (!baseSignal.bValue)
                            {
                                uint groupVal = 0;
                                for (int i = 0; i < groupSignal.valueTX.Length; i++)
                                {
                                    groupVal += (uint)(groupSignal.valueTX[i] << (8 * i));
                                }

                                groupVal |= ~baseSignal.iValue;

                                for (int i = 0; i < groupSignal.valueTX.Length; i++)
                                {
                                    groupSignal.valueTX[i] = (byte)((groupVal >> (8 * i)) & 0xFF);
                                }
                            }
                            baseSignal.group = groupSignal;
                            standSignals.listSignals.Add(groupSignal);
                        }
                    }
                    str = "</" + reader.Name + ">";
                    //lstBxXML.Items.Add(str);

                    //Console.WriteLine(">");
                    //lstBxXML.Items.Add(">");
                    break;
                }
            }
            return(standSignals);
        }
Ejemplo n.º 6
0
        public TestBoard openBoardXML(StandSignals standSignals, string XMLname)
        {
            BoardSignal  boardSignal  = null;
            BoardSignals boardSignals = new BoardSignals();
            //BoardConfig boardConfig = null;
            BoardConfig   boardConfig = new BoardConfig();
            BoardScenario scenario    = null;
            Periodic      periodic    = new Periodic();
            Manual        manual      = new Manual();
            Test          runTest     = new Test();
            //GroupSignals groupSignal = null;

            string commentString   = null;
            string imageLinkString = null;
            string str;

            bool bSectionSet    = false;
            bool bSectionGet    = false;
            bool bSectionConfig = false;

            //string name;
            string paramName     = "";
            string setSourceName = "";
            string getSourceName = "";



            string boardSignalName = null;
            string boardRSName     = null;

            UInt16 delay        = 1000;
            ushort numBytes     = 0;
            byte   marker       = 0x0;
            byte   setIndexByte = 0;
            byte   setIndexBit  = 0;
            byte   getIndexByte = 0;
            byte   getIndexBit  = 0;

            bool   bSetValueON  = true;
            bool   bGetValueON  = true;
            UInt32 uiSetValueON = 0xffffffff;
            UInt32 uiGetValueON = 0xffffffff;
            UInt32 uiGetMAX     = 0x0;
            UInt32 uiGetMIN     = 0xffffffff;

            ushort       setSizeByte    = 0;
            ushort       getSizeByte    = 0;
            UInt32       uiSetValueOFF  = 0xffffffff;
            TYPERSSIGNAL setRSignalType = TYPERSSIGNAL.NULL;
            TYPERSSIGNAL getRSignalType = TYPERSSIGNAL.NULL;
            //TYPERSSIGNAL rsSignalType = TYPERSSIGNAL.NULL;

            XmlTextReader reader        = new XmlTextReader(XMLname);
            Buttons       buttonsObj    = new Buttons();
            SysButton     sysButton     = null;
            double        dI27MAX       = 999;
            double        dI15MAX       = 999;
            double        dI12MAX       = 999;
            double        dI05MAX       = 999;
            double        dI03MAX       = 999;
            string        sysButtonName = string.Empty;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:     // Узел является элементом.

                    if (reader.Name == "RS")
                    {
                        reader.MoveToNextAttribute();
                        if (reader.Name == "NAME")
                        {
                            if (bSectionConfig)
                            {
                                boardRSName = reader.Value;
                            }
                        }
                        setRSignalType = TYPERSSIGNAL.NULL;
                        getRSignalType = TYPERSSIGNAL.NULL;
                    }


                    paramName = reader.Name;
                    str       = "<" + reader.Name + ">";
                    if (reader.Name == "SIGNAL")
                    {
                        getSourceName = null;
                        setSourceName = null;

                        commentString   = string.Empty;
                        imageLinkString = string.Empty;

                        dI27MAX = 999;
                        dI15MAX = 999;
                        dI12MAX = 999;
                        dI05MAX = 999;
                        dI03MAX = 999;
                        reader.MoveToNextAttribute();
                        str += " " + reader.Name + "='" + reader.Value + "'" + ">";
                        if (reader.Name == "NAME")
                        {
                            //baseSignal = new BaseSignal(reader.Value);
                            boardSignalName = reader.Value;
                        }
                    }

                    //Console.Write("<" + reader.Name);
                    else
                    {
                        // while (reader.MoveToNextAttribute()) // Чтение атрибутов.
                        //     str += " " + reader.Name + "='" + reader.Value + "'" + ">";
                    }


                    if (reader.Name == "BUTTON")
                    {
                        reader.MoveToNextAttribute();
                        if (reader.Name == "NAME")
                        {
                            //baseSignal = new BaseSignal(reader.Value);
                            sysButtonName = reader.Value;
                            sysButton     = new SysButton(sysButtonName);
                            useSignalType = TYPESIGUSING.BUTTON;
                        }
                    }

                    if (reader.Name == "SET")
                    {
                        bSectionSet = true;
                    }
                    if (reader.Name == "GET")
                    {
                        bSectionGet   = true;
                        getSourceName = "";
                    }

                    if (reader.Name == "CONFIG")
                    {
                        bSectionConfig = true;
                    }

                    if (reader.Name == "PERIODIC")
                    {
                        useSignalType = TYPESIGUSING.PERIODIC;
                    }

                    if (reader.Name == "TEST")
                    {
                        useSignalType = TYPESIGUSING.TEST;
                    }

                    if (reader.Name == "MANUAL")
                    {
                        useSignalType = TYPESIGUSING.MANUAL;
                    }

                    str += ">";
                    //lstBxXML.Items.Add(str);
                    break;

                case XmlNodeType.Text:     // Вывести текст в каждом элементе.
                    str = reader.Value;

                    //lstBxXML.Items.Add(str);
                    //Console.WriteLine(reader.Value);

                    if (paramName == "SOURCE")
                    {
                        if (bSectionSet)
                        {
                            setSourceName = reader.Value;
                        }
                        if (bSectionGet)
                        {
                            getSourceName = reader.Value;
                        }
                    }


                    if (paramName == "VALUEOFF")
                    {
                        uint uValue = 0xffffffff;
                        if (str2uint(reader.Value, out uValue))
                        {
                            if (bSectionSet)
                            {
                                uiSetValueOFF = uValue;
                            }
                        }
                    }

                    if (paramName == "MIN")
                    {
                        uint uValue = 0;
                        if (str2uint(reader.Value, out uValue))
                        {
                            if (bSectionGet)
                            {
                                getRSignalType = TYPERSSIGNAL.ANALOG;
                                uiGetMIN       = uValue;
                            }
                        }
                    }

                    if (paramName == "MAX")
                    {
                        uint uValue = 0;
                        if (str2uint(reader.Value, out uValue))
                        {
                            if (bSectionGet)
                            {
                                getRSignalType = TYPERSSIGNAL.ANALOG;
                                uiGetMAX       = uValue;
                            }
                        }
                    }



                    if (paramName == "VALUEON")
                    {
                        bool bValue;
                        if (bool.TryParse(reader.Value, out bValue))
                        {
                            if (bSectionSet)
                            {
                                setRSignalType = TYPERSSIGNAL.BIT;
                                bSetValueON    = bValue;
                            }
                            if (bSectionGet)
                            {
                                getRSignalType = TYPERSSIGNAL.BIT;
                                bGetValueON    = bValue;
                            }
                        }
                        else
                        {
                            uint uValue = 0;
                            if (str2uint(reader.Value, out uValue))
                            {
                                if (bSectionSet)
                                {
                                    setRSignalType = TYPERSSIGNAL.ANALOG;
                                    uiSetValueON   = uValue;
                                }
                                if (bSectionGet)
                                {
                                    uiGetValueON = uValue;
                                }
                            }
                        }
                    }

                    if (paramName == "SIZEBYTE")
                    {
                        ushort val;
                        if (ushort.TryParse(reader.Value, out val))
                        {
                            if (bSectionSet)
                            {
                                setSizeByte = val;
                            }
                            if (bSectionGet)
                            {
                                getSizeByte = val;
                            }
                        }
                    }

                    if (paramName == "INDEXBYTE")
                    {
                        byte index;
                        if (byte.TryParse(reader.Value, out index))
                        {
                            if (bSectionSet)
                            {
                                setIndexByte = index;
                            }
                            if (bSectionGet)
                            {
                                getIndexByte = index;
                            }
                        }
                    }


                    if (paramName == "INDEXBIT")
                    {
                        byte index;
                        if (byte.TryParse(reader.Value, out index))
                        {
                            if (bSectionSet)
                            {
                                setIndexBit = index;
                            }
                            if (bSectionGet)
                            {
                                getIndexBit = index;
                            }
                        }
                    }


                    if (paramName == "COMMENT")
                    {
                        commentString = reader.Value;
                    }

                    if (paramName == "IMAGELINK")
                    {
                        imageLinkString = reader.Value;
                    }

                    if (paramName == "DELAY")
                    {
                        UInt16 _delay;
                        if (UInt16.TryParse(reader.Value, out _delay))
                        {
                            delay = _delay;
                        }
                    }


                    if (paramName == "RUN")
                    {
                        //runTestName = reader.Value;
                        //BoardSignal _boardSignal = getBoardSignal(runTestName, boardSignals);
                        BoardSignal _boardSignal = getBoardSignal(reader.Value, boardSignals);
                        if (_boardSignal != null)
                        {
                            switch (useSignalType)
                            {
                            case TYPESIGUSING.PERIODIC:
                                periodic.listRun.Add(_boardSignal);
                                break;

                            case TYPESIGUSING.TEST:
                                runTest.listRun.Add(_boardSignal);
                                break;

                            case TYPESIGUSING.MANUAL:
                                manual.listRun.Add(_boardSignal);
                                break;

                            case TYPESIGUSING.BUTTON:
                                sysButton.listRun.Add(_boardSignal);
                                break;
                            }
                        }
                    }

                    if (paramName == "D27MAX")
                    {
                        double dValue = 0;
                        if (str2double(reader.Value, out dValue))
                        {
                            dI27MAX = dValue;
                        }
                    }

                    if (paramName == "D15MAX")
                    {
                        double dValue = 0;
                        if (str2double(reader.Value, out dValue))
                        {
                            dI15MAX = dValue;
                        }
                    }

                    if (paramName == "D12MAX")
                    {
                        double dValue = 0;
                        if (str2double(reader.Value, out dValue))
                        {
                            dI12MAX = dValue;
                        }
                    }

                    if (paramName == "D5MAX")
                    {
                        double dValue = 0;
                        if (str2double(reader.Value, out dValue))
                        {
                            dI05MAX = dValue;
                        }
                    }

                    if (paramName == "D3MAX")
                    {
                        double dValue = 0;
                        if (str2double(reader.Value, out dValue))
                        {
                            dI03MAX = dValue;
                        }
                    }



                    /*
                     * if (paramName == "VALUE")
                     * {
                     *
                     * }
                     *
                     *
                     * paramName = "";
                     */
                    if (paramName == "NUMBYTES")
                    {
                        ushort _numBytes;
                        if (ushort.TryParse(reader.Value, out _numBytes))
                        {
                            if (bSectionConfig)
                            {
                                numBytes = _numBytes;
                            }
                        }
                    }

                    if (paramName == "MARKER")
                    {
                        byte _marker;
                        if (byte.TryParse(reader.Value.Substring(2), System.Globalization.NumberStyles.HexNumber, null, out _marker))
                        {
                            if (bSectionConfig)
                            {
                                marker = _marker;
                            }
                        }
                    }

                    break;

                case XmlNodeType.EndElement:     // Вывести конец элемента.
                    //Console.Write("</" + reader.Name);
                    if (reader.Name == "CONFIG")
                    {
                        bSectionConfig = false;
                    }

                    if (reader.Name == "RS")
                    {
                        if (bSectionConfig)
                        {
                            BaseRS baseRS;
                            if ((baseRS = getBaseRS(standSignals, boardRSName)) != null)
                            {
                                GroupSignals groupRS = new GroupSignals(baseRS.Name, numBytes);
                                if (groupRS.valueTX.Length > 0)
                                {
                                    if (marker != 0xff)
                                    {
                                        groupRS.valueTX[0] = marker;
                                    }
                                }
                                groupRS.valueRX = new byte[64];
                                baseRS.Group    = groupRS;
                                BoardRS boardRS = new BoardRS(boardRSName, numBytes, marker);
                                boardConfig.listBoardRS.Add(boardRS);
                            }
                        }
                    }


                    if (reader.Name == "SIGNAL")
                    {
                        bool err = false;
                        iSet set = null;
                        iGet get = null;
                        if (setSourceName != null)
                        {
                            if (setSourceName.Substring(0, 2) != "RS")
                            {
                                BaseSignal baseSignal = getBaseSignal(standSignals, setSourceName);
                                if (baseSignal != null)
                                {
                                    switch (baseSignal.type)
                                    {
                                    case SIGNALTYPE.LOGIC:
                                        set = new Set_STAND_BIT(baseSignal, commentString, imageLinkString);
                                        break;

                                    case SIGNALTYPE.ARRAY:
                                        set = new Set_ARRAY(baseSignal, commentString, imageLinkString);
                                        break;

                                    case SIGNALTYPE.ANALOG:
                                        set = new Set_STAND_ANALOG(baseSignal, uiSetValueON, commentString, imageLinkString, uiSetValueOFF);
                                        break;
                                    }
                                }
                                else
                                {
                                    err = true;
                                }
                            }
                            else
                            {
                                //BaseRS baseRS=getBaseRS
                                BaseRS  baseRS  = getBaseRS(standSignals, setSourceName);
                                BoardRS boardRS = getBoardRS(boardConfig, setSourceName);
                                if (setRSignalType == TYPERSSIGNAL.BIT)
                                {
                                    set = new Set_RS_BIT(baseRS, boardRS, bSetValueON, setIndexByte, setIndexBit, commentString, imageLinkString);
                                }
                                else
                                {
                                    if (setRSignalType == TYPERSSIGNAL.ANALOG)
                                    {
                                        set = new Set_RS_ANALOG(baseRS, boardRS, uiSetValueON, setSizeByte, setIndexByte, commentString, imageLinkString, uiSetValueOFF);
                                    }
                                    //baseRS, boardRS, bSetValueON, setIndexByte, setIndexBit, commentString, imageLinkString);
                                }
                            }
                        }
                        if (getSourceName != null)
                        {
                            if (getSourceName.Length >= 2)
                            {
                                if (getSourceName.Substring(0, 2) != "RS")
                                {
                                    BaseSignal baseSignal = getBaseSignal(standSignals, getSourceName);
                                    if (baseSignal != null)
                                    {
                                        switch (baseSignal.type)
                                        {
                                        case SIGNALTYPE.LOGIC:
                                            get = new Get_STAND_BIT(baseSignal);
                                            break;

                                        case SIGNALTYPE.ARRAY:
                                            get = new Get_ARRAY(baseSignal);
                                            break;

                                        case SIGNALTYPE.ANALOG:
                                            get = new Get_STAND_ANALOG(baseSignal, uiGetMIN, uiGetMAX);
                                            break;

                                        default:
                                            get = new Get_ARRAY(null);
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    BaseRS  baseRS  = getBaseRS(standSignals, getSourceName);
                                    BoardRS boardRS = getBoardRS(boardConfig, getSourceName);
                                    if (getRSignalType == TYPERSSIGNAL.BIT)
                                    {
                                        get = new Get_RS_BIT(baseRS, boardRS, bGetValueON, getIndexByte, getIndexBit);
                                    }
                                    else
                                    {
                                        if (getRSignalType == TYPERSSIGNAL.ANALOG)
                                        {
                                            get = new Get_RS_ANALOG(baseRS, uiGetMIN, uiGetMAX, getSizeByte, getIndexByte);
                                        }
                                    }
                                }
                            }
                            if (get == null)
                            {
                                get = new Get_ARRAY(null);
                            }
                        }
                        if (!err)
                        {
                            boardSignal = new BoardSignal(boardSignalName, set, get, delay, dI27MAX, dI15MAX, dI12MAX, dI05MAX, dI03MAX);
                        }
                        else
                        {
                            boardSignal = null;
                        }
                        boardSignals.listBoardSignals.Add(boardSignal);


                        //boardSignals = new BoardSignals();
                    }

                    if (reader.Name == "BUTTON")
                    {
                        if (sysButton != null)
                        {
                            buttonsObj.listButtons.Add(sysButton);
                            useSignalType = TYPESIGUSING.NULL;
                            sysButton     = null;
                        }
                    }

                    if (reader.Name == "SET")
                    {
                        bSectionSet = false;
                    }
                    if (reader.Name == "GET")
                    {
                        bSectionGet = false;
                    }

                    str = "</" + reader.Name + ">";
                    //lstBxXML.Items.Add(str);

                    //Console.WriteLine(">");
                    //lstBxXML.Items.Add(">");
                    break;
                }
            }


            scenario = new BoardScenario(periodic, runTest, manual, buttonsObj);

            testBoard = new TestBoard(boardConfig, boardSignals, scenario);

            return(testBoard);
        }
Ejemplo n.º 7
0
        public BoardSignal(string _name, iSet _set, iGet _get, ushort _delay, double _d27Max, double _d15Max, double _d12Max, double _d5max, double _d3Max)
        {
            name   = _name;
            delay  = _delay;
            d27Max = _d27Max;
            d15Max = _d15Max;
            d12Max = _d12Max;
            d5Max  = _d5max;
            d3Max  = _d3Max;

            if (_set != null)
            {
                switch (_set.ReturnTypeSet())
                {
                case typeGetSet.RS_ANALOG:
                {
                    BaseRS tmp = ((Set_RS_ANALOG)_set).Source;
                    set.source            = new Source();
                    set.source.name       = tmp.Name;
                    set.source.groupName  = tmp.GroupName;
                    set.source.group      = tmp.Group;
                    set.source.port       = tmp.Port;
                    set.source.address    = 0;
                    set.source.type       = SIGNALTYPE.ANALOG;
                    set.source.sizeInBits = (ushort)(((Set_RS_ANALOG)_set).SizeByte * 8);
                    set.source.indexBit   = 0;
                    set.source.mode       = MODETYPE.UNDEFINED;
                    set.source.bValue     = false;
                    set.source.iValue     = ((Set_RS_ANALOG)_set).ValueOn;

                    set.source.setAddr = tmp.SetAddress;
                    set.source.bufAddr = tmp.BufAddress;

                    set.valueon   = ((Set_RS_ANALOG)_set).ValueOn;
                    set.indexbyte = ((Set_RS_ANALOG)_set).IndexByte;
                    set.indexbit  = 0;
                    set.valueoff  = ((Set_RS_ANALOG)_set).ValueOff;
                    set.sizebyte  = ((Set_RS_ANALOG)_set).SizeByte;
                    set.comment   = ((Set_RS_ANALOG)_set).Comment;
                    set.imagelink = ((Set_RS_ANALOG)_set).ImageLink;

                    //set.signalType = typeGetSet.RS_ANALOG;
                    set.signalType  = set.source.type;
                    set.source.isRS = tmp.isRS();
                }
                break;

                case typeGetSet.RS_BIT:
                {
                    //BaseRS tmp = ((BaseRS)((Set_RS_BIT)_set).Source);
                    BaseRS tmp = ((Set_RS_BIT)_set).Source;
                    set.source            = new Source();
                    set.source.name       = tmp.Name;
                    set.source.groupName  = tmp.GroupName;
                    set.source.group      = tmp.Group;
                    set.source.port       = tmp.Port;
                    set.source.address    = 0;
                    set.source.type       = SIGNALTYPE.LOGIC;
                    set.source.sizeInBits = (ushort)(8 * ((Set_RS_BIT)_set).BoardRs.NumBytes);
                    set.source.indexBit   = ((Set_RS_BIT)_set).IndexBit;
                    set.source.mode       = MODETYPE.WRITE;
                    set.source.bValue     = ((Set_RS_BIT)_set).ValueOn;

                    if (set.source.bValue)
                    {
                        set.source.iValue = (uint)(1 << ((Set_RS_BIT)_set).IndexBit);
                    }
                    else
                    {
                        set.source.iValue = (uint)(~(1 << ((Set_RS_BIT)_set).IndexBit));
                    }

                    set.source.setAddr = tmp.SetAddress;
                    set.source.bufAddr = tmp.BufAddress;
                    set.source.isRS    = tmp.isRS();


                    set.valueon   = set.source.iValue;
                    set.indexbyte = ((Set_RS_BIT)_set).IndexByte;
                    set.indexbit  = set.source.indexBit;
                    set.valueoff  = ~set.valueon;

                    set.sizebyte  = (ushort)(set.source.sizeInBits / 8);
                    set.comment   = ((Set_RS_BIT)_set).Comment;
                    set.imagelink = ((Set_RS_BIT)_set).ImageLink;

                    set.signalType = set.source.type;
                }
                break;

                case typeGetSet.STAND_ANALOG:
                {
                    BaseSignal tmp = ((Set_STAND_ANALOG)_set).Source;
                    set.source = new Source();

                    set.source.name       = tmp.name;
                    set.source.group      = tmp.group;
                    set.source.groupName  = tmp.groupName;
                    set.source.port       = tmp.port;
                    set.source.address    = tmp.address;
                    set.source.type       = tmp.type;
                    set.source.sizeInBits = tmp.sizeInBits;
                    set.source.indexBit   = tmp.indexBit;
                    set.source.mode       = tmp.mode;
                    set.source.bValue     = tmp.bValue;
                    set.source.iValue     = tmp.iValue;
                    set.source.setAddr    = 0;
                    set.source.bufAddr    = 0;
                    set.source.isRS       = tmp.isRS();

                    set.valueon    = ((Set_STAND_ANALOG)_set).ValueOn;
                    set.indexbyte  = 0;
                    set.indexbit   = set.source.indexBit;
                    set.valueoff   = ((Set_STAND_ANALOG)_set).ValueOff;
                    set.sizebyte   = (ushort)(set.source.sizeInBits / 8);
                    set.comment    = ((Set_STAND_ANALOG)_set).Comment;
                    set.imagelink  = ((Set_STAND_ANALOG)_set).ImageLink;
                    set.signalType = set.source.type;

                    for (int i = 0; i < set.sizebyte; i++)
                    {
                        set.source.group.valueTX[i] = (byte)((set.valueon >> (8 * i)) & 0xFF);
                    }
                }
                break;

                case typeGetSet.STAND_BIT:
                {
                    BaseSignal tmp = ((Set_STAND_BIT)_set).Source;
                    set.source            = new Source();
                    set.source.name       = tmp.name;
                    set.source.groupName  = tmp.groupName;
                    set.source.group      = tmp.group;
                    set.source.port       = tmp.port;
                    set.source.address    = tmp.address;
                    set.source.type       = tmp.type;
                    set.source.sizeInBits = tmp.sizeInBits;
                    set.source.indexBit   = tmp.indexBit;
                    set.source.mode       = tmp.mode;
                    set.source.bValue     = tmp.bValue;
                    set.source.iValue     = tmp.iValue;
                    set.source.isRS       = tmp.isRS();
                    set.source.setAddr    = 0;
                    set.source.bufAddr    = 0;

                    set.valueon   = set.source.iValue;
                    set.indexbyte = 0;
                    set.indexbit  = set.source.indexBit;
                    set.valueoff  = ~set.valueon;
                    set.sizebyte  = (ushort)(set.source.sizeInBits / 8);

                    set.comment   = ((Set_STAND_BIT)_set).Comment;
                    set.imagelink = ((Set_STAND_BIT)_set).ImageLink;

                    set.signalType = set.source.type;
                }
                break;

                case typeGetSet.ARRAY:
                {
                    BaseSignal tmp = ((Set_ARRAY)_set).Source;
                    set.source            = new Source();
                    set.source.name       = tmp.name;
                    set.source.groupName  = tmp.groupName;
                    set.source.group      = tmp.group;
                    set.source.port       = tmp.port;
                    set.source.address    = tmp.address;
                    set.source.type       = tmp.type;
                    set.source.sizeInBits = tmp.sizeInBits;
                    set.source.indexBit   = tmp.indexBit;           // ((Set_STAND_BIT)_set).
                    set.source.mode       = tmp.mode;
                    set.source.bValue     = tmp.bValue;
                    set.source.iValue     = tmp.iValue;
                    set.source.isRS       = tmp.isRS();
                    set.source.setAddr    = 0;
                    set.source.bufAddr    = 0;

                    set.valueon   = set.source.iValue;
                    set.indexbyte = 0;
                    set.indexbit  = set.source.indexBit;
                    set.valueoff  = ~set.valueon;
                    set.sizebyte  = (ushort)(set.source.sizeInBits / 8);

                    set.comment   = ((Set_ARRAY)_set).Comment;
                    set.imagelink = ((Set_ARRAY)_set).ImageLink;

                    //set.signalType = typeGetSet.ARRAY;
                    set.signalType = set.source.type;
                }
                break;
                }
            }
            else
            {
                set = null;
            }

            if (_get != null)
            {
                switch (_get.ReturnTypeGet())
                {
                case typeGetSet.RS_ANALOG:
                {
                    BaseRS tmp = ((Get_RS_ANALOG)_get).Source;
                    get.source            = new Source();
                    get.source.name       = tmp.Name;
                    get.source.groupName  = tmp.GroupName;
                    get.source.group      = tmp.Group;
                    get.source.port       = tmp.Port;
                    get.source.address    = 0;
                    get.source.type       = SIGNALTYPE.ANALOG;
                    get.source.sizeInBits = (ushort)(((Get_RS_ANALOG)_get).SizeByte * 8);
                    get.source.indexBit   = 0;
                    get.source.mode       = MODETYPE.UNDEFINED;
                    get.source.bValue     = false;
                    get.source.iValue     = 0;
                    get.source.setAddr    = tmp.SetAddress;
                    get.source.bufAddr    = tmp.BufAddress;
                    get.source.isRS       = tmp.isRS();

                    get.valueon    = get.source.iValue;
                    get.indexbyte  = ((Get_RS_ANALOG)_get).IndexByte;
                    get.indexbit   = 0;
                    get.sizebyte   = (ushort)(get.source.sizeInBits / 8);
                    get.min        = ((Get_RS_ANALOG)_get).Min;
                    get.max        = ((Get_RS_ANALOG)_get).Max;
                    get.signalType = get.source.type;
                }
                break;

                case typeGetSet.RS_BIT:
                {
                    BaseRS tmp = ((Get_RS_BIT)_get).Source;
                    get.source            = new Source();
                    get.source.name       = tmp.Name;
                    get.source.groupName  = tmp.GroupName;
                    get.source.group      = tmp.Group;
                    get.source.port       = tmp.Port;
                    get.source.address    = 0;
                    get.source.type       = SIGNALTYPE.LOGIC;
                    get.source.sizeInBits = (ushort)(8 * ((Get_RS_BIT)_get).BoardRs.NumBytes);
                    get.source.indexBit   = ((Get_RS_BIT)_get).IndexBit;
                    get.source.mode       = MODETYPE.READ;
                    get.source.bValue     = ((Get_RS_BIT)_get).ValueOn;
                    if (get.source.bValue)
                    {
                        get.source.iValue = (uint)(1 << ((Get_RS_BIT)_get).IndexBit);
                    }
                    else
                    {
                        get.source.iValue = (uint)(~(1 << ((Get_RS_BIT)_get).IndexBit));
                    }
                    get.source.setAddr = tmp.SetAddress;
                    get.source.bufAddr = tmp.BufAddress;
                    get.source.isRS    = tmp.isRS();

                    get.valueon   = get.source.iValue;
                    get.indexbyte = ((Get_RS_BIT)_get).IndexByte;
                    get.indexbit  = get.source.indexBit;
                    get.sizebyte  = (ushort)(get.source.sizeInBits / 8);
                    get.min       = 0;
                    get.max       = 0;

                    //get.signalType = typeGetSet.RS_BIT;
                    get.signalType = get.source.type;
                }
                break;

                case typeGetSet.STAND_ANALOG:
                {
                    BaseSignal tmp = ((Get_STAND_ANALOG)_get).Source;
                    get.source = new Source();

                    get.source.name       = tmp.name;
                    get.source.groupName  = tmp.groupName;
                    get.source.group      = tmp.group;
                    get.source.port       = tmp.port;
                    get.source.address    = tmp.address;
                    get.source.type       = tmp.type;
                    get.source.sizeInBits = tmp.sizeInBits;
                    get.source.indexBit   = tmp.indexBit;
                    get.source.mode       = tmp.mode;
                    get.source.bValue     = tmp.bValue;
                    get.source.iValue     = tmp.iValue;
                    get.source.setAddr    = 0;
                    get.source.bufAddr    = 0;
                    get.source.isRS       = tmp.isRS();

                    get.valueon   = get.source.iValue;
                    get.indexbyte = 0;
                    get.indexbit  = tmp.indexBit;
                    get.sizebyte  = (ushort)(get.source.sizeInBits / 8);
                    get.min       = ((Get_STAND_ANALOG)_get).Min;
                    get.max       = ((Get_STAND_ANALOG)_get).Max;
                }
                break;

                case typeGetSet.STAND_BIT:
                {
                    BaseSignal tmp = ((Get_STAND_BIT)_get).Source;
                    get.source            = new Source();
                    get.source.name       = tmp.name;
                    get.source.groupName  = tmp.groupName;
                    get.source.group      = tmp.group;
                    get.source.port       = tmp.port;
                    get.source.address    = tmp.address;
                    get.source.type       = tmp.type;
                    get.source.sizeInBits = tmp.sizeInBits;
                    get.source.indexBit   = tmp.indexBit;
                    get.source.mode       = tmp.mode;
                    get.source.bValue     = tmp.bValue;
                    get.source.iValue     = tmp.iValue;
                    get.source.isRS       = tmp.isRS();
                    get.source.setAddr    = 0;
                    get.source.bufAddr    = 0;

                    get.valueon   = get.source.iValue;
                    get.indexbyte = 0;
                    get.indexbit  = get.source.indexBit;
                    get.sizebyte  = (ushort)(get.source.sizeInBits / 8);
                    get.min       = 0;
                    get.max       = 0;

                    //get.signalType = typeGetSet.STAND_BIT;
                    get.signalType = get.source.type;
                }
                break;

                case typeGetSet.ARRAY:
                {
                    BaseSignal tmp = ((Get_ARRAY)_get).Source;

                    //если Source сигнала Array равен нулю, ничего не делаем. Это признак для необходимости анализа ответного пакета
                    //проверка дабы не было исключения
                    if (tmp != null)
                    {
                        get.source            = new Source();
                        get.source.name       = tmp.name;
                        get.source.groupName  = tmp.groupName;
                        get.source.group      = tmp.group;
                        get.source.port       = tmp.port;
                        get.source.address    = tmp.address;
                        get.source.type       = tmp.type;
                        get.source.sizeInBits = tmp.sizeInBits;
                        get.source.indexBit   = tmp.indexBit;
                        get.source.mode       = tmp.mode;
                        get.source.bValue     = tmp.bValue;
                        get.source.iValue     = tmp.iValue;
                        get.source.isRS       = tmp.isRS();
                        get.source.setAddr    = 0;
                        get.source.bufAddr    = 0;

                        get.valueon   = get.source.iValue;
                        get.indexbyte = 0;
                        get.indexbit  = get.source.indexBit;
                        get.sizebyte  = (ushort)(get.source.sizeInBits / 8);
                        get.min       = 0;
                        get.max       = 0;

                        //get.signalType = typeGetSet.ARRAY;
                        get.signalType = get.source.type;
                    }
                }
                break;
                }
            }
            else
            {
                get = null;
            }
        }