Beispiel #1
0
func NewFMon(s string, p uint) *ImpFMon {
	//
	var nL, nR int
	c := func(a Any, k uint) bool {
		switch k {
		case lIn:
			return nR == 0
		case rIn:
			return nL == 0 && nR == 0
		}
		return true
	}
	f := func(a Any, k uint) Any {
		switch k {
		case lIn:
			nL++
		case lOut:
			nL--
		case rIn:
			nR = 1
		case rOut:
			nR = 0
		}
		return true
	}
	return &ImpFMon{fmon.New(true, 4, f, c, s, p)}
}
Beispiel #2
0
func NewFMon(s string, p uint) *ImpFMon {
	//
	var nR, nW int
	c := func(a Any, k uint) bool {
		switch k {
		case rIn:
			return nW == 0
		case wIn:
			return nR == 0 && nW == 0
		}
		return true
	}
	f := func(a Any, k uint) Any {
		switch k {
		case rIn:
			nR++
		case rOut:
			nR--
		case wIn:
			nW = 1
		case wOut:
			nW = 0
		}
		return true
	}
	return &ImpFMon{fmon.New(true, 4, f, c, s, p)}
}
Beispiel #3
0
func init() {
	//
	b = new(botschaft)
	Monitor = fmon.New(b, AnzahlOperationen, f, TrueSp, Anbieter, 90)
	Monitor.Prepare(func() { rob.WeltDefinieren() })
	//  TerminierungInstallieren (terminieren)
	Initialisieren() // läuft nicht mehr auf dem Anbieter !
}
Beispiel #4
0
func NewF(n uint, s string, p uint) *ImpF {
	//
	val := n
	c := func(a Any, i uint) bool {
		if i == 0 {
			return val > 0
		} // P
		return true // V
	}
	f := func(a Any, i uint) Any {
		if i == 0 { // P
			val--
		} else {
			val++ // V
		}
		return true
	}
	return &ImpF{fmon.New(false, 2, f, c, s, p)}
}
Beispiel #5
0
func NewF(a Any, s string, p uint) *ImpF {
	//
	x := new(ImpF)
	x.object = Clone(a)
	x.Imp = New(a)
	c := func(a Any, i uint) bool {
		if i == 1 { // push
			return true
		}
		return !x.Imp.Empty() // top, pop
	}
	f := func(a Any, i uint) Any {
		if i == 2 { // top
			return x.Imp.Top()
		}
		return x.object // push, pop
	}
	x.m = fmon.New(a, 3, f, c, s, p)
	return x
}
Beispiel #6
0
func NewF(a Any, s string, p uint) *ImpF {
	//
	q := New(a)
	c := func(a Any, i uint) bool {
		switch i {
		case 2: // Get
			return !q.Empty()
		}
		return true // Num, Ins
	}
	f := func(a Any, i uint) Any {
		switch i {
		case 0:
			return q.Num()
		case 1:
			q.Ins(a)
		case 2:
			return q.Get()
		}
		return a
	}
	return &ImpF{fmon.New(q, 3, f, c, s, p)}
}
Beispiel #7
0
func NewF(s string, p uint) *ImpF {
	//
	x := new(ImpF)
	balance := euro.New()
	balance.Set2(0, 0)
	c := func(a Any, i uint) bool {
		if i == 1 { // draw
			return a.(*euro.Imp).Eq(balance) || a.(*euro.Imp).Less(balance)
		}
		return true // deposit
	}
	f := func(a Any, i uint) Any {
		balance.Write(0, 0)
		if i == 0 { // deposit
			balance.Plus(a.(*euro.Imp))
		} else { // draw
			balance.Minus(a.(*euro.Imp))
		}
		balance.Write(1, 0)
		return balance
	}
	x.Imp = fmon.New(balance, 2, f, c, s, p)
	return x
}
Beispiel #8
0
func NewF(a Any, n uint, s string, p uint) *ImpF {
	//
	if a == nil || n == 0 {
		return nil
	}
	x := new(ImpF)
	x.object = Clone(a)
	x.b = newBuffer(a, n)
	c := func(a Any, i uint) bool {
		if i == 0 { // Ins
			return true
		}
		return x.b.Num() > 0 // Get
	}
	f := func(a Any, i uint) Any {
		switch i {
		case 1: // Get
			return x.b.Get()
		}
		return x.object // Ins
	}
	x.m = fmon.New(a, 2, f, c, s, p)
	return x
}