Exemplo n.º 1
0
 /// SupportMaterial is generated by PrintObject.
 SupportMaterial(PrintConfig *print_config,
                 PrintObjectConfig *print_object_config,
                 Flow flow,
                 Flow first_layer_flow,
                 Flow interface_flow)
     : config(print_config),
       object_config(print_object_config),
       flow(Flow(0, 0, 0)),
       first_layer_flow(Flow(0, 0, 0)),
       interface_flow(Flow(0, 0, 0)),
       object(nullptr)
 {}
Exemplo n.º 2
0
/* This constructor builds a Flow object from a given centerline spacing. */
Flow
Flow::new_from_spacing(float spacing, float nozzle_diameter, float height, bool bridge) {
    // we need layer height unless it's a bridge
    if (height <= 0 && !bridge) CONFESS("Invalid flow height supplied to new_from_spacing()");

    float w = Flow::_width_from_spacing(spacing, nozzle_diameter, height, bridge);
    return Flow(w, height, nozzle_diameter, bridge);
}
Exemplo n.º 3
0
Flow::Flow(NetworkInterface *_iface,
	   u_int16_t _vlanId, u_int8_t _protocol,
	   u_int8_t cli_mac[6], IpAddress *_cli_ip, u_int16_t _cli_port,
	   u_int8_t srv_mac[6], IpAddress *_srv_ip, u_int16_t _srv_port) : GenericHashEntry(_iface) {
  time_t last_recvd = iface->getTimeLastPktRcvd();

  Flow(_iface, _vlanId, _protocol, cli_mac, _cli_ip, _cli_port,
       srv_mac, _srv_ip, _srv_port, last_recvd, last_recvd);
}
//---------------------------------------------------------
bool CChannelNetwork_Distance::Set_MFD(int x, int y)
{
	CSG_Vector	Flow(8);

	if( !Get_MFD(x, y, Flow) )
	{
		return( false );
	}

	double	Distance = 0.0, DistVert = 0.0, DistHorz = 0.0, Time = 0.0, SDR = 0.0;

	double	z = m_pDEM->asDouble(x, y);

	for(int i=0; i<8; i++)
	{
		if( Flow[i] > 0.0 )
		{
			int	ix = Get_xTo(i, x), iy = Get_yTo(i, y);

			double	dz	= z - m_pDEM->asDouble(ix, iy);
			double	dx	= Get_Length(i);

			Distance += Flow[i] * (m_pDistance->asDouble(ix, iy) + sqrt(dz*dz + dx*dx));
			DistVert += Flow[i] * (m_pDistVert->asDouble(ix, iy) + dz);
			DistHorz += Flow[i] * (m_pDistHorz->asDouble(ix, iy) + dx);

			if( m_pTime )
			{
				double	dt	= Get_Travel_Time(x, y, i);

				Time += Flow[i] * (m_pTime->asDouble(ix, iy) + dt);
			}
		}
	}

	if( Distance > 0.0 )
	{
		m_pDistance->Set_Value(x, y, Distance);
		m_pDistVert->Set_Value(x, y, DistVert);
		m_pDistHorz->Set_Value(x, y, DistHorz);

		if( m_pTime )
		{
			m_pTime->Set_Value(x, y, Time);
		}
	}

	return( true );
}
void CLHTMLActiveDocument::AdvancePlay()
{
//	m_totalIntendedTime += 1.0 / m_frameRate;

	if (m_document)
	{
#if 0
		CComPtr<ILDOMDocument> document;
		m_frameElement->get_contentDocument(&document);

		CComQIPtr<ILHTMLDocument> htmlDocument = document;
		if (htmlDocument)
		{
			bool bAny = static_cast<CLHTMLDocument*>(htmlDocument.p)->Seek(m_totalIntendedTime);

			if (bAny)
			{
				Flow();

				CRect urect = m_imageRect;
				urect.OffsetRect(m_client.left, m_client.top);
				m_pUI->InvalidateRect(&urect, TRUE);
				m_pUI->UpdateWindow();
			}
		}
#endif

		CComPtr<ILDOMElement> documentElement;
		m_document->get_documentElement(&documentElement);

		CComQIPtr<ILSVGSVGElement> svgsvgElement = documentElement;

		if (svgsvgElement)
		{
		/*	double currentTime;
			svgsvgElement->getCurrentTime(&currentTime);

			currentTime += 1.0 / m_frameRate;
			*/

			EnterCriticalSection(&m_paintCriticalSection);

			svgsvgElement->setCurrentTime(m_currentVideoTime);

			LeaveCriticalSection(&m_paintCriticalSection);
		}

	}
}
Exemplo n.º 6
0
int GetMaxFlowIntEK (PNEANet &Net, const int &SrcNId, const int &SnkNId) {
  IAssert(Net->IsNode(SrcNId));
  IAssert(Net->IsNode(SnkNId));
  if (SrcNId == SnkNId) { return 0; }
  int CapIndex = Net->GetIntAttrIndE(CapAttrName);
  TIntV Flow(Net->GetMxEId());
  // Initialize flow values to 0, and make sure capacities are nonnegative
  for (TNEANet::TEdgeI EI = Net->BegEI(); EI != Net->EndEI(); EI++) {
    IAssert(Net->GetIntAttrIndDatE(EI, CapIndex) >= 0);
    Flow[EI.GetId()] = 0;
  }
  // Return 0 if user attempts to flow from a node to itself.
  if (SrcNId == SnkNId) { return 0; }
  int MaxFlow = 0, MinAug, CurNId;
  while (true) {
    TIntV MidToSrcAugV; TIntV MidToSnkAugV;
    TIntQ FwdNodeQ; TIntQ BwdNodeQ;
    TIntH PredEdgeH; TIntH SuccEdgeH;
    MinAug = FindAugV(Net, CapIndex, Flow, FwdNodeQ, PredEdgeH, BwdNodeQ, SuccEdgeH, MidToSrcAugV, MidToSnkAugV, SrcNId, SnkNId);
    if (MinAug == 0) { break; }
    MaxFlow += MinAug;
    CurNId = SrcNId;
    for (int i = MidToSrcAugV.Len() - 1; i >= 0; i--) {
      int NextEId = MidToSrcAugV[i];
      const TNEANet::TEdgeI &EI = Net->GetEI(NextEId);
      if (EI.GetSrcNId() == CurNId) {
        Flow[NextEId] += MinAug;
        CurNId = EI.GetDstNId();
      } else {
        Flow[NextEId] -= MinAug;
        CurNId = EI.GetSrcNId();
      }
    }
    for (int i = 0; i < MidToSnkAugV.Len(); i++) {
      int NextEId = MidToSnkAugV[i];
      const TNEANet::TEdgeI &EI = Net->GetEI(NextEId);
      if (EI.GetSrcNId() == CurNId) {
        Flow[NextEId] += MinAug;
        CurNId = EI.GetDstNId();
      } else {
        Flow[NextEId] -= MinAug;
        CurNId = EI.GetSrcNId();
      }
    }
  }
  return MaxFlow;
}
Exemplo n.º 7
0
/* This constructor builds a Flow object from an extrusion width config setting
   and other context properties. */
