コード例 #1
0
void IBClient::updateMktDepth(TickerId id, int position, int operation, int side, double price, int size)
{
    receiveData("updateMktDepth", knk(6,
                                      kj(id),
                                      ki(position),
                                      ki(operation),
                                      ki(side),
                                      kf(price),
                                      ki(size)));
}
コード例 #2
0
void IBClient::updateMktDepthL2(TickerId id, int position, IBString marketMaker, int operation, int side, double price, int size)
{
    receiveData("updateMktDepthL2", knk(7,
                                        kj(id),
                                        ki(position),
                                        ks((S)marketMaker.c_str()),
                                        ki(operation),
                                        ki(side),
                                        kf(price),
                                        ki(size)));
}
コード例 #3
0
void IBClient::tickEFP(TickerId tickerId, TickType tickType, double basisPoints, const IBString &formattedBasisPoints, double totalDividends, int holdDays, const IBString &futureExpiry, double dividendImpact, double dividendsToExpiry)
{
    auto dict = createDictionary(std::map<std::string, K> {
        { "tickerId",               kj(tickerId) },
        { "tickType",               ki(tickType) },
        { "basisPoints",            kf(basisPoints) },
        { "formattedBasisPoints",   kp((S)formattedBasisPoints.c_str()) },
        { "totalDividends",         kf(totalDividends) },
        { "holdDays",               ki(holdDays) },
        { "futureExpiry",           kp((S)futureExpiry.c_str()) },
        { "dividendImpact",         kf(dividendImpact) },
        { "dividendsToExpiry",      kf(dividendsToExpiry) }
    });
    receiveData("tickEFP", dict);
}
	Vector3 computeDesiredForce(const SE3Type & pose, const Vector3 & linear_velocity,
			double delta_time) {
		    Vector3 desired_position(0,0,1);
            Vector3 desired_velocity(0,0,0);

//            Vector3 kp(1,1,1) ;
//            Vector3 kd(1,1,1);
//            Vector3 ki(0.0015,0.0015,0.0015) ;

//for ukf after redirecting to log
            Vector3 kp(4,4,4) ;
            Vector3 kd(3,3,3);
            Vector3 ki(0.002,0.002,0.002) ;


            Vector3 current_position=pose.translation();
            std::cout << "\nCurrent Position" << current_position ;
            Vector3 proportiona_val= kp.cwiseProduct(desired_position-current_position);
            Vector3 differential_val=kd.cwiseProduct(desired_velocity-linear_velocity);

            accumulated_error = accumulated_error+(desired_position-current_position) ;

            Vector3 integral_value=ki.cwiseProduct(accumulated_error);
            Vector3 desired_force=proportiona_val+ differential_val+integral_value;

            std::cout << "\ndesired_force is" << desired_force ;

            return desired_force;



	}
コード例 #5
0
void object::test<3>()
{
    Keyed one("one"), two("two"), three("three");
    // We don't want to rely on the underlying container delivering keys
    // in any particular order. That allows us the flexibility to
    // reimplement LLInstanceTracker using, say, a hash map instead of a
    // std::map. We DO insist that every key appear exactly once.
    typedef std::vector<std::string> StringVector;
    StringVector keys(Keyed::beginKeys(), Keyed::endKeys());
    std::sort(keys.begin(), keys.end());
    StringVector::const_iterator ki(keys.begin());
    ensure_equals(*ki++, "one");
    ensure_equals(*ki++, "three");
    ensure_equals(*ki++, "two");
    // Use ensure() here because ensure_equals would want to display
    // mismatched values, and frankly that wouldn't help much.
    ensure("didn't reach end", ki == keys.end());

    // Use a somewhat different approach to order independence with
    // beginInstances(): explicitly capture the instances we know in a
    // set, and delete them as we iterate through.
    typedef std::set<Keyed*> InstanceSet;
    InstanceSet instances;
    instances.insert(&one);
    instances.insert(&two);
    instances.insert(&three);
    for (Keyed::instance_iter ii(Keyed::beginInstances()), iend(Keyed::endInstances());
            ii != iend; ++ii)
    {
        Keyed& ref = *ii;
        ensure_equals("spurious instance", instances.erase(&ref), 1);
    }
    ensure_equals("unreported instance", instances.size(), 0);
}
コード例 #6
0
 int main(void)
{
 int i;
 pid_t pd;
 printf("main %d\n",getpid());
 
 for(i=0;i<10;i++){
  sleep(1);
  if(i==0){
  fork();
  }
 
  else if(i>=1){ 
   if(getppid())
    fork();
   } else{
   }
  printf("parent %d   me %d\n",getppid(),getpid()); 
  }

 ki();

 /*
 if(pd==0){
  printf("child\n");
  }  else if(pd>0){
  while(1){
   sleep(1);
   printf("parent %d\n",pd[0]);
   }
  }
 */
 return 0; 
}
コード例 #7
0
void IBClient::position(const IBString &account, const Contract &contract, int position, double avgCost)
{
    receiveData("position", knk(4,
                                ks((S)account.c_str()),
                                kj(contract.conId),
                                ki(position),
                                kf(avgCost)));
}
コード例 #8
0
ファイル: SLData.cpp プロジェクト: clagv/sl
 size_t Data::newEntry(const std::string& key, const SLStore& dv)
 {
     KeyIdx ki(key, m_keyIdx.size());
     KeyIdxVec::iterator it = std::upper_bound(m_keyIdx.begin(), m_keyIdx.end(), ki, key_less);
     m_keys.push_back(key);
     m_varData.push_back(dv);
     m_keyIdx.insert(it, ki);
     return ki.second;
 }
