当前位置: 首页>>代码示例>>Python>>正文


Python Data.makeData方法代码示例

本文整理汇总了Python中MDSplus.Data.makeData方法的典型用法代码示例。如果您正苦于以下问题:Python Data.makeData方法的具体用法?Python Data.makeData怎么用?Python Data.makeData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MDSplus.Data的用法示例。


在下文中一共展示了Data.makeData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: store

# 需要导入模块: from MDSplus import Data [as 别名]
# 或者: from MDSplus.Data import makeData [as 别名]
    def store(self, arg):
        """
        Store the data from the device
        """
        print '####################################################'
        print 'HMA store sh_amp.py 13/06/2012'

        #Open the Serial Port
        try:
            ser=serial.Serial(0, 19200, timeout=1)
        except serial.SerialException:
            raise RuntimeError('!!! EXCEPTION - Unable to open serial port - check no other program is using it')
            #exit("Unable to open the serial port!!! Check no other program is using")
        print ' Serial Port Open::',
        ser.flushInput()

        #Send Transmit Command
        print ' Transmit To Amplifiers::',
        self.sendMicroCommand(ser, '3')
        self.sendMicroCommand(ser, '6')

        #Wait for success reply from Micro, close Serial Port and Exit
        #print 'Wait for success reply from Micro'
        self.waitForData(ser, 1)
        test=ord(ser.read())
        print ser.read()
        if test==1:
            print ' TransmitSuccess'
            #print 'Finished Transmitting - Success!!!!'
        else:
            print ' Transmission Failed!!!!!'
            raise RuntimeError('!!! EXCEPTION - Transmission failure')
            #exit("Transmission Failure Error From Micro")

        print ' RetrieveAmpShotSettings::'
        self.sendMicroCommand(ser, '6')
        self.waitForData(ser, 96)
        returnedData=map(ord,ser.read(96))
        #print 'Values That Were Stored in the Amplifier Switch Chips'
        #print returnedData

        #Readback the old settings
        data, data2 = self.get_settings()


        if returnedData==data2:
            print ' Success - Correct Return Values'
            returnedValueSuccess=1
        else:
            print ' !!! Fail - Incorrect Return Values'
            raise RuntimeError('!!! EXCEPTION - ECHOED VALUES INCORRECT - WRONG AMPLIFIER SETTINGS DURING SHOT')
            returnedValueSuccess=0

        ser.close()
        print ' Serial Port Closed'

        linelength = 6
        n_loops = len(returnedData)/linelength
        anotherOutput=''
        for i in range(n_loops):
            tmp_line = returnedData[i*linelength:(i+1)*linelength]
            line_str = ' '.join('%d' %i for i in tmp_line)
            output_str = '< %s >\n' %line_str
            #print output_str
            anotherOutput+=output_str



        if returnedValueSuccess==1:
            anotherOutput+='SUCCESS'
        else:
            anotherOutput+='FAIL'

        new_data = Data.makeData(anotherOutput)
        self.readback.putData(new_data)
        if returnedValueSuccess==1:
            new_data2=Data.makeData('1')
        else:
            new_data2=Data.makeData('0')

        self.amp_success.putData(new_data2)

        #node.putData(new_data)
        #node2=t.getNode('.shaunampbox:amp_success')
        #node2.putData(new_data2)
        #print 'Received Data written to MDSplus Shot Number :' + str(shot_number)
        return 1
开发者ID:shaunhaskey,项目名称:AnuDevices,代码行数:89,代码来源:sh_amp.py

示例2: store

# 需要导入模块: from MDSplus import Data [as 别名]
# 或者: from MDSplus.Data import makeData [as 别名]
    def store(self, arg):
        """
        Store the data from the device
        """
        print '============Helical / Toroidal Mirnov Array Serial Connection - Post Shot======='
        #Open the Serial Port
        try:
            ser=serial.Serial(0, 19200, timeout=1)
        except serial.SerialException:
            exit("Unable to open the serial port!!! Check no other program is using")
        print 'Serial Port Open'
        ser.flushInput()

        #Send Transmit Command
        print 'Sending ~Transmit To Amplifiers~ Command Sequence to Micro'
        self.sendMicroCommand(ser, '3')
        self.sendMicroCommand(ser, '6')

        #Wait for success reply from Micro, close Serial Port and Exit
        print 'Wait for success reply from Micro'
        self.waitForData(ser, 1)
        test=ord(ser.read())
        print ser.read()
        if test==1:
            print 'Finished Transmitting - Success!!!!'
        else:
            print 'Transmission Failed!!!!!'
            exit("Transmission Failure Error From Micro")

        print 'Obtain Values that were stored in the amplifier switch chips from the Micro'
        self.sendMicroCommand(ser, '6')
        self.waitForData(ser, 96)
        returnedData=map(ord,ser.read(96))
        print 'Values That Were Stored in the Amplifier Switch Chips'
        print returnedData

        #Readback the old settings
        data, data2 = self.get_settings()


        if returnedData==data2:
            print '=====================Success - Correct Return Values========'
            returnedValueSuccess=1
        else:
            print '======================Fail - Incorrect Return Values========'
            returnedValueSuccess=0

        ser.close()
        print 'Serial Port Closed'

        linelength = 6
        n_loops = len(returnedData)/linelength
        anotherOutput=''
        for i in range(n_loops):
            tmp_line = returnedData[i*linelength:(i+1)*linelength]
            line_str = ' '.join('%d' %i for i in tmp_line)
            output_str = '< %s >\n' %line_str
            #print output_str
            anotherOutput+=output_str



        if returnedValueSuccess==1:
            anotherOutput+='SUCCESS'
        else:
            anotherOutput+='FAIL'

        new_data = Data.makeData(anotherOutput)
        self.readback.putData(new_data)
        if returnedValueSuccess==1:
            new_data2=Data.makeData('1')
        else:
            new_data2=Data.makeData('0')

        self.amp_success.putData(new_data2)

        #node.putData(new_data)
        #node2=t.getNode('.shaunampbox:amp_success')
        #node2.putData(new_data2)
        #print 'Received Data written to MDSplus Shot Number :' + str(shot_number)


        return 1
开发者ID:shaunhaskey,项目名称:AnuDevices,代码行数:85,代码来源:sh_amp2.py


注:本文中的MDSplus.Data.makeData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。