2021/01,江端さんの技術メモ

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: proxyconnect tcp: tls: oversized record received with length 20527.
See 'docker run --help'.

で、5~6日間、苦しめられて、今もまだ完全には解決していないけど、酷いオチだったのでメモを残しておく

環境:  AWS EC2:Ubuntu20.04

状況: この問題、世界中のエンジニアを悩ませているらしい

条件: 個人の環境によって、まったく役に立たない情報であることがある。これはたまたま私(江端)の環境で上手くいっただけのものである(故に、私に質問しても無駄である)

助けて頂いた資料:  Proxy環境でdockerを外に繋ぐ方法 

修正前:

/etc/systemd/system/docker.service.d/http-proxy.conf を力づくで作った(最初はなかった(みたい))。

[Service]
Environment="HTTP_PROXY=http://12.34.56.789:8080/" "HTTPS_PROXY=https://12.34.56.789:8080" "NO_PROXY=localhost,127.0.0.1,.12.34.56.789"

修正後:

[Service]
Environment="HTTP_PROXY=http://12.34.56.789:8080/" "HTTPS_PROXY=http://12.34.56.789:8080" "NO_PROXY=localhost,127.0.0.1,.12.34.56.789"

(なんのことはない、HTTPS_PROXY の "https:"→"http:" としただけ。ただし、これは、個々の環境に依存する問題だと思う)

ちなみに私のところでは徒労だった(と思われる)作業:

$ host registry-1.docker.io
registry-1.docker.io has address 52.72.232.213
registry-1.docker.io has address 54.85.56.253
registry-1.docker.io has address 54.236.165.68
registry-1.docker.io has address 3.211.199.249
registry-1.docker.io has address 18.213.137.78
registry-1.docker.io has address 18.232.227.119
registry-1.docker.io has address 52.20.56.50
registry-1.docker.io has address 52.54.232.21

と調べた後で、/etc/hostsに書き込んだ

127.0.0.1 localhost
23.22.155.84 registry-1.docker.io
34.195.246.183 registry-1.docker.io
35.174.73.84 registry-1.docker.io
52.5.11.128 registry-1.docker.io
52.20.56.50 registry-1.docker.io
52.54.232.21 registry-1.docker.io
107.23.149.57 registry-1.docker.io
18.232.227.119 registry-1.docker.io

これ↓もダメだった

$ docker run hello-world --dns 12.34.56.789:8080/

これ↓もダメだった

export http="http://proxy server : port 番号"
export https="https://proxy server : port 番号"
export ftp="ftp://proxy server : port 番号

現状、未解決な問題:

"E: Unable to locate package docker-engine"

以上

2021/01,江端さんの技術メモ

背景はこちら。

https://wp2.kobore.net/%e6%9c%aa%e5%88%86%e9%a1%9e/post-2080/

会社の方に教えて貰ったのがこちら

curlコマンドにてproxy設定

を参考にしながら、手抜き(taro:passwordを省略)で、

$ curl kobore.net -x http:192.168.1.1:8080

としてみたが、通った。

現在は、~/.curlrc に

proxy=http:192.168.1.1:8080

と書き込んで使用中。

 

キーワード: curl proxy

 

 

2021/01,江端さんの忘備録

(昨日の続きです)

(Continuation from yesterday)

新型コロナ感染のリスクは、量子論を持ち出すまでもなく、中学校で学んだ(ことになっているはず)の確率論で計算ができます。

The risk of new coronary infections can be calculated using probability theory, which you learned in middle school (or should have), without having to bring up quantum theory.

会食の人数による、感染確率の変動の計算方法は、こちらにも記載しています。

How to calculate the variation in the probability of infection depending on the number of people at a dinner can be found here.

そもそも、

To begin with.

■昼のランチが安全で、夜の会食が危険

- Lunch is safe, dinner is dangerous.

とか、

or

■緊急事態宣言前なら安全で、宣言後なら危険

- Safe before a state of emergency is declared, dangerous after.

とか、

―― なんの冗談だ、それ?

"What a joke, that? "

と思われるようなことを信じていた人がいる(らしい)、という事実に、私は心底驚いています(*)。

