當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。