Exemplo n.º 1
0
void CPicoServSession::sendDebug()
{
#ifdef __DEBUG_PRINT
	char *str = debugString();
	// send current config to client
	currentConfig.iPicoOpt = PicoOpt;
	TPtrC8 descr((TUint8*) str, 1024);
	Write(Message().Ptr0(), descr);
#endif
}
Exemplo n.º 2
0
QAction* Shortcut::action() const
      {
      if (_action)
            return _action;

      if (_state == STATE_NEVER)
            return 0;

      _action = new QAction(_text, 0);
      _action->setData(_key);
      _action->setIconVisibleInMenu (false);

      if (_keys.isEmpty())
            _action->setShortcuts(_standardKey);
      else
            _action->setShortcuts(_keys);

      _action->setShortcutContext(_context);
      if (_help) {
            _action->setToolTip(help());
            _action->setWhatsThis(help());
            }
      else {
            _action->setToolTip(descr());
            _action->setWhatsThis(descr());
            }
      QList<QKeySequence> kl = _action->shortcuts();
      if (!kl.isEmpty()) {
            QString s(_action->toolTip());
            s += " (";
            for (int i = 0; i < kl.size(); ++i) {
                  if (i)
                        s += ",";
//                  s += kl[i].toString(QKeySequence::NativeText);
                  s += Shortcut::keySeqToString(kl[i], QKeySequence::NativeText);
                  }
            s += ")";
            _action->setToolTip(s);
            }
      if (_icon != -1)
            _action->setIcon(*icons[_icon]);
      return _action;
      }
Exemplo n.º 3
0
void Playtree::onUpdateCurrent( bool b_active )
{
    if( b_active )
    {
        playlist_Lock( m_pPlaylist );

        playlist_item_t* current = playlist_CurrentPlayingItem( m_pPlaylist );
        if( !current )
        {
            playlist_Unlock( m_pPlaylist );
            return;
        }

        Iterator it = findById( current->i_id );
        if( it != m_children.end() )
        {
            it->setPlaying( true );

            tree_update descr(
                tree_update::ItemUpdated, IteratorVisible( it, this ) );
            notify( &descr );
        }

        playlist_Unlock( m_pPlaylist );
    }
    else
    {
        for( Iterator it = m_children.begin(); it != m_children.end();
             it = getNextItem( it ) )
        {
            if( it->isPlaying() )
            {
                it->setPlaying( false );

                tree_update descr(
                    tree_update::ItemUpdated, IteratorVisible( it, this ) );
                notify( &descr );
                break;
            }
        }
    }
}
Exemplo n.º 4
0
std::string CVideoSyncD3D::GetErrorDescription(HRESULT hr)
{
  WCHAR buff[1024];
  DXGetErrorDescription(hr, buff, 1024);
  std::wstring error(DXGetErrorString(hr));
  std::wstring descr(buff);
  std::wstring errMsgW = StringUtils::Format(L"%s: %s", error.c_str(), descr.c_str());
  std::string errMsg;
  g_charsetConverter.wToUTF8(errMsgW, errMsg);
  return errMsg;
}
Exemplo n.º 5
0
void CPicoServSession::changeConfig()
{
	DEBUGPRINT(_L("got new config."));

	// receve it
	const TAny* pD=Message().Ptr0();
	TPtr8 descr((TUint8*) &currentConfig, sizeof(currentConfig));
	TRAPD(res,Message().ReadL(pD, descr));
	if (res!=KErrNone) {
		PanicClient(EBadDescriptor);
		return;
	}

	// Motorola: enable experimental volume control
	if((machineUid&0xfffffff0) == 0x101f6b20) { // Motorolas
		if(currentConfig.iFlags & 0x40) {
			currentConfig.iKeyBinds[11]  =  0x00100000; // vol up
			currentConfig.iKeyBinds[12]  =  0x00200000; // vol down
			keyConfigMotA[11].flags |=  0x40; // add "not configurable" flag
			keyConfigMotA[12].flags |=  0x40;
		} else {
			currentConfig.iKeyBinds[11] &= ~0x00100000; // remove vol actions
			currentConfig.iKeyBinds[12] &= ~0x00200000;
			keyConfigMotA[11].flags &= ~0x40; // remove "not configurable" flag
			keyConfigMotA[12].flags &= ~0x40;
		}
	}

	// set region, PicoOpt and rate
	PicoRegionOverride = currentConfig.PicoRegion;
	PicoOpt = currentConfig.iPicoOpt;
	switch((currentConfig.iFlags>>3)&3) {
		case 1:  PsndRate=11025; break;
		case 2:  PsndRate=16000; break;
		case 3:  PsndRate=22050; break;
		default: PsndRate= 8000; break;
	}

	// 6 button pad, enable XYZM config if needed
	if(PicoOpt & 0x20) {
		actionNames[8]  = "Z";
		actionNames[9]  = "Y";
		actionNames[10] = "X";
		actionNames[11] = "MODE";
	} else {
		actionNames[8] = actionNames[9] = actionNames[10] = actionNames[11] = 0;
	}

	// if we are in center 90||270 modes, we can bind renderer switcher
	if(currentConfig.iScreenMode == TPicoConfig::PMCenter &&
		(currentConfig.iScreenRotation == TPicoConfig::PRot90 || currentConfig.iScreenRotation == TPicoConfig::PRot270))
				 actionNames[25] = "RENDERER";
			else actionNames[25] = 0;
}
Exemplo n.º 6
0
CharacterDescriptor StrokesMatcher::loadNextCharacterStrokeData(const QString &s)
{
    QChar c=s.at(0);
    int numStrokes=s.length()-1;
    QList<int> strokes;
    for (int i=1; i<=numStrokes;i++) {
        strokes.append(s.mid(i,1).toInt());
    }
    CharacterDescriptor descr(strokes);
    descr.setCharacter(c);
    descr.setStrokeCount(numStrokes);
    return descr;
}
Exemplo n.º 7
0
//-------------------------------------------------------------------------------------
RangeTriggerNode::RangeTriggerNode(RangeTrigger* pRangeTrigger, float xz, float y):
RangeNode(NULL),
range_xz_(xz),
range_y_(y),
old_range_xz_(range_xz_),
old_range_y_(range_y_),
pRangeTrigger_(pRangeTrigger)
{
	flags(RANGENODE_FLAG_HIDE);

#ifdef _DEBUG
	descr((boost::format("RangeTriggerNode(origin=%1%->%2%)") % pRangeTrigger_->origin() % pRangeTrigger_->origin()->descr()).str());
#endif

	static_cast<EntityRangeNode*>(pRangeTrigger_->origin())->addWatcherNode(this);
}
Exemplo n.º 8
0
        inline void Add(const Stroka& key, TInputStream* src) {
            if (Dict_.find(key) != Dict_.end()) {
                ythrow yexception() << "key " <<  ~key << " already stored";
            }

            TLengthCalc out(Out_);
            TZLibCompress compress(&out);

            TransferData(src, &compress);
            compress.Finish();

            TArchiveRecordDescriptorRef descr(new TArchiveRecordDescriptor(Off_, out.Length(), key));

            Dict_[key] = descr;
            Off_ += out.Length();
        }
