
import sys

from scs_dfe.particulate.opc_n2 import OPCN2

from scs_host.bus.i2c import I2C
from scs_host.sys.host import Host

from scs_mfr.test.test import Test


# --------------------------------------------------------------------------------------------------------------------

class OPCTest(Test):
    """
    test script
    """

    # ----------------------------------------------------------------------------------------------------------------

    def __init__(self, verbose):
        Test.__init__(self, verbose)


    # ----------------------------------------------------------------------------------------------------------------

    def conduct(self):
        if self.verbose:
            print("OPC...", file=sys.stderr)

        opc = None

        try:
            I2C.open(Host.I2C_SENSORS)

            # resources...
            opc = OPCN2(Host.OPC_SPI_BUS, Host.OPC_SPI_DEVICE)

            opc.power_on()
            opc.operations_on()

            # test...
            self.datum = opc.firmware()

            if self.verbose:
                print(self.datum, file=sys.stderr)

            # test criterion...
            return len(self.datum) > 0 and self.datum.startswith('OPC')

        finally:
            if opc:
                opc.operations_off()
                opc.power_off()

            I2C.close()


import sys

from scs_dfe.particulate.opc_n2 import OPCN2

from scs_host.bus.i2c import I2C
from scs_host.sys.host import Host

from scs_mfr.test.test import Test


# --------------------------------------------------------------------------------------------------------------------

class OPCTest(Test):
    """
    test script
    """

    # ----------------------------------------------------------------------------------------------------------------

    def __init__(self, verbose):
        Test.__init__(self, verbose)


    # ----------------------------------------------------------------------------------------------------------------

    def conduct(self):
        if self.verbose:
            print("OPC...", file=sys.stderr)

        opc = None

        try:
            I2C.open(Host.I2C_SENSORS)

            # resources...
            opc = OPCN2(Host.opc_spi_bus(), Host.opc_spi_device())

            opc.power_on()
            opc.operations_on()

            # test...
            self.datum = opc.firmware()

            if self.verbose:
                print(self.datum, file=sys.stderr)

            # test criterion...
            return len(self.datum) > 0 and self.datum.startswith('OPC')

        finally:
            if opc:
                opc.operations_off()
                opc.power_off()

            I2C.close()

Put SPI slave configurations on Host.
Put SPI slave configurations on Host.

  
  import sys
  
  from scs_dfe.particulate.opc_n2 import OPCN2
  
  from scs_host.bus.i2c import I2C
  from scs_host.sys.host import Host
  
  from scs_mfr.test.test import Test
  
  
  # --------------------------------------------------------------------------------------------------------------------
  
  class OPCTest(Test):
      """
      test script
      """
  
      # ----------------------------------------------------------------------------------------------------------------
  
      def __init__(self, verbose):
          Test.__init__(self, verbose)
  
  
      # ----------------------------------------------------------------------------------------------------------------
  
      def conduct(self):
          if self.verbose:
              print("OPC...", file=sys.stderr)
  
          opc = None
  
          try:
              I2C.open(Host.I2C_SENSORS)
  
              # resources...
-             opc = OPCN2(Host.OPC_SPI_BUS, Host.OPC_SPI_DEVICE)
+             opc = OPCN2(Host.opc_spi_bus(), Host.opc_spi_device())
  
              opc.power_on()
              opc.operations_on()
  
              # test...
              self.datum = opc.firmware()
  
              if self.verbose:
                  print(self.datum, file=sys.stderr)
  
              # test criterion...
              return len(self.datum) > 0 and self.datum.startswith('OPC')
  
          finally:
              if opc:
                  opc.operations_off()
                  opc.power_off()
  
              I2C.close()
  
Put SPI slave configurations on Host.
## Code Before:

import sys

from scs_dfe.particulate.opc_n2 import OPCN2

from scs_host.bus.i2c import I2C
from scs_host.sys.host import Host

from scs_mfr.test.test import Test


# --------------------------------------------------------------------------------------------------------------------

class OPCTest(Test):
    """
    test script
    """

    # ----------------------------------------------------------------------------------------------------------------

    def __init__(self, verbose):
        Test.__init__(self, verbose)


    # ----------------------------------------------------------------------------------------------------------------

    def conduct(self):
        if self.verbose:
            print("OPC...", file=sys.stderr)

        opc = None

        try:
            I2C.open(Host.I2C_SENSORS)

            # resources...
            opc = OPCN2(Host.OPC_SPI_BUS, Host.OPC_SPI_DEVICE)

            opc.power_on()
            opc.operations_on()

            # test...
            self.datum = opc.firmware()

            if self.verbose:
                print(self.datum, file=sys.stderr)

            # test criterion...
            return len(self.datum) > 0 and self.datum.startswith('OPC')

        finally:
            if opc:
                opc.operations_off()
                opc.power_off()

            I2C.close()

## Instruction:
Put SPI slave configurations on Host.
## Code After:

import sys

from scs_dfe.particulate.opc_n2 import OPCN2

from scs_host.bus.i2c import I2C
from scs_host.sys.host import Host

from scs_mfr.test.test import Test


# --------------------------------------------------------------------------------------------------------------------

class OPCTest(Test):
    """
    test script
    """

    # ----------------------------------------------------------------------------------------------------------------

    def __init__(self, verbose):
        Test.__init__(self, verbose)


    # ----------------------------------------------------------------------------------------------------------------

    def conduct(self):
        if self.verbose:
            print("OPC...", file=sys.stderr)

        opc = None

        try:
            I2C.open(Host.I2C_SENSORS)

            # resources...
            opc = OPCN2(Host.opc_spi_bus(), Host.opc_spi_device())

            opc.power_on()
            opc.operations_on()

            # test...
            self.datum = opc.firmware()

            if self.verbose:
                print(self.datum, file=sys.stderr)

            # test criterion...
            return len(self.datum) > 0 and self.datum.startswith('OPC')

        finally:
            if opc:
                opc.operations_off()
                opc.power_off()

            I2C.close()
