2024,江端さんの技術メモ

ポインタと値の操作: item がリスト内の要素をポインタ経由で取得している場合、item を変更しても元のリストの要素が変更されることがありますが、それ以外の場合はそのような自動的な反映は行われません。必要に応じて、&item を使用してポインタ経由でアクセスし、リスト内の要素を直接変更します。

 

スライスと範囲ループの挙動: Go言語では、for range ループで取得した item は元のスライスの要素のコピーです。これにより、item を直接変更しても元のリストの要素に反映されません。そのため、ポインタ経由でアクセスして変更する必要があります。

失敗例

var estimatedStartTime time.Time
			var estimatedMovingTime time.Duration
			var estimatedStayTime time.Duration

			for i, item := range list {

				if i == 0 {
					estimatedStartTime = estimated_Start_Time(data, item.destination) // 出発時刻(リアル時間)
					fmt.Println("i=0のitem.destination:", item.destination)
					fmt.Println("i=0のestimatedStartTime:", estimatedStartTime)
					item.dep_time = estimatedStartTime // 時刻 (記録用)
					fmt.Println("in i=0  item.dep_time:", item.dep_time)
				} else {
					item.dep_time = estimatedStartTime.Add(estimatedMovingTime + estimatedStayTime)
				}

				fmt.Println("===================>", item.dep_time)

				estimatedMovingTime = estimated_Moving_Time(item.ox, item.oy, item.dx, item.dy) // 移動時間(間隔)
				fmt.Println("estimatedMovingTime:", estimatedMovingTime)

				estimatedStayTime = estimated_Stay_Time(data, item.destination) // 滞在時間(間隔)
				fmt.Println("estimatedStayTime:", estimatedStayTime)

				// item.dep_time = estimatedStartTime // 時刻 (記録用)
				item.stay_time = estimatedStayTime // 滞在時間(間隔) (記録用)


					if i+1 < len(list) {
						fmt.Println("in 558", estimatedStartTime, item.dep_time)
						nextItem := &list[i+1]
						nextItem.dep_time = estimatedStartTime.Add(estimatedMovingTime + estimatedStayTime) // 次の出発時刻 = 現在の出発時刻 + 移動時間
						fmt.Println("After nextItem.dep_time:", nextItem.dep_time)
						fmt.Println("in 562", estimatedStartTime, item.dep_time)
					}


				//fmt.Println("in 565", estimatedStartTime, item.dep_time)

			}

			for i, item := range list {
				fmt.Println(i, "item.dep_time:", item.dep_time)
				fmt.Println(i, "item.stay_time:", item.stay_time)
				fmt.Println(i, "item:", item)
				//fmt.Println(i, "item.dep_time:", item.dep_time.Format("2006-01-02 15:04:05"))
			}

成功例

var estimatedStartTime time.Time
		var estimatedMovingTime time.Duration
		var estimatedStayTime time.Duration

		for i := range list {
			if i == 0 {
				estimatedStartTime = estimated_Start_Time(data, list[i].destination)
				fmt.Println("i=0のitem.destination:", list[i].destination)
				fmt.Println("i=0のestimatedStartTime:", estimatedStartTime)
				list[i].dep_time = estimatedStartTime
				fmt.Println("in i=0  item.dep_time:", list[i].dep_time)
			} else {
				// 前のアイテムの出発時刻に移動時間と滞在時間を加えて計算
				list[i].dep_time = list[i-1].dep_time.Add(estimatedMovingTime + estimatedStayTime)
			}

			// 移動時間と滞在時間を計算する
			estimatedMovingTime = estimated_Moving_Time(list[i].ox, list[i].oy, list[i].dx, list[i].dy)
			fmt.Println("estimatedMovingTime:", estimatedMovingTime)

			estimatedStayTime = estimated_Stay_Time(data, list[i].destination)
			fmt.Println("estimatedStayTime:", estimatedStayTime)

			// 滞在時間を記録用に設定する
			list[i].stay_time = estimatedStayTime

			fmt.Println("===================>", list[i].dep_time)
		}

		for i := range list {
			fmt.Println(i, "item.dep_time:", list[i].dep_time)
			fmt.Println(i, "item.stay_time:", list[i].stay_time)
			fmt.Println(i, "item:", list[i])
		}
	}

