Example #1
0
 def __init__(self, t, brokerAdd, brokerPort, modbusAdd, modbusPort):
     self.t = t
     self.brokerAdd = brokerAdd
     self.brokerPort = brokerPort
     self.mqttc = mqtt.Client()
     self.mqttc.connect(self.brokerAdd, self.brokerPort, 60)
     self.modbusclient = SeedlingModbusClient(modbusAdd, modbusPort)
     self.thread = Timer(self.t, self.publishRegisters)
     self.thread.start()
            int.from_bytes(bytes[1 + 2 * i:3 + 2 * i], "big"))
    return decoded_response


def on_message(client, userdata, message):
    print("Received message '" + str(message.payload) + "' on topic '" +
          message.topic + "' with QoS " + str(message.qos))


tcpipvals = {
    "modServerIp": "192.168.0.17",
    "modServerPort": 502,
    "brokerIp": "192.168.0.10",
    "brokerPort": 1884
}  #PUT HERE THE IP/PORT VALUES
client_1 = SeedlingModbusClient(tcpipvals["modServerIp"],
                                tcpipvals["modServerPort"])
client_1.connect()
subscriber = mqtt.Client()
subscriber.connect(tcpipvals["brokerIp"], tcpipvals["brokerPort"], 60)
subscriber.subscribe("robot/bandejas/alimentadora/bandejas")
subscriber.on_message = on_message
subscriber.loop_start()
#response = client_1.read_holding_registers(4014,7,unit=0x1)
#response = modbus_holding_reg_decode(response)
#print(response)

while (True):
    #response = client_1.read_holding_registers(4014, 8, unit=0x1)
    #response = modbus_holding_reg_decode(response)
    print("ModbusVal = {}".format(client_1.getProcessedTrays()))
    sleep(1.5)
Example #3
0
from libseedlingmodbus import SeedlingModbusClient


def modbus_holding_reg_decode(response):
    decoded_response = []
    bytes = response.encode()
    num_bytes = int(bytes[0])
    for i in range(int(num_bytes / 2)):
        decoded_response.append(
            int.from_bytes(bytes[1 + 2 * i:3 + 2 * i], "big"))
    return decoded_response


_client = {"ip": "192.168.1.103", "port": 502}

client1 = SeedlingModbusClient(_client["ip"], _client["port"])
client1.connectToServer()

#response = client_1.read_holding_registers(4014,7,unit=0x1)
#response = modbus_holding_reg_decode(response)
#print(response)

