Skip to main content
タグを編集
リンク
raccy
  • 8,272
  • 1
  • 14
  • 41
本文から 8 文字削除; タイトルを編集
ソース リンク
cubick
  • 2.1万
  • 5
  • 27
  • 64

python Pythonの実行の仕方がわからない

import os
import sys
import time
import win32com.client



 
NR500_USB_ID_START = 0
NR500_USB_ID_END = 3
NRX100_USB_ID_START = 4
NRX100_USB_ID_END = 7
NRX100_LAN_ID_START = 8
NRX100_LAN_ID_END = 11

STATE_START_WAIT = 2
STATE_TRIGGER_WAIT = 3
STATE_RUN = 4
STATE_REPEAT_RUN = 5
STATE_PRE_TRIGGER = 6
STATE_POST_TRIGGER = 7
STATE_STOP_WAIT = 8
STATE_READ_WAIT = 10
STATE_PROCEDURE_WAIT = 12

 
def main():
    if len(sys.argv) < 3:
        show_help()
        return

    file_path = sys.argv[1]
    if not os.path.isfile(file_path):
        print("File not exist")
        return

    id = int(sys.argv[2])
    if NRX100_LAN_ID_START <= id and id <= NRX100_LAN_ID_END:
        if len(sys.argv) < 4:
            show_help()
            return

        ip = sys.argv[3].split('.')
        if len(ip) != 4:
            print("Illegal IP address")
            return

        port_number = 24682
        if 5 <= len(sys.argv):
            port_number = int(sys.argv[4])
            if port_number < 1025 or 65535 < port_number:
                print("Illegal port number")
                return

    wave_logger = win32com.client.Dispatch("WaveLoggerX.Application")
    wave_logger.Initialize()
    wave_logger.Visible = True

    id_result = wave_logger.SetIdentifier(id)
    if id_result != 0:
        print("Failed to set the device ID [error code: %d]" %id_result)
        return

    if NRX100_LAN_ID_START <= id and id <= NRX100_LAN_ID_END:
        lan_id = id - NRX100_LAN_ID_START
        config_result = wave_logger.SetLanConfig(
            lan_id, ip[0], ip[1], ip[2], ip[3], port_number)
        if config_result != 0:
            print("Failed to set LAN parameters [error code: %d]" %config_result)
            return

        connect_result = wave_logger.ConnectLan
        if connect_result != 0:
            print("Connection failed [error code: %d]" %connect_result)
            return

    open_result = wave_logger.OpenFile(file_path)
    if open_result != 0:
        print("File open error [error code: %d]" %open_result)
        return

    start_result = wave_logger.Start
    if start_result != 0:
        print("Starting acquisition failed [error code: %d]" %start_result)
        return

    document = wave_logger.GetActiveFile
    try:
        while is_running(wave_logger.GetState):
            print("\r"+"The amount of sampling data: " + str(document.GetDataCount) + 
                  " point (Press 'Ctrl + C' to stop acquisition)", end="")
            time.sleep(1)

    except KeyboardInterrupt:
        wave_logger.Stop()
        while is_running(wave_logger.GetState):
            time.sleep(1)

    print("\r"+"The amount of sampling data: " + str(document.GetDataCount) + 
          " point (Press 'Ctrl + C' to stop acquisition)")
    print("Press Enter to exit")
    input()


def is_running(state):
    return state in {STATE_START_WAIT,
                     STATE_TRIGGER_WAIT,
                     STATE_RUN,
                     STATE_REPEAT_RUN,
                     STATE_PRE_TRIGGER,
                     STATE_POST_TRIGGER,
                     STATE_STOP_WAIT,
                     STATE_READ_WAIT,
                     STATE_PROCEDURE_WAIT}


