Ejemplo n.º 1
0
void CActuator::EvalCtrlStrategy(eScdCtrlTasks Tasks)
  {
  if (XRefListActive() && ICGetTimeInc() > 0.0)
    {

    //for (int i=0; i<NoCIOs(); i++)
    //  {
    //  int ac=IOId_Self(i);
    //  m_DataBlk[ac]->m_dReqdValue=CIO_Value(i);
    //  }

    //solve pgm functions...
    if (FnMngrPresent())
      {
      CGExecContext ECtx(this);
      ECtx.dIC_Time = ICGetTime();
      ECtx.dIC_dTime = ICGetTimeInc();
      ECtx.OnStart = bAboutToStart;
      ECtx.m_HoldNearXRefGet=true;
      ECtx.m_HoldNearXRefSet=true;
      FnMngr().Execute(ECtx);
      bAboutToStart = 0;
      if (ECtx.DoXStop)
        {
        LogError(Tag(), 0, "SysCAD stopped by function");
        ExecObj()->XStop();
        }
      if (ECtx.DoXIdle)
        {
        LogError(Tag(), 0, "SysCAD paused by function");
        ExecObj()->XIdle();
        }
      }

    //solve FlowStats...
    for (int i=0; i<m_DataBlk.GetSize(); i++)
      {
      CActuatorBlk * T = m_DataBlk[i];
      if (T->m_bValid)
        {
        //if (T->m_OutputVar.bIsFunct)
        //  {
        //  T->m_dOutputValue = T->m_OutputVar.pFunctVar->getD();
        //  }
        //else
        //  {
        //  CXRefItem& Meas = (T->m_OutputVar.bIsNear ? NearGCXRefs[T->m_OutputVar.iXRefIndex] : FarGCXRefs[T->m_OutputVar.iXRefIndex]);
        //  T->m_dOutputValue = Cnvs[Meas.iCnvIndex]->Human(Meas.dVal, Meas.sCnv());
        //  }

        T->m_InputVar.GetValue(T->m_dReqdValue);
        T->ExecIns(ICGetTimeInc());
        //if (T->m_OutputVar.bIsFunct)
        //  {
        //  T->m_dOutputValue = T->m_OutputVar.pFunctVar->getD();
        //  }
        //else
        //  {
        T->m_OutputVar.PutValue(T->m_dOutputValue);
        //  }
        int xxx=0;
        }
      }
    SetNearXRefValues();
    //for (i=0; i<m_NearXRefs.GetSize(); i++)
    //   m_NearXRefs[i]->SetNearXRefValue();
    }
  }
Ejemplo n.º 2
0
void CSlotConnect::Process(eConnSrcDst eSrc, long SrcI, eConnSrcDst eDst, long SrcDstI, CFullValue & SrcValue, int Direction)
  {
  // Always Executed as a SET - Hence the use of the ReflectedGets

  if (!m_bValid)
    return;

  if (eDst==eCSD_Default)
    eDst = m_eDst;

  switch (eDst)
    {
    case eCSD_Slot:
      {
      CFullValue V=SrcValue;
      ProcessOps(V);
      if (m_eSrc==eCSD_Link)
        ApplyRangeLink2Slot(*Slots[m_lDstIndex], V);
      gs_SlotMngr.AppendChange(eSrc, SrcI, eCSD_Slot, m_lDstIndex, -1, V, &m_Delay, false, !m_bConnect1Done);
      break;
      }
    case eCSD_CdBlk:
      {
      if (m_Delay.Configured())
        {
        CFullValue V=SrcValue;
        gs_SlotMngr.AppendChange(eSrc, SrcI, eCSD_SlotConn, SrcDstI, -1, V, &m_Delay, false, !m_bConnect1Done);
        break;
        }
      // FALL THROUGH
      }
    case eCSD_SlotConn:
      {
      CFullValue V=SrcValue;
      ProcessOps(V);
      if (m_bCdBlkVarFlt)
        {
        V.ChangeType(VT_R8);
        m_pCdBlkVar->set(V.m_vValue.dblVal);
        }
      else
        {
        V.ChangeType(VT_I4);
        m_pCdBlkVar->set(V.m_vValue.lVal);
        }
      // Execute pgm
      CGExecContext ECtx(NULL);
      m_pCdBlk->m_Code.Execute(ECtx);

      // Update Destination Tags
      for (int i=0; i<m_pCdBlk->m_ReflectedGets.GetSize(); i++)
        {
        CSlotConnect &C=(*m_pCdBlk->m_ReflectedGets[i]);
        if (C.m_bCdBlkVarFlt)
          {
          CFullValue D=V;
          D.m_vValue=C.m_pCdBlkVar->getD();
          C.ProcessOps(D);
          gs_SlotMngr.AppendChange(eCSD_CdBlk, C.m_lSrcIndex, C.m_eDst, C.m_lDstIndex, -1, D, &C.m_Delay, false, !m_bConnect1Done);
          }
        else
          {
          CFullValue L=V;
          L.m_vValue=C.m_pCdBlkVar->getL();
          C.ProcessOps(L);
          gs_SlotMngr.AppendChange(eCSD_CdBlk, C.m_lSrcIndex, C.m_eDst, C.m_lDstIndex, -1, L, &C.m_Delay, false, !m_bConnect1Done);
          }
        }
      break;
      }
    case eCSD_Link:
      {
      CFullValue V=SrcValue;
      if (m_eSrc==eCSD_Slot)
        ApplyRangeSlot2Link(*Slots[m_lSrcIndex], V);
      ProcessOps(V);
      gs_SlotMngr.AppendChange(eSrc, m_lSrcIndex, eDst, m_lDstIndex, -1, V, &m_Delay, false, !m_bConnect1Done);
      break;
      }
    default:
      ReportError("CSlotConnect::Process", 0, "Invalid Destination %s ", SrcDstString(eDst));
    }
  m_bConnect1Done=true;
  }