コード例 #9
0
void IBClient::accountSummary(int reqId, const IBString &account, const IBString &tag, const IBString &value, const IBString &curency)
{
    receiveData("accountSummary", knk(5,
                                      ki(reqId),
                                      ks((S)account.c_str()),
                                      ks((S)tag.c_str()),
                                      kp((S)value.c_str()),
                                      ks((S)curency.c_str())));
}
コード例 #10
0
ファイル: tInputFile.cpp プロジェクト: SiccarPoint/child
/****************************************************************************\
**
**  setKeyWordTable
**
**  Set KeyWordTable
**  - 11/07/2003 AD
\****************************************************************************/
static
void setKeyWordTable(tArray< tKeyPair > &KeyWordTable,
		     tList< tKeyPair > &KeyWordList) {
  KeyWordTable.setSize(KeyWordList.getSize());
  int i = 0;
  tListIter< tKeyPair > ki(KeyWordList);
  for( tKeyPair *k=ki.FirstP(); !(ki.AtEnd()); k=ki.NextP(), ++i ) {
    KeyWordTable[i] = *k;
  }
}
コード例 #11
0
ファイル: examples.c プロジェクト: kevinarpe/kx
// join an integer to a list and join a K object to a list
int eg8()
{
        K z=ki(20);
        K intlist=ktn(KI,0);
		K x=ktn(0,0);
        DO(5,ja(&intlist,&i));        
        jk(&x,intlist);
        jk(&x,z);
        k(c,"display",x,(K)0);
        return 1;
}
コード例 #12
0
void IBClient::execDetails(int reqId, const Contract &contract, const Execution &execution)
{
    auto exec = createDictionary(std::map<std::string, K> {
        { "execId",         ks((S)execution.execId.c_str()) },
        { "time",           kp((S)execution.time.c_str()) }, // TODO: Convert
        { "acctNumber",     ks((S)execution.acctNumber.c_str()) },
        { "exchange",       ks((S)execution.exchange.c_str()) },
        { "side",           ks((S)execution.side.c_str()) },
        { "shares",         ki(execution.shares) },
        { "price",          kf(execution.price) },
        { "permId",         ki(execution.permId) },
        { "clientId",       kj(execution.clientId) },
        { "orderId",        kj(execution.orderId) },
        { "liquidation",    ki(execution.liquidation) },
        { "cumQty",         ki(execution.cumQty) },
        { "avgPrice",       kf(execution.avgPrice) },
        { "evRule",         kp((S)execution.evRule.c_str()) },
        { "evMultiplier",   kf(execution.evMultiplier) }
    });
    receiveData("execDetails", knk(3, ki(reqId), kj(contract.conId), exec));
}
コード例 #13
0
void IBClient::updatePortfolio(const Contract &contract, int position, double marketPrice, double marketValue, double averageCost, double unrealizedPNL, double realizedPNL, const IBString &accountName)
{
    auto dict = createDictionary(std::map<std::string, K> {
        { "contract",       kj(contract.conId) },
        { "position",       ki(position) },
        { "marketPrice",    kf(marketPrice) },
        { "marketValue",    kf(marketValue) },
        { "averageCost",    kf(averageCost) },
        { "unrealizedPNL",  kf(unrealizedPNL) },
        { "realizedPNL",    kf(realizedPNL) },
        { "accountName",    kp((S)accountName.c_str()) }
    });
    receiveData("updatePortfolio", dict);
}
コード例 #14
0
ファイル: main.cpp プロジェクト: CCJY/coliru
 // deploy_suffixes - Deploy suffixes
 // @s[in]: The string to insert in the tree
 // @sindex[in]: The index id of @s
 //
 // deploy_suffixes performs the Ukkonen's algorithm to inser @s into the
 // tree.
 int deploy_suffixes(const S& s, int sindex) {
     ReferencePoint active_point(&tree.root, std::pair<int,int>(sindex, 0));
     int i = get_starting_node(s, &active_point);
     if (std::numeric_limits<int>::max() == i) {
         return -1;
     }
     for (; i < s.length(); ++i) {
         MappedSubstring ki(sindex, active_point.second.second, i);
         active_point = update(active_point.first, ki);
         ki.l = active_point.second.second;
         active_point = canonize(active_point.first, ki);
     }
     return sindex;
 }
