예제 #1
0
 public PineCog(PineDevice device, CogBytecode bytecode, int period)
     : base(device)
 {
     this.code = bytecode;
     _scriptName = "userscript";
     Init(device, period, code);
 }
예제 #2
0
 private void Init(PineDevice device, int period, CogBytecode code)
 {
     if (period <= 0)
     {
         period = 1;
     }
     _period = period;
     _output = 0;
     _registers = new double[20];
     _timers = new CogTimer[NumTimers];
     msCode = new MemoryStream(code.CompiledCode);
     codeReader = new BinaryReader(msCode);
 }
예제 #3
0
 /// <summary>
 /// Reassigns the associated bytecode. Use for dev purposes only.
 /// </summary>
 /// <param name="bytecode">The new bytecode to assign to the cog.</param>
 public void Reassign(CogBytecode bytecode)
 {
     codeReader.Dispose();
     msCode.Dispose();
     code = bytecode;
     msCode = new MemoryStream(code.CompiledCode);
     codeReader = new BinaryReader(msCode);
 }