public CyGeneralPage(CyParameters parameters)
            : base(parameters)
        {
            InitializeComponent();

            numUpDownWaitTime.TextChanged += numUpDownWaitTime_TextChanged;

            InitFields();
        }
Example #2
0
        public IEnumerable<CyDRCInfo_v1> GetDRCs(ICyDRCProviderArgs_v1 args)
        {
            CyParameters parameters = new CyParameters(args.InstQueryV1);

            if (parameters.CompareAppType() == false)
            {
                yield return new CyDRCInfo_v1(CyDRCInfo_v1.CyDRCType_v1.Error,
                                              Properties.Resources.AppTypeCompareError);
            }
        }
Example #3
0
        public CyCustErr GetBootloaderData(ICyBootloaderProviderArgs_v1 args, out CyBootloaderData_v1 data)
        {
            CyParameters prms = new CyParameters(args.InstQuery);

            CyBootloaderChecksumType_v1 checksum = CyBootloaderChecksumType_v1.BasicChecksum;
            if (prms.PacketChecksumType == true)
            {
                checksum = CyBootloaderChecksumType_v1.CRC16;
            }

            data = new CyBootloaderData_v1(prms.Version, checksum, prms.IOComponent);

            return CyCustErr.OK;
        }
Example #4
0
        /// <summary>
        /// Reads the bus in values
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        private int[] GetBusInValues(string text)
        {
            List <int>   list         = new List <int>();
            StringReader stringReader = new StringReader(text);

            string text2 = stringReader.ReadLine();

            while (!string.IsNullOrEmpty(text2))
            {
                uint uIntValue = CyParameters.GetUIntValue(text2);
                if (uIntValue > 16777216)
                {
                    throw new ArgumentOutOfRangeException(string.Format(
                                                              "Out of range input value detected: {0} ({1} exceeds maximum value of {2}",
                                                              text2,
                                                              uIntValue,
                                                              16777216));
                }
                list.Add((int)uIntValue);
                text2 = stringReader.ReadLine();
            }

            return(list.ToArray());
        }
 public CyEditingWrapperControl(CyParameters parameters)
 {
     m_parameters = parameters;
     this.Load += new EventHandler(CyEditingWrapperControl_Load);
 }
Example #6
0
        DialogResult ICyParamEditHook_v1.EditParams(ICyInstEdit_v1 edit, ICyTerminalQuery_v1 termQuery,
                                                    ICyExpressMgr_v1 mgr)
        {
            const string PAPAM_TAB_NAME_BUILTIN = "Built-in";
            CyEditingWrapperControl.RUN_MODE = true;
            CyParameters prms = new CyParameters(edit);
            CyGeneralPage generalPage = new CyGeneralPage(prms);
            ICyTabbedParamEditor editor = edit.CreateTabbedParamEditor();

            CyParamExprDelegate exprDelegate = delegate(ICyParamEditor custEditor, CyCompDevParam param)
            {
                prms.m_globalEditMode = false;
                if (param.TabName == generalPage.TabName)
                    generalPage.InitFields();
                prms.m_globalEditMode = true;
            };

            editor.AddCustomPage(Properties.Resources.PageTitleGeneral, generalPage, exprDelegate, generalPage.TabName);
            editor.AddDefaultPage(Properties.Resources.PageTitleBuiltIn, PAPAM_TAB_NAME_BUILTIN);

            prms.m_globalEditMode = true;

            return editor.ShowDialog();
        }
Example #7
0
 public CyGeneralPage(CyParameters parameters)
 {
     InitializeComponent();
     m_parameters = parameters;
     InitFields();
 }
