Last active
August 29, 2015 14:04
-
-
Save yume190/8368a9847d4455a2af8d to your computer and use it in GitHub Desktop.
test1234
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class packetFactory{ | |
class func sender<T where T:Constructible, T:Packable>(command:devicePacketHeader.commandType,content:T) -> devicePacketSender<T>?{ | |
var header:devicePacketHeader | |
switch (command,content){ | |
case (.ASK_DEVICE,let TAsk) where TAsk is devicePacketNil: | |
header = devicePacketHeader(deviceID: .UNKNOWN, command: command, len:Int16(sizeof(T))) | |
// case (_,let TNil) where TNil is devicePacketNil: | |
// fallthrough | |
case (.ASK_VERSION,_),(.RADIO,_),(.READ_PARAMETERS,_),(.DEFAULT_PARAMETER,_) where content is devicePacketNil: | |
fallthrough | |
case (.SAVE_PARAMETERS, _) where content is devicePacketParameters: | |
fallthrough | |
case (.UPDATE_PARAMETER, _) where content is devicePacketParameters: | |
header = devicePacketHeader(deviceID: .APSM, command: command, len:Int16(sizeof(T))) | |
default: | |
return nil | |
} | |
return devicePacketSender(deviceHeader: header, deviceContent: content) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment