Writes bus data in MATPOWER format.
188741
def write_bus_data(self, file):
        
        # I, 'NAME', BASKV, IDE, GL, BL, AREA, ZONE, VM, VA, OWNER
        bus_attrs = ["_i", "name", "v_base", "type", "g_shunt", "b_shunt",
                     "area", "zone",
                     "v_magnitude", "v_angle"]

        for bus in self.case.buses:
            vals = [getattr(bus, a) for a in bus_attrs]
            if float(vals[6]) == 0.0:
                vals[6] = 1  # default AREA: 1
            if float(vals[7])==0.0:
                vals[7] = 1  # default ZONE: 1
            d = {PQ: 1, PV: 2, REFERENCE: 3, ISOLATED: 4}
            vals[3] = d[vals[3]]
            vals.append(1)

#            print len(vals), vals

            file.write("%6d,'%-10s',%10.4f,%d,%10.3f,%10.3f,%4d,%4d,%10.3f,"
                       "%10.3f%4d\n" % tuple(vals))
        file.write(" 0 / END OF BUS DATA, BEGIN LOAD DATA\n")


        # I, ID, STATUS, AREA, ZONE, PL, QL, IP, IQ, YP, YQ, OWNER
        load_attrs = ["_i", "area", "zone", "p_demand", "q_demand"]

        for bus in self.case.buses:
            if bus.p_demand > 0.0 or bus.q_demand > 0.0:
                vals = [getattr(bus, a) for a in load_attrs]
                if float(vals[1])==0.0:
                    vals[1] = 1  # default AREA: 1
                if float(vals[2])==0.0:
                    vals[2] = 1  # default ZONE: 1
                vals.insert(1, 1) # STATUS
                vals.insert(1, "1 ") # ID
                vals.extend([0., 0., 0., 0.])
                vals.append(1) # OWNER

                file.write("%6d,'%s',%2d,%2d,%2d,%10.3f,%10.3f,%10.3f,%10.3f,"
                           "%10.3f,%10.3f,%4d\n" % tuple(vals))

        file.write(" 0 / END OF LOAD DATA, BEGIN GENERATOR DATA\n")
1126687
public void writeTo(DataOutputStream os) throws IOException
    {
    
    	int padding;
		if (size<=4 && size>0) {
			// Use small data element format (Page 1-10 in "MATLAB 7 MAT-File Format", September 2010 revision)
    		os.writeShort(size);
    		os.writeShort(type);
            padding = getPadding(data.limit(), true);
    	} else {
    		os.writeInt(type);
    		os.writeInt(size);
            padding = getPadding(data.limit(), false);
    	}
        
        int maxBuffSize = 1024;
        int writeBuffSize = data.remaining() < maxBuffSize ? data.remaining() : maxBuffSize;
        byte[] tmp = new byte[writeBuffSize]; 
        while ( data.remaining() > 0 )
        {
            int length = data.remaining() > tmp.length ? tmp.length : data.remaining();
            data.get( tmp, 0, length);
            os.write(tmp, 0, length);
        }
        
        if ( padding > 0 )
        {
            os.write( new byte[padding] );
        }
    }
278535
def write_frame(self, buf):
        '''
        
        '''
        writer = Writer(buf)

        writer.write_octet(self.type()).\
            write_short(self.channel_id).\
            write_long(len(self._payload)).\
            write(self._payload).\
            write_octet(0xce)
639088
def write_bytes(self, data, n):
        """"""
        for pos in xrange(0, n):
            self.payload[self.pos + pos] = data[pos]
            
        self.pos += n
66549
def _Write(self, data, length, progress_callback=None):
        """"""
        if progress_callback:
            progress = self._HandleProgress(length, progress_callback)
            next(progress)
        while length:
            tmp = data.read(self.chunk_kb * 1024)
            length -= len(tmp)
            self.usb.BulkWrite(tmp)

            if progress_callback and progress:
                progress.send(len(tmp))