def show_help():
    print("<Operation explanation>")
    print("Reads the specified setting file, "
          "confirms the connection, and starts acquisition")
    print()
    print("<How to use>")
    print("$ python Sample1.py <Settings file path> "
          "<Connection identifier> <IP address(option)> <port number(option)>")
    print("    [Settings file path]")
    print("    xcf, xdt, ycf, ydt, kdt File")
    print("    [Connection identifier]")
    print("    0 : NR-500 USB ID0")
    print("    1 : NR-500 USB ID1")
    print("    2 : NR-500 USB ID2")
    print("    3 : NR-500 USB ID3")
    print("    4 : NR-X100 USB ID0")
    print("    5 : NR-X100 USB ID1")
    print("    6 : NR-X100 USB ID2")
    print("    7 : NR-X100 USB ID3")
    print("    8 : NR-X100 LAN ID0")
    print("    9 : NR-X100 LAN ID1")
    print("    10: NR-X100 LAN ID2")
    print("    11: NR-X100 LAN ID3")
    print("    [IP address]")
    print("    IP address of the NRX-100 to be connected")
    print("    Must be specified in the case of "
          "Connection identifier is 8 to 11 (LAN Connection)")
    print()
    print("<Example>")
    print("Sample1.py C:\\NR-500Sample.xdt 0")
    print("Sample1.py C:\\NR-X100Sample.ydt 8 192.168.100.100 24682")
    print


main()

pythonの実行の仕方

import os
import sys
import time
import win32com.client



 
NR500_USB_ID_START = 0
NR500_USB_ID_END = 3
NRX100_USB_ID_START = 4
NRX100_USB_ID_END = 7
NRX100_LAN_ID_START = 8
NRX100_LAN_ID_END = 11

STATE_START_WAIT = 2
STATE_TRIGGER_WAIT = 3
STATE_RUN = 4
STATE_REPEAT_RUN = 5
STATE_PRE_TRIGGER = 6
STATE_POST_TRIGGER = 7
STATE_STOP_WAIT = 8
STATE_READ_WAIT = 10
STATE_PROCEDURE_WAIT = 12

 
def main():
    if len(sys.argv) < 3:
        show_help()
        return

    file_path = sys.argv[1]
    if not os.path.isfile(file_path):
        print("File not exist")
        return

    id = int(sys.argv[2])
    if NRX100_LAN_ID_START <= id and id <= NRX100_LAN_ID_END:
        if len(sys.argv) < 4:
            show_help()
            return

        ip = sys.argv[3].split('.')
        if len(ip) != 4:
            print("Illegal IP address")
            return

        port_number = 24682
        if 5 <= len(sys.argv):
            port_number = int(sys.argv[4])
            if port_number < 1025 or 65535 < port_number:
                print("Illegal port number")
                return

    wave_logger = win32com.client.Dispatch("WaveLoggerX.Application")
    wave_logger.Initialize()
    wave_logger.Visible = True

    id_result = wave_logger.SetIdentifier(id)
    if id_result != 0:
        print("Failed to set the device ID [error code: %d]" %id_result)
        return

    if NRX100_LAN_ID_START <= id and id <= NRX100_LAN_ID_END:
        lan_id = id - NRX100_LAN_ID_START
        config_result = wave_logger.SetLanConfig(
            lan_id, ip[0], ip[1], ip[2], ip[3], port_number)
        if config_result != 0:
            print("Failed to set LAN parameters [error code: %d]" %config_result)
            return

        connect_result = wave_logger.ConnectLan
        if connect_result != 0:
            print("Connection failed [error code: %d]" %connect_result)
            return

    open_result = wave_logger.OpenFile(file_path)
    if open_result != 0:
        print("File open error [error code: %d]" %open_result)
        return

    start_result = wave_logger.Start
    if start_result != 0:
        print("Starting acquisition failed [error code: %d]" %start_result)
        return

    document = wave_logger.GetActiveFile
    try:
        while is_running(wave_logger.GetState):
            print("\r"+"The amount of sampling data: " + str(document.GetDataCount) + 
                  " point (Press 'Ctrl + C' to stop acquisition)", end="")
            time.sleep(1)

    except KeyboardInterrupt:
        wave_logger.Stop()
        while is_running(wave_logger.GetState):
            time.sleep(1)

    print("\r"+"The amount of sampling data: " + str(document.GetDataCount) + 
          " point (Press 'Ctrl + C' to stop acquisition)")
    print("Press Enter to exit")
    input()