そんな仕様、知るかーーーー

2024,江端さんの技術メモ

gst-launch-1.0 rtspsrc location=rtsp://cam:Cam12345@192.168.0.10/Src/MediaInput/stream_1 latency=0 ! rtph264depay ! avdec_h264 ! videoconvert ! videoscale ! video/x-raw,width=640,height=360 ! videorate ! video/x-raw,framerate=5/1 ! x264enc bitrate=1700 speed-preset=ultrafast tune=zerolatency key-int-max=1 ! mpegtsmux ! srtserversink uri = \"srt://192.168.101.10:38089\" latency=500
を実施するためだけのプログラムをGO言語で作成してください

package main

import (
	"fmt"
	"os"

	"github.com/go-gst/go-glib/glib"
	"github.com/go-gst/go-gst/gst"
)

func main() {
	fmt.Println("starting.....")

	// gstreamer初期化処理
	gst.Init(&os.Args)

	// メインループ生成
	mainLoop := glib.NewMainLoop(glib.MainContextDefault(), false)

	// パイプラインの要素を生成
	source, _ := gst.NewElement("rtspsrc")
	depay, _ := gst.NewElement("rtph264depay")
	decoder, _ := gst.NewElement("avdec_h264")
	convert, _ := gst.NewElement("videoconvert")
	scale, _ := gst.NewElement("videoscale")
	rate, _ := gst.NewElement("videorate")
	filter1, _ := gst.NewElement("capsfilter")
	filter2, _ := gst.NewElement("capsfilter")
	encorder, _ := gst.NewElement("x264enc")
	mux, _ := gst.NewElement("mpegtsmux")
	sink, _ := gst.NewElement("srtsink")

	// 各要素のプロパティを設定
	source.SetProperty("location", "rtsp://cam:Cam12345@192.168.0.10/Src/MediaInput/stream_1")
	source.SetProperty("latency", 0)
	filter1.SetProperty("caps", gst.NewCapsFromString("video/x-raw,width=640,height=360"))
	filter2.SetProperty("caps", gst.NewCapsFromString("video/x-raw,framerate=5/1"))
	encorder.SetProperty("bitrate", 1700)
	encorder.SetProperty("speed-preset", "ultrafast")
	encorder.SetProperty("tune", "zerolatency")
	encorder.SetProperty("key-int-max", 1)
	sink.SetProperty("uri", "srt://192.168.101.10:38089")
	sink.SetProperty("latency", 500)

	// パイプラインを生成して要素を追加
	pipeline, _ := gst.NewPipeline("video_player")
	pipeline.AddMany(source, depay, decoder, convert, scale, rate, filter1, filter2, encorder, mux, sink)
	gst.ElementLinkMany(depay, decoder, convert, scale, rate, filter1, filter2, encorder, mux, sink)

	// 動的パッドのリンク
	source.Connect("pad-added", func(element *gst.Element, pad *gst.Pad) {
		pad.Link(depay.GetStaticPad("sink"))
	})

	// パイプラインメッセージ読取
	pipeline.GetPipelineBus().AddWatch(func(msg *gst.Message) bool {
		switch msg.Type() {
		case gst.MessageEOS: // end-of-streamを受信したらパイプラインを停止
			pipeline.BlockSetState(gst.StateNull)
			mainLoop.Quit()
		case gst.MessageError: // エラーメッセージはFatalにする
			err := msg.ParseError()
			fmt.Println("ERROR:", err.Error())
			if debug := err.DebugString(); debug != "" {
				fmt.Println("DEBUG:", debug)
			}
			mainLoop.Quit()
		default:
			// 受信メッセージの表示
			fmt.Println(msg)
		}

		return true
	})

	// パイプライン開始
	pipeline.SetState(gst.StatePlaying)

	// メインループ開始
	mainLoop.Run()
}