while (True):
    #response = client_1.read_holding_registers(4014, 8, unit=0x1)
    #response = modbus_holding_reg_decode(response)
    #response = client1.getProcessedTrays()
    #response = client1.getcurrentASeedlings()
    response = client1.readModbusHoldReg(4104)
    print(response)
    #client1.writeStatus(16)
    #client1.write_register(4, 65)
    def __init__(self, tcpipdict):
        tk.Tk.__init__(self)
        self.tcpipdict = tcpipdict
        self.client = SeedlingModbusClient(
            self.tcpipdict["modServerIp"],
            self.tcpipdict["modServerPort"])  #create de Modbus client
        self.client.connect()
        self.readRegsthread = Timer(0.5, self.readRegs)
        self.readRegsthread.start()
        #self.publisher = registerPublisher(1.0,self.tcpipdict["brokerIp"],self.tcpipdict["brokerPort"],self.tcpipdict["modServerIp"],self.tcpipdict["modServerPort"])
        self.title("PLC <--> MODBUS-TCP<--> MQTT : AUTOMATIC RANDOM MODE")
        self.geometry("1200x900")
        self.resizable(0, 0)
        self.label_width = 25
        self.Label_processedTrays = tk.Label(self,
                                             text="Processed Trays",
                                             height=2,
                                             width=self.label_width,
                                             font="Times 14 bold")
        self.Label_processedTrays.grid(row=0, column=0)
        self.Label_processedTraysnum = tk.Label(self,
                                                text="0",
                                                height=2,
                                                width=self.label_width,
                                                font="Times 14 bold",
                                                bg="yellow")
        self.Label_processedTraysnum.grid(row=0, column=1)

        self.Label_classifiedSeedlings = tk.Label(self,
                                                  text="Classified Seedlings",
                                                  height=2,
                                                  width=self.label_width,
                                                  font="Times 14 bold")
        self.Label_classifiedSeedlings.grid(row=1, column=0)
        self.Label_classifiedSeedlingsnum = tk.Label(self,
                                                     text="0",
                                                     height=2,
                                                     width=self.label_width,
                                                     font="Times 14 bold",
                                                     bg="yellow")
        self.Label_classifiedSeedlingsnum.grid(row=1, column=1)

        self.Label_currASeedlings = tk.Label(self,
                                             text="Current Class A seedlings",
                                             height=2,
                                             width=self.label_width,
                                             font="Times 14 bold")
        self.Label_currASeedlings.grid(row=2, column=0)
        self.Label_currASeedlingsnum = tk.Label(self,
                                                text="0",
                                                height=2,
                                                width=self.label_width,
                                                font="Times 14 bold",
                                                bg="yellow")
        self.Label_currASeedlingsnum.grid(row=2, column=1)

        self.Label_currBSeedlings = tk.Label(self,
                                             text="Current Class B seedlings",
                                             height=2,
                                             width=self.label_width,
                                             font="Times 14 bold")
        self.Label_currBSeedlings.grid(row=3, column=0)
        self.Label_currBSeedlingsnum = tk.Label(self,
                                                text="0",
                                                height=2,
                                                width=self.label_width,
                                                font="Times 14 bold",
                                                bg="yellow")
        self.Label_currBSeedlingsnum.grid(row=3, column=1)

        self.Label_currCSeedlings = tk.Label(self,
                                             text="Current Class C seedlings",
                                             height=2,
                                             width=self.label_width,
                                             font="Times 14 bold")
        self.Label_currCSeedlings.grid(row=4, column=0)
        self.Label_currCSeedlingsnum = tk.Label(self,
                                                text="0",
                                                height=2,
                                                width=self.label_width,
                                                font="Times 14 bold",
                                                bg="yellow")
        self.Label_currCSeedlingsnum.grid(row=4, column=1)

        self.Label_totalAtrays = tk.Label(self,
                                          text="Total Class A trays",
                                          height=2,
                                          width=self.label_width,
                                          font="Times 14 bold")
        self.Label_totalAtrays.grid(row=5, column=0)
        self.Label_totalAtraysnum = tk.Label(self,
                                             text="0",
                                             height=2,
                                             width=self.label_width,
                                             font="Times 14 bold",
                                             bg="yellow")
        self.Label_totalAtraysnum.grid(row=5, column=1)

        self.Label_totalBtrays = tk.Label(self,
                                          text="Total Class B trays",
                                          height=2,
                                          width=self.label_width,
                                          font="Times 14 bold")
        self.Label_totalBtrays.grid(row=6, column=0)
        self.Label_totalBtraysnum = tk.Label(self,
                                             text="0",
                                             height=2,
                                             width=self.label_width,
                                             font="Times 14 bold",
                                             bg="yellow")
        self.Label_totalBtraysnum.grid(row=6, column=1)

        self.Label_totalCtrays = tk.Label(self,
                                          text="Total Class C trays",
                                          height=2,
                                          width=self.label_width,
                                          font="Times 14 bold")
        self.Label_totalCtrays.grid(row=7, column=0)
        self.Label_totalCtraysnum = tk.Label(self,
                                             text="0",
                                             height=2,
                                             width=self.label_width,
                                             font="Times 14 bold",
                                             bg="yellow")
        self.Label_totalCtraysnum.grid(row=7, column=1)

        self.Label_XPosition = tk.Label(self,
                                        text="X position",
                                        height=2,
                                        width=self.label_width,
                                        font="Times 14 bold")
        self.Label_XPosition.grid(row=8, column=0)
        self.Label_XPositionnum = tk.Label(self,
                                           text="0",
                                           height=2,
                                           width=self.label_width,
                                           font="Times 14 bold",
                                           bg="yellow")
        self.Label_XPositionnum.grid(row=8, column=1)

        self.Label_YPosition = tk.Label(self,
                                        text="Y position",
                                        height=2,
                                        width=self.label_width,
                                        font="Times 14 bold")
        self.Label_YPosition.grid(row=9, column=0)
        self.Label_YPositionnum = tk.Label(self,
                                           text="0",
                                           height=2,
                                           width=self.label_width,
                                           font="Times 14 bold",
                                           bg="yellow")
        self.Label_YPositionnum.grid(row=9, column=1)

        self.Label_Z1Position = tk.Label(self,
                                         text="Z1 position",
                                         height=2,
                                         width=self.label_width,
                                         font="Times 14 bold")
        self.Label_Z1Position.grid(row=10, column=0)
        self.Label_Z1Positionnum = tk.Label(self,
                                            text="0",
                                            height=2,
                                            width=self.label_width,
                                            font="Times 14 bold",
                                            bg="yellow")
        self.Label_Z1Positionnum.grid(row=10, column=1)

        self.Label_Z2Position = tk.Label(self,
                                         text="Z2 position",
                                         height=2,
                                         width=self.label_width,
                                         font="Times 14 bold")
        self.Label_Z2Position.grid(row=11, column=0)
        self.Label_Z2Positionnum = tk.Label(self,
                                            text="0",
                                            height=2,
                                            width=self.label_width,
                                            font="Times 14 bold",
                                            bg="yellow")
        self.Label_Z2Positionnum.grid(row=11, column=1)

        self.Label_Z3Position = tk.Label(self,
                                         text="Z3 position",
                                         height=2,
                                         width=self.label_width,
                                         font="Times 14 bold")
        self.Label_Z3Position.grid(row=12, column=0)
        self.Label_Z3Positionnum = tk.Label(self,
                                            text="0",
                                            height=2,
                                            width=self.label_width,
                                            font="Times 14 bold",
                                            bg="yellow")
        self.Label_Z3Positionnum.grid(row=12, column=1)

        self.Label_FTrayPosition = tk.Label(self,
                                            text="Feeder Tray Position",
                                            height=2,
                                            width=self.label_width,
                                            font="Times 14 bold")
        self.Label_FTrayPosition.grid(row=0, column=2)
        self.Label_FTrayPositionnum = tk.Label(self,
                                               text="0",
                                               height=2,
                                               width=self.label_width,
                                               font="Times 14 bold",
                                               bg="yellow")
        self.Label_FTrayPositionnum.grid(row=0, column=3)

        self.Label_ATrayPosition = tk.Label(self,
                                            text="Class A Tray Position",
                                            height=2,
                                            width=self.label_width,
                                            font="Times 14 bold")
        self.Label_ATrayPosition.grid(row=1, column=2)
        self.Label_ATrayPositionnum = tk.Label(self,
                                               text="0",
                                               height=2,
                                               width=self.label_width,
                                               font="Times 14 bold",
                                               bg="yellow")
        self.Label_ATrayPositionnum.grid(row=1, column=3)

        self.Label_BTrayPosition = tk.Label(self,
                                            text="Class B Tray Position",
                                            height=2,
                                            width=self.label_width,
                                            font="Times 14 bold")
        self.Label_BTrayPosition.grid(row=2, column=2)
        self.Label_BTrayPositionnum = tk.Label(self,
                                               text="0",
                                               height=2,
                                               width=self.label_width,
                                               font="Times 14 bold",
                                               bg="yellow")
        self.Label_BTrayPositionnum.grid(row=2, column=3)

        self.Label_CTrayPosition = tk.Label(self,
                                            text="Class C Tray Position",
                                            height=2,
                                            width=self.label_width,
                                            font="Times 14 bold")
        self.Label_CTrayPosition.grid(row=3, column=2)
        self.Label_CTrayPositionnum = tk.Label(self,
                                               text="0",
                                               height=2,
                                               width=self.label_width,
                                               font="Times 14 bold",
                                               bg="yellow")
        self.Label_CTrayPositionnum.grid(row=3, column=3)

        self.Label_NXPosition = tk.Label(self,
                                         text="Needles X Position",
                                         height=2,
                                         width=self.label_width,
                                         font="Times 14 bold")
        self.Label_NXPosition.grid(row=4, column=2)
        self.Label_NXPositionnum = tk.Label(self,
                                            text="0",
                                            height=2,
                                            width=self.label_width,
                                            font="Times 14 bold",
                                            bg="yellow")
        self.Label_NXPositionnum.grid(row=4, column=3)

        self.Label_NYPosition = tk.Label(self,
                                         text="Needles Y Position",
                                         height=2,
                                         width=self.label_width,
                                         font="Times 14 bold")
        self.Label_NYPosition.grid(row=5, column=2)
        self.Label_NYPositionnum = tk.Label(self,
                                            text="0",
                                            height=2,
                                            width=self.label_width,
                                            font="Times 14 bold",
                                            bg="yellow")
        self.Label_NYPositionnum.grid(row=5, column=3)

        self.Label_GripperStat = tk.Label(self,
                                          text="Gripper status",
                                          height=2,
                                          width=self.label_width,
                                          font="Times 14 bold")
        self.Label_GripperStat.grid(row=6, column=2)
        self.Label_GripperStatnum = tk.Label(self,
                                             text="0",
                                             height=2,
                                             width=self.label_width,
                                             font="Times 14 bold",
                                             bg="yellow")
        self.Label_GripperStatnum.grid(row=6, column=3)

        self.Label_Alarm = tk.Label(self,
                                    text="Alarm",
                                    height=2,
                                    width=self.label_width,
                                    font="Times 14 bold")
        self.Label_Alarm.grid(row=7, column=2)
        self.Label_Alarmval = tk.Label(self,
                                       text="0",
                                       height=2,
                                       width=self.label_width,
                                       font="Times 14 bold",
                                       bg="yellow")
        self.Label_Alarmval.grid(row=7, column=3)

        self.Label_PlcInstruct = tk.Label(self,
                                          text="PLC instruction",
                                          height=2,
                                          width=self.label_width,
                                          font="Times 14 bold")
        self.Label_PlcInstruct.grid(row=8, column=2)
        self.Label_PlcInstructval = tk.Label(self,
                                             text="0",
                                             height=2,
                                             width=self.label_width,
                                             font="Times 14 bold",
                                             bg="yellow")
        self.Label_PlcInstructval.grid(row=8, column=3)

        self.Label_CvStatus = tk.Label(self,
                                       text="CV status",
                                       height=2,
                                       width=self.label_width,
                                       font="Times 14 bold")
        self.Label_CvStatus.grid(row=9, column=2)
        self.Label_CvStatusval = tk.Label(self,
                                          text="0",
                                          height=2,
                                          width=self.label_width,
                                          font="Times 14 bold",
                                          bg="orange")
        self.Label_CvStatusval.grid(row=9, column=3)

        self.Label_S1Quality = tk.Label(self,
                                        text="Seedling 1 Quality",
                                        height=2,
                                        width=self.label_width,
                                        font="Times 14 bold")
        self.Label_S1Quality.grid(row=10, column=2)
        self.Label_S1Qualityval = tk.Label(self,
                                           text="0",
                                           height=2,
                                           width=self.label_width,
                                           font="Times 14 bold",
                                           bg="orange")
        self.Label_S1Qualityval.grid(row=10, column=3)

        self.Label_S2Quality = tk.Label(self,
                                        text="Seedling 2 Quality",
                                        height=2,
                                        width=self.label_width,
                                        font="Times 14 bold")
        self.Label_S2Quality.grid(row=11, column=2)
        self.Label_S2Qualityval = tk.Label(self,
                                           text="0",
                                           height=2,
                                           width=self.label_width,
                                           font="Times 14 bold",
                                           bg="orange")
        self.Label_S2Qualityval.grid(row=11, column=3)

        self.Label_S3Quality = tk.Label(self,
                                        text="Seedling 3 Quality",
                                        height=2,
                                        width=self.label_width,
                                        font="Times 14 bold")
        self.Label_S3Quality.grid(row=12, column=2)
        self.Label_S3Qualityval = tk.Label(self,
                                           text="0",
                                           height=2,
                                           width=self.label_width,
                                           font="Times 14 bold",
                                           bg="orange")
        self.Label_S3Qualityval.grid(row=12, column=3)
    def __init__(self, tcpipdict):
        tk.Tk.__init__(self)
        self.selectionq1 = tk.IntVar()
        self.selectionq2 = tk.IntVar()
        self.selectionq3 = tk.IntVar()
        self.qualityS1 = lsmodb.QTY_EMPTY
        self.qualityS2 = lsmodb.QTY_EMPTY
        self.qualityS3 = lsmodb.QTY_EMPTY
        self.tcpipdict = tcpipdict
        self.client = SeedlingModbusClient(
            self.tcpipdict["modServerIp"],
            self.tcpipdict["modServerPort"])  #create de Modbus client
        self.client.connect()
        self.readRegsthread = Timer(0.5, self.readRegs)
        self.readRegsthread.start()
        #self.publisher = registerPublisher(1.0,self.tcpipdict["brokerIp"],self.tcpipdict["brokerPort"],self.tcpipdict["modServerIp"],self.tcpipdict["modServerPort"])
        self.title("PLC <--> MODBUS-TCP<--> MQTT : INTERACTIVE MODE")
        self.geometry("1200x900")
        self.resizable(0, 0)
        self.label_width = 25
        self.Label_processedTrays = tk.Label(self,
                                             text="Processed Trays",
                                             height=2,
                                             width=self.label_width,
                                             font="Times 14 bold")
        self.Label_processedTrays.grid(row=0, column=0)
        self.Label_processedTraysnum = tk.Label(self,
                                                text="0",
                                                height=2,
                                                width=self.label_width,
                                                font="Times 14 bold",
                                                bg="yellow")
        self.Label_processedTraysnum.grid(row=0, column=1)

        self.Label_classifiedSeedlings = tk.Label(self,
                                                  text="Classified Seedlings",
                                                  height=2,
                                                  width=self.label_width,
                                                  font="Times 14 bold")
        self.Label_classifiedSeedlings.grid(row=1, column=0)
        self.Label_classifiedSeedlingsnum = tk.Label(self,
                                                     text="0",
                                                     height=2,
                                                     width=self.label_width,
                                                     font="Times 14 bold",
                                                     bg="yellow")
        self.Label_classifiedSeedlingsnum.grid(row=1, column=1)

        self.Label_currASeedlings = tk.Label(self,
                                             text="Current Class A seedlings",
                                             height=2,
                                             width=self.label_width,
                                             font="Times 14 bold")
        self.Label_currASeedlings.grid(row=2, column=0)
        self.Label_currASeedlingsnum = tk.Label(self,
                                                text="0",
                                                height=2,
                                                width=self.label_width,
                                                font="Times 14 bold",
                                                bg="yellow")
        self.Label_currASeedlingsnum.grid(row=2, column=1)

        self.Label_currBSeedlings = tk.Label(self,
                                             text="Current Class B seedlings",
                                             height=2,
                                             width=self.label_width,
                                             font="Times 14 bold")
        self.Label_currBSeedlings.grid(row=3, column=0)
        self.Label_currBSeedlingsnum = tk.Label(self,
                                                text="0",
                                                height=2,
                                                width=self.label_width,
                                                font="Times 14 bold",
                                                bg="yellow")
        self.Label_currBSeedlingsnum.grid(row=3, column=1)

        self.Label_currCSeedlings = tk.Label(self,
                                             text="Current Class C seedlings",
                                             height=2,
                                             width=self.label_width,
                                             font="Times 14 bold")
        self.Label_currCSeedlings.grid(row=4, column=0)
        self.Label_currCSeedlingsnum = tk.Label(self,
                                                text="0",
                                                height=2,
                                                width=self.label_width,
                                                font="Times 14 bold",
                                                bg="yellow")
        self.Label_currCSeedlingsnum.grid(row=4, column=1)

        self.Label_totalAtrays = tk.Label(self,
                                          text="Total Class A trays",
                                          height=2,
                                          width=self.label_width,
                                          font="Times 14 bold")
        self.Label_totalAtrays.grid(row=5, column=0)
        self.Label_totalAtraysnum = tk.Label(self,
                                             text="0",
                                             height=2,
                                             width=self.label_width,
                                             font="Times 14 bold",
                                             bg="yellow")
        self.Label_totalAtraysnum.grid(row=5, column=1)

        self.Label_totalBtrays = tk.Label(self,
                                          text="Total Class B trays",
                                          height=2,
                                          width=self.label_width,
                                          font="Times 14 bold")
        self.Label_totalBtrays.grid(row=6, column=0)
        self.Label_totalBtraysnum = tk.Label(self,
                                             text="0",
                                             height=2,
                                             width=self.label_width,
                                             font="Times 14 bold",
                                             bg="yellow")
        self.Label_totalBtraysnum.grid(row=6, column=1)

        self.Label_totalCtrays = tk.Label(self,
                                          text="Total Class C trays",
                                          height=2,
                                          width=self.label_width,
                                          font="Times 14 bold")
        self.Label_totalCtrays.grid(row=7, column=0)
        self.Label_totalCtraysnum = tk.Label(self,
                                             text="0",
                                             height=2,
                                             width=self.label_width,
                                             font="Times 14 bold",
                                             bg="yellow")
        self.Label_totalCtraysnum.grid(row=7, column=1)

        self.Label_XPosition = tk.Label(self,
                                        text="X position",
                                        height=2,
                                        width=self.label_width,
                                        font="Times 14 bold")
        self.Label_XPosition.grid(row=8, column=0)
        self.Label_XPositionnum = tk.Label(self,
                                           text="0",
                                           height=2,
                                           width=self.label_width,
                                           font="Times 14 bold",
                                           bg="yellow")
        self.Label_XPositionnum.grid(row=8, column=1)

        self.Label_YPosition = tk.Label(self,
                                        text="Y position",
                                        height=2,
                                        width=self.label_width,
                                        font="Times 14 bold")
        self.Label_YPosition.grid(row=9, column=0)
        self.Label_YPositionnum = tk.Label(self,
                                           text="0",
                                           height=2,
                                           width=self.label_width,
                                           font="Times 14 bold",
                                           bg="yellow")
        self.Label_YPositionnum.grid(row=9, column=1)

        self.Label_Z1Position = tk.Label(self,
                                         text="Z1 position",
                                         height=2,
                                         width=self.label_width,
                                         font="Times 14 bold")
        self.Label_Z1Position.grid(row=10, column=0)
        self.Label_Z1Positionnum = tk.Label(self,
                                            text="0",
                                            height=2,
                                            width=self.label_width,
                                            font="Times 14 bold",
                                            bg="yellow")
        self.Label_Z1Positionnum.grid(row=10, column=1)

        self.Label_Z2Position = tk.Label(self,
                                         text="Z2 position",
                                         height=2,
                                         width=self.label_width,
                                         font="Times 14 bold")
        self.Label_Z2Position.grid(row=11, column=0)
        self.Label_Z2Positionnum = tk.Label(self,
                                            text="0",
                                            height=2,
                                            width=self.label_width,
                                            font="Times 14 bold",
                                            bg="yellow")
        self.Label_Z2Positionnum.grid(row=11, column=1)

        self.Label_Z3Position = tk.Label(self,
                                         text="Z3 position",
                                         height=2,
                                         width=self.label_width,
                                         font="Times 14 bold")
        self.Label_Z3Position.grid(row=12, column=0)
        self.Label_Z3Positionnum = tk.Label(self,
                                            text="0",
                                            height=2,
                                            width=self.label_width,
                                            font="Times 14 bold",
                                            bg="yellow")
        self.Label_Z3Positionnum.grid(row=12, column=1)

        self.Label_FTrayPosition = tk.Label(self,
                                            text="Feeder Tray Position",
                                            height=2,
                                            width=self.label_width,
                                            font="Times 14 bold")
        self.Label_FTrayPosition.grid(row=0, column=2)
        self.Label_FTrayPositionnum = tk.Label(self,
                                               text="0",
                                               height=2,
                                               width=self.label_width,
                                               font="Times 14 bold",
                                               bg="yellow")
        self.Label_FTrayPositionnum.grid(row=0, column=3)

        self.Label_ATrayPosition = tk.Label(self,
                                            text="Class A Tray Position",
                                            height=2,
                                            width=self.label_width,
                                            font="Times 14 bold")
        self.Label_ATrayPosition.grid(row=1, column=2)
        self.Label_ATrayPositionnum = tk.Label(self,
                                               text="0",
                                               height=2,
                                               width=self.label_width,
                                               font="Times 14 bold",
                                               bg="yellow")
        self.Label_ATrayPositionnum.grid(row=1, column=3)

        self.Label_BTrayPosition = tk.Label(self,
                                            text="Class B Tray Position",
                                            height=2,
                                            width=self.label_width,
                                            font="Times 14 bold")
        self.Label_BTrayPosition.grid(row=2, column=2)
        self.Label_BTrayPositionnum = tk.Label(self,
                                               text="0",
                                               height=2,
                                               width=self.label_width,
                                               font="Times 14 bold",
                                               bg="yellow")
        self.Label_BTrayPositionnum.grid(row=2, column=3)

        self.Label_CTrayPosition = tk.Label(self,
                                            text="Class C Tray Position",
                                            height=2,
                                            width=self.label_width,
                                            font="Times 14 bold")
        self.Label_CTrayPosition.grid(row=3, column=2)
        self.Label_CTrayPositionnum = tk.Label(self,
                                               text="0",
                                               height=2,
                                               width=self.label_width,
                                               font="Times 14 bold",
                                               bg="yellow")
        self.Label_CTrayPositionnum.grid(row=3, column=3)

        self.Label_NXPosition = tk.Label(self,
                                         text="Needles X Position",
                                         height=2,
                                         width=self.label_width,
                                         font="Times 14 bold")
        self.Label_NXPosition.grid(row=4, column=2)
        self.Label_NXPositionnum = tk.Label(self,
                                            text="0",
                                            height=2,
                                            width=self.label_width,
                                            font="Times 14 bold",
                                            bg="yellow")
        self.Label_NXPositionnum.grid(row=4, column=3)

        self.Label_NYPosition = tk.Label(self,
                                         text="Needles Y Position",
                                         height=2,
                                         width=self.label_width,
                                         font="Times 14 bold")
        self.Label_NYPosition.grid(row=5, column=2)
        self.Label_NYPositionnum = tk.Label(self,
                                            text="0",
                                            height=2,
                                            width=self.label_width,
                                            font="Times 14 bold",
                                            bg="yellow")
        self.Label_NYPositionnum.grid(row=5, column=3)

        self.Label_GripperStat = tk.Label(self,
                                          text="Gripper status",
                                          height=2,
                                          width=self.label_width,
                                          font="Times 14 bold")
        self.Label_GripperStat.grid(row=6, column=2)
        self.Label_GripperStatnum = tk.Label(self,
                                             text="0",
                                             height=2,
                                             width=self.label_width,
                                             font="Times 14 bold",
                                             bg="yellow")
        self.Label_GripperStatnum.grid(row=6, column=3)

        self.Label_Alarm = tk.Label(self,
                                    text="Alarm",
                                    height=2,
                                    width=self.label_width,
                                    font="Times 14 bold")
        self.Label_Alarm.grid(row=7, column=2)
        self.Label_Alarmval = tk.Label(self,
                                       text="0",
                                       height=2,
                                       width=self.label_width,
                                       font="Times 14 bold",
                                       bg="yellow")
        self.Label_Alarmval.grid(row=7, column=3)

        self.Label_PlcInstruct = tk.Label(self,
                                          text="PLC instruction",
                                          height=2,
                                          width=self.label_width,
                                          font="Times 14 bold")
        self.Label_PlcInstruct.grid(row=8, column=2)
        self.Label_PlcInstructval = tk.Label(self,
                                             text="0",
                                             height=2,
                                             width=self.label_width,
                                             font="Times 14 bold",
                                             bg="yellow")
        self.Label_PlcInstructval.grid(row=8, column=3)

        self.Label_CvStatus = tk.Label(self,
                                       text="CV status",
                                       height=2,
                                       width=self.label_width,
                                       font="Times 14 bold")
        self.Label_CvStatus.grid(row=9, column=2)
        self.Label_CvStatusval = tk.Label(self,
                                          text="0",
                                          height=2,
                                          width=self.label_width,
                                          font="Times 14 bold",
                                          bg="orange")
        self.Label_CvStatusval.grid(row=9, column=3)

        self.Label_S1Quality = tk.Label(self,
                                        text="Seedling 1 Quality",
                                        height=2,
                                        width=self.label_width,
                                        font="Times 14 bold")
        self.Label_S1Quality.grid(row=10, column=2)
        self.Label_S1Qualityval = tk.Label(self,
                                           text="0",
                                           height=2,
                                           width=self.label_width,
                                           font="Times 14 bold",
                                           bg="orange")
        self.Label_S1Qualityval.grid(row=10, column=3)

        self.Label_S2Quality = tk.Label(self,
                                        text="Seedling 2 Quality",
                                        height=2,
                                        width=self.label_width,
                                        font="Times 14 bold")
        self.Label_S2Quality.grid(row=11, column=2)
        self.Label_S2Qualityval = tk.Label(self,
                                           text="0",
                                           height=2,
                                           width=self.label_width,
                                           font="Times 14 bold",
                                           bg="orange")
        self.Label_S2Qualityval.grid(row=11, column=3)

        self.Label_S3Quality = tk.Label(self,
                                        text="Seedling 3 Quality",
                                        height=2,
                                        width=self.label_width,
                                        font="Times 14 bold")
        self.Label_S3Quality.grid(row=12, column=2)
        self.Label_S3Qualityval = tk.Label(self,
                                           text="0",
                                           height=2,
                                           width=self.label_width,
                                           font="Times 14 bold",
                                           bg="orange")
        self.Label_S3Qualityval.grid(row=12, column=3)

        self.Frame_S1Quality = tk.Frame(self, height=2, width=self.label_width)
        self.Frame_S1Quality.grid(row=1, column=4)

        self.Frame_S2Quality = tk.Frame(self, height=2, width=self.label_width)
        self.Frame_S2Quality.grid(row=3, column=4)

        self.Frame_S3Quality = tk.Frame(self, height=2, width=self.label_width)
        self.Frame_S3Quality.grid(row=5, column=4)

        self.Label_S1SelQuality = tk.Label(self,
                                           text="Seedling 1 Quality",
                                           height=2,
                                           width=self.label_width,
                                           font="Times 14 bold")
        self.Label_S1SelQuality.grid(row=0, column=4)
        self.RButton_S1_NS = tk.Radiobutton(self.Frame_S1Quality,
                                            text="Empty",
                                            variable=self.selectionq1,
                                            value=lsmodb.QTY_EMPTY,
                                            command=self.selq1)
        self.RButton_S1_A = tk.Radiobutton(self.Frame_S1Quality,
                                           text="A",
                                           variable=self.selectionq1,
                                           value=lsmodb.QTY_A,
                                           command=self.selq1)
        self.RButton_S1_B = tk.Radiobutton(self.Frame_S1Quality,
                                           text="B",
                                           variable=self.selectionq1,
                                           value=lsmodb.QTY_B,
                                           command=self.selq1)
        self.RButton_S1_C = tk.Radiobutton(self.Frame_S1Quality,
                                           text="C",
                                           variable=self.selectionq1,
                                           value=lsmodb.QTY_C,
                                           command=self.selq1)
        self.RButton_S1_NS.grid(row=0, column=0)
        self.RButton_S1_A.grid(row=0, column=1)
        self.RButton_S1_B.grid(row=0, column=2)
        self.RButton_S1_C.grid(row=0, column=3)

        self.Label_S2SelQuality = tk.Label(self,
                                           text="Seedling 2 Quality",
                                           height=2,
                                           width=self.label_width,
                                           font="Times 14 bold")
        self.Label_S2SelQuality.grid(row=2, column=4)
        self.RButton_S2_NS = tk.Radiobutton(self.Frame_S2Quality,
                                            text="Empty",
                                            variable=self.selectionq2,
                                            value=lsmodb.QTY_EMPTY,
                                            command=self.selq2)
        self.RButton_S2_A = tk.Radiobutton(self.Frame_S2Quality,
                                           text="A",
                                           variable=self.selectionq2,
                                           value=lsmodb.QTY_A,
                                           command=self.selq2)
        self.RButton_S2_B = tk.Radiobutton(self.Frame_S2Quality,
                                           text="B",
                                           variable=self.selectionq2,
                                           value=lsmodb.QTY_B,
                                           command=self.selq2)
        self.RButton_S2_C = tk.Radiobutton(self.Frame_S2Quality,
                                           text="C",
                                           variable=self.selectionq2,
                                           value=lsmodb.QTY_C,
                                           command=self.selq2)
        self.RButton_S2_NS.grid(row=0, column=0)
        self.RButton_S2_A.grid(row=0, column=1)
        self.RButton_S2_B.grid(row=0, column=2)
        self.RButton_S2_C.grid(row=0, column=3)

        self.Label_S3SelQuality = tk.Label(self,
                                           text="Seedling 3 Quality",
                                           height=2,
                                           width=self.label_width,
                                           font="Times 14 bold")
        self.Label_S3SelQuality.grid(row=4, column=4)
        self.RButton_S3_NS = tk.Radiobutton(self.Frame_S3Quality,
                                            text="Empty",
                                            variable=self.selectionq3,
                                            value=lsmodb.QTY_EMPTY,
                                            command=self.selq3)
        self.RButton_S3_A = tk.Radiobutton(self.Frame_S3Quality,
                                           text="A",
                                           variable=self.selectionq3,
                                           value=lsmodb.QTY_A,
                                           command=self.selq3)
        self.RButton_S3_B = tk.Radiobutton(self.Frame_S3Quality,
                                           text="B",
                                           variable=self.selectionq3,
                                           value=lsmodb.QTY_B,
                                           command=self.selq3)
        self.RButton_S3_C = tk.Radiobutton(self.Frame_S3Quality,
                                           text="C",
                                           variable=self.selectionq3,
                                           value=lsmodb.QTY_C,
                                           command=self.selq3)
        self.RButton_S3_NS.grid(row=0, column=0)
        self.RButton_S3_A.grid(row=0, column=1)
        self.RButton_S3_B.grid(row=0, column=2)
        self.RButton_S3_C.grid(row=0, column=3)

        self.setButton = tk.Button(self,
                                   text="Set Quality Values",
                                   command=self.setQuality,
                                   bg="green")
        self.setButton.grid(row=6, column=4)
Example #6
0
from libseedlingmodbus import SeedlingModbusClient
import libseedlingmodbus as lsmodb
import sys
from time import time, sleep

args = sys.argv

modServerIp = "192.168.1.103"
modServerPort = 502

if "-serverIp" in args:
    idx = args.index("-serverIp")
    try:
        modServerIp = args[idx + 1]
    except:
        raise Exception("Server IP wasn't specified")

if "-serverPort" in args:
    idx = args.index("-serverPort")
    try:
        modServerPort = int(args[idx + 1])
    except:
        raise Exception("Server Port wasn't specified or is not valid")

cv_Client = SeedlingModbusClient(modServerIp, modServerPort)
sleep(2)
cv_Client.writeCvStatus(lsmodb.CV_PROCESSING_STAT)
sleep(2)
cv_Client.cvFinishProcessing()