Example #1
0
        public IEnumerable<CyAPICustomizer> CustomizeAPIs(ICyInstQuery_v1 query, ICyTerminalQuery_v1 termQuery, 
            IEnumerable<CyAPICustomizer> apis)
        {
            List<CyClockData> clockStuff = termQuery.GetClockData(ADC_ClockTermName, 3);

            Dictionary<string, string> paramDict = null;
            m_termQuery = termQuery;
            m_instQuery = query;
            foreach (CyAPICustomizer api in apis)
            {
                // Get parameter dictionary
                paramDict = api.MacroDictionary;

            }

            bool isPSoC3 = query.GetCommittedParam(Resource.DsmNameText).Value == Resource.DSMText;
            float vdda = float.Parse(query.GetCommittedParam(Resource.VddaValueText).Value);

            // Calculate values
            CalcValues(ref paramDict, isPSoC3, vdda);

            // Assign dictionary back to API customizers
            foreach (CyAPICustomizer api in apis)
            {
                // Get parameter dictionary
                api.MacroDictionary = paramDict;
            }
            // Return customizers
            return apis;
        }
        public IEnumerable<CyAPICustomizer> CustomizeAPIs(
            ICyInstQuery_v1 query,
            ICyTerminalQuery_v1 termQuery,
            IEnumerable<CyAPICustomizer> apis)
        {
            List<CyAPICustomizer> customizers = new List<CyAPICustomizer>(apis);
            Dictionary<string, string> paramDict = new Dictionary<string, string>();
            string instanceName = "";

            // Get the parameters from the characterLCD.c file customizer
            for (int i = 0; i < customizers.Count; i++)
            {
                CyAPICustomizer api = customizers[i];

                // Get dict from main file.
                if (api.OriginalName.EndsWith(LCD_CFILE_NAME))
                {
                    paramDict = api.MacroDictionary;
                    paramDict.TryGetValue(INSTANCE_NAME_PARAM, out instanceName);
                }
                else if (api.OriginalName.EndsWith(CUST_CHARS_CFILE_NAME))
                {
                    m_custChar_CFile = api;
                }
                else if (api.OriginalName.EndsWith(BARGRAPH_CFILE_NAME))
                {
                    m_barGraph_CFile = api;
                }
            }

            // Determine Custom Character Set
            string value;
            paramDict.TryGetValue(CUSTOM_CHARACTER_SET_PARAM, out value);
            m_customCharacterSet = (CyCustomCharacterSetTypes)(int.Parse(value));

            // Determine existence of ASCII Routines
            paramDict.TryGetValue(CONVERSION_ROUTINE_PARAM, out value);
            m_conversionRoutines = (value == "1");

            #region New Code Substitution Values
            const string CUSTOM_CHAR_DEFINES_MACRO = "CustomCharDefines_API_GEN";
            const string CONVERSION_ROUTINE_MACRO = "ConversionRoutines_DEF";

            string customCharDeleted = "0";
            string customCharDefined = ((byte)m_customCharacterSet).ToString();

            #region Literal String Code for Conversion Routines
            string conversionRoutineDeleted = "0";

            string conversionRoutineDefined = "1";
            #endregion
            #endregion

            // If a character set is selected, build c file with data in it.
            switch (m_customCharacterSet)
            {
                case CyCustomCharacterSetTypes.USERDEFINED:
                    ConvertCharacters(LoadUserDefinedCharacters(paramDict), paramDict);
                    paramDict.Add(CUSTOM_CHAR_DEFINES_MACRO, customCharDefined);
                    customizers.Remove(m_barGraph_CFile);
                    break;
                case CyCustomCharacterSetTypes.VERTICAL:
                    GenerateVerticalBargraph(paramDict);
                    paramDict.Add(CUSTOM_CHAR_DEFINES_MACRO, customCharDefined);
                    customizers.Remove(m_custChar_CFile);
                    break;
                case CyCustomCharacterSetTypes.HORIZONTAL:
                    GenerateHorizontalBargraph(paramDict);
                    paramDict.Add(CUSTOM_CHAR_DEFINES_MACRO, customCharDefined);
                    customizers.Remove(m_custChar_CFile);
                    break;
                default:
                    paramDict.Add(CUSTOM_CHAR_DEFINES_MACRO, customCharDeleted);
                    customizers.Remove(m_barGraph_CFile);
                    customizers.Remove(m_custChar_CFile);
                    break;
            }

            // If conversion routines are selected, import them
            if (m_conversionRoutines)
            {
                paramDict.Add(CONVERSION_ROUTINE_MACRO, conversionRoutineDefined);
            }
            else
            {
                paramDict.Add(CONVERSION_ROUTINE_MACRO, conversionRoutineDeleted);
            }
            // Replace macro dictionaries with paramDict
            for (int i = 0; i < customizers.Count; i++)
            {
                CyAPICustomizer api = customizers[i];
                api.MacroDictionary = paramDict;
            }

            return customizers;
        }