def is_running(state):
    return state in {STATE_START_WAIT,
                     STATE_TRIGGER_WAIT,
                     STATE_RUN,
                     STATE_REPEAT_RUN,
                     STATE_PRE_TRIGGER,
                     STATE_POST_TRIGGER,
                     STATE_STOP_WAIT,
                     STATE_READ_WAIT,
                     STATE_PROCEDURE_WAIT}


def show_help():
    print("<Operation explanation>")
    print("Reads the specified setting file, "
          "confirms the connection, and starts acquisition")
    print()
    print("<How to use>")
    print("$ python Sample1.py <Settings file path> "
          "<Connection identifier> <IP address(option)> <port number(option)>")
    print("    [Settings file path]")
    print("    xcf, xdt, ycf, ydt, kdt File")
    print("    [Connection identifier]")
    print("    0 : NR-500 USB ID0")
    print("    1 : NR-500 USB ID1")
    print("    2 : NR-500 USB ID2")
    print("    3 : NR-500 USB ID3")
    print("    4 : NR-X100 USB ID0")
    print("    5 : NR-X100 USB ID1")
    print("    6 : NR-X100 USB ID2")
    print("    7 : NR-X100 USB ID3")
    print("    8 : NR-X100 LAN ID0")
    print("    9 : NR-X100 LAN ID1")
    print("    10: NR-X100 LAN ID2")
    print("    11: NR-X100 LAN ID3")
    print("    [IP address]")
    print("    IP address of the NRX-100 to be connected")
    print("    Must be specified in the case of "
          "Connection identifier is 8 to 11 (LAN Connection)")
    print()
    print("<Example>")
    print("Sample1.py C:\\NR-500Sample.xdt 0")
    print("Sample1.py C:\\NR-X100Sample.ydt 8 192.168.100.100 24682")
    print


main()

Pythonの実行の仕方がわからない

import os
import sys
import time
import win32com.client

NR500_USB_ID_START = 0
NR500_USB_ID_END = 3
NRX100_USB_ID_START = 4
NRX100_USB_ID_END = 7
NRX100_LAN_ID_START = 8
NRX100_LAN_ID_END = 11

STATE_START_WAIT = 2
STATE_TRIGGER_WAIT = 3
STATE_RUN = 4
STATE_REPEAT_RUN = 5
STATE_PRE_TRIGGER = 6
STATE_POST_TRIGGER = 7
STATE_STOP_WAIT = 8
STATE_READ_WAIT = 10
STATE_PROCEDURE_WAIT = 12

def main():
    if len(sys.argv) < 3:
        show_help()
        return

    file_path = sys.argv[1]
    if not os.path.isfile(file_path):
        print("File not exist")
        return

    id = int(sys.argv[2])
    if NRX100_LAN_ID_START <= id and id <= NRX100_LAN_ID_END:
        if len(sys.argv) < 4:
            show_help()
            return

        ip = sys.argv[3].split('.')
        if len(ip) != 4:
            print("Illegal IP address")
            return

        port_number = 24682
        if 5 <= len(sys.argv):
            port_number = int(sys.argv[4])
            if port_number < 1025 or 65535 < port_number:
                print("Illegal port number")
                return

    wave_logger = win32com.client.Dispatch("WaveLoggerX.Application")
    wave_logger.Initialize()
    wave_logger.Visible = True

    id_result = wave_logger.SetIdentifier(id)
    if id_result != 0:
        print("Failed to set the device ID [error code: %d]" %id_result)
        return

    if NRX100_LAN_ID_START <= id and id <= NRX100_LAN_ID_END:
        lan_id = id - NRX100_LAN_ID_START
        config_result = wave_logger.SetLanConfig(
            lan_id, ip[0], ip[1], ip[2], ip[3], port_number)
        if config_result != 0:
            print("Failed to set LAN parameters [error code: %d]" %config_result)
            return

        connect_result = wave_logger.ConnectLan
        if connect_result != 0:
            print("Connection failed [error code: %d]" %connect_result)
            return

    open_result = wave_logger.OpenFile(file_path)
    if open_result != 0:
        print("File open error [error code: %d]" %open_result)
        return

    start_result = wave_logger.Start
    if start_result != 0:
        print("Starting acquisition failed [error code: %d]" %start_result)
        return

    document = wave_logger.GetActiveFile
    try:
        while is_running(wave_logger.GetState):
            print("\r"+"The amount of sampling data: " + str(document.GetDataCount) + 
                  " point (Press 'Ctrl + C' to stop acquisition)", end="")
            time.sleep(1)

    except KeyboardInterrupt:
        wave_logger.Stop()
        while is_running(wave_logger.GetState):
            time.sleep(1)

    print("\r"+"The amount of sampling data: " + str(document.GetDataCount) + 
          " point (Press 'Ctrl + C' to stop acquisition)")
    print("Press Enter to exit")
    input()