450615
def Write(self, data):
        """"""
        self._Send(b'WRTE', arg0=self.local_id, arg1=self.remote_id, data=data)
        # Expect an ack in response.
        cmd, okay_data = self.ReadUntil(b'OKAY')
        if cmd != b'OKAY':
            if cmd == b'FAIL':
                raise usb_exceptions.AdbCommandFailureException(
                    'Command failed.', okay_data)
            raise InvalidCommandError(
                'Expected an OKAY in response to a WRITE, got %s (%s)',
                cmd, okay_data)
        return len(data)
119807
def _write4bits(self, value):
        """"""
        for i in range(4):
            bit = (value >> i) & 0x01
            GPIO.output(self.pins[i + 7], bit)
        self._pulse_enable()
783189
def write(self, output):
        
        w = c_int32()
        # print "output max", max(abs(output))
        self.WriteAnalogF64(self.bufsize, 0, 10.0, DAQmx_Val_GroupByChannel,
                            output, w, None);
378839
private synchronized void write(WritableByteChannel channel,
            Collection<MLArray> data) throws IOException
    {
        try
        {
            //write header
            writeHeader(channel);

            //write data
            for ( MLArray matrix : data )
            {
                //compress data to save storage
                Deflater compresser = new Deflater();

                ByteArrayOutputStream2 compressed = new ByteArrayOutputStream2();
                DataOutputStream dout = new DataOutputStream(new DeflaterOutputStream(compressed, compresser));

                writeMatrix( dout, matrix );
                dout.flush();
                dout.close();

                //write COMPRESSED tag and compressed data into output channel

                int compressedSize = compressed.getCount();
                ByteBuffer buf = ByteBuffer.allocateDirect(2 * 4 /* Int size */ + compressedSize);
                buf.putInt( MatDataTypes.miCOMPRESSED );

                buf.putInt( compressedSize);
                buf.put(compressed.getBuf(), 0, compressedSize);

                buf.flip();
                channel.write( buf );
            }
        }
        catch ( IOException e )
        {
            throw e;
        }
        finally
        {
            channel.close();
        }
    }
1171033
def data(self, c):
        """"""
        if self._spi is not None:
            # SPI write.
            self._gpio.set_high(self._dc)
            self._spi.write([c])
        else:
            # I2C write.
            control = 0x40   # Co = 0, DC = 0
            self._i2c.write8(control, c)
1253925
def _compile_bus_injection(self):
        """"""
        string = '"""\n'
        for device, series in zip(self.devices, self.series):
            if series:
                string += 'system.' + device + '.gcall(system.dae)\n'
        string += '\n'
        string += 'system.dae.reset_small_g()\n'
        string += self.gisland
        string += '"""'
        self.bus_injection = compile(eval(string), '', 'exec')
1245377
def GPIO_config(self, gpio_enable, gpio_config):
        ''
        self.bus.write_byte_data(self.address, 0xF6, gpio_enable)
        self.bus.write_byte_data(self.address, 0xF7, gpio_config)
        return
762252
def write_bytes(self, data: bytes, *, append=True):
        '''  '''
        mode = 'ab' if append else 'wb'
        return self.write(data, mode=mode)
147299
def _writeToTransport(self, data):
        ''''''
        self.transport.writeData(data)
        self.heartbeater.schedule()
325545
def SPI_write(self, chip_select, data):
        ' '
        dat = list(data)
        dat.insert(0, chip_select)
        return self.bus.write_i2c_block(self.address, dat);
1163152
def push_bus(self, tokens):
        
        logger.debug("Pushing bus data: %s" % tokens)

        bus = Bus()
        bus.name = tokens["bus_no"]
        bus.v_magnitude = tokens["v_magnitude"]
        bus.v_angle = tokens["v_angle"]
        bus.v_magnitude = tokens["v_magnitude"]
        bus.v_angle = tokens["v_angle"]

        self.case.buses.append(bus)
1345127
def write(self, buf):
        """"""
        return self.transport_sock.sendto(
            buf,
            (self.transport_host, self.transport_port)
        )