Esempio n. 1
0
        private void WorkerThreadProc(object obj)
        {
            while (true)
            {
                foreach (SeqData sd in _seqDataList)
                {
                    switch (sd.refdata.DataType)
                    {
                    case scsm_MMS_TypeEnum.boolean:
                        sd.refdata.DataValue = (sd.data == "True") ? true : false;

                        if ((sd.refdata.Tag as Data).isBooleanSelected())
                        {
                            (sd.refdata.Tag as Data).selectBoolean((sd.data == "True") ? true : false);
                        }
                        break;

                    case scsm_MMS_TypeEnum.integer:
                        sd.refdata.DataValue = Convert.ToInt32(sd.data);

                        if ((sd.refdata.Tag as Data).isIntegerSelected())
                        {
                            (sd.refdata.Tag as Data).selectInteger(Convert.ToInt32(sd.data));
                        }
                        break;

                    case scsm_MMS_TypeEnum.bit_string:
                        StringToDataConverter Converter = new StringToDataConverter();
                        BitString             bs        = Converter.ConvertToBitstring(sd.data);

                        sd.refdata.DataParam = bs.TrailBitsCnt;
                        sd.refdata.DataValue = bs.Value;

                        if ((sd.refdata.Tag as Data).isBitstringSelected())
                        {
                            (sd.refdata.Tag as Data).selectBitstring(bs);
                        }
                        break;

                    default:
                        break;
                    }

                    Thread.Sleep(sd.duration);
                }
            }
        }
Esempio n. 2
0
        private void listViewGooseLabelEdit(ListView lv, LabelEditEventArgs e)
        {
            switch ((lv.Items[e.Item].Tag as NodeGData).DataType)
            {
            case scsm_MMS_TypeEnum.boolean:
                (lv.Items[e.Item].Tag as NodeGData).DataValue = (lv.Items[e.Item].SubItems[2].Text == "True") ? true : false;

                if (((lv.Items[e.Item].Tag as NodeGData).Tag as Data).isBooleanSelected())
                {
                    ((lv.Items[e.Item].Tag as NodeGData).Tag as Data).selectBoolean((lv.Items[e.Item].SubItems[2].Text == "True") ? true : false);
                }
                break;

            case scsm_MMS_TypeEnum.integer:
                (lv.Items[e.Item].Tag as NodeGData).DataValue = Convert.ToInt32(lv.Items[e.Item].SubItems[2].Text);

                if (((lv.Items[e.Item].Tag as NodeGData).Tag as Data).isIntegerSelected())
                {
                    ((lv.Items[e.Item].Tag as NodeGData).Tag as Data).selectInteger(Convert.ToInt32(lv.Items[e.Item].SubItems[2].Text));
                }
                break;

            case scsm_MMS_TypeEnum.bit_string:
                StringToDataConverter Converter = new StringToDataConverter();
                BitString             bs        = Converter.ConvertToBitstring(lv.Items[e.Item].SubItems[2].Text);

                (lv.Items[e.Item].Tag as NodeGData).DataParam = bs.TrailBitsCnt;
                (lv.Items[e.Item].Tag as NodeGData).DataValue = bs.Value;


                if (((lv.Items[e.Item].Tag as NodeGData).Tag as Data).isBitstringSelected())
                {
                    ((lv.Items[e.Item].Tag as NodeGData).Tag as Data).selectBitstring(bs);
                }
                break;

            default:
                break;
            }

            if (((lv.Items[e.Item].Tag as NodeGData).Tag as Data).Description != lv.Items[e.Item].SubItems[3].Text)
            {
                ((lv.Items[e.Item].Tag as NodeGData).Tag as Data).Description = lv.Items[e.Item].SubItems[3].Text;
            }
        }