コード例 #15
0
void IBClient::realtimeBar(TickerId reqId, long time, double open, double high, double low, double close, long volume, double wap, int count)
{
    auto dict = createDictionary(std::map<std::string, K> {
        { "reqId",  kj(reqId) },
        { "time",   kj(time) }, // TODO: Convert
        { "open",   kf(open) },
        { "high",   kf(high) },
        { "low",    kf(low) },
        { "close",  kf(close) },
        { "volume", kj(volume) },
        { "wap",    kf(wap) },
        { "count",  ki(count) }
    });
    receiveData("realtimeBar", dict);
}
コード例 #16
0
void IBClient::tickOptionComputation(TickerId tickerId, TickType tickType, double impliedVol, double delta, double optPrice, double pvDividend, double gamma, double vega, double theta, double undPrice)
{
    auto dict = createDictionary(std::map<std::string, K> {
        { "tickerId",   kj(tickerId) },
        { "tickType",   ki(tickType) },
        { "impliedVol", kf(impliedVol) },
        { "delta",      kf(delta) },
        { "optPrice",   kf(optPrice) },
        { "pvDividend", kf(pvDividend) },
        { "gamma",      kf(gamma) },
        { "vega",       kf(vega) },
        { "theta",      kf(theta) },
        { "undPrice",   kf(undPrice) }
    });
    receiveData("tickOptionComputation", dict);
}
コード例 #17
0
ファイル: common1.c プロジェクト: kevinarpe/kx
PyObject* from_any_kobject(K x) {
     PyObject* result;
     int type = abs(x->t);
	
     if (98 == type)
	  result = from_table_kobject(x);
     else if (99 == type)
	  result = from_dictionary_kobject(x);
     else if (105 == type || 101 == type)
	  result = from_int_kobject(ki(0));
     else if (-1 < type && type < 20)
	  result = kdbplus_types[type](x);
     else
	  result = error_broken_kobject(x);

     return result;
}
コード例 #18
0
ファイル: SLData.cpp プロジェクト: clagv/sl
 size_t Data::idx(const std::string& key, size_t keyCount, bool required) const
 {
     if(key.empty())
         return curIdx(required);
     if(0 == keyCount && !end() && str_eql(key, m_keys[m_pos]))
         return m_pos;
     if(keyCount < m_keyIdx.size())
     {
         KeyIdx ki(key, 0);
         KeyIdxVec::const_iterator it = std::lower_bound(m_keyIdx.begin(), m_keyIdx.end(), ki, key_less);
         size_t keyIdxPos = std::distance(m_keyIdx.begin(), it) + keyCount;
         if(keyIdxPos < m_keyIdx.size() && key_eql(ki, m_keyIdx[keyIdxPos]))
             return m_keyIdx[keyIdxPos].second;
     }
     if(required)
         throw std::exception("sl::Data::idx - key not found");
     return IdxInvalidPos;
 }
コード例 #19
0
ファイル: TDB_auth.cpp プロジェクト: NeoRuby/q_Wind
TDB_API K K_DECL TDB_logout(K h) {
    ::THANDLE tdb = NULL;
    try {
        long long const hh = q::q2Dec(h);
        tdb = reinterpret_cast<::THANDLE>(hh);
    }
    catch (std::string const& error) {
        return q::error2q(error);
    }

    if (tdb) {
        int const error = ::TDB_Close(tdb);
        std::cerr << "<TDB> logged out 0x" << util::hexBytes(tdb) << std::endl;
        return ki(error);
    }
    else {
        return q::error2q("null THANDLE");
    }
}
コード例 #20
0
ファイル: SLData.cpp プロジェクト: clagv/sl
 bool Data::erase(const std::string& key, size_t keyIdx)
 {
     if(keyIdx < m_keyIdx.size())
     {
         KeyIdx ki(key, 0);
         size_t pos = (std::lower_bound(m_keyIdx.begin(), m_keyIdx.end(), ki, key_less) - m_keyIdx.begin()) + keyIdx;
         if(pos < m_keyIdx.size() && key_eql(ki, m_keyIdx[pos]))
         {
             // users shouldn't really erase keys while reading data but ...
             if(m_pos < m_keyIdx.size() && m_pos > pos)
                 --m_pos;
             m_keyIdx.erase(m_keyIdx.begin() + pos);
             m_keys.erase(m_keys.begin() + pos);
             m_varData.erase(m_varData.begin() + pos);
             return true;
         }
     }
     return false;
 }
