public RgbEasySignalType(int width, int height, int refreshRate, SIGNALTYPE type) { Width = width; Height = height; RefreshRate = refreshRate; Type = type; }
public CommonGet() { source = null; valueon = 0; indexbit = 0; indexbyte = 0; sizebyte = 0; min = max = 0; signalType = SIGNALTYPE.UNDEFINED; }
public CommonSet() { source = null; valueon = 0; valueoff = 0; indexbit = 0; indexbyte = 0; sizebyte = 0; comment = string.Empty; imagelink = string.Empty; signalType = SIGNALTYPE.UNDEFINED; }
/// <summary> /// Конструктор базовой сигнала стенда /// </summary> /// /// <param name="_name">Имя сигнала</param> /// <param name="_port">Номер порта</param> /// <param name="_addr">Базовый адрес</param> /// <param name="_type">Тип сигнала. LOGIC - битовой, ANALOG - аналоговый, COMPOUND - составной</param> /// <param name="_sizeInBits">Общий размер сигнала (группы) в битах</param> /// <param name="_indexBit">Индекс бита в составе всего сигнала (группы)</param> /// <param name="_mode">Режим доступа. WRITE, READ</param> /// <param name="_bValue">Логическое значение для сигнала. TRUE/FALSE. Для аналогового всегда FALSE</param> /// <param name="_iValue">Маска для битового сигнала и значение для аналогового. Если битовый сигнал FALSE, то устанавливается инверсная маска</param> /// <param name="groupName">Имя группы</param> /// <param name="group">Ссылка на группу</param> /// public BaseSignal(string _name, uint _port, uint _addr, SIGNALTYPE _type, ushort _sizeInBits, ushort _indexBit, MODETYPE _mode, bool _bValue, uint _iValue, string _groupName, GroupSignals _group) { name = _name; port = _port; address = _addr; type = _type; sizeInBits = _sizeInBits; indexBit = _indexBit; mode = _mode; groupName = _groupName; group = _group; bValue = _bValue; iValue = _iValue; }
public BaseSignal(string _name) { name = _name; groupName = "NONE"; group = null; port = 55055; address = 0; type = SIGNALTYPE.UNDEFINED; sizeInBits = 0; indexBit = 0; mode = MODETYPE.UNDEFINED; bValue = true; iValue = 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); }