Flow
Flow::new_from_config_width(FlowRole role, const ConfigOptionFloatOrPercent &width, float nozzle_diameter, float height, float bridge_flow_ratio) {
    // we need layer height unless it's a bridge
    if (height <= 0 && bridge_flow_ratio == 0) CONFESS("Invalid flow height supplied to new_from_config_width()");
    
    float w;
    if (bridge_flow_ratio > 0) {
        // if bridge flow was requested, calculate bridge width
        w = Flow::_bridge_width(nozzle_diameter, bridge_flow_ratio);
    } else if (!width.percent && width.value == 0) {
        // if user left option to 0, calculate a sane default width
        w = Flow::_auto_width(role, nozzle_diameter, height);
    } else {
        // if user set a manual value, use it
        w = width.get_abs_value(height);
    }
    
    return Flow(w, height, nozzle_diameter, bridge_flow_ratio > 0);
}
Exemplo n.º 8
0
double MoveIt(double &t,long wr_int,long nsteps,Plasma& Gas,Statistics** stats,Statistics *local,int nstat){


 long i;
 int j;

 Statistics *temp= new Statistics[nstat];
 if(!temp)fatal_error("MoveIt: memory allocation error\n");

 double E0=Gas.Epotent;

 for(j=0;j<nstat;j++){
  temp[j]=*(stats[j]);
  temp[j].clear();
  local[j].clear();
 }
 int tmp_wrdistr=write_distr;

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

  if(i%wr_int ==0)write_distr=tmp_wrdistr; // activating RR-distr write
  else write_distr=0;

  int ac=1;
  if(mc_equil==1){
    ac=MC->step(Gas);
    ac=1;
  }
  else{
    Gas.interaction();
    Gas.stepmove();
  }

  for(j=0;j<nstat;j++){
    if(ac || i==0)temp[j].next();
    else temp[j].prev();
  }

  t+=Gas.Wpe*Gas.dt;

  if(i==0 && RFstatus!=0.){ // initial state write at every equillibration proc
    double tmp=RFstatus;
    RFstatus=-0.5;
    WriteToLog(t,Gas,temp);
    RFstatus=tmp;
  }

  if((i+1)%wr_int==0 || i>=nsteps-1){ // now writing log
   WriteToLog(t,Gas,temp);
   for(j=0;j<nstat;j++){
     local[j]+=temp[j];
     temp[j].clear();
   }
  }

  if(catch_average){
    if((E0-Estab)*(Estab-Gas.Epotent)>=0){
      catch_average=0;
      break;
    }
    E0=Gas.Epotent;
  }

  if(Trajectory.valid){  // writing output
    //printf("stp\n");
    Trajectory.Step();
    //printf("done\n");
    int q=Trajectory.Query();
    while(q>=0){
      switch(q){
      case PR_IONCOORDS:
	Trajectory.Fill(Gas.x);
	printf("Wrote ion coords.\n");
	break;
      case PR_IONVEL:
	Trajectory.Fill(Gas.v);
	printf("Wrote ion velocities.\n");
	break;
      case PR_ELCCOORDS:
	Trajectory.Fill(Gas.x+Gas.ni);
	printf("Wrote electron coords.\n");
	break;
      case PR_ELCVEL:
	Trajectory.Fill(Gas.v+Gas.ni);
	printf("Wrote electron velocities.\n");
	break;
      case PR_FLOW:
	{
	  Vector_3 flow[2];
	  Flow(Gas.n,Gas.v,flow,flow+1);
	  Trajectory.Fill(flow);
	  //printf("wf\n");
	}
	break;
      case PR_UNKNOWN:
	msg_error("Unknown frame fill request!\n");
	break;

      }
      q=Trajectory.Query();
    }
  }

  // fixing temperature reached some value
  if(fixT>0 && Gas.T>fixT && !incEnd){
     // entering "shelf" regime
     limspec=0x03;
     limTe=Gas.Te;
     limTi=Gas.Ti;
     incEnd=gcount+incStp;
     lim_sw=1;
     FILE *f=fopen("shelf.d","at");
     fprintf(f,"%f %f\n",t,t-lim_t);
     fclose(f);
  }
  if(incEnd && gcount>=incEnd){
     // leaving "shelf" regime
     incEnd=0;
     lim_sw=0;
     // parameters for the next "shelf"
     fixT+=incdT;
     lim_t+=incStp*Gas.dt;
  }



  // velocity rescaling
  if(lim_sw){
    if(limspec&0x02 && Gas.Te> limTe){// maybe need to rescale electron velocities
      if(gcount%limstpe==0){
         printf("Rescaling electron velocity from %f to %f!\n",Gas.Te, limTe);
         Gas.evel_scale(limTe);
      }
    }

    if(limspec&0x01 && limstpi && Gas.Ti> limTi){// maybe need to rescale ion velocities
      if(gcount%limstpi==0){
         printf("Rescaling ion velocity from %f to %f!\n",Gas.Ti, limTi);
         Gas.ivel_scale(limTi);
      }
    }

    if(limspec&0x04 && limstp && Gas.T> limT){// maybe need to rescale all velocities
      if(gcount%limstp==0){
         printf("Rescaling all velocities from %f to %f!\n",Gas.T, limT);
         Gas.vel_scale(limT);
      }
    }
  }
  gcount++;


 }
 for(j=0;j<nstat;j++)(*(stats[j]))+=local[j];

 write_distr=tmp_wrdistr;

 delete [] temp;
 return nsteps*Gas.dt;
}
Exemplo n.º 9
0
 Flow visitCallImport(CallImport* curr) {
   return Flow(NONSTANDALONE);
 }