def is_running(state):
    return state in {STATE_START_WAIT,
                     STATE_TRIGGER_WAIT,
                     STATE_RUN,
                     STATE_REPEAT_RUN,
                     STATE_PRE_TRIGGER,
                     STATE_POST_TRIGGER,
                     STATE_STOP_WAIT,
                     STATE_READ_WAIT,
                     STATE_PROCEDURE_WAIT}


def show_help():
    print("<Operation explanation>")
    print("Reads the specified setting file, "
          "confirms the connection, and starts acquisition")
    print()
    print("<How to use>")
    print("$ python Sample1.py <Settings file path> "
          "<Connection identifier> <IP address(option)> <port number(option)>")
    print("    [Settings file path]")
    print("    xcf, xdt, ycf, ydt, kdt File")
    print("    [Connection identifier]")
    print("    0 : NR-500 USB ID0")
    print("    1 : NR-500 USB ID1")
    print("    2 : NR-500 USB ID2")
    print("    3 : NR-500 USB ID3")
    print("    4 : NR-X100 USB ID0")
    print("    5 : NR-X100 USB ID1")
    print("    6 : NR-X100 USB ID2")
    print("    7 : NR-X100 USB ID3")
    print("    8 : NR-X100 LAN ID0")
    print("    9 : NR-X100 LAN ID1")
    print("    10: NR-X100 LAN ID2")
    print("    11: NR-X100 LAN ID3")
    print("    [IP address]")
    print("    IP address of the NRX-100 to be connected")
    print("    Must be specified in the case of "
          "Connection identifier is 8 to 11 (LAN Connection)")
    print()
    print("<Example>")
    print("Sample1.py C:\\NR-500Sample.xdt 0")
    print("Sample1.py C:\\NR-X100Sample.ydt 8 192.168.100.100 24682")
    print


main()
装飾しました
ソース リンク
nekketsuuu
  • 2.4万
  • 12
  • 53
  • 117

これはキーエンスのロガーのサンプルプログラムです。
これをspyderで実行させたいのですが実行の仕方がわかりません。
Sample1.py C:\NR-500Sample.xdt 0Sample1.py C:\NR-500Sample.xdt 0をどこかに打てば実行できると予想していますが
どこに入力するのか、どのような形で入力するかわかりません。
よろしくお願いします。

import os
import sys
import time
import win32com.client

NR500_USB_ID_START = 0
NR500_USB_ID_END = 3
NRX100_USB_ID_START = 4
NRX100_USB_ID_END = 7
NRX100_LAN_ID_START = 8
NRX100_LAN_ID_END = 11

STATE_START_WAIT = 2
STATE_TRIGGER_WAIT = 3
STATE_RUN = 4
STATE_REPEAT_RUN = 5
STATE_PRE_TRIGGER = 6
STATE_POST_TRIGGER = 7
STATE_STOP_WAIT = 8
STATE_READ_WAIT = 10
STATE_PROCEDURE_WAIT = 12

def main():
if len(sys.argv) < 3:
show_help()
return

import os
import sys
import time
import win32com.client




NR500_USB_ID_START = 0
NR500_USB_ID_END = 3
NRX100_USB_ID_START = 4
NRX100_USB_ID_END = 7
NRX100_LAN_ID_START = 8
NRX100_LAN_ID_END = 11

