public void                                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader  = new XMLAttributeReader(aXMLTextReader);
            var lChecker = new RepeatItemNameChecker();

            string lItem = lReader.getAttribute <String>("Switch");

            lChecker.addItemName(lItem);
            mSwitchItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Input1");
            lChecker.addItemName(lItem);
            mInput1ItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Input2");
            lChecker.addItemName(lItem);
            mInput2ItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Value");
            lChecker.addItemName(lItem);
            mValueItemHandle = mItemBrowser.getItemHandleByName(lItem);

            In2ToIn1MS = lReader.getAttribute <UInt32>("In2ToIn1MS", mIn2ToIn1MS);
            In1ToIn2MS = lReader.getAttribute <UInt32>("In1ToIn2MS", mIn1ToIn2MS);
        }
        private void            dataGridViewItems_CellMouseDoubleClick(object aSender, DataGridViewCellMouseEventArgs aEventArgs)
        {
            if (aEventArgs.RowIndex == -1)
            {
                return;
            }

            string lItem   = mDataTable.Rows[aEventArgs.RowIndex][1].ToString();
            int    lHandle = -1;

            if (String.IsNullOrWhiteSpace(lItem) == false)
            {
                lHandle = mBrowser.getItemHandleByName(lItem);
            }

            lHandle = mBrowser.getItemHandleByForm(lHandle, this);

            if (lHandle != -1)
            {
                mDataTable.Rows[aEventArgs.RowIndex][1] = mBrowser.getItemNameByHandle(lHandle);
            }
            else
            {
                mDataTable.Rows[aEventArgs.RowIndex][1] = "";
            }
        }
Ejemplo n.º 3
0
        public void                                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader  = new XMLAttributeReader(aXMLTextReader);
            var lChecker = new RepeatItemNameChecker();

            string lItem = lReader.getAttribute <String>("On", "");

            lChecker.addItemName(lItem);
            mOnItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Value");
            lChecker.addItemName(lItem);
            mValueItemHandle = mItemBrowser.getItemHandleByName(lItem);

            SignalString = lReader.getAttribute <String>("Signal");
            Bias         = lReader.getAttribute <Double>("Bias", mBias);
            Amplitude    = lReader.getAttribute <Double>("Amplitude", mAmplitude);
            PeriodMS     = lReader.getAttribute <UInt32>("PeriodMS", mPeriodMS);
            TurnMS       = lReader.getAttribute <UInt32>("TurnMS", mTurnMS);
            StartMS      = lReader.getAttribute <UInt32>("StartMS", mStartMS);

            try
            {
                mValue = (double)mItemBrowser.readItemValue(mValueItemHandle);
            }
            catch
            {
                if (mSignal > 0)
                {
                    mPeriodStartMS = MiscUtils.TimerMS - mStartMS;
                    mCurrentMS     = mStartMS;
                    mFSM.executeStateAction();
                }
            }
        }
Ejemplo n.º 4
0
        private void            ItemButtonClick(object aSender, EventArgs aEventArgs)
        {
            var lItemEditBox = (ItemEditBox)aSender;
            int lHandle      = mBrowser.getItemHandleByForm(mBrowser.getItemHandleByName(lItemEditBox.ItemName), this);

            lItemEditBox.ItemName    = mBrowser.getItemNameByHandle(lHandle);
            lItemEditBox.ItemToolTip = mBrowser.getItemToolTipByHandle(lHandle);
        }
        public void                 loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader = new XMLAttributeReader(aXMLTextReader);

            string lItem = lReader.getAttribute <String>("On", "");

            mOnItemHandle = mItemBrowser.getItemHandleByName(lItem);

            mPath = lReader.getAttribute <String>("Path", "");
            if (String.IsNullOrWhiteSpace(mPath) == false)
            {
                if (Directory.Exists(mPath) == false)
                {
                    throw new ArgumentException("Path does not exist. ");
                }
            }

            mFileName         = lReader.getAttribute <String>("FileName", mFileName);
            RateMS            = (int)lReader.getAttribute <UInt32>("Rate", (uint)RateMS);
            mWriteChangesOnly = lReader.getAttribute <Boolean>("WriteChangesOnly", mWriteChangesOnly);
            mDelimiter        = lReader.getAttribute <String>("Delimiter", mDelimiter);

            HashSet <int> lItems = new HashSet <int>();

            aXMLTextReader.Read();
            if (aXMLTextReader.Name.Equals("Items", StringComparison.Ordinal))
            {
                aXMLTextReader.Read();

                int    lHandle;
                string lItemName;

                while (aXMLTextReader.Name.Equals("Item", StringComparison.Ordinal) && aXMLTextReader.IsStartElement())
                {
                    lItemName = lReader.getAttribute <String>("Name");
                    lHandle   = mItemBrowser.getItemHandleByName(lItemName);

                    if (lItems.Contains(lHandle))
                    {
                        throw new ArgumentException("Item '" + lItemName + "' already exists. ");
                    }

                    lItems.Add(lHandle);
                    aXMLTextReader.Read();
                }
            }

            if (lItems.Count != 0)
            {
                initItems(lItems.ToArray());
            }
        }
