public void setBaseAction(Anablocks curAction)
        {
            double cycleTime = valmoWin.dv.PrdPr[269].vDbl;

            if (curAction.seqEnd == curAction.seqStart)
            {
                if (curAction.tEnd < curAction.tStart)
                {
                    curAction.tEnd = curAction.tStart;
                }

                if (curAction.tStart > cycleTime)
                {
                    curAction.tStart = curAction.tEnd = cycleTime;
                }

                double actionTime = curAction.tEnd - curAction.tStart;

                lbTimeBeginBase.Content = curAction.tStart.ToString("0.00");
                lbTimeContinueBase.Content = actionTime.ToString("0.00");
                lbTimeEndBase.Content = curAction.tEnd.ToString("0.00");

                lbBase.Content = actionTime.ToString("0.00");

                if (curAction.tStart * bdItemPage.sRate > 500)
                {
                    Canvas.SetRight(lbBase, Convert.ToDouble(600 - curAction.tStart * bdItemPage.sRate));
                }
                else
                {
                    Canvas.SetLeft(lbBase, curAction.tStart * bdItemPage.sRate);
                }

                Canvas.SetLeft(prgBase, curAction.tStart * bdItemPage.sRate);
                prgBase.X2 = actionTime * bdItemPage.sRate;

                prgBase2.X2 = 0;
            }
            else if (curAction.seqEnd > curAction.seqStart)
            {
                if (curAction.tEnd > cycleTime)
                {
                    curAction.tEnd = cycleTime;
                }
                if (curAction.tStart > cycleTime)
                {
                    curAction.tStart = cycleTime;
                }

                double actionTime = cycleTime - curAction.tStart + curAction.tEnd;

                lbTimeBeginBase.Content = curAction.tStart.ToString("0.00");
                lbTimeContinueBase.Content = actionTime.ToString("0.00");
                lbTimeEndBase.Content = curAction.tEnd.ToString("0.00");

                lbBase.Content = actionTime.ToString("0.00");
                if (curAction.tStart * bdItemPage.sRate > 500)
                {
                    App.log.Info("SetRight \t" + (600 - curAction.tStart * bdItemPage.sRate));
                    Canvas.SetRight(lbBase, 600 - curAction.tStart * bdItemPage.sRate);
                }
                else
                {
                    Canvas.SetLeft(lbBase, curAction.tStart * bdItemPage.sRate);
                }

                Canvas.SetLeft(prgBase, curAction.tStart * bdItemPage.sRate);
                prgBase.X2 = 600 - curAction.tStart * bdItemPage.sRate;

                prgBase2.X2 = curAction.seqEnd * bdItemPage.sRate;
            }
            else
            {
                return;
            }
        }
        private void handleRefreshBlock(objUnit obj)
        {
            if (obj.value == 1)
            {
                obj.valueNew = 0;

                if (sRate > 0)
                {
                    cvsCursor.Visibility = Visibility.Visible;
                    lbCursor.Content = (Canvas.GetLeft(cvsCursor) / sRate).ToString("0.00");

                    if (_bIsBaseOn == true)
                    {
                        uint[] blocksCur = new uint[valmoWin.dv.PrdPr[267].value];

                        if (flagParseState == 2)
                        {
                            Lasal32.GetData(blocksCur, staticDataAddr, blocksCur.Length);
                        }
                        else
                        {
                            Lasal32.GetData(blocksCur, curDataAddr, blocksCur.Length);
                        }

                        uint[] blocksBase = new uint[valmoWin.dv.PrdPr[267].value];
                        Lasal32.GetData(blocksBase, baseDataAddr, blocksBase.Length);

                        int j = 0;
                        for (int i = 0; i < blocksCur.Length / 32; i++)
                        {
                            baseCycleTime = valmoWin.dv.PrdPr[269].getDblValue(Convert.ToInt32(blocksBase[0]));
                            uint ActionName = blocksCur[i * 8 + 3];

                            switch (ActionName)
                            {
                                case 3:
                                    time_MoldOpen_Start = Convert.ToInt32(blocksCur[i * 8 + 4]);
                                    break;
                                case 2:
                                    time_MoldClose_Start = Convert.ToInt32(blocksCur[i * 8 + 4]);
                                    time_MoldClose = Convert.ToInt32(blocksCur[i * 8 + 5]) - Convert.ToInt32(blocksCur[i * 8 + 4]);
                                    break;
                                case 8:
                                    time_Injection = Convert.ToInt32(blocksCur[i * 8 + 5]) - Convert.ToInt32(blocksCur[i * 8 + 4]);
                                    break;
                                case 9:
                                    time_Holding = Convert.ToInt32(blocksCur[i * 8 + 5]) - Convert.ToInt32(blocksCur[i * 8 + 4]);
                                    break;
                                case 11:
                                    time_Cooling = Convert.ToInt32(blocksCur[i * 8 + 5]) - Convert.ToInt32(blocksCur[i * 8 + 4]);
                                    break;
                                default:
                                    break;
                            }

                            Anablocks sblockCur = new Anablocks();
                            sblockCur.Active = blocksCur[i * 8 + 1];
                            sblockCur.Move = blocksCur[i * 8 + 2];
                            sblockCur.Name = (typeName)ActionName;
                            sblockCur.tStart = Math.Round(valmoWin.dv.PrdPr[269].getDblValue(Convert.ToInt32(blocksCur[i * 8 + 4])), 3);
                            sblockCur.tEnd = Math.Round(valmoWin.dv.PrdPr[269].getDblValue(Convert.ToInt32(blocksCur[i * 8 + 5])), 3);
                            sblockCur.seqStart = blocksCur[i * 8 + 6];
                            sblockCur.seqEnd = blocksCur[i * 8 + 7];

                            Anablocks sblockBase = new Anablocks();
                            sblockBase.Active = blocksBase[i * 8 + 1];
                            sblockBase.Move = blocksBase[i * 8 + 2];
                            sblockBase.Name = (typeName)blocksBase[i * 8 + 3];
                            sblockBase.tStart = Math.Round(valmoWin.dv.PrdPr[269].getDblValue(Convert.ToInt32(blocksBase[i * 8 + 4])), 3);
                            sblockBase.tEnd = Math.Round(valmoWin.dv.PrdPr[269].getDblValue(Convert.ToInt32(blocksBase[i * 8 + 5])), 3);
                            sblockBase.seqStart = blocksBase[i * 8 + 6];
                            sblockBase.seqEnd = blocksBase[i * 8 + 7];

                            if (sblockBase.Name == sblockCur.Name)
                            {
                                if (typeName.IsDefined(typeof(typeName), sblockCur.Name) && (sblockCur.Name != typeName.noactive))
                                {
                                    lstBarCtrl[j].visiable = Visibility.Visible;
                                    lstBarCtrl[j].type = sblockCur.Name;
                                    lstBarCtrl[j].setCurAction(sblockCur);
                                    lstBarCtrl[j].setBaseAction(sblockBase);
                                    j++;
                                }
                            }
                            else
                            {
                                if (typeName.IsDefined(typeof(typeName), sblockCur.Name) && (sblockCur.Name != typeName.noactive))
                                {
                                    lstBarCtrl[j].visiable = Visibility.Visible;
                                    lstBarCtrl[j].type = sblockCur.Name;
                                    lstBarCtrl[j].setCurAction(sblockCur);
                                    j++;
                                }

                                if (typeName.IsDefined(typeof(typeName), sblockCur.Name) && (sblockCur.Name != typeName.noactive))
                                {
                                    lstBarCtrl[j].visiable = Visibility.Visible;
                                    lstBarCtrl[j].type = sblockBase.Name;
                                    lstBarCtrl[j].setBaseAction(sblockBase);
                                    j++;
                                }
                            }
                        }

                        for (int i = j; i < 50; i++)
                        {
                            lstBarCtrl[i].visiable = Visibility.Hidden;
                        }

                        if (valmoWin.dv.PrdPr[96].value > TotalMoldNumber)
                        {
                            double tmep = valmoWin.dv.PrdPr[269].value;

                            if (tmep <= 0)
                            {
                                return;
                            }

                            lb1.Content = "0.0%";
                            if ((time_MoldClose < tmep) && (time_MoldClose > 0))
                            {
                                lb1.Content = ((time_MoldClose) * 100 / tmep).ToString("0.0") + "%";
                            }

                            lb2.Content = "0.0%";
                            if (time_Injection != 0)
                            {
                                lb2.Content = ((time_Injection + time_Holding + time_Cooling) * 100 / tmep).ToString("0.0") + "%";
                            }

                            lb3.Content = "0.0%";
                            if ((time_MoldOpen_Start < tmep) && (time_MoldClose_Start > 0))
                            {
                                lb3.Content = ((tmep - time_MoldOpen_Start) * 100 / tmep).ToString("0.0") + "%";
                            }

                            TotalMoldNumber = valmoWin.dv.PrdPr[96].value;
                        }
                    }
                    else
                    {
                        uint[] blocksCur = new uint[valmoWin.dv.PrdPr[267].value];

                        if (flagParseState == 2)
                        {
                            Lasal32.GetData(blocksCur, staticDataAddr, blocksCur.Length);
                        }
                        else
                        {
                            Lasal32.GetData(blocksCur, curDataAddr, blocksCur.Length);
                        }

                        int j = 0;

                        for (int i = 0; i < blocksCur.Length / 32; i++)
                        {
                            uint ActionName = blocksCur[i * 8 + 3];

                            switch (ActionName)
                            {
                                case 3:
                                    time_MoldOpen_Start = Convert.ToInt32(blocksCur[i * 8 + 4]);
                                    break;
                                case 2:
                                    time_MoldClose_Start = Convert.ToInt32(blocksCur[i * 8 + 4]);
                                    time_MoldClose = Convert.ToInt32(blocksCur[i * 8 + 5]) - Convert.ToInt32(blocksCur[i * 8 + 4]);
                                    break;
                                case 8:
                                    time_Injection = Convert.ToInt32(blocksCur[i * 8 + 5]) - Convert.ToInt32(blocksCur[i * 8 + 4]);
                                    break;
                                case 9:
                                    time_Holding = Convert.ToInt32(blocksCur[i * 8 + 5]) - Convert.ToInt32(blocksCur[i * 8 + 4]);
                                    break;
                                case 11:
                                    time_Cooling = Convert.ToInt32(blocksCur[i * 8 + 5]) - Convert.ToInt32(blocksCur[i * 8 + 4]);
                                    break;
                                default:
                                    break;
                            }

                            Anablocks sblockCur = new Anablocks();
                            sblockCur.Active = blocksCur[i * 8 + 1];
                            sblockCur.Move = blocksCur[i * 8 + 2];
                            sblockCur.Name = (typeName)ActionName;
                            sblockCur.tStart = Math.Round(valmoWin.dv.PrdPr[269].getDblValue(Convert.ToInt32(blocksCur[i * 8 + 4])), 3);
                            sblockCur.tEnd = Math.Round(valmoWin.dv.PrdPr[269].getDblValue(Convert.ToInt32(blocksCur[i * 8 + 5])), 3);
                            sblockCur.seqStart = blocksCur[i * 8 + 6];
                            sblockCur.seqEnd = blocksCur[i * 8 + 7];
                            Anablocks sblockBase = new Anablocks();
                            sblockBase.Active = blocksCur[i * 8 + 1];
                            sblockBase.Move = blocksCur[i * 8 + 1];
                            sblockBase.Name = (typeName)ActionName;
                            sblockBase.tStart = 0;
                            sblockBase.tEnd = 0;
                            sblockBase.seqStart = blocksCur[i * 8 + 6];
                            sblockBase.seqEnd = blocksCur[i * 8 + 7];

                            if (typeName.IsDefined(typeof(typeName), sblockCur.Name) && (sblockCur.Name != typeName.noactive))
                            {
                                lstBarCtrl[j].visiable = Visibility.Visible;
                                lstBarCtrl[j].type = sblockCur.Name;
                                lstBarCtrl[j].setCurAction(sblockCur);
                                lstBarCtrl[j].setBaseAction(sblockBase);
                                j++;
                            }
                        }

                        for (int i = j; i < 50; i++)
                        {
                            lstBarCtrl[i].visiable = Visibility.Hidden;
                        }

                        if (valmoWin.dv.PrdPr[96].value > TotalMoldNumber)
                        {
                            double tmep = valmoWin.dv.PrdPr[269].value;

                            if (tmep <= 0)
                            {
                                return;
                            }

                            lb1.Content = "0.0%";
                            if ((time_MoldClose < tmep) && (time_MoldClose > 0))
                            {
                                lb1.Content = ((time_MoldClose) * 100 / tmep).ToString("0.0") + "%";
                            }

                            lb2.Content = "0.0%";
                            if (time_Injection != 0)
                            {
                                lb2.Content = ((time_Injection + time_Holding + time_Cooling) * 100 / tmep).ToString("0.0") + "%";
                            }

                            lb3.Content = "0.0%";
                            if ((time_MoldOpen_Start < tmep) && (time_MoldClose_Start > 0))
                            {
                                lb3.Content = ((tmep - time_MoldOpen_Start) * 100 / tmep).ToString("0.0") + "%";
                            }

                            TotalMoldNumber = valmoWin.dv.PrdPr[96].value;
                        }
                    }
                }
                else
                {
                    cvsCursor.Visibility = Visibility.Hidden;
                }
            }
        }
        public void setCurAction(Anablocks curAction)
        {
            double cycleTime = valmoWin.dv.PrdPr[269].vDbl;

            if (curAction.seqEnd == curAction.seqStart)
            {
                if (curAction.tEnd < curAction.tStart)
                {
                    curAction.tEnd = curAction.tStart;
                }

                if (curAction.tStart > cycleTime)
                {
                    curAction.tStart = curAction.tEnd = cycleTime;
                }

                if (curAction.tEnd > cycleTime)
                {
                    curAction.tEnd = cycleTime;
                }

                double actionTime = curAction.tEnd - curAction.tStart;

                if (curAction.Move == 1)
                {
                    cvsMain.Background = new SolidColorBrush(Color.FromRgb(0xCB, 0xE5, 0xEA));
                }
                else
                {
                    cvsMain.Background = new SolidColorBrush(Color.FromRgb(220, 220, 220));

                    if (cycleTime > 0)
                    {
                        lbPer.Content = (100 * actionTime / cycleTime).ToString("0.0");
                    }
                }

                lbTimeBeginCur.Content = curAction.tStart.ToString("0.00");
                lbTimeContinueCur.Content = actionTime.ToString("0.00");
                lbTimeEndCur.Content = curAction.tEnd.ToString("0.00");

                lbCur.Content = actionTime.ToString("0.00");
                if (curAction.tStart * bdItemPage.sRate > 500)
                {
                    Canvas.SetRight(lbCur, 600 - curAction.tStart * bdItemPage.sRate);
                }
                else
                {
                    Canvas.SetLeft(lbCur, curAction.tStart * bdItemPage.sRate);
                }

                Canvas.SetLeft(prgCur, curAction.tStart * bdItemPage.sRate);
                prgCur.X2 = actionTime * bdItemPage.sRate;

                prgCur2.X2 = 0;
            }
            else if (curAction.seqEnd > curAction.seqStart)
            {
                if (curAction.tEnd > cycleTime)
                {
                    curAction.tEnd = cycleTime;
                }
                if (curAction.tStart > cycleTime)
                {
                    curAction.tStart = cycleTime;
                }

                double actionTime = cycleTime - curAction.tStart + curAction.tEnd;

                if (curAction.Move == 1)
                {
                    cvsMain.Background = new SolidColorBrush(Color.FromRgb(0xCB, 0xE5, 0xEA));
                }
                else
                {
                    cvsMain.Background = new SolidColorBrush(Color.FromRgb(220, 220, 220));

                    if (cycleTime > 0)
                    {
                        if (actionTime > cycleTime)
                        {
                            actionTime = cycleTime;
                        }
                        lbPer.Content = (100 * actionTime / cycleTime).ToString("0.0");
                    }
                }

                lbTimeBeginCur.Content = curAction.tStart.ToString("0.00");
                lbTimeContinueCur.Content = actionTime.ToString("0.00");
                lbTimeEndCur.Content = curAction.tEnd.ToString("0.00");

                lbCur.Content = actionTime.ToString("0.00");
                if (curAction.tStart * bdItemPage.sRate > 500)
                {
                    Canvas.SetRight(lbCur, 600 - curAction.tStart * bdItemPage.sRate);
                }
                else
                {
                    Canvas.SetLeft(lbCur, curAction.tStart * bdItemPage.sRate);
                }

                Canvas.SetLeft(prgCur, curAction.tStart * bdItemPage.sRate);
                prgCur.X2 = 600 - curAction.tStart * bdItemPage.sRate;

                prgCur2.X2 = curAction.seqEnd * bdItemPage.sRate;
            }
            else
            {
                return;
            }
        }