private static void PrintNuSMV(SMVModel nuSMV, KpMetaModel kpMetaModel, Experiment kpx, string outFileName)
        {
            //instantiate output file, otherwise to console
            Writer.FileName = outFileName;
            Writer.CleanFile(outFileName);
            bool firstModule = true;

            foreach (var module in nuSMV.Modules)
            {
                if (!firstModule)
                {
                    TUtil.AddDashedComment(module.Type.ToUpper());
                }
                WriteModule(module);
                WriteVariables(module);
                WriteINVAR(module);
                WriteInit(module);
                if (!module.HasDivisionRule && module.HasDissolutionRule)
                {
                    WriteStatusNext(module);
                }

                WriteNext(module);

                firstModule = false;
            }
            WriteMain(nuSMV);
            WriteStatusAndCommuncationNext(nuSMV);
            WriteProperties(kpx, kpMetaModel);
        }
        private static void WriteProperties(Experiment kpx, KpMetaModel kpMetaModel)
        {
            if (kpx != null)
            {
                if (kpx.LtlProperties != null && kpx.LtlProperties.Count() > 0)
                {
                    Writer.WriteLine("-- LTL Properties");
                    foreach (var ltlProperty in kpx.LtlProperties)
                    {
                        Writer.WriteLine(string.Format("LTLSPEC {0}", PropertyTranslationManager.Instance.Translate(ltlProperty, kpMetaModel, ModelCheckingTarget.NuSmv)));
                    }

                    Writer.Write(Environment.NewLine);
                }

                if (kpx.CtlProperties != null && kpx.CtlProperties.Count() > 0)
                {
                    Writer.WriteLine("-- CTL Properties");
                    foreach (var ctlProperty in kpx.CtlProperties)
                    {
                        Writer.WriteLine(string.Format("SPEC {0}", PropertyTranslationManager.Instance.Translate(ctlProperty, kpMetaModel, ModelCheckingTarget.NuSmv)));
                    }
                }
            }
        }
        public static void Translate(KpCore.KpModel kpModel, Experiment kpx, string outFileName)
        {
            KPsystem    kpSystem    = kpModel.KPsystem;
            KpMetaModel kpMetaModel = new KpMetaModel(kpSystem);

            try
            {
                //Translate KP model to SMV model
                SMVModel nuSMV = BNuSMV.buildModel(kpSystem);

                //SMVModels are loaded, in first run write variable to XML files, in 2nd run these values can be read.
                foreach (var module in nuSMV.Modules)
                {
                    BVariables.writeBounds2XML(module);
                }

                //Generate SMV file
                if (nuSMV != null)
                {
                    PrintNuSMV(nuSMV, kpMetaModel, kpx, outFileName);
                }
                else
                {
                    throw new Exception("NuSMV translation failed.");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception occurred during NuSMV translation.");
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                throw ex;
            }
        }
Example #4
0
        public string Translate(ICtlProperty ctlProperty, KpMetaModel kpMetaModel, ModelCheckingTarget target)
        {
            var propertyTranslator = default(ICtlPropertyTranslator);

            switch (target)
            {
            case ModelCheckingTarget.NuSmv: propertyTranslator = new NuSmvCtlTranslator(kpMetaModel); break;
            }

            return(ctlProperty.Accept(propertyTranslator));
        }
Example #5
0
 public NuSmvCtlTranslator(KpMetaModel kpMetaModel)
 {
     _kpMetaModel = kpMetaModel;
 }
 public PromelaLtlTranslator(KpMetaModel kpMetaModel)
 {
     _kpMetaModel = kpMetaModel;
 }