Ejemplo n.º 1
0
void MeshNode::update(double deltaT) {
	sn_State* currentSNState = &sn_states[SimState::currentUpdateState];

	stateUpdate(deltaT);

	for(std::vector<scene_node*>::iterator it = currentSNState->children.begin(); it != currentSNState->children.end(); ++it) {
		(*it)->update(deltaT);
	}
}
Ejemplo n.º 2
0
void DkCamControls::updateLiveViewImage() {
	stateUpdate();

	try {
		// TODO: get the plugin viewport here?!
		//viewport->setImage(maidFacade->getLiveViewImage());
		emit updateImage(maidFacade->getLiveViewImage());
		qDebug() << "live view image updated...";

	} catch (Maid::MaidError) {
		// do nothing
	}
}
Ejemplo n.º 3
0
void EventQueue::flushStateUpdates() const {
  std::vector<StateUpdate> stateUpdateQueue;

  {
    std::lock_guard<std::mutex> lock(queueMutex_);

    if (stateUpdateQueue_.size() == 0) {
      return;
    }

    stateUpdateQueue = std::move(stateUpdateQueue_);
    stateUpdateQueue_.clear();
  }

  for (const auto &stateUpdate : stateUpdateQueue) {
    auto pair = stateUpdate();
    statePipe_(pair.second, pair.first);
  }
}
Ejemplo n.º 4
0
void CBaseChar::update()
{
	//중력 계산
	colliderUpdate();
	//보는것 계산
	lookUpdate();
	//애니움직임
	aniUpdate();
	//스테이트로 움직임
	stateUpdate();
	//최종 벡터 연산
	moveUpdate();

	//무기 발사
	weaponUpdate();

	attackUpdate();

}
Ejemplo n.º 5
0
void
TranzportClient::documentChanged(RosegardenDocument* doc)
{
    RG_DEBUG << "TranzportClient::DocumentChanged " << endl;

    m_rgDocument = doc;
    m_composition = &m_rgDocument->getComposition();
    m_composition->addObserver(this);
    connect(m_rgDocument, SIGNAL(pointerPositionChanged(timeT)),
            this, SLOT(pointerPositionChanged(timeT)));
    connect(m_rgDocument, SIGNAL(loopChanged(timeT,timeT)),
            this, SLOT(loopChanged(timeT,timeT)));
    connect(this, SIGNAL(setPosition(timeT)),
            m_rgDocument, SLOT(slotSetPointerPosition(timeT)));
                
    while (not commands.empty()) {
        commands.pop();
    }
    stateUpdate();
}
Ejemplo n.º 6
0
void DkCamControls::connectDevice() {
	
	if (connected) {
		closeDeviceAndSetState();
		return;
	}

	connectDeviceDialog.reset(new ConnectDeviceDialog(maidFacade, this));
	stateUpdate(); // avoid delay
	if (connectDeviceDialog->exec() == QDialog::Accepted && connectDeviceDialog->getSelectedId().second) {
		try {
			openDeviceProgressDialog.reset(new OpenDeviceProgressDialog(this));

			connectedDeviceId = connectDeviceDialog->getSelectedId();
			openDeviceThread.reset(new OpenDeviceThread(maidFacade, connectedDeviceId.first));
			connect(openDeviceThread.get(), SIGNAL(finished()), this, SLOT(onDeviceOpened()));
			connect(openDeviceThread.get(), SIGNAL(error()), this, SLOT(onOpenDeviceError()));
			openDeviceThread->start();
			openDeviceProgressDialog->exec();
		} catch (Maid::MaidError e) {
			onOpenDeviceError();
		}
	}
}
Ejemplo n.º 7
0
TranzportClient::TranzportClient(RosegardenMainWindow* rgGUIApp) :
    QObject(),
    device_online(true),
    previous_buttons(*reinterpret_cast<uint32_t*>(previousbuf+2)),
    current_buttons(*reinterpret_cast<uint32_t*>(currentbuf+2)),
    datawheel(currentbuf[6]),
    status(currentbuf[1]),
    m_rgGUIApp(rgGUIApp),
    m_rgDocument(rgGUIApp->getDocument()),
    m_composition(&m_rgDocument->getComposition())
{
    m_descriptor = open("/dev/tranzport0",O_RDWR);
    
    if (m_descriptor < 0) {
        throw Exception(qstrtostr(QObject::tr("Failed to open tranzport device /dev/tranzport0")));
    }

    bzero(currentbuf,8);
    bzero(previousbuf,8);

    fcntl(m_descriptor,F_SETOWN, getpid());
    int socketFlags = fcntl(m_descriptor, F_GETFL, 0);
    if (socketFlags != -1) {
        fcntl(m_descriptor, F_SETFL, socketFlags | O_NONBLOCK);
    }

    m_socketReadNotifier = new QSocketNotifier(m_descriptor, QSocketNotifier::Read, 0);
    m_socketWriteNotifier = new QSocketNotifier(m_descriptor, QSocketNotifier::Write,0);

    connect(m_socketReadNotifier, SIGNAL(activated(int)), this, SLOT(readData()));
    connect(m_socketWriteNotifier, SIGNAL(activated(int)), this, SLOT(writeCommandQueue()));
        
    connect(this, SIGNAL(play()),
            m_rgGUIApp, SLOT(slotPlay()) );
    connect(this, SIGNAL(stop()),
            m_rgGUIApp, SLOT(slotStop()) );
    connect(this, SIGNAL(record()),
            m_rgGUIApp, SLOT(slotRecord()) );
    connect(this, SIGNAL(rewind()),
            m_rgGUIApp, SLOT(slotRewind()) );
    connect(this, SIGNAL(rewindToBeginning()),
            m_rgGUIApp, SLOT(slotRewindToBeginning()) );
    connect(this, SIGNAL(fastForward()),
            m_rgGUIApp, SLOT(slotFastforward()) );
    connect(this, SIGNAL(fastForwardToEnd()),
            m_rgGUIApp, SLOT(slotFastForwardToEnd()) );
    connect(this, SIGNAL(toggleRecord()),
            m_rgGUIApp, SLOT(slotToggleRecord()) );
    connect(this, SIGNAL(trackDown()),
            m_rgGUIApp, SLOT(slotTrackDown()) );
    connect(this, SIGNAL(trackUp()),
            m_rgGUIApp, SLOT(slotTrackUp()) );
    connect(this, SIGNAL(trackMute()),
            m_rgGUIApp, SLOT(slotToggleMute()) );
    connect(this, SIGNAL(trackRecord()),
            m_rgGUIApp, SLOT(slotToggleRecordCurrentTrack()) );
    connect(this, SIGNAL(solo(bool)),
            m_rgGUIApp, SLOT(slotToggleSolo(bool)));

    connect(m_rgGUIApp, SIGNAL(documentChanged(RosegardenDocument*)),
            this, SLOT(documentChanged(RosegardenDocument*)));

    connect(m_rgDocument, SIGNAL(pointerPositionChanged(timeT)),
            this, SLOT(pointerPositionChanged(timeT)));

    connect(m_rgDocument, SIGNAL(loopChanged(timeT,timeT)),
            this, SLOT(loopChanged(timeT,timeT)));

    connect(this, SIGNAL(undo()),
            CommandHistory::getInstance(),SLOT(undo()));

    connect(this, SIGNAL(redo()),
            CommandHistory::getInstance(), SLOT(redo()));

    connect(this, SIGNAL(setPosition(timeT)),
            m_rgDocument, SLOT(slotSetPointerPosition(timeT)));

    m_composition->addObserver(this);
    m_socketWriteNotifier->setEnabled(false);
    stateUpdate();

    RG_DEBUG << "TranzportClient::TranzportClient: connected to tranzport device: " << m_descriptor << endl;
}
Ejemplo n.º 8
0
void
TranzportClient::readData()
{
    memcpy(previousbuf, currentbuf, 8);
    ssize_t val;
    static timeT loop_start_time=0;
    static timeT loop_end_time=0;

    while ((val=read(m_descriptor,currentbuf,8)) == 8) {
        uint32_t new_buttons = current_buttons ^ previous_buttons;
        if (status == 0x1) {
            RG_DEBUG << "TranzportClient: device just came online";

            while (not commands.empty()) {
                commands.pop();
            }
            device_online = true;

            m_rgDocument = m_rgGUIApp->getDocument();
            m_composition = &m_rgGUIApp->getDocument()->getComposition();
            stateUpdate();
        }

        if (status == 0xff) {
            RG_DEBUG << "TranzportClient: device just went offline";

            device_online = false;
            return;
        }

        if (new_buttons & TrackSolo  and
            current_buttons & TrackSolo) {
            if (current_buttons & Shift) {
                bool soloflag = m_composition->isSolo();
                emit solo(not soloflag);
            }
        }

        if (new_buttons & Add  and
            current_buttons & Add) {
            if (current_buttons & Shift) {
            } else {
                AddMarkerCommand* cmd = new AddMarkerCommand(m_composition,
                                                             m_composition->getPosition(),
                                                             "tranzport",
                                                             "");
                CommandHistory::getInstance()->addCommand(cmd);
            }
        }

        if (new_buttons & Prev  and
            current_buttons & Prev) {
            RG_DEBUG << "TranzportClient:: received marker previous";

            if (current_buttons & Shift) {
            } else {
                timeT currentTime = m_composition->getPosition();
                Composition::markercontainer& mc = m_composition->getMarkers();
                timeT closestPrevious = -1;

                for (Composition::markerconstiterator it = mc.begin();
                     it != mc.end();
                     ++it) {
                    timeT markerTime = (*it)->getTime();
                    if (markerTime < currentTime  and
                        markerTime > closestPrevious) {
                        closestPrevious = markerTime;
                    }
                }

                if (closestPrevious >= 0) {
                    RG_DEBUG << "Tranzport:: setting position: " << closestPrevious;

                    emit setPosition(closestPrevious);
                }
            }
        }

        if (new_buttons & Next  and
            current_buttons & Next)
        {
            RG_DEBUG << "TranzportClient:: received marker next";

            if (current_buttons & Shift) {
            } else {
                timeT currentTime = m_composition->getPosition();
                Composition::markercontainer& mc = m_composition->getMarkers();
                timeT closestNext = std::numeric_limits<long>::max();
                
                for (Composition::markerconstiterator it = mc.begin();
                     it != mc.end();
                     ++it) {
                    timeT markerTime = (*it)->getTime();
                    if (markerTime > currentTime and
                        markerTime < closestNext) {
                        closestNext = markerTime;
                    }
                }

                if (closestNext < std::numeric_limits<long>::max()) {
                    RG_DEBUG << "Tranzport:: setting position: " << closestNext;

                    emit setPosition(closestNext);
                }
            }
        }

        if (new_buttons & Undo  and
            current_buttons & Undo) {
            if (current_buttons & Shift) {
                emit redo();
            } else {
                emit undo();
            }
        }

        if (new_buttons & Play  and
            current_buttons & Play) {
            if (current_buttons & Shift) {
            } else {
                emit play();
            }
        }

        if (new_buttons & Stop  and
            current_buttons & Stop) {
            if (current_buttons & Shift) {
            } else {
                emit stop();
            }
        }

        if (new_buttons & Record  and
            current_buttons & Record) {
            if (current_buttons & Shift) {
            } else {
                emit record();
            }
        }

        if (new_buttons & Loop  and
            current_buttons & Loop) {
            if (current_buttons & Shift) {
            } else {
                loop_start_time = m_composition->getPosition();
                loop_end_time = loop_start_time;
            }
        }

        if (new_buttons & Loop  and
            (not (current_buttons & Loop))) {
            if (current_buttons & Shift) {
            } else {
                if (loop_start_time == loop_end_time) {
                    m_rgDocument->setLoop(0,0);
                }

                loop_start_time = 0;
                loop_end_time = 0;
            }
        }

        if (new_buttons& Rewind  and
            current_buttons & Rewind) {
            if (current_buttons&Shift) {
                emit rewindToBeginning();
            } else {
                emit rewind();
            }
        }

        if (new_buttons & FastForward  and
            current_buttons & FastForward) {
            if (current_buttons & Shift) {
                emit fastForwardToEnd();
            } else {
                emit fastForward();
            }
        }

        if (new_buttons & TrackRec  and
            current_buttons & TrackRec) {
            if (current_buttons & Shift) {
            } else {
                emit trackRecord();
            }
        }

        if (new_buttons & TrackRight  and
            current_buttons & TrackRight) {
            if (current_buttons & Shift) {
            } else {
                emit trackDown();
            }
        }

        if (new_buttons & TrackLeft  and
            current_buttons & TrackLeft) {
            if (current_buttons& Shift) {
            } else {
                emit trackUp();
            }
        }

        if (new_buttons & TrackMute  and
            current_buttons & TrackMute) {
            if (current_buttons & Shift) {
            } else {
                emit trackMute();
            }
        }

        if (datawheel) {
            if (datawheel < 0x7F) {
                if (current_buttons & Loop) {
                    loop_end_time += datawheel *
                        m_composition->getDurationForMusicalTime(loop_end_time, 0,1,0,0);
                    m_rgDocument->setLoop(loop_start_time, loop_end_time);
                } else if(current_buttons & Shift) {
                    timeT here = m_composition->getPosition();
                    here += datawheel * m_composition->getDurationForMusicalTime(here,0,0,1,0);
                    if (here <= m_composition->getEndMarker()) {
                        emit setPosition(here);
                    }
                } else {
                    timeT here = m_composition->getPosition();
                    here += datawheel * m_composition->getDurationForMusicalTime(here,0,1,0,0);
                    if (here <= m_composition->getEndMarker()) {
                        emit setPosition(here);
                    }
                }
            } else {
#define DATAWHEEL_VALUE (1 + (0xFF - (datawheel)))
                if (current_buttons & Loop) {
                    loop_end_time -= (1 + (0xFF - datawheel)) *
                        m_rgGUIApp->getDocument()->getComposition().getDurationForMusicalTime(loop_end_time, 0,1,0,0);
                    m_rgDocument->setLoop(loop_start_time, loop_end_time);
                }

                if (current_buttons & Shift) {
                    timeT here = m_composition->getPosition();
                    here -= DATAWHEEL_VALUE *  m_composition->getDurationForMusicalTime(here,0,0,1,0);
                    if (here >= m_composition->getStartMarker()) {
                        emit setPosition(here);
                    }
                } else {
                    timeT here = m_composition->getPosition();
                    here -= DATAWHEEL_VALUE *  m_composition->getDurationForMusicalTime(here,0,1,0,0);
                    if (here >= m_composition->getStartMarker()) {
                        emit setPosition(here);
                    }
                }
#undef DATAWHEEL_VALUE
            }
        }

        memcpy(previousbuf, currentbuf, 8);
    }

    if (val == -1) {
        if (errno == EAGAIN) {
            return;
        } else {
            RG_DEBUG << "TranzportClient::readData: error " << strerror(errno);
        }
    } else {
        RG_DEBUG << "TranzportClient::readData: partial read of length " << val;
        RG_DEBUG << "TranzportClient::readData: this should not happen " << val;
    }
}
Ejemplo n.º 9
0
void Motor::processCanMsg(int cmdID, unsigned char data[])
{
    if(cmdID == TPDO3_COBID) //0x380(896D) - trace response
    {
        long tmp_curr = data[5];
        Current = (tmp_curr << 8) + data[4];

        PositionRaw = pcanData2Double(data,0);
        PositionGrad = PositionRaw*360/jointReduction;
        Position = ((double) PositionGrad)*PI/180.0;

        long long actualTime = llround(KAL::GetTime());
        VelocityRaw = (long)(PositionRaw - OldPositionRaw)/((actualTime - updateTime)*1E-9);
        Velocity = VelocityRaw*2*PI/jointReduction;

        OldPositionRaw = PositionRaw;
        OldPosition = Position;
        updateTime = actualTime;
        //KAL::DebugConsole::Write(LOG_LEVEL_NOTICE, "States Update", "ID = %X,  curr = %X%X, pos = %X%X%X%X", ID, data[5], data[4], data[3], data[2], data[1], data[0] );

    }//if(cmdID == TPDO3_COBID)
    else if(cmdID == TPDO2_COBID) //0x280(640D) - TxPDO2 response
    {
        if(data[0] == 0x2B)
        {
            Velocity = pcanData2Double(data,1)*360/jointReduction;
            KAL::DebugConsole::Write(LOG_LEVEL_NOTICE, "States Update", "ID = %X,  vel = %X%X%X%X", ID, data[4], data[3], data[2], data[1]);
        }
        else if(data[0] == 0x40)
        {
            PositionGrad = pcanData2Double(data,1)*360/jointReduction;
            KAL::DebugConsole::Write(LOG_LEVEL_NOTICE, "States Update", "ID = %X,  pos = %X%X%X%X", ID, data[4], data[3], data[2], data[1]);
        }
    }//else if(cmdID == TPDO2_COBID)
    else if(cmdID == TPDO1_COBID) //0x180(384D) - TxPDO1 (statusWord)
    {
        stateUpdate(data);

        if(stateChanged())
            switch(State & STATUS_WORD_MASK){
            case SWITCH_ON_DISABLED:
                KAL::DebugConsole::Write(LOG_LEVEL_NOTICE, TRIGGERTASK_NAME, "Motor %d Switch On Disabled.", ID);
                break;
            case READY_TO_SWITCH_ON:
                KAL::DebugConsole::Write(LOG_LEVEL_NOTICE, TRIGGERTASK_NAME, "Motor %d Ready to Switch On.", ID);
                break;
            case SWITCHED_ON:
                KAL::DebugConsole::Write(LOG_LEVEL_NOTICE, TRIGGERTASK_NAME, "Motor %d Switched On.", ID);
                break;
            case OPERATION_ENABLED:
                KAL::DebugConsole::Write(LOG_LEVEL_NOTICE, TRIGGERTASK_NAME, "Motor %d Operation Enabled.", ID);
                break;
            case FAULT_STATE:
                KAL::DebugConsole::Write(LOG_LEVEL_NOTICE, TRIGGERTASK_NAME, "Motor %d Fault Detected. Reset Motor.", ID);
                break;
            case QUICKSTOP:
                break;
            default:
                break;
            }

    } else if(cmdID == BOOTUP_COBID) //0x700 (1972D) - Boot up message
    {
        BootUp = true;
        KAL::DebugConsole::Write(LOG_LEVEL_NOTICE, TRIGGERTASK_NAME, "Motor %d booted up.", ID);
    }
}
Ejemplo n.º 10
0
//==============================================================================
//
//==============================================================================
void MBMasterWidget::setMBMaster( MBMasterXMLPtr mm )
{
  mbmaster = mm;
  connect( mm.get(), SIGNAL( stateChanged() ), SLOT( stateUpdate() ),Qt::QueuedConnection);
}