コード例 #1
0
ファイル: Program.cs プロジェクト: tonyhoangdev/PinsTool
        private static void SerialModuleProperty(ParserProperty.property_configuration pc, string fileNameOut)
        {
            XmlSerializer           xml = new XmlSerializer(typeof(ParserProperty.property_configuration));
            XmlSerializerNamespaces ns  = new XmlSerializerNamespaces();

            ns.Add(string.Empty, string.Empty);
            ns.Add("pc", "http://www.freescale.com/ProcessorExpert/PropertyConfiguration.xsd");

            using (TextWriter writer = new StreamWriter(fileNameOut))
            {
                xml.Serialize(writer, pc, ns);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: tonyhoangdev/PinsTool
        private static ParserProperty.property_configuration DeserialModuleProperty(string file)
        {
            XmlSerializer de     = new XmlSerializer(typeof(ParserProperty.property_configuration));
            TextReader    reader = new StreamReader(file);

            object obj = de.Deserialize(reader);

            ParserProperty.property_configuration config = (ParserProperty.property_configuration)obj;

            reader.Close();

            return(config);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: tonyhoangdev/PinsTool
        private static void ProcessProperty(PinsFile fileIn, PinsFile fileOut)
        {
            ParserProperty.property_configuration pc = DeserialModuleProperty(fileIn.Property);

            List <ParserProperty.propertiesEnum_property> lstProperty = new List <ParserProperty.propertiesEnum_property>();

            string pattern = @"(PORT\w)_PCR(\d+)_(\w+)";

            string currID  = "0";
            string preID   = "0";
            string prePort = "PORTA";

            foreach (var item in pc.properties)
            {
                foreach (Match item2 in Regex.Matches(item.id, pattern))
                {
                    if (item2.Groups[3].Value.Equals("InitValue"))
                    {
                        break;
                    }

                    currID = item2.Groups[2].Value;

                    if (preID.CompareTo(currID) != 0)
                    {
                        ParserProperty.propertiesEnum_property pt = new ParserProperty.propertiesEnum_property();
                        pt.caption     = "Initial Value";
                        pt.description = "Initial Value";
                        pt.@default    = "state_0";

                        List <ParserProperty.propertiesEnum_propertyState> lstEnumState = new List <ParserProperty.propertiesEnum_propertyState>();

                        ParserProperty.propertiesEnum_propertyStateConfiguration stateConfig0 = new ParserProperty.propertiesEnum_propertyStateConfiguration()
                        {
                            const_assign = new ParserProperty.propertiesEnum_propertyStateConfigurationConst_assign()
                            {
                                register        = string.Format("{0}_PCR{1}", prePort, preID),
                                check_conflict  = true,
                                bit_field_value = "0",
                                //configuration_step = string.Format("init_{0}", prePort)
                            }
                        };

                        ParserProperty.propertiesEnum_propertyStateConfiguration stateConfig1 = new ParserProperty.propertiesEnum_propertyStateConfiguration()
                        {
                            const_assign = new ParserProperty.propertiesEnum_propertyStateConfigurationConst_assign()
                            {
                                register        = string.Format("{0}_PCR{1}", prePort, preID),
                                check_conflict  = true,
                                bit_field_value = "0x1",
                                //configuration_step = string.Format("init_{0}", prePort)
                            }
                        };


                        lstEnumState.Add(new ParserProperty.propertiesEnum_propertyState()
                        {
                            id = "state_0", caption = "Initial Value is configured on the corresponding pin", description = "Initial Value is configured on the corresponding pin", configuration = stateConfig0
                        });
                        lstEnumState.Add(new ParserProperty.propertiesEnum_propertyState()
                        {
                            id = "state_1", caption = "Initial Value is configured on the corresponding pin", description = "Initial Value is configured on the corresponding pin", configuration = stateConfig1
                        });

                        pt.state = lstEnumState.ToArray();

                        pt.id = string.Format("{0}_PCR{1}_InitValue", prePort, preID);


                        preID   = currID;
                        prePort = item2.Groups[1].Value;

                        lstProperty.Add(pt);
                    }
                }

                if (!item.id.Contains("InitValue"))
                {
                    lstProperty.Add(item);
                }
            }
            pc.properties = lstProperty.ToArray();
            SerialModuleProperty(pc, fileOut.Property);
        }