STATE_START_WAIT = 2
STATE_TRIGGER_WAIT = 3
STATE_RUN = 4
STATE_REPEAT_RUN = 5
STATE_PRE_TRIGGER = 6
STATE_POST_TRIGGER = 7
STATE_STOP_WAIT = 8
STATE_READ_WAIT = 10
STATE_PROCEDURE_WAIT = 12


def main():
    if len(sys.argv) < 3:
        show_help()
        return

    file_path = sys.argv[1]
    if not os.path.isfile(file_path):
        print("File not exist")
        return

    id = int(sys.argv[2])
    if NRX100_LAN_ID_START <= id and id <= NRX100_LAN_ID_END:
        if len(sys.argv) < 4:
            show_help()
            return

        ip = sys.argv[3].split('.')
        if len(ip) != 4:
            print("Illegal IP address")
            return

        port_number = 24682
        if 5 <= len(sys.argv):
            port_number = int(sys.argv[4])
            if port_number < 1025 or 65535 < port_number:
                print("Illegal port number")
                return

    wave_logger = win32com.client.Dispatch("WaveLoggerX.Application")
    wave_logger.Initialize()
    wave_logger.Visible = True

    id_result = wave_logger.SetIdentifier(id)
    if id_result != 0:
        print("Failed to set the device ID [error code: %d]" %id_result)
        return

    if NRX100_LAN_ID_START <= id and id <= NRX100_LAN_ID_END:
        lan_id = id - NRX100_LAN_ID_START
        config_result = wave_logger.SetLanConfig(
            lan_id, ip[0], ip[1], ip[2], ip[3], port_number)
        if config_result != 0:
            print("Failed to set LAN parameters [error code: %d]" %config_result)
            return

        connect_result = wave_logger.ConnectLan
        if connect_result != 0:
            print("Connection failed [error code: %d]" %connect_result)
            return

    open_result = wave_logger.OpenFile(file_path)
    if open_result != 0:
        print("File open error [error code: %d]" %open_result)
        return

    start_result = wave_logger.Start
    if start_result != 0:
        print("Starting acquisition failed [error code: %d]" %start_result)
        return

    document = wave_logger.GetActiveFile
    try:
        while is_running(wave_logger.GetState):
            print("\r"+"The amount of sampling data: " + str(document.GetDataCount) + 
                  " point (Press 'Ctrl + C' to stop acquisition)", end="")
            time.sleep(1)

    except KeyboardInterrupt:
        wave_logger.Stop()
        while is_running(wave_logger.GetState):
            time.sleep(1)

    print("\r"+"The amount of sampling data: " + str(document.GetDataCount) + 
          " point (Press 'Ctrl + C' to stop acquisition)")
    print("Press Enter to exit")
    input()


def is_running(state):
    return state in {STATE_START_WAIT,
                     STATE_TRIGGER_WAIT,
                     STATE_RUN,
                     STATE_REPEAT_RUN,
                     STATE_PRE_TRIGGER,
                     STATE_POST_TRIGGER,
                     STATE_STOP_WAIT,
                     STATE_READ_WAIT,
                     STATE_PROCEDURE_WAIT}


def show_help():
    print("<Operation explanation>")
    print("Reads the specified setting file, "
          "confirms the connection, and starts acquisition")
    print()
    print("<How to use>")
    print("$ python Sample1.py <Settings file path> "
          "<Connection identifier> <IP address(option)> <port number(option)>")
    print("    [Settings file path]")
    print("    xcf, xdt, ycf, ydt, kdt File")
    print("    [Connection identifier]")
    print("    0 : NR-500 USB ID0")
    print("    1 : NR-500 USB ID1")
    print("    2 : NR-500 USB ID2")
    print("    3 : NR-500 USB ID3")
    print("    4 : NR-X100 USB ID0")
    print("    5 : NR-X100 USB ID1")
    print("    6 : NR-X100 USB ID2")
    print("    7 : NR-X100 USB ID3")
    print("    8 : NR-X100 LAN ID0")
    print("    9 : NR-X100 LAN ID1")
    print("    10: NR-X100 LAN ID2")
    print("    11: NR-X100 LAN ID3")
    print("    [IP address]")
    print("    IP address of the NRX-100 to be connected")
    print("    Must be specified in the case of "
          "Connection identifier is 8 to 11 (LAN Connection)")
    print()
    print("<Example>")
    print("Sample1.py C:\\NR-500Sample.xdt 0")
    print("Sample1.py C:\\NR-X100Sample.ydt 8 192.168.100.100 24682")
    print


