Status isn't returning the value created by new. --Tim
On Thursday, March 27, 2014 05:45:08 AM RecentConvert wrote: > It turns out the error wasn't in the code I posted but how it was then > implemented though I still am not sure what is wrong. > > This code works. > type Status AutoBG::Vector{Bool} > AutoCal::Vector{Bool} > FrequencyLock::Vector{Bool} > BinomialFilter::Vector{Bool} > AltMode::Vector{Bool} > GuessLast::Vector{Bool} > PowerNorm::Vector{Bool} > ContRefLock::Vector{Bool} > > AutoSpectSave::Vector{Bool} > PressureLock::Vector{Bool} > #b11::Vector{Bool} > #b12::Vector{Bool} > WriteData::Vector{Bool} > RS232::Vector{Bool} > ElectronicBGSub::Vector{Bool} > #b16::Vector{Bool} > > Valve1::Vector{Bool} > Valve2::Vector{Bool} > Valve3::Vector{Bool} > Valve4::Vector{Bool} > Valve5::Vector{Bool} > Valve6::Vector{Bool} > Valve7::Vector{Bool} > Valve8::Vector{Bool} > > # Constructor for Status type > function Status(vals::Array{Int64}) > l = int64(length(vals)) > > AutoBG = Array(Bool,l) > AutoCal = Array(Bool,l) > FrequencyLock = Array(Bool,l) > BinomialFilter = Array(Bool,l) > AltMode = Array(Bool,l) > GuessLast = Array(Bool,l) > PowerNorm = Array(Bool,l) > ContRefLock = Array(Bool,l) > > AutoSpectSave = Array(Bool,l) > PressureLock = Array(Bool,l) > #b11 = Array(Bool,l) > #b12 = Array(Bool,l) > WriteData = Array(Bool,l) > RS232 = Array(Bool,l) > ElectronicBGSub = Array(Bool,l) > #b16 = Array(Bool,l) > > Valve1 = Array(Bool,l) > Valve2 = Array(Bool,l) > Valve3 = Array(Bool,l) > Valve4 = Array(Bool,l) > Valve5 = Array(Bool,l) > Valve6 = Array(Bool,l) > Valve7 = Array(Bool,l) > Valve8 = Array(Bool,l) > > # Parse Inputs > for i=1:l > # Byte 1 > AutoBG[i] = vals[i] & 2^(1-1) > 0 > AutoCal[i] = vals[i] & 2^(2-1) > 0 > FrequencyLock[i] = vals[i] & 2^(3-1) > 0 > BinomialFilter[i] = vals[i] & 2^(4-1) > 0 > AltMode[i] = vals[i] & 2^(5-1) > 0 > GuessLast[i] = vals[i] & 2^(6-1) > 0 > PowerNorm[i] = vals[i] & 2^(7-1) > 0 > ContRefLock[i] = vals[i] & 2^(8-1) > 0 > > # Byte 2 > AutoSpectSave[i] = vals[i] & 2^(9-1) > 0 > PressureLock[i] = vals[i] & 2^(10-1) > 0 > #b11[i] = vals[i] & 2^(11-1) > 0 > #b12[i] = vals[i] & 2^(12-1) > 0 > WriteData[i] = vals[i] & 2^(13-1) > 0 > RS232[i] = vals[i] & 2^(14-1) > 0 > ElectronicBGSub[i] = vals[i] & 2^(15-1) > 0 > #b16[i] = vals[i] & 2^(16-1) > 0 > > # Byte 3 > Valve1[i] = vals[i] & 2^(17-1) > 0 > Valve2[i] = vals[i] & 2^(18-1) > 0 > Valve3[i] = vals[i] & 2^(19-1) > 0 > Valve4[i] = vals[i] & 2^(20-1) > 0 > Valve5[i] = vals[i] & 2^(21-1) > 0 > Valve6[i] = vals[i] & 2^(22-1) > 0 > Valve7[i] = vals[i] & 2^(23-1) > 0 > Valve8[i] = vals[i] & 2^(24-1) > 0 > end # End of conversion > println("AutoBG Length: " * string(length(AutoBG))) > > #new(AutoBG,AutoCal,FrequencyLock,BinomialFilter,AltMode,GuessLast,PowerNorm > ,ContRefLock,AutoSpectSave,PressureLock,b11,b12,WriteData,RS232,ElectronicBG > Sub,b16,Valve1_temp,Valve2_temp,Valve3_temp,Valve4_temp,Valve5_temp,Valve6_t > emp,Valve7_temp,Valve8_temp) > new(AutoBG,AutoCal,FrequencyLock,BinomialFilter,AltMode,GuessLast,PowerNorm > ,ContRefLock,AutoSpectSave,PressureLock,WriteData,RS232,ElectronicBGSub, > Valve1,Valve2,Valve3,Valve4,Valve5,Valve6,Valve7,Valve8) > end # End of constructor > end # End of type > > > y = [1:10] > x = Status(y) > > > # Properties > println("Type: " * string(typeof(x))) > println(x.AutoBG) > > I'm trying to build a module for functions related to an instrument we have > and the Status type was placed in there. The module looks like this. > module Aerodyne > > export Status, aerodyne > > type Status > AutoBG::Vector{Bool} > AutoCal::Vector{Bool} > FrequencyLock::Vector{Bool} > BinomialFilter::Vector{Bool} > AltMode::Vector{Bool} > GuessLast::Vector{Bool} > PowerNorm::Vector{Bool} > ContRefLock::Vector{Bool} > > AutoSpectSave::Vector{Bool} > PressureLock::Vector{Bool} > #b11::Vector{Bool} > #b12::Vector{Bool} > WriteData::Vector{Bool} > RS232::Vector{Bool} > ElectronicBGSub::Vector{Bool} > #b16::Vector{Bool} > > Valve1::Vector{Bool} > Valve2::Vector{Bool} > Valve3::Vector{Bool} > Valve4::Vector{Bool} > Valve5::Vector{Bool} > Valve6::Vector{Bool} > Valve7::Vector{Bool} > Valve8::Vector{Bool} > > # Constructor for Status type > function Status(vals::Array{Int64}) > l = int64(length(vals)) > > AutoBG = Array(Bool,l) > AutoCal = Array(Bool,l) > FrequencyLock = Array(Bool,l) > BinomialFilter = Array(Bool,l) > AltMode = Array(Bool,l) > GuessLast = Array(Bool,l) > PowerNorm = Array(Bool,l) > ContRefLock = Array(Bool,l) > > AutoSpectSave = Array(Bool,l) > PressureLock = Array(Bool,l) > #b11 = Array(Bool,l) > #b12 = Array(Bool,l) > WriteData = Array(Bool,l) > RS232 = Array(Bool,l) > ElectronicBGSub = Array(Bool,l) > #b16 = Array(Bool,l) > > Valve1 = Array(Bool,l) > Valve2 = Array(Bool,l) > Valve3 = Array(Bool,l) > Valve4 = Array(Bool,l) > Valve5 = Array(Bool,l) > Valve6 = Array(Bool,l) > Valve7 = Array(Bool,l) > Valve8 = Array(Bool,l) > > # Parse Inputs > for i=1:l > # Byte 1 > AutoBG[i] = vals[i] & 2^(1-1) > 0 > AutoCal[i] = vals[i] & 2^(2-1) > 0 > FrequencyLock[i] = vals[i] & 2^(3-1) > 0 > BinomialFilter[i] = vals[i] & 2^(4-1) > 0 > AltMode[i] = vals[i] & 2^(5-1) > 0 > GuessLast[i] = vals[i] & 2^(6-1) > 0 > PowerNorm[i] = vals[i] & 2^(7-1) > 0 > ContRefLock[i] = vals[i] & 2^(8-1) > 0 > > # Byte 2 > AutoSpectSave[i] = vals[i] & 2^(9-1) > 0 > PressureLock[i] = vals[i] & 2^(10-1) > 0 > #b11[i] = vals[i] & 2^(11-1) > 0 > #b12[i] = vals[i] & 2^(12-1) > 0 > WriteData[i] = vals[i] & 2^(13-1) > 0 > RS232[i] = vals[i] & 2^(14-1) > 0 > ElectronicBGSub[i] = vals[i] & 2^(15-1) > 0 > #b16[i] = vals[i] & 2^(16-1) > 0 > > # Byte 3 > Valve1[i] = vals[i] & 2^(17-1) > 0 > Valve2[i] = vals[i] & 2^(18-1) > 0 > Valve3[i] = vals[i] & 2^(19-1) > 0 > Valve4[i] = vals[i] & 2^(20-1) > 0 > Valve5[i] = vals[i] & 2^(21-1) > 0 > Valve6[i] = vals[i] & 2^(22-1) > 0 > Valve7[i] = vals[i] & 2^(23-1) > 0 > Valve8[i] = vals[i] & 2^(24-1) > 0 > end # End of conversion > println("Valve1: " * string(typeof(Valve1))) > println("Valve1 Length: " * string(length(Valve1))) > new(AutoBG,AutoCal,FrequencyLock,BinomialFilter,AltMode,GuessLast, > PowerNorm,ContRefLock,AutoSpectSave,PressureLock,WriteData,RS232, > ElectronicBGSub,Valve1,Valve2,Valve3,Valve4,Valve5,Valve6,Valve7,Valve8) > println("Test3") > end # End of constructor > end # End of type > end # End of module > > > > It's then called in this manner. > using Aerodyne > ... > statuses = Status(vector(Dstc["StatusW"])) > > Dstc is a dataframe. > Dstc["StatusW"] is a DataArray{Int64,1}. > vector(Dstc["StatusW"]) is a Array{Int64,1}. > > Unfortunately statuses still ends up being Nothing (constructor with 1 > method).