Пример #1
0
        public CRF_Network BuildNetwork(string State)
        {
            CRF_Network TheNetwork = null;

            if (FDataLoaded)
            {
                // build resources list
                CRF_ResourceList ResList = new CRF_ResourceList();
                for (int i = 0; i < ResourceList.Length; i++)
                {
                    int          Value   = GetValue(State, ResourceList[i]);
                    CRF_Resource TempRes = new CRF_Resource(ResourceList[i], ResourceListLabel[i], ResColors[i], Value);
                    ResList.Add(TempRes);
                }
                // Build Consumer List
                CRF_ConsumerList ConsList = new CRF_ConsumerList();
                for (int i = 0; i < ConsumerList.Length; i++)
                {
                    int          Value    = GetValue(State, ConsumerList[i]);
                    CRF_Consumer TempCons = new CRF_Consumer(ConsumerList[i], ConsumerListLabel[i], ConsColors[i], Value);
                    ConsList.Add(TempCons);
                }
                // Ok now the hard part, add fluxes
                // Go through each of the resources
                foreach (CRF_Resource Res in ResList)
                {
                    // go through each of the SDResourceConsumerLinks looking for a match
                    foreach (SDResourceConsumerLink RCL in FFluxes)
                    {
                        // found one
                        if (Res.Name == RCL.Resource)
                        {
                            // lookin for a match consumer
                            foreach (CRF_Consumer Cons in ConsList)
                            {
                                // found it. add this flux
                                if (RCL.Consumer == Cons.Name)
                                {
                                    int Value = GetValue(State, RCL.Flux);
                                    Res.AddConsumer(Cons, Value, CRF_Flux.Method.amAbsolute);
                                }
                            }
                        }
                    }
                }
                TheNetwork = new CRF_Network("WaterSim " + State, ResList, ConsList, null);
            }
            return(TheNetwork);
        }