2024,江端さんの技術メモ

C言語を使えて、GStreamerが使えて、GO言語を使えて、CGOが使える環境を作っています。

(1)Windowsの方のmsys2とGStreamerのパッケージを削除
Windowsの方のC言語、GStreamerはコンフリクトするので削除しますが、GO言語は、別のタスク(大学の方のシミュレータ)があるので、削除できませんでした。
という訳で、MSYS2の環境を、Windowsの方と切り離して運用するという覚悟ができました。

(2)C:の容量が小さいので、G:\の方にパッケージを分離していたのですが、これをやると、全く動かなくなるので、C:\msys2の配下に勝手に作成される、/c/msys64/home/tomoi/の直下でプログラムの作成をすることにしました。

これ、/usr/local/binの配下に/home/ebataを作るような気持ち悪さがあるのですが、今回は稼動が最優先です。

MSYS2のインストール

  1. MSYS2公式サイトからインストーラをダウンロードします。
  2. インストーラを実行し、画面の指示に従ってMSYS2をインストールします。

2. MSYS2の初期設定

  1. MSYS2ターミナルを起動: MSYS2 MSYSショートカットを使用してMSYS2ターミナルを起動します。
  2. パッケージデータベースと基本パッケージの更新: 以下のコマンドを順番に実行して、パッケージデータベースと基本パッケージを更新します。

    sh

    pacman -Syu

    初回のアップデートが完了したら、ターミナルを一度閉じて再起動します。

  3. 再度更新を実行: ターミナルを再起動後、再度以下のコマンドを実行します。

    sh

    pacman -Syu

3. MinGW-w64のインストール

  1. MinGW-w64ツールチェインのインストール: MSYS2 MinGW 64-bitショートカットを使用してMSYS2ターミナルを起動し、以下のコマンドを実行します。

    sh

    pacman -S mingw-w64-x86_64-toolchain

    これにより、GCC、G++、およびその他の開発ツールがインストールされます。

4. 環境変数の設定

MinGW-w64のバイナリにアクセスするために、環境変数PATHを設定します。

  1. ~/.bashrcファイルの編集: MSYS2ターミナルで~/.bashrcファイルを開きます。

    sh

    nano ~/.bashrc
  2. PATHの設定: 以下の行を追加して保存します。

    sh

    export PATH="/mingw64/bin:$PATH"
  3. 設定の反映: 設定を反映させるために、ターミナルを再起動するか、以下のコマンドを実行します。

    sh

    source ~/.bashrc

5. GStreamerのインストール

  1. GStreamerのパッケージのインストール: MSYS2 MinGW 64-bitショートカットを使用してMSYS2ターミナルを起動し、以下のコマンドを実行します。

    sh

    pacman -S mingw-w64-x86_64-gstreamer mingw-w64-x86_64-gst-plugins-base mingw-w64-x86_64-gst-plugins-good mingw-w64-x86_64-gst-plugins-bad mingw-w64-x86_64-gst-plugins-ugly

    pacman -S mingw-w64-x86_64-gstreamer mingw-w64-x86_64-gst-plugins-base mingw-w64-x86_64-gst-plugins-good mingw-w64-x86_64-gst-plugins-bad mingw-w64-x86_64-gst-libav

6. 確認とテスト

  1. GCCの動作確認: GCCが正しくインストールされているか確認します。

    sh

    gcc --version
  2. 簡単なCプログラムの作成とコンパイル: 簡単なCプログラムを作成してコンパイルします。

    sh

    nano test.c

    以下の内容を入力します。

    c

    #include <stdio.h>

    int main() {
    printf("Hello, World!\n");
    return 0;
    }

    ファイルを保存してNanoエディタを閉じた後、コンパイルします。

    sh

    gcc test.c -o test.exe

    コンパイルが成功したら、実行します。

    sh

    ./test.exe
  3. GStreamerの動作確認: GStreamerが正しくインストールされているか確認します。

    sh

    gst-launch-1.0 --version

    簡単なGStreamerパイプラインを実行して動作確認します。

    sh

    gst-launch-1.0 videotestsrc ! autovideosink