Exemplo n.º 10
0
	void solve(void) {
		Input();
		MakeGraph();
		printf("%d\n", Sum - Flow());
	}
Exemplo n.º 11
0
/**
 * This is a callback function that is used by the netfilter module
 * whenever a packet is intercepted and read from the netfilter queue.
 * @param qh a pointer to the handle for the nfq queue
 * @param msg a pointer to an nfgenmsg structure
 * @param pkt a pointer to the packet retrieved from the nfq queue
 * @param cbData a pointer to the data of the callback function
 * @return 0 upon success
 */
static int cb(struct nfq_q_handle *qh, struct nfgenmsg *msg, struct nfq_data *pkt, void *cbData) {
    
    // declaration of local variables
    u_int16_t id;
    u_int8_t protocol;
    unsigned char* pktData;
    Host* data = (Host*) cbData;
    
    struct ipPacket* regularPkt;
    struct ipPacket* newPkt;
    struct AITFPacket* AITFPkt;
    struct AITFPacket* newAITFPkt;
    struct routeRecord* routeRecord;
    struct nfqnl_msg_packet_hdr *header;

    // initialization of local variables
    int len = nfq_get_payload(pkt, &pktData);
    // ipAddress = (u_int32_t) cbData;
    
    // acquire the netfilter id of the received packet
    if ((header = nfq_get_msg_packet_hdr(pkt))) {
        id = ntohl(header->packet_id);
    }

    // acquire the received packet and read in its contents
    regularPkt = (struct ipPacket*) pktData;
    AITFPkt = (struct AITFPacket*) pktData;

    // determine if the packet is an AITF packet
    protocol = (u_int8_t) regularPkt->ipHeader.ip_p;

    // manage the packet when it is recognized as an AITF packet
    if (protocol == 61) {
        std::cout << "- Received an AITF packet" << std::endl;

        // drop the received packet if the route record is malformed
        if (AITFPkt->rr.position + 1 > AITFPkt->rr.length) {
            return nfq_set_verdict(qh, id, NF_DROP, 0, NULL);
        }
        
        struct ifaddrs **ifp;
        struct ifaddrs *ifpoint;
        struct sockaddr_in *ip_address;

            	getifaddrs(ifp);
            	for (ifpoint = *ifp; ifpoint != NULL; ifpoint = ifpoint->ifa_next) {
            		if (strncmp(ifpoint->ifa_name, "eth0", 10) == 0) {
            			ip_address = (sockaddr_in *) ifpoint->ifa_addr;
            			break;
            		}
            	}

        // add to the route record of the received AITF packet
        Hash hsh = Hash();
        unsigned int outlen = 0;
        AITFPkt->rr.pktFlow[AITFPkt->rr.position + 1].ip = ip_address->sin_addr;
        AITFPkt->rr.pktFlow[AITFPkt->rr.position + 1].nonce = 1;
        
        // produce the flow to send to the policy module
        Flow flow = Flow(AITFPkt->rr.pktFlow, AITFPkt->rr.length);

        // provide observed packet flow to host policy module
        HostPolicyModule policyModule = HostPolicyModule();
        if (policyModule.checkHighFlowPolicy(flow) == true){
        	data->sendMessage(flow);
        }

        // remove the route record shim from the packet
        newPkt->ipHeader = AITFPkt->ipHeader;
        newPkt->ipHeader.ip_p = AITFPkt->rr.protocol;
        newPkt->ipHeader.ip_sum = checksum((void*) newPkt, sizeof(struct ipPacket));

        // drop the modified packet back into to be received by a socket
        memcpy(newPkt->payload, AITFPkt->payload, 1500);
        return nfq_set_verdict(qh, id, NF_ACCEPT, sizeof(ipPacket), (const unsigned char*) newPkt);
    }
    std::cout << "- Returning packet back to queue" << std::endl;

    newAITFPkt->ipHeader = regularPkt->ipHeader;
    memmove(newAITFPkt->payload, regularPkt->payload, 1500);
    newAITFPkt->rr.length = 10;
    newAITFPkt->rr.position = 0;
    newAITFPkt->rr.protocol = 61;
    newAITFPkt->rr.pktFlow[0].ip = regularPkt->ipHeader.ip_src;
    newAITFPkt->rr.pktFlow[0].nonce = 1;
    newAITFPkt->ipHeader.ip_sum = checksum(newAITFPkt, sizeof(AITFPacket));

    return nfq_set_verdict(qh, id, NF_ACCEPT, sizeof(AITFPacket), (const unsigned char*) newAITFPkt);
}
Exemplo n.º 12
0
 Flow visitStore(Store *curr) {
   return Flow(NONSTANDALONE);
 }