Esempio n. 3
0
        private void recursiveCreateDataList(object dl, XElement el)
        {
            Data nd = new Data();

            switch (el.Attribute("Type").Value)
            {
            case "structure":
                nd = new Data();
                DataSequence sd = new DataSequence();
                sd.initValue();
                nd.selectStructure(sd);
                if (dl is List <Data> )
                {
                    (dl as List <Data>).Add(nd);
                }
                else if (dl is Data)
                {
                    if ((dl as Data).isStructureSelected())
                    {
                        (dl as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        Logger.getLogger().LogError("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    Logger.getLogger().LogError("Error: Invalid parent data type !");
                }
                break;

            case "boolean":
                nd = new Data();
                nd.selectBoolean(el.Attribute("Value").Value == "True" ? true : false);

                if (el.Attribute("Desc") != null)
                {
                    nd.Description = el.Attribute("Desc").Value;
                }

                if (dl is List <Data> )
                {
                    (dl as List <Data>).Add(nd);
                }
                else if (dl is Data)
                {
                    if ((dl as Data).isStructureSelected())
                    {
                        (dl as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        Logger.getLogger().LogError("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    Logger.getLogger().LogError("Error: Invalid parent data type !");
                }
                break;

            case "integer":
                nd = new Data();
                nd.selectInteger(Convert.ToInt32(el.Attribute("Value").Value));

                if (el.Attribute("Desc") != null)
                {
                    nd.Description = el.Attribute("Desc").Value;
                }

                if (dl is List <Data> )
                {
                    (dl as List <Data>).Add(nd);
                }
                else if (dl is Data)
                {
                    if ((dl as Data).isStructureSelected())
                    {
                        (dl as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        Logger.getLogger().LogError("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    Logger.getLogger().LogError("Error: Invalid parent data type !");
                }
                break;

            case "bit_string":
                nd = new Data();
                StringToDataConverter Converter = new StringToDataConverter();
                BitString             bs        = Converter.ConvertToBitstring(el.Attribute("Value").Value);

                if (el.Attribute("Desc") != null)
                {
                    nd.Description = el.Attribute("Desc").Value;
                }

                if (bs != null)
                {
                    nd.selectBitstring(bs);
                }
                else
                {
                    nd.selectBitstring(new BitString(new byte[] { 0 }));
                    nd.Bitstring.TrailBitsCnt = 8;
                }
                if (dl is List <Data> )
                {
                    (dl as List <Data>).Add(nd);
                }
                else if (dl is Data)
                {
                    if ((dl as Data).isStructureSelected())
                    {
                        (dl as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        Logger.getLogger().LogError("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    Logger.getLogger().LogError("Error: Invalid parent data type !");
                }
                break;

            default:
                break;
            }

            if (el.HasElements)
            {
                foreach (XElement ndcn in el.Elements())
                {
                    recursiveCreateDataList(nd, ndcn);
                }
            }
        }
Esempio n. 4
0
        private void recursiveCreateGvl(object dl, XElement el, List <string> nst)
        {
            Data nd = new Data();

            switch (el.Attribute("Type").Value)
            {
            case "structure":
                nd = new Data();
                DataSequence sd = new DataSequence();
                sd.initValue();
                nd.selectStructure(sd);
                if (dl is List <Data> )
                {
                    (dl as List <Data>).Add(nd);
                }
                else if (dl is Data)
                {
                    if ((dl as Data).isStructureSelected())
                    {
                        (dl as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        Logger.getLogger().LogError("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    Logger.getLogger().LogError("Error: Invalid parent data type !");
                }
                break;

            case "boolean":
                nd = new Data();
                nd.selectBoolean(el.Attribute("Value").Value == "True" ? true : false);
                //nd.ValueChanged += new EventHandler(_ValueChanged);

                if (el.Attribute("Desc") != null)
                {
                    nd.Description = el.Attribute("Desc").Value;
                }

                if (dl is List <Data> )
                {
                    (dl as List <Data>).Add(nd);
                }
                else if (dl is Data)
                {
                    if ((dl as Data).isStructureSelected())
                    {
                        (dl as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        Logger.getLogger().LogError("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    Logger.getLogger().LogError("Error: Invalid parent data type !");
                }
                break;

            case "integer":
                nd = new Data();
                nd.selectInteger(Convert.ToInt32(el.Attribute("Value").Value));
                //nd.ValueChanged += new EventHandler(_ValueChanged);

                if (el.Attribute("Desc") != null)
                {
                    nd.Description = el.Attribute("Desc").Value;
                }

                if (dl is List <Data> )
                {
                    (dl as List <Data>).Add(nd);
                }
                else if (dl is Data)
                {
                    if ((dl as Data).isStructureSelected())
                    {
                        (dl as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        Logger.getLogger().LogError("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    Logger.getLogger().LogError("Error: Invalid parent data type !");
                }
                break;

            /*
             * case "float":
             * nd = new Data();
             * nd.selectFloatingpoint(new FloatingPoint(new byte[] { 0 }));
             * nd.ValueChanged += new EventHandler(_ValueChanged);
             * if (dl is List<Data>)
             *  (dl as List<Data>).Add(nd);
             * else if (dl is Data)
             * {
             *  if ((dl as Data).isStructureSelected())
             *      (dl as Data).Structure.Value.Add(nd);
             *  else
             *      MessageBox.Show("Error: Invalid parent data type !");
             * }
             * else
             *  MessageBox.Show("Error: Invalid parent data type !");
             * break;
             */
            case "bit_string":
                nd = new Data();
                StringToDataConverter Converter = new StringToDataConverter();
                BitString             bs        = Converter.ConvertToBitstring(el.Attribute("Value").Value);
                if (bs != null)
                {
                    nd.selectBitstring(bs);
                }
                else
                {
                    nd.selectBitstring(new BitString(new byte[] { 0 }));
                    nd.Bitstring.TrailBitsCnt = 8;
                }

                if (el.Attribute("Desc") != null)
                {
                    nd.Description = el.Attribute("Desc").Value;
                }

                //nd.ValueChanged += new EventHandler(_ValueChanged);
                if (dl is List <Data> )
                {
                    (dl as List <Data>).Add(nd);
                }
                else if (dl is Data)
                {
                    if ((dl as Data).isStructureSelected())
                    {
                        (dl as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        Logger.getLogger().LogError("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    Logger.getLogger().LogError("Error: Invalid parent data type !");
                }
                break;

            default:
                if (!nst.Contains(el.Attribute("Type").Value))
                {
                    nst.Add(el.Attribute("Type").Value);
                }
                break;
            }

            if (el.HasElements)
            {
                foreach (XElement ndcn in el.Elements())
                {
                    recursiveCreateGvl(nd, ndcn, nst);
                }
            }
        }