とうぜん 、ここまですんなりできた訳ではありませんが、取り敢えず私が思い出せる程度の情報を載せてあります。

-----

https://github.com/go-gst/go-gst

から、/home/tomoi/go/srcで、 git clone https://github.com/go-gst/go-gst をして、/home/tomoi/go/src/go-gst を作って、

に張ってあったプログラムを、main.goでセーブしたのち、

go run main.go videotestsrc ! glimagesink

で、

と、

が、表われることを確認。

なにがどうなっているのかは、サッパリ分からないが、とりあえず、GoからGstreamerが動いたことは確認できた。

以上

なんか、サラっと書くと自分でも腹たつなぁ。10時間以上はかかったんだけどなぁ

2024,江端さんの技術メモ

Windows10に、GStreamerの1.24をインストール(フルインストールを選ぶこと)をしたのですが、定番の、

$ gst-launch-1.0.exe videotestsrc ! autovideosink
Use Windows high-resolution clock, precision: 1 ms
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Got context from element 'autovideosink0': gst.d3d11.device.handle=context, device=(GstD3D11Device)"
\(GstD3D11Device\)\ d3d11device2", adapter=(uint)0, adapter-luid=(gint64)41376, device-id=(uint)1042
, vendor-id=(uint)32902, hardware=(boolean)true, description=(string)"Intel\(R\)\ HD\ Graphics\ 4600
";
ERROR: from element /GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0/GstD3D11VideoSink:autovid
eosink0-actual-sink-d3d11video: Cannot create converter
Additional debug info:
Failed to prepare d3d11window
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
ERROR: from element /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0: Internal data stream error
.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3177): gst_base_src_loop (): /GstPipeline:pipeline0/GstVideoTestSrc:vi
deotestsrc0:
streaming stopped, reason error (-5)
ERROR: pipeline doesn't want to preroll.
Freeing pipeline ...

となります。別のWindows BOXでも、先日も経験して、青ざめていました。

結果として、

$ gst-launch-1.0 videotestsrc ! glimagesink

とすれば動きます。

autovideosinkが動かん、っていうのは、結局分かっていませんが、これは困りものです。

以下自分用メモ

-UDP通信の実験

-受信側

-gst-launch-1.0 videotestsrc ! x264enc ! rtph264pay ! udpsink host=192.168.101.10 port=38089
(ローカルの場合、host=127.0.0.1とする.  host=localhost は動かない)

-送信側

-gst-launch-1.0 udpsrc port=38089 caps="application/x-rtp,media=video,encoding-name=H264,payload=96" ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! glimagesink

-

-SRT通信の実験

-受信側

-gst-launch-1.0 srtsrc uri="srt://0.0.0.0:38089?mode=listener" keep-listening=true ! tsdemux ! h264parse ! avdec_h264 ! videoconvert ! glimagesink sync=false

-送信側

-gst-launch-1.0 rtspsrc location=rtsp://cam:Cam12345@192.168.0.10/Src/MediaInput/stream_1 latency=0 ! rtph264depay ! avdec_h264 ! videoconvert ! videoscale ! video/x-raw,width=640,height=360 ! videorate ! video/x-raw,framerate=5/1 ! x264enc speed-preset=ultrafast tune=zerolatency key-int-max=1 ! mpegtsmux ! srtserversink uri = \"srt://192.168.101.10:38089\" latency=500

2022/12,江端さんの技術メモ

自分の環境で作ったpostgresqlのDBを、先方にわざわざ作ってもらうのは申し訳ないので、丸ごとコピーして送付する方法

環境はこんな感じ

