//获取自己的签到信息
        #region 获取默认(本人)签到信息
        public JsonResult Sign_json(string text)
        {
            int UID = int.Parse(LoginBase.ID);

            List <Sign_dateModel> JsonData = ISIS.Get_data(UID, 1);//1web 2考勤机

            return(Json(ISIS.Obj2Json(JsonData), JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public static List<CyPhy.JoinData> TransformJoinData(iFAB.assemblyDetail ad, ISIS.GME.Common.Interfaces.Container parent)
        {
            var rtn = new List<CyPhy.JoinData>();

            foreach (var join in ad.Items)
            {
                CyPhy.JoinData jd = null;
                if (join is welded)
                {
                    var w = join as welded;
                	if (parent is CyPhy.Connector)
                    	jd = CyPhyClasses.WeldedJoin.Create(parent as CyPhy.Connector);
                	else
                    	jd = CyPhyClasses.WeldedJoin.CreateGeneric(parent) as CyPhy.WeldedJoin;
                }
                else if (join is brazed)
                {
                    var w = join as brazed;
                	if (parent is CyPhy.Connector)
                    	jd = CyPhyClasses.BrazedJoin.Create(parent as CyPhy.Connector);
                	else
                    	jd = CyPhyClasses.BrazedJoin.CreateGeneric(parent) as CyPhy.BrazedJoin;
                }
                else if (join is soldered)
                {
                    var w = join as soldered;
                	if (parent is CyPhy.Connector)
                    	jd = CyPhyClasses.SolderedJoin.Create(parent as CyPhy.Connector);
                	else
                    	jd = CyPhyClasses.SolderedJoin.CreateGeneric(parent) as CyPhy.SolderedJoin;
                }
                else if (join is glued)
                {
                    var w = join as glued;
                	if (parent is CyPhy.Connector)
                    	jd = CyPhyClasses.GluedJoin.Create(parent as CyPhy.Connector);
                	else
                    	jd = CyPhyClasses.GluedJoin.CreateGeneric(parent) as CyPhy.GluedJoin;
                }
                else if (join is mechanical)
                {
                    var w = join as mechanical;
                	if (parent is CyPhy.Connector)
                    	jd = CyPhyClasses.MechanicalJoin.Create(parent as CyPhy.Connector);
                	else
                    	jd = CyPhyClasses.MechanicalJoin.CreateGeneric(parent) as CyPhy.MechanicalJoin;
                }
                else
                    continue;

                jd.Attributes.Description = ad.id;
                rtn.Add(jd);
            }

            return rtn;
        }
        //查看其它用户签到情况
        #region 获取用户签到信息(限学生)
        public JsonResult changeuser(string text)
        {
            int UID  = int.Parse(Request.Form[0].ToString());
            int type = int.Parse(Request.Form[1].ToString());


            List <Sign_dateModel> JsonData = ISIS.Get_data(UID, type);

            return(Json(ISIS.Obj2Json(JsonData), JsonRequestBehavior.AllowGet));
        }
        private static void SetCoordinates(ISIS.GME.Common.Interfaces.FCO fco, String s_Coord)
        {
            string[] sa_coords = s_Coord.Split(',');
            int x = int.Parse(sa_coords[0]);
            int y = int.Parse(sa_coords[1]);

            foreach (IMgaPart part in (fco.Impl as IMgaFCO).Parts)
            {
                part.SetGmeAttrs(null, x, y);
            }
        }
        public IISIS Create()
        {
            var toReturn = new ISIS
            {
                Options = new Options
                {
                    PressureAltitudeUnits = (PressureUnits)Enum.Parse(typeof(PressureUnits), Settings.Default.ISIS_PressureUnits),
                }
            };

            return(toReturn);
        }
        public JsonResult User_Sign(string text)
        {
            int UID = int.Parse(LoginBase.ID);
            //
            //IP属性目前没有加,等待后续更改
            //
            //string IP = LoginBase.IP;
            string IP   = "";
            bool   flag = ISIS.userSign(UID, IP);

            return(Json(flag, JsonRequestBehavior.AllowGet));
        }
        public JsonResult Is_Sign(string text)
        {
            //不可签到时间段
            string   _Day1      = "11:30";
            string   Day1       = "12:30";
            string   _Day2      = "17:30";
            string   Day2       = "18:00";
            string   _Day3      = "20:30";
            string   Day3       = "22:00";
            TimeSpan _Day1_time = DateTime.Parse(_Day1).TimeOfDay;
            TimeSpan Day1_time  = DateTime.Parse(Day1).TimeOfDay;
            TimeSpan _Day2_time = DateTime.Parse(_Day2).TimeOfDay;
            TimeSpan Day2_time  = DateTime.Parse(Day2).TimeOfDay;
            TimeSpan _Day3_time = DateTime.Parse(_Day3).TimeOfDay;
            TimeSpan Day3_time  = DateTime.Parse(Day3).TimeOfDay;
            DateTime t1         = DateTime.Now;
            TimeSpan dspNow     = t1.TimeOfDay;
            //if ((dspNow > _Day1_time && dspNow < Day1_time) || (dspNow > _Day2_time && dspNow < Day2_time) || (dspNow > _Day3_time && dspNow < Day3_time))//不可签到
            //{
            //    return Json("错误时间", JsonRequestBehavior.AllowGet);
            //}

            int UID = 1;

            try
            {
                UID = int.Parse(LoginBase.ID);

                bool IsSign = ISIS.Is_Sign_In(UID);

                if (IsSign)
                {
                    return(Json("true", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json("false", JsonRequestBehavior.AllowGet));
                }
            }
            catch
            {
                return(Json("false", JsonRequestBehavior.AllowGet));;
            }
        }
            public void Increment(ISIS.GME.Common.Interfaces.FCO fco)
            {
                if (fco is CyPhy.ValueFlowTarget)
                {
                    int i_CharsOver10 = Math.Max(fco.Name.Length - 12, 12);
                    int i_XOffset = 160 + (i_CharsOver10 * 10);
                    i_x += i_XOffset;
                }
                else if (fco is CyPhy.Connector)
                    i_x += 250;
                else if (fco is CyPhy.Port)
                    i_x += 100;
                else if (fco is CyPhy.ModelicaConnector)
                    i_x += 250;
                else
                    i_x += 250;

                if (i_x > i_MaxX)
                    NextLine();
            }
Beispiel #9
0
        /// <summary>
        /// 获取值日信息
        /// </summary>
        /// <returns></returns>
        public JsonResult GetDutyData()
        {
            //List<DutyNeedDto>
            List <DutyDto>     DutyList   = DutyData.GetDuty();
            List <DutyNeedDto> returnList = new List <DutyNeedDto>();

            foreach (DutyDto ss in DutyList)
            {
                DutyNeedDto DutyNeedData = new DutyNeedDto();
                int         userId       = ss.User_ID;
                ss.DutyEnd = ss.DutyEnd.AddDays(1);
                List <UserDto> UserList = UserData.GetUser(userId);
                DutyNeedData.title = UserList[0].Real_Name;
                DutyNeedData.start = ss.DutyStart.ToString("yyyy-MM-dd");
                DutyNeedData.end   = ss.DutyEnd.ToString("yyyy-MM-dd");

                //DutyNeedData.Url = ss.Url;
                returnList.Add(DutyNeedData);
            }

            return(Json(ISIS.Obj2Json(returnList), JsonRequestBehavior.AllowGet));
        }
 private CyPhy.KinematicJoint GetJoint(ISIS.GME.Dsml.CyPhyML.Interfaces.Connector conn)
 {
     return conn.Children.KinematicJointCollection.FirstOrDefault();
 }
 public CyPhy.Parameter Create(ISIS.GME.Common.Interfaces.Container container)
 {
     CyPhy.Parameter result = ISIS.GME.Common.Utils.CreateObject<ISIS.GME.Dsml.CyPhyML.Classes.Parameter>(container, "" + ISIS.GME.Dsml.CyPhyML.Classes.Parameter.DefaultRole.Parameter.ToString());
     result.Name = Name;
     result.Attributes.Value = DefaultValue;
     result.Attributes.DataType = Type;
     return result;
 }
 private bool portHasCorrectParentType(ISIS.GME.Common.Interfaces.FCO port)
 {
     ISIS.GME.Common.Interfaces.Container parent = port.ParentContainer;
     Type parentType = parent.GetType();
     return this.SchematicModelType.IsAssignableFrom(parentType);
 }
 private MgaFCO CreateChild(ISIS.GME.Common.Interfaces.Model parent, Type type)
 {
     var role = ((MgaMetaModel)parent.Impl.MetaBase).RoleByName[type.Name];
     return (MgaFCO)((MgaModel)parent.Impl).CreateChildObject(role);
 }
        public string LoadDataFromExcel(string Path)
        {
            string success_name = null;

            string          strConn = "Provider=Microsoft.Ace.OleDb.12.0;" + "data source=" + Path + ";Extended Properties='Excel 12.0; HDR=Yes; IMEX=1'";
            OleDbConnection conn    = new OleDbConnection(strConn);

            conn.Open();

            //获取成员信息;
            DataTable dt1 = new DataTable();

            dt1 = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
            if (dt1 == null)
            {
                return(null);
            }
            String[] excelSheets = new String[dt1.Rows.Count];
            int      i           = 0;

            // 加入工作表名称到字符串数组
            foreach (DataRow row in dt1.Rows)
            {
                string strSheetTableName = row["TABLE_NAME"].ToString();
                //过滤无效SheetName
                if (strSheetTableName.Contains("$") && strSheetTableName.Replace("'", "").EndsWith("$"))
                {
                    excelSheets[i] = strSheetTableName.Substring(0, strSheetTableName.Length - 1);
                }
                i++;
            }

            string           strExcel  = "";
            OleDbDataAdapter myCommand = null;
            DataTable        dt        = null;

            for (i = 0; i < dt1.Rows.Count; i++)
            {
                try
                {
                    strExcel  = "select * from [" + excelSheets[i] + "$]";
                    myCommand = new OleDbDataAdapter(strExcel, strConn);
                    dt        = new DataTable();
                    myCommand.Fill(dt);

                    string month = dt.Rows[0][16].ToString();
                    string name  = excelSheets[i].Split('_')[0].ToString();
                    int    uid   = IUDS.get_uid(name);
                    for (int j = 1; j <= 16; j++)//前16天
                    {
                        string day_table = dt.Rows[j + 7][0].ToString().Split(' ')[0];
                        string day       = month + "-" + day_table + " ";
                        string time_1    = dt.Rows[j + 7][1].ToString();
                        if (time_1 != null && time_1 != "")
                        {
                            string time = day + time_1;
                            ISIS.Ecxel_add(time, uid);
                        }
                        string time_2 = dt.Rows[j + 7][3].ToString();
                        if (time_2 != null && time_2 != "")
                        {
                            string time = day + time_2;
                            ISIS.Ecxel_add(time, uid);
                        }
                        string time_3 = dt.Rows[j + 7][5].ToString();
                        if (time_3 != null && time_3 != "")
                        {
                            string time = day + time_3;
                            ISIS.Ecxel_add(time, uid);
                        }
                    }
                    for (int j = 17; j <= 31; j++)//后16天
                    {
                        string day_table = dt.Rows[j - 9][9].ToString().Split(' ')[0];
                        string day       = month + "-" + day_table + " ";
                        string time_1    = dt.Rows[j - 9][10].ToString();
                        if (time_1 != null && time_1 != "")
                        {
                            string time = day + time_1;
                            ISIS.Ecxel_add(time, uid);
                        }
                        string time_2 = dt.Rows[j - 9][12].ToString();
                        if (time_2 != null && time_2 != "")
                        {
                            string time = day + time_2;
                            ISIS.Ecxel_add(time, uid);
                        }
                        string time_3 = dt.Rows[j - 9][14].ToString();
                        if (time_3 != null && time_3 != "")
                        {
                            string time = day + time_3;
                            ISIS.Ecxel_add(time, uid);
                        }
                    }

                    if (success_name != null)
                    {
                        success_name += "," + name;
                    }
                    else
                    {
                        success_name += name;
                    }
                }//try
                catch { }
            }
            return(success_name);
        }
 public static CyPhyML.Component FindAVMComponent(MgaProject project, string avmid, ISIS.GME.Dsml.CyPhyML.Interfaces.Components root)
 {
     if (root == null)
     {
         var rf = CyPhyMLClasses.RootFolder.GetRootFolder(project);
         foreach (var components in rf.Children.ComponentsCollection)
         {
             CyPhyML.Component comp = FindAVMComponent(project, avmid, components);
             if (comp != null)
                 return comp;
         }
     }
     else
     {
         foreach (var components in root.Children.ComponentsCollection)
         {
             CyPhyML.Component comp = FindAVMComponent(project, avmid, components);
             if (comp != null)
                 return comp;
         }
         foreach (var component in root.Children.ComponentCollection)
         {
             if (component.Attributes.AVMID == avmid)
                 return component;
         }
     }
     return null;
 }
        private void HighlightInTree(ISIS.GME.Common.Interfaces.Base item, int highlight)
        {
            if (TestMode)
            {
                return;
            }

            HighlightInTree(item.Impl, highlight);
        }
 public void HighlightInTree(ISIS.GME.Common.Interfaces.Base item, int highlight)
 {
     if (TestMode) return;
     HighlightInTree(item.Impl, highlight);
 }
        public static TestBench Convert(ISIS.GME.Dsml.CyPhyML.Interfaces.TestBench tb)
        {
            if (tb == null)
                throw new ArgumentNullException("tb");

            // TODO: Generate ID
            //var componentConnectorTargetMapping = new Dictionary<CyPhy.Connector, ComponentConnectorInstance>();
            var componentConnectorTargetMapping = new Dictionary<CyPhy.Connector, object>();
            
            //var componentValueflowTargetMapping = new Dictionary<CyPhy.ValueFlowTarget, ContainerPrimitivePropertyInstance>();
            // Note: its is object because it contains: ContainerPrimitivePropertyInstance AND ComponentPrimitivePropertyInstance (TestComponent)
            var componentValueflowTargetMapping = new Dictionary<CyPhy.ValueFlowTarget, object>();
            
            var vftIdCache = new Dictionary<CyPhy.ValueFlowTarget, String>();

            var avmTestBench = new TestBench { Name = tb.Name };

            #region Process ComponentAssembly | DesignContainer

            var systemUnderTest = tb.Children.TopLevelSystemUnderTestCollection.FirstOrDefault();
            if (systemUnderTest != null && systemUnderTest.Referred != null)
            {
                var wrapper = new TestBenchPrimitiveWrapper(systemUnderTest.AllReferred);
                if (wrapper.Primitive != null)
                {
                    var avmTopLevelSystemUnderTest = new TopLevelSystemUnderTest()
                    {
                        // Note: DesignContainers have no ConfigurationUniqueID
                        DesignID = wrapper.ConfigurationUniqueID,

                        // TODO: Check if null
                        IDinSourceModel = wrapper.ID.ToString()
                    };

                    SetLayoutData(avmTopLevelSystemUnderTest, systemUnderTest.Impl);

                    #region Process TopLevelSystemUnderTest parameters

                    foreach (var parameter in wrapper.ParameterCollection)
                    {
                        DataTypeEnum xDataType;
                        if (!ConvertCyPhyDataTypeEnum(parameter.Attributes.DataType, out xDataType)) continue;
                        /*
                        var avmPrimitivePropertyInstance = new ContainerPrimitivePropertyInstance()
                        {
                            IDinSourceModel = parameter.Attributes.ID.ToString(),
                            Value = new Value
                                {
                                    DataType = xDataType,
                                    DataTypeSpecified = true,
                                    DimensionType = DimensionTypeEnum.Scalar,
                                    DimensionTypeSpecified = true,
                                    Dimensions = parameter.Attributes.Dimension,
                                    ID = Guid.NewGuid().ToString("D"),
                                    //parameter.Guid.ToString("D")
                                }
                        };

                        //SetLayoutData(avmPrimitivePropertyInstance, parameter.Impl);

                        componentValueflowTargetMapping[parameter] = avmPrimitivePropertyInstance;
                        vftIdCache[parameter] = avmPrimitivePropertyInstance.Value.ID;
                        avmTopLevelSystemUnderTest.PropertyInstance.Add(avmPrimitivePropertyInstance);
                        */
                    }

                    #endregion

                    #region Process TopLevelSystemUnderTest properties

                    foreach (var property in wrapper.PropertyCollection)
                    {
                        DataTypeEnum xDataType;
                        if (!ConvertCyPhyDataTypeEnum(property.Attributes.DataType, out xDataType)) continue;
                        /*
                        var avmPrimitivePropertyInstance = new ContainerPrimitivePropertyInstance()
                        {
                            IDinSourceModel = property.Attributes.ID.ToString(),
                            Value = new Value
                            {
                                DataType = xDataType,
                                DataTypeSpecified = true,
                                DimensionType = DimensionTypeEnum.Scalar,
                                DimensionTypeSpecified = true,
                                Dimensions = property.Attributes.Dimension,
                                ID = Guid.NewGuid().ToString("D"), //property.Guid.ToString("D")
                            }
                        };

                        //SetLayoutData(avmPrimitivePropertyInstance, property.Impl);

                        avmTopLevelSystemUnderTest.PropertyInstance.Add(avmPrimitivePropertyInstance);
                        componentValueflowTargetMapping[property] = avmPrimitivePropertyInstance;
                        vftIdCache[property] = avmPrimitivePropertyInstance.Value.ID;
                        */
                    }

                    #endregion

                    #region Process TopLevelSystemUnderTest ModelicaConnector

                    
                    foreach (var mc in wrapper.ModelicaConnectorCollection)
                    {
                        /*
                        var avmPortInstance = new ContainerPortInstance
                        {
                            ID = string.IsNullOrEmpty(mc.Attributes.ID) ? GetOrSetID(mc) : mc.Attributes.ID,
                            NameInSourceModel = mc.Name,
                        };

                        modelicaConnectorCache[mc] = avmPortInstance;
                        avmTopLevelSystemUnderTest.PortInstance.Add(avmPortInstance);
                         */
                    }

                    #endregion

                    // TODO: Temprary solution for Zsolt no difference between ModelicaConnector and Connector in the atm file.
                    // => Impossible to import
                    #region Process TopLevelSystemUnderTest Connectors

                    foreach (var cc in wrapper.ConnectorCollection)
                    {
                        // Now it is ContainerPortInstance => Should be changed in the future.
                        /*
                        var avmPortInstance = new ContainerPortInstance
                        {
                            ID = EnsureComponentIdAttribute(cc),
                            NameInSourceModel = cc.Name,
                        };

                        componentConnectorTargetMapping[cc] = avmPortInstance;
                        avmTopLevelSystemUnderTest.PortInstance.Add(avmPortInstance);
                        */
                    }

                    #endregion

                    avmTestBench.TopLevelSystemUnderTest = avmTopLevelSystemUnderTest;

                   
                }
            }
            

            #endregion

            #region Process TestComponents

            foreach (var testComponent in tb.Children.TestComponentCollection)
            {
                var avmComponentInstance = new avm.ComponentInstance()
                {
                    Name = testComponent.Name,
                    ID = EnsureComponentIdAttribute(testComponent).ToString(),
                    ComponentID = testComponent.Guid.ToString("D")
                };

                #region Component connectors

                foreach (var connector in testComponent.Children.ConnectorCollection)
                {
                    var connectorId = EnsureComponentIdAttribute(connector);
                    var avmComponentConnectorInstance = new avm.ComponentConnectorInstance
                    {
                        IDinComponentModel = connector.Attributes.ID,
                        ID = avmComponentInstance.ID + '-' + connectorId,
                    };

                    avmComponentInstance.ConnectorInstance.Add(avmComponentConnectorInstance);

                    if (!componentConnectorTargetMapping.ContainsKey(connector))
                        componentConnectorTargetMapping[connector] = avmComponentConnectorInstance;
                }

                #endregion

                #region Process testComponent parameters

                foreach (var parameter in testComponent.Children.ParameterCollection)
                {
                    DataTypeEnum xDataType;
                    if (!ConvertCyPhyDataTypeEnum(parameter.Attributes.DataType, out xDataType)) continue;

                    var avmPrimitivePropertyInstance = new ComponentPrimitivePropertyInstance()
                    {
                        IDinComponentModel = parameter.Attributes.ID.ToString(),
                        Value = new Value
                        {
                            DataType = xDataType,
                            DataTypeSpecified = true,
                            DimensionType = DimensionTypeEnum.Scalar,
                            DimensionTypeSpecified = true,
                            Dimensions = parameter.Attributes.Dimension,
                            ID = Guid.NewGuid().ToString("D"),
                            //parameter.Guid.ToString("D")
                        }
                    };

                    //SetLayoutData(avmPrimitivePropertyInstance, parameter.Impl);

                    componentValueflowTargetMapping[parameter] = avmPrimitivePropertyInstance;
                    vftIdCache[parameter] = avmPrimitivePropertyInstance.Value.ID;
                    avmComponentInstance.PrimitivePropertyInstance.Add(avmPrimitivePropertyInstance);
                }

                #endregion

                #region Process testComponent properties

                foreach (var property in testComponent.Children.PropertyCollection)
                {
                    DataTypeEnum xDataType;
                    if (!ConvertCyPhyDataTypeEnum(property.Attributes.DataType, out xDataType)) continue;

                    var avmPrimitivePropertyInstance = new ComponentPrimitivePropertyInstance()
                    {
                        IDinComponentModel = property.Attributes.ID.ToString(),
                        Value = new Value
                        {
                            DataType = xDataType,
                            DataTypeSpecified = true,
                            DimensionType = DimensionTypeEnum.Scalar,
                            DimensionTypeSpecified = true,
                            Dimensions = property.Attributes.Dimension,
                            ID = Guid.NewGuid().ToString("D"), //property.Guid.ToString("D")
                        }
                    };

                    //SetLayoutData(avmPrimitivePropertyInstance, property.Impl);

                    avmComponentInstance.PrimitivePropertyInstance.Add(avmPrimitivePropertyInstance);
                    componentValueflowTargetMapping[property] = avmPrimitivePropertyInstance;
                    vftIdCache[property] = avmPrimitivePropertyInstance.Value.ID;
                }

                #endregion

                SetLayoutData(avmComponentInstance, testComponent.Impl);
                avmTestBench.TestComponent.Add(avmComponentInstance);
            }

            // TODO: not use dynamic, it is just a walkaround while Adam is on vacation
            #region Process ConnectorCompositions

            foreach (var cc in tb.Children.ConnectorCompositionCollection)
            {
                var src = cc.SrcEnds.Connector;
                var dst = cc.DstEnds.Connector;

                if (src != null && dst != null)
                {
                    dynamic avmSrc;
                    dynamic avmDst;
                    if (componentConnectorTargetMapping.ContainsKey(src) && componentConnectorTargetMapping.ContainsKey(dst))
                    {
                        avmSrc = componentConnectorTargetMapping[src];
                        avmDst = componentConnectorTargetMapping[dst];

                        try
                        {
                            avmSrc.ConnectorComposition.Add(avmDst.ID);
                        }
                        catch (RuntimeBinderException e)
                        {
                            avmSrc.PortMap.Add(avmDst.ID);
                        }
                    }
                }
            }

            #endregion

            #endregion

            #region Process Testbench parameters

            foreach (var parameter in tb.Children.ParameterCollection)
            {
                DataTypeEnum xDataType;
                if (!ConvertCyPhyDataTypeEnum(parameter.Attributes.DataType, out xDataType)) continue;

                var avmParameter = new Parameter
                {
                    ID = parameter.Attributes.ID,
                    Name = parameter.Name,
                    Notes = parameter.Attributes.Description,
                    Value = new Value
                    {
                        DataType = xDataType,
                        DataTypeSpecified = true,
                        DimensionType = DimensionTypeEnum.Scalar,
                        DimensionTypeSpecified = true,
                        Dimensions = parameter.Attributes.Dimension,
                        ID = Guid.NewGuid().ToString("D"),
                        //parameter.Guid.ToString("D")
                    }
                };

                SetLayoutData(avmParameter, parameter.Impl);

                #region Set value expressions / Derived values

                if (parameter.SrcConnections.ValueFlowCollection.Any())
                {
                    var vft = parameter.SrcConnections.ValueFlowCollection.First().SrcEnds.ValueFlowTarget;

                    String idVft = null;
                    // ContainerPrimitivePropertyInstance cppi = null;
                    dynamic cppi;
                    if (componentValueflowTargetMapping.TryGetValue(vft, out cppi))
                    {
                        idVft = cppi.Value.ID;
                    }
                    else
                    {
                        //idVft = GetOrSetID(vft);
                    }

                    avmParameter.Value.ValueExpression = new DerivedValue { ValueSource = idVft };
                }
                else
                {
                    // FixedValue or ParametricValue????
                    //var avmFixedValue = new FixedValue() {
                    //    Value = parameter.Attributes.Value
                    //};

                    var rangeParts = (parameter.Attributes.Range == null || !parameter.Attributes.Range.Contains("..")) ?
                                      new[] { "", "" } :
                                      parameter.Attributes.Range.Split(new[] { ".." }, StringSplitOptions.RemoveEmptyEntries);

                    if (rangeParts.Count() != 2) rangeParts = new[] { "", "" };

                    var avmParametricValue = new ParametricValue
                    {
                        AssignedValue = new FixedValue { Value = parameter.Attributes.Value },
                        Default = new FixedValue { Value = parameter.Attributes.DefaultValue },
                        Maximum = new FixedValue { Value = rangeParts[1] },
                        Minimum = new FixedValue { Value = rangeParts[0] },
                    };

                    avmParameter.Value.ValueExpression = avmParametricValue;
                    vftIdCache[parameter] = avmParameter.Value.ID;
                }

                #endregion

                avmTestBench.Parameter.Add(avmParameter);
            }

            #endregion

            #region Process Testbench metrics

            foreach (var metric in tb.Children.MetricCollection)
            {
                var avmMetric = new Metric
                {
                    Name = metric.Name,
                    Notes = metric.Attributes.Description
                };

                SetLayoutData(avmMetric, metric.Impl);

                #region Derived values

                // Metric is derived only
                if (metric.SrcConnections.ValueFlowCollection.Any())
                {
                    var vft = metric.SrcConnections.ValueFlowCollection.First().SrcEnds.ValueFlowTarget;

                    String idVft = null;
                    // ContainerPrimitivePropertyInstance cppi = null;
                    dynamic cppi;
                    if (componentValueflowTargetMapping.TryGetValue(vft, out cppi))
                    {
                        idVft = cppi.Value.ID;
                    }
                    else
                    {
                        //idVft = GetOrSetID(vft);
                    }

                    avmMetric.Value.ValueExpression = new DerivedValue { ValueSource = idVft };
                }

                #endregion

                avmTestBench.Metric.Add(avmMetric);
            }

            #endregion

            #region Process Testbench Environments (modelica models)

            foreach (var env in tb.Children.EnvironmentCollection)
            {
                var avmModelicaModel = new avm.modelica.ModelicaModel
                {
                    Name = env.Name,
                    Author = env.Attributes.Author,
                    Class = env.Attributes.Class,
                    Notes = env.Attributes.Notes,
                    UsesResource = env.Attributes.FilePathWithinResource,
                };

                #region Process modelica connectors

                foreach (var mc in env.Children.ModelicaConnectorCollection)
                {
                    var avmModelicaConnector = new avm.modelica.Connector
                    {
                        Name = mc.Name,
                        Class = mc.Attributes.Class,
                        Definition = mc.Attributes.Definition,
                        Notes = mc.Attributes.DefinitionNotes,
                        ID = string.IsNullOrEmpty(mc.Attributes.ID) ? GetOrSetID(mc) : mc.Attributes.ID,
                        //= mc.Attributes.InstanceNotes,
                        Locator = mc.Attributes.Locator,
                    };

                    avmModelicaModel.Connector.Add(avmModelicaConnector);
                    SetLayoutData(avmModelicaConnector, mc.Impl);
                }

                #endregion

                avmTestBench.TestStructure.Add(avmModelicaModel);
                SetLayoutData(avmModelicaModel, env.Impl);
            }

            #endregion

            #region Process Valueflows/set valueexpressions

            // Note: dynamic because of the Testcomponent Properties/Parameters
            foreach (var vf in tb.Children.ValueFlowCollection)
            {
                var srcValueFlow = vf.SrcEnds.ValueFlowTarget;
                var dstValueFlow = vf.DstEnds.ValueFlowTarget;

                if (componentValueflowTargetMapping.ContainsKey(dstValueFlow))
                {
                    dynamic dstPair = componentValueflowTargetMapping[dstValueFlow];
                    dstPair.Value.ValueExpression = new avm.DerivedValue
                    {
                        ValueSource = vftIdCache[srcValueFlow]
                    };
                }
            }

            #endregion

            #region Process PortCompositions

            foreach (var pc in tb.Children.PortCompositionCollection)
            {
                var src = pc.SrcEnds.ModelicaConnector;
                var dst = pc.DstEnds.ModelicaConnector;
                /*
                if (src != null & dst != null)
                {
                    ContainerPortInstance avmSrc;
                    ContainerPortInstance avmDst;
                    if (modelicaConnectorCache.ContainsKey(src))
                    {
                        avmSrc = modelicaConnectorCache[src];
                        avmSrc.PortMap.Add(dst.Attributes.ID);
                    }
                    else if (modelicaConnectorCache.ContainsKey(dst))
                    {
                        avmDst = modelicaConnectorCache[dst];
                        avmDst.PortMap.Add(src.Attributes.ID);
                    }
                }
                */
            }

            #endregion

            #region Process Workflows

            var workflowRef = tb.Children.WorkflowRefCollection.FirstOrDefault();

            if (workflowRef != null)
            {
                var referred = workflowRef.Referred;
                if (referred != null && referred!=null)
                {
                    var workflow = referred.Workflow;

                    var avmWorkflow = new Workflow
                    {
                        Name = workflow.Name,
                    };

                    avmTestBench.Workflow = avmWorkflow;
                    SetLayoutData(avmWorkflow, workflowRef.Impl);

                    var allTasks = workflow.Children.TaskBaseCollection.ToList();

                    // Get the first task
                    var currentTask = allTasks.FirstOrDefault(x => !x.SrcConnections.FlowCollection.Any());
                    if (currentTask != null)
                    {
                        do
                        {
                            // Create avm workflow tasks
                            if (currentTask is CyPhy.Task)
                            {
                                var cyphyTask = (CyPhy.Task)currentTask;
                                var avmTask = new InterpreterTask
                                {
                                    Name = cyphyTask.Name,
                                    COMName = cyphyTask.Attributes.COMName,
                                    Parameters = cyphyTask.Attributes.Parameters
                                };

                                avmWorkflow.Task.Add(avmTask);
                                SetLayoutData(avmTask, cyphyTask.Impl);
                            }
                            else if (currentTask is CyPhy.ExecutionTask)
                            {
                                var cyphyTask = (CyPhy.ExecutionTask)currentTask;
                                var avmTask = new ExecutionTask
                                {
                                    Name = cyphyTask.Name,
                                    Description = cyphyTask.Attributes.Description,
                                    Invocation = cyphyTask.Attributes.Invocation,
                                    //TODO: Ask adam about these:
                                    // = cyphyTask.Attributes.Parameters
                                    // = cyphyTask.Attributes.PostProcess
                                    // = cyphyTask.Attributes.PreProcess
                                };

                                SetLayoutData(avmTask, cyphyTask.Impl);
                                avmWorkflow.Task.Add(avmTask);
                            }
                            else
                            {
                                // ToDo: Give a warning
                                break;
                            }

                            // Next edge
                            var nextFlow = currentTask.DstConnections.FlowCollection.FirstOrDefault();

                            // No more outgoing edge
                            if (nextFlow == null) break;
                            currentTask = nextFlow.DstEnds.TaskBase;

                            // No element at the end of the edge
                            // ToDo: Give a warning
                        } while (currentTask != null);
                    }
                }
            }

            #endregion

            #region Process Settings

            foreach (var settings in tb.Children.SolverSettingsCollection)
            {
                var intervalMethod = AvmModelicaIntervalMethodMapping.FirstOrDefault(x => x.Item1 == settings.Attributes.IntervalMethod);
                var jobManagerToolSelection = AvmModelicaJobManagerToolSelectionMapping.FirstOrDefault(x => x.Item1 == settings.Attributes.JobManagerToolSelection);

                var avmSettings = new avm.modelica.SolverSettings
                {
                    IntervalLength = settings.Attributes.IntervalLength,
                    IntervalLengthSpecified = true,
                    
                    // TODO: Give warning
                    IntervalMethod = intervalMethod!=null?intervalMethod.Item2:avm.modelica.IntervalMethod.IntervalLength,
                    
                    // TODO: Give warning
                    JobManagerToolSelection = jobManagerToolSelection!=null?jobManagerToolSelection.Item2:avm.modelica.JobManagerToolSelection.Dymola_latest,
                    
                    JobManagerToolSelectionSpecified = true,
                    NumberOfIntervals = settings.Attributes.NumberOfIntervals,
                    NumberOfIntervalsSpecified = true,
                    Solver = settings.Attributes.Solver.ToString(),
                    StartTime = settings.Attributes.StartTime,
                    StartTimeSpecified = true,
                    StopTime = settings.Attributes.StartTime,
                    StopTimeSpecified = true,
                    Tolerance = settings.Attributes.Tolerance,
                    ToleranceSpecified = true,
                    ToolSpecificAnnotations = settings.Attributes.ToolSpecificAnnotations
                };

                avmTestBench.Settings.Add(avmSettings);
            }

            #endregion

            return avmTestBench;
        }
 public String GetCoordinatesAndIncrement(ISIS.GME.Common.Interfaces.FCO fco)
 {
     String s_Rtn = GetCoordinates();
     Increment(fco);
     return s_Rtn;
 }
 private void VerifyResources(ISIS.GME.Dsml.CyPhyML.Interfaces.Component component, string[] resources)
 {
     Assert.Equal(resources.Length, component.Children.ResourceCollection.Count());
     foreach (var res in component.Children.ResourceCollection)
     {
         Assert.True(resources.Contains(res.Attributes.Path.ToLower()));
     }
 }
        public static void LayoutChildrenByName(ISIS.GME.Common.Interfaces.Model parent)
        {
            PositionTracker pt = new PositionTracker();

            foreach (ISIS.GME.Common.Interfaces.FCO child in parent.AllChildren.OrderBy(child => child.Name))
            {
                String s_Coord = pt.GetCoordinatesAndIncrement(child);
                SetCoordinates(child, s_Coord);
            }
        }
        private void createAVMCyberConnector(List<avm.modelica.Connector> avmCyberModelConnectorList,  ISIS.GME.Common.Interfaces.Model cyberModelSignalInterface)
        {

            //Intialize new avm.modelica.Connector
            avm.modelica.Connector avmCyberConnector = new avm.modelica.Connector();

            // Assign the Class to avmCyberConnector from cyber SignalInterface
            avmCyberConnector.Class = META2AVM_Util.UtilFuncs.getMetaAttributeContent(cyberModelSignalInterface, "Class");

            // Assign name to the avmconnector from cyber SignalInterface
            //avmCyberConnector.Name = META2AVM_Util.UtilFuncs.getMetaObjectName(cyberModelSignalInterface);
            avmCyberConnector.Name = cyberModelSignalInterface.Name;

            // Assign Locator to the avmconnector from cyber SignalInterface relative path from its CyberModel
            avmCyberConnector.Locator = cyberModelSignalInterface.Name; // the Port is a direct child of the CyberModel hence locator is the name

            // Assign id to the avmconnector from cyber SignalInterface UDM ID
            avmCyberConnector.ID = META2AVM_Util.UtilFuncs.ensureMetaIDAttribute(cyberModelSignalInterface);
            


            // Now create the outer connector
            avm.Connector avmConnector = new avm.Connector();
            avmConnector.Name = avmCyberConnector.Name;
            avmConnector.ID = avmCyberConnector.ID;

            avm.modelica.Connector innerConnector = new avm.modelica.Connector();
            innerConnector.ID = META2AVM_Util.UtilFuncs.ensureMetaIDAttribute();
            innerConnector.Class = avmCyberConnector.Class;
            innerConnector.Locator = avmCyberConnector.Locator;
            innerConnector.Name = avmCyberConnector.Name;
            innerConnector.PortMap.Add(avmCyberConnector.ID);
     
            avmConnector.Role.Add(innerConnector);
            _avmComponent.Connector.Add(avmConnector);

            // Add the created avm connector to the given list
            avmCyberModelConnectorList.Add(avmCyberConnector);
        }