I was really surprised to find out that there were people who believed in such things (*).

(*)新型コロナウイルス感染症対策担当大臣が「昼間でも感染リスクは変わりません。夜だけでなく昼の外出も控えてください」との緊急メッセージを出した

(*)The Minister in charge of countermeasures against the new coronavirus infection has issued an urgent message saying, "The risk of infection remains the same even during the daytime. Please refrain from going out not only at night but also during the day.

-----

私のメッセージは、一貫して同じです。

My message has been consistently the same.

『外食しても良い。深夜まで酒を飲んでもいい。一晩中語っていても、騒いでいても一向に構わん ――

"It's okay to eat out. You can drink until midnight. You can stay up all night talking, making noise, it doesn't matter.

ただし、それを一人でやれ』

However, do it alone."

これだけです。

That's all.

一人の状態で、ウイルス感染させることなんか、神様にだってできません。

Even God can't infect you with a virus when you are alone.

-----

時代は、「Boys, Be ぼっち」

The time has come to "Boys, Be Alone"!

です。

======

少年よ、孤立を抱け。

Boys be alone!

しかし、独善を求める孤立であってはならない。

Be alone not for your egoism

自己満を満たす孤立であってはならない。

not for your self-satisfaction

他人を批判するという浮ついたものを求める孤立であってはならない

not for that evanescent thing which men call criticism for others.

人間としてあるべき全ての物を求める孤立を抱きたまえ

Be alone for the attainment of all that a man ought to be.

======

上記が、何のパロディであるか分からない人は、スルーして下さい。

If you don't know what the above is a parody of, please go through it.

2021/01,江端さんの忘備録

「シュレーディンガーの猫」について、私は、半端でない時間を費して勉強してきた、という自負があります。

I am proud to say that I have spent a considerable amount of time studying Schrodinger's cat.

そんでもって、多くの人が、勉強前の私と同様に、「シュレーディンガーの猫」の解釈を「知らない」か「誤解している」ということも分かりました。

I also found out that many people either don't "know" or misunderstand the interpretation of "Schrodinger's Cat" as I did before my study.

この話(「シュレーディンガーの猫」)の解説を、家族にしたところ、

When I explained this story ("Schrodinger's Cat") to my family...

次女:「なるほど。『"そういう猫"の存在を"仮定"すると、量子論が理解できる』ということね」

Junior daughter: "I see. "So you're saying that if we 'assume' the existence of such a cat, we can understand quantum theory.

ほら、やっぱり、誤解している。

See, I knew she misunderstood it.

-----

江端:「違う。『"そういう猫"は実在』しているし、『量子状態(例:絶対零度付近)の物質は、すべて"そういう猫"』なんだ」

Ebata: "No, it's not. Such cats do exist, and all matter in the quantum state (e.g., near absolute zero) is such a cat."

という私の言葉に対して、家族の反応は、予想した通りのものでした。

My family's reaction to my words was exactly what I expected.

「半分死んでいて、半分生きている猫」が実在するということを理解しろ、というのが無理なのかもしれません。

Maybe it's impossible for us to understand that "half-dead, half-alive cats" do exist.

実際に、嫁さんも次女も『分からん』の一言で終了しました。

In fact, both my wife and second daughter ended up saying, 'I don't know.

私も、それ以上の説明をしませんでした。

I didn't offer any further explanation either.

少なくとも、5種類の知覚センサしか有さない人間に対して、量子状態を、現時点の地球上の言語で説明するのは不可能だと思っているからです。

This is because I believe that it is impossible to explain quantum states to humans, who only have at least five types of perception sensors, using the current language on earth.

確率を使った数式と数値で、ギリギリ理解可能なレベルになりますが、そもそも、人類は「数字と数式が嫌い」な生き物です。

Quantum theory is just barely understandable with formulas and numbers using probability. However, the human race is a creature that "hates numbers and formulas" to begin with.

-----

今朝、ふと

This morning, I noticed that

―― 今回の新型コロナの感染拡大(爆発)の理由は、「シュレーディンガーの猫」で説明できる