Ejemplo n.º 6
0
        public void                     addRecord(string aItemName, object aValue)
        {
            checkRecordArguments(aItemName, aValue);

            int lItemHandle = mItemBrowser.getItemHandleByName(aItemName);

            if (mRecords.ContainsKey(lItemHandle))
            {
                throw new ArgumentException("Item '" + aItemName + "' already exists. ");
            }

            mRecords.Add(lItemHandle, aValue);
        }
Ejemplo n.º 7
0
        public void                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader = new XMLAttributeReader(aXMLTextReader);

            Language         = lReader.getAttribute <String>("Language");
            mValueItemHandle = mItemBrowser.getItemHandleByName(lReader.getAttribute <String>("Item"));

            mHolder.clear();
            if (aXMLTextReader.IsEmptyElement == false)
            {
                aXMLTextReader.Read();
                if (aXMLTextReader.Name.Equals("Commands", StringComparison.Ordinal))
                {
                    if (aXMLTextReader.IsEmptyElement == false)
                    {
                        mHolder.loadFromXML(aXMLTextReader, "Comand");
                    }

                    aXMLTextReader.Read();
                }
            }

            if (mHolder.Count == 0)
            {
                mHolder.add("Ok, Dave.", 0, false);
            }
        }
        public void                                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader  = new XMLAttributeReader(aXMLTextReader);
            var lChecker = new RepeatItemNameChecker();

            string lItem = lReader.getAttribute <String>("X");

            lChecker.addItemName(lItem);
            mXValueItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Y");
            lChecker.addItemName(lItem);
            mYValueItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Visible", "");
            lChecker.addItemName(lItem);
            mVisibleItemHandle = mItemBrowser.getItemHandleByName(lItem);

            if (aXMLTextReader.IsEmptyElement == false)
            {
                aXMLTextReader.Read();
                if (aXMLTextReader.Name.Equals("Image", StringComparison.Ordinal))
                {
                    if (aXMLTextReader.IsEmptyElement == false)
                    {
                        aXMLTextReader.Read();
                        mImgMemStrm = new MemoryStream(Convert.FromBase64String(aXMLTextReader.ReadString()));
                    }
                }
            }

            if (mImgMemStrm == null)
            {
                throw new ArgumentException("Image does not exist. ");
            }

            try
            {
                mBmp = new Bitmap(mImgMemStrm);
            }
            catch (Exception lExc)
            {
                mImgMemStrm.Close();
                mImgMemStrm = null;
                throw new ArgumentException("Image is wrong. " + lExc.Message, lExc);
            }
        }
Ejemplo n.º 9
0
        public void                             loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader  = new XMLAttributeReader(aXMLTextReader);
            var lChecker = new RepeatItemNameChecker();

            string lItem = lReader.getAttribute <String>("Y");

            lChecker.addItemName(lItem);
            mValueItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("X");
            lChecker.addItemName(lItem);
            mInputItemHandle = mItemBrowser.getItemHandleByName(lItem);

            var lPoints = new SortedDictionary <double, double>();

            aXMLTextReader.Read();
            if (aXMLTextReader.Name.Equals("Points", StringComparison.Ordinal))
            {
                aXMLTextReader.Read();

                double lX, lY;

                while (aXMLTextReader.Name.Equals("Point", StringComparison.Ordinal) && aXMLTextReader.IsStartElement())
                {
                    lX = lReader.getAttribute <Double>("X");
                    lY = lReader.getAttribute <Double>("Y");

                    if (lPoints.ContainsKey(lX))
                    {
                        throw new ArgumentException("Point where X equals '" + lX.ToString() + "' already exists. ");
                    }

                    lPoints.Add(lX, lY);
                    aXMLTextReader.Read();
                }
            }

            if (lPoints.Count >= 2)
            {
                Points = lPoints;
            }
            else
            {
                throw new ArgumentException("Points number must be equal or grater than two. ");
            }
        }
