public MachineTask(WorkPath shape, KnifeToolInstance drill) { Tool = drill; Path = shape; Layout = new PathLayout(); CompleteOrByPath = true; }
private void lwFiles_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) { if (e.OriginalSource is TextBlock) { if (((TextBlock)e.OriginalSource).Background == Brushes.Red) { ((TextBlock)e.OriginalSource).Background = Brushes.Transparent; HitTestResult result = VisualTreeHelper.HitTest(lwFiles, e.GetPosition(lwFiles)); ListBoxItem lbi = Statik.FindParent <ListBoxItem>(result.VisualHit); WKeyVal vl = lbi.DataContext as WKeyVal; WorkPath wp = ((WorkPath)comboBox1.SelectedItem); panel1.removeBack(vl.Val.ToString()); } else { ((TextBlock)e.OriginalSource).Background = Brushes.Red; HitTestResult result = VisualTreeHelper.HitTest(lwFiles, e.GetPosition(lwFiles)); ListBoxItem lbi = Statik.FindParent <ListBoxItem>(result.VisualHit); WKeyVal vl = lbi.DataContext as WKeyVal; WorkPath wp = ((WorkPath)comboBox1.SelectedItem); panel1.addBack(vl.Val.ToString(), wp.OverrideOldTexture); } } e.Handled = true; }
void newProj_Click(object sender, EventArgs e) { WorkPath path = new WorkPath(null, null, inkCol.Ink); path.createProj(); //path.Go(); }
private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e) { lwFiles.Items.Clear(); WorkPath wp = ((WorkPath)comboBox1.SelectedItem); foreach (var item in Directory.GetFiles(wp.Path).OrderBy(x => x)) { FileInfo fi = new FileInfo(item); lwFiles.Items.Add(new WKeyVal(fi.Name, fi.FullName)); } }
void BeginAddTask(WorkPath ps) { propertyBrowser.Children.Clear(); PathUIDef UIDef = m_UIFactory.FindUI(ps.GetType()); if (UIDef != null) { m_ModelView.BeginAddTask(UIDef.CreateShapeModel(ps)); CreateTaskUI(UIDef.CreateUI(), UIDef.Title, UIMode.UM_Add); } }
/// <summary> /// 基本配置 /// </summary> private pub() { LoadConfig(this); if (WorkPath == null) { WorkPath = fastCSharp.pub.ApplicationPath; } else { WorkPath = WorkPath.pathSuffix().fileNameToLower(); } if (CachePath == null || !directory.Create(CachePath = CachePath.pathSuffix().fileNameToLower())) { CachePath = fastCSharp.pub.ApplicationPath; } }
void erRead_Click(object sender, EventArgs e) { WorkPath path = new WorkPath(); List <Pin> errors = new List <Pin>(); errors.AddRange(path.errors("c:\\cats\\error.log")); foreach (Pin datapin in errors) { Console.Write(datapin.PinName + " "); Console.Write(datapin.val2str()); if (datapin.Polarity.Equals(PinPolarity.Ouput)) { Console.Write(" "); Console.Write(datapin.expected2str()); } Console.WriteLine(); } //path.pins2testVectors(errors, "c:\\cats\\error.log"); }
/// <summary> /// HTTP文件请求处理 /// </summary> /// <param name="path">请求路径</param> /// <param name="ifModifiedSince">文件修改时间</param> /// <param name="response">HTTP响应输出</param> /// <param name="isCopyPath">是否复制请求路径</param> /// <returns>文件缓存</returns> protected unsafe FileCache file(byte[] path, SubArray <byte> ifModifiedSince, ref Http.Response response, bool isCopyPath) { string cacheFileName = null; try { if (path.Length != 0 && WorkPath.Length + path.Length <= AutoCSer.IO.File.MaxFullNameLength) { byte[] contentType = null; bool isCompress = true; fixed(byte *pathFixed = path) { byte *pathStart = pathFixed, pathEnd = pathStart + path.Length; if (isFile(pathEnd, ref contentType, ref isCompress) == 0) { if (*pathStart == '/') { ++pathStart; } for (byte *formatStart = pathStart; formatStart != pathEnd; ++formatStart) { if (*formatStart == ':') { response = Http.Response.Blank; return(null); } } int cachePathLength = (int)(pathEnd - pathStart); FileCacheKey cacheKey = new FileCacheKey(pathIdentity, path, (int)(pathStart - pathFixed), cachePathLength); FileCache fileCache = FileCacheQueue.Get(ref cacheKey); if (fileCache == null) { cacheFileName = StringExtension.FastAllocateString(WorkPath.Length + cachePathLength); fixed(char *nameFixed = cacheFileName) { char *write = nameFixed + WorkPath.Length; char directorySeparatorChar = Path.DirectorySeparatorChar; StringExtension.CopyNotNull(WorkPath, nameFixed); for (byte *start = pathStart; start != pathEnd; ++start) { *write++ = *start == '/' ? directorySeparatorChar : (char)*start; } } FileInfo file = new FileInfo(cacheFileName); if (file.Exists) { string fileName = file.FullName; if (fileName.Length > WorkPath.Length && WorkPath.equalCaseNotNull(fileName, WorkPath.Length)) { if (fileName.Length <= AutoCSer.IO.File.MaxFullNameLength && file.Length <= FileCacheQueue.MaxFileSize) { if (FileCacheQueue.Get(ref cacheKey, out fileCache, isCopyPath) != 0) { try { fileCache.LastModified = file.LastWriteTimeUtc.UniversalNewBytes(); int extensionNameLength = (int)(pathEnd - getExtensionNameStart(pathEnd)); SubArray <byte> fileData = readCacheFile(new SubString { String = fileName, Start = fileName.Length - extensionNameLength, Length = extensionNameLength }); FileCacheQueue.Set(ref cacheKey, fileCache, fileCache.Set(ref fileData, contentType, cacheControl, isCompress)); if (ifModifiedSince.Length == fileCache.LastModified.Length) { fixed(byte *ifModifiedSinceFixed = ifModifiedSince.Array) { if (Memory.EqualNotNull(fileCache.LastModified, ifModifiedSinceFixed + ifModifiedSince.Start, ifModifiedSince.Length)) { response = Http.Response.NotChanged304; return(null); } } } } finally { if (fileCache.IsData == 0) { fileCache.PulseAll(); fileCache = null; FileCacheQueue.RemoveOnly(ref cacheKey); } } } } else { if (ifModifiedSince.Length == Date.ToByteLength && Date.UniversalByteEquals(file.LastWriteTimeUtc, ifModifiedSince) == 0) { response = Http.Response.NotChanged304; return(null); } response = Http.Response.Get(); //response.State = Http.ResponseState.Ok200; response.SetBodyFile(file); response.CacheControl = cacheControl; response.ContentType = contentType; response.SetLastModified(file.LastWriteTimeUtc.UniversalNewBytes()); return(null); } } } } return(fileCache); } } } } catch (Exception error) { RegisterServer.TcpServer.Log.Add(AutoCSer.Log.LogType.Error, error, cacheFileName); } return(null); }
/// <summary> /// Main process /// </summary> private static void Process(string[] args) { Console.WriteLine("FOLDER ZIP AND UPLOAD v2.0"); Console.WriteLine("by Daniele Arrighi @ Idioblast. [email protected]"); Console.WriteLine(); Console.WriteLine("Processing..."); //LOG Utilities.WriteToFile(string.Format("{0}: Executing...", DateTime.Now)); /******************** * DEFAULTS VALUES ********************/ //ZIPs Temporary Path string zipDestinationFolder = ConfigurationManager.AppSettings["ZipDestinationFolder"]; if (!zipDestinationFolder.EndsWith("\\")) { zipDestinationFolder += "\\"; } //Configuration File to Load string configurationFile = AppDomain.CurrentDomain.BaseDirectory + "config.xml"; //Verbosity bool verbose = false; /******************** * OVERWRITE DEFAULT VALUES WITH COMMAND ARGUMENTS IF PRESENT ********************/ var options = new Options(); if (Parser.Default.ParseArguments(args, options)) { //Verbosity verbose = options.Verbose; //ZIPs Temporary Path if (!string.IsNullOrEmpty(options.ZipDestinationFolder)) { zipDestinationFolder = options.ZipDestinationFolder; } //Configuration File to Load if (!string.IsNullOrEmpty(options.ConfigFile)) { configurationFile = options.ConfigFile; } //Outputs the encrypted password to save in configuration file. if (!string.IsNullOrEmpty(options.Password)) { Console.WriteLine("Encrypted Password is: {0}", Security.EncryptText(options.Password)); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); return; } } /******************** * CONFIGURATION ********************/ //Checks if configuration files exist if (!File.Exists(configurationFile)) { Utilities.WriteToFile(string.Format("Missing Configuration File At {0}", configurationFile)); Console.WriteLine("Missing Configuration File At {0}", configurationFile); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); return; } //Checks if the Temporary Directory Exist, or create it if (!Directory.Exists(zipDestinationFolder)) { Directory.CreateDirectory(zipDestinationFolder); } //Gets the folders to process from XML file ProcessQueue folderQueue = new ProcessQueue(configurationFile); //Setup Directory Names string nowFileName = DateTime.Now.ToString("yyyyMMdd"); /******************** * PROCESS THE QUEUE ********************/ foreach (QueueItem queue in folderQueue.Queue) { //Extra checks if (!queue.FtpDirectory.EndsWith("/")) { queue.FtpDirectory += "/"; } if (!queue.Directory.EndsWith("\\")) { queue.Directory += "\\"; } //Password check if (String.IsNullOrEmpty(queue.FtpPassword)) { Utilities.WriteToFile("Error. Missing password (Encrypted) for FTP connection"); Console.WriteLine("Error. Missing password (Encrypted) for FTP connection"); continue; } else { try { queue.FtpPassword = Security.DecryptText(queue.FtpPassword); } catch { Utilities.WriteToFile("Error. Wrong password format"); Console.WriteLine("Error. Wrong password format"); continue; } } //ELABORATES ALL THE FOLDERS TO ZIP AND UPLOAD if (queue.ProcessSubDirectories) { DirectoryInfo startingDirectory = new DirectoryInfo(queue.Directory); foreach (var currentDirectory in startingDirectory.GetDirectories()) { if (!queue.IsPathExcluded(currentDirectory.FullName)) { WorkPath w = new WorkPath(); w.FullPath = currentDirectory.FullName; w.FullZipPath = Path.Combine(zipDestinationFolder, currentDirectory.Name + ".zip"); if (queue.AppendDateTime) { w.FullZipPath = Path.Combine(zipDestinationFolder, String.Format("{0:yyyMMddHHmmss}-{1}.zip", DateTime.Now, currentDirectory.Name)); } w.IsZipped = ZipService.ZipFolder(currentDirectory.FullName, w.FullZipPath, queue.ExcludedFolders.ToStringArray(), verbose); w.IsUploaded = false; queue.WorkList.Add(w); } } } else { //IF SHOULD NOT PROCSS SUBDIRS, ZIP THE DIRECTORY DIRECTLY DirectoryInfo currentDirectory = new DirectoryInfo(queue.Directory); if (!queue.IsPathExcluded(currentDirectory.FullName)) { WorkPath w = new WorkPath(); w.FullPath = currentDirectory.FullName; w.FullZipPath = Path.Combine(zipDestinationFolder, currentDirectory.Name + ".zip"); if (queue.AppendDateTime) { w.FullZipPath = Path.Combine(zipDestinationFolder, String.Format("{0:yyyMMddHHmmss}-{1}.zip", DateTime.Now, currentDirectory.Name)); } w.IsZipped = ZipService.ZipFolder(currentDirectory.FullName, w.FullZipPath, queue.ExcludedFolders.ToStringArray(), verbose); w.IsUploaded = false; queue.WorkList.Add(w); } } //FTP UPLOAD ALL ELABORATED FOLDER bool uploadSuccess = FtpService.UploadQueue(queue, queue.FtpDirectory + nowFileName + "/", queue.FtpServer, queue.FtpUser, queue.FtpPassword, verbose); //DELETE OLDER FOLDERS IF REQUIRED //TODO: Use same session in UploadQueue and in CleanOldRemoteFolders if (queue.CleanRemote > 0 && uploadSuccess) { FtpService.CleanOldRemoteFolders(queue.CleanRemote, verbose, queue.FtpDirectory, queue.FtpServer, queue.FtpUser, queue.FtpPassword); } //DELETE ALL CREATED ZIP FILES if (queue.DeleteFilesWhenFinished) { FileService.DeleteFilesInQueue(queue, verbose); } } //LOG Utilities.WriteToFile(String.Format("Zip & Upload routine completed at: {0}\n", DateTime.Now)); //SEND MAIL string subject = String.Format("Zip & Upload routine completed at: {0}", DateTime.Now); //Todo: Send more information in the mail body. MailService.Send("Zip & Upload Executed", subject, verbose); //DONE if (verbose) { Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadLine(); } }
public MachineTask() { Path = new WorkPath(); Layout = new PathLayout(); Id = 0; }
public override WorkPathModel CreateShapeModel(WorkPath ps) { return(new CirclePathModel(ps as CirclePath)); }
public WorkPathModel(WorkPath shape) { Shape = shape; }
/// <summary> /// HTTP文件请求处理 /// </summary> /// <param name="header">请求头部</param> /// <param name="response">HTTP响应输出</param> /// <returns>文件缓存</returns> protected unsafe FileCache file(Http.Header header, ref Http.Response response) { SubArray <byte> path = header.Path; string cacheFileName = null; try { if (path.Length != 0 && WorkPath.Length + path.Length <= AutoCSer.IO.File.MaxFullNameLength) { byte[] contentType = null; bool isCompress = true; fixed(byte *pathFixed = path.GetFixedBuffer()) { byte *pathStart = pathFixed + path.Start, pathEnd = pathStart + path.Length; if (isFile(pathEnd, ref contentType, ref isCompress) == 0) { if (*pathStart == '/') { ++pathStart; } for (byte *formatStart = pathStart; formatStart != pathEnd; ++formatStart) { if (*formatStart == ':') { response = Http.Response.Blank; return(null); } #if !MONO if ((uint)(*formatStart - 'A') < 26) { *formatStart |= 0x20; } #endif } int cachePathLength = (int)(pathEnd - pathStart); FileCacheKey cacheKey = new FileCacheKey(pathIdentity, path.Array, (int)(pathStart - pathFixed), cachePathLength); FileCache fileCache = FileCacheQueue.Get(ref cacheKey); if (fileCache == null) { cacheFileName = StringExtension.FastAllocateString(WorkPath.Length + cachePathLength); fixed(char *nameFixed = cacheFileName) { char *write = nameFixed + WorkPath.Length; char directorySeparatorChar = Path.DirectorySeparatorChar; StringExtension.CopyNotNull(WorkPath, nameFixed); for (byte *start = pathStart; start != pathEnd; ++start) { *write++ = *start == '/' ? directorySeparatorChar : (char)*start; } } FileInfo file = new FileInfo(cacheFileName); bool isFileExists = file.Exists, isCopyPath = true; if (!isFileExists && cacheFileName.IndexOf('%') >= WorkPath.Length) { cacheKey.CopyPath(); isCopyPath = false; string newPath = AutoCSer.Net.Http.Header.UnescapeUtf8(pathStart, cachePathLength, path.Array, (int)(pathStart - pathFixed)); if (Path.DirectorySeparatorChar != '/') { newPath.replaceNotNull('/', Path.DirectorySeparatorChar); } FileInfo newFile = new FileInfo(WorkPath + newPath); if (newFile.Exists) { file = newFile; isFileExists = true; } } if (isFileExists) { string fileName = file.FullName; if (fileName.Length > WorkPath.Length && WorkPath.equalCaseNotNull(fileName, WorkPath.Length)) { if (fileName.Length <= AutoCSer.IO.File.MaxFullNameLength && file.Length <= FileCacheQueue.MaxFileSize) { if (FileCacheQueue.Get(ref cacheKey, out fileCache, isCopyPath) != 0) { try { fileCache.LastModified = file.LastWriteTimeUtc.UniversalNewBytes(); int extensionNameLength = (int)(pathEnd - getExtensionNameStart(pathEnd)); SubArray <byte> fileData = readCacheFile(new SubString { String = fileName, Start = fileName.Length - extensionNameLength, Length = extensionNameLength }); FileCacheQueue.Set(ref cacheKey, fileCache, fileCache.Set(ref fileData, contentType, cacheControl, isCompress)); if ((header.Flag & Http.HeaderFlag.IsSetIfModifiedSince) != 0 && header.IfModifiedSinceIndex.Length == fileCache.LastModified.Length) { if (AutoCSer.Memory.Common.EqualNotNull(fileCache.LastModified, pathFixed + header.Buffer.StartIndex + header.IfModifiedSinceIndex.StartIndex, header.IfModifiedSinceIndex.Length)) { response = Http.Response.NotChanged304; return(null); } } } finally { if (fileCache.IsData == 0) { fileCache.PulseAll(); fileCache = null; FileCacheQueue.RemoveOnly(ref cacheKey); } } } } else { if ((header.Flag & Http.HeaderFlag.IsSetIfModifiedSince) != 0 && header.IfModifiedSinceIndex.Length == Date.ToByteLength && Date.UniversalByteEquals(file.LastWriteTimeUtc, header.IfModifiedSince) == 0) { response = Http.Response.NotChanged304; return(null); } response = Http.Response.Get(); //response.State = Http.ResponseState.Ok200; response.SetBodyFile(file); response.CacheControl = cacheControl; response.ContentType = contentType; response.SetLastModified(file.LastWriteTimeUtc.UniversalNewBytes()); return(null); } } } } return(fileCache); } } } } catch (Exception error) { RegisterServer.TcpServer.Log.Exception(error, cacheFileName, LogLevel.Exception | LogLevel.AutoCSer); } return(null); }
public virtual WorkPathModel CreateShapeModel(WorkPath ps) { return(null); }
void mod2pin2ink_Click(object sender, EventArgs e) { WorkPath path = new WorkPath(); Module mod = new Module("mistaKitties"); List <Pin> inputs = new List <Pin>(); List <Pin> outputs = new List <Pin>(); inputs.Add(new Pin(PinPolarity.Input, "clk", 1)); inputs.Add(new Pin(PinPolarity.Input, "s", 4)); inputs.Add(new Pin(PinPolarity.Input, "b", 1)); /* * int[] insizes = new int[3]; * inputs.Add("clk"); * inputs.Add("s"); * inputs.Add("b"); * insizes[0] = 1; * insizes[1] = 4; * insizes[2] = 1;*/ //List<Pin> outputs = new List<Pin>(); //int[] outsizes = new int[2]; outputs.Add(new Pin(PinPolarity.Ouput, "x", 5)); outputs.Add(new Pin(PinPolarity.Ouput, "y", 1)); //outsizes[0] = 5; //outsizes[1] = 1; mod.addInputs(inputs); mod.addOutputs(outputs); List <Pin> pins = new List <Pin>(); pins.AddRange(path.mod2pin(mod)); Module mod2 = path.pins2mod(pins, "MistaB"); int i = 0; foreach (Pin str in mod2.inputPins) { Console.WriteLine(str.PinName + " " + str.bussize); i++; } i = 0; foreach (Pin str in mod2.outputPins) { Console.WriteLine(str.PinName + " " + str.bussize); i++; } List <Pin> pin2 = new List <Pin>(); foreach (Pin instance in pins) { if (instance.PinName != "clk") { pin2.Add(instance); } } foreach (Pin datapin in pin2) { Console.WriteLine(datapin.PinName + " " + datapin.bussize); } // Console.WriteLine(pin2[0].PinName + " " + pins[0]); // Console.WriteLine(pin2[0].Equals(pins[0])); //Pin dk = new Pin("in", "clk", 1); //pin2.Remove(pin2[0]); //pin2.Add(dk); pin2.Reverse(); Mesh sup = new Mesh(); Mesh sup1 = new Mesh(); Mesh sup2 = new Mesh(); Mesh sup3 = new Mesh(); Mesh sup4 = new Mesh(); List <Mesh> list = new List <Mesh>(); //sup.Name = "clk"; //sup.IOType = WirePolarity.Input; //list.Add(sup); sup1.Name = "s"; sup1.IOType = WirePolarity.Input; sup1.Bussize = 4; list.Add(sup1); sup2.Name = "b"; sup2.Bussize = 1; sup2.IOType = WirePolarity.Input; list.Add(sup2); sup3.Name = "x"; sup3.Bussize = 5; sup3.IOType = WirePolarity.Output; list.Add(sup3); sup4.Name = "y"; sup4.Bussize = 1; sup4.IOType = WirePolarity.Output; list.Add(sup4); List <Pin> pins4 = new List <Pin>(); pins4.AddRange(path.inOutRectify(pin2, list, "c:\\cats\\test.v")); List <List <Pin> > sups = new List <List <Pin> >(); List <List <Pin> > sups3 = new List <List <Pin> >(); sups3.Add(pin2); sups.Add(pins); sups.AddRange(sups3); MessageBox.Show("shows"); foreach (Pin instance in sups[0]) { Console.WriteLine(instance.PinName); } }
void sim_Click(object sender, EventArgs e) { WorkPath path = new WorkPath("c:\\cats\\lab1_xx.ise", null, inkCol.Ink); //path.Go(); }