"The reason for the spread (explosion) of this new corona infection can be explained by "Schrodinger's cat""

ことに気がつきました。

「シュレーディンガーのコロナ」

It is "Schrodinger's Corona.

です。

PRC検査の結果が「感染の有無」ではなく「感染の陽性/陰性」という、なんともはっきりしない物言いで語られるのは、

The reason why the results of the PRC test are referred to in such an unclear manner as "positive/negative for infection" rather than "presence of infection" is as follows.

「半分感染していて、半分感染していない私」

The "half-infected, half-uninfected me" is real.

が、現実に存在しているからです。

つまり、感染の有無は、発病するまで確定しないものであり、発病までの間、感染は確率的に、しかも、年齢や環境や体調や行動によって、常に変動しつづけるものなのです。

In other words, the presence or absence of infection is not determined until the onset of the disease, and until the onset of the disease, infection is probabilistic and constantly changing depending on age, environment, physical condition, and behavior.

と、ここで思い出したのですが、

And here I remembered...

「量子論から見たコロナ感染」については、すでに、「轢断のシバタ」医師が論じておられます。

"Dr. Shibata of the Run Over" has already discussed "Corona infection from the viewpoint of quantum theory".

(続く)

(To be continued)

2021/01,江端さんの忘備録

(昨日の続きです)

(Continuation from yesterday)

それはさておき。

Aside from that.

私(たち?)は、今回の『愚か者として描かれた米国大統領』のおかげで、米国の政治システムを深く知ることができました。

I (we?) thanks to "The U.S. President Portrayed as a stupid", I was able to learn more about the U.S. political system.

特に、米国の二大政党である民主党と共和党について、その違いだけでなく、その政党の支持者の「生々しい顔」を見ることもできました。

In particular, I was able to see not only the differences between the two major political parties in the U.S., the Democratic Party and the Republican Party, but also the "real faces" of the supporters of those parties.

同時に、私は、「自分自身にいい聞かせておかなければならないことがある」とも思いました。

At the same time, I thought to myself, "There are things I need to tell myself.

それは、例えば、

For examples,

■イスラム過激派と、イスラム教の教えを、混同してはならないこと

- Do not confuse Islamic extremism with Islam.

あるいは、

or

■天皇陛下と、天皇制を、混同してはならないこと

- Do not confuse His Majesty the Emperor with the emperor system.

と同様に、

■現職大統領の人格と、米国大統領制度を、混同してはならないこと

- Do not confuse the personality of the current president with the U.S. presidential system.

であり、なにより、

and above all,

■米国共和党の党員と、連邦議会議事堂を襲撃したデモ参加者を、混同してはならないこと

- Do not confuse members of the U.S. Republican Party with the protesters who attacked the U.S. Capitol.

です。

この混同によって、私も含めた多くの人が、政治やマスコミの情宣に「つけこまれやすい」ことを知っているからです。

I know that this confusion makes it easy for many people, including myself, to be "taken advantage of" by political and media sentiments.

私、経験者です。

I'm experienced.

「混同する側」としてだけでなく、「混同される側」としても、です。

not only as a "confuser" but also as a "confused".

-----

ところで ―― 我が国でも「国会襲撃事件」があったのをご存知ですか?

By the way -- did you know that there was an attack on the Diet building in Japan?

日米安全保障条約調印阻止闘争、いわゆる、安保闘争です。

It was the struggle to prevent the signing of the Japan-U.S. Security Treaty, the so-called Security Treaty Struggle.

1959年11月27日、全国で200万人がデモや集会に参加し、全学連主流派を中心とした国会襲撃事件が起こりました。

On November 27, 1959, two million people participated in demonstrations and rallies across the country, and the attacj on the Diet took place, led by the mainstream faction of the All-Japan Federation of Student Self-Government Associations.

ここで私が問題としているのは、

The problem I have here is that my feeling of

―― 「国会襲撃」ではなく、「国会突入」という言葉を使いたい

"I want not to use the term "attack on the Diet" but "rush on the Diet."

という、私の気持ちです。

