func (s *FailoverSerialConn) BytesDelay(n int) time.Duration {
	return s.SerialContext.BytesDelay(n)
}
BytesDelay implements BytesDelay for SerialContext.
package modbusone
import (
	"bytes"
	"errors"
	"strings"
	"sync"
	"time"
)
type FailoverSerialConn struct {
	SerialContext  
	PacketReader
	isClient   bool  
	isFailover bool  
	isActive   bool  
	lock       sync.Mutex
	requestTime time.Time  
	reqPacket   bytes.Buffer
	lastRead    time.Time
	PrimaryDisconnectDelay time.Duration
	PrimaryForceBackDelay time.Duration
	startTime             time.Time
	SecondaryDelay time.Duration
	MissDelay time.Duration
	MissesMax int32
	misses    int32
}
func NewFailoverConn(sc SerialContext, isFailover, isClient bool) *FailoverSerialConn {
	c := &FailoverSerialConn{
		SerialContext:          sc,
		isClient:               isClient,
		isFailover:             isFailover,
		PrimaryDisconnectDelay: 10 * time.Second,
		PrimaryForceBackDelay:  10 * time.Minute,
		SecondaryDelay:         time.Second / 10,
		MissDelay:              time.Second / 5,
		startTime:              time.Now(),
		MissesMax:              2,
	}
	if isFailover {
		c.MissesMax += 2
	}
	c.PacketReader = NewRTUBidirectionalPacketReader(c.SerialContext)
	return c
}