#!/usr/bin/env python3
#-----------------------------------------------------------------------------
# Title      : Example Root
#-----------------------------------------------------------------------------
# This file is part of the rogue_example software. It is subject to
# the license terms in the LICENSE.txt file found in the top-level directory
# of this distribution and at:
#    https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
# No part of the rogue_example software, including this file, may be
# copied, modified, propagated, or distributed except according to the terms
# contained in the LICENSE.txt file.
#-----------------------------------------------------------------------------
import pyrogue
import pyrogue.interfaces.simulation
import pyrogue.utilities.fileio
import pyrogue.utilities.prbs
import pyrogue.examples
import pyrogue.protocols
import rogue.interfaces.stream
import rogue.interfaces.memory
import rogue
import math
import numpy as np
import matplotlib.pyplot as plt
import TestDevice

class ExampleRoot(pyrogue.Root):

    def __init__(self):
        pyrogue.Root.__init__(self,
                              description="Example Root",
                              timeout=2.0,
                              pollEn=True)

        # Use a memory space emulator
        sim = rogue.interfaces.memory.Emulate(4,0x1000)
        sim.setName("SimSlave")
        self.addInterface(sim)

        self.add(TestDevice.ExampleDevice(memBase=sim))

        # Add zmq server
        self.zmqServer = pyrogue.interfaces.ZmqServer(root=self, addr='127.0.0.1', port=0)
        self.addInterface(self.zmqServer)