もちろん、当時は、政府与党は勿論、日本共産党すらも、彼らを『左翼暴力集団』とテッレルを貼って、非難(蔑視)していました。

Of course, at that time, not only the ruling party but even the Japanese Communist Party condemned (scorned) them, labeling them as a "leftist violent group.

つまり、私は、当時の全共闘(学生を中心とした反安保運動)について比較的良く知っていて(まだ、生まれていませんが)、国会突入した当時の学生達に「共感」できるのです。

That is to say, I know relatively well (though I was not born yet) about the Zenkyoto (student-centered anti-Apartheid movement) of that time, and I can sympathize with the students of that time who rushed into the Diet.

-----

つまり、私は、「全共闘の国会突入」には共感して、「連邦議会議事堂を襲撃したデモ参加者」を非難しているのです。

In other words, I sympathize with the "students who rushed into the parliament" and condemn the "protesters who attacked the U.S. Capitol".

この両者に違いはあるのでしょうか?

Is there a difference between the two?

もちろん、あるでしょう。

Of course there is.

それでも、私の「エンジニアリングアプローチ」の視点から見れば ―― 私は、自分がとても「不公平な人間である」と感じてしまうのです。

Still, from the perspective of my "engineering approach" -- I feel that I am being very "unfair".

2021/01,江端さんの技術メモ

/etc/apt/apt.confに

1
2
3
Acquire::http::Proxy "http://proxy server : port 番号";
Acquire::https::Proxy "https://proxy server : port 番号";
("s"をつけるとマズい時もある)
Acquire::ftp::Proxy "ftp://proxy server : port 番号";

を追記してみたら、apt-get update できるようになった。pingなどは通る。

curl http://sample.com では、コマンドも戻ってこない。

 

明日は、

(1)シェルを変えてみる。

1
2
3
export http="http://proxy server : port 番号"
export https="https://proxy server : port 番号"
export ftp="ftp://proxy server : port 番号
1
printenv | grep -i proxy

/etc/apt/sources.listの内容を確認する

 

https://qiita.com/tkyonezu/items/0f6da57eb2d823d2611d から

3. スクリプトでのインストール

+ sh -c
echo
"deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial edge"
> /etc/apt/sources.list.d/docker.list

 

https://askubuntu.com/questions/1230189/how-to-install-docker-community-on-ubuntu-20-04-lts

2021/01,江端さんの技術メモ

// simple_csv_1_socket.go
// 2021/01/14
// 対向サーバは、server22-1.go(変更なしで使えた)
// simple_cvs.go の場合、数万のエージェント全部とwebsocket通信することになるため、
// サーバとの通信用のソケットを1つに限定して、この問題を回避した。
// ただエージェントは、従来通り、全部の数(数万から十万くらい?)作成したがそれでも。動いている。
// golang まじ凄い
// 変更点は、mainルーチンで、エージェント用のソケットを作って、goroutineでエージェント用のスレッド作る時に、それを渡している点
// あと通信は、送信→受信で1セットになるように、ミューテックスロックで競合回避を行った点(まあ通信が混乱するのを回避するため)
// 普通なら、これで相当の実行速度の低下が発生するはずなんだけど、体感的には遅くなかった。
// 現状の問題点は、chromoの方が先に落ちる、ということかな。まあ、数万のオブジェクトを1秒以内に動かされたら、chromoも文句の一つも言いたかろう。
// この問題は、メモリが潤沢に搭載されているPCでなら回避できるような気がするので、当面は放置することにする
// simple_csv_1_socket.go

// 2021/01/14
// simple_cvs.go の場合、数万のエージェント全部とwebsocket通信することになるため、
// サーバとの通信用のソケットを1つに限定して、この問題を回避した。
// ただエージェントは、従来通り、全部の数(数万から十万くらい?)作成したがそれでも。動いている。
// golang まじ凄い
// 変更点は、mainルーチンで、エージェント用のソケットを作って、goroutineでエージェント用のスレッド作る時に、それを渡している点
// あと通信は、送信→受信で1セットになるように、ミューテックスロックで競合回避を行った点(まあ通信が混乱するのを回避するため)
// 普通なら、これで相当の実行速度の低下が発生するはずなんだけど、体感的には遅くなかった。
// 現状の問題点は、chromoの方が先に落ちる、ということかな。まあ、数万のオブジェクトを1秒以内に動かされたら、chromoも文句の一つも言いたかろう。
// この問題は、メモリが潤沢に搭載されているPCでなら回避できるような気がするので、当面は放置することにする