main()

def is_running(state):
return state in {STATE_START_WAIT,
STATE_TRIGGER_WAIT,
STATE_RUN,
STATE_REPEAT_RUN,
STATE_PRE_TRIGGER,
STATE_POST_TRIGGER,
STATE_STOP_WAIT,
STATE_READ_WAIT,
STATE_PROCEDURE_WAIT}

def show_help():
print("")
print("Reads the specified setting file, "
"confirms the connection, and starts acquisition")
print()
print("")
print("$ python Sample1.py "
" <IP address(option)> <port number(option)>")
print(" [Settings file path]")
print(" xcf, xdt, ycf, ydt, kdt File")
print(" [Connection identifier]")
print(" 0 : NR-500 USB ID0")
print(" 1 : NR-500 USB ID1")
print(" 2 : NR-500 USB ID2")
print(" 3 : NR-500 USB ID3")
print(" 4 : NR-X100 USB ID0")
print(" 5 : NR-X100 USB ID1")
print(" 6 : NR-X100 USB ID2")
print(" 7 : NR-X100 USB ID3")
print(" 8 : NR-X100 LAN ID0")
print(" 9 : NR-X100 LAN ID1")
print(" 10: NR-X100 LAN ID2")
print(" 11: NR-X100 LAN ID3")
print(" [IP address]")
print(" IP address of the NRX-100 to be connected")
print(" Must be specified in the case of "
"Connection identifier is 8 to 11 (LAN Connection)")
print()
print("")
print("Sample1.py C:\NR-500Sample.xdt 0")
print("Sample1.py C:\NR-X100Sample.ydt 8 192.168.100.100 24682")
print

main()

これはキーエンスのロガーのサンプルプログラムです。
これをspyderで実行させたいのですが実行の仕方がわかりません。
Sample1.py C:\NR-500Sample.xdt 0をどこかに打てば実行できると予想していますが
どこに入力するのか、どのような形で入力するかわかりません。
よろしくお願いします。

import os
import sys
import time
import win32com.client

NR500_USB_ID_START = 0
NR500_USB_ID_END = 3
NRX100_USB_ID_START = 4
NRX100_USB_ID_END = 7
NRX100_LAN_ID_START = 8
NRX100_LAN_ID_END = 11

STATE_START_WAIT = 2
STATE_TRIGGER_WAIT = 3
STATE_RUN = 4
STATE_REPEAT_RUN = 5
STATE_PRE_TRIGGER = 6
STATE_POST_TRIGGER = 7
STATE_STOP_WAIT = 8
STATE_READ_WAIT = 10
STATE_PROCEDURE_WAIT = 12

def main():
if len(sys.argv) < 3:
show_help()
return

file_path = sys.argv[1]
if not os.path.isfile(file_path):
    print("File not exist")
    return

id = int(sys.argv[2])
if NRX100_LAN_ID_START <= id and id <= NRX100_LAN_ID_END:
    if len(sys.argv) < 4:
        show_help()
        return

    ip = sys.argv[3].split('.')
    if len(ip) != 4:
        print("Illegal IP address")
        return

    port_number = 24682
    if 5 <= len(sys.argv):
        port_number = int(sys.argv[4])
        if port_number < 1025 or 65535 < port_number:
            print("Illegal port number")
            return

wave_logger = win32com.client.Dispatch("WaveLoggerX.Application")
wave_logger.Initialize()
wave_logger.Visible = True

id_result = wave_logger.SetIdentifier(id)
if id_result != 0:
    print("Failed to set the device ID [error code: %d]" %id_result)
    return

