/// <summary>
        /// Process one cycle by iterating over all values of the cycleArray.
        /// </summary>
        /// <param name="networkId"></param>
        /// <param name="cycleIdx"></param>
        /// <returns></returns>
        private static async Task ProcessCycleAsync(string networkId, int cycleIdx)
        {
            int stepIdx = 1;

            foreach (int sensorValue in ExampleConfiguration.CycleArry)
            {
                DisplayData result = new DisplayData {
                    CycleIdx = cycleIdx + 1, StepIdx = stepIdx, Value = sensorValue
                };

                // Encode the sensor value using a scalar encoder
                await RestClient.Api.SetEncoderValueAsync(networkId, ExampleConfiguration.EncoderRegionName, sensorValue);

                // Execute one iteration of the Network
                await RestClient.Api.RunNetworkAsync(networkId);

                // Get the active, winner and predicted cells from the Temporal Memory
                result.ActiveSdr = await RestClient.Api.GetTmActiveCellsAsync(networkId, ExampleConfiguration.TmRegionName);

                result.WinnderSdr = await RestClient.Api.GetTmWinnerCellsAsync(networkId, ExampleConfiguration.TmRegionName);

                result.PredictiveSdr = await RestClient.Api.GetTmPredictiveCellsAsync(networkId, ExampleConfiguration.TmRegionName);

                // Also get the anomaly score of the TM for this run
                result.AnomalyScore = await RestClient.Api.GetTmAnomalyAsync(networkId, ExampleConfiguration.TmRegionName);

                DisplayOutput.PrintResult(result);

                stepIdx++;
            }
        }
 private static void PrintHeader(DisplayData result)
 {
     Console.Clear();
     PrintSeparatorLine();
     Console.WriteLine($"| Cycle: {result.CycleIdx:D2} | Step: {result.StepIdx:D2} | Value: {result.Value:D2} | Anomaly: {result.AnomalyScore:0.0} |");
     PrintSeparatorLine();
     PrintColumnInfo();
     PrintSeparatorLine();
 }
        /// <summary>
        /// Prints the overall result to the console for a certain amount of time.
        /// </summary>
        /// <param name="result"></param>
        internal static void PrintResult(DisplayData result)
        {
            PrintHeader(result);
            for (int rowIdx = 0; rowIdx < ExampleConfiguration.CellsPerColumn; rowIdx++)
            {
                PrintCellRow(result, rowIdx);
            }
            Console.WriteLine();

            Thread.Sleep(ExampleConfiguration.DisplaySleepMilliseconds);
        }
 private static void PrintCellRow(DisplayData result, int rowIdx)
 {
     Console.Write("| Cell    |");
     for (int colIdx = 0; colIdx < ExampleConfiguration.ColumnSize; colIdx++)
     {
         int  cellId          = colIdx * ExampleConfiguration.CellsPerColumn + rowIdx;
         byte activeState     = result.ActiveSdr.GetDense()[cellId];
         byte winnerState     = result.WinnderSdr.GetDense()[cellId];
         byte predictiveState = result.PredictiveSdr.GetDense()[cellId];
         PrintCell(cellId, activeState, winnerState, predictiveState);
     }
     Console.WriteLine();
 }