package main

import (
	"encoding/csv"
	"flag"
	"fmt"
	"log"
	"math"
	"net/url"
	"os"
	"strconv"
	"sync"
	"time"

	"github.com/gorilla/websocket"
)

// GetLoc GetLoc
type GetLoc struct {
	ID  int     `json:"id"`
	Lat float64 `json:"lat"`
	Lng float64 `json:"lng"`
	//Address string  `json:"address"`
}

// 構造体の作り方
type unmTbl struct {
	uniName string // User Name: Example  6ca....
	objType string // "Bus" or "User"
	simNum  int
	pmNum   int
	lon     float64
	lat     float64
}

var list = make([]unmTbl, 0)                                           // 構造体の動的リスト宣言
var addr = flag.String("addr", "0.0.0.0:8080", "http service address") // テスト

func main() {
	file, err := os.Open("1.csv")
	if err != nil {
		panic(err)
	}
	defer file.Close()

	var wg sync.WaitGroup

	reader := csv.NewReader(file)
	var line []string

	// サーバとのコネクションを1つに統一

	//var upgrader = websocket.Upgrader{} // use default options
	_ = websocket.Upgrader{} // use default options

	// rand.Seed(time.Now().UnixNano())

	flag.Parse()
	log.SetFlags(0)
	u := url.URL{Scheme: "ws", Host: *addr, Path: "/echo2"}
	//log.Printf("connecting to %s", u.String())

	c, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
	if err != nil {
		log.Fatal("dial:", err)
	}

	for {

		time.Sleep(time.Millisecond * 1) // 0.001秒休む

		line, err = reader.Read()
		if err != nil {
			break
		}

		uniName := line[0]
		//fmt.Printf("%s\n", uniName)

		objType := line[9]
		//fmt.Printf("%s\n", objType)

		lon, _ := strconv.ParseFloat(line[8], 64)
		//fmt.Printf("%f\n", lon)

		lat, _ := strconv.ParseFloat(line[7], 64)
		//fmt.Printf("%f\n", lat)

		// 特定範囲に限定する
		//if lon > 139.744330 && lon < 139.866586 && lat > 35.574777 && lat < 35.694479 {
		if lon > 139.7583407156985 && lon < 139.81403350119444 && lat > 35.62835195825786 && lat < 35.66678018870369 {

			flag := 0

			for i := range list {
				if i != 0 && list[i].uniName == uniName { // 同一IDを発見したら
					list[i].lon = lon // 新しい経度情報の更新
					list[i].lat = lat // 新しい緯度情報の更新

					flag = 1
					break
				}
			}

			uniNum := len(list)

			if flag == 0 { // 新しいIDを発見した場合
				wg.Add(1) // goルーチンを実行する関数分だけAddする
				go movingObject(uniNum, uniName, objType, lon, lat, &wg, c)
			}
		}

	}
}

var mutex sync.Mutex