Ejemplo n.º 10
0
        public void                                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader  = new XMLAttributeReader(aXMLTextReader);
            var lChecker = new RepeatItemNameChecker();

            string lItem = lReader.getAttribute <String>("Value");

            lChecker.addItemName(lItem);
            mValueItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Input");
            lChecker.addItemName(lItem);
            mInputItemHandle = mItemBrowser.getItemHandleByName(lItem);

            LagMS = lReader.getAttribute <UInt32>("LagMS", LagMS);
            Gain  = lReader.getAttribute <Double>("Gain", Gain);
        }
Ejemplo n.º 11
0
        public void                                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader  = new XMLAttributeReader(aXMLTextReader);
            var lChecker = new RepeatItemNameChecker();

            string lItem = lReader.getAttribute <String>("InputItem");

            lChecker.addItemName(lItem);
            mInValueItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("OutputItem");
            lChecker.addItemName(lItem);
            mOutValueItemHandle = mItemBrowser.getItemHandleByName(lItem);

            Inverse    = lReader.getAttribute <Boolean>("Inverse", Inverse);
            OnDelayMS  = lReader.getAttribute <UInt32>("OnDelayMS", OnDelayMS);
            OffDelayMS = lReader.getAttribute <UInt32>("OffDelayMS", OffDelayMS);
        }
Ejemplo n.º 12
0
        public void             loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader  = new XMLAttributeReader(aXMLTextReader);
            var lChecker = new RepeatItemNameChecker();

            mFront       = (EFront)Enum.Parse(typeof(EFront), lReader.getAttribute <String>("Front"));
            mPositiveInc = lReader.getAttribute <Boolean>("PositiveIncrease");
            mNegativeInc = lReader.getAttribute <Boolean>("NegativeIncrease");

            string lItem = lReader.getAttribute <String>("Input");

            lChecker.addItemName(lItem);
            mInValueItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Output");
            lChecker.addItemName(lItem);
            mOutValueItemHandle = mItemBrowser.getItemHandleByName(lItem);
        }
        public void                                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader  = new XMLAttributeReader(aXMLTextReader);
            var lChecker = new RepeatItemNameChecker();

            string lItem = lReader.getAttribute <String>("Remote", "");

            lChecker.addItemName(lItem);
            mRemoteItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("OnCMD", "");
            lChecker.addItemName(lItem);
            mOnCMDItemHandle = mItemBrowser.getItemHandleByName(lItem);

            mUseOneCommand = lReader.getAttribute <Boolean>("UseOneCMD", mUseOneCommand);

            lItem = lReader.getAttribute <String>("OffCMD", "");
            lChecker.addItemName(lItem);
            mOffCMDItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("EsdCMD", "");
            lChecker.addItemName(lItem);
            mEsdCMDItemHandle = mItemBrowser.getItemHandleByName(lItem);

            OnMS  = lReader.getAttribute <UInt32>("OnMS", mOnMS);
            OffMS = lReader.getAttribute <UInt32>("OffMS", mOffMS);

            lItem = lReader.getAttribute <String>("On", "");
            lChecker.addItemName(lItem);
            mOnItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Power", "");
            lChecker.addItemName(lItem);
            mPowerItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Alarm", "");
            lChecker.addItemName(lItem);
            mAlarmItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("OnBtn", "");
            lChecker.addItemName(lItem);
            mOnBtnItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("OffBtn", "");
            lChecker.addItemName(lItem);
            mOffBtnItemHandle = mItemBrowser.getItemHandleByName(lItem);
        }
        public void                                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader  = new XMLAttributeReader(aXMLTextReader);
            var lChecker = new RepeatItemNameChecker();

            string lItem = lReader.getAttribute <String>("On", "");

            lChecker.addItemName(lItem);
            mOnItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Value");
            lChecker.addItemName(lItem);
            mValueItemHandle = mItemBrowser.getItemHandleByName(lItem);

            SignalString = lReader.getAttribute <String>("Signal");
            Bias         = lReader.getAttribute <Double>("Bias", Bias);
            Amplitude    = lReader.getAttribute <Double>("Amplitude", Amplitude);
            PeriodMS     = lReader.getAttribute <UInt32>("PeriodMS", PeriodMS);
            TurnMS       = lReader.getAttribute <UInt32>("TurnMS", TurnMS);
        }
        public void                                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader  = new XMLAttributeReader(aXMLTextReader);
            var lChecker = new RepeatItemNameChecker();

            OperationString = lReader.getAttribute <String>("Operation");

            string lItem = lReader.getAttribute <String>("Input1");

            lChecker.addItemName(lItem);
            mInput1ItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Input2");
            lChecker.addItemName(lItem);
            mInput2ItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Value");
            lChecker.addItemName(lItem);
            mValueItemHandle = mItemBrowser.getItemHandleByName(lItem);
        }
        public void                                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader  = new XMLAttributeReader(aXMLTextReader);
            var lChecker = new RepeatItemNameChecker();

            string lItem = lReader.getAttribute <String>("Set");

            lChecker.addItemName(lItem);
            mSetItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Reset");
            lChecker.addItemName(lItem);
            mResetItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Value");
            lChecker.addItemName(lItem);
            mValueItemHandle = mItemBrowser.getItemHandleByName(lItem);

            SR_RS = lReader.getAttribute <Boolean>("SR_RS");
        }