if NRX100_LAN_ID_START <= id and id <= NRX100_LAN_ID_END:
    lan_id = id - NRX100_LAN_ID_START
    config_result = wave_logger.SetLanConfig(
        lan_id, ip[0], ip[1], ip[2], ip[3], port_number)
    if config_result != 0:
        print("Failed to set LAN parameters [error code: %d]" %config_result)
        return

    connect_result = wave_logger.ConnectLan
    if connect_result != 0:
        print("Connection failed [error code: %d]" %connect_result)
        return

open_result = wave_logger.OpenFile(file_path)
if open_result != 0:
    print("File open error [error code: %d]" %open_result)
    return

start_result = wave_logger.Start
if start_result != 0:
    print("Starting acquisition failed [error code: %d]" %start_result)
    return

document = wave_logger.GetActiveFile
try:
    while is_running(wave_logger.GetState):
        print("\r"+"The amount of sampling data: " + str(document.GetDataCount) + 
              " point (Press 'Ctrl + C' to stop acquisition)", end="")
        time.sleep(1)

except KeyboardInterrupt:
    wave_logger.Stop()
    while is_running(wave_logger.GetState):
        time.sleep(1)

print("\r"+"The amount of sampling data: " + str(document.GetDataCount) + 
      " point (Press 'Ctrl + C' to stop acquisition)")
print("Press Enter to exit")
input()

def is_running(state):
return state in {STATE_START_WAIT,
STATE_TRIGGER_WAIT,
STATE_RUN,
STATE_REPEAT_RUN,
STATE_PRE_TRIGGER,
STATE_POST_TRIGGER,
STATE_STOP_WAIT,
STATE_READ_WAIT,
STATE_PROCEDURE_WAIT}

def show_help():
print("")
print("Reads the specified setting file, "
"confirms the connection, and starts acquisition")
print()
print("")
print("$ python Sample1.py "
" <IP address(option)> <port number(option)>")
print(" [Settings file path]")
print(" xcf, xdt, ycf, ydt, kdt File")
print(" [Connection identifier]")
print(" 0 : NR-500 USB ID0")
print(" 1 : NR-500 USB ID1")
print(" 2 : NR-500 USB ID2")
print(" 3 : NR-500 USB ID3")
print(" 4 : NR-X100 USB ID0")
print(" 5 : NR-X100 USB ID1")
print(" 6 : NR-X100 USB ID2")
print(" 7 : NR-X100 USB ID3")
print(" 8 : NR-X100 LAN ID0")
print(" 9 : NR-X100 LAN ID1")
print(" 10: NR-X100 LAN ID2")
print(" 11: NR-X100 LAN ID3")
print(" [IP address]")
print(" IP address of the NRX-100 to be connected")
print(" Must be specified in the case of "
"Connection identifier is 8 to 11 (LAN Connection)")
print()
print("")
print("Sample1.py C:\NR-500Sample.xdt 0")
print("Sample1.py C:\NR-X100Sample.ydt 8 192.168.100.100 24682")
print

main()

これはキーエンスのロガーのサンプルプログラムです。
これをspyderで実行させたいのですが実行の仕方がわかりません。
Sample1.py C:\NR-500Sample.xdt 0をどこかに打てば実行できると予想していますが
どこに入力するのか、どのような形で入力するかわかりません。
よろしくお願いします。

import os
import sys
import time
import win32com.client




NR500_USB_ID_START = 0
NR500_USB_ID_END = 3
NRX100_USB_ID_START = 4
NRX100_USB_ID_END = 7
NRX100_LAN_ID_START = 8
NRX100_LAN_ID_END = 11

STATE_START_WAIT = 2
STATE_TRIGGER_WAIT = 3
STATE_RUN = 4
STATE_REPEAT_RUN = 5
STATE_PRE_TRIGGER = 6
STATE_POST_TRIGGER = 7
STATE_STOP_WAIT = 8
STATE_READ_WAIT = 10
STATE_PROCEDURE_WAIT = 12