func movingObject(uniNum int, uniName string, objType string, lon float64, lat float64, wg *sync.WaitGroup, c *websocket.Conn) {

	fmt.Printf("start movingObject\n")

	defer wg.Done() // WaitGroupを最後に完了しないといけない。

	defer c.Close()

	// リストを作る前にテストをする
	//fmt.Printf("%s\n", objType)
	//fmt.Printf("%d\n", uniNum)
	//fmt.Printf("%f\n", lon)
	//fmt.Printf("%f\n", lat)

	ut := unmTbl{} // 構造体変数の初期化
	ut.uniName = uniName
	ut.objType = objType
	ut.simNum = uniNum
	ut.lat = lat
	ut.lon = lon

	gl := new(GetLoc)
	gl.ID = 0
	gl.Lat = ut.lat
	gl.Lng = ut.lon

	mutex.Lock()           // 送受信時にミューテックスロックしないと
	err := c.WriteJSON(gl) // PruneMobile登録用送信
	if err != nil {
		log.Println("write1:", err)
	}

	gl2 := new(GetLoc) // PruneMobile登録確認用受信
	err = c.ReadJSON(gl2)
	mutex.Unlock()

	ut.pmNum = gl2.ID // PrumeMobileから提供される番号

	//fmt.Printf("ut.objType=%v\n", ut.objType)
	list = append(list, ut) // 構造体をリストに動的追加

	// ここからは更新用のループ
	for {
		time.Sleep(time.Millisecond * 100) // 0.1秒休む

		// 前回との座標に差が認められれば、移動させる
		if math.Abs(list[uniNum].lat-gl.Lat) > 0.000000001 || math.Abs(list[uniNum].lon-gl.Lng) > 0.000000001 {

			fmt.Print("MOVING!\n")
			gl.Lat = list[uniNum].lat
			gl.Lng = list[uniNum].lon
			gl.ID = gl2.ID

			// 座標の送信

			mutex.Lock()
			err = c.WriteJSON(gl)
			if err != nil {
				log.Println("write2:", err)
			}

			// 応答受信
			gl3 := new(GetLoc)
			err = c.ReadJSON(gl3)
			mutex.Unlock()

		}

	}

}

2021/01,江端さんの忘備録

(昨日の続きです)

(Continuation from yesterday)

私の知る限り、このような描かれ方は、「ゴルゴ13」では非常に珍しいのです。

As far as I know, this kind of depiction is very rare in "Golgo 13".

「ゴルゴ13」の中で登場する米国大統領は、社会通念上の正義に反することを行ったとしても、そのストーリーの中に、それなりの正当化されうるだけの理由があることになっています。

The U.S. presidents in "Golgo 13" have been supposed to have a justifiable reason in their story, even if they have to do something that is against socially accepted justice.

ところが、現職の米国大統領だけは、このような「知性」を感じさせる描写が見あたらないのです。

The current president of the United States, however, is the only one who has not been portrayed as having this kind of "intelligence.

粗野で、頭が悪く、自我をコントロールできない ―― はっきり言って「三下のギャング」と同程度の取り扱いをされているように感じました。

He is crude, dim-witted, and unable to control his ego -- to put it bluntly, I felt like he has been treated on par with a "low-life gangster".

私が、今回たまたま、そのようなストーリーを読んだだけかもしれません。

Maybe I just happened to read such a story this time.

それでも、私が知る限り『愚か者として描かれた米国大統領』の話を思い出すことができません。

Still, as far as I know, I can't recall a story about a 'US President portrayed as a stupid'.

-----

「ゴルゴ13」は、連載期間50年間、シリーズ総発行部数は2億8000万部という、我が国で最も著名なコンテンツの一つです。

Golgo 13" is one of the most famous contents in Japan with 50 years of serialization and 280 million copies sold.

ここまで支持を受けてきた理由として、「ゴルゴ13」が、我が国の読者の想いや感情に、丁寧に寄り沿ってきたからだ、と思っています。

I believe that the reason why "Golgo 13" has received so much support is because it has carefully followed the thoughts and feelings of readers in our country.

ここから導かれる私の仮説は、

My hypothesis, derived from the above, is that

―― 「我が国の国民の現職米国大統領に対する評価」は、「ゴルゴ13の中で描かれている内容と同じ」

"Our people's assessment of the current U.S. president is about the same as that portrayed in Golgo 13.

です。

(続く)

(To be continued)

2021/01,江端さんの技術メモ

// simple_csv.go

package main

import (
	"encoding/csv"
	"flag"
	"fmt"
	"log"
	"math"
	"net/url"
	"os"
	"strconv"
	"sync"
	"time"

	"github.com/gorilla/websocket"
)

// GetLoc GetLoc
type GetLoc struct {
	ID  int     `json:"id"`
	Lat float64 `json:"lat"`
	Lng float64 `json:"lng"`
	//Address string  `json:"address"`
}