Ejemplo n.º 17
0
        public void                                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader = new XMLAttributeReader(aXMLTextReader);

            mValueItemHandle = mItemBrowser.getItemHandleByName(lReader.getAttribute <String>("Item"));
            TrueSpeech       = lReader.getAttribute <String>("TrueSpeech", "");
            FalseSpeech      = lReader.getAttribute <String>("FalseSpeech", "");
            TellTrue         = lReader.getAttribute <Boolean>("TellTrue", TellTrue);
            LogTrue          = lReader.getAttribute <Boolean>("LogTrue", LogTrue);
            TellFalse        = lReader.getAttribute <Boolean>("TellFalse", TellFalse);
            LogFalse         = lReader.getAttribute <Boolean>("LogFalse", LogFalse);
        }
Ejemplo n.º 18
0
        public void                                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader  = new XMLAttributeReader(aXMLTextReader);
            var lChecker = new RepeatItemNameChecker();

            string lItem = lReader.getAttribute <String>("InputItem");

            lChecker.addItemName(lItem);
            mInValueItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("OutputItem");
            lChecker.addItemName(lItem);
            mOutValueItemHandle = mItemBrowser.getItemHandleByName(lItem);

            double lInMax  = lReader.getAttribute <Double>("MaxInputValue");
            double lInMin  = lReader.getAttribute <Double>("MinInputValue");
            double lOutMax = lReader.getAttribute <Double>("MaxOutputValue");
            double lOutMin = lReader.getAttribute <Double>("MinOutputValue");

            mValueScale.setProperties(lInMax, lInMin, lOutMax, lOutMin);
        }
        private void            fastColoredTextBox_Code_ToolTipNeeded(object aSender, ToolTipNeededEventArgs aEventArgs)
        {
            var lRange = new Range(aSender as FastColoredTextBox, aEventArgs.Place, aEventArgs.Place);

            try
            {
                int lHandle = mBrowser.getItemHandleByName(lRange.GetFragment("[^\n ']").Text);
                if (lHandle != -1)
                {
                    aEventArgs.ToolTipText = mBrowser.getItemToolTipByHandle(lHandle);
                }
            }
            catch { }
        }
        public void                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader = new XMLAttributeReader(aXMLTextReader);

            string lItem = lReader.getAttribute <String>("On", "");

            mOnItemHandle = mItemBrowser.getItemHandleByName(lItem);

            Loop = lReader.getAttribute <Boolean>("Loop", Loop);

            aXMLTextReader.Read();
            if (aXMLTextReader.Name.Equals("Sections", StringComparison.Ordinal))
            {
                aXMLTextReader.Read();

                long     lInterval;
                Snapshot lSnapshot;

                while (aXMLTextReader.Name.Equals("Section", StringComparison.Ordinal) && aXMLTextReader.IsStartElement())
                {
                    lInterval = lReader.getAttribute <Int64>("DelayMS");
                    lSnapshot = new Snapshot("", mItemBrowser);

                    aXMLTextReader.Read();

                    if (aXMLTextReader.Name.Equals("Record", StringComparison.Ordinal))
                    {
                        lSnapshot.loadFromXML(aXMLTextReader);
                    }

                    mSections.Add(new Tuple <long, Snapshot>(lInterval, lSnapshot));

                    aXMLTextReader.Read();
                }
            }
        }
        public void                                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader  = new XMLAttributeReader(aXMLTextReader);
            var lChecker = new RepeatItemNameChecker();

            string lItem = lReader.getAttribute <String>("Item");

            lChecker.addItemName(lItem);
            mValueItemHandle = mItemBrowser.getItemHandleByName(lItem);

            double lPMax   = lReader.getAttribute <Double>("MaxPhysicalValue");
            double lPMin   = lReader.getAttribute <Double>("MinPhysicalValue");
            double lRawMax = lReader.getAttribute <Double>("MaxRawValue");
            double lRawMin = lReader.getAttribute <Double>("MinRawValue");

            mValueScale.setProperties(lRawMax, lRawMin, lPMax, lPMin);

            mFaultValue = lReader.getAttribute <Double>("FaultValue", mFaultValue);
            if (mFaultValue > lRawMin && mFaultValue < lRawMax)
            {
                throw new ArgumentException("Fault value is inside normal range. ");
            }

            mUnits = lReader.getAttribute <String>("Units", mUnits);

            #region Thresholds

            if (aXMLTextReader.IsEmptyElement == false)
            {
                aXMLTextReader.Read();
                if (aXMLTextReader.Name.Equals("Thresholds", StringComparison.Ordinal))
                {
                    if (aXMLTextReader.IsEmptyElement == false)
                    {
                        List <int>           lItems      = new List <int>();
                        List <double>        lValues     = new List <double>();
                        List <ValuesCompare> lOperations = new List <ValuesCompare>();
                        double lValue;

                        aXMLTextReader.Read();
                        while (aXMLTextReader.Name.Equals("Threshold", StringComparison.Ordinal))
                        {
                            lOperations.Add(new ValuesCompare(lReader.getAttribute <String>("Operation")));

                            lValue = lReader.getAttribute <Double>("Value");
                            if (lValue > mValueScale.OutMax)
                            {
                                throw new ArgumentException("Threshold value is more than maximum of physical value. ");
                            }
                            if (lValue < mValueScale.OutMin)
                            {
                                throw new ArgumentException("Threshold value is less than minimum of physical value. ");
                            }
                            lValues.Add(lValue);

                            lItem = lReader.getAttribute <String>("Item");
                            lChecker.addItemName(lItem);
                            lItems.Add(mItemBrowser.getItemHandleByName(lItem));

                            aXMLTextReader.Read();
                        }

                        if (lOperations.Count != 0)
                        {
                            mThdItemHandles = lItems.ToArray();
                            mThdItemValues  = new bool[lOperations.Count];
                            mThdValues      = lValues.ToArray();
                            mThdOperations  = lOperations.ToArray();
                        }
                    }

                    aXMLTextReader.Read();
                }
            }

            #endregion
        }
        public void                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader  = new XMLAttributeReader(aXMLTextReader);
            var lChecker = new RepeatItemNameChecker();

            string lItem = lReader.getAttribute <String>("ArrayItem");

            lChecker.addItemName(lItem);
            mArrayValueItemHandle = mItemBrowser.getItemHandleByName(lItem);

            mDataFlow = (EDataFlow)Enum.Parse(typeof(EDataFlow), lReader.getAttribute <String>("DataFlow", mDataFlow.ToString()));

            #region Elements

            if (aXMLTextReader.IsEmptyElement == false)
            {
                aXMLTextReader.Read();
                if (aXMLTextReader.Name.Equals("Elements", StringComparison.Ordinal))
                {
                    if (aXMLTextReader.IsEmptyElement == false)
                    {
                        List <int> lIndexes  = new List <int>();
                        List <int> lItems    = new List <int>();
                        var        lIndexSet = new HashSet <int>();
                        int        lMaxIndex = -1;
                        int        lIndex;

                        aXMLTextReader.Read();
                        while (aXMLTextReader.Name.Equals("Element", StringComparison.Ordinal))
                        {
                            lIndex = (int)lReader.getAttribute <UInt32>("Index");
                            if (lIndexSet.Add(lIndex) == false)
                            {
                                throw new ArgumentException("Index '" + lIndex.ToString() + "' already exists. ");
                            }
                            lIndexes.Add(lIndex);
                            if (lIndex > lMaxIndex)
                            {
                                lMaxIndex = lIndex;
                            }

                            lItem = lReader.getAttribute <String>("Item");
                            lChecker.addItemName(lItem);
                            lItems.Add(mItemBrowser.getItemHandleByName(lItem));

                            aXMLTextReader.Read();
                        }

                        if (lIndexes.Count != 0)
                        {
                            mElementItemHandles = new int[lMaxIndex + 1];
                            for (int i = 0; i < mElementItemHandles.Length; i++)
                            {
                                mElementItemHandles[i] = -1;
                            }
                            mElementValueChanged = new bool[mElementItemHandles.Length];
                            mArrayValue          = new object[mElementItemHandles.Length];

                            int lCount = lIndexes.Count;
                            for (int i = 0; i < lCount; i++)
                            {
                                lIndex = lIndexes[i];
                                mElementItemHandles[lIndex] = lItems[i];
                            }
                        }
                    }

                    aXMLTextReader.Read();
                }
            }

            #endregion
        }
        public void                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader  = new XMLAttributeReader(aXMLTextReader);
            var lChecker = new RepeatItemNameChecker();

            SendData        = lReader.getAttribute <Boolean>("SendData", SendData);
            UpdateRoKiSimMS = (int)lReader.getAttribute <UInt32>("UpdateRoKiSimMS", (uint)UpdateRoKiSimMS);

            if (aXMLTextReader.IsEmptyElement == false)
            {
                aXMLTextReader.Read();
                if (aXMLTextReader.Name.Equals("Joints", StringComparison.Ordinal))
                {
                    if (aXMLTextReader.IsEmptyElement == false)
                    {
                        var    lIndexSet = new HashSet <int>();
                        int    lIndex;
                        int    lArrayIndex;
                        string lItem;

                        aXMLTextReader.Read();
                        while (aXMLTextReader.Name.Equals("Joint", StringComparison.Ordinal))
                        {
                            lIndex = (int)lReader.getAttribute <UInt32>("Index");

                            if (lIndex == 0 || lIndex > 6)
                            {
                                throw new ArgumentException("Wrong joint number. ");
                            }

                            if (lIndexSet.Add(lIndex) == false)
                            {
                                throw new ArgumentException("Joint №" + lIndex.ToString() + " already exists. ");
                            }

                            lArrayIndex = lIndex - 1;

                            lItem = lReader.getAttribute <String>("SetPointItem", "");
                            lChecker.addItemName(lItem);
                            mAxisSPItemHandle[lArrayIndex] = mItemBrowser.getItemHandleByName(lItem);

                            mMaxSpeed[lArrayIndex] = lReader.getAttribute <Double>("MaxSpeed", mMaxSpeed[lArrayIndex]);
                            if (mMaxSpeed[lArrayIndex] <= 0.0D)
                            {
                                throw new ArgumentException("Maximum speed of joint №" + lIndex.ToString() + " must be greater than zero. ");
                            }

                            lItem = lReader.getAttribute <String>("AngleItem", "");
                            lChecker.addItemName(lItem);
                            mAxisAngleItemHandle[lArrayIndex] = mItemBrowser.getItemHandleByName(lItem);

                            mMaxAngle[lArrayIndex] = lReader.getAttribute <Double>("MaxAngle", mMaxAngle[lArrayIndex]);
                            mMinAngle[lArrayIndex] = lReader.getAttribute <Double>("MinAngle", mMinAngle[lArrayIndex]);
                            if (mMaxAngle[lArrayIndex] <= mMinAngle[lArrayIndex])
                            {
                                throw new ArgumentException("The maximum angle of joint №" + lIndex.ToString() + " has to be greater than minimum. ");
                            }

                            aXMLTextReader.Read();
                        }
                    }

                    aXMLTextReader.Read();
                }
            }
        }
        public void                                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var    lReader = new XMLAttributeReader(aXMLTextReader);
            var    lChecker = new RepeatItemNameChecker();
            double lMax, lMin;

            string lItem = lReader.getAttribute <String>("StartCMD", "");

            lChecker.addItemName(lItem);
            mStartCMDItemHandle = mItemBrowser.getItemHandleByName(lItem);

            mUseOneCommand = lReader.getAttribute <Boolean>("UseOneCMD", mUseOneCommand);

            lItem = lReader.getAttribute <String>("StopCMD", "");
            lChecker.addItemName(lItem);
            mStopCMDItemHandle = mItemBrowser.getItemHandleByName(lItem);

            StartMS = lReader.getAttribute <UInt32>("StartMS", mStartMS);
            StopMS  = lReader.getAttribute <UInt32>("StopMS", mStopMS);

            lItem = lReader.getAttribute <String>("SpeedCMD", "");
            lChecker.addItemName(lItem);
            mSpeedCMDItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lMax = lReader.getAttribute <Double>("SpeedCMDMax", mSpeedCMDScale.InMax);
            lMin = lReader.getAttribute <Double>("SpeedCMDMin", mSpeedCMDScale.InMin);
            mSpeedCMDScale.setProperties(lMax, lMin, 100.0D, 0.0D);

            lItem = lReader.getAttribute <String>("Moving", "");
            lChecker.addItemName(lItem);
            mMovingItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Alarm", "");
            lChecker.addItemName(lItem);
            mAlarmItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Reverse", "");
            lChecker.addItemName(lItem);
            mReverseItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Acceleration", "");
            lChecker.addItemName(lItem);
            mAccelerationItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Braking", "");
            lChecker.addItemName(lItem);
            mBrakingItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Speed", "");
            lChecker.addItemName(lItem);
            mSpeedItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lMax = lReader.getAttribute <Double>("SpeedMax", mSpeedScale.InMax);
            lMin = lReader.getAttribute <Double>("SpeedMin", mSpeedScale.InMin);
            mSpeedScale.setProperties(lMax, lMin, 100.0D, 0.0D);

            lItem = lReader.getAttribute <String>("Forward", "");
            lChecker.addItemName(lItem);
            mForwardItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Backward", "");
            lChecker.addItemName(lItem);
            mBackwardItemHandle = mItemBrowser.getItemHandleByName(lItem);
        }