def main():
    if len(sys.argv) < 3:
        show_help()
        return

    file_path = sys.argv[1]
    if not os.path.isfile(file_path):
        print("File not exist")
        return

    id = int(sys.argv[2])
    if NRX100_LAN_ID_START <= id and id <= NRX100_LAN_ID_END:
        if len(sys.argv) < 4:
            show_help()
            return

        ip = sys.argv[3].split('.')
        if len(ip) != 4:
            print("Illegal IP address")
            return

        port_number = 24682
        if 5 <= len(sys.argv):
            port_number = int(sys.argv[4])
            if port_number < 1025 or 65535 < port_number:
                print("Illegal port number")
                return

    wave_logger = win32com.client.Dispatch("WaveLoggerX.Application")
    wave_logger.Initialize()
    wave_logger.Visible = True

    id_result = wave_logger.SetIdentifier(id)
    if id_result != 0:
        print("Failed to set the device ID [error code: %d]" %id_result)
        return

    if NRX100_LAN_ID_START <= id and id <= NRX100_LAN_ID_END:
        lan_id = id - NRX100_LAN_ID_START
        config_result = wave_logger.SetLanConfig(
            lan_id, ip[0], ip[1], ip[2], ip[3], port_number)
        if config_result != 0:
            print("Failed to set LAN parameters [error code: %d]" %config_result)
            return

        connect_result = wave_logger.ConnectLan
        if connect_result != 0:
            print("Connection failed [error code: %d]" %connect_result)
            return

    open_result = wave_logger.OpenFile(file_path)
    if open_result != 0:
        print("File open error [error code: %d]" %open_result)
        return

    start_result = wave_logger.Start
    if start_result != 0:
        print("Starting acquisition failed [error code: %d]" %start_result)
        return

    document = wave_logger.GetActiveFile
    try:
        while is_running(wave_logger.GetState):
            print("\r"+"The amount of sampling data: " + str(document.GetDataCount) + 
                  " point (Press 'Ctrl + C' to stop acquisition)", end="")
            time.sleep(1)

    except KeyboardInterrupt:
        wave_logger.Stop()
        while is_running(wave_logger.GetState):
            time.sleep(1)

    print("\r"+"The amount of sampling data: " + str(document.GetDataCount) + 
          " point (Press 'Ctrl + C' to stop acquisition)")
    print("Press Enter to exit")
    input()


def is_running(state):
    return state in {STATE_START_WAIT,
                     STATE_TRIGGER_WAIT,
                     STATE_RUN,
                     STATE_REPEAT_RUN,
                     STATE_PRE_TRIGGER,
                     STATE_POST_TRIGGER,
                     STATE_STOP_WAIT,
                     STATE_READ_WAIT,
                     STATE_PROCEDURE_WAIT}


def show_help():
    print("<Operation explanation>")
    print("Reads the specified setting file, "
          "confirms the connection, and starts acquisition")
    print()
    print("<How to use>")
    print("$ python Sample1.py <Settings file path> "
          "<Connection identifier> <IP address(option)> <port number(option)>")
    print("    [Settings file path]")
    print("    xcf, xdt, ycf, ydt, kdt File")
    print("    [Connection identifier]")
    print("    0 : NR-500 USB ID0")
    print("    1 : NR-500 USB ID1")
    print("    2 : NR-500 USB ID2")
    print("    3 : NR-500 USB ID3")
    print("    4 : NR-X100 USB ID0")
    print("    5 : NR-X100 USB ID1")
    print("    6 : NR-X100 USB ID2")
    print("    7 : NR-X100 USB ID3")
    print("    8 : NR-X100 LAN ID0")
    print("    9 : NR-X100 LAN ID1")
    print("    10: NR-X100 LAN ID2")
    print("    11: NR-X100 LAN ID3")
    print("    [IP address]")
    print("    IP address of the NRX-100 to be connected")
    print("    Must be specified in the case of "
          "Connection identifier is 8 to 11 (LAN Connection)")
    print()
    print("<Example>")
    print("Sample1.py C:\\NR-500Sample.xdt 0")
    print("Sample1.py C:\\NR-X100Sample.ydt 8 192.168.100.100 24682")
    print


main()
ソース リンク
読み込んでいます