예제 #1
0
        /// <summary>
        /// トレースの現在位置を可視化する為にラベルの背景色を変える
        /// </summary>
        /// <returns></returns>
        /// <param name="flowTable">フローチャートの部品を格納した配列</param>
        private async Task <string> LabelInserter(FlowPartstable flowTable)
        {
            await Task.Run(() =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    TraceLabel.Text = TraceLabel.Text + flowTable.data.ToString() + "\n";
                    int id          = int.Parse(flowTable.identification_id);

                    try
                    {
                        ImageList[PriviousId].BackgroundColor = Color.Default;
                        ImageList[id].BackgroundColor         = Color.Violet;
                        PriviousId = id;
                    }catch (Exception)
                    {
                        ImageList[id].BackgroundColor = Color.Violet;
                        PriviousId = id;
                    }
                });

                Thread.Sleep(1000);
            });

            return("");
        }
예제 #2
0
        /// <summary>
        /// 計算を行う
        /// 第二テーブルを受け取ってアウトプット番号を返す
        /// </summary>
        /// <returns>The calculate.</returns>
        /// <param name="partsTb">Parts tb.</param>
        public async Task <string> TypeCalculate(FlowPartstable partsTb)
        {
            /* 形状四角 */
            if (partsTb.type_id.Equals("SideSikaku.png"))
            {
                VarManegement = new CalculateClass().SquareCalculate(VarManegement, partsTb.data);
                var startPossition2 = from x in DbInsertListTb3
                                      where x.Value.identification_id == partsTb.identification_id
                                      select x.Key;

                Device.BeginInvokeOnMainThread(() =>
                {
                    try
                    {
                        Debug.WriteLine("四角で受け取るiの値:" + VarManegement["i"].ToString());
                        ILabel.Text = "i:   " + VarManegement["i"].ToString();
                    }catch (Exception) { }
                    try{
                        Debug.WriteLine("四角で受け取るjの値:" + VarManegement["j"].ToString());
                        JLabel.Text = "j:   " + VarManegement["j"].ToString();
                    }catch (Exception) { }
                });

                /* 表示用 */
                await LabelInserter(partsTb);

                Debug.WriteLine("Debug:    color");

                return(DbInsertListTb3[startPossition2.First()].output_identification_id);
            }
            /* 形状ひし形 */
            else if (partsTb.type_id.Equals("SideHisigata.png"))
            {
                (string Symbol, int b, int c)JudgAnsower = new CalculateClass().DiamondCalculat(VarManegement, partsTb.data);
                string Symbol = JudgAnsower.Symbol;
                int    before = JudgAnsower.b;
                int    after  = JudgAnsower.c;

                Debug.WriteLine("hisigata返還アイテム: " + Symbol + before + after);

                if (Symbol == ":")
                {
                    if (before == after)
                    {
                        Symbol = "-1";
                    }
                    else if (before > after)
                    {
                        Symbol = "1";
                    }
                    else
                    {
                        Symbol = "2";
                    }
                }
                if (Symbol == "-1")
                {
                    /* 表示用 */
                    await LabelInserter(partsTb);

                    var NextIdFinder = from x in DbInsertListTb3
                                       where x.Value.identification_id == partsTb.identification_id &&
                                       x.Value.blanch_flag == "-1"
                                       select x.Value.output_identification_id;

                    await Task.Run(() =>
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            TraceLabel.Text = TraceLabel.Text + "No" + "\n";
                        });

                        Thread.Sleep(1000);
                    });


                    Debug.WriteLine("Noだった場合(-1)の時のリターン値: " + NextIdFinder.First());

                    return(String.Concat(NextIdFinder.First()));
                }
                else if (Symbol.Equals("0"))
                {
                    /* 表示用 */
                    await LabelInserter(partsTb);

                    var NextIdFinder = from x in DbInsertListTb3
                                       where x.Value.identification_id == partsTb.identification_id &&
                                       x.Value.blanch_flag == "0"
                                       select x.Value.output_identification_id;

                    await Task.Run(() =>
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            TraceLabel.Text = TraceLabel.Text + "Yes" + "\n";
                        });

                        Thread.Sleep(1000);
                    });

                    Debug.WriteLine("Yesだった場合(0)の時のリターン値: " + NextIdFinder.First());

                    return(String.Concat(NextIdFinder.First()));
                }
                else if (Symbol.Equals("1"))
                {
                    /* 表示用 */
                    await LabelInserter(partsTb);

                    var NextIdFinder = from x in DbInsertListTb3
                                       where x.Value.identification_id == partsTb.identification_id &&
                                       x.Value.blanch_flag == "1"
                                       select x.Value.output_identification_id;

                    await Task.Run(() =>
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            TraceLabel.Text = TraceLabel.Text + ">" + "\n";
                        });

                        Thread.Sleep(1000);
                    });

                    Debug.WriteLine(": >場合(1)の時のリターン値: " + NextIdFinder.First());
                    return(String.Concat(NextIdFinder.First()));
                }
                else if (Symbol.Equals("2"))
                {
                    /* 表示用 */
                    await LabelInserter(partsTb);

                    var nextIdFinder = from x in DbInsertListTb3
                                       where x.Value.identification_id == partsTb.identification_id &&
                                       x.Value.blanch_flag == "2"
                                       select x.Value.output_identification_id;

                    await Task.Run(() =>
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            TraceLabel.Text = TraceLabel.Text + "<" + "\n";
                        });

                        Thread.Sleep(1000);
                    });

                    Debug.WriteLine(": <場合(1)の時のリターン値: " + nextIdFinder.First());

                    return(String.Concat(nextIdFinder.First()));
                }
            }
            /* 形状台形 */
            else if (partsTb.type_id.Equals("SideDaikeiUe.png") || partsTb.type_id.Equals("SideDaikeiSita.png"))
            {
                if (!partsTb.data.Equals(""))
                {
                    (string Symbol, int b, int c)judgAnsower = new CalculateClass().DiamondCalculat(VarManegement, partsTb.data);
                    string symbol = judgAnsower.Symbol;
                    int    before = judgAnsower.b;
                    int    after  = judgAnsower.c;

                    if (symbol == "-1")
                    {
                        /* 表示用 */
                        await LabelInserter(partsTb);

                        var nextIdFinder = from x in DbInsertListTb3
                                           where x.Value.identification_id == partsTb.identification_id &&
                                           x.Value.blanch_flag == "-1"
                                           select x.Value.output_identification_id;

                        await Task.Run(() =>
                        {
                            Device.BeginInvokeOnMainThread(() =>
                            {
                                TraceLabel.Text += "継続\n";
                            });

                            Thread.Sleep(1000);
                        });

                        Debug.WriteLine("Noだった場合(-1)の時のリターン値: {0}", nextIdFinder.First());

                        return(String.Concat(nextIdFinder.First()));
                    }
                    else if (symbol.Equals("0"))
                    {
                        /* 表示用 */
                        await LabelInserter(partsTb);

                        var nextIdFinder = from x in DbInsertListTb3
                                           where x.Value.identification_id == partsTb.identification_id &&
                                           x.Value.blanch_flag == "0"
                                           select x.Value.output_identification_id;

                        await Task.Run(() =>
                        {
                            Device.BeginInvokeOnMainThread(() =>
                            {
                                TraceLabel.Text += "終了\n";
                            });

                            Thread.Sleep(1000);
                        });

                        Debug.WriteLine("Yesだった場合(0)の時のリターン値: {0}", nextIdFinder.First());

                        return(String.Concat(nextIdFinder.First()));
                    }
                }
                else
                {
                    var nextIdFinder = from x in DbInsertListTb3
                                       where x.Value.identification_id == partsTb.identification_id &&
                                       x.Value.blanch_flag == "0"
                                       select x.Value.output_identification_id;

                    /*
                     * await Task.Run(() =>
                     * {
                     *  Device.BeginInvokeOnMainThread(() =>
                     *  {
                     *      TraceLabel.Text = TraceLabel.Text + "スルーパス" + "\n";
                     *  });
                     *
                     *  Thread.Sleep(1000);
                     * });
                     * Debug.WriteLine("Yesだった場合(0)の時のリターン値: " + NextIdFinder.First());
                     */

                    return(String.Concat(nextIdFinder.First()));
                }
            }
            /* 形状平行四辺形 */
            else if (partsTb.type_id == "SideHeikou.png")
            {
                var nextIdFinder = from x in DbInsertListTb3
                                   where x.Value.identification_id == partsTb.identification_id
                                   select x.Value.output_identification_id;

                var output = from x in DbInsertListTb2
                             where x.Value.identification_id == partsTb.identification_id
                             select x.Value.data;

                /* 表示用 */
                await LabelInserter(partsTb);

                Debug.WriteLine("最終結果ではなく:  " + VarManegement[new CalculateClass().ParallelogramOutput(String.Concat(output))]);

                MassageLabel.Text = "終了" + String.Concat(output) + "の解は" + VarManegement[new CalculateClass().ParallelogramOutput(String.Concat(output))];

                return("-1");
            }

            return("-1");
        }