Ejemplo n.º 1
0
        public static void Start(string simulationID)
        {
            //Always prepare analysis.  Take snap shot of data.
            PrepareAnalysis.Simulation(simulationID);
            bool isStartNewSimulation = true;

            if (RunSimulation.Simulations.ContainsKey(simulationID))
            {
                Thread runningThread = RunSimulation.Simulations[simulationID];
                if (runningThread.IsAlive)
                {
                    isStartNewSimulation = false;
                }
                else
                {
                    RunSimulation.Simulations.Remove(simulationID);
                }
            }
            if (isStartNewSimulation)
            {
                Simulation.SimulationMessaging.ClearProgressList(simulationID);
                Simulation.Simulation simulation = new Simulation.Simulation("", "", simulationID, "1", DB.ConnectionString);
                Thread simulationThread          = new Thread(new ParameterizedThreadStart(simulation.CompileSimulation));
                RunSimulation.Simulations.Add(simulationID, simulationThread);
                simulationThread.Start(false);
            }
        }
Ejemplo n.º 2
0
        private static void Performance(SimulationStore simulation)
        {
            List <String> assets = new List <String>();

            assets.Add(simulation.Asset);
            PrepareAnalysis.Performance(simulation.SimulationID, assets);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Convert SimulationStore into necessary tables entries for RoadCare
        /// </summary>
        /// <param name="simulationID"></param>
        public static void Simulation(string simulationID)
        {
            SimulationStore             simulation = SelectScenario.GetSimulationStore(simulationID);
            OMSAssetConditionIndexStore oci        = OMS.GetAssetConditionIndex(simulation.Asset);

            PrepareAnalysis.Priorities(simulation);
            //PrepareAnalysis.TargetAndDeficients(simulation);
            PrepareAnalysis.ConditionCategoryWeights(simulation);
            //PrepareAnalysis.Performance(simulation);
            //PrepareAnalysis.RepeatedActivities(simulation);
            //PrepareAnalysis.ActivityFeasibilityCostConsequences(simulation);
            List <AttributeStore>    attributes   = PrepareAnalysis.Attributes(simulation);
            AssetRequestOMSDataStore assetRequest = new AssetRequestOMSDataStore(DateTime.Now, attributes, oci);
            Dictionary <string, AssetReplyOMSLookupTable> assetLookups = OMS.GetAssetLookupData(assetRequest);
            List <AssetReplyOMSDataStore> assets = OMS.GetAssetData(assetRequest);
            List <AssetReplyOMSDataStore> assetsWithCondition = assets.FindAll(delegate(AssetReplyOMSDataStore arods) { return(arods.ConditionIndices != null); });

            PrepareAnalysis.Assets(simulation, assetsWithCondition, attributes, assetRequest, assetLookups);
        }
Ejemplo n.º 4
0
 private static void Assets(SimulationStore simulation, List <AssetReplyOMSDataStore> assets, List <AttributeStore> attributes, AssetRequestOMSDataStore assetRequest, Dictionary <string, AssetReplyOMSLookupTable> assetLookups)
 {
     PrepareAnalysis.Assets(simulation.SimulationID, assets, attributes, assetRequest, assetLookups, true);
 }
Ejemplo n.º 5
0
        public static List <AttributeStore> InitializeRoadCareAttributes(List <String> assets, List <String> additionalAttributes)
        {
            DeleteScenario.DeleteAssets("0");
            List <AttributeStore> crossAssets = new List <AttributeStore>();

            foreach (String asset in assets)
            {
                List <AttributeStore>       attributes = new List <AttributeStore>();
                OMSAssetConditionIndexStore oci        = OMS.GetAssetConditionIndex(asset);
                for (int i = 0; i < oci.ConditionIndexes.Count; i++)
                {
                    string criteria = oci.Weights[i].Criteria;
                    if (criteria != null)
                    {
                        List <AttributeStore> ociCriteriaAttributes = OMS.ParseAttributes(asset, criteria);
                        foreach (AttributeStore attribute in ociCriteriaAttributes)
                        {
                            if (!attributes.Contains(attribute))
                            {
                                attributes.Add(attribute);
                            }
                        }
                    }
                }



                //Get additional data requested.
                List <AttributeStore> attributeAsset = OMS.GetAssetAttributes(asset);
                foreach (String additionalAttribute in additionalAttributes)
                {
                    AttributeStore additional = attributeAsset.Find(delegate(AttributeStore a) { return(a.AttributeField == additionalAttribute); });
                    if (!attributes.Contains(additional))
                    {
                        if (additional != null)
                        {
                            attributes.Add(additional);
                        }
                    }

                    AttributeStore crossAsset = crossAssets.Find(delegate(AttributeStore a) { return(a.AttributeField == additionalAttribute); });
                    if (crossAsset == null)
                    {
                        if (additional != null)
                        {
                            crossAssets.Add(additional);
                        }
                    }
                }


                AssetRequestOMSDataStore assetRequest = new AssetRequestOMSDataStore(DateTime.Now, attributes, oci);
                Dictionary <string, AssetReplyOMSLookupTable> assetLookups = OMS.GetAssetLookupData(assetRequest);
                List <AssetReplyOMSDataStore> assetsFromRequest            = OMS.GetAssetData(assetRequest);
                List <AssetReplyOMSDataStore> assetsWithCondition          = assetsFromRequest.FindAll(delegate(AssetReplyOMSDataStore arods) { return(arods.ConditionIndices != null); });

                PrepareAnalysis.Assets("0", assetsWithCondition, attributes, assetRequest, assetLookups, false);
            }

            //Do something with cross attributes.
            AttributeStore assetType = new AttributeStore(null, "AssetType", "AssetType", null);

            assetType.FieldType = "Text";
            crossAssets.Add(assetType);

            AttributeStore overallConditionIndex = new AttributeStore(null, "OverallConditionIndex", "OverallConditionIndex", null);

            overallConditionIndex.FieldType    = "Number";
            overallConditionIndex.Minimum      = 0;
            overallConditionIndex.Maximum      = 100;
            overallConditionIndex.Format       = "f1";
            overallConditionIndex.InitialValue = "100";
            overallConditionIndex.Ascending    = true;
            crossAssets.Add(overallConditionIndex);


            foreach (String asset in assets)
            {
                OMSAssetConditionIndexStore oci = OMS.GetAssetConditionIndex(asset);

                foreach (OMSConditionIndexStore ci  in oci.ConditionIndexes)
                {
                    String         conditionIndex          = "__" + ci.ConditionCategory.Replace(" ", "").Replace("/", "");
                    AttributeStore attributeConditionIndex = crossAssets.Find(delegate(AttributeStore a) { return(a.OmsObjectUserIDHierarchy == conditionIndex); });
                    if (attributeConditionIndex == null)
                    {
                        attributeConditionIndex           = new AttributeStore(null, conditionIndex, conditionIndex, null);
                        attributeConditionIndex.FieldType = "Number";
                        crossAssets.Add(attributeConditionIndex);
                    }
                }
            }
            return(crossAssets);
        }