[192.168.0.23 の中に作ったDockerのPostgresqlのDBを起動]

中身は、

C:\Users\ebata>psql -U postgres -h 192.168.0.23 -p 15432
Password for user postgres:
psql (13.4, server 12.5 (Debian 12.5-1.pgdg100+1))
Type "help" for help.
postgres=# \l
                                 List of databases
   Name    |  Owner   | Encoding |  Collate   |   Ctype    |   Access privileges
-----------+----------+----------+------------+------------+-----------------------
 agent_db  | postgres | UTF8     | en_US.utf8 | en_US.utf8 |
 kitaya_db | postgres | UTF8     | en_US.utf8 | en_US.utf8 |
 postgres  | postgres | UTF8     | en_US.utf8 | en_US.utf8 |
 template0 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
           |          |          |            |            | postgres=CTc/postgres
(5 rows)

[192.168.0.8(localhost)に入っている psqlクライアント一式]

【PostgreSQL】Windows に psql コマンドだけをインストールする手順

で、

C:\Users\ebata>pg_dump -U postgres -h 192.168.0.23 -p 15432 kitaya_db > kitaya_db.sql
Password:

C:\Users\ebata>pg_dump -U postgres -h 192.168.0.23 -p 15432 agent_db > agent_db.sql
Password:

で完了

あとは、kitaya_db.sql と agent_db.sqlを先方に送って、

バスが宇都宮ライトレールの上を驀進している ―― 宇都宮ライトレールの利用を拒否させるような、ダイクストラをどうやって作ろうか

の最後の2行10行を参考に、DBを作って貰えばOK

以上

2024,江端さんの技術メモ

dockerは、どのOS環境でも動くを唄っていますが、基本的に、わたしは、どんなパッケージであろうとも、「これ」を信じていません。

とくに時系列方向については、全く信用していません。

ともあれ、ノートPCにtomioka_dbをdocker-compose.ymlで再構築した時、以下の部分の変更が必要でしたので、逐次メモしていきます。

#version: '3.9'
services:
  db:
    build:
      context: .
    environment:
      POSTGRES_PASSWORD: password
      POSTGRES_DB: tomioka_db
    ports:
      - "15432:5432"
    volumes:
      - ./tomioka_db:/tomioka_db
      - db-data:/var/lib/postgresql/data
  osm2pgsql:
    # image: openfirmware/osm2pgsql:latest
    image: osmtw/osm2pgsql:latest  # イメージ名を変更
    environment:
      PG_PORT_5432_TCP_ADDR: db
      PG_PORT_5432_TCP_PORT: 5432
      PG_ENV_OSM_DB: tomioka_db
      PG_ENV_OSM_USER: postgres
      PG_ENV_POSTGRES_PASSWORD: password
    volumes:
      - ./tomioka_db:/tomioka_db
volumes:
  db-data:

 

2024,江端さんの忘備録

私は今でも、Meadow3を使っています。

I still use Meadow3.

Meadow3とは、Windowsに特化したemacsのことです。

Meadow3 is a Windows-specific emacs.

WindowsNT 4.0より前から使っていますが、今も使い続けています。

I have been using it since before Windows NT 4.0 and continue to use it.

なぜか ―― 動くからです。

Why -- because it works.

現在、Windows11上でも動き続けています。

Currently, it continues to run on Windows 11.

vscodeのemacsキーバインドマッピング 諦めました。

-----

動き続けている限り、使わない理由はありません。

There is no reason not to use it as long as it keeps moving.

.emacsをメンテナンスする気力もありませんので、キーバインドも、当時から固定のままです。

I don't have the energy to maintain .emacs, so key bindings have remained fixed since that time.

もはやMeadow3は、私の体の一部といっても過言ではありません。

It is no exaggeration to say that Meadow3 is now a part of my body.

-----

Meadowが、バージョンアップしたWindowsOSで動かなくなった時に、私の中でも何かが終わるような気がしています。

I feel that something will end for me when Meadow stops working with the upgraded Windows OS.

