예제 #1
0
        //public static string FindMemberFromAka(Type t, string aka)
        //{
        //    foreach (MemberInfo memberInfo in t.GetMembers())
        //    {
        //        if (AkaAttribute.FindAka(memberInfo).ToLower() == aka.ToLower())
        //            return memberInfo.Name;
        //    }
        //    return null;
        //}

        public static void AssignTimeSeries(RiverSystemScenario scenario, object target, string element,
                                            string dataGroupName, string dataItem, int column = 0)
        {
            var ri = GetReflectedItem(target, element);

            var dm = scenario.Network.DataManager;

            dm.RemoveUsage(ri);

            var dataGroup = dm.DataGroups.Where(dg => dg.Name == dataGroupName).FirstOrDefault();

            if (dataGroup == null)
            {
                dataGroup      = DataGroupItem.CreateGroup <GeneratedCentralDataSource>(scenario.Network.DefaultInputSet);
                dataGroup.Name = dataGroupName;
                dm.DataGroups.Add(dataGroup);
            }

            var dataGroupItem = dataGroup.DataDetails.Where(dgi => dgi.Name == dataItem).FirstOrDefault();

            if (dataGroupItem == null)
            {
                Data[]     loaded = NonInteractiveIO.Load(dataItem);
                TimeSeries ts     = loaded[column] as TimeSeries;
                ts.name = dataItem;
                dataGroup.CreateUsage <GeneratedDataDetails>(ri, ts);
            }
            else
            {
                dataGroupItem.Usages.Add(new DataUsage {
                    ReflectedItem = ri
                });
            }
        }
예제 #2
0
        public DataGroupItem AddToScenario(RiverSystemScenario scenario)
        {
            var dm            = scenario.Network.DataManager;
            var asFile        = Items.All(i => i.DetailsAsCSV == null);
            var dataGroupType = asFile
                ? typeof(FileCentralDataSource)
                : typeof(GeneratedCentralDataSource);

            var dataGroup = DataGroupItem.CreateGroup(dataGroupType, scenario.Network.InputSets);

            dataGroup.Name = Name;
            if (asFile)
            {
                dataGroup.InputSetItems.ForEachItem(i =>
                {
                    FileCentralDataSource ds = i.DataSource.SourceInformation as FileCentralDataSource;
                    ds.Filename = Name;
                });
            }

            dm.DataGroups.Add(dataGroup);

            if (Items == null)
            {
                return(dataGroup);
            }

            for (int i = 0; i < Items.Length; i++)
            {
                var item = Items[i];
                item.AddToGroup(scenario, dataGroup, i);
            }
            return(dataGroup);
        }