Exemple #1
0
 void CPUCycle_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     PLC_Basic.CPUBasic.SCPUResult res = (PLC_Basic.CPUBasic.SCPUResult)e.UserState;
     if (e.ProgressPercentage > 0)
     {
         m_CurError      = (eCPUError)e.ProgressPercentage;
         m_CurErrorInstr = res.Instr;
         m_bRunError     = true;
     }
     m_CycleTime = res.CycleTime;
 }
Exemple #2
0
        public int run()
        {
            if (!m_bRuns && !m_bPause)
            {
                CPUCycle.RunWorkerAsync(m_bPause);
                m_bRuns    = true;
                m_CurError = eCPUError.NONE;
                return(0);
            }

            return(1);
        }
Exemple #3
0
        private void cycle(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = ((BackgroundWorker)sender);

            while (true)
            {
                eCPUError RunError = eCPUError.NONE;
                if (worker.CancellationPending)
                {
                    return;
                }

                DateTime start = DateTime.Now;

                copyInput();

                while (m_iInstrPointer < m_byaInstrMemory.Length)
                {
                    for (int i = 0; i < 100000; i++)
                    {
                        double d = Math.Sqrt(25 * 25);
                    }

                    if (worker.CancellationPending)
                    {
                        return;
                    }

                    byte cmd     = m_byaInstrMemory[m_iInstrPointer];
                    uint iTarget = (uint)m_byaInstrMemory[m_iInstrPointer + 1] << 24;
                    iTarget |= (uint)m_byaInstrMemory[m_iInstrPointer + 2] << 16;
                    iTarget |= (uint)m_byaInstrMemory[m_iInstrPointer + 3] << 8;
                    iTarget |= (uint)m_byaInstrMemory[m_iInstrPointer + 4];

                    if (m_bLoop)
                    {
                        cmd      = m_byaInstrMemory[m_iLoopInstrAddress];
                        iTarget  = (uint)m_byaInstrMemory[m_iLoopInstrAddress + 1] << 24;
                        iTarget |= (uint)m_byaInstrMemory[m_iLoopInstrAddress + 2] << 16;
                        iTarget |= (uint)m_byaInstrMemory[m_iLoopInstrAddress + 3] << 8;
                        iTarget |= (uint)m_byaInstrMemory[m_iLoopInstrAddress + 4];
                    }

                    doInstr(cmd, iTarget, out RunError);

                    if (RunError != eCPUError.NONE)
                    {
                        break;
                    }
                }

                copyOutput();

                TimeSpan diff = DateTime.Now - start;
                PLC_Basic.CPUBasic.SCPUResult res = new CPUBasic.SCPUResult();
                res.CycleTime = diff;
                res.Instr     = (RunError != eCPUError.NONE ? m_iInstrPointer / PLC_Basic.CPUBasic.INSTR_SIZE : 0);

                m_iInstrPointer = 0;

                if (sender is BackgroundWorker)
                {
                    worker.ReportProgress((int)RunError, res);
                }

                if (RunError != eCPUError.NONE)
                {
                    worker.CancelAsync();
                }
            }
        }
Exemple #4
0
        public int run()
        {
            if (!m_bRuns && !m_bPause)
            {
                CPUCycle.RunWorkerAsync(m_bPause);
                m_bRuns = true;
                m_CurError = eCPUError.NONE;
                return 0;
            }

            return 1;
        }
Exemple #5
0
 void CPUCycle_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     PLC_Basic.CPUBasic.SCPUResult res = (PLC_Basic.CPUBasic.SCPUResult)e.UserState;
     if (e.ProgressPercentage > 0)
     {
         m_CurError = (eCPUError)e.ProgressPercentage;
         m_CurErrorInstr = res.Instr;
         m_bRunError = true;
     }
     m_CycleTime = res.CycleTime;
 }