Lab. of Voynich Code
2020年アルゼンチン皆既日食のたくらみ
SDKでNikon Z6を外部制御-3
2019.12.14 Open /2020/01/27Update

制御のフローチャート

〇時刻で制御を行う
 第2接触の14秒前以内でなければ、食の最大(Cmax)の前2分毎に1EV間隔で4枚(1/2000, 1/1000, 1/500, 1/250, 1/125, 1/60秒)を撮像する。
 第2接触の14秒前以内であれば、0.3秒ビープ音を鳴らして21秒待つ。この間20秒連写が音信号で起動するPICで実行される。
 その後第2接触から第3接触の14秒前までならば多段階撮像(1.5EV間隔10段)を1周(8秒)行う。
 第3接触の14秒前以内であればビープ音を0.3秒鳴らし、21秒待つ。この間、20秒連写が音と信号で起動するPICで実行される。
 食の最大から2分経つごとに1EV間隔で4枚(1/2000, 1/1000, 1/500, 1/250, 1/125, 1/60秒)を撮像する。

問題点と対策


          



   1:  //

   2:  // This work is licensed under a Creative Commons Attribution 3.0 Unported License.

   3:  // Thomas Dideriksen (thomas@dideriksen.com)

   4:  //

   5:  // Modified by M_shi@Lab. of Eclips Manuscript

   6:  // http://horukeu.web.fc2.com/Exp/2020Trial/Index.html

   7:  //

   8:   

   9:  using System;

  10:  using System.Collections.Generic;

  11:  using System.Linq;

  12:  using System.Text;

  13:  using System.Threading;

  14:  using System.IO;

  15:  using Nikon;

  16:   

  17:  //

  18:  // This demo shows how to perform continuous capture and store the images to disk

  19:  //

  20:   

  21:  namespace demo_continuouscapture

  22:  {

  23:      class DemoContinuousCapture

  24:      {

  25:          int _captureCount = 0;

  26:   

  27:          NikonDevice _device;

  28:          AutoResetEvent _waitForDevice = new AutoResetEvent(false);

  29:          AutoResetEvent _waitForCaptureComplete = new AutoResetEvent(false);

  30:   

  31:          int C2hour = 20;

  32:          int C2min = 10;

  33:          int C2sec = 0;

  34:   

  35:          int Cmaxhour = 20   ;

  36:          int Cmaxmin = 11;

  37:          int Cmaxsec = 0;

  38:   

  39:          int C3hour = 20;

  40:          int C3min = 12;

  41:          int C3sec = 0;

  42:   

  43:   publicvoid Run()

  44:          {

  45:              int C2 = C2hour * 3600 + C2min * 60 + C2sec;

  46:              int Cmax = Cmaxhour * 3600 + Cmaxmin * 60 + Cmaxsec;

  47:              int C3 = C3hour * 3600 + C3min * 60 + C3sec;

  48:   

  49:              try

  50:              {

  51:                  // Create manager object - make sure you have the correct MD3 file for your Nikon DSLR

  52:                  //Type00##.md3の##が機種によって違う

  53:                  NikonManager manager = new NikonManager("Type0024.md3");

  54:   

  55:                  // Listen for the 'DeviceAdded' event

  56:                  manager.DeviceAdded += manager_DeviceAdded;

  57:   

  58:                  // Wait for a device to arrive

  59:                  _waitForDevice.WaitOne();

  60:   

  61:                  while (true)

  62:                  {

  63:                      int NowTime = Now();

  64:   

  65:                      //Console.WriteLine(NowTime);

  66:                      //Console.ReadLine();

  67:   

  68:                      if (NowTime < Cmax - 119)

  69:                      {

  70:                          if ((Cmax - NowTime) % 120 == 0)

  71:                          {

  72:                              //1EV間隔6段ブラケティング撮像

  73:                              _ = Interval_Capture();

  74:                          }

  75:                      }

  76:   elseif (NowTime > Cmax - 119 && NowTime == C2 - 10)

  77:                      {

  78:                          //連写指示のビープ音&連写終了待ち

  79:                          Console.Beep(5000, 300);

  80:                          System.Threading.Thread.Sleep(21000);

  81:   

  82:                          //多段階AEブラケティング

  83:                          _ = AEBlacket_Capture();

  84:   

  85:                          //連写指示のビープ音&連写終了待ち

  86:                          Console.Beep(5000, 300);

  87:                          System.Threading.Thread.Sleep(21000);

  88:                      }

  89:   elseif (NowTime > C3 + 5)

  90:                      {

  91:                          if ((NowTime - Cmax) % 120 == 0)

  92:                          {

  93:                              //1EV間隔6段ブラケティング撮像

  94:                              _ = Interval_Capture();

  95:                          }

  96:                      }

  97:   

  98:                      System.Threading.Thread.Sleep(200);

  99:   

 100:   

 101:                  }

 102:   

 103:                  // Shutdown

 104:                  manager.Shutdown();

 105:              }

 106:              catch (NikonException ex)

 107:              {

 108:                  Console.WriteLine(ex.Message);

 109:              }

 110:          }

 111:   staticint Now()

 112:          {

 113:              DateTime dt = DateTime.Now;

 114:              int hour = dt.Hour;

 115:              int minute = dt.Minute;

 116:              int second = dt.Second;

 117:              int x = hour * 3600 + minute * 60 + second;

 118:              return x;

 119:          }

 120:   

 121:          //2分毎の1EV6段階撮像

 122:   publicint Interval_Capture()

 123:          {

 124:   

 125:                  //Set Sensitivity 140

 126:                  NikonEnum ISOSens = _device.GetEnum(eNkMAIDCapability.kNkMAIDCapability_Sensitivity);

 127:                  ISOSens.Index = 3;

 128:                  _device.SetEnum(eNkMAIDCapability.kNkMAIDCapability_Sensitivity, ISOSens);

 129:   

 130:                  NikonEnum SpeedMode = _device.GetEnum(eNkMAIDCapability.kNkMAIDCapability_ShutterSpeed);

 131:   

 132:                  //1/2000-1/60sec 1EV間隔6段AEブラケティング撮影

 133:                  int i = 0;

 134:                  for (i = 35; i >= 25; i = i - 2)

 135:                  {

 136:                      SpeedMode.Index = i;

 137:                      _device.SetEnum(eNkMAIDCapability.kNkMAIDCapability_ShutterSpeed, SpeedMode);

 138:   

 139:                      // Set number of continuous captures - in this case we want 1

 140:                      _device.SetUnsigned(eNkMAIDCapability.kNkMAIDCapability_ContinuousShootingNum, 1);

 141:   

 142:                      // Hook up capture events

 143:                      _device.ImageReady += _device_ImageReady;

 144:                      _device.CaptureComplete += _device_CaptureComplete;

 145:   

 146:                      // Capture

 147:                      _device.Capture();

 148:   

 149:                      // Wait for the capture to complete

 150:                      _waitForCaptureComplete.WaitOne();

 151:                  }

 152:   

 153:                  //set SS 1/500

 154:                  SpeedMode.Index = 31;

 155:                  _device.SetEnum(eNkMAIDCapability.kNkMAIDCapability_ShutterSpeed, SpeedMode);

 156:   

 157:   

 158:              return 0;

 159:          }

 160:   

 161:          //多段階AEブラケティング撮像

 162:   publicint AEBlacket_Capture()

 163:          {

 164:   

 165:              // Set shooting mode to 'continuous, highspeed'

 166:              NikonEnum shootingMode = _device.GetEnum(eNkMAIDCapability.kNkMAIDCapability_ShootingMode);

 167:              shootingMode.Index = (int)eNkMAIDShootingMode.kNkMAIDShootingMode_CH;

 168:              _device.SetEnum(eNkMAIDCapability.kNkMAIDCapability_ShootingMode, shootingMode);

 169:   

 170:              //Set Sesitivity 1100

 171:              NikonEnum ISOSens = _device.GetEnum(eNkMAIDCapability.kNkMAIDCapability_Sensitivity);

 172:              ISOSens.Index = 9;

 173:              _device.SetEnum(eNkMAIDCapability.kNkMAIDCapability_Sensitivity, ISOSens);

 174:   

 175:              int i = 0;

 176:   

 177:              NikonEnum SpeedMode = _device.GetEnum(eNkMAIDCapability.kNkMAIDCapability_ShutterSpeed);

 178:   

 179:              //

 180:              while (true)

 181:              {

 182:                  int C3 = C3hour * 3600 + C3min * 60 + C3sec;

 183:   

 184:                  //SS from 1/8000 - 1/2sec, 1.5EV step, 10 shoots, 1 loop 6sec.

 185:                  for (i = 39; i >= 15; i = i - 3)

 186:                  {

 187:                      SpeedMode.Index = i;

 188:                      _device.SetEnum(eNkMAIDCapability.kNkMAIDCapability_ShutterSpeed, SpeedMode);

 189:   

 190:                      // Set number of continuous captures - in this case we want 1

 191:                      _device.SetUnsigned(eNkMAIDCapability.kNkMAIDCapability_ContinuousShootingNum, 1);

 192:   

 193:                      // Hook up capture events

 194:                      _device.ImageReady += _device_ImageReady;

 195:                      _device.CaptureComplete += _device_CaptureComplete;

 196:   

 197:                      // Capture

 198:                      _device.Capture();

 199:   

 200:                      // Wait for the capture to complete

 201:                      _waitForCaptureComplete.WaitOne();

 202:                  }

 203:                  //時刻をピックアップして次の連写に行けるかを判断、14秒以内ならC3用連写

 204:                  int NowTime = Now();

 205:                  if (NowTime >= C3 - 16)

 206:                  {

 207:                      break;

 208:                  }

 209:                  //SS from 1/8000 - 1.5sec, 1.5EV step, 11 shoots, 1 loop 8sec.

 210:                  for (i = 39; i >= 12; i = i - 3)

 211:                      {

 212:                          SpeedMode.Index = i;

 213:                          _device.SetEnum(eNkMAIDCapability.kNkMAIDCapability_ShutterSpeed, SpeedMode);

 214:   

 215:                          // Set number of continuous captures - in this case we want 1

 216:                          _device.SetUnsigned(eNkMAIDCapability.kNkMAIDCapability_ContinuousShootingNum, 1);

 217:   

 218:                          // Hook up capture events

 219:                          _device.ImageReady += _device_ImageReady;

 220:                          _device.CaptureComplete += _device_CaptureComplete;

 221:   

 222:                          // Capture

 223:                          _device.Capture();

 224:   

 225:                          // Wait for the capture to complete

 226:                          _waitForCaptureComplete.WaitOne();

 227:                      }

 228:                  //時刻をピックアップしてC3の連写に行けるかを判断、14秒以内ならC3用連写

 229:                  NowTime = Now();

 230:                  if (NowTime >= C3 - 14)

 231:                  {

 232:                      break;

 233:                  }

 234:              }

 235:   

 236:              //ダイヤモンドリング撮像の下準備

 237:              //set SS 1/500

 238:              SpeedMode.Index = 31;

 239:              _device.SetEnum(eNkMAIDCapability.kNkMAIDCapability_ShutterSpeed, SpeedMode);

 240:   

 241:              //Set Sensitivity 140

 242:              ISOSens.Index = 3;

 243:              _device.SetEnum(eNkMAIDCapability.kNkMAIDCapability_Sensitivity, ISOSens);

 244:   

 245:              // Hook up capture events

 246:              _device.ImageReady += _device_ImageReady;

 247:              //_device.CaptureComplete += _device_CaptureComplete;

 248:   

 249:              // Capture

 250:              _device.Capture();

 251:   

 252:              // Wait for the capture to complete

 253:              _waitForCaptureComplete.WaitOne();

 254:   

 255:   

 256:              return 0;

 257:          }

 258:   

 259:   

 260:          void _device_ImageReady(NikonDevice sender, NikonImage image)

 261:          {

 262:              // Save captured image to disk

 263:              string filename = "image" + _captureCount.ToString() + ((image.Type == NikonImageType.Jpeg) ? ".jpg" : ".nef");

 264:              _captureCount++;

 265:   

 266:              using (FileStream s = new FileStream(filename, FileMode.Create, FileAccess.Write))

 267:              {

 268:                  s.Write(image.Buffer, 0, image.Buffer.Length);

 269:              }

 270:          }

 271:   

 272:          void _device_CaptureComplete(NikonDevice sender, int data)

 273:          {

 274:              // Signal the the capture completed

 275:              _waitForCaptureComplete.Set();

 276:          }

 277:   

 278:          void manager_DeviceAdded(NikonManager sender, NikonDevice device)

 279:          {

 280:              if (_device == null)

 281:              {

 282:                  // Save device

 283:                  _device = device;

 284:   

 285:                  // Signal that we got a device

 286:                  _waitForDevice.Set();

 287:              }

 288:          }

 289:      }

 290:   

 291:      class Program

 292:      {

 293:   staticvoid Main(string[] args)

 294:          {

 295:              DemoContinuousCapture demo = new DemoContinuousCapture();

 296:              demo.Run();

 297:          }

 298:      }

 299:  }

inserted by FC2 system