本日はmockmockアドベントカレンダーの12日目です。
バケットバリュージェネレーターについてです!
バケットバリュージェネレーターとは
離散値をあつかうバリュージェネレーターです。
値のリストを渡すことで、ランダムもしくは順番に値を生成できます。
送信ルール
送信ルールについてそれぞれ説明します。
ランダム
送信ルールをランダムにして、データリストに入れる値を工夫すると出現確率が制御できます。
サンプルはNG確率10%のステータスを生成しました。
ランダムなので、NGがいつ出るかは制御できせんが、いい感じに10%のNGがでています。
2019-11-18 08:01:31.363839 {"serial_number":"dv-001","time":"2019-11-18T08:01:29Z","status":"ok"}
2019-11-18 08:01:39.838374 {"serial_number":"dv-001","time":"2019-11-18T08:01:39Z","status":"ok"}
2019-11-18 08:01:49.837749 {"serial_number":"dv-001","time":"2019-11-18T08:01:49Z","status":"ok"}
2019-11-18 08:01:59.843312 {"serial_number":"dv-001","time":"2019-11-18T08:01:59Z","status":"ok"}
2019-11-18 08:02:09.836346 {"serial_number":"dv-001","time":"2019-11-18T08:02:09Z","status":"ng"}
2019-11-18 08:02:19.832031 {"serial_number":"dv-001","time":"2019-11-18T08:02:19Z","status":"ok"}
2019-11-18 08:02:29.842585 {"serial_number":"dv-001","time":"2019-11-18T08:02:29Z","status":"ok"}
2019-11-18 08:02:39.850557 {"serial_number":"dv-001","time":"2019-11-18T08:02:39Z","status":"ok"}
2019-11-18 08:02:49.843809 {"serial_number":"dv-001","time":"2019-11-18T08:02:49Z","status":"ok"}
2019-11-18 08:02:59.850951 {"serial_number":"dv-001","time":"2019-11-18T08:02:59Z","status":"ng"}
2019-11-18 08:03:09.845432 {"serial_number":"dv-001","time":"2019-11-18T08:03:09Z","status":"ok"}
2019-11-18 08:03:19.847263 {"serial_number":"dv-001","time":"2019-11-18T08:03:19Z","status":"ok"}
2019-11-18 08:03:29.845405 {"serial_number":"dv-001","time":"2019-11-18T08:03:29Z","status":"ok"}
2019-11-18 08:03:39.838682 {"serial_number":"dv-001","time":"2019-11-18T08:03:39Z","status":"ok"}
2019-11-18 08:03:49.869844 {"serial_number":"dv-001","time":"2019-11-18T08:03:49Z","status":"ok"}
2019-11-18 08:03:59.845353 {"serial_number":"dv-001","time":"2019-11-18T08:03:59Z","status":"ok"}
2019-11-18 08:04:09.830634 {"serial_number":"dv-001","time":"2019-11-18T08:04:09Z","status":"ok"}
2019-11-18 08:04:19.845379 {"serial_number":"dv-001","time":"2019-11-18T08:04:19Z","status":"ok"}
2019-11-18 08:04:29.836624 {"serial_number":"dv-001","time":"2019-11-18T08:04:29Z","status":"ok"}
2019-11-18 08:04:39.853877 {"serial_number":"dv-001","time":"2019-11-18T08:04:39Z","status":"ok"}
順次
リストに入力されている順番の通りにデータを送信します。
状態遷移等でステータスが変わると、データリストの途中であっても一番上から送信し直します。
サンプルに状態遷移を設定しました。10%の確率でエラーになり(Errorと出力する)、50%の確率でデフォルトに復帰する設定です。
「順次」と次に説明する「継続的順次」の違いは、状態遷移したときにデータリストの上から出力していた順番をリセットするかしないかです。
順次の場合はリセットします。エラーから復帰するたびに、データリストの一番上の値から送信します。
2019-11-19 01:46:12.907079 {"serial_number":"mk-001","time":"2019-11-19T01:46:11Z","status":"ok"}
2019-11-19 01:46:21.379431 {"serial_number":"mk-001","time":"2019-11-19T01:46:21Z","status":"Error"}
2019-11-19 01:46:31.387741 {"serial_number":"mk-001","time":"2019-11-19T01:46:31Z","status":"Error"}
2019-11-19 01:46:41.382446 {"serial_number":"mk-001","time":"2019-11-19T01:46:41Z","status":"Error"}
2019-11-19 01:46:51.385901 {"serial_number":"mk-001","time":"2019-11-19T01:46:51Z","status":"Error"}
2019-11-19 01:47:01.385961 {"serial_number":"mk-001","time":"2019-11-19T01:47:01Z","status":"ok"}
2019-11-19 01:47:11.390915 {"serial_number":"mk-001","time":"2019-11-19T01:47:11Z","status":"ok"}
2019-11-19 01:47:21.390223 {"serial_number":"mk-001","time":"2019-11-19T01:47:21Z","status":"ok"}
2019-11-19 01:47:31.393103 {"serial_number":"mk-001","time":"2019-11-19T01:47:31Z","status":"ok"}
2019-11-19 01:47:41.380794 {"serial_number":"mk-001","time":"2019-11-19T01:47:41Z","status":"Error"}
2019-11-19 01:47:51.386050 {"serial_number":"mk-001","time":"2019-11-19T01:47:51Z","status":"ok"}
2019-11-19 01:48:01.387549 {"serial_number":"mk-001","time":"2019-11-19T01:48:01Z","status":"ok"}
2019-11-19 01:48:11.396184 {"serial_number":"mk-001","time":"2019-11-19T01:48:11Z","status":"ok"}
2019-11-19 01:48:21.384459 {"serial_number":"mk-001","time":"2019-11-19T01:48:21Z","status":"ok"}
2019-11-19 01:48:31.385022 {"serial_number":"mk-001","time":"2019-11-19T01:48:31Z","status":"ok"}
2019-11-19 01:48:41.381922 {"serial_number":"mk-001","time":"2019-11-19T01:48:41Z","status":"ok"}
2019-11-19 01:48:51.398977 {"serial_number":"mk-001","time":"2019-11-19T01:48:51Z","status":"ok"}
2019-11-19 01:49:01.392538 {"serial_number":"mk-001","time":"2019-11-19T01:49:01Z","status":"ok"}
2019-11-19 01:49:11.378935 {"serial_number":"mk-001","time":"2019-11-19T01:49:11Z","status":"ok"}
2019-11-19 01:49:21.390017 {"serial_number":"mk-001","time":"2019-11-19T01:49:21Z","status":"ng"}
2019-11-19 01:49:31.380341 {"serial_number":"mk-001","time":"2019-11-19T01:49:31Z","status":"ok"}
Error状態
からdefaultに戻ったタイミングで、リストがリセットされるので、NGがなかなか出ません〜。
継続的順次
データリストの一番上から順番にデータを送信します。
さらに、状態遷移してもリストをリセットしません。エラーから復帰した時、リストの途中のデータから送信を再開します。
2019-11-19 01:19:33.278178 {"serial_number":"mk-001","time":"2019-11-19T01:19:31Z","status":"ok"}
2019-11-19 01:19:41.778246 {"serial_number":"mk-001","time":"2019-11-19T01:19:41Z","status":"ok"}
2019-11-19 01:19:51.781838 {"serial_number":"mk-001","time":"2019-11-19T01:19:51Z","status":"ok"}
2019-11-19 01:20:01.778636 {"serial_number":"mk-001","time":"2019-11-19T01:20:01Z","status":"ok"}
2019-11-19 01:20:11.782252 {"serial_number":"mk-001","time":"2019-11-19T01:20:11Z","status":"ok"}
2019-11-19 01:20:21.779396 {"serial_number":"mk-001","time":"2019-11-19T01:20:21Z","status":"ok"}
2019-11-19 01:20:31.781555 {"serial_number":"mk-001","time":"2019-11-19T01:20:31Z","status":"ok"}
2019-11-19 01:20:41.790466 {"serial_number":"mk-001","time":"2019-11-19T01:20:41Z","status":"ok"}
2019-11-19 01:20:51.781097 {"serial_number":"mk-001","time":"2019-11-19T01:20:51Z","status":"ok"}
2019-11-19 01:21:01.770577 {"serial_number":"mk-001","time":"2019-11-19T01:21:01Z","status":"Error"}
2019-11-19 01:21:11.782826 {"serial_number":"mk-001","time":"2019-11-19T01:21:11Z","status":"ng"}
2019-11-19 01:21:21.770170 {"serial_number":"mk-001","time":"2019-11-19T01:21:21Z","status":"ok"}
2019-11-19 01:21:31.770750 {"serial_number":"mk-001","time":"2019-11-19T01:21:31Z","status":"ok"}
2019-11-19 01:21:41.779340 {"serial_number":"mk-001","time":"2019-11-19T01:21:41Z","status":"ok"}
2019-11-19 01:21:51.790354 {"serial_number":"mk-001","time":"2019-11-19T01:21:51Z","status":"ok"}
2019-11-19 01:22:01.767647 {"serial_number":"mk-001","time":"2019-11-19T01:22:01Z","status":"ok"}
2019-11-19 01:22:11.769007 {"serial_number":"mk-001","time":"2019-11-19T01:22:11Z","status":"ok"}
2019-11-19 01:22:21.782243 {"serial_number":"mk-001","time":"2019-11-19T01:22:21Z","status":"ok"}
2019-11-19 01:22:31.784371 {"serial_number":"mk-001","time":"2019-11-19T01:22:31Z","status":"ok"}
2019-11-19 01:22:41.785791 {"serial_number":"mk-001","time":"2019-11-19T01:22:41Z","status":"ok"}
以上、バケットバリュージェネレーターの送信ルールの違いでした!
デバイスの仕様に合わせて設定してみてください ✨💪✨
明日は
@Kta-Mによる、めっっっちゃ便利な位置ジェネレーターについて書いてくれます。
明日もよろしくお願いします!