Example #8
0
        /// <summary>
        /// Run the simulations asynchronously
        /// </summary>
        /// <param name="parameters">Simulation parameters</param>
        /// <param name="numCycles">Number of cycles to simulate</param>
        /// <param name="progress">Progress report update object</param>
        /// <param name="cancellationToken">Cancellation token for UI</param>
        /// <param name="inputSequence">List of globals to set at specifiec cycle numbers</param>
        /// <param name="cyCodeTab">CyCodeTab instance</param>
        /// <param name="containerPx">Bounding box of diagram container</param>
        /// <param name="dpiX">DPI of system - x</param>
        /// <param name="dpiY">DPI of system - y</param>
        /// <returns></returns>
        public Task <DFBState> RunDFBSimulations(
            CyParameters parameters,
            int numCycles,
            IProgress <SimProgressReport> progress,
            CancellationToken cancellationToken,
            List <InputSequence> inputSequence,
            CyCodeTab cyCodeTab,
            Rectangle containerPx,
            float dpiX,
            float dpiY)
        {
            var progressReport = new SimProgressReport();

            this.inputSequence = inputSequence;
            stepsRequested     = numCycles;
            cyParameters       = parameters;

            // CyCodeTab must be instantiated on the WInForms side, with references to
            // UIFramework.Product4.WinForms and UIFramework.Product6.WinForms
            this.cyCodeTab = cyCodeTab;

            Assemble();

            // Create state view manager
            var dfbState = new DFBState(this, DFBValueFormat.q23Decimal);

            // Return on error
            var errors = cyDfbAsm.Errors.GetFullList();

            if (errors.Where(x => x.Type == CyMessageType.Error).Count() > 0)
            {
                return(Task.Run(() => { return dfbState; }));
            }

            // Check pending async cancel
            if (cancellationToken.IsCancellationRequested == true)
            {
                return(Task.Run(() => { return dfbState; }));
            }

            // Execute the simulation steps with status reports
            return(Task.Run(() =>
            {
                // Execute DFB simulator for all cycles
                while (true)
                {
                    bool sim;

                    sim = SimulateStep();
                    if (sim && stepsExecuted < numCycles)
                    {
                        stepsExecuted++;
                    }
                    else
                    {
                        break;
                    }
                }

                progressReport.TotalSteps = simulatorHistory.Count;

                // Generate state frames in batches
                if (batchSize > simulatorHistory.Count)
                {
                    batchSize = simulatorHistory.Count;
                }
                var batchStartIdx = 0;
                var batchEndIdx = batchStartIdx + batchSize;

                var framesTmp = new Dictionary <int, DFBStateFrame>();

                while (true)
                {
                    // Check pending async cancel
                    if (cancellationToken.IsCancellationRequested == true)
                    {
                        progressReport.Cancelled = true;
                        progress.Report(progressReport);
                        return dfbState;
                    }

                    // Generate a batch of frames
                    framesTmp.Clear();
                    var curBatch = batchStartIdx;
                    Parallel.For(batchStartIdx, batchEndIdx, b =>
                    {
                        framesTmp.Add(b, DFBState.GenerateFrame(this, b, containerPx, dpiX, dpiY));
                        curBatch++;
                        progressReport.CurrentStep = curBatch;
                        progress.Report(progressReport);
                    });

                    dfbState.StateFrames.AddRange(framesTmp
                                                  .OrderBy(x => x.Key)
                                                  .Select(x => x.Value));

                    batchStartIdx = batchStartIdx + batchSize;
                    if (batchStartIdx > simulatorHistory.Count - 1)
                    {
                        // Last batch finished all frames
                        break;
                    }

                    batchEndIdx = batchEndIdx + batchSize;
                    // Note that batchEndIdx is exclusive in Parallel.For()
                    if (batchEndIdx > simulatorHistory.Count)
                    {
                        batchEndIdx = simulatorHistory.Count;
                    }
                }

                return dfbState;
            }));
        }
        DialogResult ICyParamEditHook_v1.EditParams(ICyInstEdit_v1 edit, ICyTerminalQuery_v1 termQuery,
            ICyExpressMgr_v1 mgr)
        {
            const string PAPAM_TAB_NAME_BUILTIN = "Built-in";
            const string PAPAM_TAB_NAME_INTERCONNECT = "Interconnect";
            CyParameters prms = new CyParameters(edit);
            CyGeneralPage generalPage = new CyGeneralPage(prms);
            ICyTabbedParamEditor editor = edit.CreateTabbedParamEditor();
            CyTerminalControl_v1 interconnectTab = null;

            CyParamExprDelegate exprDelegate = delegate(ICyParamEditor custEditor, CyCompDevParam param)
            {
                prms.m_globalEditMode = false;
                if (param.TabName == generalPage.TabName)
                    generalPage.InitFields();
                prms.m_globalEditMode = true;
            };

            editor.AddCustomPage(Properties.Resources.PageTitleGeneral, generalPage, exprDelegate, generalPage.TabName);

            // System Builder support
            if (prms.InstQuery.DeviceQuery.IsPSoC4 && edit.IsInSystemBuilder)
            {
                interconnectTab = new CyTerminalControl_v1(edit);
                editor.AddCustomPage(Resources.InterconnectTabDisplayName, interconnectTab, exprDelegate,
                    PAPAM_TAB_NAME_INTERCONNECT);
            }
            editor.AddDefaultPage(Properties.Resources.PageTitleBuiltIn, PAPAM_TAB_NAME_BUILTIN);

            prms.m_globalEditMode = true;

            return editor.ShowDialog();
        }