示例#1
0
 def 讀一个(self, 所在):
     return FatekTarget(self.連線, 所在).read()
示例#2
0
 def test_coil_range_2000(self):
     with self.assertRaises(InvalidTargetError):
         FatekTarget(self.client, 'M0').read_all(2001)
示例#3
0
 def test_register_range_125(self):
     with self.assertRaises(InvalidTargetError):
         FatekTarget(self.client, 'R300').read_all(155)
示例#4
0
 def test_M300_readall_with_unit(self):
     FatekTarget(self.client, 'M300', unit=0x01).read_all(50)
     self.client.read_coils.assert_called_once_with(2300, 50, unit=0x01)
示例#5
0
 def test_R300_readall_with_unit(self):
     FatekTarget(self.client, 'R300', unit=0x01).read_all(55)
     self.client.read_holding_registers.assert_called_once_with(300,
                                                                55,
                                                                unit=0x01)
示例#6
0
 def test_T255c_with_unit(self):
     FatekTarget(self.client, 'T255', unit=0x01, current_value=False).read()
     self.client.read_coils.assert_called_once_with(9255, 1, unit=0x01)
示例#7
0
 def test_T255r(self):
     FatekTarget(self.client, 'T255', unit=0x01, current_value=True).read()
     self.client.read_holding_registers.assert_called_once_with(9255,
                                                                1,
                                                                unit=0x01)
示例#8
0
 def test_D333(self):
     FatekTarget(self.client, 'D333').write(593)
     self.client.write_register.assert_called_once_with(6333, 593)
示例#9
0
 def test_D333_with_unit(self):
     FatekTarget(self.client, 'D333', unit=0x01).write(593)
     self.client.write_register.assert_called_once_with(6333,
                                                        593,
                                                        unit=0x01)
示例#10
0
 def test_R333(self):
     FatekTarget(self.client, 'R333').read()
     self.client.read_holding_registers.assert_called_once_with(333, 1)
示例#11
0
 def test_R333_with_unit(self):
     FatekTarget(self.client, 'R333', unit=0x01).read()
     self.client.read_holding_registers.assert_called_once_with(333,
                                                                1,
                                                                unit=0x01)
示例#12
0
 def test_M0(self):
     FatekTarget(self.client, 'M0').read()
     self.client.read_coils.assert_called_once_with(2000, 1)
示例#13
0
 def test_X10(self):
     FatekTarget(self.client, 'X10').write(5)
     self.client.write_coil.assert_called_once_with(1010, 5)
示例#14
0
 def test_Y0(self):
     FatekTarget(self.client, 'Y33').read()
     self.client.read_coils.assert_called_once_with(33, 1)
示例#15
0
 def __setattr__(self, name, value):
     if name in ["連線", "對應表"]:
         return super(Modbus試驗, self).__setattr__(name, value)
     位址 = self.對應表[name]
     FatekTarget(self.連線, 位址).write(value)
     return
示例#16
0
 def __getattr__(self, name):
     位址 = self.對應表[name]
     return FatekTarget(self.連線, 位址).read()