Beispiel #1
0
        public virtual void ShowModelCheckingWindow(String tabName, PNExtendInfo extendInfo)
        {
            if (Specification != null)
            {
                if (Specification.AssertionDatabase.Count > 0)
                {
                    if (ModelCheckingForm.ModelCheckingFormInstance != null)
                    {
                        if (
                            MessageBox.Show(Resources.Only_one_model_checking_window_can_be_open_at_a_time__Do_you_want_to_close_the_current_one_to_open_a_new_one_,
                                            Common.Utility.Utilities.APPLICATION_NAME, MessageBoxButtons.YesNo,
                                            MessageBoxIcon.Warning) == DialogResult.Yes)
                        {
                            ModelCheckingForm.ModelCheckingFormInstance.Close();
                        }
                        else
                        {
                            return;
                        }
                    }

                    if (ModelCheckingForm.ModelCheckingFormInstance == null)
                    {
                        ModelCheckingForm form = InstanciateModelCheckingForm(tabName, extendInfo);
                        form.Show();
                    }
                }
                else
                {
                    MessageBox.Show(Resources.Please_input_at_least_one_assertion_, Common.Utility.Utilities.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
        public SpecificationWorker(PNExtendInfo pnExtendInfo, SpecificationBase spec, ISpecificationWorker listener, Form parentFrm)
        {
            mExtendInfo = pnExtendInfo;
            mSpec       = spec;
            mListener   = listener;
            mForm       = parentFrm;

            // Setup timer
            mTimer          = new Timer();
            mTimer.Tick    += MCTimer_Tick;
            mTimer.Interval = 1000;
        }
Beispiel #3
0
        public LatexWorker(PNExtendInfo extendInfo, string filename)
        {
            this.mFileName = filename;
            mLatexList = new List<LatexResult>();
            mExtInfo = extendInfo;

            // Init folder
            try
            {
                Directory.CreateDirectory(ROOT_LATEX_PATH);
                Directory.CreateDirectory(TMP_LATEX_PATH);
                checkLatex();
            }
            catch (Exception e) { }
        }
Beispiel #4
0
        /// <summary>
        /// Parse and load LTS from Xml
        /// </summary>
        /// <param name="text">Xml pure text</param>
        /// <returns></returns>
        public static PNModel LoadLTSFromXML(string text)
        {
            string          assertion  = string.Empty;
            List <PNCanvas> canvases   = new List <PNCanvas>();
            PNExtendInfo    extendInfo = null;

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(text);

            XmlNodeList sitesNodes = doc.GetElementsByTagName(XmlTag.TAG_DECLARATION);

            //TODO? What is this for?
            foreach (XmlElement component in sitesNodes)
            {
                assertion = component.InnerText;
            }

            sitesNodes = doc.GetElementsByTagName(XmlTag.TAG_MODELS);

            if (sitesNodes.Count > 0)
            {
                foreach (XmlElement component in sitesNodes[0].ChildNodes)
                {
                    // mlqvu -- set value for extend info
                    // load topology from xml
                    if (component.ChildNodes.Count == 4)
                    {
                        XmlElement topologyElement = (XmlElement)component.ChildNodes[0];
                        extendInfo = loadExtendInfo(topologyElement);
                    }

                    PNCanvas canvas = new PNCanvas();
                    canvas.LoadFromXml(component);
                    canvases.Add(canvas);
                }
            }

            PNModel model = new PNModel(assertion, canvases);

            model.mExtendInfo = extendInfo;

            return(model);
        }
Beispiel #5
0
        public ModelCheckingForm(string Name, SpecificationBase spec, PNExtendInfo extendInfo)
        {
            mSpecWorker = new SpecificationWorker(spec, this, this);
            mExtendInfo = extendInfo;

            InitializeComponent();
            initPerformanceAnalytics();
            initLogic();
            mLatexWorker = new LatexWorker(extendInfo, Name);

            if (Name != "")
            {
            #if DEBUG
                Text = Text + " (Debug Model) - " + Name;
            #else
            this.Text = this.Text + " - " + Name;
            #endif
            }
        }
Beispiel #6
0
        public ModelCheckingForm(string Name, SpecificationBase spec, PNExtendInfo extendInfo)
        {
            mExtendInfo = extendInfo;
            mSpecWorker = new SpecificationWorker(mExtendInfo,spec, this, this);
            filename = Name;
            InitializeComponent();
            initPerformanceAnalytics();
            initLogic();
            //mLatexWorker = new LatexWorker(extendInfo, Name);
            mLatexWorker = new LatexWorker(mExtendInfo, Name);
            
            if (Name != "")
            {
#if DEBUG
                Text = Text + " (Debug Model) - " + Name;
#else
            this.Text = this.Text + " - " + Name; 
#endif
            }
        }
Beispiel #7
0
        public LatexWorker(PNExtendInfo extendInfo, string filename)
        {
            mFileName   = filename;
            mExtendInfo = extendInfo;
            //mParseRes = latexresult;

            // Init latex result
            mParseRes[0] = new LatexResult(AssertType.DEADLOCK_FREE, 0, 0, 0, 0d, "\\unk", false);
            mParseRes[1] = new LatexResult(AssertType.CONGESTION_CHANNEL, 0, 0, 0, 0d, "\\unk", false);
            mParseRes[2] = new LatexResult(AssertType.CONGESTION_SENSOR, 0, 0, 0, 0d, "\\unk", false);

            // Init folder
            try
            {
                Directory.CreateDirectory(ROOT_LATEX_PATH);
                Directory.CreateDirectory(TMP_LATEX_PATH);
                checkLatex();
            }
            catch (Exception e) { }
        }
Beispiel #8
0
        /// <summary>
        /// Generate extend information from model
        /// </summary>
        /// <param name="model"></param>
        private void generateExtendInfo(XmlElement model)
        {
            do
            {
                XmlElement topoElem = (XmlElement)model.GetElementsByTagName(XmlTag.TAG_TOPOLOGY)[0];
                if (topoElem == null)
                {
                    break;
                }

                if (mExtendInfo == null)
                {
                    mExtendInfo = new PNExtendInfo();
                }
                topoElem.SetAttribute(XmlTag.ATTR_mID, mExtendInfo.mID.ToString());
                topoElem.SetAttribute(XmlTag.ATTR_NUMOFSENSORS, mExtendInfo.mNumberSensor.ToString());
                topoElem.SetAttribute(XmlTag.ATTR_NUMOFPACKETS, mExtendInfo.mNumberPacket.ToString());
                topoElem.SetAttribute(XmlTag.ATTR_AVGBUFFER, mExtendInfo.mSensorMaxBufferSize.ToString());
                topoElem.SetAttribute(XmlTag.TAG_MODE, mExtendInfo.mMode.ToString());
                topoElem.SetAttribute(XmlTag.TAG_ABSTRACTEDLEVEL, mExtendInfo.mAbsLevel);
            } while (false);
        }
Beispiel #9
0
        /// <summary>
        /// Load extend information from Xml
        /// </summary>
        /// <param name="topoElement"></param>
        /// <returns></returns>
        private static PNExtendInfo loadExtendInfo(XmlElement topoElement)
        {
            PNExtendInfo extendInfo = null;

            do
            {
                extendInfo = new PNExtendInfo();
                String mID         = topoElement.Attributes[XmlTag.ATTR_mID].Value;
                String numOfSensor = topoElement.Attributes[XmlTag.ATTR_NUMOFSENSORS].Value;
                String numOfPacket = topoElement.Attributes[XmlTag.ATTR_NUMOFPACKETS].Value;
                String avgBuffer   = topoElement.Attributes[XmlTag.ATTR_AVGBUFFER].Value;
                String mode        = topoElement.Attributes[XmlTag.TAG_MODE].Value;
                String absLevel    = topoElement.Attributes[XmlTag.TAG_ABSTRACTEDLEVEL].Value;

                extendInfo.mID                  = long.Parse(mID);
                extendInfo.mNumberSensor        = Int32.Parse(numOfSensor);
                extendInfo.mNumberPacket        = Int32.Parse(numOfPacket);
                extendInfo.mSensorMaxBufferSize = Int32.Parse(avgBuffer);
                extendInfo.mMode                = (NetMode)Enum.Parse(typeof(NetMode), mode);
                extendInfo.mAbsLevel            = absLevel;
            } while (false);

            return(extendInfo);
        }
Beispiel #10
0
        public override void SetText(string text)
        {
            PNModel pn = PNModel.LoadLTSFromXML(text);

            // mlqvu -- Cache extend info
            mExtendInfo = pn.mExtendInfo;

            DeclarationNode.Tag = pn.Declaration;
            textEditorControl.Text = pn.Declaration;

            ModelNode.Nodes.Clear();
            toolStripContainer1.ContentPanel.Controls.Clear();

            foreach (PNCanvas canvas in pn.Canvases)
            {

                canvas.Dock = DockStyle.Fill;
                canvas.ContextMenuStrip = contextMenuStrip1;
                canvas.CanvasItemSelected += new EventHandler<CanvasItemEventArgs>(Canvas_CanvasItemSelected);
                canvas.CanvasItemsSelected += new EventHandler<CanvasItemsEventArgs>(Canvas_CanvasItemsSelected);
                canvas.CanvasRouteSelected += new EventHandler<CanvasRouteEventArgs>(Canvas_CanvasRouteSelected);
                canvas.ItemDoubleClick += new EventHandler<CanvasItemEventArgs>(Canvas_ItemDoubleClick);
                canvas.RouteDoubleClick += new EventHandler<CanvasRouteEventArgs>(Canvas_RouteDoubleClick);
                canvas.LayoutChanged += new EventHandler(Canvas_LayoutChanged);
                canvas.SaveCurrentCanvas += new EventHandler(Canvas_SaveCurrentCanvas);
                canvas.Visible = false;

                toolStripContainer1.ContentPanel.Controls.Add(canvas);
                ModelNode.Nodes.Add(canvas.Node);
                canvas.undoStack.Clear();
                this.StoreCanvas(canvas);
            }

            toolStripContainer1.Visible = false;
            textEditorControl.Visible = false;

            if (ModelNode.Nodes.Count > 0)
            {
                TreeView_Structure.SelectedNode = ModelNode.Nodes[0];
                TreeView_Structure_NodeMouseDoubleClick(null, new TreeNodeMouseClickEventArgs(ModelNode.Nodes[0], MouseButtons.Left, 2, 0, 0));
            }
        }
Beispiel #11
0
 public void onShowModelCheckingWindow(string PNItem, PNExtendInfo extenInfo)
 {
     CurrentModule.ShowModelCheckingWindow(PNItem, extenInfo);
 }
Beispiel #12
0
        /// <summary>
        /// Generate extend information from model
        /// </summary>
        /// <param name="model"></param>
        private void generateExtendInfo(XmlElement model)
        {
            do
            {
                XmlElement topoElem = (XmlElement)model.GetElementsByTagName(XmlTag.TAG_TOPOLOGY)[0];
                if (topoElem == null)
                    break;

                if (mExtendInfo == null)
                    mExtendInfo = new PNExtendInfo();
                topoElem.SetAttribute(XmlTag.ATTR_mID, mExtendInfo.mID.ToString());
                topoElem.SetAttribute(XmlTag.ATTR_NUMOFSENSORS, mExtendInfo.mNumberSensor.ToString());
                topoElem.SetAttribute(XmlTag.ATTR_NUMOFPACKETS, mExtendInfo.mNumberPacket.ToString());
                topoElem.SetAttribute(XmlTag.ATTR_AVGBUFFER, mExtendInfo.mSensorMaxBufferSize.ToString());
                topoElem.SetAttribute(XmlTag.TAG_MODE, mExtendInfo.mMode.ToString());
                topoElem.SetAttribute(XmlTag.TAG_ABSTRACTEDLEVEL, mExtendInfo.mAbsLevel);
            } while (false);
        }
Beispiel #13
0
        /// <summary>
        /// Load extend information from Xml
        /// </summary>
        /// <param name="topoElement"></param>
        /// <returns></returns>
        private static PNExtendInfo loadExtendInfo(XmlElement topoElement)
        {
            PNExtendInfo extendInfo = null;

            do
            {
                extendInfo = new PNExtendInfo();
                String mID=topoElement.Attributes[XmlTag.ATTR_mID].Value;
                String numOfSensor = topoElement.Attributes[XmlTag.ATTR_NUMOFSENSORS].Value;
                String numOfPacket = topoElement.Attributes[XmlTag.ATTR_NUMOFPACKETS].Value;
                String avgBuffer = topoElement.Attributes[XmlTag.ATTR_AVGBUFFER].Value;
                String mode = topoElement.Attributes[XmlTag.TAG_MODE].Value;
                String absLevel = topoElement.Attributes[XmlTag.TAG_ABSTRACTEDLEVEL].Value;

                extendInfo.mID = long.Parse(mID);
                extendInfo.mNumberSensor = Int32.Parse(numOfSensor);
                extendInfo.mNumberPacket = Int32.Parse(numOfPacket);
                extendInfo.mSensorMaxBufferSize = Int32.Parse(avgBuffer);
                extendInfo.mMode = (NetMode)Enum.Parse(typeof(NetMode), mode);
                extendInfo.mAbsLevel = absLevel;
            } while (false);

            return extendInfo;
        }
Beispiel #14
0
 protected virtual ModelCheckingForm InstanciateModelCheckingForm(string tabName, PNExtendInfo extendInfo)
 {
     return(new ModelCheckingForm(tabName, Specification, extendInfo));
 }
Beispiel #15
0
 protected virtual ModelCheckingForm InstanciateModelCheckingForm(string tabName, PNExtendInfo extendInfo)
 {
     return new ModelCheckingForm(tabName, Specification, extendInfo);
 }
Beispiel #16
0
        public virtual void ShowModelCheckingWindow(String tabName, PNExtendInfo extendInfo)
        {
            if (Specification != null)
            {
                if (Specification.AssertionDatabase.Count > 0)
                {
                    if (ModelCheckingForm.ModelCheckingFormInstance != null)
                    {
                        if (
                            MessageBox.Show(Resources.Only_one_model_checking_window_can_be_open_at_a_time__Do_you_want_to_close_the_current_one_to_open_a_new_one_,
                                Common.Utility.Utilities.APPLICATION_NAME, MessageBoxButtons.YesNo,
                                MessageBoxIcon.Warning) == DialogResult.Yes)
                        {
                            ModelCheckingForm.ModelCheckingFormInstance.Close();
                        }
                        else
                        {
                            return;
                        }
                    }

                    if (ModelCheckingForm.ModelCheckingFormInstance == null)
                    {
                        ModelCheckingForm form = InstanciateModelCheckingForm(tabName, extendInfo);
                        form.Show();
                    }
                }
                else
                {
                    MessageBox.Show(Resources.Please_input_at_least_one_assertion_, Common.Utility.Utilities.APPLICATION_NAME,MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }