예제 #1
0
psection()
{
	Section *sec;
	Prop *p, *p1;
	
	sec = chk_access();
	p = sec->prop;
	Printf("%s {", secname(sec));
	Printf(" nseg=%d  L=%g  Ra=%g", sec->nnode - 1, section_length(sec),
		nrn_ra(sec));
	if (p->dparam[4].val != 1) {
		Printf(" rallbranch=%g", p->dparam[4].val);
	}
	Printf("\n");
	if (sec->parentsec) {
		Printf("	%s ",secname(sec->parentsec));
		Printf("connect %s (%g), %g\n",	secname(sec),
			p->dparam[3].val, p->dparam[1].val);
	} else {
		v_setup_vectors();
		/*SUPPRESS 440*/
		Printf("	/*location %g attached to cell %d*/\n",
			p->dparam[3].val, sec->parentnode->v_node_index);
	}
	if (sec->nnode) {
		/*SUPPRESS 440*/
		Printf("	/* First segment only */\n");
		p1 = sec->pnode[0]->prop;
		pnode(p1);
	}
	Printf("}\n");
	ret(1.);
}
예제 #2
0
/*
** Losless Section Demux 1.4.1 by Emard
** Valsecchi Patrick:
**  - middle of section A  (no PUSI)
**  - end of section A and start of section B
**    (with PUSI pointing to the start of the second section)
**
**  In this case, without feed->pusi_seen you'll receive a garbage section
**  consisting of the end of section A. Basically because tsfeedp
**  is incemented and the use=0 condition is not raised
**  when the second packet arrives.
**
** Fix:
** when demux is started, let feed->pusi_seen = 0 to
** prevent initial feeding of garbage from the end of
** previous section. When you for the first time see PUSI=1
** then set feed->pusi_seen = 1
*/
static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const u8 *buf, u8 len)
{
	struct dvb_demux *demux = feed->demux;
	struct dmx_section_feed *sec = &feed->feed.sec;
	u16 limit, seclen, n;

	if(sec->tsfeedp >= DMX_MAX_SECFEED_SIZE)
		return 0;

	if(sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE)
	{
#ifdef DVB_DEMUX_SECTION_LOSS_LOG
		printk("dvb_demux.c section buffer full loss: %d/%d\n",
		       sec->tsfeedp + len - DMX_MAX_SECFEED_SIZE, DMX_MAX_SECFEED_SIZE);
#endif
		len = DMX_MAX_SECFEED_SIZE - sec->tsfeedp;
	}

	if(len <= 0)
		return 0;

	demux->memcopy(feed, sec->secbuf_base + sec->tsfeedp, buf, len);
	sec->tsfeedp += len;

	/* -----------------------------------------------------
	** Dump all the sections we can find in the data (Emard)
	*/

	limit = sec->tsfeedp;
	if(limit > DMX_MAX_SECFEED_SIZE)
		return -1; /* internal error should never happen */

	/* to be sure always set secbuf */
	sec->secbuf = sec->secbuf_base + sec->secbufp;

	for(n = 0; sec->secbufp + 2 < limit; n++)
	{
		seclen = section_length(sec->secbuf);
		if(seclen <= 0 || seclen > DMX_MAX_SECFEED_SIZE
		   || seclen + sec->secbufp > limit)
			return 0;
		sec->seclen = seclen;
		sec->crc_val = ~0;
		/* dump [secbuf .. secbuf+seclen) */
		if(feed->pusi_seen)
			dvb_dmx_swfilter_section_feed(feed);
#ifdef DVB_DEMUX_SECTION_LOSS_LOG
		else
			printk("dvb_demux.c pusi not seen, discarding section data\n");
#endif
		sec->secbufp += seclen; /* secbufp and secbuf moving together is */
		sec->secbuf += seclen; /* redundand but saves pointer arithmetic */
	}

	return 0;
}
예제 #3
0
struct dvb_tdt_section * dvb_tdt_section_codec(struct section * section)
{
	size_t len = section_length(section);
	struct dvb_tdt_section * ret = (struct dvb_tdt_section *) section;

	if (len != sizeof(struct dvb_tdt_section))
		return NULL;

	return ret;
}
예제 #4
0
static PyObject* section_getattro(NPySecObj* self, PyObject* name) {
	Py_INCREF(name);
	PyObject* rv;
	char* n = PyString_AsString(name);
//printf("section_getattr %s\n", n);
	PyObject* result = 0;
	if (strcmp(n, "L") == 0) {
		result = Py_BuildValue("d", section_length(self->sec_));
	}else if (strcmp(n, "Ra") == 0) {
		result = Py_BuildValue("d", nrn_ra(self->sec_));
	}else if (strcmp(n, "nseg") == 0) {
		result = Py_BuildValue("i", self->sec_->nnode - 1);
	}else if ((rv = PyDict_GetItemString(rangevars_, n)) != NULL) {
		Symbol* sym = ((NPyRangeVar*)rv)->sym_;
		if (ISARRAY(sym)) {
			NPyRangeVar* r = PyObject_New(NPyRangeVar, range_type);
			r->pyseg_ = PyObject_New(NPySegObj, psegment_type);
			r->pyseg_->pysec_ = self;
			Py_INCREF(self);
			r->pyseg_->x_ = 0.5;
			r->sym_ = sym;
			r->isptr_ = 0;
			result = (PyObject*)r;
		}else{
			int err;
			double* d = nrnpy_rangepointer(self->sec_, sym, 0.5, &err);
			if (!d) {
				rv_noexist(self->sec_, n, 0.5, err);
				result = NULL;
			}else{
				result = Py_BuildValue("d", *d);
			}
		}
	}else if (strcmp(n, "rallbranch") == 0) {
		result = Py_BuildValue("d", self->sec_->prop->dparam[4].val);
	}else if (strcmp(n, "__dict__") == 0) {
		result = PyDict_New();
		assert(PyDict_SetItemString(result, "L", Py_None) == 0);
		assert(PyDict_SetItemString(result, "Ra", Py_None) == 0);
		assert(PyDict_SetItemString(result, "nseg", Py_None) == 0);
		assert(PyDict_SetItemString(result, "rallbranch", Py_None) == 0);
	}else{
		result = PyObject_GenericGetAttr((PyObject*)self, name);
	}
	Py_DECREF(name);
	return result;
}
예제 #5
0
struct dvb_rst_section * dvb_rst_section_codec(struct section *section)
{
	uint8_t * buf = (uint8_t *) section;
	size_t pos = sizeof(struct section);
	size_t len = section_length(section);
	struct dvb_rst_section * ret = (struct dvb_rst_section *) section;

	while (pos < len) {
		if ((pos + sizeof(struct dvb_rst_status)) > len)
			return NULL;

		bswap16(buf + pos);
		bswap16(buf + pos + 2);
		bswap16(buf + pos + 4);
		bswap16(buf + pos + 6);

		pos += sizeof(struct dvb_rst_status);
	}

	if (pos != len)
		return NULL;

	return ret;
}
예제 #6
0
파일: method3.c 프로젝트: bhache/pkg-neuron
method3_connection_coef()	/* setup a and b */
{
	int j;
	double dx, diam, ra, coef;
	hoc_Item* qsec;
	Section* sec;
	Node *nd;
	Prop *p, *nrn_mechanism();
	float r, s, t;
	
	if (tree_changed) {
		setup_topology();
	}
/* for now assume diameter between node and parent is constant and located at the node */

	/* r = 6 is standard method, 5 is third order, 4 is modified second order */
	switch (_method3) {
	case 1:
		r = 6.;
		break;
	case 2:
		r = 4.;
		break;
	case 3:
		r = 5.;
		break;
	default:
		hoc_execerror(" invalid spatial method", (char*)0);
	}
	s = 6. - r;
	if (r == 5.) {
		t = 1.;
	}else{
		t = 0.;
	}

	ForAllSections(sec)
		dx = section_length(sec)/((double)(sec->nnode));
		for (j = 0; j < sec->nnode; ++j) {
			nd = sec->pnode[j];
			p = nrn_mechanism(MORPHOLOGY, nd);
			assert(p);
			diam = p->param[0];
			/* dv/(ra*dx) is nanoamps */
			ra = nrn_ra(sec)*4.e-2/(PI * diam*diam);
			/* coef*dx* mA/cm^2 should be nanoamps */
			coef = PI *1e-2* diam;

			nd->area = 100.;
			sec->parentnode->area = 100.;

			nd->toparent.coef0 = coef*r*dx/12.;
			nd->fromparent.coef0 = coef*r*dx/12.;
			nd->toparent.coefn = coef*s*dx/12.;
			nd->fromparent.coefn = coef*s*dx/12.;
			nd->toparent.coefjdot = t*ra*coef*dx*dx/12.;
			nd->fromparent.coefjdot = t*ra*coef*dx*dx/12.;
			nd->toparent.coefdg = t*coef*dx/12.;
			nd->fromparent.coefdg = t*coef*dx/12.;
			nd->toparent.coefj = 1./(ra*dx);
			nd->fromparent.coefj = 1./(ra*dx);
			nd->toparent.nd2 = 0;
			nd->fromparent.nd2 = 0;
		}
		if (sec->nnode > 1) {
			sec->pnode[0]->toparent.nd2 = sec->pnode[1];
			if (sec->nnode > 2) {
				sec->pnode[sec->nnode - 2]->fromparent.nd2 =
					sec->pnode[sec->nnode - 3];
			}else{
			   sec->pnode[sec->nnode - 2]->fromparent.nd2 =
				sec->parentsec->pnode[sec->parentsec->nnode - 1];
			}
		}
	}