Exemplo n.º 13
0
 Flow visitHost(Host *curr) {
   return Flow(NONSTANDALONE);
 }
Exemplo n.º 14
0
 Flow visitSetGlobal(SetGlobal *curr) {
   return Flow(NONSTANDALONE);
 }
Exemplo n.º 15
0
 Flow visitLoad(Load *curr) {
   return Flow(NONSTANDALONE);
 }
Exemplo n.º 16
0
 Flow visitCallIndirect(CallIndirect* curr) {
   return Flow(NONSTANDALONE);
 }
Exemplo n.º 17
0
 Flow visitGetLocal(GetLocal *curr) {
   return Flow(NONSTANDALONE);
 }
Exemplo n.º 18
0
void UmlFlow::importIt(FileIn & in, Token & token, UmlItem *)
{
  Flow & flow = *(All.append(Flow()));
  QCString s;
  
  flow.id = token.xmiId();
  flow.name = token.valueOf("name");
  flow.interrupt = (token.what() == "interruptingedge");
  flow.source = token.valueOf("source");
  flow.target = token.valueOf("target");
  flow.selection = token.valueOf("selection");
  flow.transformation = token.valueOf("transformation");
  
  if (! token.closed()) {
    QCString k = token.what();
    const char * kstr = k;
      
    while (in.read(), !token.close(kstr)) {
      s = token.what();
      
      if (s == "selection") {
	flow.selection = token.valueOf("idref");
	if (! token.closed())
	  in.finish(s);
      }
      else if (s == "transformation") {
	flow.transformation = token.valueOf("idref");
	if (! token.closed())
	  in.finish(s);
      }
      else if (s == "weight") {
	flow.weight = token.valueOf("value");
	if (! token.closed())
	  in.finish(s);
      }
      else if (s == "guard") {
	QCString b = token.valueOf("body");
	
	if (! b.isNull()) {
	  flow.guard = b;
	  if (! token.closed())
	    in.finish(s);
	}
	else if (! token.closed()) {
	  while (in.read(), !token.close("guard")) {
	    b = token.what();
      
	    if (b == "body") {
	      flow.guard = in.body("body");
	      in.finish("guard");
	      break;
	    }
	    else if (! token.closed())
	      in.finish(b);
	  }
	}
      }
      else if (! token.closed())
	in.finish(s);
    }
  }
}
Exemplo n.º 19
0
 Flow visitCall(Call* curr) {
   return Flow(NONSTANDALONE);
 }
Exemplo n.º 20
0
 Flow visitLoop(Loop* curr) {
   // loops might be infinite, so must be careful
   // but we can't tell if non-infinite, since we don't have state, so loops are just impossible to optimize for now
   return Flow(NONSTANDALONE);
 }
Exemplo n.º 21
0
//-=========================================
// MUpperControl methods
//-=========================================        
void CIPProtoBinder::StartSending()
	{
	__CFLOG_1(KIPProtoTag1, KIPProtoTag2, _L("CIPProtoBinder %08x:\tStartSending()"), this);
	Flow().BinderReady();	
	iNif->StartSending();
	}
Exemplo n.º 22
0
void CIPProtoBinder::Error(TInt aError)
	{
	__CFLOG_2(KIPProtoTag1, KIPProtoTag2, _L("CIPProtoBinder %08x:\tError(%d)"), this, aError);
	Flow().BinderError(aError, this);
	}