―― と言いながら、次女のPCにMeadow3をインストールして、今、それで、この文章を書いています。

-- but I installed Meadow3 on my second daughter's PC and am now writing this text with it.

あと、次女のノートPCに大量に貼ってあるステッカーが、ちょっとアバンギャルドで、このPCを学会会場に持ち込む勇気が出ませんでした。

Also, the large number of stickers on my second daughter's laptop was a bit avant-garde, and I could not find the courage to bring this computer to the conference venue.

という訳で、こんなの購入して、ノートPCに貼りつけていました。

So I bought one like this and stuck it on my laptop.

返却時に、元に戻して返すつもりですが。

I intend to return it to its original state when I return it.

2024,江端さんの技術メモ

gnuplotで
0.98, 0.40, 0.30
0.98, 0.41, 0.30
0.97, 0.42, 0.30
0.96, 0.42, 0.30
0.98, 0.42, 0.31
0.98, 0.41, 0.31
のようにx,y,z座標で記載された、cluster1.csvの内容を、Gnuplotで表示するコマンドを教えて下さい。

ChatGPT
ChatGPT
以下は、cluster1.csv の内容を Gnuplot で表示するためのコマンドです。まず、CSVファイルの内容を正しく読み込むためのスクリプトを作成し、その後に3Dプロットを行います。

cluster1.csv の内容が次のようになっていると仮定します:
コードをコピーする
0.98, 0.40, 0.30
0.98, 0.41, 0.30
0.97, 0.42, 0.30
0.96, 0.42, 0.30
0.98, 0.42, 0.31
0.98, 0.41, 0.31
Gnuplot を使用してこのデータをプロットするためのスクリプトを作成します。以下はそのスクリプトです:
gnuplot
コードをコピーする
set datafile separator ","
set title "Cluster 1 Data"
set xlabel "X-axis"
set ylabel "Y-axis"
set zlabel "Z-axis"
set xrange [0:1]
set yrange [0:1]
set zrange [0:1]
set ticslevel 0
splot 'cluster1.csv' using 1:2:3 with points pt 7 ps 1 lc rgb "blue" title 'Cluster 1'

複数個出すのであれば、こんな感じ
splot 'cluster1.csv' using 1:2:3 with points pt 7 ps 1 lc rgb "blue" title 'Cluster 1', 'cluster2.csv' using 1:2:3 with points pt 7 ps 1 lc rgb "red" title 'Cluster 2', 'cluster3.csv' using 1:2:3 with points pt 7 ps 1 lc rgb "yellow" title 'Cluster 3'

splot 'cluster1.csv' using 1:2:3 with points pt 7 ps 2 lc rgb "blue" title 'Cluster 1', 'cluster2.csv' using 1:2:3 with points pt 7 ps 2 lc rgb "red" title 'Cluster 2', 'cluster3.csv' using 1:2:3 with points pt 7 ps 2 lc rgb "yellow" title 'Cluster 3', 'cluster4.csv' using 1:2:3 with points pt 7 ps 2 lc rgb "green" title 'Cluster 4', 'cluster5.csv' using 1:2:3 with points pt 7 ps 2 lc rgb "cyan" title 'Cluster 5', 'cluster6.csv' using 1:2:3 with points pt 7 ps 2 lc rgb "magenta" title 'Cluster 6', 'cluster7.csv' using 1:2:3 with points pt 7 ps 2 lc rgb "orange" title 'Cluster 7'

このスクリプトを Gnuplot に読み込むことで、3Dプロットが作成されます。具体的な手順は以下の通りです。

Gnuplot を起動します。
上記のスクリプトをコマンドラインに入力するか、ファイルに保存して load コマンドで読み込みます。
例えば、スクリプトを plot_cluster1.gnuplot というファイルに保存した場合:

sh
コードをコピーする
gnuplot> load 'plot_cluster1.gnuplot'
これで、cluster1.csv の内容が3Dプロットとして表示されます。プロットのポイントの形状や色、サイズは必要に応じて調整できます。

