Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

【読書メモ】令和ビジネス書類テンプレート集 税率変更対応 (デジタル素材BOOK)

ビジネス文章は今まで何となく我流で作っていました。
もし分からない事が生じたら都度ググるという事を継続してきたのですが……
流石にそれは不味かろうという事で、本書を購入。

それぞれの文章について気をつけるべき事を書いてくれているので
自身の状況に応じて内容を変更する際にも助かります。

契約系なら

受発注の日常業務ならともかく、NDAや基本契約書は怖いよという場合、
お国が税金投じて作ってくれたやつがあります。
有効活用させてもらいましょう。
shuzo-kino.hateblo.jp

processingでテキスト入力をうけとる

キーボード入力は"key"という内部変数に格納されます。
イベントハンドラkeyPressed関数で拾ってレンダリングできます。

実際のところ

char   charactor;
String string = "";

void setup() {
  size(120,80);
  background(0);
}

void draw() {
  background(0);
  text("lastchar :' " + charactor + " ' ",10,20);
  text(string,10,60);
}

void keyPressed()
{
  charactor = key;
  string += key;
}

実行すると、こんな感じ
f:id:shuzo_kino:20191102001245p:plain


テキストボックスめいたものを作る場合……以下のような感じの実装になるかと思います。

  • テキストボックス風の領域をつくる
  • マウスクリックかtabキーでフォーカスできるようにする
  • 入力できるようにする。

processingのweb鯖

実際のところ

Processing

/**
 * Sttings. 
 * 
 * Robot Arm showing UI. 
 */
 
import processing.net.*;

int port = 10002;
boolean myServerRunning = true;
int bgColor = 0;
int direction = 1;
int textLine = 60;

int rad = 60;
int[] dataArray = {0,0,0};


Server myServer;

void setup() 
{
  size(640, 360);
  noStroke();
  myServer = new Server(this, port); // Starts a myServer on port 10002
  
  background(102); //Window clear
  text("server", 15, 45);
}

void mousePressed()
{
  // If the mouse clicked the myServer stops
  myServer.stop();
  myServerRunning = false;
}

void draw() 
{  
  if (myServerRunning == true)
  {
    Client thisClient = myServer.available();
    if (thisClient != null) {
      if (thisClient.available() > 0) {
        // text("mesage from: " + thisClient.ip() + " : " + thisClient.readString(), 15, textLine);
        //textLine = textLine + 35;
        dataArray = int(split(thisClient.readString(), ","));
        println(dataArray);
        
        background(102);
        text("server", 15, 45);

        showData(dataArray[0],dataArray[1],dataArray[2]);

      }
    }
  } 
  else 
  {
    text("server", 15, 45);
    text("stopped", 15, 65);
  }
}

void showData (int x,int y,int z) 
{
    text(x, 10, textLine);
    text(y, 60, textLine);
    text(z, 110, textLine);
    ellipse(100+ (x % 200), 100 + (y % 200), 12, 12);
}

データ送信(コマンドライン)

サーバーはローカルホストで起動しているので、これにncコマンドで送ってみます

$ cat senddata.sh 
#!/bin/bash

var=100

while :
do
  var=`expr $var + 20`
  printf "%d,%d,111" $var 100 | netcat  -c localhost 10002
  sleep 1s
done

【イベントログ】ロボティクスカーニバル2019with電気通信大学で発表してきました。

ロボティクスカーニバル2019with電気通信大学を開催します(開催日10月29日(火)) – 公益財団法人 埼玉県産業振興公社
f:id:shuzo_kino:20191029233712p:plain

公益財団法人埼玉県産業振興公社が主催する、
ロボティクスカーニバル2019with電気通信大学に出てきました。



私は
 電通大ベンチャー紹介『小型ロボットアームの活用事例の紹介』
というネタで発表してきました。

X Window越しでRasPiのGUIを起動する

macOSならXQuarts越しにRasPiのGUIアプリを起動できます。
……なんだよこれ……知らなかったよそんなのぉ……今まで毎回ディスプレイ起動したりVNCやったりしたのに(絶望

実際のところ

$ ssh -X -C pi@remote.local 
pi@remote:~ $ nohup arduino &

f:id:shuzo_kino:20191029232053p:plain

f:id:shuzo_kino:20191029232058p:plain

socatで作ったサーバーに一個毎にデータを送る

socatで作ったサーバーにデータを送る方法です。
なんも考えないでnetcatで送信、コネクションが切れず終わらない

実際のところ

サーバー

ベタに、パケットを受け取って、USBポートにつないだシリアルデバイスにパケットを流す構成です。

$ socat TCP4-LISTEN:5300,fork /dev/ttyUSB0 

クライアント

netcat版

"-c"オプションをいれます

$ printf "100 100 150 1000"  | netcat  -c 192.168.0.7 5300

avahiでの指定もいけます。楽チンでいいですね。

$ printf "120 100 150 2300"  | netcat  -c raspberrypi.local 5300

socat版

こちらはトンネルするだけなので、そのまま。楽でいいですね。

 $ echo "100 100 150 1000" | socat - tcp:192.168.0.7:5300