Exemplo n.º 9
0
//-------------------------------------------------------------------------------------
RangeTriggerNode::RangeTriggerNode(RangeTrigger* pRangeTrigger, float xz, float y):
CoordinateNode(NULL),
range_xz_(xz),
range_y_(y),
old_range_xz_(range_xz_),
old_range_y_(range_y_),
pRangeTrigger_(pRangeTrigger)
{
	flags(COORDINATE_NODE_FLAG_HIDE);

#ifdef _DEBUG
	descr((fmt::format("RangeTriggerNode(origin={:p}->{})", 
		(void*)pRangeTrigger_->origin(), pRangeTrigger_->origin()->descr())));
#endif

	static_cast<EntityCoordinateNode*>(pRangeTrigger_->origin())->addWatcherNode(this);
}
Exemplo n.º 10
0
static eString getEPGTitle()
{
	eServiceReference &ref = eServiceInterface::getInstance()->service;

	eString descr(_("no description is available"));

	EITEvent *tmp=eEPGCache::getInstance()->lookupEvent((eServiceReferenceDVB&)ref);

	if(tmp)
	{
		LocalEventData led;
		eString text;
		led.getLocalData(tmp, &descr, &text);
		if (text)
			descr += " - " + text;
		delete tmp;
	}
	return descr;
}
Exemplo n.º 11
0
ini() {
    int actres, tim[2];
    unsigned rand();

    loadcm();

    if( (F1=fopen("frozen.adv","rb")) != NULL ) {
        loadfr();

    } else {
        time( tim );  srand( tim[1] );
        loc=1;
        rndini=rand();
        actfla=1;
        actres=act(tiniti,0);
        actfla=0;
    }
    descr();

}
Exemplo n.º 12
0
void Playtree::onDelete( int i_id )
{
    Iterator it = findById( i_id ) ;
    if( it != m_children.end() )
    {
        VarTree* parent = it->parent();
        if( parent )
        {
            tree_update descr(
                tree_update::DeletingItem, IteratorVisible( it, this ) );
            notify( &descr );

            parent->removeChild( it );
            m_allItems.erase( i_id );

            tree_update descr2(
                tree_update::ItemDeleted, end() );
            notify( &descr2 );
        }
    }
}
Exemplo n.º 13
0
  /* package */void TypeExtensionManager::LoadTesters(
      std::vector<IPropertyTester::Pointer>& result, const std::string& typeName)
  {
    if (fConfigurationElementMap == 0)
    {
      fConfigurationElementMap = new std::map<std::string, std::vector<IConfigurationElement::Pointer> >();
      IExtensionPointService::Pointer registry(Platform::GetExtensionPointService());
      IConfigurationElement::vector ces(
        registry->GetConfigurationElementsFor("org.blueberry.core.expressions." + fExtensionPoint));
      for (unsigned int i= 0; i < ces.size(); i++)
      {
        IConfigurationElement::Pointer config(ces[i]);
        std::string typeAttr;
        config->GetAttribute(TYPE, typeAttr);
        std::vector<IConfigurationElement::Pointer> typeConfigs = (*fConfigurationElementMap)[typeAttr];
        typeConfigs.push_back(config);
      }
    }
    //std::string typeName= type.getName();
    std::vector<IConfigurationElement::Pointer> typeConfigs = (*fConfigurationElementMap)[typeName];

    for (unsigned int i= 0; i < typeConfigs.size(); i++)
    {
      IConfigurationElement::Pointer config(typeConfigs[i]);
      try
      {
        IPropertyTester::Pointer descr(new PropertyTesterDescriptor(config));
        result.push_back(descr);
      }
      catch (CoreException e)
      {
        //TODO
        //ExpressionPlugin.getDefault().getLog().log(e.getStatus());
        IPropertyTester::Pointer nullTester(new NULL_PROPERTY_TESTER_());
        result.push_back(nullTester);
      }
    }
    fConfigurationElementMap->erase(typeName);

  }