// 構造体の作り方
type unmTbl struct {
	uniName string // User Name: Example  6ca90e
	objType string // "Bus" or "User"
	simNum  int
	pmNum   int
	lon     float64
	lat     float64
}

var list = make([]unmTbl, 0)                                           // 構造体の動的リスト宣言
var addr = flag.String("addr", "0.0.0.0:8080", "http service address") // テスト

func main() {
	file, err := os.Open("1.csv")
	if err != nil {
		panic(err)
	}
	defer file.Close()

	var wg sync.WaitGroup

	reader := csv.NewReader(file)
	var line []string

	for {

		time.Sleep(time.Millisecond * 1) // 0.001秒休む

		line, err = reader.Read()
		if err != nil {
			break
		}

		uniName := line[0]
		//fmt.Printf("%s\n", uniName)

		objType := line[9]
		//fmt.Printf("%s\n", objType)

		lon, _ := strconv.ParseFloat(line[8], 64)
		//fmt.Printf("%f\n", lon)

		lat, _ := strconv.ParseFloat(line[7], 64)
		//fmt.Printf("%f\n", lat)

		// 特定範囲に限定する
		//if lon > 139.744330 && lon < 139.866586 && lat > 35.574777 && lat < 35.694479 {
		if lon > 139.7583407156985 && lon < 139.81403350119444 && lat > 35.62835195825786 && lat < 35.66678018870369 {

			flag := 0

			for i := range list {
				if i != 0 && list[i].uniName == uniName { // 同一IDを発見したら
					list[i].lon = lon // 新しい経度情報の更新
					list[i].lat = lat // 新しい緯度情報の更新

					flag = 1
					break
				}
			}

			uniNum := len(list)

			if flag == 0 { // 新しいIDを発見した場合
				wg.Add(1) // goルーチンを実行する関数分だけAddする
				go movingObject(uniNum, uniName, objType, lon, lat, &wg)
			}
		}

	}
}

func movingObject(uniNum int, uniName string, objType string, lon float64, lat float64, wg *sync.WaitGroup) {

	fmt.Printf("start movingObject\n")

	defer wg.Done() // WaitGroupを最後に完了しないといけない。

	//var upgrader = websocket.Upgrader{} // use default options
	_ = websocket.Upgrader{} // use default options

	// rand.Seed(time.Now().UnixNano())

	flag.Parse()
	log.SetFlags(0)
	u := url.URL{Scheme: "ws", Host: *addr, Path: "/echo2"}
	//log.Printf("connecting to %s", u.String())

	c, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
	if err != nil {
		log.Fatal("dial:", err)
	}
	defer c.Close()

	ut := unmTbl{} // 構造体変数の初期化
	ut.uniName = uniName
	ut.objType = objType
	ut.simNum = uniNum
	ut.lat = lat
	ut.lon = lon

	gl := new(GetLoc)
	gl.ID = 0
	gl.Lat = ut.lat
	gl.Lng = ut.lon

	err = c.WriteJSON(gl) // PruneMobile登録用送信
	if err != nil {
		log.Println("write:", err)
	}

	gl2 := new(GetLoc) // PruneMobile登録確認用受信
	err = c.ReadJSON(gl2)

	ut.pmNum = gl2.ID // PrumeMobileから提供される番号

	//fmt.Printf("ut.objType=%v\n", ut.objType)
	list = append(list, ut) // 構造体をリストに動的追加

	// ここからは更新用のループ
	for {
		time.Sleep(time.Millisecond * 100) // 0.1秒休む

		// 前回との座標に差が認められれば、移動させる
		if math.Abs(list[uniNum].lat-gl.Lat) > 0.000000001 || math.Abs(list[uniNum].lon-gl.Lng) > 0.000000001 {

			fmt.Print("MOVING!\n")
			gl.Lat = list[uniNum].lat
			gl.Lng = list[uniNum].lon
			gl.ID = gl2.ID

			// 座標の送信
			err = c.WriteJSON(gl)
			if err != nil {
				log.Println("write:", err)
			}

			// 応答受信
			gl3 := new(GetLoc)
			err = c.ReadJSON(gl3)
		}

	}

}