text: # _*_ coding: utf-8 _*_
  # @Time : 2021/4/28 上午 11:36 
  # @Author : cherish_peng
  # @Email : 1058386071@qq.com 
  # @File : demo_mnetg.py
  # @Software : PyCharm
  import sys
  import os
  from pathlib import Path
  BASE_DIR = Path(__file__).resolve().parent.parent
  sys.path.insert(0, os.path.join(BASE_DIR, 'extra_apps'))
  
  from pymnetg import *
  from pymnetg.mnnetg_enum import ChanEnum
  
  
  def main():
      worker = MnetgWorker(255, 0, ChanEnum.CC_Link_IE_Controller_1)
      worker.connect()
      if worker.is_connected():
          print("MNETG Connect Success!")
  
      while True:
          input_str = input('请输入寄存器地址(W0000,1:2:3|B0000,1:0:1:0:1):')
          if len(input_str.split(',')) == 2:
              datas = input_str.split(',')[1]
              input_str = input_str.split(',')[0]
              try:
                  print(worker.write(input_str, for data in datas.split(':')))
              except Exception as e:
                  # print("输入错误, 程序终止",e)
                  # mc.close_connect()
                  # break
                  print(e)
  
  
  if __name__ == '__main__':
      main()
  