コード例 #21
0
void IBClient::orderStatus(OrderId orderId, const IBString &status, int filled, int remaining, double avgFillPrice, int permId, int parentId, double lastFillPrice, int clientId, const IBString &whyHeld)
{
    auto dict = createDictionary(std::map<std::string, K> {
        { "id",                 ki(orderId) },
        { "status",             kp((S)status.c_str()) },
        { "filled",             ki(filled) },
        { "remaining",          ki(remaining) },
        { "avgFillPrice",       kf(avgFillPrice) },
        { "permId",             ki(permId) },
        { "parentId",           ki(parentId) },
        { "lastFilledPrice",    kf(lastFillPrice) },
        { "clientId",           ki(clientId) },
        { "whyHeld",            kp((S)whyHeld.c_str()) }
    });
    receiveData("orderStatus", dict);
}
コード例 #22
0
ファイル: TDF_code.cpp プロジェクト: NeoRuby/q_Wind
TDF_API K K_DECL TDF_optionCodeInfo(K h, K windCode) {
	::THANDLE tdf = NULL;
	std::string code;
	try {
		TDF::parseTdfHandle(h, tdf);
		code = q::q2String(windCode);
	}
	catch (std::string const& error) {
		return q::error2q(error);
	}

	::TDF_OPTION_CODE info = { 0 };
	::TDF_ERR result = static_cast<::TDF_ERR>(::TDF_GetOptionCodeInfo(tdf, code.c_str(), &info));
	if (result != TDF_ERR_SUCCESS) {
		return q::error2q(::TDF::getError(result));
	}

	q::K_ptr data(ktn(0, 6 + 12));
	kK(data.get())[0 +  0] = ks(const_cast<S>(info.basicCode.szWindCode));
	kK(data.get())[0 +  1] = ks(const_cast<S>(info.basicCode.szMarket));
	kK(data.get())[0 +  2] = ks(const_cast<S>(info.basicCode.szCode));
	kK(data.get())[0 +  3] = ks(const_cast<S>(info.basicCode.szENName));
	kK(data.get())[0 +  4] = ks(const_cast<S>(Wind::encoder::GB18030_UTF8::encode(info.basicCode.szCNName).c_str()));
	kK(data.get())[0 +  5] = kg(info.basicCode.nType);
	kK(data.get())[6 +  0] = ks(const_cast<S>(info.szContractID));
	kK(data.get())[6 +  1] = ks(const_cast<S>(info.szUnderlyingSecurityID));
	kK(data.get())[6 +  2] = kc(info.chCallOrPut);
	kK(data.get())[6 +  3] = kd(q::date2q(info.nExerciseDate));
	kK(data.get())[6 +  4] = kc(info.chUnderlyingType);
	kK(data.get())[6 +  5] = kc(info.chOptionType);
	kK(data.get())[6 +  6] = kc(info.chPriceLimitType);
	kK(data.get())[6 +  7] = ki(info.nContractMultiplierUnit);
	kK(data.get())[6 +  8] = kf(info.nExercisePrice);
	kK(data.get())[6 +  9] = kd(q::date2q(info.nStartDate));
	kK(data.get())[6 + 10] = kd(q::date2q(info.nEndDate));
	kK(data.get())[6 + 11] = kd(q::date2q(info.nExpireDate));
	return data.release();
}
コード例 #23
0
ファイル: FLD_CAL.C プロジェクト: pemaxwell/JCUSI-AY13
int circular_cal(FORMPTR fmp)
{
WINDOWPTR       wnp;
int             status,done;
int             score,count,environment;
int             row,col;
int             state;
char            cal_msg[81];
char            serial_nbr[8],unit_type[5],cal_date[9];
char            hardware_rev,software_rev;


   latt_rpl(L_BLINK,NORMAL|BLINK,BLUE|BLINK,WHITE,LATT_SYS);
   latt_rpl(L_ERROR,REVERSE,     RED|BLINK, WHITE,LATT_SYS);

   wnp = wn_def(CENTER_WN,CENTER_WN,12,60,LREVERSE,BDR_DLNP);
   sw_shad(TRANSPARENT,LSHADOW,BOTTOMRIGHT,wnp);
   sw_updnfp(wn_expset,wn_expunset,wnp);

   wn_up(wnp);

   status = c100_open_channel(dflt_port,dflt_baud);
   if (status != 0) {
      v_printf(wnp,"Error: unable to open compass channel - %s",
               c100_error_name(status));
      goto END;
   } /* if */

   status = c100_halt_data();
   if (status != 0) {
      v_printf(wnp,"Error: unable to halt data messages - %s",
               c100_error_name(status));
      goto END;
   } /* if */

   status = c100_get_who(serial_nbr,&software_rev,&hardware_rev,
                         unit_type,cal_date);
   if (status != 0) {
      v_printf(wnp,"Error: unable to read software revision level.  %s",
               c100_error_name(status));
      goto END;
   } /* if */
   if (software_rev < 'C') {
      v_st("\nCircular Cal requires software revision C or higher.",wnp);
      v_printf(wnp,"\nThis C100 has rev %c software.",software_rev);
      v_st("\n\nCalibration aborted.",wnp);
      goto END;
   } /* if */



//-----------
//   Start Circular Calibration
//-----------
   status = c100_cal_mode(CIRCULAR_CAL,NULL,cal_msg);
   if (status != 0) {
      v_printf(wnp,"Error: unable to start circular cal. %s.",
               c100_error_name(status));
      goto END;
   } /* if */

   v_st("Circular calibration started.\n\n",wnp);
   v_st("Turn compass SLOWLY in a circle...",wnp);
   row = wnp->r;
   col = wnp->c;
   v_statt("Collecting",L_BLINK,wnp);
   csr_mvwn(row,col,wnp);

   state = COLLECTING;
   done = FALSE;
   do {

      if (ki_chk()) {
         if (ki() == KEY_ESC) {
            if (continue_abort("ESC pressed!") == ABORT) {
               v_st("ABORTED    ",wnp);
               c100_cal_mode(ABORT_CAL,NULL,NULL);
               v_st("\nCircular calibration aborted by user!",wnp);
               goto END;
            } /* if */
         } /* if */
      } /* if */

      status = c100_check_for_ack(cal_msg);
      switch (status) {
         case ACK_RECEIVED:
            if (state == COLLECTING) {
               state = CALCULATING;
               v_statt("Calculating",L_BLINK,wnp);
               csr_mvwn(row,col,wnp);
            } else {
               v_st("Finished    ",wnp);
               v_st("\n\nCircular calibration complete!",wnp);
               if (software_rev >= 'C') {
                  if (dflt_baud <= 1200)
                     delay(3000);

                  status = c100_get_cal_score(LONG_SCORE,&score,&count,
                                              &environment);
                  if (status != 0) {
                     v_printf(wnp,"\nError: unable to read cal score - %s",
                              c100_error_name(status));
                  } else {
                     v_printf(wnp,"\nCal score = %d, environment = %d, "
                              "count = %d.",score,environment,count);
                     if (environment < 5)
                        v_st("\nBad magnetic environment.  Consider re-"
                             "locating and re-calibrating the compass.",wnp);
                  } /* if */

               } else {

                  status = c100_get_cal_score(SHORT_SCORE,&score,&count,NULL);
                  if (status != 0) {
                     v_printf(wnp,"\nError: unable to read cal score - %s",
                              c100_error_name(status));
                  } else {
                     v_printf(wnp,"\nCal score = %d, count = %d.",
                              score,count);
                  } /* if */
               } /* if */

               if (score < 7)
                  v_statt("\nThis calibration may NOT be accurate!",
                          L_ERROR,wnp);
               done = TRUE;
            } /* if */
            break;


         case NAK_RECEIVED:
            v_st("ABORTED    ",wnp);
            v_printf(wnp,"\nError: unable to complete calibration - %s",
                     cal_msg);
            c100_cal_mode(ABORT_CAL,NULL,NULL);
            done = TRUE;
            break;


         default:
            break;

      } /* switch */

   } while (!done);


END:
   if (c100_mode == SENDING) {
      c100_send_data();
   } /* if */

   sw_title("[Press any key...]",L_BLINK,BOTTOMCENTER,wnp);
   v_bdr(BDR_DLNP,wnp);
   beep_vv(BPMEDIUM,BPLOW);
   beep_vv(BPMEDIUM,BPMIDDLE);
   beep_vv(BPMEDIUM,BPHIGH);
   flush_keybuf();
   ki();

   c100_close_channel();
   wn_dn(wnp);
   wn_free(wnp);

   return(SAMELEVEL);

} /* circular_cal() */
コード例 #24
0
ファイル: main.c プロジェクト: sametgolgeci/QuickSort
int main(int argc, const char * argv[]) {
    
    int yontem,dizi[2000000],eleman,i;
    clock_t a,b;
    
    printf("Lütfen kullanılacak yöntemi seçiniz\n");
    printf("1) İlk elemanı pivot olarak alınız\n");
    printf("2) Rastgele bir elemanı pivot olarak alınız\n");
    printf("3) İlk,son ve orta elemanı alıp 2.büyük olanı pivot yapınız\n");
    
    scanf("%d",&yontem);
    
    switch (yontem) {
        case 1:
            printf("Dizinin eleman sayısını giriniz\n");
            scanf("%d",&eleman);
           // printf("Dizinin elemanlarını giriniz\n");
            for (i=0; i<eleman; i++) {
                dizi[i]=i;
            //    dizi[i]=rand()%20;
            //    scanf("%d",&dizi[i]);
            //    printf("%d ",dizi[i]);
            }
            //    printf("\n");
            
            a=clock();
            quickSortBir(dizi,0,eleman-1,eleman);
            b=clock();
            
            printf("Dizinin son hali\n");
            
            for (i=0; i<eleman; i++) {
                printf("%d ",dizi[i]);
            }
            
            printf("\n %lu mikrosaniye\n",(b-a));
            
            break;
            
        case 2:
            printf("Dizinin eleman sayısını giriniz\n");
            scanf("%d",&eleman);
            printf("Dizinin elemanlarını giriniz\n");
            for (i=0; i<eleman; i++) {
                //dizi[i]=i;
               // dizi[i]=rand()%100000;
                scanf("%d",&dizi[i]);
                //printf("%d ",dizi[i]);
            }
                //printf("\n");
            
            
            a=clock();
            quickSortİki(dizi,0,eleman-1,eleman);
            b=clock();
            
            printf("Dizinin son hali\n");
            
            for (i=0; i<eleman; i++) {
                printf("%d ",dizi[i]);
            }
            
            printf("\n%lu mikrosaniye\n",(b-a));

            break;
            
        case 3:
            printf("Dizinin eleman sayısını giriniz\n");
            scanf("%d",&eleman);
            printf("Dizinin elemanlarını giriniz\n");
            for (i=0; i<eleman; i++) {
                //dizi[i]=i;
                scanf("%d",&dizi[i]);
                //dizi[i]=rand()%100000;
                //printf("%d ",dizi[i]);
            }
                //printf("\n");
            
            a=clock();
            quickSortUc(dizi,0,eleman-1,eleman);
            b=clock();
            
            printf("Dizinin son hali\n");
            
            for (i=0; i<eleman; i++) {
                printf("%d ",dizi[i]);
            }
            
            printf("\n%lu mikrosaniye\n",(b-a));

            break;
            
        default:
            printf("Yanlış değer girdiniz");
            break;
    }

    return 0;
}
コード例 #25
0
ファイル: qzmq.c プロジェクト: jaeheum/qzmq
Z K1(zsockfd){PC(x);R ki(zsock_fd(VSK(x)));}
コード例 #26
0
ファイル: FLD_CAL.C プロジェクト: pemaxwell/JCUSI-AY13
int eight_point_cal(FORMPTR fmp)
{
WINDOWPTR   wnp;
int         status,done;
int         score,count,environment;
int         space_pressed;
double      heading;
char        cal_msg[81];
char        serial_nbr[8],unit_type[5],cal_date[9];
char        hardware_rev,software_rev;


    latt_rpl(L_BLINK,NORMAL|BLINK,BLUE|BLINK,WHITE,LATT_SYS);
    latt_rpl(L_ERROR,REVERSE,     RED|BLINK, WHITE,LATT_SYS);

    wnp = wn_def(CENTER_WN,CENTER_WN,12,60,LREVERSE,BDR_DLNP);
    sw_shad(TRANSPARENT,LSHADOW,BOTTOMRIGHT,wnp);
    sw_updnfp(wn_expset,wn_expunset,wnp);

    wn_up(wnp);

    status = c100_open_channel(dflt_port,dflt_baud);
    if (status != 0) {
        v_printf(wnp,"Error: unable to open compass channel - %s",
                     c100_error_name(status));
        goto END;
    } /* if */

    status = c100_halt_data();
    if (status != 0) {
        v_printf(wnp,"Error: unable to halt data messages - %s",
                     c100_error_name(status));
        goto END;
    } /* if */

    status = c100_get_who(serial_nbr,&software_rev,&hardware_rev,
                                      unit_type,cal_date);
    if (status != 0) {
        v_printf(wnp,"Error: unable to read software revision level.  %s",
                 c100_error_name(status));
        goto END;
    } /* if */


    /*--- Start 8-point Calibration --*/
    sw_title("[Press SPACE when done...]",L_BLINK,BOTTOMCENTER,wnp);
    v_bdr(BDR_DLNP,wnp);
    v_st("Eight-Point Calibration started!\n",wnp);

   done = FALSE;
   do {

      status = c100_cal_mode(FORCED_EIGHT_POINT_CAL,&heading,cal_msg);
      switch (status) {
         case OK:
            v_printf(wnp,"\nPosition compass to ñ%.0fø...",heading);
            break;

         case DONE:
            v_st("\n\n8-point calibration complete!",wnp);

            if (dflt_baud <= 1200)
                delay(3000);

            if (software_rev >= 'C') {
               status = c100_get_cal_score(LONG_SCORE,&score,&count,
                                           &environment);
               if (status != 0) {
                  v_printf(wnp,"\nError: unable to read cal score - %s",
                           c100_error_name(status));
               } else {
                  v_printf(wnp,"\nCal score = %d, environment = %d, "
                           "count = %d.",score,environment,count);
                  if (environment < 5)
                     v_st("\nBad magnetic environment.  Consider re-"
                          "locating and re-calibrating the compass.",wnp);
               } /* if */
            } else {
               status = c100_get_cal_score(SHORT_SCORE,&score,&count,NULL);
               if (status != 0) {
                  v_printf(wnp,"\nError: unable to read cal score - %s",
                           c100_error_name(status));
               } else {
                  v_printf(wnp,"\nCal score = %d, count = %d.",
                           score,count);
               } /* if */
            } /* if */

            if (score < 7)
               v_statt("\nThis calibration may NOT be accurate.",
                       L_ERROR,wnp);
            done = TRUE;
            break;

         case MSG_NAKKED:
            v_printf(wnp,"\n\nError: %s",cal_msg);
            if (software_rev < 'C')
               c100_zap();
            else
               c100_cal_mode(ABORT_CAL,NULL,NULL);
            done = TRUE;
            break;

         default:
            v_printf(wnp,"\n\nError: unable to complete calibration - %s",
                     c100_error_name(status));
            if (software_rev < 'C')
               c100_zap();
            else
               c100_cal_mode(ABORT_CAL,NULL,NULL);
            done = TRUE;
            break;

      } /* switch */

      if (!done) {
         space_pressed = FALSE;
         do {
            switch (ki()) {
               case KEY_ESC:
                  if (continue_abort("ESC pressed!") == ABORT) {
                     if (software_rev < 'C')
                        c100_zap();
                     else
                        c100_cal_mode(ABORT_CAL,NULL,NULL);
                     v_st("\n8-point calibration aborted by user!",wnp);
                     goto END;
                  } /* if */
                  break;

               case KEY_SPACE:
                  space_pressed = TRUE;
                  break;

               default:
                  break;

            } /* switch */
         } while (!space_pressed);
      } /* if */

    } while (!done);


END:
//  if (c100_mode == SENDING) {
//     c100_send_data();
//  } /* if */

    sw_title("[Press any key...]",L_BLINK,BOTTOMCENTER,wnp);
    v_bdr(BDR_DLNP,wnp);
    beep_vv(BPMEDIUM,BPLOW);
    beep_vv(BPMEDIUM,BPMIDDLE);
    beep_vv(BPMEDIUM,BPHIGH);
    flush_keybuf();
    ki();

    c100_close_channel();
    wn_dn(wnp);
    wn_free(wnp);

    return(SAMELEVEL);

} /* eight_point_cal() */
コード例 #27
0
ファイル: py.c プロジェクト: robertotang/pyq
K py(K f, K x, K lib)
{
    int argc; char **argv;
    char *error, *p, *buf;
    void *h;
    K r;
#ifdef PY3K
    char *oldloc;
#endif
    h = dlopen((const char *)kG(lib), RTLD_NOW|RTLD_GLOBAL);
    if (!h)
        R krr(dlerror());
    dlerror();    /* Clear any existing error */
    Py_Main = dlsym(h, "Py_Main");
    P((error = dlerror()),krr(error));
    P(xt, krr("argv type"));
        I m = 0;     /* buf length */
    DO(xn,
       K y;
       P((y = kK(x)[i])->t!=KC, krr("arg type"));
       m += y->n+1);
    argc = xn+1;
    argv = malloc(sizeof(char*) * argc);
    P(!argv, krr("memory"));
        buf = malloc(m);
    P(!buf,(free(argv),krr("memory")));
    argv[0] = f->s;
    p = buf;
    DO(xn,
       K y = kK(x)[i];
       argv[i+1] = memcpy(p, kG(y), y->n);
       p += y->n; *p++ = '\0');
#ifdef PY3K
    dlerror();    /* Clear any existing error */
#if PY3K < 35
    c2w = dlsym(h, "_Py_char2wchar");
#else
    c2w = dlsym(h, "Py_DecodeLocale");
#endif
    P((error = dlerror()),krr(error));
    dlerror();    /* Clear any existing error */
#if PY3K < 34
    PyMem_Free = dlsym(h, "PyMem_Free");
#else
    PyMem_Free = dlsym(h, "PyMem_RawFree");
#endif
    P((error = dlerror()),krr(error));
    wchar_t **wargv = malloc(sizeof(wchar_t*)*(argc+1));
    wchar_t **wargv_copy = malloc(sizeof(wchar_t*)*(argc+1));
    oldloc = strdup(setlocale(LC_ALL, NULL));
    setlocale(LC_ALL, "");
    DO(argc,P(!(wargv[i]=c2w(argv[i],NULL)),krr("decode")));
        memcpy(wargv_copy, wargv, sizeof(wchar_t*)*argc);
    setlocale(LC_ALL, oldloc);
    free(oldloc);
    wargv[argc] = wargv_copy[argc] = NULL;
    r = ki(Py_Main(argc, wargv));
    DO(argc,PyMem_Free(wargv_copy[i]));
    free(wargv_copy);
    free(wargv);
#else
    r = ki(Py_Main(argc, argv));
#endif
    dlclose(h);
    free(argv);
    free(buf);
    R r;
}
コード例 #28
0
ファイル: AsiMS2000.cpp プロジェクト: AllenBurnham/microscope
void AsiMS2000::selectCommand(int commandNum)
{
  switch(commandNum)
  {
      case 0:
          accel();
          break;
      case 1:
          aalign();
          break;
      case 2:
          afcont();
          break;
      case 3:
          aflim();
          break;
      case 4:
          afocus();
          break;
      case 5:
          afset();
          break;
      case 6:
          afmove();
          break;
      case 7:
          ahome();
          break;
      case 8:
          aij();
          break;
      case 9:
          array();
          break;
      case 10:
          azero();
          break;
      case 11:
          backlash();
          break;
      case 12:
          bcustom();
          break;
      case 13:
          benable();
          break;
      case 14:
          build();
          break;
      case 15:
          cdate();
          break;
      case 16:
          cnts();
          break;
      case 17:
          customa();
          break;
      case 18:
          customb();
          break;
      case 19:
          dack();
          break;
      case 20:
          dump();
          break;
      case 21:
          ensync();
          break;
      case 22:
          epolarity();
          break;
      case 23:
          error();
          break;
      case 24:
          halt();
          break;
      case 25:
          here();
          break;
      case 26:
          home();
          break;
      case 27:
          info();
          break;
      case 28:
          joystick();
          break;
      case 29:
          jsspd();
          break;
      case 30:
          kadc();
          break;
      case 31:
          kd();
          break;
      case 32:
          ki();
          break;
      case 33:
          kp();
          break;
      case 34:
          lcd();
          break;
      case 35:
          led();
          break;
      case 36:
          lladdr();
          break;
      case 37:
          load();
          break;
      case 38:
          lock();
          break;
      case 39:
          lockrg();
          break;
      case 40:
          lockset();
          break;
      case 41:
          maintain();
          break;
      case 42:
          motctrl();
          break;
      case 43:
          move();
          break;
      case 44:
          movrel();
          break;
      case 45:
          pcros();
          break;
      case 46:
          pedal();
          break;
      case 47:
          rbmode();
          break;
      case 48:
          rdadc();
          break;
      case 49:
          rdsbyte();
          break;
      case 50:
          rdstat();
          break;
      case 51:
          relock();
          break;
      case 52:
          reset();
          break;
      case 53:
          rt();
          break;
      case 54:
          runaway();
          break;
      case 55:
          saveset();
          break;
      case 56:
          savepos();
          break;
      case 57:
          scan();
          break;
      case 58:
          scanr();
          break;
      case 59:
          scanv();
          break;
      case 60:
          secure();
          break;
      case 61:
          sethome();
          break;
      case 62:
          setlow();
          break;
      case 63:
          setup();
          break;
      case 64:
          si();
          break;
      case 65:
          speed();
          break;
      case 66:
          spin();
          break;
      case 67:
          status();
          break;
      case 68:
          stopbits();
          break;
      case 69:
          ttl();
          break;
      case 70:
          um();
          break;
      case 71:
          units();
          break;
      case 72:
          unlock();
          break;
      case 73:
          vb();
          break;
      case 74:
          vector();
          break;
      case 75:
          version();
          break;
      case 76:
          wait();
          break;
      case 77:
          where();
          break;
      case 78:
          who();
          break;
      case 79:
          wrdac();
          break;
      case 80:
          zero();
          break;
      case 81:
          z2b();
          break;
      case 82:
          zs();
          break;
      case 83:
          overshoot();
          break;
  }
}
コード例 #29
-15
ファイル: examples.c プロジェクト: kevinarpe/kx
//Calling functions with different valencies and with simple data types
int eg3()
{
K result=NULL;


//Monadic [Single argument function]
result=k(c,"f1s",ks("Hello World"),(K)0);
printf( "Executing f1s - This will return a symbol [type=%i] with value %s\n\n\n",result->t,result->s);

//Dyadic function
result=k(c,"f2i",ki(10),ki(1),(K)0);
printf( "Executing f2s - This will return a integer [type=%i] with value %i\n\n\n",result->t,result->i);

//Triadic function
result=k(c,"f3f",kf(10),kf(-1.),kf(2.2),(K)0);
printf( "Executing f2s - This will return a float [type=%i] with value %f\n\n\n",result->t,result->f);


//The examples above can be extended to up to functions with eight arguments.
//[Errors are discussed later]

printf("Finished Example 3");

return 1;

}
コード例 #30
-27
ファイル: main.c プロジェクト: sametgolgeci/QuickSort
void quickSortİki(int dizi[2000000],int first,int last,int eleman){
    
    int pivot,tmp,i,j,x,k;
    
    
    if (first<last) {

        x=first+rand()%(last-first+1);
        printf("Random olarak seçilen eleman %d\n",x+1);
        
        tmp=dizi[first];
        dizi[first]=dizi[x];
        dizi[x]=tmp;
        
        printf("%d. eleman ile %d. eleman yer değiştiriyor\n",first+1,x+1);
        for (k=0; k<eleman; k++) {
            printf("%d ",dizi[k]);
        }
        printf("\n");

        
        pivot=first;
        i=first;
        j=last;
        
        printf("Pivot %d. eleman : %d\n",pivot+1,dizi[pivot]);
        
        
        while(i<j){
            while((dizi[i]<=dizi[pivot])&&(i<last))
                i++;
            while(dizi[j]>dizi[pivot])
                j--;
            if(i<j){
                tmp=dizi[i];
                dizi[i]=dizi[j];
                dizi[j]=tmp;
                
                printf("%d. eleman ile %d. eleman yer değiştiriyor\n",i+1,j+1);
                for (k=0; k<eleman; k++) {
                    printf("%d ",dizi[k]);
                }
                printf("\n");
            }
        }
        
        printf("Pivot eleman ile %d. eleman yer değiştiriyor\n",j+1);
        
        tmp=dizi[pivot];
        dizi[pivot]=dizi[j];
        dizi[j]=tmp;
        
        for (k=0; k<eleman; k++) {
            printf("%d ",dizi[k]);
        }
        printf("\n");
        quickSortİki(dizi,first,j-1,eleman);
        quickSortİki(dizi,j+1,last,eleman);
    }
}