2台がそれぞれ引込線に侵入します。

Each two train enter service line.

import jarray

import jmri


class A_2dai(jmri.jmrit.automat.AbstractAutomaton) :


    def init(self):

        self.Sensor9 = sensors.provideSensor("9")

        self.Sensor8 = sensors.provideSensor("8")

        self.Sensor7 = sensors.provideSensor("7")

        self.Sensor6 = sensors.provideSensor("6")

        self.Sensor5 = sensors.provideSensor("5")

        self.Sensor4 = sensors.provideSensor("4")

        self.Sensor3 = sensors.provideSensor("3")

        self.Sensor2 = sensors.provideSensor("2")

        self.Sensor1 = sensors.provideSensor("1")

        self.throttle = self.getThrottle(3, True)  # address 3

        self.t2 = turnouts. provideTurnout("2") # point address 2

        self.t1 = turnouts. provideTurnout("1") # point address 1

       

        if (self.throttle == None) :

            print "Couldn't assign throttle!"

        return


    def handle(self):

        self.throttle = self.getThrottle(3, True)  # address 3

        self.t1.state = CLOSED # point straight

        self.waitMsec(500)

        self.t2.state = THROWN # point curve

        self.waitMsec(1000)


        self.throttle = self.getThrottle(3, True)  # address 3

        self.throttle.setIsForward(False)

        self.throttle.speedSetting = 0.27


        self.waitSensorActive(self.Sensor6)

        self.waitMsec(1000)

        self.t1.state = THROWN # point curve

        self.waitMsec(500)

           

        self.throttle = self.getThrottle(5, True)  # address 5

        self.throttle.setIsForward(True)

        self.throttle.speedSetting = 0.24


        self.waitMsec(300)

        self.throttle = self.getThrottle(3, True)  # address 3

        self.waitSensorActive(self.Sensor9)

        self.t2.state = CLOSED # point straight

        self.waitMsec(500)


        self.throttle = self.getThrottle(3, True)  # address 3

        self.throttle.speedSetting = 0


        self.throttle = self.getThrottle(5, True)  # address 5

        self.waitSensorActive(self.Sensor6)

        self.throttle.speedSetting = 0.20

        self.waitMsec(100)

       

        self.t1.state = THROWN # point curve

        self.waitMsec(500)

        self.t2.state = THROWN # point curve

        self.waitMsec(500)

       

        self.throttle = self.getThrottle(3, True)  # address 3

        self.throttle.setIsForward(True)

        self.throttle.speedSetting = 0.27


        self.waitMsec(500)

        self.throttle = self.getThrottle(5, True)  # address 5

        self.waitSensorActive(self.Sensor7)

        self.waitMsec(100)


        self.throttle = self.getThrottle(5, True)  # address 5

        self.throttle.speedSetting = 0


        self.waitMsec(500)

           

        self.t1.state = CLOSED # point straight

        self.waitMsec(500)

           

        self.throttle = self.getThrottle(3, True)  # address 3

        self.waitSensorActive(self.Sensor2)


        self.throttle = self.getThrottle(3, True)  # address 3

        self.throttle.speedSetting = 0.20


        self.waitMsec(500)

        self.t1.state = THROWN # point curve

        self.waitMsec(500)

        self.t2.state = THROWN # point curve

        self.waitMsec(500)


        self.throttle = self.getThrottle(5, True)  # address 5

        self.throttle.setIsForward(False)

        self.throttle.speedSetting = 0.26


        self.throttle = self.getThrottle(5, True)  # address 5

        self.waitSensorActive(self.Sensor8)

        self.throttle.speedSetting = 0.24

        self.waitMsec(100)


        self.throttle = self.getThrottle(5, True)  # address 5

        self.waitSensorActive(self.Sensor9)

        self.t2.state = CLOSED # point straight

        self.waitMsec(500)


        self.throttle = self.getThrottle(5, True)  # address 5

        self.throttle.speedSetting = 0


        self.waitMsec(500)

        self.t1.state = CLOSED # point straight

        self.waitMsec(500)


        self.throttle = self.getThrottle(3, True)  # address 3

        self.throttle.speedSetting = 0.27


        self.throttle = self.getThrottle(3, True)  # address 3

        self.waitSensorActive(self.Sensor6)

        self.t2.state = THROWN # point curve

        self.waitMsec(500)


        self.throttle = self.getThrottle(5, True)  # address 5

        self.throttle.setIsForward(True)

        self.throttle.speedSetting = 0.24


        self.waitMsec(500)

        self.throttle = self.getThrottle(3, True)  # address 3

        self.waitSensorActive(self.Sensor1)

        self.waitMsec(300)


        self.throttle = self.getThrottle(3, True)  # address 3

        self.throttle.speedSetting = 0


        self.waitMsec(300)   

        self.t1.state = THROWN # point curve

        self.waitMsec(500)


        self.throttle = self.getThrottle(5, True)  # address 5

        self.waitSensorActive(self.Sensor6)

        self.waitMsec(100)


        self.throttle = self.getThrottle(5, True)  # address 5

        self.throttle.speedSetting = 0.20

        self.waitMsec(100)

        self.throttle = self.getThrottle(5, True)  # address 5

        self.throttle.speedSetting = 0.20

        self.waitMsec(100)

        self.throttle = self.getThrottle(5, True)  # address 5

        self.throttle.speedSetting = 0.20

        self.waitMsec(100)


        self.throttle = self.getThrottle(5, True)  # address 5

        self.waitSensorActive(self.Sensor7)

        self.waitMsec(300)


        self.throttle = self.getThrottle(5, True)  # address 5

        self.throttle.speedSetting = 0

        self.waitMsec(100)

        self.throttle = self.getThrottle(5, True)  # address 5

        self.throttle.speedSetting = 0

        self.waitMsec(100)

        self.throttle = self.getThrottle(5, True)  # address 5

        self.throttle.speedSetting = 0

        self.waitMsec(100)


        self.waitMsec(1000)


    return 1# to continue



    self.t1.state = THROWN # point curve

    self.t1.state = CLOSED # point straight

           

    self.t2.state = THROWN # point curve

    self.t2.state = CLOSED # point straight

           


# create one of these

a = A_2dai()


# set the name

a.setName("2dai script")


# and start it running

a.start()



Ver 3.8 は、また調べていきます。

2台とも引込線へ侵入するように動かしてみました。

あと少しだけ雰囲気を出すために、情景を入れてみました。

スクリプトは、以下のとおりです。

正面衝突しないように、引込線へ侵入させます。

最後に元の場所で停止します。

最後に05番の車両を止めるために、速度を0にする命令を3回入れています。

実際に動かしたところ、そこの部分が速度0にならずに素通りしてしまったことがあったからです。

かっこ悪いのですが、、、 このようにしています。

あと今回ですが、動作が安定しないことからJMRIを最新版に更新してみました。


Ver 2.10 → Ver 3.8


ところが、更新してスクリプトを実行しても動いてくれません。。

いろいろ試したところ、スクリプト実行後にスロットルで一度各車両番号を「セット」し、そのあとで「ディスパッチ」を押すとうまく動作しだしました。

最新版のJMRIでは、車両番号の機器による取得・開放が変わった(より厳密になった?)ということかも知れません。

LocoNet監視の画面も変わっていました。

以前より見やすくなったようです。