/// <summary> /// オーブ内か確認 /// </summary> /// <returns>The between.</returns> /// <param name="targetDegree">Target degree.</param> public bool Between(double targetDegree) { if (fromPlanetNumber == CommonData.ZODIAC_NUMBER_SUN || toPlanetNumber == CommonData.ZODIAC_NUMBER_SUN) { if (Between(targetDegree, aspectDegree - setting.orbs[0][OrbKind.SUN_SOFT_1ST], aspectDegree + setting.orbs[0][OrbKind.SUN_SOFT_1ST])) { softHard = SoftHard.SOFT; return(true); } else if (Between(targetDegree, aspectDegree - setting.orbs[0][OrbKind.SUN_HARD_1ST], aspectDegree + setting.orbs[0][OrbKind.SUN_HARD_1ST])) { softHard = SoftHard.HARD; return(true); } } else if (fromPlanetNumber == CommonData.ZODIAC_NUMBER_MOON || toPlanetNumber == CommonData.ZODIAC_NUMBER_MOON) { if (Between(targetDegree, aspectDegree - setting.orbs[0][OrbKind.MOON_SOFT_1ST], aspectDegree + setting.orbs[0][OrbKind.MOON_SOFT_1ST])) { softHard = SoftHard.SOFT; return(true); } else if (Between(targetDegree, aspectDegree - setting.orbs[0][OrbKind.MOON_HARD_1ST], aspectDegree + setting.orbs[0][OrbKind.MOON_HARD_1ST])) { softHard = SoftHard.HARD; return(true); } } else { if (Between(targetDegree, aspectDegree - setting.orbs[0][OrbKind.OTHER_SOFT_1ST], aspectDegree + setting.orbs[0][OrbKind.OTHER_SOFT_1ST])) { softHard = SoftHard.SOFT; return(true); } else if (Between(targetDegree, aspectDegree - setting.orbs[0][OrbKind.OTHER_HARD_1ST], aspectDegree + setting.orbs[0][OrbKind.OTHER_HARD_1ST])) { softHard = SoftHard.HARD; return(true); } } return(false); }
public static byte[] WriteReg(int deviceIndex, int deviceAddress, int regAddress, SoftHard softHard, byte[] dataToWrite) { if (softHard == SoftHard.OnEasyB_I2C) { Thread.Sleep(30); byte byDevIndex = OnEasyB_I2C.USBIO_OpenDeviceByNumber(OnEasyB_I2C.serialNumber); if (byDevIndex == 0xFF) { return(null); } if (!OnEasyB_I2C.USBIO_I2cSetConfig((byte)deviceIndex, (byte)deviceAddress, Frequency, tmptime)) { return(null); } bool result = false; //if (regAddress <= 0xFF)//use for regAddressWide = false //{ // byte[] cmd = BitConverter.GetBytes(regAddress); // byte cmdLength = 1;// // result = OnEasyB_I2C.USBIO_I2cWrite((byte)deviceIndex, (byte)deviceAddress, cmd, cmdLength, dataToWrite, (ushort)dataToWrite.Length); //} //else //{ byte[] buf = BitConverter.GetBytes(regAddress); byte cmdLength = 2; // byte[] cmd = new byte[2]; cmd[0] = buf[1]; cmd[1] = buf[0]; result = OnEasyB_I2C.USBIO_I2cWrite((byte)deviceIndex, (byte)deviceAddress, cmd, cmdLength, dataToWrite, (ushort)dataToWrite.Length); //} Thread.Sleep(50); byte[] readData = new byte[dataToWrite.Length]; OnEasyB_I2C.USBIO_CloseDevice((byte)deviceIndex); Thread.Sleep(20); if (result == false) { return(null); } //return ReadReg(deviceIndex, deviceAddress, regAddress, softHard, dataToWrite.Length); return(readData); } bool regAddressWide = false; if (regAddress > 0xFF) { regAddressWide = true; } else { regAddressWide = false; } return(ReadWriteReg(deviceIndex, deviceAddress, regAddress, regAddressWide, softHard, ReadWrite.Write, (CFKType)0, dataToWrite)); }
public static byte[] ReadWriteReg(int deviceIndex, int deviceAddress, int regAddress, bool regAddressWide, SoftHard softHard, ReadWrite operate, CFKType cfk, byte[] buffer) { if (softHard == SoftHard.SerialPort) { if (operate == ReadWrite.Read) { return(SNOEC_USB_I2C.USB_I2C.ReadPort(deviceIndex, deviceAddress, regAddress, regAddressWide, buffer)); } else { return(SNOEC_USB_I2C.USB_I2C.WritePort(deviceIndex, deviceAddress, regAddress, regAddressWide, buffer)); } } byte[] arr = new byte[buffer.Length + 8]; arr[0] = regAddressWide ? (byte)1 : (byte)0; arr[1] = (byte)(regAddress / 256); arr[2] = (byte)softHard; arr[3] = (byte)operate; arr[4] = (byte)deviceAddress; arr[5] = (byte)(regAddress & 0xFF); arr[6] = (byte)buffer.Length; arr[7] = (byte)cfk; buffer.CopyTo(arr, 8); semaphore.WaitOne(); OpenDevice(deviceIndex); CH375SetTimeout((byte)deviceIndex, 100, 100); bool b = CH375WriteData(deviceIndex, arr); System.Threading.Thread.Sleep(50); byte[] arrRead = CH375ReadData(deviceIndex, buffer.Length); CloseDevice(deviceIndex); semaphore.Release(); // System.Threading.Thread.Sleep(50); // System.Threading.Thread.Sleep(100); return(arrRead); }
public static byte[] WriteReg(int deviceIndex, int deviceAddress, int regAddress, SoftHard softHard, byte[] dataToWrite) { return(ReadWriteReg(deviceIndex, deviceAddress, regAddress, false, softHard, ReadWrite.Write, (CFKType)0, dataToWrite)); }
public static byte[] ReadReg(int deviceIndex, int deviceAddress, int regAddress, SoftHard softHard, int readLength) { return(ReadWriteReg(deviceIndex, deviceAddress, regAddress, false, softHard, ReadWrite.Read, (CFKType)0, new byte[readLength])); }