2023,江端さんの技術メモ

DockerのSQL-DBが死んだら、と、考えるだけで恐怖なので、 8TBのHDDの方にDockerの構築環境まるごとコピーして、そこに、Dockerのイメージも放り込んでおくことにした。

Step 1 Docker Desktopを立ち上げて、"tomioka"をアクティベートにする

Step 2 "docker ps" で起動状態を確認する

Step 3 "$ docker commit tomioka-db-1 tomioka_db_backup"をする
ちなみに実施するディレクトリはどこでもいい。tomioka_db_backupはファイルではないので。

Step.4 "$ docker images"をして、作成を確認する

イメージができているのを確認する。

Step.5 C:\の直下に、DockerBackupsという名前のディレクトリはすでに掘られているので、

Step.6 Command.com(他のシェルではダメみたい)"$ docker save -o C:\DockerBackups\tomioka_db_backup.tar tomioka_db_backup" を実施する

で、これを、F:\backup\tomoi\tomiokaに移動しておく。
こっちで纏めて管理しておく。

で、同じことを、person_trip1(×person_trip)でも行う(以下省略)

 

=======

 

私、DockerでDBの大量生産をやっているのですが、このDockerを起動させるPCが不具合のような兆候を見せて、今年最大の「真っ青」な状態になりました。

2T程度のHDDを購入して、Dockerコンテナのバックアップしておかなければ、ここ1年の研究が吹き飛ぶと実感しました。

とりあえず、逃し方のメモを取っておきます。

Step 1 Docker Desktopを立ち上げて、"kitaya"をアクティベートにする

Step 2 "docker ps" で起動状態を確認する

Step 3 "$ docker commit kitaya-db-1 kitaya_db_backup"をする
ちなみに実施するディレクトリはどこでもいい。kitaya_db_backupはファイルではないので。

Step.4 "$ docker images"をして、作成を確認する

イメージができているのを確認する。

Step.5 C:\の直下に、DockerBackupsという名前のディレクトリを掘っておく。

Step.6 "$ docker save -o C:\DockerBackups\kitaya_db_backup.tar kitaya_db_backup" を実施する

というファイルができる。

Step.7 "docker rmi kitaya-db-1_backup" でイメージを消去する(しなくてもいいが)。無駄なリソースを削除するためである。

ちなみに、kitaya_db_backup.tarも、サイズがバカでかいので、外部HDDなどに逃しておく方が良いと思う。

 


ちなみに、(試していないが)リストアはこんな感じになる(らしい)

docker load -i C:\DockerBackups\kitaya_backup.tar


ところで、Amazonで購入した2TのHDDが、まるで使えんので、返品することになりました。

この"評価1"て何だ?

私は、これを注文したハズなんだが? (だれが評価1、評価者2の商品なんぞ買うか)

なんか、やられたのかなぁ。腹立つなぁ。返品できるだけマシだが。

2024,江端さんの技術メモ

User
You
type LocInfo struct { Lon float64 Lat float64 Source int } という型があり、 route, dis := getDijkstraPath(db_agent_od, LocInfo{Source: 432}, LocInfo{Source: 1070}) のように LocInfo{Source: 432} を使いたいのですが、423,が変数aに入っている場合は、どのように取り扱えば良いでしょうか
ChatGPT
ChatGPT

変数aにLocInfo型の値が入っていて、その中のSourceフィールドの値を使いたい場合、以下のようにすれば良いでしょう:

// 変数aがLocInfo型であると仮定する
var a LocInfo

// aのSourceフィールドの値を使ってgetDijkstraPath関数を呼び出す
route, dis := getDijkstraPath(db_agent_od, LocInfo{Source: a.Source}, LocInfo{Source: 1070})

これにより、変数aのSourceフィールドの値がLocInfo構造体のインスタンスを作成する際に使用され、その値がgetDijkstraPath関数に渡されます。