Exemplo n.º 14
0
int main(int argc, const char **argv)
{
  int retval = 0;

  std::string camera_ip;
  uint32_t xmlrpc_port;
  std::string password;
  std::string descr("o3d3xx Viewer");

  try
    {
      //---------------------------------------------------
      // Handle command-line arguments
      //---------------------------------------------------
      o3d3xx::CmdLineOpts opts(descr);
      if (! opts.Parse(argc, argv, &camera_ip, &xmlrpc_port, &password))
        {
          return 0;
        }

      //---------------------------------------------------
      // Initialize the camera
      //---------------------------------------------------
      o3d3xx::Camera::Ptr cam =
        std::make_shared<o3d3xx::Camera>(camera_ip, xmlrpc_port, password);

      //---------------------------------------------------
      // Run the viewer
      //---------------------------------------------------
      O3DViewer viewer(cam, descr);
      viewer.Run();
    }
  catch (const std::exception& e)
    {
      std::cerr << e.what() << std::endl;
      return 1;
    }

  return retval;
}
Exemplo n.º 15
0
void MainScreen(char *InstallName) {
   char fromdrive[2], todrive[3], tmp1[3], topath[9], tmp[9], drive[2];
   EditClass EditToDrive(WINDOW_LEFT+26,WINDOW_TOP+3,1, DEF_DRIVE);
   EditClass EditPath(WINDOW_LEFT+32,WINDOW_TOP+4,8, DEF_DIRECTORY);
   char ok;

   sprintf(fromdrive, "%c", getdisk()+'A');
   strcpy(todrive, "C");
   strcpy(tmp, "\\EDIR");
   _setcursortype(_NORMALCURSOR);
   putxy(WINDOW_LEFT+3,WINDOW_TOP+2,0,STANDARD,"Installing from drive %c:", fromdrive[0]);
   putxy(WINDOW_LEFT+3,WINDOW_TOP+3,0,STANDARD,"Install to what drive?  :");
   putxy(WINDOW_LEFT+3,WINDOW_TOP+4,0,STANDARD,"Install to what directory?  :", topath);
   EditToDrive.Display();
   EditPath.Display();
   putxy(WINDOW_LEFT+30, WINDOW_TOP+4, 0, STANDARD, "%c", toupper(todrive[0]));
   strcpy(todrive, EditToDrive.GetInput());
   putxy(WINDOW_LEFT+30, WINDOW_TOP+4, 0, STANDARD, "%c", toupper(todrive[0]));
   strcpy(tmp, EditPath.GetInput());
   descr(NULL);
   sprintf(topath, "%c:%s", todrive[0], tmp);
   putxy(WINDOW_LEFT+3,WINDOW_TOP+5,0,STANDARD,"Is this ok (Y/N/Q)? ");
   ok = (int) tolower((char) getch());
   if(ok == 121) {
      if(CheckDrive(todrive[0], "Invalid disk drive to copy files to") == 1) {
	 _setcursortype(_NOCURSOR);
	 putxy(WINDOW_LEFT+3,WINDOW_TOP+5,0,STANDARD,"Please wait...installing files...");
	 sprintf(tmp1, "%c:", fromdrive[0]);
	 docopy(tmp1, topath, InstallName);
	 getch();
      }
      else MainScreen(InstallName);
   }
   else if(ok == 113);
   else {
      putxy(WINDOW_LEFT+3,WINDOW_TOP+5,0,STANDARD,"%s", space(20));
      MainScreen(InstallName);
   }
}
Exemplo n.º 16
0
void Playtree::onAppend( int i_id )
{
    playlist_item_t *pItem;

    playlist_Lock( m_pPlaylist );
    pItem = playlist_ItemGetById( m_pPlaylist, i_id );
    if( !pItem || !pItem->p_parent )
    {
        playlist_Unlock( m_pPlaylist );
        return;
    }

    Iterator it_node = findById( pItem->p_parent->i_id );
    if( it_node == m_children.end() )
    {
        playlist_Unlock( m_pPlaylist );
        return;
    }

    int pos;
    for( pos = 0; pos < pItem->p_parent->i_children; pos++ )
        if( pItem->p_parent->pp_children[pos] == pItem ) break;

    UString *pName = getTitle( pItem->p_input );
    playlist_item_t* current = playlist_CurrentPlayingItem( m_pPlaylist );

    Iterator it = it_node->add(
        i_id, UStringPtr( pName ), false, pItem == current,
        false, pItem->i_flags & PLAYLIST_RO_FLAG, pos );

    m_allItems[i_id] = &*it;

    playlist_Unlock( m_pPlaylist );

    tree_update descr( tree_update::ItemInserted,
                       IteratorVisible( it, this ) );
    notify( &descr );
}
Exemplo n.º 17
0
void Playtree::onUpdateItem( int id )
{
    Iterator it = findById( id );
    if( it != m_children.end() )
    {
        // Update the item
        playlist_Lock( m_pPlaylist );
        playlist_item_t *pNode =
            playlist_ItemGetById( m_pPlaylist, it->getId() );
        if( !pNode )
        {
            playlist_Unlock( m_pPlaylist );
            return;
        }

        UString *pName = getTitle( pNode->p_input );
        playlist_Unlock( m_pPlaylist );

        if( *pName != *(it->getString()) )
        {
            it->setString( UStringPtr( pName ) );

            tree_update descr(
                tree_update::ItemUpdated, IteratorVisible( it, this ) );
            notify( &descr );
        }
        else
        {
            delete pName;
        }

    }
    else
    {
        msg_Warn( getIntf(), "cannot find node with id %d", id );
    }
}
Exemplo n.º 18
0
int CCommand::Execute (std::vector <std::string> const& args)
{
  po::options_description descr (GetOptionsDescription ());
  descr.add (GetHiddenDescription ());
  descr.add (CFormatterFactory::GetOptionsDescription());

  po::parsed_options opts = po::command_line_parser(args)
    .options(descr)
    .positional(GetPositionalOptionsDescription ())
    .extra_parser(cmd_line_utils::vss_option_parser (descr))
    .run();
  po::store (opts, m_VariablesMap);
  po::notify(m_VariablesMap);   

  // extract the arguments from the parsed command line
  std::vector<po::option> arguments;
  std::remove_copy_if(opts.options.begin(), opts.options.end(), 
    std::back_inserter(arguments), cmd_line_utils::is_argument());

  // Load the names cache
  //  SSNamesCacheFile namesCache;
  //  if (!options.GetNamesCache ().empty ())
  //  {
  //    try {
  //      if (namesCache.Open (options.GetNamesCache ()))
  //        g_NamesCache.SetFile (&namesCache);
  //    }
  //    catch (SSException& ex)
  //    {
  //      std::cerr << "names cache error: " << ex.what() << std::endl;
  //    }
  //  }

  Execute(m_VariablesMap, arguments);

  return 0;
}
Exemplo n.º 19
0
int MDSPlusData::getNodeLen()
{
	/* local vars */
	int dtype_long = DTYPE_LONG;
	char buf[1024];
	int size;
	int null = 0;
	int idesc = descr(&dtype_long, &size, &null);

	/* init buffer */
	memset(buf,0,sizeof(buf));

	string ftreename = string("\\")+mtreename;
	/* put SIZE() TDI function around tree name */
	snprintf(buf,sizeof(buf)-1,"SIZE(%s)",ftreename.c_str());

	//printf("node:%s, shot:%d\n", mnodename.c_str(), mshot);
	int status = MdsOpen((char*)mnodename.c_str(), &mshot);
	if ( !status_ok(status) )
	{
		fprintf(stderr,"Error opening rdata tree for [node:%s, tree:%s, shot:%d]\n",mnodename.c_str(), mtreename.c_str(), mshot);
		return -1;
	};

	//printf("buf:%s, shot:%d\n", buf, mshot);
	/* use MdsValue to get the tree length */
	status = MdsValue(buf, &idesc, &null, 0);
	if ( !status_ok(status) )
	{
		fprintf(stderr,"Unable to get length of %s.\n",ftreename.c_str());
		return -1;
	};
	/* return tree length */
	MdsClose((char*)mnodename.c_str(), &mshot);
	return size;
}
Exemplo n.º 20
0
QVariant SoundCloudService::data(const QModelIndex &index, int role) const
{
    if (!index.isValid()) {
        switch (role) {
        case Cantata::Role_TitleText:
            return title();
        case Cantata::Role_SubText:
            return job ? i18n("Searching...") : descr();
        case Qt::DecorationRole:
            return icon();
        default:
            break;
        }
    }
    switch (role) {
    case Cantata::Role_ListImage:
        return false;
    case Cantata::Role_CoverSong:
        return QVariant();
    default:
        break;
    }
    return SearchModel::data(index, role);
}
Exemplo n.º 21
0
std::shared_ptr<CAbstractShape> CShapeFactory::CreateShape(std::string const & descriptionShape)
{
	std::string type;
	std::stringstream descr(descriptionShape);
	descr >> type;

	if (type == "Rectangle")
	{
		return CreateRectangle(descr);
	}
	else if (type == "Ellipse")
	{
		return CreateEllipse(descr);
	}
	else if (type == "Triangle")
	{
		return CreateTriangle(descr);
	}
	else
	{
		throw std::invalid_argument("Unknown type");
	}
	return std::shared_ptr<CAbstractShape>();
}
Exemplo n.º 22
0
void Playtree::onUpdateSlider()
{
    tree_update descr( tree_update::SliderChanged, end() );
    notify( &descr );
}
Exemplo n.º 23
0
void Playtree::onChange()
{
    buildTree();
    tree_update descr( tree_update::ResetAll, end() );
    notify( &descr );
}
Exemplo n.º 24
0
long mdsPlusPrepNext()
{
    int socket;
    int null=0;
    int dtype_long = DTYPE_LONG;
    int mdsstat, len;
    int idesc;
    int status=1,i;

    int bufsize=40;
    char buf[bufsize];
    char            treeID[20];
    char            serverID[20];
    int             shotID = 0;

    DBADDR  *paddr;
    long options, nRequest;

    paddr = (DBADDR *)dbCalloc(1, sizeof(struct dbAddr));
    /* Get server information */
    sprintf(buf, "icrf:daq:mptree:i.VAL");
    status = dbNameToAddr(buf, paddr);
    options = 0;
    nRequest = 1;
    status = dbGet(paddr, DBR_STRING, buf, &options, &nRequest, NULL);
    i=sscanf(buf,"%s %s",serverID, treeID);
    /* Connect server */
    socket=MdsConnect(serverID);
    if(socket == -1) {
        printf("genSub: Error connecting to mdsip server[%s].\n",serverID);
        return(-1);
    }
    if(genSubDebug > 5)
            printf("genSub: mdsPlusPrepNext() MdsConnected[%s]\n",serverID);

    /* Get pulse id */
    sprintf(buf, "icrf:pulseid.VAL");
    status = dbNameToAddr(buf, paddr);
    options = 0;
    nRequest = 1;
    status = dbGetField(paddr, DBR_LONG, &shotID, &options, &nRequest, NULL);
    /* open MDSPlus*/
    status=MdsOpen(treeID, &shotID);
    if( !status_ok(status) ) {
            printf("genSub: Error opening tree [%s] for shot [%d].\n",
                            treeID,shotID );
        return(-1);
    }
    if(genSubDebug > 5)
               printf("genSub: mdsPlusPrepNext() MdsOpened [%s] shot number [%d].\n",
                            treeID,shotID);

    /* generate MDSPlus event*/
    sprintf(buf, "TCL(\"SETEVENT cmpl\")");
    idesc = descr(&dtype_long, &mdsstat, &null);
    status = MdsValue(buf,&idesc,&null,&len);
    if( !status_ok(status) ) {
            printf("genSub: Error generating event for tree [%s].\n", treeID);
        return(-1);
    }
    if(genSubDebug > 0)
            printf("genSub: mdsPlusPrepNext() MdsValue %s\n", buf);

    /* Put next pulse number */
    sprintf(buf, "icrf:pulseid.VAL");
    status = dbNameToAddr(buf, paddr);
    options = 0;
    nRequest = 1;
    shotID++;
    status = dbPutField(paddr, DBR_LONG, &shotID, 1);

    status=MdsClose(treeID, &shotID);
    free(paddr);
    return(0);
}
Exemplo n.º 25
0
int DllExport _nidaq_store (int id, char *nodeName, int simultaneous)
{
	char channelName[256], pathName[256];
	int16 *data;
	int32 stats, samplesRead, idesc, idesc1, idesc2, idesc3, idesc4, idesc5, idesc6, dtype, null = 0;
	uInt32 i, arraySize, nPacket, packetSize;
	uInt64 numSamples;
	float64 convRate, dt, range, resolution, period;
	sTask *pTask;
	sDataChain *pData, *pNext;
	
	pTask = tasks.item + id;
	if (simultaneous)
	{
		dt = 0.0;
	}
	else
	{
		DAQmxGetTimingAttribute (pTask->handle, DAQmx_AIConv_Rate, &convRate);
		dt = 1.0/convRate;
	}

	if (pTask->type== DAQmx_Val_OnDemand)
	{
		pData = pTask->current;
		samplesRead = pTask->num * NBUF + pData->num;
		arraySize = pTask->numChannels * samplesRead;
		data = (int16 *)malloc(arraySize * sizeof (int16));
		nPacket = NBUF * pTask->numChannels;
		packetSize = nPacket * sizeof (int16);
		pNext = pTask->start;
		for (i=0; i<pTask->num; i++)
		{
			pData = pNext;
			memcpy (data + i * nPacket, pData->data, packetSize);
			pNext = pData->next;
			free (pData->data);
			free (pData);
		}
		memcpy (data + i * nPacket, pNext->data, pNext->num * pTask->numChannels * sizeof (int16));
		free (pNext->data);
		free (pNext);
	}
	else
	{
		/* # of samples */
		DAQmxGetTimingAttribute (pTask->handle, DAQmx_SampQuant_SampPerChan, &numSamples);
		arraySize = pTask->numChannels * numSamples;
		data = (int16 *)malloc(arraySize * sizeof (int16));
		DAQmxReadBinaryI16 (pTask->handle, DAQmx_Val_Auto, 10.0, DAQmx_Val_GroupByScanNumber, data, arraySize, &samplesRead, NULL);
	}
	/* Get the ADC resolution 12bits=NI6071,NI6115, 16bits=NI6143, 14bits but packed from bit 15=NI6133 */
	DAQmxGetChanAttribute (pTask->handle, NULL, DAQmx_AI_Resolution, &resolution);
	if (resolution == 14.) resolution = 16.;
	resolution = ldexp (1.0, (int) resolution-1);  

	/* Sampling time */
	DAQmxGetTimingAttribute (pTask->handle, DAQmx_SampClk_Rate, &period);
	period = 1.0/period; //Rate -> Time
	
	dtype = DTYPE_SHORT;
	idesc1 = descr(&dtype, data, &arraySize, &null);

	dtype = DTYPE_ULONG;
	idesc2 = descr(&dtype, &i, &null);

	idesc3 = descr(&dtype, &pTask->numChannels, &null);

	dtype = DTYPE_ULONGLONG;
	numSamples = samplesRead - 1;
	idesc4 = descr(&dtype, &numSamples, &null);

	dtype = DTYPE_DOUBLE;
	idesc = descr(&dtype, &range, &null);
	idesc5 = descr(&dtype, &convRate, &null);
	idesc6 = descr(&dtype, &period, &null);
	for (i=0; i<pTask->numChannels; i++)
	{
		/* Translate a channel name to a node name */
		DAQmxGetNthTaskChannel (pTask->handle, i+1, channelName, 256);
		sprintf (pathName, "%s:%s:FOO", nodeName, channelName);

		DAQmxGetChanAttribute (pTask->handle, channelName, DAQmx_AI_Max, &range);
		range /= resolution;

		convRate = i * dt;
		stats = MdsPut(pathName,"BUILD_SIGNAL(BUILD_WITH_UNITS($*$VALUE,'V'),(`$[$:*:($)]),MAKE_DIM(MAKE_WINDOW(0,$,$),MAKE_SLOPE(MAKE_WITH_UNITS($,'s'))))",
			&idesc, &idesc1, &idesc2, &idesc3, &idesc4, &idesc5, &idesc6, &null);
	}
	free (data);
	
	DAQmxStopTask (pTask->handle);
	return 1;
}
Exemplo n.º 26
0
void mdsPlusPut_Task(int param)
{
    unsigned long i;
    int socket;
    int null=0;
    int dtypeFloat = DTYPE_FLOAT;
    int dataDesc,timeDesc;
    int status=1, j;

    float          tdT;
    float          toffT;

    int            tnoRd;
    int            tshotID;
    char            ttagName[20];
    char            ttreeID[20];
    char            tserverID[20];
    float           *timeBase;

    DBADDR          *paddr;
    paddr = (DBADDR *)dbCalloc(1, sizeof(struct dbAddr));

    if(genSubDebug > 0)
        printf("Start MdsPut. ##############.\n");
    status = dbNameToAddr(mpActivePV, paddr);
    enum16Val = 1;
    status = dbPutField(paddr, DBR_ENUM, &enum16Val, 1);
    status = mdsPlusCreatePulse();
    /* loop numNode times */
    for(j = 0;j < numNode; j++) {
        if(genSubDebug > 5)
            printf("genSub: mdsPlusPut_Task() started. Task Position=%d, Flag=%ld\n",j,pmdsPutData[j].putFlag);
        if(pmdsPutData[j].putFlag == 0)
            goto endloop;

        epicsThreadSleep(0.01);

        tnoRd=(int)(pmdsPutData[j].noRd);
        tshotID=(int)(pmdsPutData[j].shotID);
        strcpy(ttagName,pmdsPutData[j].tagName);
        strcpy(ttreeID,pmdsPutData[j].treeID);
        strcpy(tserverID,pmdsPutData[j].serverID);

        tdT=pmdsPutData[j].dT;
        toffT=pmdsPutData[j].offT;

        if(genSubDebug > 3)
            printf("genSub: mdsPlusPut_Task() MdsConnect Ready. ServerID=[%s] TreeID=[%s] tagName=[%s] dt=[%f] off=[%f] noRd=[%d]\n",tserverID, ttreeID, ttagName, tdT, toffT, tnoRd);

        /* Connect server and open tree*/
        socket=MdsConnect(tserverID);
        if(socket == -1) {
            printf("genSub: Error connecting to mdsip server[%s].\n",tserverID);
            break;
        }
        if(genSubDebug > 5)
             printf("genSub: mdsPlusPut_Task() MdsConnected[%s]\n",tserverID);

        status=MdsOpen(ttreeID, &tshotID);
        if( !status_ok(status) ) {
             printf("genSub: Error opening tree [%s] for shot [%d].\n",
                            ttreeID,tshotID );
             break;
        }                
        if(genSubDebug > 5)
             printf("genSub: mdsPlusPut_Task() MdsOpened [%s] shot number [%d].\n",
                       ttreeID,tshotID);

        /* put data */
        timeBase = (float *)malloc(tnoRd*sizeof(float));
        for(i=0;i<tnoRd;i++)
            *(timeBase + i) = ((float)i)*tdT + toffT;

        dataDesc=descr(&dtypeFloat,pmdsPutData[j].dataArray,&tnoRd, &null);
        timeDesc=descr(&dtypeFloat,timeBase, &tnoRd, &null);
        status=MdsPut(ttagName,"BUILD_SIGNAL($1,,$2)",&dataDesc,&timeDesc,&null);
        if( !status_ok(status) ) {
            printf("genSub: Error writing signal.\n");
            break;
        }

        if(genSubDebug > 5)
            printf("genSub: mdsPlusPut_Task() MdsPutted to tag [%s]. shot number [%d], noRd=[%d].\n",
                                ttagName,tshotID,tnoRd);
        if(genSubDebug > 10)
            for(i=0;i<tnoRd;i++) {
                    printf("timeBase=%f,data=%f\n",
                                        *((float *)timeBase+i),*((float *)pmdsPutData[j].dataArray+i));
            }
        free(timeBase);
        status=MdsClose(ttreeID, &tshotID);
        if( !status_ok(status) ) {
            printf("genSub: Error closing tree for shot [%d].\n",tshotID );
            break;
        }
        if(genSubDebug > 5)
            printf("genSub: mdsPlusPut_Task() MdsClosed [%s] shot number [%d]\n",ttreeID,tshotID);

        endloop:
        if(genSubDebug > 5)
            printf("genSub: mdsPlusPut_Task() Data discarded for taskPos[%d].\n",j);
    }
    status = mdsPlusPrepNext();
    /* end of mdsput */
    startMdsPut = 0;
    status = dbNameToAddr(mpActivePV, paddr);
    enum16Val = 0;
    status = dbPutField(paddr, DBR_ENUM, &enum16Val, 1);
    free(paddr);
}
Exemplo n.º 27
0
int acqMdsPutTCData(TCMDS_INFO *tcmds, int mode)
{
    int _null = 0;
    int status;
    int dtype_Double = DTYPE_DOUBLE;
    int dtype_Short = DTYPE_SHORT;
    int dtype_ULong = DTYPE_ULONG;

    int rawDataDesc;
    int rateDesc, startDesc, endDesc, voltageTDesc;
    int   id_end_Desc;

    int i, j, k;
	int slot;

    FILE *fpRaw = NULL;
    int  nTrueSampleCnt = 0;
    int  nTrueSampleCnt_1;
    double fVpp10_16bit;

    double fStartTime;
    double fEndTime;
    double fRealTimeGap;

    int   mdsSock;
    int   shot = tcmds->shot;

    long   totalCnt;

    FILE *fp;
    char szTemp[256];

    int   reConn = 0;
	char  tempNode[200];

	double *getData = NULL;

    nTrueSampleCnt = (tcmds->t1 - tcmds->t0) * 10;

	getData = (double *)malloc(sizeof(double)*nTrueSampleCnt);

    while(1) {
		if(mode == 1) { /* KSTAR MDS */
            mdsSock = MdsConnect("172.17.100.202:8000");
		}
		else if(mode == 0) { /* LOCAL MDS */
            mdsSock = MdsConnect("172.17.121.244:8000");
		}

        if(mdsSock == -1) {
            printf("--- MDS Connect Faile Reconnect [%d] ---\n", reConn);
            if(reConn >= 3) return -1;
            else reConn++;
        }
        else {
            break;
        }
    }

    reConn = 0;

    while(1) {
		if(mode == 1) /* KSTAR MDS */
			status = MdsOpen("HEATING", &shot);
		else if(mode == 0) /* LOCAL MDS */
            status = MdsOpen("nbi1", &shot);

        if ( !STATUS_OK(status) )
        {
            epicsThreadSleep(0.1);
            fprintf(stderr,"Error opening tree for shot %d.\n",shot);
            printf("%s\n", MdsGetMsg(status));
            if(reConn >= 3) return -1;
            else reConn++;
        }
        else {
            break;
        }
    }

    fStartTime = tcmds->t0;
    fEndTime = nTrueSampleCnt + fStartTime;

    fRealTimeGap = 1.0 / 10.0;
    nTrueSampleCnt_1 = nTrueSampleCnt - 1;

    rateDesc = descr(&dtype_Double, &fRealTimeGap, &_null);
    startDesc = descr(&dtype_Double, &fStartTime, &_null);
    endDesc = descr(&dtype_Double, &fEndTime, &_null);
    voltageTDesc = descr(&dtype_Double, &fVpp10_16bit, &_null);
    id_end_Desc = descr(&dtype_ULong, &nTrueSampleCnt_1, &_null);


	double read_data[nTrueSampleCnt*MAX_CARD_NUM];
	double raw_data[TC_MAX_CH][nTrueSampleCnt];

    for(slot=0; slot < MAX_CARD_NUM; slot++) {
		int ind = 0;
		int inc = 0;

		sprintf(szTemp, "/tmp/tc_%d_%d.dat", tcmds->card, slot);
		fp = fopen(szTemp, "r");
		fread(&read_data[0],  sizeof(double)*tcmds->t1*MAX_CARD_NUM*8, 1, fp);
		fclose(fp);
		for(i=0; i < tcmds->t1; i++) {
			for(j=0; j < TC_MAX_CH; j++) {
				for(k=0; k < 10; k++) {
					raw_data[j][k+ind] = read_data[k+inc];
				}
				inc += 10;
			}
			ind += 10;
		}

		for(i=0; i < TC_MAX_CH; i++) {

			printf("TC MDS NODE : [%s]\n", tcmds->mdsinfo[slot][i].node);
			memcpy(getData, &raw_data[i], sizeof(double)*nTrueSampleCnt);

	        rawDataDesc = descr(&dtype_Double, getData, &nTrueSampleCnt, &_null);

	        if( tcmds->mdsinfo[slot][i].mdsput != 0) {
				sprintf(tempNode, "\\%s", tcmds->mdsinfo[slot][i].node);


				if(mode == 1) { /* KSTAR MDS */
	         	    status = MdsPut(tempNode, 
						"BUILD_SIGNAL(BUILD_WITH_UNITS($,\"V\"),,MAKE_DIM(MAKE_WINDOW($,$,$),MAKE_SLOPE(MAKE_WITH_UNITS($,\"s\"))))", 
						&rawDataDesc, &startDesc, &endDesc, &rateDesc, &rateDesc, &_null);
				}
				else if(mode == 0) { /* LOCAL MDS */
			        status = MdsPut(tempNode ,
					    "BUILD_SIGNAL(BUILD_WITH_UNITS($,\"V\"),,MAKE_DIM(MAKE_WINDOW(0,$,$),MAKE_SLOPE(MAKE_WITH_UNITS($,\"s\"))))", 
					    &rawDataDesc, &id_end_Desc, &startDesc, &rateDesc, &_null);
				}

		        if(!((status) & 1)) {
	                printf("MdsPut Error --> node [%s]\n", tcmds->mdsinfo[slot][i].node);
	            }
	        }
		}
    }

	if(mode == 1) /* KSTAR MDS */
        status = MdsClose("HEATING", &shot);
	else if(mode == 0) /* LOCAL MDS */
		status = MdsClose("nbi1", &shot);
    MdsDisconnect(mdsSock);

    free(getData);
    getData = NULL;

    printf("--- TC MDSPlus Data Put OK ---\n");

    return 0;
}
Exemplo n.º 28
0
 shape(int xpos, int ypos) : x(xpos), y(ypos) {
     id = count++;
     std::cout << "constructing: " << descr() << std::endl;
 }
Exemplo n.º 29
0
 virtual ~shape() {
     std::cout << "destructing: " << descr() << std::endl;
 }
Exemplo n.º 30
0
void Type::print(std::ostream & out){
	out << "Type name=" << descr()->name() << "\n";
	for (int i = 0; i < size(); ++i) {
		out << "Field descr =" << descr()->get(i) << ", value = " << get(i) << "\n";
	}
}