Ejemplo n.º 25
0
        public void                                         loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader  = new XMLAttributeReader(aXMLTextReader);
            var lChecker = new RepeatItemNameChecker();

            string lItem = lReader.getAttribute <String>("X");

            lChecker.addItemName(lItem);
            mXValueItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Y");
            lChecker.addItemName(lItem);
            mYValueItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Visible", "");
            lChecker.addItemName(lItem);
            mVisibleItemHandle = mItemBrowser.getItemHandleByName(lItem);

            mUserCanMove = lReader.getAttribute <Boolean>("UserCanMove", mUserCanMove);

            lItem = lReader.getAttribute <String>("MovingByUser", "");
            lChecker.addItemName(lItem);
            mMovingByUserItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Width", "");
            lChecker.addItemName(lItem);
            mWidthItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Height", "");
            lChecker.addItemName(lItem);
            mHeightItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Label", "");
            lChecker.addItemName(lItem);
            mLabelItemHandle = mItemBrowser.getItemHandleByName(lItem);

            lItem = lReader.getAttribute <String>("Rotate", "");
            lChecker.addItemName(lItem);
            mRotateItemHandle = mItemBrowser.getItemHandleByName(lItem);

            mLabelFont  = lReader.getAttribute <Font>("LabelFont", mLabelFont);
            mLabelColor = lReader.getAttribute <Color>("LabelColor", mLabelColor);

            if (aXMLTextReader.IsEmptyElement == false)
            {
                aXMLTextReader.Read();
                if (aXMLTextReader.Name.Equals("Image", StringComparison.Ordinal))
                {
                    if (aXMLTextReader.IsEmptyElement == false)
                    {
                        aXMLTextReader.Read();
                        mImgMemStrm = new MemoryStream(Convert.FromBase64String(aXMLTextReader.ReadString()));
                    }
                }
            }

            if (mImgMemStrm == null)
            {
                throw new ArgumentException("Image does not exist. ");
            }

            try
            {
                mBmp = new Bitmap(mImgMemStrm);
            }
            catch (Exception lExc)
            {
                mImgMemStrm.Close();
                mImgMemStrm = null;
                throw new ArgumentException("Image is wrong. " + lExc.Message, lExc);
            }

            mWidth  = mBmp.Width;
            mHeight = mBmp.Height;
        }