public void AddMachine(FAMachine machine)
        {
            if (machine == null) return;

            PropertyInfo[] propList = machine.GetType().GetProperties();
            foreach (PropertyInfo info in propList)
            {
                if (info.PropertyType == typeof(FASequence))
                {
                    FASequence sequence = (FASequence)info.GetValue(machine, null);
                    if (sequence == null) return;
                    SequenceList.Add(sequence);
                }
            }
        }
 public void AddPart(FAMachine parent, FAMachine obj)
 {
     _partList.Add(obj);
 }
 public void AddModule(FAMachine obj)
 {
     _moduleList.Add(obj);
 }
        private void SetAlarmIDToMachine(int machineTypeID, FAMachine machine, bool includeAlarmIDMoreThanZero, bool allReset)
        {
            Dictionary<string, int> dic = new Dictionary<string,int>();

            foreach (var propInfo in machine.GetType().GetProperties())
            {
                foreach (var attr in Attribute.GetCustomAttributes(propInfo, typeof(FAAttribute), false))
                {
                    FAAttribute faAttr = (FAAttribute)attr;
                    if (faAttr.GroupName == "Alarm")
                    {
                        int alarmNo = 0;

                        if (allReset == false)
                        {
                            alarmNo = (int)propInfo.GetValue(machine, null);
                        }

                        dic.Add(propInfo.Name, alarmNo);

                        break;
                    }
                }
            }

            var machineType = machine.GetType();

            var keys = dic.Keys.ToList();
            for (int i=0; i<keys.Count; i++)
            {
                var property = machineType.GetProperty(keys[i]);
                int propValue = dic[keys[i]];

                if (propValue > 0 && includeAlarmIDMoreThanZero == false)
                    continue;

                for (int alarm = 1; alarm < 999; alarm++)
                {
                    int alarmID = machineTypeID * 1000000 + machine.MachineID * 1000 + alarm;

                    if (dic.Values.Contains(alarmID) == false)
                    {
                        property.SetValue(machine, alarmID, null);
                        dic[keys[i]] = alarmID;
                        break;
                    }
                }
            }
        }
        private void AddAlarmOfMachine(FAMachine machine, string preName)
        {
            foreach (var propInfo in machine.GetType().GetProperties())
            {
                foreach (var attr in Attribute.GetCustomAttributes(propInfo, typeof(FAAttribute), false))
                {
                    FAAttribute faAttr = (FAAttribute)attr;
                    if (faAttr.GroupName == "Alarm")
                    {
                        int alarmNo = (int)propInfo.GetValue(machine, null);

                        if (alarmNo == 0) continue;

                        if (FAAlarmManager.Instance.Items.ContainsKey(alarmNo) == false)
                        {
                            try
                            {
                                DefaultAlarmInfo alarmInfo = (DefaultAlarmInfo)Attribute.GetCustomAttribute(propInfo, typeof(DefaultAlarmInfo), false);

                                FAAlarm alarm = new FAAlarm();
                                alarm.AlarmNo = alarmNo;
                                alarm.AlarmName = "[" + preName.Trim() + "] " + propInfo.Name;
                                alarm.Description = "[" + preName.Trim() + "] " + propInfo.Name;
                                if (alarmInfo != null)
                                {
                                    alarm.Type = alarmInfo.AlarmType;
                                    alarm.Status = alarmInfo.AlarmStatus;
                                    alarm.Solution = "[" + preName.Trim() + "] " + alarmInfo.AlarmSolution;
                                }

                                FAAlarmManager.Instance.Items.Add(alarmNo, alarm);
                            }
                            catch
                            {
                            }
                        }

                        break;
                    }
                }
            }
        }